@paramms/chat-widget 1.9.0 → 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.
package/dist/embed.js CHANGED
@@ -1,8 +1,11 @@
1
1
  var RelayEmbed=function(te){"use strict";var fi=Object.defineProperty;var wi=(te,J,pe)=>J in te?fi(te,J,{enumerable:!0,configurable:!0,writable:!0,value:pe}):te[J]=pe;var c=(te,J,pe)=>wi(te,typeof J!="symbol"?J+"":J,pe);const J="oc_uid";function pe(t){try{const e=document.cookie.match(new RegExp(`(?:^|; )${t}=([^;]*)`));return e?decodeURIComponent(e[1]):null}catch{return null}}function zt(t,e){try{const o=location.protocol==="https:"?"; Secure":"";document.cookie=`${t}=${encodeURIComponent(e)}; Max-Age=31536000; Path=/; SameSite=Lax${o}`}catch{}}function Mt(){return`g_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`}function it(){let t=null;try{t=localStorage.getItem(J)}catch{}t||(t=pe(J));const e=t??Mt();try{localStorage.setItem(J,e)}catch{}return zt(J,e),e}function Kt(t){const e=t.length;let n=0,o=0;for(;o<e;){let i=t.charCodeAt(o++);if(i&4294967168)if(!(i&4294965248))n+=2;else{if(i>=55296&&i<=56319&&o<e){const s=t.charCodeAt(o);(s&64512)===56320&&(++o,i=((i&1023)<<10)+(s&1023)+65536)}i&4294901760?n+=4:n+=3}else{n++;continue}}return n}function $t(t,e,n){const o=t.length;let i=n,s=0;for(;s<o;){let r=t.charCodeAt(s++);if(r&4294967168)if(!(r&4294965248))e[i++]=r>>6&31|192;else{if(r>=55296&&r<=56319&&s<o){const p=t.charCodeAt(s);(p&64512)===56320&&(++s,r=((r&1023)<<10)+(p&1023)+65536)}r&4294901760?(e[i++]=r>>18&7|240,e[i++]=r>>12&63|128,e[i++]=r>>6&63|128):(e[i++]=r>>12&15|224,e[i++]=r>>6&63|128)}else{e[i++]=r;continue}e[i++]=r&63|128}}const Rt=new TextEncoder,Dt=50;function _t(t,e,n){Rt.encodeInto(t,e.subarray(n))}function jt(t,e,n){t.length>Dt?_t(t,e,n):$t(t,e,n)}const Nt=4096;function ot(t,e,n){let o=e;const i=o+n,s=[];let r="";for(;o<i;){const p=t[o++];if(!(p&128))s.push(p);else if((p&224)===192){const a=t[o++]&63;s.push((p&31)<<6|a)}else if((p&240)===224){const a=t[o++]&63,w=t[o++]&63;s.push((p&31)<<12|a<<6|w)}else if((p&248)===240){const a=t[o++]&63,w=t[o++]&63,f=t[o++]&63;let h=(p&7)<<18|a<<12|w<<6|f;h>65535&&(h-=65536,s.push(h>>>10&1023|55296),h=56320|h&1023),s.push(h)}else s.push(p);s.length>=Nt&&(r+=String.fromCharCode(...s),s.length=0)}return s.length>0&&(r+=String.fromCharCode(...s)),r}const qt=new TextDecoder,Ht=200;function Ot(t,e,n){const o=t.subarray(e,e+n);return qt.decode(o)}function Ft(t,e,n){return n>Ht?Ot(t,e,n):ot(t,e,n)}class Pe{constructor(e,n){c(this,"type");c(this,"data");this.type=e,this.data=n}}class G extends Error{constructor(e){super(e);const n=Object.create(G.prototype);Object.setPrototypeOf(this,n),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:G.name})}}const xe=4294967295;function Wt(t,e,n){const o=n/4294967296,i=n;t.setUint32(e,o),t.setUint32(e+4,i)}function st(t,e,n){const o=Math.floor(n/4294967296),i=n;t.setUint32(e,o),t.setUint32(e+4,i)}function rt(t,e){const n=t.getInt32(e),o=t.getUint32(e+4);return n*4294967296+o}function Vt(t,e){const n=t.getUint32(e),o=t.getUint32(e+4);return n*4294967296+o}const Xt=-1,Gt=4294967296-1,Yt=17179869184-1;function Jt({sec:t,nsec:e}){if(t>=0&&e>=0&&t<=Yt)if(e===0&&t<=Gt){const n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,t),n}else{const n=t/4294967296,o=t&4294967295,i=new Uint8Array(8),s=new DataView(i.buffer);return s.setUint32(0,e<<2|n&3),s.setUint32(4,o),i}else{const n=new Uint8Array(12),o=new DataView(n.buffer);return o.setUint32(0,e),st(o,4,t),n}}function Zt(t){const e=t.getTime(),n=Math.floor(e/1e3),o=(e-n*1e3)*1e6,i=Math.floor(o/1e9);return{sec:n+i,nsec:o-i*1e9}}function Qt(t){if(t instanceof Date){const e=Zt(t);return Jt(e)}else return null}function en(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),o=e.getUint32(4),i=(n&3)*4294967296+o,s=n>>>2;return{sec:i,nsec:s}}case 12:{const n=rt(e,4),o=e.getUint32(0);return{sec:n,nsec:o}}default:throw new G(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${t.length}`)}}function tn(t){const e=en(t);return new Date(e.sec*1e3+e.nsec/1e6)}const nn={type:Xt,encode:Qt,decode:tn},Ke=class Ke{constructor(){c(this,"__brand");c(this,"builtInEncoders",[]);c(this,"builtInDecoders",[]);c(this,"encoders",[]);c(this,"decoders",[]);this.register(nn)}register({type:e,encode:n,decode:o}){if(e>=0)this.encoders[e]=n,this.decoders[e]=o;else{const i=-1-e;this.builtInEncoders[i]=n,this.builtInDecoders[i]=o}}tryToEncode(e,n){for(let o=0;o<this.builtInEncoders.length;o++){const i=this.builtInEncoders[o];if(i!=null){const s=i(e,n);if(s!=null){const r=-1-o;return new Pe(r,s)}}}for(let o=0;o<this.encoders.length;o++){const i=this.encoders[o];if(i!=null){const s=i(e,n);if(s!=null){const r=o;return new Pe(r,s)}}}return e instanceof Pe?e:null}decode(e,n,o){const i=n<0?this.builtInDecoders[-1-n]:this.decoders[n];return i?i(e,n,o):new Pe(n,e)}};c(Ke,"defaultCodec",new Ke);let Be=Ke;function on(t){return t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer}function je(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):on(t)?new Uint8Array(t):Uint8Array.from(t)}const sn=100,rn=2048;class Ne{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)??sn,this.initialBufferSize=(e==null?void 0:e.initialBufferSize)??rn,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 Ne({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),o=new Uint8Array(n),i=new DataView(n);o.set(this.bytes),this.view=i,this.bytes=o}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 o=Kt(e);this.ensureBufferSizeToWrite(5+o),this.writeStringHeader(o),jt(e,this.bytes,this.pos),this.pos+=o}encodeObject(e,n){const o=this.extensionCodec.tryToEncode(e,this.context);if(o!=null)this.encodeExtension(o);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 o=je(e);this.writeU8a(o)}encodeArray(e,n){const o=e.length;if(o<16)this.writeU8(144+o);else if(o<65536)this.writeU8(220),this.writeU16(o);else if(o<4294967296)this.writeU8(221),this.writeU32(o);else throw new Error(`Too large array: ${o}`);for(const i of e)this.doEncode(i,n+1)}countWithoutUndefined(e,n){let o=0;for(const i of n)e[i]!==void 0&&o++;return o}encodeMap(e,n){const o=Object.keys(e);this.sortKeys&&o.sort();const i=this.ignoreUndefined?this.countWithoutUndefined(e,o):o.length;if(i<16)this.writeU8(128+i);else if(i<65536)this.writeU8(222),this.writeU16(i);else if(i<4294967296)this.writeU8(223),this.writeU32(i);else throw new Error(`Too large map object: ${i}`);for(const s of o){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 o=e.data(this.pos+6),i=o.length;if(i>=4294967296)throw new Error(`Too large extension object: ${i}`);this.writeU8(201),this.writeU32(i),this.writeI8(e.type),this.writeU8a(o);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),Wt(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),st(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 an(t,e){return new Ne(e).encodeSharedRef(t)}function qe(t){return`${t<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`}const cn=16,ln=16;class dn{constructor(e=cn,n=ln){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 o=0;o<this.maxKeyLength;o++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,n,o){const i=this.caches[o-1];e:for(const s of i){const r=s.bytes;for(let p=0;p<o;p++)if(r[p]!==e[n+p])continue e;return s.str}return null}store(e,n){const o=this.caches[e.length-1],i={bytes:e,str:n};o.length>=this.maxLengthPerKey?o[Math.random()*o.length|0]=i:o.push(i)}decode(e,n,o){const i=this.find(e,n,o);if(i!=null)return this.hit++,i;this.miss++;const s=ot(e,n,o),r=Uint8Array.prototype.slice.call(e,n,n+o);return this.store(r,s),s}}const He="array",me="map_key",at="map_value",hn=t=>{if(typeof t=="string"||typeof t=="number")return t;throw new G("The type of key must be string or number but "+typeof t)};class pn{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=He,n.position=0,n.size=e,n.array=new Array(e)}pushMapState(e){const n=this.getUninitializedStateFromPool();n.type=me,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===He){const o=e;o.size=0,o.array=void 0,o.position=0,o.type=void 0}if(e.type===me||e.type===at){const o=e;o.size=0,o.map=void 0,o.readCount=0,o.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}const be=-1,Oe=new DataView(new ArrayBuffer(0)),un=new Uint8Array(Oe.buffer);try{Oe.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 ct=new RangeError("Insufficient data"),fn=new dn;class Fe{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",Oe);c(this,"bytes",un);c(this,"headByte",be);c(this,"stack",new pn);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)??xe,this.maxBinLength=(e==null?void 0:e.maxBinLength)??xe,this.maxArrayLength=(e==null?void 0:e.maxArrayLength)??xe,this.maxMapLength=(e==null?void 0:e.maxMapLength)??xe,this.maxExtLength=(e==null?void 0:e.maxExtLength)??xe,this.keyDecoder=(e==null?void 0:e.keyDecoder)!==void 0?e.keyDecoder:fn,this.mapKeyConverter=(e==null?void 0:e.mapKeyConverter)??hn}clone(){return new Fe({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=be,this.stack.reset()}setBuffer(e){const n=je(e);this.bytes=n,this.view=new DataView(n.buffer,n.byteOffset,n.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===be&&!this.hasRemaining(1))this.setBuffer(e);else{const n=this.bytes.subarray(this.pos),o=je(e),i=new Uint8Array(n.length+o.length);i.set(n),i.set(o,n.length),this.setBuffer(i)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){const{view:n,pos:o}=this;return new RangeError(`Extra ${n.byteLength-o} 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,o;for await(const p of e){if(n)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(p);try{o=this.doDecodeSync(),n=!0}catch(a){if(!(a instanceof RangeError))throw a}this.totalPos+=this.pos}if(n){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return o}const{headByte:i,pos:s,totalPos:r}=this;throw new RangeError(`Insufficient data in parsing ${qe(i)} 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 o=n,i=-1;for await(const s of e){if(n&&i===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(s),o&&(i=this.readArraySize(),o=!1,this.complete());try{for(;yield this.doDecodeSync(),--i!==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 i=e-128;if(i!==0){this.pushMapState(i),this.complete();continue e}else n={}}else if(e<160){const i=e-144;if(i!==0){this.pushArrayState(i),this.complete();continue e}else n=[]}else{const i=e-160;n=this.decodeString(i,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 i=this.lookU8();n=this.decodeString(i,1)}else if(e===218){const i=this.lookU16();n=this.decodeString(i,2)}else if(e===219){const i=this.lookU32();n=this.decodeString(i,4)}else if(e===220){const i=this.readU16();if(i!==0){this.pushArrayState(i),this.complete();continue e}else n=[]}else if(e===221){const i=this.readU32();if(i!==0){this.pushArrayState(i),this.complete();continue e}else n=[]}else if(e===222){const i=this.readU16();if(i!==0){this.pushMapState(i),this.complete();continue e}else n={}}else if(e===223){const i=this.readU32();if(i!==0){this.pushMapState(i),this.complete();continue e}else n={}}else if(e===196){const i=this.lookU8();n=this.decodeBinary(i,1)}else if(e===197){const i=this.lookU16();n=this.decodeBinary(i,2)}else if(e===198){const i=this.lookU32();n=this.decodeBinary(i,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 i=this.lookU8();n=this.decodeExtension(i,1)}else if(e===200){const i=this.lookU16();n=this.decodeExtension(i,2)}else if(e===201){const i=this.lookU32();n=this.decodeExtension(i,4)}else throw new G(`Unrecognized type byte: ${qe(e)}`);this.complete();const o=this.stack;for(;o.length>0;){const i=o.top();if(i.type===He)if(i.array[i.position]=n,i.position++,i.position===i.size)n=i.array,o.release(i);else continue e;else if(i.type===me){if(n==="__proto__")throw new G("The key __proto__ is not allowed");i.key=this.mapKeyConverter(n),i.type=at;continue e}else if(i.map[i.key]=n,i.readCount++,i.readCount===i.size)n=i.map,o.release(i);else{i.key=null,i.type=me;continue e}}return n}}readHeadByte(){return this.headByte===be&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=be}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 G(`Unrecognized array type byte: ${qe(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new G(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new G(`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 G(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+n+e)throw ct;const o=this.pos+n;let i;return this.stateIsMapKey()&&((s=this.keyDecoder)!=null&&s.canBeCached(e))?i=this.keyDecoder.decode(this.bytes,o,e):i=Ft(this.bytes,o,e),this.pos+=n+e,i}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===me:!1}decodeBinary(e,n){if(e>this.maxBinLength)throw new G(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+n))throw ct;const o=this.pos+n,i=this.bytes.subarray(o,o+e);return this.pos+=n+e,i}decodeExtension(e,n){if(e>this.maxExtLength)throw new G(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);const o=this.view.getInt8(this.pos+n),i=this.decodeBinary(e,n+1);return this.extensionCodec.decode(i,o,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=Vt(this.view,this.pos);return this.pos+=8,e}readI64(){const e=rt(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 wn(t,e){return new Fe(e).decode(t)}const gn=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 yn(t){return gn.has(t.type)}function We(t){return an(t)}function lt(t){let e;try{e=wn(t)}catch{return null}return typeof e!="object"||e===null||typeof e.type!="string"?null:e}class xn{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 o=e.status==="pending",i=n.status==="pending";return o!==i?o?1:-1:o&&i?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 o={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,o),this.keyByClient.set(e,e),this._sorted=null,o}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 o=this.keyByClient.get(e.clientMsgId),i=o?this.byId.get(o):void 0;if(i&&o){this.byId.delete(o);const s={...i,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 o of e.messages)this.upsert({...o});return;case"history":for(const o of e.messages)this.upsert({...o});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 o=this.byId.get(e.messageId);if(!o)return;const i={...o.reactions??{}},s=(i[e.emoji]??[]).filter(r=>r!==e.by);e.removed||s.push(e.by),s.length?i[e.emoji]=s:delete i[e.emoji],this.byId.set(e.messageId,{...o,reactions:i}),this._sorted=null;return}case"edited":{const o=this.byId.get(e.messageId);o&&(this.byId.set(e.messageId,{...o,content:e.content,editedAt:e.editedAt}),this._sorted=null);return}case"deleted":{const o=this.byId.get(e.messageId);o&&(this.byId.set(e.messageId,{...o,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 o=dt(n);let i=!1;for(const[s,r]of this.byId)r.senderId!==this.me||r.seq<=0||r.seq>e||dt(r.status)>=o||(this.byId.set(s,{...r,status:n}),i=!0);i&&(this._sorted=null)}}function dt(t){switch(t){case"read":return 3;case"delivered":return 2;case"sent":return 1;default:return 0}}class mn{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 o,i;if(this.state==="connecting"||this.state==="open")return;this.stopped=!1,this.state="connecting",this.authed=!1,(i=(o=this.opts).onStatusChange)==null||i.call(o,this.attempt>0?"reconnecting":"connecting");const n=(this.opts.socketFactory??kn)(this.opts.url);n.binaryType="arraybuffer",this.socket=n,n.onopen=()=>{this.raw({type:"auth",token:this.opts.token})},n.onmessage=s=>{const r=lt(new Uint8Array(s.data));!r||yn(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,o,i,s;if(e.type==="authed"&&(this.attempt=0,this.state="open",this.authed=!0,this.everAuthed=!0,(o=(n=this.opts).onStatusChange)==null||o.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"&&bn.has(e.code)){if(e.code==="UNAUTHORIZED"&&this.opts.refreshToken&&!this.refreshing){this.refreshing=!0,(s=(i=this.opts).onStatusChange)==null||s.call(i,"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,o,i;this.stopped=!0;try{(n=this.socket)==null||n.close()}catch{}this.state="closed",(i=(o=this.opts).onStatusChange)==null||i.call(o,"error",vn(e.code)),this.opts.onFrame(e)}flush(e){const n=this.outbox;this.outbox=[];for(const o of n)this.raw(e&&o.type==="send"&&o.conversationId!==e?{...o,conversationId:e}:o)}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(We(e))}catch{this.queue(e)}}onClosed(){var i,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,o=Math.min(n,e*2**this.attempt)*(.5+Math.random()*.5);this.attempt++,this.attempt>=3&&!this.everAuthed&&((s=(i=this.opts).onStatusChange)==null||s.call(i,"reconnecting","Can't reach chat — retrying…")),this.timer=setTimeout(()=>this.connect(),o)}}const bn=new Set(["UNAUTHORIZED"]);function vn(t){switch(t){case"UNAUTHORIZED":return"Chat unavailable — sign-in/token was rejected";default:return"Chat unavailable"}}function kn(t){return new WebSocket(t)}const ht=200,Sn=7*864e5;class In{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),o=Date.now()-Sn,i=n.filter(s=>s.ts>=o);return i.length!==n.length&&this.save(i),i}catch{return[]}}add(e){try{const n=this.load();n.push(e),this.save(n.length>ht?n.slice(n.length-ht):n)}catch{}}remove(e){try{const n=this.load().filter(o=>o.clientMsgId!==e);this.save(n)}catch{}}save(e){try{localStorage.setItem(this.key,JSON.stringify(e))}catch{}}}const D=()=>globalThis.crypto.subtle;function Ae(t){const e=t instanceof Uint8Array?t:new Uint8Array(t);let n="";for(const o of e)n+=String.fromCharCode(o);return btoa(n)}function Ve(t){const e=atob(t),n=new ArrayBuffer(e.length),o=new Uint8Array(n);for(let i=0;i<e.length;i++)o[i]=e.charCodeAt(i);return o}async function ve(){const t=await D().generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey","deriveBits"]);return{publicKey:t.publicKey,privateKey:t.privateKey}}async function re(t){return Ae(await D().exportKey("raw",t))}async function ue(t){return D().importKey("raw",Ve(t),{name:"ECDH",namedCurve:"P-256"},!1,[])}async function Cn(t,e){const n=await ue(e);return D().deriveKey({name:"ECDH",public:n},t,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function Tn(t,e){const n=globalThis.crypto.getRandomValues(new Uint8Array(12)),o=new TextEncoder().encode(e),i=await D().encrypt({name:"AES-GCM",iv:n},t,o);return{ct:Ae(i),iv:Ae(n)}}async function En(t,e,n){const o=await D().decrypt({name:"AES-GCM",iv:Ve(n)},t,Ve(e));return new TextDecoder().decode(o)}async function Un(t){var n,o;try{const i=(n=globalThis.localStorage)==null?void 0:n.getItem(t);if(i){const{pub:s,priv:r}=JSON.parse(i),p=await D().importKey("jwk",s,{name:"ECDH",namedCurve:"P-256"},!0,[]),a=await D().importKey("jwk",r,{name:"ECDH",namedCurve:"P-256"},!0,["deriveKey","deriveBits"]);return{publicKey:p,privateKey:a}}}catch{}const e=await ve();try{const i=await D().exportKey("jwk",e.publicKey),s=await D().exportKey("jwk",e.privateKey);(o=globalThis.localStorage)==null||o.setItem(t,JSON.stringify({pub:i,priv:s}))}catch{}return e}async function Pn(t,e){const n=await D().exportKey("raw",e),o=await D().sign({name:"ECDSA",hash:"SHA-256"},t,n);return Ae(o)}async function Bn(){const t=await ve(),e=await D().generateKey({name:"ECDSA",namedCurve:"P-256"},!0,["sign","verify"]);return{ecdhKP:t,ecdsaKP:{publicKey:e.publicKey,privateKey:e.privateKey},publicKeyB64:await re(t.publicKey),sigPublicKeyB64:await re(e.publicKey)}}async function pt(t){var n,o;try{const i=(n=globalThis.localStorage)==null?void 0:n.getItem(`${t}-identity`);if(i){const s=JSON.parse(i),r=await D().importKey("jwk",s.ecdhPub,{name:"ECDH",namedCurve:"P-256"},!0,[]),p=await D().importKey("jwk",s.ecdhPriv,{name:"ECDH",namedCurve:"P-256"},!0,["deriveKey","deriveBits"]),a=await D().importKey("jwk",s.ecdsaPub,{name:"ECDSA",namedCurve:"P-256"},!0,["verify"]),w=await D().importKey("jwk",s.ecdsaPriv,{name:"ECDSA",namedCurve:"P-256"},!0,["sign"]);return{ecdhKP:{publicKey:r,privateKey:p},ecdsaKP:{publicKey:a,privateKey:w},publicKeyB64:await re(r),sigPublicKeyB64:await re(a)}}}catch{}const e=await Bn();try{const i=await D().exportKey("jwk",e.ecdhKP.publicKey),s=await D().exportKey("jwk",e.ecdhKP.privateKey),r=await D().exportKey("jwk",e.ecdsaKP.publicKey),p=await D().exportKey("jwk",e.ecdsaKP.privateKey);(o=globalThis.localStorage)==null||o.setItem(`${t}-identity`,JSON.stringify({ecdhPub:i,ecdhPriv:s,ecdsaPub:r,ecdsaPriv:p}))}catch{}return e}async function An(t,e){const n=await ve(),o=await re(n.publicKey),i=await ue(e.identityKey),s=await ue(e.signedPrekey),r=e.oneTimePrekey?await ue(e.oneTimePrekey):null,p=await ae(t.privateKey,s),a=await ae(n.privateKey,i),w=await ae(n.privateKey,s),f=r?await ae(n.privateKey,r):null,h=ut(p,a,w,...f?[f]:[]);return{sharedKey:await ft(h),ephemeralPublicKey:o}}async function Ln(t,e,n,o,i){const s=await ue(n),r=await ue(o),p=await ae(e.privateKey,s),a=await ae(t.privateKey,r),w=await ae(e.privateKey,r),f=i?await ae(i.privateKey,r):null,h=ut(p,a,w,...f?[f]:[]);return ft(h)}async function ae(t,e){return D().deriveBits({name:"ECDH",public:e},t,256)}function ut(...t){const e=t.reduce((i,s)=>i+s.byteLength,0),n=new Uint8Array(e);let o=0;for(const i of t)n.set(new Uint8Array(i),o),o+=i.byteLength;return n.buffer}async function ft(t){const e=await D().importKey("raw",t,"HKDF",!1,["deriveKey"]);return D().deriveKey({name:"HKDF",hash:"SHA-256",salt:new Uint8Array(32),info:new TextEncoder().encode("ObjectChat X3DH v1")},e,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}const zn=20;class Mn{constructor(e){c(this,"kp");c(this,"shared");c(this,"identityKP");c(this,"signedPreKP");c(this,"signedPrekeyId");c(this,"otpKeys",[]);c(this,"x3dhShared");c(this,"pendingX3DH");this.storageKey=e}get ready(){return!!(this.shared??this.x3dhShared)}async begin(){return this.kp=await Un(this.storageKey),re(this.kp.publicKey)}async onPeerKey(e){this.kp&&(this.shared=await Cn(this.kp.privateKey,e))}async initX3DH(){this.identityKP=await pt(this.storageKey),this.signedPreKP=await ve(),this.signedPrekeyId=`spk-${Date.now()}-${Math.random().toString(36).slice(2)}`;for(let i=0;i<zn;i++)this.otpKeys.push(await ve());const e=await re(this.signedPreKP.publicKey),n=await Pn(this.identityKP.ecdsaKP.privateKey,this.signedPreKP.publicKey),o=await Promise.all(this.otpKeys.map(i=>re(i.publicKey)));return{identityKey:this.identityKP.publicKeyB64,signedPrekey:e,signedPrekeyId:this.signedPrekeyId,signature:n,oneTimePrekeys:o}}async x3dhSendTo(e){this.identityKP||(this.identityKP=await pt(this.storageKey));const{sharedKey:n,ephemeralPublicKey:o}=await An(this.identityKP.ecdhKP,e);return this.x3dhShared=n,{ephemeralKey:o,spkId:e.signedPrekeyId,usedOTP:!!e.oneTimePrekey,senderIK:this.identityKP.publicKeyB64}}async x3dhReceiveFrom(e,n,o,i){if(!this.identityKP||!this.signedPreKP){this.pendingX3DH={senderIK:e,ephemeralKey:n,spkId:o,usedOTP:i};return}const s=i?this.otpKeys.shift():void 0;this.x3dhShared=await Ln(this.identityKP.ecdhKP,this.signedPreKP,e,n,s)}async flushPendingX3DH(){if(!this.pendingX3DH)return;const{senderIK:e,ephemeralKey:n,spkId:o,usedOTP:i}=this.pendingX3DH;this.pendingX3DH=void 0,await this.x3dhReceiveFrom(e,n,o,i)}async sealText(e,n){const o=this.x3dhShared??this.shared;if(!o)throw new Error("secure channel not ready");const{ct:i,iv:s}=await Tn(o,e);return{kind:"text",text:i,enc:!0,iv:s,...n?{x3dhEK:n.ephemeralKey,x3dhSPK:n.spkId,x3dhIK:n.senderIK,x3dhOTP:n.usedOTP}:{}}}async openContent(e){if(e.kind!=="text"||!e.enc||!e.iv)return e;const n=this.x3dhShared??this.shared;if(!n)return{kind:"text",text:"🔒 encrypted"};try{return{kind:"text",text:await En(n,e.text,e.iv)}}catch{return{kind:"text",text:"🔒 unable to decrypt"}}}async openFrame(e){if(e.type==="message")e.message.content=await this.openContent(e.message.content);else if(e.type==="sync")for(const n of e.messages)n.content=await this.openContent(n.content)}}function Kn(t){if(t.kind!=="text"||!t.enc)return null;const e=t;return!e.x3dhEK||!e.x3dhSPK||!e.x3dhIK?null:{x3dhEK:e.x3dhEK,x3dhSPK:e.x3dhSPK,x3dhIK:e.x3dhIK,x3dhOTP:e.x3dhOTP??!1}}const $n={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)"},Rn={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)"},Dn="'Nunito',-apple-system,BlinkMacSystemFont,'Segoe UI',system-ui,sans-serif";function wt(t,e){return Object.entries(e).map(([n,o])=>`--${t}-${n}:${o};`).join(" ")}function gt(t){return`${wt(t,$n)} --${t}-fb:${Dn}; --${t}-fh:'Baloo 2',var(--${t}-fb);`}function Le(t){return wt(t,Rn)}const _n=`
2
2
  .ocw { ${gt("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"] { ${Le("ocw")} } }
7
10
  .ocw[data-theme="dark"] { ${Le("ocw")} }
8
11
  /* ── Responsive sizing ──────────────────────────────────────────────────────
@@ -50,7 +53,7 @@ var RelayEmbed=function(te){"use strict";var fi=Object.defineProperty;var wi=(te
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 RelayEmbed=function(te){"use strict";var fi=Object.defineProperty;var wi=(te
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; }
@@ -184,12 +188,11 @@ var RelayEmbed=function(te){"use strict";var fi=Object.defineProperty;var wi=(te
184
188
  .ocw-sendbtn:disabled { opacity:.5; cursor:default; }
185
189
  .ocw-sendbtn:focus-visible, .ocw-back:focus-visible, .ocw-chip:focus-visible { outline:2px solid var(--ocw-accent); outline-offset:2px; }
186
190
 
187
- .ocw-translate-btn { position:absolute; bottom:2px; right:-26px; background:var(--ocw-card); border:1px solid var(--ocw-line); border-radius:50%; width:22px; height:22px; font-size:11px; cursor:pointer; color:var(--ocw-mut); display:flex; align-items:center; justify-content:center; opacity:0; transition:opacity .15s; padding:0; }
188
- .ocw-row.theirs .ocw-translate-btn { right:auto; left:-26px; }
189
- .ocw-bubble-wrap:hover .ocw-translate-btn { opacity:1; }
191
+ .ocw-translate-btn { display:inline-flex; align-items:center; gap:4px; margin-top:3px; background:none; border:none; padding:2px 0; font-size:11px; line-height:1; cursor:pointer; color:var(--ocw-mut); opacity:.85; }
192
+ .ocw-translate-btn:hover { opacity:1; text-decoration:underline; }
190
193
  .ocw-translation { margin-top:6px; padding-top:6px; border-top:1px solid var(--ocw-line); font-size:13px; line-height:1.45; }
191
194
  .ocw-translation::before { content:'🌐 '; opacity:.75; }
192
- `,yt="objectchat-widget-styles",jn=["👍","❤️","😂","😮","😢","🙏"],Nn=400,qn='<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M22 2 11 13M22 2l-7 20-4-9-9-4 20-7z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';function Hn(){if(typeof document>"u"||document.getElementById(yt))return;const t=document.createElement("style");t.id=yt,t.textContent=_n,document.head.appendChild(t)}const xt="ocw-webfont";function On(){if(typeof document>"u"||document.getElementById(xt))return;const t=document.createElement("link");t.id=xt,t.rel="stylesheet",t.href="https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700&family=Nunito:wght@400;500;600;700&display=swap",document.head.appendChild(t)}function l(t,e,n){const o=document.createElement(t);return e&&(o.className=e),n!==void 0&&(o.textContent=n),o}function Fn(t,e){const n=/(https?:\/\/[^\s]+)/g;let o=0,i=null,s;for(;(s=n.exec(e))!==null;){if(s.index>o){const h=document.createTextNode(e.slice(o,s.index));t.append(h),i??(i=h)}let p=s[0],a="";const w=/[).,!?;:]+$/.exec(p);w&&(a=w[0],p=p.slice(0,-a.length));const f=document.createElement("a");f.href=p,f.target="_blank",f.rel="noopener noreferrer",f.textContent=p,f.style.cssText="color:inherit;text-decoration:underline;word-break:break-all",t.append(f),a&&t.append(document.createTextNode(a)),o=s.index+s[0].length}const r=document.createTextNode(e.slice(o));return t.append(r),i??(i=r),i}function Wn(t){try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function Xe(t){var e;switch(t.kind){case"text":return t.text;case"system":return typeof((e=t.data)==null?void 0:e.message)=="string"?String(t.data.message):t.event;case"card":return[t.title,t.body].filter(Boolean).join(" — ");case"attachment":return t.name??t.url;case"form":return t.prompt;case"appointment":return`📅 ${t.title} — ${new Date(t.startIso).toLocaleString()}`}}class Vn{constructor(e,n,o,i={}){c(this,"scroll");c(this,"chips");c(this,"typing");c(this,"quick");c(this,"formHost");c(this,"csatPanel");c(this,"awayNotice");c(this,"headStatus");c(this,"reopenBtn");c(this,"preChatPanel");c(this,"deflectPanel");c(this,"preChatBuilt",!1);c(this,"preChatDone",!1);c(this,"footer");c(this,"input");c(this,"subjectCard");c(this,"e2eBadge");c(this,"statusBadge");c(this,"headerName");c(this,"connStatus");c(this,"typingTimer",null);c(this,"csatSubmitted",!1);c(this,"sendBtn");c(this,"compactObserver",null);c(this,"storeRef",null);c(this,"cfgAccent2");c(this,"scrollCleanup",null);c(this,"translationCache",new Map);c(this,"showingTranslation",new Set);c(this,"subjectBuilt",!1);var _,F,U,Z,B,g,u,b,m,C,T;this.root=e,this.me=n,this.h=o,this.cfg=i,Hn(),i.webfont!==!1&&On(),e.replaceChildren(),e.classList.add("ocw"),i.accent&&e.style.setProperty("--ocw-accent",i.accent);const s=i.accent2??i.accent;s&&e.style.setProperty("--ocw-accent2",s),this.cfgAccent2=i.accent2,e.dataset.theme=i.theme??"light";const r=l("div","ocw-head");if(this.h.onBack){const v=l("button","ocw-back","‹");v.type="button",v.setAttribute("aria-label","Back"),v.addEventListener("click",()=>this.h.onBack()),r.append(v)}const p=((_=i.subject)==null?void 0:_.ownerLabel)??((F=i.subject)==null?void 0:F.title)??"",a=l("div","ocw-avatar");p.trim()&&(a.textContent=p.trim()[0].toUpperCase(),r.append(a));const w=l("div","ocw-head-main");this.headerName=l("div","ocw-head-name",((U=i.subject)==null?void 0:U.ownerLabel)??((Z=i.subject)==null?void 0:Z.title)??""),w.append(this.headerName),this.headStatus=l("div","ocw-head-status"),this.headStatus.style.display="none",w.append(this.headStatus),(B=i.subject)!=null&&B.subtitle&&w.append(l("div","ocw-head-meta",i.subject.subtitle)),r.append(w),this.statusBadge=l("span","ocw-badge",((g=i.subject)==null?void 0:g.status)??""),(u=i.subject)!=null&&u.status||(this.statusBadge.style.display="none"),r.append(this.statusBadge),this.e2eBadge=l("span","ocw-e2e","🔒 E2E"),this.e2eBadge.style.display="none",r.append(this.e2eBadge),this.connStatus=l("span","ocw-conn-status"),this.connStatus.style.display="none",r.append(this.connStatus),r.append(l("button","ocw-menu","⋯")),this.chips=l("div","ocw-chiprow"),this.scroll=l("div","ocw-scroll"),this.subjectCard=l("div","ocw-subject"),this.typing=l("div","ocw-typing");const f=l("div","ocw-typing-bubble");f.append(l("div","ocw-typing-dot"),l("div","ocw-typing-dot"),l("div","ocw-typing-dot")),this.typing.append(f),this.quick=l("div","ocw-quick");for(const v of i.quickReplies??[]){const P=l("button",void 0,v);P.addEventListener("click",()=>{this.h.onSend(v),this.quick.style.display="none"}),this.quick.append(P)}this.formHost=l("div","ocw-form-host"),this.csatPanel=l("div","ocw-csat"),this.csatPanel.style.display="none",this.awayNotice=l("div","ocw-away"),this.awayNotice.style.display="none",this.preChatPanel=l("div","ocw-prechat"),this.preChatPanel.style.display="none",this.deflectPanel=l("div","ocw-deflect"),this.deflectPanel.style.display="none",this.input=l("textarea",void 0),this.input.rows=1,this.input.placeholder=((b=i.i18n)==null?void 0:b.placeholder)??"Message…";const h=l("button","ocw-sendbtn");h.type="button";const y=(m=i.i18n)==null?void 0:m.send;y?(h.textContent=y,h.classList.add("ocw-sendbtn-label"),h.setAttribute("aria-label",y)):(h.innerHTML=qn,h.setAttribute("aria-label","Send message")),h.disabled=!0,this.sendBtn=h,h.addEventListener("click",()=>this.flushSend()),this.input.addEventListener("input",()=>{var v,P;this.sendBtn.disabled=this.input.value.trim().length===0,this.autoGrowInput(),this.storeRef&&!this.storeRef.messages().some(A=>A.senderRole==="guest")?(P=(v=this.h).onDeflectQuery)==null||P.call(v,this.input.value):this.hideDeflection()}),this.input.addEventListener("keydown",v=>{v.isComposing||v.keyCode===229||(v.key==="Enter"&&!v.shiftKey?(v.preventDefault(),this.flushSend()):this.signalTyping())});const S=l("button","ocw-attach","📎");S.title="Attach image or file";const E=document.createElement("input");E.type="file",E.accept="image/*,.pdf,.txt,.doc,.docx",E.style.display="none",S.addEventListener("click",()=>E.click()),E.addEventListener("change",()=>{var v;(v=E.files)!=null&&v[0]&&this.h.onAttach&&this.h.onAttach(E.files[0]),E.value=""});const z=l("div","ocw-input");z.append(S,E,this.input,h);const K=l("div","ocw-footer");((C=i.i18n)==null?void 0:C.poweredBy)!==void 0?K.textContent=i.i18n.poweredBy:K.innerHTML='Powered by <a href="https://relay.paramms.com" target="_blank" rel="noopener">Relay</a>',this.footer=K,this.reopenBtn=l("button","ocw-reopen",((T=this.cfg.i18n)==null?void 0:T.reopen)??"Reopen conversation"),this.reopenBtn.type="button",this.reopenBtn.addEventListener("click",()=>{this.reopenBtn.style.display="none";const v=this.root.querySelector(".ocw-input textarea");v==null||v.focus()}),e.append(r,this.chips,this.scroll,this.typing,this.quick,this.formHost,this.csatPanel,this.preChatPanel,this.deflectPanel,this.awayNotice,z,this.reopenBtn,this.footer);const $=v=>{e.classList.toggle("ocw-compact",v>0&&v<Nn)};$(e.clientWidth),typeof ResizeObserver<"u"&&(this.compactObserver=new ResizeObserver(v=>{var A;const P=((A=v[0])==null?void 0:A.contentRect.width)??e.clientWidth;$(P)}),this.compactObserver.observe(e))}getScrollEl(){return this.scroll}setScrollCleanup(e){var n;(n=this.scrollCleanup)==null||n.call(this),this.scrollCleanup=e}destroy(){var e,n;(e=this.scrollCleanup)==null||e.call(this),this.scrollCleanup=null,this.typingTimer&&(clearTimeout(this.typingTimer),this.typingTimer=null),(n=this.compactObserver)==null||n.disconnect(),this.compactObserver=null}flushSend(){this.hideDeflection();const e=this.input.value.trim();e&&(this.input.value="",this.sendBtn.disabled=!0,this.autoGrowInput(),this.h.onTyping(!1),this.h.onSend(e))}autoGrowInput(){this.input.style.height="auto";const e=this.input.scrollHeight;e>0?this.input.style.height=`${Math.min(e,120)}px`:this.input.style.removeProperty("height")}signalTyping(){const e=this.input.value.trim().slice(0,100)||void 0;this.h.onTyping(!0,e),this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=setTimeout(()=>this.h.onTyping(!1),2e3)}setBotName(e){this.cfg.i18n={...this.cfg.i18n??{},aiAssistant:e}}render(e){var E,z,K,$,_,F,U,Z;if(this.storeRef=e,e.accent&&(this.root.style.setProperty("--ocw-accent",e.accent),this.root.style.setProperty("--ocw-accent2",this.cfgAccent2??e.accent)),this.e2eBadge.style.display=e.e2e?"inline-flex":"none",this.buildSubjectCard(e),e.subject){const B=(E=this.cfg.subject)==null?void 0:E.ownerLabel;B&&(this.headerName.textContent=B)}this.quick.style.display=e.messages().length===0?"flex":"none",this.chips.replaceChildren();const n=e.visibleActions();this.chips.style.display=n.length?"flex":"none";for(const B of n)this.chips.append(this.chipEl(B));const o=this.scroll.scrollHeight,i=this.scroll.scrollTop;if(this.scroll.replaceChildren(),this.subjectCard.childNodes.length&&this.scroll.append(this.subjectCard),e.hasMoreHistory){const B=l("div","ocw-load-more");B.textContent="↑ Loading earlier messages…",B.style.pointerEvents="none",this.scroll.append(B)}let s=0,r=null;const p=[...e.messages()];for(let B=0;B<p.length;B++){const g=p[B],u=g.senderRole!=="system"&&g.senderId!==this.me&&!g.internal&&g.senderId!==r;this.scroll.append(this.messageEl(g,e,u,B===p.length-1)),g.senderRole!=="system"&&(r=g.senderId),g.senderId!==this.me&&g.seq>s&&(s=g.seq)}i>20?this.scroll.scrollTop=this.scroll.scrollHeight-o+i:this.scroll.scrollTop=this.scroll.scrollHeight,s>0&&this.h.onReadUpTo(s);const a=[...e.typing];this.typing.classList.toggle("active",a.length>0);const w=this.typing.querySelector(".ocw-typing-bubble");w&&w.setAttribute("aria-label",a.length?"typing":""),this.footer.style.display=e.whiteLabel?"none":"block";const f=e.messages().some(B=>B.senderRole==="guest");if(!!((z=e.preChat)!=null&&z.enabled)&&!this.preChatDone&&!f&&(e.preChat.showWhen!=="offline"||e.offline))this.preChatBuilt||this.buildPreChatPanel(e.preChat),this.preChatPanel.style.display="block",this.awayNotice.style.display="none",(K=this.root.querySelector(".ocw-input"))==null||K.style.setProperty("display","none");else{if(this.preChatPanel.style.display="none",e.offline){this.awayNotice.firstChild||this.awayNotice.append(l("span","ocw-away-icon","🌙"),l("span","",""));const B=this.awayNotice.lastChild;B.textContent=e.offlineMessage||(($=this.cfg.i18n)==null?void 0:$.offline)||"We're away right now — send your message and we'll reply as soon as we're back.",this.awayNotice.style.display="flex"}else this.awayNotice.style.display="none";(_=this.root.querySelector(".ocw-input"))==null||_.style.removeProperty("display")}const y=["resolved","closed","sold","issued","checked_out"];this.h.onCsat&&!this.csatSubmitted&&y.includes(e.state)&&e.messages().length>0&&(this.csatPanel.style.display==="none"&&this.buildCsatPanel(),this.csatPanel.style.display="block");const S=y.includes(e.state);if(e.offline?(this.headStatus.textContent=`● ${e.offlineMessage||((F=this.cfg.i18n)==null?void 0:F.away)||"Away"}`,this.headStatus.className="ocw-head-status away",this.headStatus.style.display=""):e.conversationId?(this.headStatus.textContent=`● ${((U=this.cfg.i18n)==null?void 0:U.online)??"Online"}`,this.headStatus.className="ocw-head-status online",this.headStatus.style.display=""):this.headStatus.style.display="none",S&&e.messages().length>0){const B=l("div","ocw-resolved-note",`— ${((Z=this.cfg.i18n)==null?void 0:Z.resolved)??"Marked as resolved"} —`);this.scroll.append(B),this.reopenBtn.style.display="block"}else this.reopenBtn.style.display="none"}setConnStatus(e,n){if(e==="open"){this.connStatus.style.display="none";return}this.connStatus.style.display="";const o=e==="error";this.connStatus.className=`ocw-conn-status${o?" err":e==="reconnecting"?" warn":""}`,this.connStatus.textContent=o?`⚠ ${n??"Chat unavailable"}`:e==="reconnecting"?n??"↻ reconnecting…":"● connecting…"}buildPreChatPanel(e){var a;this.preChatBuilt=!0,this.preChatPanel.replaceChildren(),this.preChatPanel.append(l("div","ocw-prechat-title",e.title??"Before we start…"));const n=l("div","ocw-offline-form"),o={};for(const w of e.fields??["name","email"]){const f=l("input","ocw-offline-input");f.type=w==="email"?"email":w==="phone"?"tel":"text",f.placeholder=w==="name"?"Your name":w==="email"?"Your email":"Your phone number",o[w]=f,n.append(f)}let i=null;if((a=e.topics)!=null&&a.length){i=l("select",void 0);const w=document.createElement("option");w.value="",w.textContent="What is this about?",i.append(w);for(const f of e.topics){const h=document.createElement("option");h.value=f,h.textContent=f,i.append(h)}n.append(i)}let s=null,r=null;if(e.callbackOption){const w=l("label","ocw-prechat-cb");s=document.createElement("input"),s.type="checkbox",w.append(s,document.createTextNode("📞 Request a call back")),n.append(w),o.phone||(r=l("input","ocw-offline-input"),r.type="tel",r.placeholder="Phone number for the call",r.style.display="none",s.addEventListener("change",()=>r.style.setProperty("display",s.checked?"block":"none")),n.append(r))}const p=l("button","ocw-offline-submit","Start chat");p.type="button",p.addEventListener("click",()=>{var y,S,E,z,K,$,_;const w=(y=o.email)==null?void 0:y.value.trim();if(o.email&&(!w||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(w))){o.email.focus();return}const f=!!(s!=null&&s.checked),h=(((S=o.phone)==null?void 0:S.value)??(r==null?void 0:r.value)??"").trim();if(f&&!h){(E=o.phone??r)==null||E.focus();return}if(i&&((z=e.topics)!=null&&z.length)&&!i.value){i.focus();return}p.disabled=!0,this.completePreChat(),(_=($=this.h).onPreChat)==null||_.call($,{...(K=o.name)!=null&&K.value.trim()?{name:o.name.value.trim()}:{},...w?{email:w}:{},...h?{phone:h}:{},...i!=null&&i.value?{topic:i.value}:{},...f?{callback:!0}:{}})}),n.append(p),this.preChatPanel.append(n)}completePreChat(){this.preChatDone=!0,this.preChatPanel.style.display="none",this.storeRef&&this.render(this.storeRef)}showDeflection(e){if(!e.length)return this.hideDeflection();this.deflectPanel.replaceChildren(),this.deflectPanel.append(l("div","ocw-deflect-hint","Instant answers — tap to expand"));for(const n of e.slice(0,3)){const o=l("button","ocw-deflect-card");o.append(l("div","ocw-deflect-q",n.title),l("div","ocw-deflect-a",n.answer)),o.addEventListener("click",()=>o.classList.toggle("open")),this.deflectPanel.append(o)}this.deflectPanel.style.display="flex"}hideDeflection(){this.deflectPanel.style.display="none",this.deflectPanel.replaceChildren()}buildCsatPanel(){this.csatPanel.replaceChildren(),this.csatPanel.append(l("div","ocw-csat-title","How did we do?"));const e=l("div","ocw-csat-stars"),n=[];for(let o=1;o<=5;o++){const i=l("button","ocw-csat-star","★");i.dataset.score=String(o),i.addEventListener("mouseenter",()=>n.forEach((s,r)=>s.classList.toggle("lit",r<o))),i.addEventListener("mouseleave",()=>n.forEach(s=>s.classList.remove("lit"))),i.addEventListener("click",()=>{var s,r;this.csatSubmitted=!0,this.csatPanel.replaceChildren(l("div","ocw-csat-done",`Thanks for your ${o}★ rating!`)),(r=(s=this.h).onCsat)==null||r.call(s,o)}),n.push(i),e.append(i)}this.csatPanel.append(e)}buildSubjectCard(e){if(this.subjectBuilt)return;const n=e.subject,o=this.cfg.subject,i=(n==null?void 0:n.title)??(o==null?void 0:o.title);if(!i)return;this.subjectBuilt=!0,this.subjectCard.replaceChildren(),this.subjectCard.append(l("div","ocw-subject-title",i)),o!=null&&o.subtitle&&this.subjectCard.append(l("div","ocw-subject-sub",o.subtitle));const s=l("div","ocw-tags");if(n)for(const[p,a]of Object.entries(n.fields))s.append(l("span","ocw-tag",`${p}: ${a}`));else for(const p of(o==null?void 0:o.tags)??[])s.append(l("span","ocw-tag",p));s.childNodes.length&&this.subjectCard.append(s);const r=(n==null?void 0:n.state)??(o==null?void 0:o.status);r&&(this.statusBadge.textContent=r,this.statusBadge.style.display="inline-flex")}chipEl(e){const n=l("button","ocw-chip",e.icon?`${e.icon} ${e.label}`:e.label);return n.dataset.actionId=e.id,n.addEventListener("click",async()=>{var o;e.confirm&&!await this.confirm(e.label)||((o=e.input)!=null&&o.length?this.openForm(e):this.h.onInvoke(e.id))}),n}confirm(e){return new Promise(n=>{const o=l("div","ocw-modal"),i=l("div","ocw-modal-card");i.append(l("div","ocw-modal-title",e)),i.append(l("div","ocw-modal-body",`Confirm “${e}”?`));const s=l("div","ocw-modal-actions"),r=l("button","ocw-modal-cancel","Cancel"),p=l("button","ocw-modal-ok","Confirm"),a=w=>{o.remove(),n(w)};r.addEventListener("click",()=>a(!1)),p.addEventListener("click",()=>a(!0)),o.addEventListener("click",w=>{w.target===o&&a(!1)}),s.append(r,p),i.append(s),o.append(i),this.root.append(o),p.focus()})}openForm(e,n){var a,w;this.formHost.replaceChildren();const o=l("div","ocw-form");o.append(l("div","ocw-form-title",e.icon?`${e.icon} ${e.label}`:e.label));const i=new Map;for(const f of e.input??[]){const h=n==null?void 0:n[f.name],y=l("label","ocw-form-row");if(y.append(l("span","ocw-form-lbl",f.label)),f.type==="select"&&((a=f.options)!=null&&a.length)){const S=l("select","ocw-form-input");f.required||S.append(l("option",void 0,"— select —"));for(const E of f.options){const z=l("option");z.value=E,z.textContent=E,S.append(z)}f.required&&(S.required=!0),h!=null&&f.options.includes(h)&&(S.value=h),y.append(S),i.set(f.name,S)}else{const S=l("input","ocw-form-input");S.type=f.type==="number"?"number":f.type==="date"?"datetime-local":"text",f.required&&(S.required=!0),h!=null&&h!==""&&(S.value=h),y.append(S),i.set(f.name,S)}o.append(y)}const s=l("div","ocw-form-actions"),r=l("button","ocw-form-cancel","Cancel"),p=l("button","ocw-form-submit","Send");r.addEventListener("click",()=>this.formHost.replaceChildren()),p.addEventListener("click",()=>{const f={};for(const[h,y]of i){if(y.required&&!y.value){y.style.borderColor="#e5484d";return}f[h]=y.type==="number"?Number(y.value):y.value}this.formHost.replaceChildren(),this.h.onInvoke(e.id,f)}),s.append(r,p),o.append(s),this.formHost.append(o),(w=i.values().next().value)==null||w.focus()}messageEl(e,n,o=!1,i=!1){var S,E,z,K,$,_,F,U,Z,B;if(e.senderRole==="system"){const g=l("div","ocw-sys");return g.textContent=e.deletedAt?"message deleted":Xe(e.content),g}const s=e.senderId===this.me,r=!!e.internal,p=l("div",`ocw-row ${r?"ocw-note mine":s?"mine":"theirs"} ${e.senderRole==="bot"?"ocw-bot":""}`),a=l("div");if(o){const g=e.senderRole==="bot"?((S=this.cfg.i18n)==null?void 0:S.aiAssistant)??"AI Assistant":((E=this.cfg.subject)==null?void 0:E.ownerLabel)??((z=this.cfg.subject)==null?void 0:z.title)??"Support";a.append(l("div","ocw-msg-sender",g))}const w=l("div","ocw-bubble-wrap");if(e.replyToId){const g=l("div","ocw-reply-to","↩ replying to a message");g.style.cssText="font-size:11px;color:var(--ocw-mut);margin-bottom:2px;font-style:italic",a.append(g)}const f=l("div","ocw-bubble");let h=null;if(e.deletedAt)f.append(l("span","ocw-deleted","message deleted"));else if(e.content.kind==="attachment"){const g=e.content;if((K=g.mime)!=null&&K.startsWith("image/")){const u=document.createElement("img");u.src=g.url,u.alt=g.name??"image",u.style.cssText="max-width:220px;max-height:160px;border-radius:10px;display:block;cursor:pointer",u.addEventListener("click",()=>window.open(g.url,"_blank")),f.append(u)}else if(($=g.mime)!=null&&$.startsWith("video/")){const u=document.createElement("video");u.src=g.url,u.controls=!0,u.style.cssText="max-width:240px;max-height:180px;border-radius:10px;display:block",f.append(u)}else{const u=document.createElement("a");u.href=g.url,u.target="_blank",u.rel="noopener",u.style.cssText="display:flex;align-items:center;gap:8px;color:inherit;text-decoration:none",u.append(l("span",void 0,"📄"),l("span",void 0,g.name??"file")),f.append(u)}}else if(e.content.kind==="appointment"){const g=e.content,u=l("div","ocw-appt");u.append(l("div","ocw-appt-title",`📅 ${g.title}`)),u.append(l("div","ocw-appt-time",new Date(g.startIso).toLocaleString()+" – "+new Date(g.endIso).toLocaleTimeString())),g.location&&u.append(l("div","ocw-appt-loc",`📍 ${g.location}`)),g.description&&u.append(l("div","ocw-appt-desc",g.description));const b=l("div","ocw-appt-links"),m=document.createElement("a");m.href=g.googleUrl,m.target="_blank",m.rel="noopener",m.className="ocw-appt-btn",m.textContent="📅 Add to Google Calendar";const C=document.createElement("a");C.href=g.icalUrl,C.download=`${g.title}.ics`,C.className="ocw-appt-btn ocw-appt-btn-sec",C.textContent="🍎 Apple / iCal",b.append(m,C),u.append(b),f.append(u)}else h=Fn(f,Xe(e.content)),e.editedAt&&f.append(l("span","ocw-edited","(edited)"));if(w.append(f),i&&!e.deletedAt&&e.content.kind==="text"&&((_=e.content.quickReplies)!=null&&_.length)){const g=l("div","ocw-flow-choices");g.style.cssText="display:flex;flex-wrap:wrap;gap:6px;margin-top:6px";for(const u of e.content.quickReplies){const b=l("button","ocw-flow-choice",u);b.type="button",b.style.cssText="border:1px solid var(--ocw-bd,rgba(0,0,0,.12));background:var(--ocw-bg,#fff);color:inherit;border-radius:14px;padding:5px 12px;font:inherit;font-size:13px;cursor:pointer",b.addEventListener("click",()=>{g.querySelectorAll("button").forEach(m=>m.disabled=!0),g.style.opacity="0.5",this.h.onSend(u)}),g.append(b)}w.append(g)}if(i&&!e.deletedAt&&e.content.kind==="form"){const g=e.content,u=n.actionById(g.actionId);if((F=u==null?void 0:u.input)!=null&&F.length){const b=l("button","ocw-chip",u.icon?`${u.icon} ${u.label}`:u.label);b.type="button",b.style.cssText="margin-top:6px",b.addEventListener("click",async()=>{u.confirm&&!await this.confirm(u.label)||this.openForm(u,g.prefill)}),w.append(b)}}if(!s&&!r&&this.h.onTranslate&&e.content.kind==="text"&&!e.deletedAt&&e.seq>0&&h){const g=e.content.text;if(g.trim()){const u=l("button","ocw-translate-btn","🌐");u.type="button",u.title="Translate";const b=l("div","ocw-translation");b.style.display="none",f.append(b);const m=v=>{b.textContent=v,b.style.display="",this.showingTranslation.add(e.id),u.textContent="↩",u.title="Show original"},C=()=>{b.style.display="none",this.showingTranslation.delete(e.id),u.textContent="🌐",u.title="Translate"};u.addEventListener("click",v=>{if(v.stopPropagation(),this.showingTranslation.has(e.id)){C();return}const P=this.translationCache.get(e.id);if(P!==void 0){m(P);return}u.textContent="⏳",this.h.onTranslate(g).then(A=>{if(A===null){u.textContent="⚠️",u.title="Translation unavailable",setTimeout(()=>{u.textContent="🌐",u.title="Translate"},1500);return}this.translationCache.set(e.id,A),m(A)})}),w.append(u);const T=this.translationCache.get(e.id);this.showingTranslation.has(e.id)&&T!==void 0&&m(T)}}if(s&&!e.deletedAt&&e.seq>0&&(this.h.onEdit??this.h.onDelete)){const g=l("div","ocw-msg-menu");if(this.h.onEdit){const u=l("button",void 0,"✏️");u.title="Edit",u.addEventListener("click",b=>{b.stopPropagation();const m=Xe(e.content),C=document.createElement("textarea");C.value=m,C.rows=Math.min(4,Math.ceil(m.length/40)+1),C.style.cssText="width:100%;resize:vertical;border:1px solid var(--ocw-accent);border-radius:8px;padding:6px 10px;font:inherit;font-size:14px;background:var(--ocw-card);color:#1c1b1a;box-sizing:border-box";const T=l("button","ocw-form-submit","Save");T.style.cssText="margin-top:6px;padding:5px 14px;font-size:13px";const v=l("button","ocw-form-cancel","Cancel");v.style.cssText="margin-top:6px;padding:5px 10px;font-size:13px";const P=l("div");P.style.cssText="display:flex;gap:6px;justify-content:flex-end",P.append(v,T);const A=l("div");A.append(C,P),f.replaceChildren(A),C.focus(),C.select();const Q=()=>f.replaceChildren(h??document.createTextNode(m));v.addEventListener("click",Q),T.addEventListener("click",()=>{const W=C.value.trim();W&&W!==m&&this.h.onEdit(e.id,W),Q()}),C.addEventListener("keydown",W=>{W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),T.click()),W.key==="Escape"&&Q()})}),g.append(u)}if(this.h.onDelete){const u=l("button","del","🗑");u.title="Delete",u.addEventListener("click",b=>{b.stopPropagation(),this.h.onDelete(e.id)}),g.append(u)}w.append(g)}if(a.append(w),e.senderRole==="bot"&&!e.deletedAt&&e.seq>0&&e.content.kind==="text"){const g=e.content.citations;if(g!=null&&g.length){const u=l("div","ocw-cites");u.style.cssText="margin-top:4px;font-size:11px;color:var(--ocw-mut,#667)",u.textContent=`${((U=this.cfg.i18n)==null?void 0:U.sources)??"Sources"}: ${g.map(b=>b.source).join(", ")}`,a.append(u)}if(this.h.onReact){const u=l("div","ocw-bot-feedback");u.style.cssText="display:flex;gap:6px;margin-top:4px";const b=(m,C)=>{const T=l("button","ocw-fb-btn",m);T.type="button",T.title=C,T.style.cssText="border:1px solid var(--ocw-bd,rgba(0,0,0,.12));background:transparent;border-radius:12px;padding:1px 8px;font-size:12px;cursor:pointer;opacity:.7";const v=()=>{var P,A;return!!((A=(P=e.reactions)==null?void 0:P[m])!=null&&A.includes(this.me))};return v()&&(T.style.opacity="1"),T.addEventListener("click",()=>{var P,A;(A=(P=this.h).onReact)==null||A.call(P,e.id,m,v()),T.style.opacity="1"}),T};u.append(b("👍",((Z=this.cfg.i18n)==null?void 0:Z.helpful)??"Helpful"),b("👎",((B=this.cfg.i18n)==null?void 0:B.notHelpful)??"Not helpful")),a.append(u)}}if(this.h.onReact&&!e.deletedAt&&e.seq>0){const g=l("div","ocw-react-wrap"),u=l("div","ocw-react");if(e.reactions&&Object.keys(e.reactions).length)for(const[C,T]of Object.entries(e.reactions)){const v=l("button",`ocw-react-pill${T.includes(this.me)?" mine":""}`,`${C} ${T.length}`);v.addEventListener("click",()=>{var P,A;return(A=(P=this.h).onReact)==null?void 0:A.call(P,e.id,C,T.includes(this.me))}),u.append(v)}const b=l("button","ocw-react-btn","+"),m=l("div","ocw-react-picker");for(const C of jn){const T=l("button",void 0,C);T.addEventListener("click",v=>{var A,Q,W,k;v.stopPropagation();const P=(Q=(A=e.reactions)==null?void 0:A[C])==null?void 0:Q.includes(this.me);(k=(W=this.h).onReact)==null||k.call(W,e.id,C,!!P),m.style.display="none"}),m.append(T)}m.style.display="none",b.addEventListener("click",C=>{C.stopPropagation();const T=m.style.display==="none";m.style.display=T?"flex":"none",T&&document.addEventListener("click",()=>{m.style.display="none"},{once:!0})}),u.append(b),g.append(u,m),a.append(g)}else e.reactions&&Object.keys(e.reactions).length&&a.append(l("div","ocw-react",Object.entries(e.reactions).map(([g,u])=>`${g}${u.length}`).join(" ")));const y=l("div","ocw-time ocw-meta",Wn(e.ts));if(s&&e.status){const g=l("span",`ocw-tick${e.status==="read"?" read":e.status==="delivered"?" delivered":""}`,Xn(e.status));y.append(g)}return s&&e.seq>0&&n.lastReadByOthers>=e.seq&&y.append(l("span","ocw-seen"," · Seen")),a.append(y),p.append(a),p}}function Xn(t){switch(t){case"read":return"✓✓";case"delivered":return"✓✓";case"sent":return"✓";default:return"🕓"}}const Gn=20;function Ge(t,e){var a;const n=t.trim().replace(/\/+$/,""),o=(a=n.match(/^(https|http|wss|ws):\/\//))==null?void 0:a[1],i=o?o==="https"||o==="wss":!0,s=(o?n.slice(o.length+3):n).replace(/\/ws$/,""),r=e?e.trim().replace(/\/+$/,""):`${i?"https":"http"}://${s}`;return{wsUrl:`${i?"wss":"ws"}://${s}/ws`,httpBase:r}}function Yn(t){return Ge(t).httpBase}function Jn(t,e,n,o){const i=`beforeSeq=${n}&limit=${o}`;return[`${t}/conversations/${e}/messages?${i}`,`${t}/conversations/${e}/history?${i}`]}async function mt(t,e,n,o,i=Gn){let s,r=!1;for(const p of Jn(t,e,o,i))try{const a=await fetch(p,{headers:{authorization:`Bearer ${n}`}});if(r=!0,!a.ok)continue;const w=await a.json();return{messages:w.messages??[],hasMore:w.hasMore??!1}}catch(a){s=a}return r?console.error(`[chat-widget] history request to ${t} was rejected for conversation ${e}.`):console.error(`[chat-widget] could not load history from ${t} — the request never reached the server. This is almost always CORS: add this site's origin to the chatroom's allowed origins (dashboard → chatroom → allowed origins) or to the server's CORS_ORIGINS.`,s),null}async function Zn(t,e,n,o,i,s){const r=s?s.replace(/\/+$/,""):Yn(t),p=await mt(r,n,e,Number.MAX_SAFE_INTEGER);if(!p||(p.messages.length?(o.apply({type:"sync",conversationId:n,messages:p.messages}),o.apply({type:"history",conversationId:n,messages:[],hasMore:p.hasMore}),i.render(o)):o.apply({type:"history",conversationId:n,messages:[],hasMore:!1}),!p.hasMore))return;let a=!1;const w=async()=>{if(a||!o.hasMoreHistory)return;a=!0;const S=o.messages()[0];if(!S){a=!1;return}const E=await mt(r,n,e,S.seq);E&&(o.apply({type:"history",conversationId:n,messages:E.messages,hasMore:E.hasMore}),i.render(o)),a=!1},f=i.getScrollEl();if(!f)return;let h=!1;setTimeout(()=>{h=!0},300);const y=()=>{h&&f.scrollTop<80&&o.hasMoreHistory&&!a&&w()};f.addEventListener("scroll",y,{passive:!0}),i.setScrollCleanup(()=>f.removeEventListener("scroll",y))}const Qn=`
195
+ `,yt="objectchat-widget-styles",jn=["👍","❤️","😂","😮","😢","🙏"],Nn=400,qn='<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M22 2 11 13M22 2l-7 20-4-9-9-4 20-7z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';function Hn(){if(typeof document>"u"||document.getElementById(yt))return;const t=document.createElement("style");t.id=yt,t.textContent=_n,document.head.appendChild(t)}const xt="ocw-webfont";function On(){if(typeof document>"u"||document.getElementById(xt))return;const t=document.createElement("link");t.id=xt,t.rel="stylesheet",t.href="https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700&family=Nunito:wght@400;500;600;700&display=swap",document.head.appendChild(t)}function l(t,e,n){const o=document.createElement(t);return e&&(o.className=e),n!==void 0&&(o.textContent=n),o}function Fn(t,e){const n=/(https?:\/\/[^\s]+)/g;let o=0,i=null,s;for(;(s=n.exec(e))!==null;){if(s.index>o){const h=document.createTextNode(e.slice(o,s.index));t.append(h),i??(i=h)}let p=s[0],a="";const w=/[).,!?;:]+$/.exec(p);w&&(a=w[0],p=p.slice(0,-a.length));const f=document.createElement("a");f.href=p,f.target="_blank",f.rel="noopener noreferrer",f.textContent=p,f.style.cssText="color:inherit;text-decoration:underline;word-break:break-all",t.append(f),a&&t.append(document.createTextNode(a)),o=s.index+s[0].length}const r=document.createTextNode(e.slice(o));return t.append(r),i??(i=r),i}function Wn(t){try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function Xe(t){var e;switch(t.kind){case"text":return t.text;case"system":return typeof((e=t.data)==null?void 0:e.message)=="string"?String(t.data.message):t.event;case"card":return[t.title,t.body].filter(Boolean).join(" — ");case"attachment":return t.name??t.url;case"form":return t.prompt;case"appointment":return`📅 ${t.title} — ${new Date(t.startIso).toLocaleString()}`}}class Vn{constructor(e,n,o,i={}){c(this,"scroll");c(this,"chips");c(this,"typing");c(this,"quick");c(this,"formHost");c(this,"csatPanel");c(this,"awayNotice");c(this,"headStatus");c(this,"reopenBtn");c(this,"preChatPanel");c(this,"deflectPanel");c(this,"preChatBuilt",!1);c(this,"preChatDone",!1);c(this,"footer");c(this,"input");c(this,"subjectCard");c(this,"e2eBadge");c(this,"statusBadge");c(this,"headerName");c(this,"connStatus");c(this,"typingTimer",null);c(this,"csatSubmitted",!1);c(this,"sendBtn");c(this,"compactObserver",null);c(this,"storeRef",null);c(this,"cfgAccent2");c(this,"scrollCleanup",null);c(this,"translationCache",new Map);c(this,"showingTranslation",new Set);c(this,"subjectBuilt",!1);var _,F,U,Z,B,g,u,b,m,C,T;this.root=e,this.me=n,this.h=o,this.cfg=i,Hn(),i.webfont!==!1&&On(),e.replaceChildren(),e.classList.add("ocw"),i.accent&&e.style.setProperty("--ocw-accent",i.accent);const s=i.accent2??i.accent;s&&e.style.setProperty("--ocw-accent2",s),this.cfgAccent2=i.accent2,e.dataset.theme=i.theme??"light";const r=l("div","ocw-head");if(this.h.onBack){const v=l("button","ocw-back","‹");v.type="button",v.setAttribute("aria-label","Back"),v.addEventListener("click",()=>this.h.onBack()),r.append(v)}const p=((_=i.subject)==null?void 0:_.ownerLabel)??((F=i.subject)==null?void 0:F.title)??"",a=l("div","ocw-avatar");p.trim()&&(a.textContent=p.trim()[0].toUpperCase(),r.append(a));const w=l("div","ocw-head-main");this.headerName=l("div","ocw-head-name",((U=i.subject)==null?void 0:U.ownerLabel)??((Z=i.subject)==null?void 0:Z.title)??""),w.append(this.headerName),this.headStatus=l("div","ocw-head-status"),this.headStatus.style.display="none",w.append(this.headStatus),(B=i.subject)!=null&&B.subtitle&&w.append(l("div","ocw-head-meta",i.subject.subtitle)),r.append(w),this.statusBadge=l("span","ocw-badge",((g=i.subject)==null?void 0:g.status)??""),(u=i.subject)!=null&&u.status||(this.statusBadge.style.display="none"),r.append(this.statusBadge),this.e2eBadge=l("span","ocw-e2e","🔒 E2E"),this.e2eBadge.style.display="none",r.append(this.e2eBadge),this.connStatus=l("span","ocw-conn-status"),this.connStatus.style.display="none",r.append(this.connStatus),r.append(l("button","ocw-menu","⋯")),this.chips=l("div","ocw-chiprow"),this.scroll=l("div","ocw-scroll"),this.subjectCard=l("div","ocw-subject"),this.typing=l("div","ocw-typing");const f=l("div","ocw-typing-bubble");f.append(l("div","ocw-typing-dot"),l("div","ocw-typing-dot"),l("div","ocw-typing-dot")),this.typing.append(f),this.quick=l("div","ocw-quick");for(const v of i.quickReplies??[]){const P=l("button",void 0,v);P.addEventListener("click",()=>{this.h.onSend(v),this.quick.style.display="none"}),this.quick.append(P)}this.formHost=l("div","ocw-form-host"),this.csatPanel=l("div","ocw-csat"),this.csatPanel.style.display="none",this.awayNotice=l("div","ocw-away"),this.awayNotice.style.display="none",this.preChatPanel=l("div","ocw-prechat"),this.preChatPanel.style.display="none",this.deflectPanel=l("div","ocw-deflect"),this.deflectPanel.style.display="none",this.input=l("textarea",void 0),this.input.rows=1,this.input.placeholder=((b=i.i18n)==null?void 0:b.placeholder)??"Message…";const h=l("button","ocw-sendbtn");h.type="button";const y=(m=i.i18n)==null?void 0:m.send;y?(h.textContent=y,h.classList.add("ocw-sendbtn-label"),h.setAttribute("aria-label",y)):(h.innerHTML=qn,h.setAttribute("aria-label","Send message")),h.disabled=!0,this.sendBtn=h,h.addEventListener("click",()=>this.flushSend()),this.input.addEventListener("input",()=>{var v,P;this.sendBtn.disabled=this.input.value.trim().length===0,this.autoGrowInput(),this.storeRef&&!this.storeRef.messages().some(A=>A.senderRole==="guest")?(P=(v=this.h).onDeflectQuery)==null||P.call(v,this.input.value):this.hideDeflection()}),this.input.addEventListener("keydown",v=>{v.isComposing||v.keyCode===229||(v.key==="Enter"&&!v.shiftKey?(v.preventDefault(),this.flushSend()):this.signalTyping())});const S=l("button","ocw-attach","📎");S.title="Attach image or file";const E=document.createElement("input");E.type="file",E.accept="image/*,.pdf,.txt,.doc,.docx",E.style.display="none",S.addEventListener("click",()=>E.click()),E.addEventListener("change",()=>{var v;(v=E.files)!=null&&v[0]&&this.h.onAttach&&this.h.onAttach(E.files[0]),E.value=""});const z=l("div","ocw-input");z.append(S,E,this.input,h);const K=l("div","ocw-footer");((C=i.i18n)==null?void 0:C.poweredBy)!==void 0?K.textContent=i.i18n.poweredBy:K.innerHTML='Powered by <a href="https://relay.paramms.com" target="_blank" rel="noopener">Relay</a>',this.footer=K,this.reopenBtn=l("button","ocw-reopen",((T=this.cfg.i18n)==null?void 0:T.reopen)??"Reopen conversation"),this.reopenBtn.type="button",this.reopenBtn.addEventListener("click",()=>{this.reopenBtn.style.display="none";const v=this.root.querySelector(".ocw-input textarea");v==null||v.focus()}),e.append(r,this.chips,this.scroll,this.typing,this.quick,this.formHost,this.csatPanel,this.preChatPanel,this.deflectPanel,this.awayNotice,z,this.reopenBtn,this.footer);const $=v=>{e.classList.toggle("ocw-compact",v>0&&v<Nn)};$(e.clientWidth),typeof ResizeObserver<"u"&&(this.compactObserver=new ResizeObserver(v=>{var A;const P=((A=v[0])==null?void 0:A.contentRect.width)??e.clientWidth;$(P)}),this.compactObserver.observe(e))}getScrollEl(){return this.scroll}setScrollCleanup(e){var n;(n=this.scrollCleanup)==null||n.call(this),this.scrollCleanup=e}destroy(){var e,n;(e=this.scrollCleanup)==null||e.call(this),this.scrollCleanup=null,this.typingTimer&&(clearTimeout(this.typingTimer),this.typingTimer=null),(n=this.compactObserver)==null||n.disconnect(),this.compactObserver=null}flushSend(){this.hideDeflection();const e=this.input.value.trim();e&&(this.input.value="",this.sendBtn.disabled=!0,this.autoGrowInput(),this.h.onTyping(!1),this.h.onSend(e))}autoGrowInput(){this.input.style.height="auto";const e=this.input.scrollHeight;e>0?this.input.style.height=`${Math.min(e,120)}px`:this.input.style.removeProperty("height")}signalTyping(){const e=this.input.value.trim().slice(0,100)||void 0;this.h.onTyping(!0,e),this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=setTimeout(()=>this.h.onTyping(!1),2e3)}setBotName(e){this.cfg.i18n={...this.cfg.i18n??{},aiAssistant:e}}render(e){var E,z,K,$,_,F,U,Z;if(this.storeRef=e,e.accent&&(this.root.style.setProperty("--ocw-accent",e.accent),this.root.style.setProperty("--ocw-accent2",this.cfgAccent2??e.accent)),this.e2eBadge.style.display=e.e2e?"inline-flex":"none",this.buildSubjectCard(e),e.subject){const B=(E=this.cfg.subject)==null?void 0:E.ownerLabel;B&&(this.headerName.textContent=B)}this.quick.style.display=e.messages().length===0?"flex":"none",this.chips.replaceChildren();const n=e.visibleActions();this.chips.style.display=n.length?"flex":"none";for(const B of n)this.chips.append(this.chipEl(B));const o=this.scroll.scrollHeight,i=this.scroll.scrollTop;if(this.scroll.replaceChildren(),this.subjectCard.childNodes.length&&this.scroll.append(this.subjectCard),e.hasMoreHistory){const B=l("div","ocw-load-more");B.textContent="↑ Loading earlier messages…",B.style.pointerEvents="none",this.scroll.append(B)}let s=0,r=null;const p=[...e.messages()];for(let B=0;B<p.length;B++){const g=p[B],u=g.senderRole!=="system"&&g.senderId!==this.me&&!g.internal&&g.senderId!==r;this.scroll.append(this.messageEl(g,e,u,B===p.length-1)),g.senderRole!=="system"&&(r=g.senderId),g.senderId!==this.me&&g.seq>s&&(s=g.seq)}i>20?this.scroll.scrollTop=this.scroll.scrollHeight-o+i:this.scroll.scrollTop=this.scroll.scrollHeight,s>0&&this.h.onReadUpTo(s);const a=[...e.typing];this.typing.classList.toggle("active",a.length>0);const w=this.typing.querySelector(".ocw-typing-bubble");w&&w.setAttribute("aria-label",a.length?"typing":""),this.footer.style.display=e.whiteLabel?"none":"block";const f=e.messages().some(B=>B.senderRole==="guest");if(!!((z=e.preChat)!=null&&z.enabled)&&!this.preChatDone&&!f&&(e.preChat.showWhen!=="offline"||e.offline))this.preChatBuilt||this.buildPreChatPanel(e.preChat),this.preChatPanel.style.display="block",this.awayNotice.style.display="none",(K=this.root.querySelector(".ocw-input"))==null||K.style.setProperty("display","none");else{if(this.preChatPanel.style.display="none",e.offline){this.awayNotice.firstChild||this.awayNotice.append(l("span","ocw-away-icon","🌙"),l("span","",""));const B=this.awayNotice.lastChild;B.textContent=e.offlineMessage||(($=this.cfg.i18n)==null?void 0:$.offline)||"We're away right now — send your message and we'll reply as soon as we're back.",this.awayNotice.style.display="flex"}else this.awayNotice.style.display="none";(_=this.root.querySelector(".ocw-input"))==null||_.style.removeProperty("display")}const y=["resolved","closed","sold","issued","checked_out"];this.h.onCsat&&!this.csatSubmitted&&y.includes(e.state)&&e.messages().length>0&&(this.csatPanel.style.display==="none"&&this.buildCsatPanel(),this.csatPanel.style.display="block");const S=y.includes(e.state);if(e.offline?(this.headStatus.textContent=`● ${e.offlineMessage||((F=this.cfg.i18n)==null?void 0:F.away)||"Away"}`,this.headStatus.className="ocw-head-status away",this.headStatus.style.display=""):e.conversationId?(this.headStatus.textContent=`● ${((U=this.cfg.i18n)==null?void 0:U.online)??"Online"}`,this.headStatus.className="ocw-head-status online",this.headStatus.style.display=""):this.headStatus.style.display="none",S&&e.messages().length>0){const B=l("div","ocw-resolved-note",`— ${((Z=this.cfg.i18n)==null?void 0:Z.resolved)??"Marked as resolved"} —`);this.scroll.append(B),this.reopenBtn.style.display="block"}else this.reopenBtn.style.display="none"}setConnStatus(e,n){if(e==="open"){this.connStatus.style.display="none";return}this.connStatus.style.display="";const o=e==="error";this.connStatus.className=`ocw-conn-status${o?" err":e==="reconnecting"?" warn":""}`,this.connStatus.textContent=o?`⚠ ${n??"Chat unavailable"}`:e==="reconnecting"?n??"↻ reconnecting…":"● connecting…"}buildPreChatPanel(e){var a;this.preChatBuilt=!0,this.preChatPanel.replaceChildren(),this.preChatPanel.append(l("div","ocw-prechat-title",e.title??"Before we start…"));const n=l("div","ocw-offline-form"),o={};for(const w of e.fields??["name","email"]){const f=l("input","ocw-offline-input");f.type=w==="email"?"email":w==="phone"?"tel":"text",f.placeholder=w==="name"?"Your name":w==="email"?"Your email":"Your phone number",o[w]=f,n.append(f)}let i=null;if((a=e.topics)!=null&&a.length){i=l("select",void 0);const w=document.createElement("option");w.value="",w.textContent="What is this about?",i.append(w);for(const f of e.topics){const h=document.createElement("option");h.value=f,h.textContent=f,i.append(h)}n.append(i)}let s=null,r=null;if(e.callbackOption){const w=l("label","ocw-prechat-cb");s=document.createElement("input"),s.type="checkbox",w.append(s,document.createTextNode("📞 Request a call back")),n.append(w),o.phone||(r=l("input","ocw-offline-input"),r.type="tel",r.placeholder="Phone number for the call",r.style.display="none",s.addEventListener("change",()=>r.style.setProperty("display",s.checked?"block":"none")),n.append(r))}const p=l("button","ocw-offline-submit","Start chat");p.type="button",p.addEventListener("click",()=>{var y,S,E,z,K,$,_;const w=(y=o.email)==null?void 0:y.value.trim();if(o.email&&(!w||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(w))){o.email.focus();return}const f=!!(s!=null&&s.checked),h=(((S=o.phone)==null?void 0:S.value)??(r==null?void 0:r.value)??"").trim();if(f&&!h){(E=o.phone??r)==null||E.focus();return}if(i&&((z=e.topics)!=null&&z.length)&&!i.value){i.focus();return}p.disabled=!0,this.completePreChat(),(_=($=this.h).onPreChat)==null||_.call($,{...(K=o.name)!=null&&K.value.trim()?{name:o.name.value.trim()}:{},...w?{email:w}:{},...h?{phone:h}:{},...i!=null&&i.value?{topic:i.value}:{},...f?{callback:!0}:{}})}),n.append(p),this.preChatPanel.append(n)}completePreChat(){this.preChatDone=!0,this.preChatPanel.style.display="none",this.storeRef&&this.render(this.storeRef)}showDeflection(e){if(!e.length)return this.hideDeflection();this.deflectPanel.replaceChildren(),this.deflectPanel.append(l("div","ocw-deflect-hint","Instant answers — tap to expand"));for(const n of e.slice(0,3)){const o=l("button","ocw-deflect-card");o.append(l("div","ocw-deflect-q",n.title),l("div","ocw-deflect-a",n.answer)),o.addEventListener("click",()=>o.classList.toggle("open")),this.deflectPanel.append(o)}this.deflectPanel.style.display="flex"}hideDeflection(){this.deflectPanel.style.display="none",this.deflectPanel.replaceChildren()}buildCsatPanel(){this.csatPanel.replaceChildren(),this.csatPanel.append(l("div","ocw-csat-title","How did we do?"));const e=l("div","ocw-csat-stars"),n=[];for(let o=1;o<=5;o++){const i=l("button","ocw-csat-star","★");i.dataset.score=String(o),i.addEventListener("mouseenter",()=>n.forEach((s,r)=>s.classList.toggle("lit",r<o))),i.addEventListener("mouseleave",()=>n.forEach(s=>s.classList.remove("lit"))),i.addEventListener("click",()=>{var s,r;this.csatSubmitted=!0,this.csatPanel.replaceChildren(l("div","ocw-csat-done",`Thanks for your ${o}★ rating!`)),(r=(s=this.h).onCsat)==null||r.call(s,o)}),n.push(i),e.append(i)}this.csatPanel.append(e)}buildSubjectCard(e){if(this.subjectBuilt)return;const n=e.subject,o=this.cfg.subject,i=(n==null?void 0:n.title)??(o==null?void 0:o.title);if(!i)return;this.subjectBuilt=!0,this.subjectCard.replaceChildren(),this.subjectCard.append(l("div","ocw-subject-title",i)),o!=null&&o.subtitle&&this.subjectCard.append(l("div","ocw-subject-sub",o.subtitle));const s=l("div","ocw-tags");if(n)for(const[p,a]of Object.entries(n.fields))s.append(l("span","ocw-tag",`${p}: ${a}`));else for(const p of(o==null?void 0:o.tags)??[])s.append(l("span","ocw-tag",p));s.childNodes.length&&this.subjectCard.append(s);const r=(n==null?void 0:n.state)??(o==null?void 0:o.status);r&&(this.statusBadge.textContent=r,this.statusBadge.style.display="inline-flex")}chipEl(e){const n=l("button","ocw-chip",e.icon?`${e.icon} ${e.label}`:e.label);return n.dataset.actionId=e.id,n.addEventListener("click",async()=>{var o;e.confirm&&!await this.confirm(e.label)||((o=e.input)!=null&&o.length?this.openForm(e):this.h.onInvoke(e.id))}),n}confirm(e){return new Promise(n=>{const o=l("div","ocw-modal"),i=l("div","ocw-modal-card");i.append(l("div","ocw-modal-title",e)),i.append(l("div","ocw-modal-body",`Confirm “${e}”?`));const s=l("div","ocw-modal-actions"),r=l("button","ocw-modal-cancel","Cancel"),p=l("button","ocw-modal-ok","Confirm"),a=w=>{o.remove(),n(w)};r.addEventListener("click",()=>a(!1)),p.addEventListener("click",()=>a(!0)),o.addEventListener("click",w=>{w.target===o&&a(!1)}),s.append(r,p),i.append(s),o.append(i),this.root.append(o),p.focus()})}openForm(e,n){var a,w;this.formHost.replaceChildren();const o=l("div","ocw-form");o.append(l("div","ocw-form-title",e.icon?`${e.icon} ${e.label}`:e.label));const i=new Map;for(const f of e.input??[]){const h=n==null?void 0:n[f.name],y=l("label","ocw-form-row");if(y.append(l("span","ocw-form-lbl",f.label)),f.type==="select"&&((a=f.options)!=null&&a.length)){const S=l("select","ocw-form-input");f.required||S.append(l("option",void 0,"— select —"));for(const E of f.options){const z=l("option");z.value=E,z.textContent=E,S.append(z)}f.required&&(S.required=!0),h!=null&&f.options.includes(h)&&(S.value=h),y.append(S),i.set(f.name,S)}else{const S=l("input","ocw-form-input");S.type=f.type==="number"?"number":f.type==="date"?"datetime-local":"text",f.required&&(S.required=!0),h!=null&&h!==""&&(S.value=h),y.append(S),i.set(f.name,S)}o.append(y)}const s=l("div","ocw-form-actions"),r=l("button","ocw-form-cancel","Cancel"),p=l("button","ocw-form-submit","Send");r.addEventListener("click",()=>this.formHost.replaceChildren()),p.addEventListener("click",()=>{const f={};for(const[h,y]of i){if(y.required&&!y.value){y.style.borderColor="#e5484d";return}f[h]=y.type==="number"?Number(y.value):y.value}this.formHost.replaceChildren(),this.h.onInvoke(e.id,f)}),s.append(r,p),o.append(s),this.formHost.append(o),(w=i.values().next().value)==null||w.focus()}messageEl(e,n,o=!1,i=!1){var S,E,z,K,$,_,F,U,Z,B;if(e.senderRole==="system"){const g=l("div","ocw-sys");return g.textContent=e.deletedAt?"message deleted":Xe(e.content),g}const s=e.senderId===this.me,r=!!e.internal,p=l("div",`ocw-row ${r?"ocw-note mine":s?"mine":"theirs"} ${e.senderRole==="bot"?"ocw-bot":""}`),a=l("div");if(o){const g=e.senderRole==="bot"?((S=this.cfg.i18n)==null?void 0:S.aiAssistant)??"AI Assistant":((E=this.cfg.subject)==null?void 0:E.ownerLabel)??((z=this.cfg.subject)==null?void 0:z.title)??"Support";a.append(l("div","ocw-msg-sender",g))}const w=l("div","ocw-bubble-wrap");if(e.replyToId){const g=l("div","ocw-reply-to","↩ replying to a message");g.style.cssText="font-size:11px;color:var(--ocw-mut);margin-bottom:2px;font-style:italic",a.append(g)}const f=l("div","ocw-bubble");let h=null;if(e.deletedAt)f.append(l("span","ocw-deleted","message deleted"));else if(e.content.kind==="attachment"){const g=e.content;if((K=g.mime)!=null&&K.startsWith("image/")){const u=document.createElement("img");u.src=g.url,u.alt=g.name??"image",u.style.cssText="max-width:220px;max-height:160px;border-radius:10px;display:block;cursor:pointer",u.addEventListener("click",()=>window.open(g.url,"_blank")),f.append(u)}else if(($=g.mime)!=null&&$.startsWith("video/")){const u=document.createElement("video");u.src=g.url,u.controls=!0,u.style.cssText="max-width:240px;max-height:180px;border-radius:10px;display:block",f.append(u)}else{const u=document.createElement("a");u.href=g.url,u.target="_blank",u.rel="noopener",u.style.cssText="display:flex;align-items:center;gap:8px;color:inherit;text-decoration:none",u.append(l("span",void 0,"📄"),l("span",void 0,g.name??"file")),f.append(u)}}else if(e.content.kind==="appointment"){const g=e.content,u=l("div","ocw-appt");u.append(l("div","ocw-appt-title",`📅 ${g.title}`)),u.append(l("div","ocw-appt-time",new Date(g.startIso).toLocaleString()+" – "+new Date(g.endIso).toLocaleTimeString())),g.location&&u.append(l("div","ocw-appt-loc",`📍 ${g.location}`)),g.description&&u.append(l("div","ocw-appt-desc",g.description));const b=l("div","ocw-appt-links"),m=document.createElement("a");m.href=g.googleUrl,m.target="_blank",m.rel="noopener",m.className="ocw-appt-btn",m.textContent="📅 Add to Google Calendar";const C=document.createElement("a");C.href=g.icalUrl,C.download=`${g.title}.ics`,C.className="ocw-appt-btn ocw-appt-btn-sec",C.textContent="🍎 Apple / iCal",b.append(m,C),u.append(b),f.append(u)}else h=Fn(f,Xe(e.content)),e.editedAt&&f.append(l("span","ocw-edited","(edited)"));if(w.append(f),i&&!e.deletedAt&&e.content.kind==="text"&&((_=e.content.quickReplies)!=null&&_.length)){const g=l("div","ocw-flow-choices");g.style.cssText="display:flex;flex-wrap:wrap;gap:6px;margin-top:6px";for(const u of e.content.quickReplies){const b=l("button","ocw-flow-choice",u);b.type="button",b.style.cssText="border:1px solid var(--ocw-bd,rgba(0,0,0,.12));background:var(--ocw-bg,#fff);color:inherit;border-radius:14px;padding:5px 12px;font:inherit;font-size:13px;cursor:pointer",b.addEventListener("click",()=>{g.querySelectorAll("button").forEach(m=>m.disabled=!0),g.style.opacity="0.5",this.h.onSend(u)}),g.append(b)}w.append(g)}if(i&&!e.deletedAt&&e.content.kind==="form"){const g=e.content,u=n.actionById(g.actionId);if((F=u==null?void 0:u.input)!=null&&F.length){const b=l("button","ocw-chip",u.icon?`${u.icon} ${u.label}`:u.label);b.type="button",b.style.cssText="margin-top:6px",b.addEventListener("click",async()=>{u.confirm&&!await this.confirm(u.label)||this.openForm(u,g.prefill)}),w.append(b)}}if(!s&&!r&&this.h.onTranslate&&e.content.kind==="text"&&!e.deletedAt&&e.seq>0&&h){const g=e.content.text;if(g.trim()){const u=l("button","ocw-translate-btn");u.type="button",u.innerHTML='<span aria-hidden="true">🌐</span> Translate',u.title="Translate";const b=l("div","ocw-translation");b.style.display="none",f.append(b);const m=v=>{b.textContent=v,b.style.display="",this.showingTranslation.add(e.id),u.innerHTML='<span aria-hidden="true">↩</span> Original',u.title="Show original"},C=()=>{b.style.display="none",this.showingTranslation.delete(e.id),u.innerHTML='<span aria-hidden="true">🌐</span> Translate',u.title="Translate"};u.addEventListener("click",v=>{if(v.stopPropagation(),this.showingTranslation.has(e.id)){C();return}const P=this.translationCache.get(e.id);if(P!==void 0){m(P);return}u.textContent="⏳ …",this.h.onTranslate(g).then(A=>{if(A===null){u.textContent="⚠️ Unavailable",setTimeout(()=>C(),1500);return}this.translationCache.set(e.id,A),m(A)})}),w.append(u);const T=this.translationCache.get(e.id);this.showingTranslation.has(e.id)&&T!==void 0&&m(T)}}if(s&&!e.deletedAt&&e.seq>0&&(this.h.onEdit??this.h.onDelete)){const g=l("div","ocw-msg-menu");if(this.h.onEdit){const u=l("button",void 0,"✏️");u.title="Edit",u.addEventListener("click",b=>{b.stopPropagation();const m=Xe(e.content),C=document.createElement("textarea");C.value=m,C.rows=Math.min(4,Math.ceil(m.length/40)+1),C.style.cssText="width:100%;resize:vertical;border:1px solid var(--ocw-accent);border-radius:8px;padding:6px 10px;font:inherit;font-size:14px;background:var(--ocw-card);color:#1c1b1a;box-sizing:border-box";const T=l("button","ocw-form-submit","Save");T.style.cssText="margin-top:6px;padding:5px 14px;font-size:13px";const v=l("button","ocw-form-cancel","Cancel");v.style.cssText="margin-top:6px;padding:5px 10px;font-size:13px";const P=l("div");P.style.cssText="display:flex;gap:6px;justify-content:flex-end",P.append(v,T);const A=l("div");A.append(C,P),f.replaceChildren(A),C.focus(),C.select();const Q=()=>f.replaceChildren(h??document.createTextNode(m));v.addEventListener("click",Q),T.addEventListener("click",()=>{const W=C.value.trim();W&&W!==m&&this.h.onEdit(e.id,W),Q()}),C.addEventListener("keydown",W=>{W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),T.click()),W.key==="Escape"&&Q()})}),g.append(u)}if(this.h.onDelete){const u=l("button","del","🗑");u.title="Delete",u.addEventListener("click",b=>{b.stopPropagation(),this.h.onDelete(e.id)}),g.append(u)}w.append(g)}if(a.append(w),e.senderRole==="bot"&&!e.deletedAt&&e.seq>0&&e.content.kind==="text"){const g=e.content.citations;if(g!=null&&g.length){const u=l("div","ocw-cites");u.style.cssText="margin-top:4px;font-size:11px;color:var(--ocw-mut,#667)",u.textContent=`${((U=this.cfg.i18n)==null?void 0:U.sources)??"Sources"}: ${g.map(b=>b.source).join(", ")}`,a.append(u)}if(this.h.onReact){const u=l("div","ocw-bot-feedback");u.style.cssText="display:flex;gap:6px;margin-top:4px";const b=(m,C)=>{const T=l("button","ocw-fb-btn",m);T.type="button",T.title=C,T.style.cssText="border:1px solid var(--ocw-bd,rgba(0,0,0,.12));background:transparent;border-radius:12px;padding:1px 8px;font-size:12px;cursor:pointer;opacity:.7";const v=()=>{var P,A;return!!((A=(P=e.reactions)==null?void 0:P[m])!=null&&A.includes(this.me))};return v()&&(T.style.opacity="1"),T.addEventListener("click",()=>{var P,A;(A=(P=this.h).onReact)==null||A.call(P,e.id,m,v()),T.style.opacity="1"}),T};u.append(b("👍",((Z=this.cfg.i18n)==null?void 0:Z.helpful)??"Helpful"),b("👎",((B=this.cfg.i18n)==null?void 0:B.notHelpful)??"Not helpful")),a.append(u)}}if(this.h.onReact&&!e.deletedAt&&e.seq>0){const g=l("div","ocw-react-wrap"),u=l("div","ocw-react");if(e.reactions&&Object.keys(e.reactions).length)for(const[C,T]of Object.entries(e.reactions)){const v=l("button",`ocw-react-pill${T.includes(this.me)?" mine":""}`,`${C} ${T.length}`);v.addEventListener("click",()=>{var P,A;return(A=(P=this.h).onReact)==null?void 0:A.call(P,e.id,C,T.includes(this.me))}),u.append(v)}const b=l("button","ocw-react-btn","+"),m=l("div","ocw-react-picker");for(const C of jn){const T=l("button",void 0,C);T.addEventListener("click",v=>{var A,Q,W,k;v.stopPropagation();const P=(Q=(A=e.reactions)==null?void 0:A[C])==null?void 0:Q.includes(this.me);(k=(W=this.h).onReact)==null||k.call(W,e.id,C,!!P),m.style.display="none"}),m.append(T)}m.style.display="none",b.addEventListener("click",C=>{C.stopPropagation();const T=m.style.display==="none";m.style.display=T?"flex":"none",T&&document.addEventListener("click",()=>{m.style.display="none"},{once:!0})}),u.append(b),g.append(u,m),a.append(g)}else e.reactions&&Object.keys(e.reactions).length&&a.append(l("div","ocw-react",Object.entries(e.reactions).map(([g,u])=>`${g}${u.length}`).join(" ")));const y=l("div","ocw-time ocw-meta",Wn(e.ts));if(s&&e.status){const g=l("span",`ocw-tick${e.status==="read"?" read":e.status==="delivered"?" delivered":""}`,Xn(e.status));y.append(g)}return s&&e.seq>0&&n.lastReadByOthers>=e.seq&&y.append(l("span","ocw-seen"," · Seen")),a.append(y),p.append(a),p}}function Xn(t){switch(t){case"read":return"✓✓";case"delivered":return"✓✓";case"sent":return"✓";default:return"🕓"}}const Gn=20;function Ge(t,e){var a;const n=t.trim().replace(/\/+$/,""),o=(a=n.match(/^(https|http|wss|ws):\/\//))==null?void 0:a[1],i=o?o==="https"||o==="wss":!0,s=(o?n.slice(o.length+3):n).replace(/\/ws$/,""),r=e?e.trim().replace(/\/+$/,""):`${i?"https":"http"}://${s}`;return{wsUrl:`${i?"wss":"ws"}://${s}/ws`,httpBase:r}}function Yn(t){return Ge(t).httpBase}function Jn(t,e,n,o){const i=`beforeSeq=${n}&limit=${o}`;return[`${t}/conversations/${e}/messages?${i}`,`${t}/conversations/${e}/history?${i}`]}async function mt(t,e,n,o,i=Gn){let s,r=!1;for(const p of Jn(t,e,o,i))try{const a=await fetch(p,{headers:{authorization:`Bearer ${n}`}});if(r=!0,!a.ok)continue;const w=await a.json();return{messages:w.messages??[],hasMore:w.hasMore??!1}}catch(a){s=a}return r?console.error(`[chat-widget] history request to ${t} was rejected for conversation ${e}.`):console.error(`[chat-widget] could not load history from ${t} — the request never reached the server. This is almost always CORS: add this site's origin to the chatroom's allowed origins (dashboard → chatroom → allowed origins) or to the server's CORS_ORIGINS.`,s),null}async function Zn(t,e,n,o,i,s){const r=s?s.replace(/\/+$/,""):Yn(t),p=await mt(r,n,e,Number.MAX_SAFE_INTEGER);if(!p||(p.messages.length?(o.apply({type:"sync",conversationId:n,messages:p.messages}),o.apply({type:"history",conversationId:n,messages:[],hasMore:p.hasMore}),i.render(o)):o.apply({type:"history",conversationId:n,messages:[],hasMore:!1}),!p.hasMore))return;let a=!1;const w=async()=>{if(a||!o.hasMoreHistory)return;a=!0;const S=o.messages()[0];if(!S){a=!1;return}const E=await mt(r,n,e,S.seq);E&&(o.apply({type:"history",conversationId:n,messages:E.messages,hasMore:E.hasMore}),i.render(o)),a=!1},f=i.getScrollEl();if(!f)return;let h=!1;setTimeout(()=>{h=!0},300);const y=()=>{h&&f.scrollTop<80&&o.hasMoreHistory&&!a&&w()};f.addEventListener("scroll",y,{passive:!0}),i.setScrollCleanup(()=>f.removeEventListener("scroll",y))}const Qn=`
193
196
  .ocl { ${gt("ocl")}
194
197
  display:flex; flex-direction:column; height:100%; background:var(--ocl-bg);
195
198
  font-family:var(--ocl-fb); color:var(--ocl-ink); overflow:hidden; }