@pocketping/widget 1.1.0 → 1.3.0
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/index.cjs +1493 -142
- package/dist/index.d.cts +85 -4
- package/dist/index.d.ts +85 -4
- package/dist/index.js +1490 -141
- package/dist/pocketping.min.global.js +593 -6
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var PocketPing=(()=>{var te=Object.defineProperty;var pt=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var gt=(t,e)=>{for(var n in e)te(t,n,{get:e[n],enumerable:!0})},ht=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of dt(e))!ut.call(t,o)&&o!==n&&te(t,o,{get:()=>e[o],enumerable:!(s=pt(e,o))||s.enumerable});return t};var _t=t=>ht(te({},"__esModule",{value:!0}),t);var Rt={};gt(Rt,{close:()=>Ge,default:()=>Ht,destroy:()=>Je,getIdentity:()=>it,getTrackedElements:()=>et,identify:()=>st,init:()=>_e,offEvent:()=>nt,on:()=>rt,onEvent:()=>tt,open:()=>Xe,reset:()=>ot,sendMessage:()=>Ze,setupTrackedElements:()=>Qe,toggle:()=>Ye,trigger:()=>Ke});var G,y,be,ft,N,fe,ke,xe,we,ie,ne,se,mt,U={},Se=[],vt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Y=Array.isArray;function T(t,e){for(var n in e)t[n]=e[n];return t}function re(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function ae(t,e,n){var s,o,i,a={};for(i in e)i=="key"?s=e[i]:i=="ref"?o=e[i]:a[i]=e[i];if(arguments.length>2&&(a.children=arguments.length>3?G.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)a[i]===void 0&&(a[i]=t.defaultProps[i]);return q(t,a,s,o,null)}function q(t,e,n,s,o){var i={type:t,props:e,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++be,__i:-1,__u:0};return o==null&&y.vnode!=null&&y.vnode(i),i}function I(t){return t.children}function J(t,e){this.props=t,this.context=e}function L(t,e){if(e==null)return t.__?L(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?L(t):null}function Pe(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return Pe(t)}}function me(t){(!t.__d&&(t.__d=!0)&&N.push(t)&&!X.__r++||fe!=y.debounceRendering)&&((fe=y.debounceRendering)||ke)(X)}function X(){for(var t,e,n,s,o,i,a,l=1;N.length;)N.length>l&&N.sort(xe),t=N.shift(),l=N.length,t.__d&&(n=void 0,s=void 0,o=(s=(e=t).__v).__e,i=[],a=[],e.__P&&((n=T({},s)).__v=s.__v+1,y.vnode&&y.vnode(n),ce(e.__P,n,s,e.__n,e.__P.namespaceURI,32&s.__u?[o]:null,i,o??L(s),!!(32&s.__u),a),n.__v=s.__v,n.__.__k[n.__i]=n,Ie(i,n,a),s.__e=s.__=null,n.__e!=o&&Pe(n)));X.__r=0}function Ee(t,e,n,s,o,i,a,l,p,c,g){var r,d,h,k,P,f,v,m=s&&s.__k||Se,C=e.length;for(p=yt(n,e,m,p,C),r=0;r<C;r++)(h=n.__k[r])!=null&&(d=h.__i==-1?U:m[h.__i]||U,h.__i=r,f=ce(t,h,d,o,i,a,l,p,c,g),k=h.__e,h.ref&&d.ref!=h.ref&&(d.ref&&le(d.ref,null,h),g.push(h.ref,h.__c||k,h)),P==null&&k!=null&&(P=k),(v=!!(4&h.__u))||d.__k===h.__k?p=Ce(h,p,t,v):typeof h.type=="function"&&f!==void 0?p=f:k&&(p=k.nextSibling),h.__u&=-7);return n.__e=P,p}function yt(t,e,n,s,o){var i,a,l,p,c,g=n.length,r=g,d=0;for(t.__k=new Array(o),i=0;i<o;i++)(a=e[i])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=t.__k[i]=q(null,a,null,null,null):Y(a)?a=t.__k[i]=q(I,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=t.__k[i]=q(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):t.__k[i]=a,p=i+d,a.__=t,a.__b=t.__b+1,l=null,(c=a.__i=bt(a,n,p,r))!=-1&&(r--,(l=n[c])&&(l.__u|=2)),l==null||l.__v==null?(c==-1&&(o>g?d--:o<g&&d++),typeof a.type!="function"&&(a.__u|=4)):c!=p&&(c==p-1?d--:c==p+1?d++:(c>p?d--:d++,a.__u|=4))):t.__k[i]=null;if(r)for(i=0;i<g;i++)(l=n[i])!=null&&(2&l.__u)==0&&(l.__e==s&&(s=L(l)),Me(l,l));return s}function Ce(t,e,n,s){var o,i;if(typeof t.type=="function"){for(o=t.__k,i=0;o&&i<o.length;i++)o[i]&&(o[i].__=t,e=Ce(o[i],e,n,s));return e}t.__e!=e&&(s&&(e&&t.type&&!e.parentNode&&(e=L(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function bt(t,e,n,s){var o,i,a,l=t.key,p=t.type,c=e[n],g=c!=null&&(2&c.__u)==0;if(c===null&&l==null||g&&l==c.key&&p==c.type)return n;if(s>(g?1:0)){for(o=n-1,i=n+1;o>=0||i<e.length;)if((c=e[a=o>=0?o--:i++])!=null&&(2&c.__u)==0&&l==c.key&&p==c.type)return a}return-1}function ve(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||vt.test(e)?n:n+"px"}function B(t,e,n,s,o){var i,a;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof s=="string"&&(t.style.cssText=s=""),s)for(e in s)n&&e in n||ve(t.style,e,"");if(n)for(e in n)s&&n[e]==s[e]||ve(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")i=e!=(e=e.replace(we,"$1")),a=e.toLowerCase(),e=a in t||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+i]=n,n?s?n.u=s.u:(n.u=ie,t.addEventListener(e,i?se:ne,i)):t.removeEventListener(e,i?se:ne,i);else{if(o=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function ye(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ie++;else if(e.t<n.u)return;return n(y.event?y.event(e):e)}}}function ce(t,e,n,s,o,i,a,l,p,c){var g,r,d,h,k,P,f,v,m,C,E,W,H,j,R,$,F,_=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(p=!!(32&n.__u),i=[l=e.__e=n.__e]),(g=y.__b)&&g(e);e:if(typeof _=="function")try{if(v=e.props,m="prototype"in _&&_.prototype.render,C=(g=_.contextType)&&s[g.__c],E=g?C?C.props.value:g.__:s,n.__c?f=(r=e.__c=n.__c).__=r.__E:(m?e.__c=r=new _(v,E):(e.__c=r=new J(v,E),r.constructor=_,r.render=xt),C&&C.sub(r),r.state||(r.state={}),r.__n=s,d=r.__d=!0,r.__h=[],r._sb=[]),m&&r.__s==null&&(r.__s=r.state),m&&_.getDerivedStateFromProps!=null&&(r.__s==r.state&&(r.__s=T({},r.__s)),T(r.__s,_.getDerivedStateFromProps(v,r.__s))),h=r.props,k=r.state,r.__v=e,d)m&&_.getDerivedStateFromProps==null&&r.componentWillMount!=null&&r.componentWillMount(),m&&r.componentDidMount!=null&&r.__h.push(r.componentDidMount);else{if(m&&_.getDerivedStateFromProps==null&&v!==h&&r.componentWillReceiveProps!=null&&r.componentWillReceiveProps(v,E),e.__v==n.__v||!r.__e&&r.shouldComponentUpdate!=null&&r.shouldComponentUpdate(v,r.__s,E)===!1){for(e.__v!=n.__v&&(r.props=v,r.state=r.__s,r.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(w){w&&(w.__=e)}),W=0;W<r._sb.length;W++)r.__h.push(r._sb[W]);r._sb=[],r.__h.length&&a.push(r);break e}r.componentWillUpdate!=null&&r.componentWillUpdate(v,r.__s,E),m&&r.componentDidUpdate!=null&&r.__h.push(function(){r.componentDidUpdate(h,k,P)})}if(r.context=E,r.props=v,r.__P=t,r.__e=!1,H=y.__r,j=0,m){for(r.state=r.__s,r.__d=!1,H&&H(e),g=r.render(r.props,r.state,r.context),R=0;R<r._sb.length;R++)r.__h.push(r._sb[R]);r._sb=[]}else do r.__d=!1,H&&H(e),g=r.render(r.props,r.state,r.context),r.state=r.__s;while(r.__d&&++j<25);r.state=r.__s,r.getChildContext!=null&&(s=T(T({},s),r.getChildContext())),m&&!d&&r.getSnapshotBeforeUpdate!=null&&(P=r.getSnapshotBeforeUpdate(h,k)),$=g,g!=null&&g.type===I&&g.key==null&&($=Te(g.props.children)),l=Ee(t,Y($)?$:[$],e,n,s,o,i,a,l,p,c),r.base=e.__e,e.__u&=-161,r.__h.length&&a.push(r),f&&(r.__E=r.__=null)}catch(w){if(e.__v=null,p||i!=null)if(w.then){for(e.__u|=p?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;i[i.indexOf(l)]=null,e.__e=l}else{for(F=i.length;F--;)re(i[F]);oe(e)}else e.__e=n.__e,e.__k=n.__k,w.then||oe(e);y.__e(w,e,n)}else i==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):l=e.__e=kt(n.__e,e,n,s,o,i,a,p,c);return(g=y.diffed)&&g(e),128&e.__u?void 0:l}function oe(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(oe)}function Ie(t,e,n){for(var s=0;s<n.length;s++)le(n[s],n[++s],n[++s]);y.__c&&y.__c(e,t),t.some(function(o){try{t=o.__h,o.__h=[],t.some(function(i){i.call(o)})}catch(i){y.__e(i,o.__v)}})}function Te(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:Y(t)?t.map(Te):T({},t)}function kt(t,e,n,s,o,i,a,l,p){var c,g,r,d,h,k,P,f=n.props||U,v=e.props,m=e.type;if(m=="svg"?o="http://www.w3.org/2000/svg":m=="math"?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),i!=null){for(c=0;c<i.length;c++)if((h=i[c])&&"setAttribute"in h==!!m&&(m?h.localName==m:h.nodeType==3)){t=h,i[c]=null;break}}if(t==null){if(m==null)return document.createTextNode(v);t=document.createElementNS(o,m,v.is&&v),l&&(y.__m&&y.__m(e,i),l=!1),i=null}if(m==null)f===v||l&&t.data==v||(t.data=v);else{if(i=i&&G.call(t.childNodes),!l&&i!=null)for(f={},c=0;c<t.attributes.length;c++)f[(h=t.attributes[c]).name]=h.value;for(c in f)if(h=f[c],c!="children"){if(c=="dangerouslySetInnerHTML")r=h;else if(!(c in v)){if(c=="value"&&"defaultValue"in v||c=="checked"&&"defaultChecked"in v)continue;B(t,c,null,h,o)}}for(c in v)h=v[c],c=="children"?d=h:c=="dangerouslySetInnerHTML"?g=h:c=="value"?k=h:c=="checked"?P=h:l&&typeof h!="function"||f[c]===h||B(t,c,h,f[c],o);if(g)l||r&&(g.__html==r.__html||g.__html==t.innerHTML)||(t.innerHTML=g.__html),e.__k=[];else if(r&&(t.innerHTML=""),Ee(e.type=="template"?t.content:t,Y(d)?d:[d],e,n,s,m=="foreignObject"?"http://www.w3.org/1999/xhtml":o,i,a,i?i[0]:n.__k&&L(n,0),l,p),i!=null)for(c=i.length;c--;)re(i[c]);l||(c="value",m=="progress"&&k==null?t.removeAttribute("value"):k!=null&&(k!==t[c]||m=="progress"&&!k||m=="option"&&k!=f[c])&&B(t,c,k,f[c],o),c="checked",P!=null&&P!=t[c]&&B(t,c,P,f[c],o))}return t}function le(t,e,n){try{if(typeof t=="function"){var s=typeof t.__u=="function";s&&t.__u(),s&&e==null||(t.__u=t(e))}else t.current=e}catch(o){y.__e(o,n)}}function Me(t,e,n){var s,o;if(y.unmount&&y.unmount(t),(s=t.ref)&&(s.current&&s.current!=t.__e||le(s,null,e)),(s=t.__c)!=null){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(i){y.__e(i,e)}s.base=s.__P=null}if(s=t.__k)for(o=0;o<s.length;o++)s[o]&&Me(s[o],e,n||typeof t.type!="function");n||re(t.__e),t.__c=t.__=t.__e=void 0}function xt(t,e,n){return this.constructor(t,n)}function pe(t,e,n){var s,o,i,a;e==document&&(e=document.documentElement),y.__&&y.__(t,e),o=(s=typeof n=="function")?null:n&&n.__k||e.__k,i=[],a=[],ce(e,t=(!s&&n||e).__k=ae(I,null,[t]),o||U,U,e.namespaceURI,!s&&n?[n]:o?null:e.firstChild?G.call(e.childNodes):null,i,!s&&n?n:o?o.__e:e.firstChild,s,a),Ie(i,t,a)}G=Se.slice,y={__e:function(t,e,n,s){for(var o,i,a;e=e.__;)if((o=e.__c)&&!o.__)try{if((i=o.constructor)&&i.getDerivedStateFromError!=null&&(o.setState(i.getDerivedStateFromError(t)),a=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(t,s||{}),a=o.__d),a)return o.__E=o}catch(l){t=l}throw t}},be=0,ft=function(t){return t!=null&&t.constructor===void 0},J.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=T({},this.state),typeof t=="function"&&(t=t(T({},n),this.props)),t&&T(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),me(this))},J.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),me(this))},J.prototype.render=I,N=[],ke=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,xe=function(t,e){return t.__v.__b-e.__v.__b},X.__r=0,we=/(PointerCapture)$|Capture$/i,ie=0,ne=ye(!1),se=ye(!0),mt=0;var D,x,de,$e,z=0,Fe=[],S=y,Oe=S.__b,Ae=S.__r,He=S.diffed,Re=S.__c,Ne=S.unmount,Le=S.__;function ge(t,e){S.__h&&S.__h(x,t,z||e),z=0;var n=x.__H||(x.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function M(t){return z=1,wt(ze,t)}function wt(t,e,n){var s=ge(D++,2);if(s.t=t,!s.__c&&(s.__=[n?n(e):ze(void 0,e),function(l){var p=s.__N?s.__N[0]:s.__[0],c=s.t(p,l);p!==c&&(s.__N=[c,s.__[1]],s.__c.setState({}))}],s.__c=x,!x.__f)){var o=function(l,p,c){if(!s.__c.__H)return!0;var g=s.__c.__H.__.filter(function(d){return!!d.__c});if(g.every(function(d){return!d.__N}))return!i||i.call(this,l,p,c);var r=s.__c.props!==l;return g.forEach(function(d){if(d.__N){var h=d.__[0];d.__=d.__N,d.__N=void 0,h!==d.__[0]&&(r=!0)}}),i&&i.call(this,l,p,c)||r};x.__f=!0;var i=x.shouldComponentUpdate,a=x.componentWillUpdate;x.componentWillUpdate=function(l,p,c){if(this.__e){var g=i;i=void 0,o(l,p,c),i=g}a&&a.call(this,l,p,c)},x.shouldComponentUpdate=o}return s.__N||s.__}function O(t,e){var n=ge(D++,3);!S.__s&&De(n.__H,e)&&(n.__=t,n.u=e,x.__H.__h.push(n))}function he(t){return z=5,Ve(function(){return{current:t}},[])}function Ve(t,e){var n=ge(D++,7);return De(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function Ue(t,e){return z=8,Ve(function(){return t},e)}function St(){for(var t;t=Fe.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(Z),t.__H.__h.forEach(ue),t.__H.__h=[]}catch(e){t.__H.__h=[],S.__e(e,t.__v)}}S.__b=function(t){x=null,Oe&&Oe(t)},S.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Le&&Le(t,e)},S.__r=function(t){Ae&&Ae(t),D=0;var e=(x=t.__c).__H;e&&(de===x?(e.__h=[],x.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(Z),e.__h.forEach(ue),e.__h=[],D=0)),de=x},S.diffed=function(t){He&&He(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Fe.push(e)!==1&&$e===S.requestAnimationFrame||(($e=S.requestAnimationFrame)||Pt)(St)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),de=x=null},S.__c=function(t,e){e.some(function(n){try{n.__h.forEach(Z),n.__h=n.__h.filter(function(s){return!s.__||ue(s)})}catch(s){e.some(function(o){o.__h&&(o.__h=[])}),e=[],S.__e(s,n.__v)}}),Re&&Re(t,e)},S.unmount=function(t){Ne&&Ne(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(s){try{Z(s)}catch(o){e=o}}),n.__H=void 0,e&&S.__e(e,n.__v))};var We=typeof requestAnimationFrame=="function";function Pt(t){var e,n=function(){clearTimeout(s),We&&cancelAnimationFrame(e),setTimeout(t)},s=setTimeout(n,35);We&&(e=requestAnimationFrame(n))}function Z(t){var e=x,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),x=e}function ue(t){var e=x;t.__c=t.__(),x=e}function De(t,e){return!t||t.length!==e.length||e.some(function(n,s){return n!==t[s]})}function ze(t,e){return typeof e=="function"?e(t):e}function je(t,e){let n=e==="dark",s={bg:n?"#1f2937":"#ffffff",bgSecondary:n?"#374151":"#f3f4f6",text:n?"#f9fafb":"#111827",textSecondary:n?"#9ca3af":"#6b7280",border:n?"#4b5563":"#e5e7eb",messageBg:n?"#374151":"#f3f4f6"};return`
|
|
1
|
+
"use strict";var PocketPing=(()=>{var xe=Object.defineProperty;var tn=Object.getOwnPropertyDescriptor;var nn=Object.getOwnPropertyNames;var sn=Object.prototype.hasOwnProperty;var on=(t,e)=>{for(var n in e)xe(t,n,{get:e[n],enumerable:!0})},rn=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of nn(e))!sn.call(t,i)&&i!==n&&xe(t,i,{get:()=>e[i],enumerable:!(s=tn(e,i))||s.enumerable});return t};var an=t=>rn(xe({},"__esModule",{value:!0}),t);var In={};on(In,{close:()=>Pt,default:()=>Tn,destroy:()=>St,getIdentity:()=>Ft,getTrackedElements:()=>Rt,identify:()=>Lt,init:()=>Ae,offEvent:()=>Dt,on:()=>Nt,onEvent:()=>Ot,open:()=>Et,reset:()=>Ht,sendMessage:()=>It,setupTrackedElements:()=>At,toggle:()=>Tt,trigger:()=>$t,uploadFile:()=>Ct,uploadFiles:()=>Mt});var le,w,Je,ln,J,Ve,Xe,Ye,Ge,ke,ye,be,pn,Z={},Ke=[],cn=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,pe=Array.isArray;function V(t,e){for(var n in e)t[n]=e[n];return t}function Se(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function Ee(t,e,n){var s,i,a,r={};for(a in e)a=="key"?s=e[a]:a=="ref"?i=e[a]:r[a]=e[a];if(arguments.length>2&&(r.children=arguments.length>3?le.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(a in t.defaultProps)r[a]===void 0&&(r[a]=t.defaultProps[a]);return oe(t,r,s,i,null)}function oe(t,e,n,s,i){var a={type:t,props:e,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Je,__i:-1,__u:0};return i==null&&w.vnode!=null&&w.vnode(a),a}function D(t){return t.children}function re(t,e){this.props=t,this.context=e}function Y(t,e){if(e==null)return t.__?Y(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?Y(t):null}function Qe(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return Qe(t)}}function je(t){(!t.__d&&(t.__d=!0)&&J.push(t)&&!ae.__r++||Ve!=w.debounceRendering)&&((Ve=w.debounceRendering)||Xe)(ae)}function ae(){for(var t,e,n,s,i,a,r,c=1;J.length;)J.length>c&&J.sort(Ye),t=J.shift(),c=J.length,t.__d&&(n=void 0,s=void 0,i=(s=(e=t).__v).__e,a=[],r=[],e.__P&&((n=V({},s)).__v=s.__v+1,w.vnode&&w.vnode(n),Pe(e.__P,n,s,e.__n,e.__P.namespaceURI,32&s.__u?[i]:null,a,i??Y(s),!!(32&s.__u),r),n.__v=s.__v,n.__.__k[n.__i]=n,tt(a,n,r),s.__e=s.__=null,n.__e!=i&&Qe(n)));ae.__r=0}function Ze(t,e,n,s,i,a,r,c,u,p,g){var l,h,f,S,A,k,_,b=s&&s.__k||Ke,L=e.length;for(u=dn(n,e,b,u,L),l=0;l<L;l++)(f=n.__k[l])!=null&&(h=f.__i==-1?Z:b[f.__i]||Z,f.__i=l,k=Pe(t,f,h,i,a,r,c,u,p,g),S=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&Te(h.ref,null,f),g.push(f.ref,f.__c||S,f)),A==null&&S!=null&&(A=S),(_=!!(4&f.__u))||h.__k===f.__k?u=et(f,u,t,_):typeof f.type=="function"&&k!==void 0?u=k:S&&(u=S.nextSibling),f.__u&=-7);return n.__e=A,u}function dn(t,e,n,s,i){var a,r,c,u,p,g=n.length,l=g,h=0;for(t.__k=new Array(i),a=0;a<i;a++)(r=e[a])!=null&&typeof r!="boolean"&&typeof r!="function"?(typeof r=="string"||typeof r=="number"||typeof r=="bigint"||r.constructor==String?r=t.__k[a]=oe(null,r,null,null,null):pe(r)?r=t.__k[a]=oe(D,{children:r},null,null,null):r.constructor===void 0&&r.__b>0?r=t.__k[a]=oe(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):t.__k[a]=r,u=a+h,r.__=t,r.__b=t.__b+1,c=null,(p=r.__i=un(r,n,u,l))!=-1&&(l--,(c=n[p])&&(c.__u|=2)),c==null||c.__v==null?(p==-1&&(i>g?h--:i<g&&h++),typeof r.type!="function"&&(r.__u|=4)):p!=u&&(p==u-1?h--:p==u+1?h++:(p>u?h--:h++,r.__u|=4))):t.__k[a]=null;if(l)for(a=0;a<g;a++)(c=n[a])!=null&&(2&c.__u)==0&&(c.__e==s&&(s=Y(c)),st(c,c));return s}function et(t,e,n,s){var i,a;if(typeof t.type=="function"){for(i=t.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=t,e=et(i[a],e,n,s));return e}t.__e!=e&&(s&&(e&&t.type&&!e.parentNode&&(e=Y(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function un(t,e,n,s){var i,a,r,c=t.key,u=t.type,p=e[n],g=p!=null&&(2&p.__u)==0;if(p===null&&c==null||g&&c==p.key&&u==p.type)return n;if(s>(g?1:0)){for(i=n-1,a=n+1;i>=0||a<e.length;)if((p=e[r=i>=0?i--:a++])!=null&&(2&p.__u)==0&&c==p.key&&u==p.type)return r}return-1}function Be(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||cn.test(e)?n:n+"px"}function ie(t,e,n,s,i){var a,r;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof s=="string"&&(t.style.cssText=s=""),s)for(e in s)n&&e in n||Be(t.style,e,"");if(n)for(e in n)s&&n[e]==s[e]||Be(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")a=e!=(e=e.replace(Ge,"$1")),r=e.toLowerCase(),e=r in t||e=="onFocusOut"||e=="onFocusIn"?r.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+a]=n,n?s?n.u=s.u:(n.u=ke,t.addEventListener(e,a?be:ye,a)):t.removeEventListener(e,a?be:ye,a);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function qe(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ke++;else if(e.t<n.u)return;return n(w.event?w.event(e):e)}}}function Pe(t,e,n,s,i,a,r,c,u,p){var g,l,h,f,S,A,k,_,b,L,H,B,U,X,W,F,O,R=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),a=[c=e.__e=n.__e]),(g=w.__b)&&g(e);e:if(typeof R=="function")try{if(_=e.props,b="prototype"in R&&R.prototype.render,L=(g=R.contextType)&&s[g.__c],H=g?L?L.props.value:g.__:s,n.__c?k=(l=e.__c=n.__c).__=l.__E:(b?e.__c=l=new R(_,H):(e.__c=l=new re(_,H),l.constructor=R,l.render=hn),L&&L.sub(l),l.state||(l.state={}),l.__n=s,h=l.__d=!0,l.__h=[],l._sb=[]),b&&l.__s==null&&(l.__s=l.state),b&&R.getDerivedStateFromProps!=null&&(l.__s==l.state&&(l.__s=V({},l.__s)),V(l.__s,R.getDerivedStateFromProps(_,l.__s))),f=l.props,S=l.state,l.__v=e,h)b&&R.getDerivedStateFromProps==null&&l.componentWillMount!=null&&l.componentWillMount(),b&&l.componentDidMount!=null&&l.__h.push(l.componentDidMount);else{if(b&&R.getDerivedStateFromProps==null&&_!==f&&l.componentWillReceiveProps!=null&&l.componentWillReceiveProps(_,H),e.__v==n.__v||!l.__e&&l.shouldComponentUpdate!=null&&l.shouldComponentUpdate(_,l.__s,H)===!1){for(e.__v!=n.__v&&(l.props=_,l.state=l.__s,l.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(z){z&&(z.__=e)}),B=0;B<l._sb.length;B++)l.__h.push(l._sb[B]);l._sb=[],l.__h.length&&r.push(l);break e}l.componentWillUpdate!=null&&l.componentWillUpdate(_,l.__s,H),b&&l.componentDidUpdate!=null&&l.__h.push(function(){l.componentDidUpdate(f,S,A)})}if(l.context=H,l.props=_,l.__P=t,l.__e=!1,U=w.__r,X=0,b){for(l.state=l.__s,l.__d=!1,U&&U(e),g=l.render(l.props,l.state,l.context),W=0;W<l._sb.length;W++)l.__h.push(l._sb[W]);l._sb=[]}else do l.__d=!1,U&&U(e),g=l.render(l.props,l.state,l.context),l.state=l.__s;while(l.__d&&++X<25);l.state=l.__s,l.getChildContext!=null&&(s=V(V({},s),l.getChildContext())),b&&!h&&l.getSnapshotBeforeUpdate!=null&&(A=l.getSnapshotBeforeUpdate(f,S)),F=g,g!=null&&g.type===D&&g.key==null&&(F=nt(g.props.children)),c=Ze(t,pe(F)?F:[F],e,n,s,i,a,r,c,u,p),l.base=e.__e,e.__u&=-161,l.__h.length&&r.push(l),k&&(l.__E=l.__=null)}catch(z){if(e.__v=null,u||a!=null)if(z.then){for(e.__u|=u?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;a[a.indexOf(c)]=null,e.__e=c}else{for(O=a.length;O--;)Se(a[O]);we(e)}else e.__e=n.__e,e.__k=n.__k,z.then||we(e);w.__e(z,e,n)}else a==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):c=e.__e=gn(n.__e,e,n,s,i,a,r,u,p);return(g=w.diffed)&&g(e),128&e.__u?void 0:c}function we(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(we)}function tt(t,e,n){for(var s=0;s<n.length;s++)Te(n[s],n[++s],n[++s]);w.__c&&w.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(a){a.call(i)})}catch(a){w.__e(a,i.__v)}})}function nt(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:pe(t)?t.map(nt):V({},t)}function gn(t,e,n,s,i,a,r,c,u){var p,g,l,h,f,S,A,k=n.props||Z,_=e.props,b=e.type;if(b=="svg"?i="http://www.w3.org/2000/svg":b=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),a!=null){for(p=0;p<a.length;p++)if((f=a[p])&&"setAttribute"in f==!!b&&(b?f.localName==b:f.nodeType==3)){t=f,a[p]=null;break}}if(t==null){if(b==null)return document.createTextNode(_);t=document.createElementNS(i,b,_.is&&_),c&&(w.__m&&w.__m(e,a),c=!1),a=null}if(b==null)k===_||c&&t.data==_||(t.data=_);else{if(a=a&&le.call(t.childNodes),!c&&a!=null)for(k={},p=0;p<t.attributes.length;p++)k[(f=t.attributes[p]).name]=f.value;for(p in k)if(f=k[p],p!="children"){if(p=="dangerouslySetInnerHTML")l=f;else if(!(p in _)){if(p=="value"&&"defaultValue"in _||p=="checked"&&"defaultChecked"in _)continue;ie(t,p,null,f,i)}}for(p in _)f=_[p],p=="children"?h=f:p=="dangerouslySetInnerHTML"?g=f:p=="value"?S=f:p=="checked"?A=f:c&&typeof f!="function"||k[p]===f||ie(t,p,f,k[p],i);if(g)c||l&&(g.__html==l.__html||g.__html==t.innerHTML)||(t.innerHTML=g.__html),e.__k=[];else if(l&&(t.innerHTML=""),Ze(e.type=="template"?t.content:t,pe(h)?h:[h],e,n,s,b=="foreignObject"?"http://www.w3.org/1999/xhtml":i,a,r,a?a[0]:n.__k&&Y(n,0),c,u),a!=null)for(p=a.length;p--;)Se(a[p]);c||(p="value",b=="progress"&&S==null?t.removeAttribute("value"):S!=null&&(S!==t[p]||b=="progress"&&!S||b=="option"&&S!=k[p])&&ie(t,p,S,k[p],i),p="checked",A!=null&&A!=t[p]&&ie(t,p,A,k[p],i))}return t}function Te(t,e,n){try{if(typeof t=="function"){var s=typeof t.__u=="function";s&&t.__u(),s&&e==null||(t.__u=t(e))}else t.current=e}catch(i){w.__e(i,n)}}function st(t,e,n){var s,i;if(w.unmount&&w.unmount(t),(s=t.ref)&&(s.current&&s.current!=t.__e||Te(s,null,e)),(s=t.__c)!=null){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(a){w.__e(a,e)}s.base=s.__P=null}if(s=t.__k)for(i=0;i<s.length;i++)s[i]&&st(s[i],e,n||typeof t.type!="function");n||Se(t.__e),t.__c=t.__=t.__e=void 0}function hn(t,e,n){return this.constructor(t,n)}function Ie(t,e,n){var s,i,a,r;e==document&&(e=document.documentElement),w.__&&w.__(t,e),i=(s=typeof n=="function")?null:n&&n.__k||e.__k,a=[],r=[],Pe(e,t=(!s&&n||e).__k=Ee(D,null,[t]),i||Z,Z,e.namespaceURI,!s&&n?[n]:i?null:e.firstChild?le.call(e.childNodes):null,a,!s&&n?n:i?i.__e:e.firstChild,s,r),tt(a,t,r)}le=Ke.slice,w={__e:function(t,e,n,s){for(var i,a,r;e=e.__;)if((i=e.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(t)),r=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,s||{}),r=i.__d),r)return i.__E=i}catch(c){t=c}throw t}},Je=0,ln=function(t){return t!=null&&t.constructor===void 0},re.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=V({},this.state),typeof t=="function"&&(t=t(V({},n),this.props)),t&&V(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),je(this))},re.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),je(this))},re.prototype.render=D,J=[],Xe=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ye=function(t,e){return t.__v.__b-e.__v.__b},ae.__r=0,Ge=/(PointerCapture)$|Capture$/i,ke=0,ye=qe(!1),be=qe(!0),pn=0;var ee,C,Ce,it,te=0,ut=[],M=w,ot=M.__b,rt=M.__r,at=M.diffed,lt=M.__c,pt=M.unmount,ct=M.__;function $e(t,e){M.__h&&M.__h(C,t,te||e),te=0;var n=C.__H||(C.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function $(t){return te=1,fn(mt,t)}function fn(t,e,n){var s=$e(ee++,2);if(s.t=t,!s.__c&&(s.__=[n?n(e):mt(void 0,e),function(c){var u=s.__N?s.__N[0]:s.__[0],p=s.t(u,c);u!==p&&(s.__N=[p,s.__[1]],s.__c.setState({}))}],s.__c=C,!C.__f)){var i=function(c,u,p){if(!s.__c.__H)return!0;var g=s.__c.__H.__.filter(function(h){return!!h.__c});if(g.every(function(h){return!h.__N}))return!a||a.call(this,c,u,p);var l=s.__c.props!==c;return g.forEach(function(h){if(h.__N){var f=h.__[0];h.__=h.__N,h.__N=void 0,f!==h.__[0]&&(l=!0)}}),a&&a.call(this,c,u,p)||l};C.__f=!0;var a=C.shouldComponentUpdate,r=C.componentWillUpdate;C.componentWillUpdate=function(c,u,p){if(this.__e){var g=a;a=void 0,i(c,u,p),a=g}r&&r.call(this,c,u,p)},C.shouldComponentUpdate=i}return s.__N||s.__}function j(t,e){var n=$e(ee++,3);!M.__s&&ft(n.__H,e)&&(n.__=t,n.u=e,C.__H.__h.push(n))}function G(t){return te=5,gt(function(){return{current:t}},[])}function gt(t,e){var n=$e(ee++,7);return ft(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function ht(t,e){return te=8,gt(function(){return t},e)}function mn(){for(var t;t=ut.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(ce),t.__H.__h.forEach(Me),t.__H.__h=[]}catch(e){t.__H.__h=[],M.__e(e,t.__v)}}M.__b=function(t){C=null,ot&&ot(t)},M.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),ct&&ct(t,e)},M.__r=function(t){rt&&rt(t),ee=0;var e=(C=t.__c).__H;e&&(Ce===C?(e.__h=[],C.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(ce),e.__h.forEach(Me),e.__h=[],ee=0)),Ce=C},M.diffed=function(t){at&&at(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(ut.push(e)!==1&&it===M.requestAnimationFrame||((it=M.requestAnimationFrame)||_n)(mn)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Ce=C=null},M.__c=function(t,e){e.some(function(n){try{n.__h.forEach(ce),n.__h=n.__h.filter(function(s){return!s.__||Me(s)})}catch(s){e.some(function(i){i.__h&&(i.__h=[])}),e=[],M.__e(s,n.__v)}}),lt&<(t,e)},M.unmount=function(t){pt&&pt(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(s){try{ce(s)}catch(i){e=i}}),n.__H=void 0,e&&M.__e(e,n.__v))};var dt=typeof requestAnimationFrame=="function";function _n(t){var e,n=function(){clearTimeout(s),dt&&cancelAnimationFrame(e),setTimeout(t)},s=setTimeout(n,35);dt&&(e=requestAnimationFrame(n))}function ce(t){var e=C,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),C=e}function Me(t){var e=C;t.__c=t.__(),C=e}function ft(t,e){return!t||t.length!==e.length||e.some(function(n,s){return n!==t[s]})}function mt(t,e){return typeof e=="function"?e(t):e}function _t(t,e){let n=e==="dark",s={bg:n?"#1f2937":"#ffffff",bgSecondary:n?"#374151":"#f3f4f6",text:n?"#f9fafb":"#111827",textSecondary:n?"#9ca3af":"#6b7280",border:n?"#4b5563":"#e5e7eb",messageBg:n?"#374151":"#f3f4f6"};return`
|
|
2
2
|
#pocketping-container {
|
|
3
3
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
4
4
|
font-size: 14px;
|
|
@@ -172,6 +172,12 @@
|
|
|
172
172
|
border-radius: 4px;
|
|
173
173
|
opacity: 0.8;
|
|
174
174
|
transition: opacity 0.2s;
|
|
175
|
+
flex-shrink: 0;
|
|
176
|
+
width: 28px;
|
|
177
|
+
height: 28px;
|
|
178
|
+
display: flex;
|
|
179
|
+
align-items: center;
|
|
180
|
+
justify-content: center;
|
|
175
181
|
}
|
|
176
182
|
|
|
177
183
|
.pp-close-btn:hover {
|
|
@@ -179,8 +185,8 @@
|
|
|
179
185
|
}
|
|
180
186
|
|
|
181
187
|
.pp-close-btn svg {
|
|
182
|
-
width:
|
|
183
|
-
height:
|
|
188
|
+
width: 16px;
|
|
189
|
+
height: 16px;
|
|
184
190
|
}
|
|
185
191
|
|
|
186
192
|
.pp-messages {
|
|
@@ -204,6 +210,94 @@
|
|
|
204
210
|
padding: 10px 14px;
|
|
205
211
|
border-radius: 16px;
|
|
206
212
|
word-wrap: break-word;
|
|
213
|
+
position: relative;
|
|
214
|
+
user-select: text;
|
|
215
|
+
-webkit-user-select: text;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/* Hover actions container - positioned above message (Slack style) */
|
|
219
|
+
.pp-message-actions {
|
|
220
|
+
position: absolute;
|
|
221
|
+
top: -28px;
|
|
222
|
+
display: flex;
|
|
223
|
+
gap: 2px;
|
|
224
|
+
background: ${s.bg};
|
|
225
|
+
border: 1px solid ${s.border};
|
|
226
|
+
border-radius: 6px;
|
|
227
|
+
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
|
|
228
|
+
padding: 2px;
|
|
229
|
+
opacity: 0;
|
|
230
|
+
animation: pp-actions-fade-in 0.12s ease forwards;
|
|
231
|
+
z-index: 10;
|
|
232
|
+
/* Reset color inheritance from message */
|
|
233
|
+
color: ${s.textSecondary};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
@keyframes pp-actions-fade-in {
|
|
237
|
+
from { opacity: 0; transform: translateY(4px); }
|
|
238
|
+
to { opacity: 1; transform: translateY(0); }
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/* Visitor messages: actions aligned right */
|
|
242
|
+
.pp-actions-left {
|
|
243
|
+
right: 0;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/* Operator messages: actions aligned left */
|
|
247
|
+
.pp-actions-right {
|
|
248
|
+
left: 0;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.pp-message-actions .pp-action-btn {
|
|
252
|
+
width: 24px;
|
|
253
|
+
height: 24px;
|
|
254
|
+
border: none;
|
|
255
|
+
background: transparent;
|
|
256
|
+
border-radius: 4px;
|
|
257
|
+
cursor: pointer;
|
|
258
|
+
display: flex;
|
|
259
|
+
align-items: center;
|
|
260
|
+
justify-content: center;
|
|
261
|
+
color: ${s.textSecondary} !important;
|
|
262
|
+
transition: background 0.1s, color 0.1s;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.pp-message-actions .pp-action-btn:hover {
|
|
266
|
+
background: ${s.bgSecondary};
|
|
267
|
+
color: ${s.text} !important;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.pp-message-actions .pp-action-btn svg {
|
|
271
|
+
width: 14px;
|
|
272
|
+
height: 14px;
|
|
273
|
+
stroke: ${s.textSecondary};
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.pp-message-actions .pp-action-btn:hover svg {
|
|
277
|
+
stroke: ${s.text};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.pp-message-actions .pp-action-delete:hover {
|
|
281
|
+
background: #fef2f2;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.pp-message-actions .pp-action-delete:hover svg {
|
|
285
|
+
stroke: #ef4444;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.pp-theme-dark .pp-message-actions .pp-action-delete:hover {
|
|
289
|
+
background: #7f1d1d;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.pp-theme-dark .pp-message-actions .pp-action-delete:hover svg {
|
|
293
|
+
stroke: #fca5a5;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/* Hide hover actions on mobile */
|
|
297
|
+
@media (hover: none) and (pointer: coarse) {
|
|
298
|
+
.pp-message-actions {
|
|
299
|
+
display: none;
|
|
300
|
+
}
|
|
207
301
|
}
|
|
208
302
|
|
|
209
303
|
.pp-message-visitor {
|
|
@@ -354,7 +448,500 @@
|
|
|
354
448
|
.pp-footer a:hover {
|
|
355
449
|
text-decoration: underline;
|
|
356
450
|
}
|
|
357
|
-
`}var Et=0;function u(t,e,n,s,o,i){e||(e={});var a,l,p=e;if("ref"in p)for(l in p={},e)l=="ref"?a=e[l]:p[l]=e[l];var c={type:t,props:p,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Et,__i:-1,__u:0,__source:o,__self:i};if(typeof t=="function"&&(a=t.defaultProps))for(l in a)p[l]===void 0&&(p[l]=a[l]);return y.vnode&&y.vnode(c),c}function qe({client:t,config:e}){let[n,s]=M(!1),[o,i]=M([]),[a,l]=M(""),[p,c]=M(!1),[g,r]=M(!1),[d,h]=M(!1),[k,P]=M(0),[f,v]=M(e),m=he(null),C=he(null);O(()=>{let _=t.on("openChange",s),w=t.on("message",()=>{i([...t.getMessages()])}),V=t.on("typing",ee=>{c(ee.isTyping)}),at=t.on("presence",ee=>{r(ee.online)}),ct=t.on("connect",()=>{h(!0),i(t.getMessages()),r(t.getSession()?.operatorOnline??!1),v(t.getConfig())}),lt=t.on("configUpdate",()=>{v(t.getConfig())});return t.isConnected()&&(h(!0),i(t.getMessages()),r(t.getSession()?.operatorOnline??!1),v(t.getConfig())),()=>{_(),w(),V(),at(),ct(),lt()}},[t]),O(()=>{n&&m.current?.scrollIntoView({behavior:"smooth"})},[o,n]),O(()=>{n&&(setTimeout(()=>{m.current?.scrollIntoView({behavior:"auto"})},50),C.current?.focus(),P(0))},[n]),O(()=>{if(!n&&o.length>0){let _=o.filter(w=>w.sender!=="visitor"&&w.status!=="read").length;P(_)}},[o,n]);let E=Ue(()=>{if(!n||!d)return;let _=o.filter(w=>w.sender!=="visitor"&&w.status!=="read");if(_.length>0){let w=_.map(V=>V.id);t.sendReadStatus(w,"read")}},[n,d,o,t]);if(O(()=>{if(!n||!d)return;let _=setTimeout(()=>{E()},1e3);return()=>clearTimeout(_)},[n,d,o,E]),O(()=>{let _=()=>{document.visibilityState==="visible"&&n&&E()};return document.addEventListener("visibilitychange",_),()=>document.removeEventListener("visibilitychange",_)},[n,E]),O(()=>{let _=t.on("read",()=>{i([...t.getMessages()])});return()=>_()},[t]),!Ct(f))return null;let H=async _=>{if(_.preventDefault(),!a.trim())return;let w=a;l("");try{await t.sendMessage(w)}catch(V){console.error("[PocketPing] Failed to send message:",V)}},j=_=>{let w=_.target;l(w.value),t.sendTyping(!0)},R=f.position??"bottom-right",$=It(f.theme??"auto"),F=f.primaryColor??"#6366f1";return u(I,{children:[u("style",{children:je(F,$)}),u("button",{class:`pp-toggle pp-${R}`,onClick:()=>t.toggleOpen(),"aria-label":n?"Close chat":"Open chat",children:[n?u(Be,{}):u(Mt,{}),!n&&k>0&&u("span",{class:"pp-unread-badge",children:k>9?"9+":k}),!n&&k===0&&g&&u("span",{class:"pp-online-dot"})]}),n&&u("div",{class:`pp-window pp-${R} pp-theme-${$}`,children:[u("div",{class:"pp-header",children:[u("div",{class:"pp-header-info",children:[f.operatorAvatar&&u("img",{src:f.operatorAvatar,alt:"",class:"pp-avatar"}),u("div",{children:[u("div",{class:"pp-header-title",children:f.operatorName??"Support"}),u("div",{class:"pp-header-status",children:g?u(I,{children:[u("span",{class:"pp-status-dot pp-online"})," Online"]}):u(I,{children:[u("span",{class:"pp-status-dot"})," Away"]})})]})]}),u("button",{class:"pp-close-btn",onClick:()=>t.setOpen(!1),"aria-label":"Close chat",children:u(Be,{})})]}),u("div",{class:"pp-messages",children:[f.welcomeMessage&&o.length===0&&u("div",{class:"pp-welcome",children:f.welcomeMessage}),o.map(_=>u("div",{class:`pp-message pp-message-${_.sender}`,children:[u("div",{class:"pp-message-content",children:_.content}),u("div",{class:"pp-message-time",children:[Tt(_.timestamp),_.sender==="ai"&&u("span",{class:"pp-ai-badge",children:"AI"}),_.sender==="visitor"&&u("span",{class:`pp-status pp-status-${_.status??"sent"}`,children:u(Ot,{status:_.status})})]})]},_.id)),p&&u("div",{class:"pp-message pp-message-operator pp-typing",children:[u("span",{}),u("span",{}),u("span",{})]}),u("div",{ref:m})]}),u("form",{class:"pp-input-form",onSubmit:H,children:[u("input",{ref:C,type:"text",class:"pp-input",placeholder:f.placeholder??"Type a message...",value:a,onInput:j,disabled:!d}),u("button",{type:"submit",class:"pp-send-btn",disabled:!a.trim()||!d,"aria-label":"Send message",children:u($t,{})})]}),u("div",{class:"pp-footer",children:["Powered by ",u("a",{href:"https://pocketping.io",target:"_blank",rel:"noopener",children:"PocketPing"})]})]})]})}function Ct(t){let e=window.location.pathname;return t.hideOnPages?.some(n=>new RegExp(n).test(e))?!1:t.showOnPages?.length?t.showOnPages.some(n=>new RegExp(n).test(e)):!0}function It(t){return t==="auto"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t}function Tt(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Mt(){return u("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:u("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function Be(){return u("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[u("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),u("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function $t(){return u("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[u("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),u("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function Ot({status:t}){return!t||t==="sending"||t==="sent"?u("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"2",class:"pp-check",children:u("polyline",{points:"3 8 7 12 13 4"})}):t==="delivered"?u("svg",{viewBox:"0 0 20 16",fill:"none",stroke:"currentColor","stroke-width":"2",class:"pp-check-double",children:[u("polyline",{points:"1 8 5 12 11 4"}),u("polyline",{points:"7 8 11 12 17 4"})]}):t==="read"?u("svg",{viewBox:"0 0 20 16",fill:"none",stroke:"currentColor","stroke-width":"2",class:"pp-check-double pp-check-read",children:[u("polyline",{points:"1 8 5 12 11 4"}),u("polyline",{points:"7 8 11 12 17 4"})]}):null}var K="0.3.6";var Q=class{constructor(e){this.session=null;this.ws=null;this.sse=null;this.isOpen=!1;this.listeners=new Map;this.customEventHandlers=new Map;this.reconnectAttempts=0;this.maxReconnectAttempts=5;this.reconnectTimeout=null;this.pollingTimeout=null;this.pollingFailures=0;this.maxPollingFailures=10;this.wsConnectedAt=0;this.quickFailureThreshold=2e3;this.connectionMode="none";this.trackedElementCleanups=[];this.currentTrackedElements=[];this.inspectorMode=!1;this.inspectorCleanup=null;this.config=e}async connect(){let e=this.getOrCreateVisitorId(),n=this.getStoredSessionId(),s=this.getStoredIdentity(),i=new URLSearchParams(window.location.search).get("pp_inspector"),a=await this.fetch("/connect",{method:"POST",body:JSON.stringify({visitorId:e,sessionId:n,inspectorToken:i||void 0,metadata:{url:window.location.href,referrer:document.referrer||void 0,pageTitle:document.title||void 0,userAgent:navigator.userAgent,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,language:navigator.language,screenResolution:`${window.screen.width}x${window.screen.height}`},identity:s||void 0})});return this.session={sessionId:a.sessionId,visitorId:a.visitorId,operatorOnline:a.operatorOnline??!1,messages:a.messages??[],identity:a.identity||s||void 0},a.operatorName&&(this.config.operatorName=a.operatorName),a.operatorAvatar&&(this.config.operatorAvatar=a.operatorAvatar),a.primaryColor&&(this.config.primaryColor=a.primaryColor),a.welcomeMessage&&(this.config.welcomeMessage=a.welcomeMessage),this.emit("configUpdate",{operatorName:this.config.operatorName,operatorAvatar:this.config.operatorAvatar,primaryColor:this.config.primaryColor,welcomeMessage:this.config.welcomeMessage}),this.storeSessionId(a.sessionId),this.connectRealtime(),a.inspectorMode?this.enableInspectorMode():a.trackedElements?.length&&this.setupTrackedElements(a.trackedElements),this.emit("connect",this.session),this.config.onConnect?.(a.sessionId),this.session}disconnect(){this.ws&&(this.ws.onclose=null,this.ws.onmessage=null,this.ws.onerror=null,this.ws.onopen=null,this.ws.close(),this.ws=null),this.sse&&(this.sse.close(),this.sse=null),this.session=null,this.connectionMode="none",this.reconnectTimeout&&clearTimeout(this.reconnectTimeout),this.stopPolling(),this.cleanupTrackedElements(),this.disableInspectorMode()}async sendMessage(e){if(!this.session)throw new Error("Not connected");let n=`temp-${this.generateId()}`,s={id:n,sessionId:this.session.sessionId,content:e,sender:"visitor",timestamp:new Date().toISOString(),status:"sending"};this.session.messages.push(s),this.emit("message",s);try{let o=await this.fetch("/message",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,content:e,sender:"visitor"})}),i=this.session.messages.findIndex(l=>l.id===n);i>=0&&(this.session.messages[i].id=o.messageId,this.session.messages[i].timestamp=o.timestamp,this.session.messages[i].status="sent",this.emit("message",this.session.messages[i]));let a=this.session.messages[i]||{id:o.messageId,sessionId:this.session.sessionId,content:e,sender:"visitor",timestamp:o.timestamp,status:"sent"};return this.config.onMessage?.(a),a}catch(o){let i=this.session.messages.findIndex(a=>a.id===n);throw i>=0&&(this.session.messages.splice(i,1),this.emit("message",s)),o}}async fetchMessages(e){if(!this.session)throw new Error("Not connected");let n=new URLSearchParams({sessionId:this.session.sessionId});return e&&n.set("after",e),(await this.fetch(`/messages?${n}`,{method:"GET"})).messages}async sendTyping(e=!0){this.session&&await this.fetch("/typing",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,sender:"visitor",isTyping:e})})}async sendReadStatus(e,n){if(!(!this.session||e.length===0))try{await this.fetch("/read",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,messageIds:e,status:n})});for(let s of this.session.messages)e.includes(s.id)&&(s.status=n,n==="delivered"?s.deliveredAt=new Date().toISOString():n==="read"&&(s.readAt=new Date().toISOString()));this.emit("readStatusSent",{messageIds:e,status:n})}catch(s){console.error("[PocketPing] Failed to send read status:",s)}}async getPresence(){return this.fetch("/presence",{method:"GET"})}async identify(e){if(!e?.id)throw new Error("[PocketPing] identity.id is required");if(this.storeIdentity(e),this.session)try{await this.fetch("/identify",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,identity:e})}),this.session.identity=e,this.emit("identify",e)}catch(n){throw console.error("[PocketPing] Failed to identify:",n),n}}async reset(e){this.clearIdentity(),this.session&&(this.session.identity=void 0),e?.newSession&&(localStorage.removeItem("pocketping_session_id"),localStorage.removeItem("pocketping_visitor_id"),this.disconnect(),await this.connect()),this.emit("reset",null)}getIdentity(){return this.session?.identity||this.getStoredIdentity()}getSession(){return this.session}getMessages(){return this.session?.messages??[]}isConnected(){return this.session!==null}isWidgetOpen(){return this.isOpen}getConfig(){return this.config}setOpen(e){this.isOpen=e,this.emit("openChange",e),e?this.config.onOpen?.():this.config.onClose?.()}toggleOpen(){this.setOpen(!this.isOpen)}on(e,n){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(n),()=>{this.listeners.get(e)?.delete(n)}}emit(e,n){this.listeners.get(e)?.forEach(s=>s(n))}trigger(e,n,s){if(!this.ws||this.ws.readyState!==WebSocket.OPEN){console.warn("[PocketPing] Cannot trigger event: WebSocket not connected");return}let o={name:e,data:n,timestamp:new Date().toISOString()};this.ws.send(JSON.stringify({type:"event",data:o})),this.emit(`event:${e}`,o),s?.widgetMessage&&(this.setOpen(!0),this.emit("triggerMessage",{message:s.widgetMessage,eventName:e}))}onEvent(e,n){return this.customEventHandlers.has(e)||this.customEventHandlers.set(e,new Set),this.customEventHandlers.get(e).add(n),()=>{this.customEventHandlers.get(e)?.delete(n)}}offEvent(e,n){this.customEventHandlers.get(e)?.delete(n)}emitCustomEvent(e){let n=this.customEventHandlers.get(e.name);n&&n.forEach(s=>s(e.data,e)),this.emit("event",e),this.emit(`event:${e.name}`,e)}setupTrackedElements(e){this.cleanupTrackedElements(),this.currentTrackedElements=e;for(let n of e){let s=n.event||"click",o=a=>{let l={...n.data,selector:n.selector,elementText:a.target?.textContent?.trim().slice(0,100),url:window.location.href};this.trigger(n.name,l,{widgetMessage:n.widgetMessage})},i=a=>{a.target?.closest(n.selector)&&o(a)};document.addEventListener(s,i,!0),this.trackedElementCleanups.push(()=>{document.removeEventListener(s,i,!0)})}e.length>0&&console.info(`[PocketPing] Tracking ${e.length} element(s)`)}cleanupTrackedElements(){for(let e of this.trackedElementCleanups)e();this.trackedElementCleanups=[],this.currentTrackedElements=[]}getTrackedElements(){return[...this.currentTrackedElements]}enableInspectorMode(){if(this.inspectorMode)return;this.inspectorMode=!0,console.info("[PocketPing] \u{1F50D} Inspector mode active - click on any element to select it");let e=document.createElement("div");e.id="pp-inspector-overlay",e.innerHTML=`
|
|
451
|
+
|
|
452
|
+
/* Attachment Styles */
|
|
453
|
+
.pp-file-input {
|
|
454
|
+
/* Use offscreen positioning instead of display:none for better browser compatibility */
|
|
455
|
+
position: absolute;
|
|
456
|
+
width: 1px;
|
|
457
|
+
height: 1px;
|
|
458
|
+
padding: 0;
|
|
459
|
+
margin: -1px;
|
|
460
|
+
overflow: hidden;
|
|
461
|
+
clip: rect(0, 0, 0, 0);
|
|
462
|
+
white-space: nowrap;
|
|
463
|
+
border: 0;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
.pp-attach-btn {
|
|
467
|
+
width: 40px;
|
|
468
|
+
height: 40px;
|
|
469
|
+
border-radius: 50%;
|
|
470
|
+
background: transparent;
|
|
471
|
+
color: ${s.textSecondary};
|
|
472
|
+
border: 1px solid ${s.border};
|
|
473
|
+
cursor: pointer;
|
|
474
|
+
display: flex;
|
|
475
|
+
align-items: center;
|
|
476
|
+
justify-content: center;
|
|
477
|
+
transition: color 0.2s, border-color 0.2s;
|
|
478
|
+
flex-shrink: 0;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
.pp-attach-btn:hover:not(:disabled) {
|
|
482
|
+
color: ${t};
|
|
483
|
+
border-color: ${t};
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
.pp-attach-btn:disabled {
|
|
487
|
+
opacity: 0.5;
|
|
488
|
+
cursor: not-allowed;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
.pp-attach-btn svg {
|
|
492
|
+
width: 18px;
|
|
493
|
+
height: 18px;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
.pp-attachments-preview {
|
|
497
|
+
display: flex;
|
|
498
|
+
gap: 8px;
|
|
499
|
+
padding: 8px 12px;
|
|
500
|
+
border-top: 1px solid ${s.border};
|
|
501
|
+
overflow-x: auto;
|
|
502
|
+
background: ${s.bgSecondary};
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
.pp-attachment-preview {
|
|
506
|
+
position: relative;
|
|
507
|
+
width: 60px;
|
|
508
|
+
height: 60px;
|
|
509
|
+
border-radius: 8px;
|
|
510
|
+
overflow: hidden;
|
|
511
|
+
flex-shrink: 0;
|
|
512
|
+
background: ${s.bg};
|
|
513
|
+
border: 1px solid ${s.border};
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
.pp-preview-img {
|
|
517
|
+
width: 100%;
|
|
518
|
+
height: 100%;
|
|
519
|
+
object-fit: cover;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
.pp-preview-file {
|
|
523
|
+
width: 100%;
|
|
524
|
+
height: 100%;
|
|
525
|
+
display: flex;
|
|
526
|
+
align-items: center;
|
|
527
|
+
justify-content: center;
|
|
528
|
+
color: ${s.textSecondary};
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
.pp-preview-file svg {
|
|
532
|
+
width: 24px;
|
|
533
|
+
height: 24px;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
.pp-remove-attachment {
|
|
537
|
+
position: absolute;
|
|
538
|
+
top: 2px;
|
|
539
|
+
right: 2px;
|
|
540
|
+
width: 18px;
|
|
541
|
+
height: 18px;
|
|
542
|
+
border-radius: 50%;
|
|
543
|
+
background: rgba(0, 0, 0, 0.6);
|
|
544
|
+
color: white;
|
|
545
|
+
border: none;
|
|
546
|
+
cursor: pointer;
|
|
547
|
+
display: flex;
|
|
548
|
+
align-items: center;
|
|
549
|
+
justify-content: center;
|
|
550
|
+
padding: 0;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
.pp-remove-attachment svg {
|
|
554
|
+
width: 10px;
|
|
555
|
+
height: 10px;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
.pp-upload-progress {
|
|
559
|
+
position: absolute;
|
|
560
|
+
bottom: 0;
|
|
561
|
+
left: 0;
|
|
562
|
+
height: 3px;
|
|
563
|
+
background: ${t};
|
|
564
|
+
transition: width 0.1s;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
.pp-upload-error {
|
|
568
|
+
position: absolute;
|
|
569
|
+
top: 50%;
|
|
570
|
+
left: 50%;
|
|
571
|
+
transform: translate(-50%, -50%);
|
|
572
|
+
width: 24px;
|
|
573
|
+
height: 24px;
|
|
574
|
+
border-radius: 50%;
|
|
575
|
+
background: #ef4444;
|
|
576
|
+
color: white;
|
|
577
|
+
font-weight: bold;
|
|
578
|
+
display: flex;
|
|
579
|
+
align-items: center;
|
|
580
|
+
justify-content: center;
|
|
581
|
+
font-size: 14px;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
.pp-attachment-uploading {
|
|
585
|
+
opacity: 0.7;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
.pp-attachment-error {
|
|
589
|
+
border-color: #ef4444;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/* Message Attachments */
|
|
593
|
+
.pp-message-attachments {
|
|
594
|
+
display: flex;
|
|
595
|
+
flex-direction: column;
|
|
596
|
+
gap: 8px;
|
|
597
|
+
margin-top: 4px;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
.pp-attachment {
|
|
601
|
+
display: block;
|
|
602
|
+
text-decoration: none;
|
|
603
|
+
color: inherit;
|
|
604
|
+
border-radius: 8px;
|
|
605
|
+
overflow: hidden;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
.pp-attachment-image img {
|
|
609
|
+
max-width: 200px;
|
|
610
|
+
max-height: 200px;
|
|
611
|
+
border-radius: 8px;
|
|
612
|
+
display: block;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
.pp-attachment-audio {
|
|
616
|
+
display: flex;
|
|
617
|
+
flex-direction: column;
|
|
618
|
+
gap: 4px;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
.pp-attachment-audio audio {
|
|
622
|
+
width: 200px;
|
|
623
|
+
height: 36px;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
.pp-attachment-audio .pp-attachment-name {
|
|
627
|
+
font-size: 11px;
|
|
628
|
+
opacity: 0.7;
|
|
629
|
+
white-space: nowrap;
|
|
630
|
+
overflow: hidden;
|
|
631
|
+
text-overflow: ellipsis;
|
|
632
|
+
max-width: 200px;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
.pp-attachment-video video {
|
|
636
|
+
max-width: 200px;
|
|
637
|
+
max-height: 200px;
|
|
638
|
+
border-radius: 8px;
|
|
639
|
+
display: block;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
.pp-attachment-file {
|
|
643
|
+
display: flex;
|
|
644
|
+
align-items: center;
|
|
645
|
+
gap: 8px;
|
|
646
|
+
padding: 8px 12px;
|
|
647
|
+
background: ${n?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.05)"};
|
|
648
|
+
border-radius: 8px;
|
|
649
|
+
transition: background 0.2s;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
.pp-attachment-file:hover {
|
|
653
|
+
background: ${n?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.08)"};
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
.pp-attachment-file svg {
|
|
657
|
+
width: 24px;
|
|
658
|
+
height: 24px;
|
|
659
|
+
flex-shrink: 0;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
.pp-attachment-info {
|
|
663
|
+
display: flex;
|
|
664
|
+
flex-direction: column;
|
|
665
|
+
min-width: 0;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
.pp-attachment-name {
|
|
669
|
+
font-size: 13px;
|
|
670
|
+
font-weight: 500;
|
|
671
|
+
white-space: nowrap;
|
|
672
|
+
overflow: hidden;
|
|
673
|
+
text-overflow: ellipsis;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
.pp-attachment-size {
|
|
677
|
+
font-size: 11px;
|
|
678
|
+
opacity: 0.7;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/* Drag & Drop */
|
|
682
|
+
.pp-dragging {
|
|
683
|
+
position: relative;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
.pp-drop-overlay {
|
|
687
|
+
position: absolute;
|
|
688
|
+
inset: 0;
|
|
689
|
+
background: ${n?"rgba(0,0,0,0.9)":"rgba(255,255,255,0.95)"};
|
|
690
|
+
display: flex;
|
|
691
|
+
flex-direction: column;
|
|
692
|
+
align-items: center;
|
|
693
|
+
justify-content: center;
|
|
694
|
+
gap: 12px;
|
|
695
|
+
z-index: 100;
|
|
696
|
+
border: 3px dashed ${t};
|
|
697
|
+
border-radius: 16px;
|
|
698
|
+
margin: 4px;
|
|
699
|
+
pointer-events: none;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
.pp-drop-icon svg {
|
|
703
|
+
width: 48px;
|
|
704
|
+
height: 48px;
|
|
705
|
+
color: ${t};
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
.pp-drop-text {
|
|
709
|
+
font-size: 16px;
|
|
710
|
+
font-weight: 500;
|
|
711
|
+
color: ${s.text};
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/* Message Context Menu */
|
|
715
|
+
.pp-message-menu {
|
|
716
|
+
position: fixed;
|
|
717
|
+
background: ${s.bg};
|
|
718
|
+
border: 1px solid ${s.border};
|
|
719
|
+
border-radius: 8px;
|
|
720
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
|
721
|
+
padding: 4px;
|
|
722
|
+
z-index: 200;
|
|
723
|
+
min-width: 120px;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
.pp-message-menu button {
|
|
727
|
+
display: flex;
|
|
728
|
+
align-items: center;
|
|
729
|
+
gap: 8px;
|
|
730
|
+
width: 100%;
|
|
731
|
+
padding: 8px 12px;
|
|
732
|
+
border: none;
|
|
733
|
+
background: transparent;
|
|
734
|
+
color: ${s.text};
|
|
735
|
+
font-size: 13px;
|
|
736
|
+
cursor: pointer;
|
|
737
|
+
border-radius: 4px;
|
|
738
|
+
text-align: left;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
.pp-message-menu button:hover {
|
|
742
|
+
background: ${n?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.05)"};
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
.pp-message-menu button svg {
|
|
746
|
+
width: 16px;
|
|
747
|
+
height: 16px;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
.pp-menu-delete {
|
|
751
|
+
color: #ef4444 !important;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/* Edit Modal */
|
|
755
|
+
.pp-edit-modal {
|
|
756
|
+
position: absolute;
|
|
757
|
+
bottom: 80px;
|
|
758
|
+
left: 12px;
|
|
759
|
+
right: 12px;
|
|
760
|
+
background: ${s.bg};
|
|
761
|
+
border: 1px solid ${s.border};
|
|
762
|
+
border-radius: 12px;
|
|
763
|
+
box-shadow: 0 4px 20px rgba(0,0,0,0.15);
|
|
764
|
+
z-index: 150;
|
|
765
|
+
overflow: hidden;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
.pp-edit-header {
|
|
769
|
+
display: flex;
|
|
770
|
+
justify-content: space-between;
|
|
771
|
+
align-items: center;
|
|
772
|
+
padding: 12px 16px;
|
|
773
|
+
border-bottom: 1px solid ${s.border};
|
|
774
|
+
font-weight: 500;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
.pp-edit-header button {
|
|
778
|
+
background: transparent;
|
|
779
|
+
border: none;
|
|
780
|
+
color: ${s.textSecondary};
|
|
781
|
+
cursor: pointer;
|
|
782
|
+
padding: 4px;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
.pp-edit-header button svg {
|
|
786
|
+
width: 18px;
|
|
787
|
+
height: 18px;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
.pp-edit-input {
|
|
791
|
+
width: 100%;
|
|
792
|
+
padding: 12px 16px;
|
|
793
|
+
border: none;
|
|
794
|
+
background: transparent;
|
|
795
|
+
color: ${s.text};
|
|
796
|
+
font-size: 14px;
|
|
797
|
+
resize: none;
|
|
798
|
+
min-height: 80px;
|
|
799
|
+
outline: none;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
.pp-edit-actions {
|
|
803
|
+
display: flex;
|
|
804
|
+
justify-content: flex-end;
|
|
805
|
+
gap: 8px;
|
|
806
|
+
padding: 12px 16px;
|
|
807
|
+
border-top: 1px solid ${s.border};
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
.pp-edit-cancel {
|
|
811
|
+
padding: 8px 16px;
|
|
812
|
+
border: 1px solid ${s.border};
|
|
813
|
+
border-radius: 6px;
|
|
814
|
+
background: transparent;
|
|
815
|
+
color: ${s.text};
|
|
816
|
+
font-size: 13px;
|
|
817
|
+
cursor: pointer;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
.pp-edit-save {
|
|
821
|
+
padding: 8px 16px;
|
|
822
|
+
border: none;
|
|
823
|
+
border-radius: 6px;
|
|
824
|
+
background: ${t};
|
|
825
|
+
color: white;
|
|
826
|
+
font-size: 13px;
|
|
827
|
+
cursor: pointer;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
.pp-edit-save:disabled {
|
|
831
|
+
opacity: 0.5;
|
|
832
|
+
cursor: not-allowed;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/* Reply Preview */
|
|
836
|
+
.pp-reply-preview {
|
|
837
|
+
display: flex;
|
|
838
|
+
align-items: center;
|
|
839
|
+
gap: 8px;
|
|
840
|
+
padding: 8px 12px;
|
|
841
|
+
background: ${n?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.03)"};
|
|
842
|
+
border-top: 1px solid ${s.border};
|
|
843
|
+
border-left: 3px solid ${t};
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
.pp-reply-preview-content {
|
|
847
|
+
flex: 1;
|
|
848
|
+
min-width: 0;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
.pp-reply-label {
|
|
852
|
+
display: block;
|
|
853
|
+
font-size: 11px;
|
|
854
|
+
color: ${t};
|
|
855
|
+
font-weight: 500;
|
|
856
|
+
margin-bottom: 2px;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
.pp-reply-text {
|
|
860
|
+
display: block;
|
|
861
|
+
font-size: 12px;
|
|
862
|
+
color: ${s.textSecondary};
|
|
863
|
+
white-space: nowrap;
|
|
864
|
+
overflow: hidden;
|
|
865
|
+
text-overflow: ellipsis;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
.pp-reply-cancel {
|
|
869
|
+
background: transparent;
|
|
870
|
+
border: none;
|
|
871
|
+
color: ${s.textSecondary};
|
|
872
|
+
cursor: pointer;
|
|
873
|
+
padding: 4px;
|
|
874
|
+
flex-shrink: 0;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
.pp-reply-cancel svg {
|
|
878
|
+
width: 16px;
|
|
879
|
+
height: 16px;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
/* Reply Quote in Message */
|
|
883
|
+
.pp-reply-quote {
|
|
884
|
+
background: ${n?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.05)"};
|
|
885
|
+
border-left: 2px solid ${t};
|
|
886
|
+
padding: 4px 8px;
|
|
887
|
+
margin-bottom: 6px;
|
|
888
|
+
border-radius: 0 4px 4px 0;
|
|
889
|
+
font-size: 12px;
|
|
890
|
+
position: relative;
|
|
891
|
+
z-index: 1;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
.pp-reply-sender {
|
|
895
|
+
display: block;
|
|
896
|
+
font-weight: 500;
|
|
897
|
+
color: ${t};
|
|
898
|
+
margin-bottom: 2px;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
.pp-reply-content {
|
|
902
|
+
display: block;
|
|
903
|
+
color: ${s.textSecondary};
|
|
904
|
+
white-space: nowrap;
|
|
905
|
+
overflow: hidden;
|
|
906
|
+
text-overflow: ellipsis;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/* Reply quote in visitor message bubble needs higher contrast */
|
|
910
|
+
.pp-message-visitor .pp-reply-quote {
|
|
911
|
+
background: rgba(255, 255, 255, 0.18);
|
|
912
|
+
border-left-color: rgba(255, 255, 255, 0.7);
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
.pp-message-visitor .pp-reply-sender,
|
|
916
|
+
.pp-message-visitor .pp-reply-content {
|
|
917
|
+
color: rgba(255, 255, 255, 0.9);
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
/* Deleted Message */
|
|
921
|
+
.pp-message-deleted {
|
|
922
|
+
opacity: 0.6;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
.pp-deleted-content {
|
|
926
|
+
font-style: italic;
|
|
927
|
+
color: ${s.textSecondary};
|
|
928
|
+
display: flex;
|
|
929
|
+
align-items: center;
|
|
930
|
+
gap: 4px;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
.pp-deleted-icon {
|
|
934
|
+
font-size: 12px;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
/* Edited Badge */
|
|
938
|
+
.pp-edited-badge {
|
|
939
|
+
font-size: 10px;
|
|
940
|
+
color: ${s.textSecondary};
|
|
941
|
+
margin-left: 4px;
|
|
942
|
+
font-style: italic;
|
|
943
|
+
}
|
|
944
|
+
`}var vn=0;function o(t,e,n,s,i,a){e||(e={});var r,c,u=e;if("ref"in u)for(c in u={},e)c=="ref"?r=e[c]:u[c]=e[c];var p={type:t,props:u,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--vn,__i:-1,__u:0,__source:i,__self:a};if(typeof t=="function"&&(r=t.defaultProps))for(c in r)u[c]===void 0&&(u[c]=r[c]);return w.vnode&&w.vnode(p),p}function wt({client:t,config:e}){let[n,s]=$(!1),[i,a]=$([]),[r,c]=$(""),[u,p]=$(!1),[g,l]=$(!1),[h,f]=$(!1),[S,A]=$(0),[k,_]=$([]),[b,L]=$(!1),[H,B]=$(null),[U,X]=$(null),[W,F]=$(""),[O,R]=$(null),[z,ge]=$(!1),[Ut,Re]=$(null),[Oe,De]=$(null),[N,he]=$(e),fe=G(null),me=G(null),Le=G(null),Wt=G(null);j(()=>{let d=t.on("openChange",s),v=t.on("message",()=>{a([...t.getMessages()])}),P=t.on("typing",m=>{p(m.isTyping)}),x=t.on("presence",m=>{l(m.online)}),E=t.on("connect",()=>{f(!0),a(t.getMessages()),l(t.getSession()?.operatorOnline??!1),he(t.getConfig())}),T=t.on("configUpdate",()=>{he(t.getConfig())});return t.isConnected()&&(f(!0),a(t.getMessages()),l(t.getSession()?.operatorOnline??!1),he(t.getConfig())),()=>{d(),v(),P(),x(),E(),T()}},[t]),j(()=>{n&&fe.current?.scrollIntoView({behavior:"smooth"})},[i,n]),j(()=>{n&&(setTimeout(()=>{fe.current?.scrollIntoView({behavior:"auto"})},50),me.current?.focus(),A(0))},[n]),j(()=>{if(!n&&i.length>0){let d=i.filter(v=>v.sender!=="visitor"&&v.status!=="read").length;A(d)}},[i,n]);let se=ht(()=>{if(!n||!h)return;let d=i.filter(v=>v.sender!=="visitor"&&v.status!=="read");if(d.length>0){let v=d.map(P=>P.id);t.sendReadStatus(v,"read")}},[n,h,i,t]);if(j(()=>{if(!n||!h)return;let d=setTimeout(()=>{se()},1e3);return()=>clearTimeout(d)},[n,h,i,se]),j(()=>{let d=()=>{document.visibilityState==="visible"&&n&&se()};return document.addEventListener("visibilitychange",d),()=>document.removeEventListener("visibilitychange",d)},[n,se]),j(()=>{let d=t.on("read",()=>{a([...t.getMessages()])});return()=>d()},[t]),!xn(N))return null;let zt=async d=>{d.preventDefault();let v=r.trim().length>0,P=k.filter(m=>m.status==="ready"&&m.attachment);if(!v&&P.length===0)return;let x=r,E=P.map(m=>m.attachment.id),T=H?.id;c(""),_([]),B(null);try{await t.sendMessage(x,E,T)}catch(m){console.error("[PocketPing] Failed to send message:",m)}},Vt=d=>{let v=d.target;c(v.value),t.sendTyping(!0)},jt=async d=>{let v=d.target,P=v.files;if(!P||P.length===0)return;let x=[];for(let E=0;E<P.length;E++){let T=P[E],m=`pending-${Date.now()}-${E}`,I;T.type.startsWith("image/")&&(I=URL.createObjectURL(T)),x.push({id:m,file:T,preview:I,progress:0,status:"pending"})}_(E=>[...E,...x]),v.value="",L(!0);for(let E of x)try{_(m=>m.map(I=>I.id===E.id?{...I,status:"uploading"}:I));let T=await t.uploadFile(E.file,m=>{_(I=>I.map(ve=>ve.id===E.id?{...ve,progress:m}:ve))});_(m=>m.map(I=>I.id===E.id?{...I,status:"ready",progress:100,attachment:T}:I))}catch(T){console.error("[PocketPing] Failed to upload file:",T),_(m=>m.map(I=>I.id===E.id?{...I,status:"error",error:"Upload failed"}:I))}L(!1)},Bt=d=>{_(v=>{let P=v.find(x=>x.id===d);return P?.preview&&URL.revokeObjectURL(P.preview),v.filter(x=>x.id!==d)})},He=d=>{B(d),R(null),me.current?.focus()},qt=()=>{B(null)},Fe=d=>{d.sender==="visitor"&&(X(d),F(d.content),R(null))},Ne=()=>{X(null),F("")},Jt=async()=>{if(!(!U||!W.trim()))try{await t.editMessage(U.id,W.trim()),X(null),F("")}catch(d){console.error("[PocketPing] Failed to edit message:",d)}},Ue=async d=>{if(d.sender==="visitor"&&(R(null),confirm("Delete this message?")))try{await t.deleteMessage(d.id)}catch(v){console.error("[PocketPing] Failed to delete message:",v)}},Xt=(d,v)=>{d.preventDefault();let P=d;R({message:v,x:P.clientX,y:P.clientY})},Yt=d=>{let v=setTimeout(()=>{navigator.vibrate&&navigator.vibrate(50),R({message:d,x:window.innerWidth/2-60,y:window.innerHeight/2-50})},500);De(v)},We=()=>{Oe&&(clearTimeout(Oe),De(null))};j(()=>{if(!O)return;let d=()=>R(null);return document.addEventListener("click",d),()=>document.removeEventListener("click",d)},[O]);let K=G(0),Gt=d=>{d.preventDefault(),d.stopPropagation(),K.current++,K.current===1&&ge(!0)},Kt=d=>{d.preventDefault(),d.stopPropagation()},Qt=d=>{d.preventDefault(),d.stopPropagation(),K.current--,K.current===0&&ge(!1)},Zt=async d=>{d.preventDefault(),d.stopPropagation(),K.current=0,ge(!1);let v=d.dataTransfer?.files;if(!v||v.length===0)return;let P=[];for(let x=0;x<v.length;x++){let E=v[x],T=`pending-${Date.now()}-${x}`,m;E.type.startsWith("image/")&&(m=URL.createObjectURL(E)),P.push({id:T,file:E,preview:m,progress:0,status:"pending"})}_(x=>[...x,...P]),L(!0);for(let x of P)try{_(T=>T.map(m=>m.id===x.id?{...m,status:"uploading"}:m));let E=await t.uploadFile(x.file,T=>{_(m=>m.map(I=>I.id===x.id?{...I,progress:T}:I))});_(T=>T.map(m=>m.id===x.id?{...m,status:"ready",progress:100,attachment:E}:m))}catch(E){console.error("[PocketPing] Failed to upload dropped file:",E),_(T=>T.map(m=>m.id===x.id?{...m,status:"error",error:"Upload failed"}:m))}L(!1)},ze=N.position??"bottom-right",_e=yn(N.theme??"auto"),en=N.primaryColor??"#6366f1",Q=_e==="dark"?"#9ca3af":"#6b7280";return o(D,{children:[o("style",{children:_t(en,_e)}),o("button",{class:`pp-toggle pp-${ze}`,onClick:()=>t.toggleOpen(),"aria-label":n?"Close chat":"Open chat",children:[n?o(ne,{}):o(wn,{}),!n&&S>0&&o("span",{class:"pp-unread-badge",children:S>9?"9+":S}),!n&&S===0&&g&&o("span",{class:"pp-online-dot"})]}),n&&o("div",{class:`pp-window pp-${ze} pp-theme-${_e} ${z?"pp-dragging":""}`,onDragEnter:Gt,onDragOver:Kt,onDragLeave:Qt,onDrop:Zt,children:[z&&o("div",{class:"pp-drop-overlay",children:[o("div",{class:"pp-drop-icon",children:o(vt,{})}),o("div",{class:"pp-drop-text",children:"Drop files to upload"})]}),o("div",{class:"pp-header",children:[o("div",{class:"pp-header-info",children:[N.operatorAvatar&&o("img",{src:N.operatorAvatar,alt:"",class:"pp-avatar"}),o("div",{children:[o("div",{class:"pp-header-title",children:N.operatorName??"Support"}),o("div",{class:"pp-header-status",children:g?o(D,{children:[o("span",{class:"pp-status-dot pp-online"})," Online"]}):o(D,{children:[o("span",{class:"pp-status-dot"})," Away"]})})]})]}),o("button",{class:"pp-close-btn",onClick:()=>t.setOpen(!1),"aria-label":"Close chat",children:o(ne,{})})]}),o("div",{class:"pp-messages",ref:Wt,children:[N.welcomeMessage&&i.length===0&&o("div",{class:"pp-welcome",children:N.welcomeMessage}),i.map(d=>{let v=!!d.deletedAt,P=!!d.editedAt,x=null;if(d.replyTo)if(typeof d.replyTo=="object")x=d.replyTo;else{let m=i.find(I=>I.id===d.replyTo);m&&(x={sender:m.sender,content:m.content,deleted:!!m.deletedAt})}let T=Ut===d.id&&!v;return o("div",{class:`pp-message pp-message-${d.sender} ${v?"pp-message-deleted":""}`,onContextMenu:m=>Xt(m,d),onMouseEnter:()=>Re(d.id),onMouseLeave:()=>Re(null),onTouchStart:()=>Yt(d),onTouchEnd:We,onTouchCancel:We,children:[T&&o("div",{class:`pp-message-actions ${d.sender==="visitor"?"pp-actions-left":"pp-actions-right"}`,children:[o("button",{class:"pp-action-btn",onClick:()=>He(d),title:"Reply",children:o(xt,{color:Q})}),d.sender==="visitor"&&o(D,{children:[o("button",{class:"pp-action-btn",onClick:()=>Fe(d),title:"Edit",children:o(yt,{color:Q})}),o("button",{class:"pp-action-btn pp-action-delete",onClick:()=>Ue(d),title:"Delete",children:o(bt,{color:Q})})]})]}),x&&x.content&&o("div",{class:"pp-reply-quote",children:[o("span",{class:"pp-reply-sender",children:x.sender==="visitor"?"You":"Support"}),o("span",{class:"pp-reply-content",children:[x.deleted?"Message deleted":(x.content||"").slice(0,50),(x.content||"").length>50?"...":""]})]}),v?o("div",{class:"pp-message-content pp-deleted-content",children:[o("span",{class:"pp-deleted-icon",children:"\u{1F5D1}\uFE0F"})," Message deleted"]}):o(D,{children:[d.content&&o("div",{class:"pp-message-content",children:d.content}),d.attachments&&d.attachments.length>0&&o("div",{class:"pp-message-attachments",children:d.attachments.map(m=>o(En,{attachment:m},m.id))})]}),o("div",{class:"pp-message-time",children:[bn(d.timestamp),P&&!v&&o("span",{class:"pp-edited-badge",children:"edited"}),d.sender==="ai"&&o("span",{class:"pp-ai-badge",children:"AI"}),d.sender==="visitor"&&!v&&o("span",{class:`pp-status pp-status-${d.status??"sent"}`,children:o(Sn,{status:d.status})})]})]},d.id)}),u&&o("div",{class:"pp-message pp-message-operator pp-typing",children:[o("span",{}),o("span",{}),o("span",{})]}),o("div",{ref:fe})]}),O&&o("div",{class:"pp-message-menu",style:{top:`${O.y}px`,left:`${O.x}px`},children:[o("button",{onClick:()=>He(O.message),children:[o(xt,{color:Q})," Reply"]}),O.message.sender==="visitor"&&!O.message.deletedAt&&o(D,{children:[o("button",{onClick:()=>Fe(O.message),children:[o(yt,{color:Q})," Edit"]}),o("button",{class:"pp-menu-delete",onClick:()=>Ue(O.message),children:[o(bt,{color:"#ef4444"})," Delete"]})]})]}),U&&o("div",{class:"pp-edit-modal",children:[o("div",{class:"pp-edit-header",children:[o("span",{children:"Edit message"}),o("button",{onClick:Ne,children:o(ne,{})})]}),o("textarea",{class:"pp-edit-input",value:W,onInput:d=>F(d.target.value),autoFocus:!0}),o("div",{class:"pp-edit-actions",children:[o("button",{class:"pp-edit-cancel",onClick:Ne,children:"Cancel"}),o("button",{class:"pp-edit-save",onClick:Jt,disabled:!W.trim(),children:"Save"})]})]}),H&&o("div",{class:"pp-reply-preview",children:[o("div",{class:"pp-reply-preview-content",children:[o("span",{class:"pp-reply-label",children:"Replying to"}),o("span",{class:"pp-reply-text",children:[H.content.slice(0,50),H.content.length>50?"...":""]})]}),o("button",{class:"pp-reply-cancel",onClick:qt,children:o(ne,{})})]}),k.length>0&&o("div",{class:"pp-attachments-preview",children:k.map(d=>o("div",{class:`pp-attachment-preview pp-attachment-${d.status}`,children:[d.preview?o("img",{src:d.preview,alt:d.file.name,class:"pp-preview-img"}):o("div",{class:"pp-preview-file",children:o(kt,{mimeType:d.file.type})}),o("button",{class:"pp-remove-attachment",onClick:()=>Bt(d.id),"aria-label":"Remove attachment",type:"button",children:o(ne,{})}),d.status==="uploading"&&o("div",{class:"pp-upload-progress",style:{width:`${d.progress}%`}}),d.status==="error"&&o("div",{class:"pp-upload-error",title:d.error,children:"!"})]},d.id))}),o("form",{class:"pp-input-form",onSubmit:zt,children:[o("input",{ref:d=>{Le.current=d,d&&(d.onchange=jt)},type:"file",class:"pp-file-input",accept:"image/*,audio/*,video/*,.pdf,.doc,.docx,.xls,.xlsx,.txt",multiple:!0}),o("button",{type:"button",class:"pp-attach-btn",onClick:()=>Le.current?.click(),disabled:!h||b,"aria-label":"Attach file",children:o(vt,{})}),o("input",{ref:me,type:"text",class:"pp-input",placeholder:N.placeholder??"Type a message...",value:r,onInput:Vt,disabled:!h}),o("button",{type:"submit",class:"pp-send-btn",disabled:!r.trim()&&k.filter(d=>d.status==="ready").length===0||!h||b,"aria-label":"Send message",children:o(kn,{})})]}),o("div",{class:"pp-footer",children:["Powered by ",o("a",{href:"https://pocketping.io",target:"_blank",rel:"noopener",children:"PocketPing"})]})]})]})}function xn(t){let e=window.location.pathname;return t.hideOnPages?.some(n=>new RegExp(n).test(e))?!1:t.showOnPages?.length?t.showOnPages.some(n=>new RegExp(n).test(e)):!0}function yn(t){return t==="auto"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t}function bn(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function wn(){return o("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:o("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function ne(){return o("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[o("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function kn(){return o("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[o("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),o("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function Sn({status:t}){return!t||t==="sending"||t==="sent"?o("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"2",class:"pp-check",children:o("polyline",{points:"3 8 7 12 13 4"})}):t==="delivered"?o("svg",{viewBox:"0 0 20 16",fill:"none",stroke:"currentColor","stroke-width":"2",class:"pp-check-double",children:[o("polyline",{points:"1 8 5 12 11 4"}),o("polyline",{points:"7 8 11 12 17 4"})]}):t==="read"?o("svg",{viewBox:"0 0 20 16",fill:"none",stroke:"currentColor","stroke-width":"2",class:"pp-check-double pp-check-read",children:[o("polyline",{points:"1 8 5 12 11 4"}),o("polyline",{points:"7 8 11 12 17 4"})]}):null}function vt(){return o("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:o("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}function xt({color:t,size:e=16}){return o("svg",{viewBox:"0 0 24 24",fill:"none","stroke-width":"2",style:{stroke:t||"currentColor",width:`${e}px`,minWidth:`${e}px`,height:`${e}px`,display:"block",flexShrink:0},children:[o("polyline",{points:"9 17 4 12 9 7"}),o("path",{d:"M20 18v-2a4 4 0 0 0-4-4H4"})]})}function yt({color:t,size:e=16}){return o("svg",{viewBox:"0 0 24 24",fill:"none","stroke-width":"2",style:{stroke:t||"currentColor",width:`${e}px`,minWidth:`${e}px`,height:`${e}px`,display:"block",flexShrink:0},children:o("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}function bt({color:t,size:e=16}){return o("svg",{viewBox:"0 0 24 24",fill:"none","stroke-width":"2",style:{stroke:t||"currentColor",width:`${e}px`,minWidth:`${e}px`,height:`${e}px`,display:"block",flexShrink:0},children:[o("polyline",{points:"3 6 5 6 21 6"}),o("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}function kt({mimeType:t}){return t==="application/pdf"?o("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[o("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),o("polyline",{points:"14 2 14 8 20 8"}),o("path",{d:"M9 15h6"}),o("path",{d:"M9 11h6"})]}):t.startsWith("audio/")?o("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[o("path",{d:"M9 18V5l12-2v13"}),o("circle",{cx:"6",cy:"18",r:"3"}),o("circle",{cx:"18",cy:"16",r:"3"})]}):t.startsWith("video/")?o("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[o("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2.18",ry:"2.18"}),o("line",{x1:"7",y1:"2",x2:"7",y2:"22"}),o("line",{x1:"17",y1:"2",x2:"17",y2:"22"}),o("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),o("line",{x1:"2",y1:"7",x2:"7",y2:"7"}),o("line",{x1:"2",y1:"17",x2:"7",y2:"17"}),o("line",{x1:"17",y1:"17",x2:"22",y2:"17"}),o("line",{x1:"17",y1:"7",x2:"22",y2:"7"})]}):o("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[o("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),o("polyline",{points:"14 2 14 8 20 8"})]})}function En({attachment:t}){let e=t.mimeType.startsWith("image/"),n=t.mimeType.startsWith("audio/"),s=t.mimeType.startsWith("video/"),i=a=>a<1024?`${a} B`:a<1024*1024?`${(a/1024).toFixed(1)} KB`:`${(a/(1024*1024)).toFixed(1)} MB`;return e?o("a",{href:t.url,target:"_blank",rel:"noopener",class:"pp-attachment pp-attachment-image",children:o("img",{src:t.thumbnailUrl||t.url,alt:t.filename})}):n?o("div",{class:"pp-attachment pp-attachment-audio",children:[o("audio",{controls:!0,preload:"metadata",children:o("source",{src:t.url,type:t.mimeType})}),o("span",{class:"pp-attachment-name",children:t.filename})]}):s?o("div",{class:"pp-attachment pp-attachment-video",children:o("video",{controls:!0,preload:"metadata",children:o("source",{src:t.url,type:t.mimeType})})}):o("a",{href:t.url,target:"_blank",rel:"noopener",class:"pp-attachment pp-attachment-file",children:[o(kt,{mimeType:t.mimeType}),o("div",{class:"pp-attachment-info",children:[o("span",{class:"pp-attachment-name",children:t.filename}),o("span",{class:"pp-attachment-size",children:i(t.size)})]})]})}var de="0.3.6";var ue=class{constructor(e){this.session=null;this.ws=null;this.sse=null;this.isOpen=!1;this.listeners=new Map;this.customEventHandlers=new Map;this.reconnectAttempts=0;this.maxReconnectAttempts=5;this.reconnectTimeout=null;this.pollingTimeout=null;this.pollingFailures=0;this.maxPollingFailures=10;this.wsConnectedAt=0;this.quickFailureThreshold=2e3;this.connectionMode="none";this.trackedElementCleanups=[];this.currentTrackedElements=[];this.inspectorMode=!1;this.inspectorCleanup=null;this.config=e}async connect(){let e=this.getOrCreateVisitorId(),n=this.getStoredSessionId(),s=this.getStoredIdentity(),a=new URLSearchParams(window.location.search).get("pp_inspector"),r=await this.fetch("/connect",{method:"POST",body:JSON.stringify({visitorId:e,sessionId:n,inspectorToken:a||void 0,metadata:{url:window.location.href,referrer:document.referrer||void 0,pageTitle:document.title||void 0,userAgent:navigator.userAgent,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,language:navigator.language,screenResolution:`${window.screen.width}x${window.screen.height}`},identity:s||void 0})});return this.session={sessionId:r.sessionId,visitorId:r.visitorId,operatorOnline:r.operatorOnline??!1,messages:r.messages??[],identity:r.identity||s||void 0},r.operatorName&&(this.config.operatorName=r.operatorName),r.operatorAvatar&&(this.config.operatorAvatar=r.operatorAvatar),r.primaryColor&&(this.config.primaryColor=r.primaryColor),r.welcomeMessage&&(this.config.welcomeMessage=r.welcomeMessage),this.emit("configUpdate",{operatorName:this.config.operatorName,operatorAvatar:this.config.operatorAvatar,primaryColor:this.config.primaryColor,welcomeMessage:this.config.welcomeMessage}),this.storeSessionId(r.sessionId),this.connectRealtime(),r.inspectorMode?this.enableInspectorMode():r.trackedElements?.length&&this.setupTrackedElements(r.trackedElements),this.emit("connect",this.session),this.config.onConnect?.(r.sessionId),this.session}disconnect(){this.ws&&(this.ws.onclose=null,this.ws.onmessage=null,this.ws.onerror=null,this.ws.onopen=null,this.ws.close(),this.ws=null),this.sse&&(this.sse.close(),this.sse=null),this.session=null,this.connectionMode="none",this.reconnectTimeout&&clearTimeout(this.reconnectTimeout),this.stopPolling(),this.cleanupTrackedElements(),this.disableInspectorMode()}async sendMessage(e,n,s){if(!this.session)throw new Error("Not connected");let i=`temp-${this.generateId()}`,a={id:i,sessionId:this.session.sessionId,content:e,sender:"visitor",timestamp:new Date().toISOString(),status:"sending",replyTo:s};this.session.messages.push(a),this.emit("message",a);try{let r=await this.fetch("/message",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,content:e,sender:"visitor",attachmentIds:n||[],replyTo:s})}),c=this.session.messages.findIndex(p=>p.id===i);c>=0&&(this.session.messages[c].id=r.messageId,this.session.messages[c].timestamp=r.timestamp,this.session.messages[c].status="sent",r.attachments&&r.attachments.length>0&&(this.session.messages[c].attachments=r.attachments),this.emit("message",this.session.messages[c]));let u=this.session.messages[c]||{id:r.messageId,sessionId:this.session.sessionId,content:e,sender:"visitor",timestamp:r.timestamp,status:"sent",attachments:r.attachments};return this.config.onMessage?.(u),u}catch(r){let c=this.session.messages.findIndex(u=>u.id===i);throw c>=0&&(this.session.messages.splice(c,1),this.emit("message",a)),r}}async uploadFile(e,n){if(!this.session)throw new Error("Not connected");this.emit("uploadStart",{filename:e.name,size:e.size});try{let s=await this.fetch("/upload",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,filename:e.name,mimeType:e.type||"application/octet-stream",size:e.size})});n?.(10),this.emit("uploadProgress",{filename:e.name,progress:10}),await this.uploadToPresignedUrl(s.uploadUrl,e,a=>{let r=10+a*.8;n?.(r),this.emit("uploadProgress",{filename:e.name,progress:r})});let i=await this.fetch("/upload/complete",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,attachmentId:s.attachmentId})});return n?.(100),this.emit("uploadComplete",i),{id:i.id,filename:i.filename,mimeType:i.mimeType,size:i.size,url:i.url,thumbnailUrl:i.thumbnailUrl,status:i.status}}catch(s){throw this.emit("uploadError",{filename:e.name,error:s}),s}}async uploadFiles(e,n){let s=[],i=e.length;for(let a=0;a<i;a++){let r=e[a],c=a/i*100,u=100/i,p=await this.uploadFile(r,g=>{let l=c+g/100*u;n?.(l)});s.push(p)}return s}uploadToPresignedUrl(e,n,s){return new Promise((i,a)=>{let r=new XMLHttpRequest;r.upload.addEventListener("progress",c=>{if(c.lengthComputable){let u=c.loaded/c.total*100;s?.(u)}}),r.addEventListener("load",()=>{r.status>=200&&r.status<300?i():a(new Error(`Upload failed with status ${r.status}`))}),r.addEventListener("error",()=>{a(new Error("Upload failed"))}),r.open("PUT",e),r.setRequestHeader("Content-Type",n.type||"application/octet-stream"),r.send(n)})}async fetchMessages(e){if(!this.session)throw new Error("Not connected");let n=new URLSearchParams({sessionId:this.session.sessionId});return e&&n.set("after",e),(await this.fetch(`/messages?${n}`,{method:"GET"})).messages}async sendTyping(e=!0){this.session&&await this.fetch("/typing",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,sender:"visitor",isTyping:e})})}async sendReadStatus(e,n){if(!(!this.session||e.length===0))try{await this.fetch("/read",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,messageIds:e,status:n})});for(let s of this.session.messages)e.includes(s.id)&&(s.status=n,n==="delivered"?s.deliveredAt=new Date().toISOString():n==="read"&&(s.readAt=new Date().toISOString()));this.emit("readStatusSent",{messageIds:e,status:n})}catch(s){console.error("[PocketPing] Failed to send read status:",s)}}async editMessage(e,n){if(!this.session)throw new Error("Not connected");let s=await this.fetch(`/message/${e}`,{method:"PATCH",body:JSON.stringify({sessionId:this.session.sessionId,content:n})}),i=this.session.messages.findIndex(a=>a.id===e);return i>=0&&(this.session.messages[i].content=s.message.content,this.session.messages[i].editedAt=s.message.editedAt,this.emit("messageEdited",this.session.messages[i])),this.session.messages[i]}async deleteMessage(e){if(!this.session)throw new Error("Not connected");let n=await this.fetch(`/message/${e}`,{method:"DELETE",body:JSON.stringify({sessionId:this.session.sessionId})});if(n.deleted){let s=this.session.messages.findIndex(i=>i.id===e);s>=0&&(this.session.messages[s].deletedAt=new Date().toISOString(),this.session.messages[s].content="",this.emit("messageDeleted",this.session.messages[s]))}return n.deleted}async getPresence(){return this.fetch("/presence",{method:"GET"})}async identify(e){if(!e?.id)throw new Error("[PocketPing] identity.id is required");if(this.storeIdentity(e),this.session)try{await this.fetch("/identify",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,identity:e})}),this.session.identity=e,this.emit("identify",e)}catch(n){throw console.error("[PocketPing] Failed to identify:",n),n}}async reset(e){this.clearIdentity(),this.session&&(this.session.identity=void 0),e?.newSession&&(localStorage.removeItem("pocketping_session_id"),localStorage.removeItem("pocketping_visitor_id"),this.disconnect(),await this.connect()),this.emit("reset",null)}getIdentity(){return this.session?.identity||this.getStoredIdentity()}getSession(){return this.session}getMessages(){return this.session?.messages??[]}isConnected(){return this.session!==null}isWidgetOpen(){return this.isOpen}getConfig(){return this.config}setOpen(e){this.isOpen=e,this.emit("openChange",e),e?this.config.onOpen?.():this.config.onClose?.()}toggleOpen(){this.setOpen(!this.isOpen)}on(e,n){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(n),()=>{this.listeners.get(e)?.delete(n)}}emit(e,n){this.listeners.get(e)?.forEach(s=>s(n))}trigger(e,n,s){if(!this.ws||this.ws.readyState!==WebSocket.OPEN){console.warn("[PocketPing] Cannot trigger event: WebSocket not connected");return}let i={name:e,data:n,timestamp:new Date().toISOString()};this.ws.send(JSON.stringify({type:"event",data:i})),this.emit(`event:${e}`,i),s?.widgetMessage&&(this.setOpen(!0),this.emit("triggerMessage",{message:s.widgetMessage,eventName:e}))}onEvent(e,n){return this.customEventHandlers.has(e)||this.customEventHandlers.set(e,new Set),this.customEventHandlers.get(e).add(n),()=>{this.customEventHandlers.get(e)?.delete(n)}}offEvent(e,n){this.customEventHandlers.get(e)?.delete(n)}emitCustomEvent(e){let n=this.customEventHandlers.get(e.name);n&&n.forEach(s=>s(e.data,e)),this.emit("event",e),this.emit(`event:${e.name}`,e)}setupTrackedElements(e){this.cleanupTrackedElements(),this.currentTrackedElements=e;for(let n of e){let s=n.event||"click",i=r=>{let c={...n.data,selector:n.selector,elementText:r.target?.textContent?.trim().slice(0,100),url:window.location.href};this.trigger(n.name,c,{widgetMessage:n.widgetMessage})},a=r=>{r.target?.closest(n.selector)&&i(r)};document.addEventListener(s,a,!0),this.trackedElementCleanups.push(()=>{document.removeEventListener(s,a,!0)})}e.length>0&&console.info(`[PocketPing] Tracking ${e.length} element(s)`)}cleanupTrackedElements(){for(let e of this.trackedElementCleanups)e();this.trackedElementCleanups=[],this.currentTrackedElements=[]}getTrackedElements(){return[...this.currentTrackedElements]}enableInspectorMode(){if(this.inspectorMode)return;this.inspectorMode=!0,console.info("[PocketPing] \u{1F50D} Inspector mode active - click on any element to select it");let e=document.createElement("div");e.id="pp-inspector-overlay",e.innerHTML=`
|
|
358
945
|
<style>
|
|
359
946
|
#pp-inspector-overlay {
|
|
360
947
|
position: fixed;
|
|
@@ -437,9 +1024,9 @@
|
|
|
437
1024
|
<button id="pp-inspector-exit">Exit</button>
|
|
438
1025
|
</div>
|
|
439
1026
|
<div id="pp-inspector-tooltip"></div>
|
|
440
|
-
`,document.body.appendChild(e);let n=document.getElementById("pp-inspector-tooltip"),s=null,
|
|
1027
|
+
`,document.body.appendChild(e);let n=document.getElementById("pp-inspector-tooltip"),s=null,i=u=>{if(u.id&&!u.id.startsWith("pp-"))return`#${CSS.escape(u.id)}`;let p=Array.from(u.classList).filter(h=>!h.startsWith("pp-"));if(p.length>0){let h="."+p.map(f=>CSS.escape(f)).join(".");if(document.querySelectorAll(h).length===1)return h}for(let h of Array.from(u.attributes))if(h.name.startsWith("data-")&&h.value){let f=`[${h.name}="${CSS.escape(h.value)}"]`;if(document.querySelectorAll(f).length===1)return f}let g=[],l=u;for(;l&&l!==document.body;){let h=l.tagName.toLowerCase();if(l.id&&!l.id.startsWith("pp-")){h=`#${CSS.escape(l.id)}`,g.unshift(h);break}let f=l.parentElement;if(f){let S=l.tagName,A=Array.from(f.children).filter(k=>k.tagName===S);if(A.length>1){let k=A.indexOf(l)+1;h+=`:nth-of-type(${k})`}}g.unshift(h),l=f}return g.join(" > ")},a=u=>{let p=u.target;if(p.closest("#pp-inspector-overlay")||p.closest("#pocketping-widget"))return;s&&s.classList.remove("pp-inspector-highlight"),p.classList.add("pp-inspector-highlight"),s=p;let g=i(p);n.textContent=g,n.style.display="block",n.style.left=`${u.clientX+15}px`,n.style.top=`${u.clientY+15}px`;let l=n.getBoundingClientRect();l.right>window.innerWidth&&(n.style.left=`${u.clientX-l.width-15}px`),l.bottom>window.innerHeight&&(n.style.top=`${u.clientY-l.height-15}px`)},r=u=>{let p=u.target;p.closest("#pp-inspector-overlay")||(p.classList.remove("pp-inspector-highlight"),n.style.display="none")},c=u=>{let p=u.target;if(p.id==="pp-inspector-exit"){this.disableInspectorMode();return}if(p.closest("#pp-inspector-overlay")||p.closest("#pocketping-widget"))return;u.preventDefault(),u.stopPropagation();let g=i(p);this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"inspector_select",data:{selector:g,tagName:p.tagName.toLowerCase(),text:p.textContent?.trim().slice(0,50)||"",url:window.location.href}})),this.emit("inspectorSelect",{selector:g,element:p}),p.classList.remove("pp-inspector-highlight"),p.classList.add("pp-inspector-highlight"),setTimeout(()=>{p.classList.remove("pp-inspector-highlight")},500);let l=document.getElementById("pp-inspector-banner");if(l){let h=l.innerHTML;l.innerHTML=`
|
|
441
1028
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
442
1029
|
<polyline points="20 6 9 17 4 12"/>
|
|
443
1030
|
</svg>
|
|
444
1031
|
<span>Selector captured: <code style="background:rgba(255,255,255,0.2);padding:2px 6px;border-radius:4px;font-family:monospace;">${g}</code></span>
|
|
445
|
-
`,setTimeout(()=>{r&&this.inspectorMode&&(r.innerHTML=d,document.getElementById("pp-inspector-exit")?.addEventListener("click",()=>{this.disableInspectorMode()}))},2e3)}console.info(`[PocketPing] \u{1F4CC} Selector captured: ${g}`)};document.addEventListener("mouseover",i,!0),document.addEventListener("mouseout",a,!0),document.addEventListener("click",l,!0),this.inspectorCleanup=()=>{document.removeEventListener("mouseover",i,!0),document.removeEventListener("mouseout",a,!0),document.removeEventListener("click",l,!0),e.remove(),s&&s.classList.remove("pp-inspector-highlight")},document.getElementById("pp-inspector-exit")?.addEventListener("click",()=>{this.disableInspectorMode()})}disableInspectorMode(){this.inspectorMode&&(this.inspectorMode=!1,this.inspectorCleanup&&(this.inspectorCleanup(),this.inspectorCleanup=null),console.info("[PocketPing] Inspector mode disabled"),this.emit("inspectorDisabled",null))}isInspectorModeActive(){return this.inspectorMode}connectRealtime(){if(this.session){if(this.connectionMode==="polling"){this.startPolling();return}if(this.connectionMode==="sse"){this.connectSSE();return}this.connectWebSocket()}}connectWebSocket(){if(!this.session)return;let e=this.config.endpoint.replace(/^http/,"ws").replace(/\/$/,"")+`/stream?sessionId=${this.session.sessionId}`;try{this.ws=new WebSocket(e),this.wsConnectedAt=Date.now();let n=setTimeout(()=>{console.warn("[PocketPing] \u23F1\uFE0F WebSocket timeout - trying SSE"),this.ws&&this.ws.readyState!==WebSocket.OPEN&&(this.ws.onclose=null,this.ws.onerror=null,this.ws.onopen=null,this.ws.close(),this.ws=null,this.connectSSE())},5e3);this.ws.onopen=()=>{clearTimeout(n),this.connectionMode="ws",this.reconnectAttempts=0,this.wsConnectedAt=Date.now(),this.emit("wsConnected",null)},this.ws.onmessage=s=>{try{let o=JSON.parse(s.data);this.handleRealtimeEvent(o)}catch(o){console.error("[PocketPing] Failed to parse WS message:",o)}},this.ws.onclose=()=>{clearTimeout(n),this.emit("wsDisconnected",null),this.handleWsFailure()},this.ws.onerror=()=>{clearTimeout(n)}}catch{console.warn("[PocketPing] WebSocket unavailable - trying SSE"),this.connectSSE()}}connectSSE(){if(!this.session)return;let e=this.config.endpoint.replace(/\/$/,"")+`/stream?sessionId=${this.session.sessionId}`;try{this.sse=new EventSource(e);let n=setTimeout(()=>{console.warn("[PocketPing] \u23F1\uFE0F SSE timeout - falling back to polling"),this.sse&&this.sse.readyState!==EventSource.OPEN&&(this.sse.close(),this.sse=null,this.connectionMode="polling",this.startPolling())},5e3);this.sse.onopen=()=>{clearTimeout(n),this.connectionMode="sse",this.emit("sseConnected",null)},this.sse.addEventListener("message",s=>{try{let o=JSON.parse(s.data);this.handleRealtimeEvent(o)}catch(o){console.error("[PocketPing] Failed to parse SSE message:",o)}}),this.sse.addEventListener("connected",()=>{}),this.sse.onerror=()=>{clearTimeout(n),console.warn("[PocketPing] \u274C SSE error - falling back to polling"),this.sse&&(this.sse.close(),this.sse=null),this.connectionMode="polling",this.startPolling()}}catch{console.warn("[PocketPing] SSE unavailable - falling back to polling"),this.connectionMode="polling",this.startPolling()}}handleWsFailure(){if(Date.now()-this.wsConnectedAt<this.quickFailureThreshold){console.info("[PocketPing] WebSocket failed quickly - trying SSE"),this.connectSSE();return}this.scheduleReconnect()}handleRealtimeEvent(e){this.handleWebSocketEvent(e)}handleWebSocketEvent(e){switch(e.type){case"message":let n=e.data;if(this.session){let p=this.session.messages.findIndex(c=>c.id===n.id);if(p<0&&n.sender==="visitor"&&(p=this.session.messages.findIndex(c=>c.id.startsWith("temp-")&&c.content===n.content&&c.sender==="visitor"),p>=0&&(this.session.messages[p].id=n.id)),p<0&&n.sender!=="visitor"){let c=new Date(n.timestamp).getTime();p=this.session.messages.findIndex(g=>g.sender===n.sender&&g.content===n.content&&Math.abs(new Date(g.timestamp).getTime()-c)<2e3)}if(p>=0){let c=this.session.messages[p];n.status&&n.status!==c.status&&(c.status=n.status,n.deliveredAt&&(c.deliveredAt=n.deliveredAt),n.readAt&&(c.readAt=n.readAt),this.emit("read",{messageIds:[n.id],status:n.status}))}else this.session.messages.push(n),this.emit("message",n),this.config.onMessage?.(n)}n.sender!=="visitor"&&this.emit("typing",{isTyping:!1});break;case"typing":let s=e.data;s.sender!=="visitor"&&this.emit("typing",{isTyping:s.isTyping});break;case"presence":this.session&&(this.session.operatorOnline=e.data.online),this.emit("presence",e.data);break;case"ai_takeover":this.emit("aiTakeover",e.data);break;case"read":let o=e.data;if(this.session)for(let p of this.session.messages)o.messageIds.includes(p.id)&&(p.status=o.status,o.deliveredAt&&(p.deliveredAt=o.deliveredAt),o.readAt&&(p.readAt=o.readAt));this.emit("read",o);break;case"event":let i=e.data;this.emitCustomEvent(i);break;case"version_warning":let a=e.data;this.handleVersionWarning(a);break;case"config_update":let l=e.data;l.trackedElements&&(this.setupTrackedElements(l.trackedElements),this.emit("configUpdate",l));break}}handleVersionWarning(e){let n="[PocketPing]",s=e.upgradeUrl?` Upgrade: ${e.upgradeUrl}`:" Update your widget to the latest version.";switch(e.severity){case"error":console.error(`${n} \u{1F6A8} VERSION ERROR: ${e.message}${s}`),console.error(`${n} Current: ${e.currentVersion}, Required: ${e.minVersion||"unknown"}`);break;case"warning":console.warn(`${n} \u26A0\uFE0F VERSION WARNING: ${e.message}${s}`),console.warn(`${n} Current: ${e.currentVersion}, Latest: ${e.latestVersion||"unknown"}`);break;case"info":console.info(`${n} \u2139\uFE0F ${e.message}`);break}this.emit("versionWarning",e),this.config.onVersionWarning?.(e),e.canContinue||(console.error(`${n} Widget is incompatible with backend. Please update immediately.`),this.disconnect())}scheduleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts){console.warn("[PocketPing] Max reconnect attempts reached, trying SSE"),this.connectSSE();return}let e=Math.min(1e3*Math.pow(2,this.reconnectAttempts),3e4);this.reconnectAttempts++,this.reconnectTimeout=setTimeout(()=>{this.connectWebSocket()},e)}startPolling(){let e=async()=>{if(this.session){try{let n=this.session.messages[this.session.messages.length-1]?.id,s=await this.fetchMessages(n);this.pollingFailures=0;for(let o of s)this.session.messages.find(i=>i.id===o.id)||(this.session.messages.push(o),this.emit("message",o),this.config.onMessage?.(o))}catch(n){if(this.pollingFailures++,console.error("[PocketPing] \u274C Polling error:",n),(this.pollingFailures<=3||this.pollingFailures%3===0)&&console.warn(`[PocketPing] Polling failed (${this.pollingFailures}/${this.maxPollingFailures})`),this.pollingFailures>=this.maxPollingFailures){console.error("[PocketPing] Polling disabled after too many failures. Real-time updates unavailable."),this.emit("pollingDisabled",{failures:this.pollingFailures});return}}if(this.session){let n=this.pollingFailures>0?Math.min(2e3*Math.pow(2,this.pollingFailures-1),3e4):2e3;this.pollingTimeout=setTimeout(e,n)}}};this.pollingTimeout=setTimeout(e,500)}stopPolling(){this.pollingTimeout&&(clearTimeout(this.pollingTimeout),this.pollingTimeout=null),this.pollingFailures=0}async fetch(e,n){let s=this.config.endpoint.replace(/\/$/,"")+e,o=await fetch(s,{...n,headers:{"Content-Type":"application/json","X-PocketPing-Version":K,...n.headers}});if(this.checkVersionHeaders(o),!o.ok){let i=await o.text();throw new Error(`PocketPing API error: ${o.status} ${i}`)}return o.json()}checkVersionHeaders(e){let n=e.headers.get("X-PocketPing-Version-Status"),s=e.headers.get("X-PocketPing-Min-Version"),o=e.headers.get("X-PocketPing-Latest-Version"),i=e.headers.get("X-PocketPing-Version-Message");if(!n||n==="ok")return;let a="info",l=!0;n==="deprecated"?a="warning":n==="unsupported"?(a="error",l=!1):n==="outdated"&&(a="info");let p={severity:a,message:i||`Widget version ${K} is ${n}`,currentVersion:K,minVersion:s||void 0,latestVersion:o||void 0,canContinue:l,upgradeUrl:"https://docs.pocketping.io/widget/installation"};this.handleVersionWarning(p)}getOrCreateVisitorId(){let e="pocketping_visitor_id",n=localStorage.getItem(e);return n||(n=this.generateId(),localStorage.setItem(e,n)),n}getStoredSessionId(){return localStorage.getItem("pocketping_session_id")}storeSessionId(e){localStorage.setItem("pocketping_session_id",e)}getStoredIdentity(){try{let e=localStorage.getItem("pocketping_user_identity");return e?JSON.parse(e):null}catch{return null}}storeIdentity(e){localStorage.setItem("pocketping_user_identity",JSON.stringify(e))}clearIdentity(){localStorage.removeItem("pocketping_user_identity")}generateId(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}};var b=null,A=null,At="https://app.pocketping.io/api/widget";function _e(t){if(b)return console.warn("[PocketPing] Already initialized"),b;let e=t.endpoint;if(!e&&t.projectId&&(e=`${At}/${t.projectId}`),!e)throw new Error("[PocketPing] endpoint or projectId is required");let n={...t,endpoint:e};return b=new Q(n),A=document.createElement("div"),A.id="pocketping-container",document.body.appendChild(A),pe(ae(qe,{client:b,config:t}),A),b.connect().catch(s=>{console.error("[PocketPing] Failed to connect:",s)}),b}function Je(){A&&(pe(null,A),A.remove(),A=null),b&&(b.disconnect(),b=null)}function Xe(){b?.setOpen(!0)}function Ge(){b?.setOpen(!1)}function Ye(){b?.toggleOpen()}function Ze(t){if(!b)throw new Error("[PocketPing] Not initialized");return b.sendMessage(t)}function Ke(t,e,n){if(!b){console.warn("[PocketPing] Not initialized, cannot trigger event");return}b.trigger(t,e,n)}function Qe(t){if(!b){console.warn("[PocketPing] Not initialized, cannot setup tracked elements");return}b.setupTrackedElements(t)}function et(){return b?.getTrackedElements()||[]}function tt(t,e){return b?b.onEvent(t,e):(console.warn("[PocketPing] Not initialized, cannot subscribe to event"),()=>{})}function nt(t,e){b?.offEvent(t,e)}async function st(t){if(!b)throw new Error("[PocketPing] Not initialized");return b.identify(t)}async function ot(t){if(!b){console.warn("[PocketPing] Not initialized");return}return b.reset(t)}function it(){return b?.getIdentity()||null}function rt(t,e){return b?b.on(t,e):(console.warn("[PocketPing] Not initialized, cannot subscribe to event"),()=>{})}if(typeof document<"u"){let t=document.currentScript;if(t){let e=t.dataset.projectId,n=t.dataset.endpoint;(e||n)&&_e({projectId:e,endpoint:n,theme:t.dataset.theme||"auto",position:t.dataset.position||"bottom-right"})}}var Ht={init:_e,destroy:Je,open:Xe,close:Ge,toggle:Ye,sendMessage:Ze,trigger:Ke,onEvent:tt,offEvent:nt,on:rt,identify:st,reset:ot,getIdentity:it,setupTrackedElements:Qe,getTrackedElements:et};return _t(Rt);})();
|
|
1032
|
+
`,setTimeout(()=>{l&&this.inspectorMode&&(l.innerHTML=h,document.getElementById("pp-inspector-exit")?.addEventListener("click",()=>{this.disableInspectorMode()}))},2e3)}console.info(`[PocketPing] \u{1F4CC} Selector captured: ${g}`)};document.addEventListener("mouseover",a,!0),document.addEventListener("mouseout",r,!0),document.addEventListener("click",c,!0),this.inspectorCleanup=()=>{document.removeEventListener("mouseover",a,!0),document.removeEventListener("mouseout",r,!0),document.removeEventListener("click",c,!0),e.remove(),s&&s.classList.remove("pp-inspector-highlight")},document.getElementById("pp-inspector-exit")?.addEventListener("click",()=>{this.disableInspectorMode()})}disableInspectorMode(){this.inspectorMode&&(this.inspectorMode=!1,this.inspectorCleanup&&(this.inspectorCleanup(),this.inspectorCleanup=null),console.info("[PocketPing] Inspector mode disabled"),this.emit("inspectorDisabled",null))}isInspectorModeActive(){return this.inspectorMode}connectRealtime(){if(this.session){if(this.connectionMode==="polling"){this.startPolling();return}if(this.connectionMode==="sse"){this.connectSSE();return}this.connectWebSocket()}}connectWebSocket(){if(!this.session)return;let e=this.config.endpoint.replace(/^http/,"ws").replace(/\/$/,"")+`/stream?sessionId=${this.session.sessionId}`;try{this.ws=new WebSocket(e),this.wsConnectedAt=Date.now();let n=setTimeout(()=>{console.warn("[PocketPing] \u23F1\uFE0F WebSocket timeout - trying SSE"),this.ws&&this.ws.readyState!==WebSocket.OPEN&&(this.ws.onclose=null,this.ws.onerror=null,this.ws.onopen=null,this.ws.close(),this.ws=null,this.connectSSE())},5e3);this.ws.onopen=()=>{clearTimeout(n),this.connectionMode="ws",this.reconnectAttempts=0,this.wsConnectedAt=Date.now(),this.emit("wsConnected",null)},this.ws.onmessage=s=>{try{let i=JSON.parse(s.data);this.handleRealtimeEvent(i)}catch(i){console.error("[PocketPing] Failed to parse WS message:",i)}},this.ws.onclose=()=>{clearTimeout(n),this.emit("wsDisconnected",null),this.handleWsFailure()},this.ws.onerror=()=>{clearTimeout(n)}}catch{console.warn("[PocketPing] WebSocket unavailable - trying SSE"),this.connectSSE()}}connectSSE(){if(!this.session)return;let e=new URLSearchParams({sessionId:this.session.sessionId}),n=this.getLastEventTimestamp();n&&e.set("after",n);let s=this.config.endpoint.replace(/\/$/,"")+`/stream?${e.toString()}`;try{this.sse=new EventSource(s);let i=setTimeout(()=>{console.warn("[PocketPing] \u23F1\uFE0F SSE timeout - falling back to polling"),this.sse&&this.sse.readyState!==EventSource.OPEN&&(this.sse.close(),this.sse=null,this.connectionMode="polling",this.startPolling())},5e3);this.sse.onopen=()=>{clearTimeout(i),this.connectionMode="sse",this.emit("sseConnected",null)},this.sse.addEventListener("message",a=>{try{let r=JSON.parse(a.data);this.handleRealtimeEvent(r)}catch(r){console.error("[PocketPing] Failed to parse SSE message:",r)}}),this.sse.addEventListener("connected",()=>{}),this.sse.onerror=()=>{clearTimeout(i),console.warn("[PocketPing] \u274C SSE error - falling back to polling"),this.sse&&(this.sse.close(),this.sse=null),this.connectionMode="polling",this.startPolling()}}catch{console.warn("[PocketPing] SSE unavailable - falling back to polling"),this.connectionMode="polling",this.startPolling()}}handleWsFailure(){if(Date.now()-this.wsConnectedAt<this.quickFailureThreshold){console.info("[PocketPing] WebSocket failed quickly - trying SSE"),this.connectSSE();return}this.scheduleReconnect()}handleRealtimeEvent(e){this.handleWebSocketEvent(e)}getLastEventTimestamp(){if(!this.session)return null;let e=null;for(let n of this.session.messages){let s=[n.timestamp,n.editedAt,n.deletedAt,n.deliveredAt,n.readAt].filter(Boolean).map(i=>new Date(i)).filter(i=>!isNaN(i.getTime()));for(let i of s)(!e||i>e)&&(e=i)}return e?e.toISOString():null}handleWebSocketEvent(e){switch(e.type){case"message":let n=e.data;if(this.session){let u=this.session.messages.findIndex(p=>p.id===n.id);if(u<0&&n.sender==="visitor"&&(u=this.session.messages.findIndex(p=>p.id.startsWith("temp-")&&p.content===n.content&&p.sender==="visitor"),u>=0&&(this.session.messages[u].id=n.id)),u<0&&n.sender!=="visitor"){let p=new Date(n.timestamp).getTime();u=this.session.messages.findIndex(g=>g.sender===n.sender&&g.content===n.content&&Math.abs(new Date(g.timestamp).getTime()-p)<2e3)}if(u>=0){let p=this.session.messages[u],g=!1;n.status&&n.status!==p.status&&(p.status=n.status,g=!0,n.deliveredAt&&(p.deliveredAt=n.deliveredAt),n.readAt&&(p.readAt=n.readAt),this.emit("read",{messageIds:[n.id],status:n.status})),n.content!==void 0&&n.content!==p.content&&(p.content=n.content,g=!0),n.editedAt!==void 0&&n.editedAt!==p.editedAt&&(p.editedAt=n.editedAt,g=!0),n.deletedAt!==void 0&&n.deletedAt!==p.deletedAt&&(p.deletedAt=n.deletedAt,g=!0),n.replyTo!==void 0&&(p.replyTo=n.replyTo,g=!0),n.attachments!==void 0&&(p.attachments=n.attachments,g=!0),g&&this.emit("message",p)}else this.session.messages.push(n),this.emit("message",n),this.config.onMessage?.(n)}n.sender!=="visitor"&&this.emit("typing",{isTyping:!1});break;case"typing":let s=e.data;s.sender!=="visitor"&&this.emit("typing",{isTyping:s.isTyping});break;case"presence":this.session&&(this.session.operatorOnline=e.data.online),this.emit("presence",e.data);break;case"ai_takeover":this.emit("aiTakeover",e.data);break;case"read":let i=e.data;if(this.session)for(let u of this.session.messages)i.messageIds.includes(u.id)&&(u.status=i.status,i.deliveredAt&&(u.deliveredAt=i.deliveredAt),i.readAt&&(u.readAt=i.readAt));this.emit("read",i);break;case"message_edited":if(this.session){let u=e.data,p=this.session.messages.findIndex(g=>g.id===u.messageId);if(p>=0){let g=this.session.messages[p];g.content=u.content,g.editedAt=u.editedAt??new Date().toISOString(),this.emit("message",g)}}break;case"message_deleted":if(this.session){let u=e.data,p=this.session.messages.findIndex(g=>g.id===u.messageId);if(p>=0){let g=this.session.messages[p];g.deletedAt=u.deletedAt??new Date().toISOString(),this.emit("message",g)}}break;case"event":let a=e.data;this.emitCustomEvent(a);break;case"version_warning":let r=e.data;this.handleVersionWarning(r);break;case"config_update":let c=e.data;c.trackedElements&&(this.setupTrackedElements(c.trackedElements),this.emit("configUpdate",c));break}}handleVersionWarning(e){let n="[PocketPing]",s=e.upgradeUrl?` Upgrade: ${e.upgradeUrl}`:" Update your widget to the latest version.";switch(e.severity){case"error":console.error(`${n} \u{1F6A8} VERSION ERROR: ${e.message}${s}`),console.error(`${n} Current: ${e.currentVersion}, Required: ${e.minVersion||"unknown"}`);break;case"warning":console.warn(`${n} \u26A0\uFE0F VERSION WARNING: ${e.message}${s}`),console.warn(`${n} Current: ${e.currentVersion}, Latest: ${e.latestVersion||"unknown"}`);break;case"info":console.info(`${n} \u2139\uFE0F ${e.message}`);break}this.emit("versionWarning",e),this.config.onVersionWarning?.(e),e.canContinue||(console.error(`${n} Widget is incompatible with backend. Please update immediately.`),this.disconnect())}scheduleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts){console.warn("[PocketPing] Max reconnect attempts reached, trying SSE"),this.connectSSE();return}let e=Math.min(1e3*Math.pow(2,this.reconnectAttempts),3e4);this.reconnectAttempts++,this.reconnectTimeout=setTimeout(()=>{this.connectWebSocket()},e)}startPolling(){let e=async()=>{if(this.session){try{let n=this.getLastEventTimestamp(),s=await this.fetchMessages(n??void 0);this.pollingFailures=0;for(let i of s){let a=this.session.messages.findIndex(r=>r.id===i.id);if(a>=0){let r=this.session.messages[a],c=!1;i.status&&i.status!==r.status&&(r.status=i.status,c=!0,i.deliveredAt&&(r.deliveredAt=i.deliveredAt),i.readAt&&(r.readAt=i.readAt),this.emit("read",{messageIds:[i.id],status:i.status})),i.content!==void 0&&i.content!==r.content&&(r.content=i.content,c=!0),i.editedAt!==void 0&&i.editedAt!==r.editedAt&&(r.editedAt=i.editedAt,c=!0),i.deletedAt!==void 0&&i.deletedAt!==r.deletedAt&&(r.deletedAt=i.deletedAt,c=!0),i.replyTo!==void 0&&(r.replyTo=i.replyTo,c=!0),i.attachments!==void 0&&(r.attachments=i.attachments,c=!0),c&&this.emit("message",r)}else this.session.messages.push(i),this.emit("message",i),this.config.onMessage?.(i)}}catch(n){if(this.pollingFailures++,console.error("[PocketPing] \u274C Polling error:",n),(this.pollingFailures<=3||this.pollingFailures%3===0)&&console.warn(`[PocketPing] Polling failed (${this.pollingFailures}/${this.maxPollingFailures})`),this.pollingFailures>=this.maxPollingFailures){console.error("[PocketPing] Polling disabled after too many failures. Real-time updates unavailable."),this.emit("pollingDisabled",{failures:this.pollingFailures});return}}if(this.session){let n=this.pollingFailures>0?Math.min(2e3*Math.pow(2,this.pollingFailures-1),3e4):2e3;this.pollingTimeout=setTimeout(e,n)}}};this.pollingTimeout=setTimeout(e,500)}stopPolling(){this.pollingTimeout&&(clearTimeout(this.pollingTimeout),this.pollingTimeout=null),this.pollingFailures=0}async fetch(e,n){let s=this.config.endpoint.replace(/\/$/,"")+e,i=await fetch(s,{...n,headers:{"Content-Type":"application/json","X-PocketPing-Version":de,...n.headers}});if(this.checkVersionHeaders(i),!i.ok){let a=await i.text();throw new Error(`PocketPing API error: ${i.status} ${a}`)}return i.json()}checkVersionHeaders(e){let n=e.headers.get("X-PocketPing-Version-Status"),s=e.headers.get("X-PocketPing-Min-Version"),i=e.headers.get("X-PocketPing-Latest-Version"),a=e.headers.get("X-PocketPing-Version-Message");if(!n||n==="ok")return;let r="info",c=!0;n==="deprecated"?r="warning":n==="unsupported"?(r="error",c=!1):n==="outdated"&&(r="info");let u={severity:r,message:a||`Widget version ${de} is ${n}`,currentVersion:de,minVersion:s||void 0,latestVersion:i||void 0,canContinue:c,upgradeUrl:"https://docs.pocketping.io/widget/installation"};this.handleVersionWarning(u)}getOrCreateVisitorId(){let e="pocketping_visitor_id",n=localStorage.getItem(e);return n||(n=this.generateId(),localStorage.setItem(e,n)),n}getStoredSessionId(){return localStorage.getItem("pocketping_session_id")}storeSessionId(e){localStorage.setItem("pocketping_session_id",e)}getStoredIdentity(){try{let e=localStorage.getItem("pocketping_user_identity");return e?JSON.parse(e):null}catch{return null}}storeIdentity(e){localStorage.setItem("pocketping_user_identity",JSON.stringify(e))}clearIdentity(){localStorage.removeItem("pocketping_user_identity")}generateId(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}};var y=null,q=null,Pn="https://app.pocketping.io/api/widget";function Ae(t){if(y)return console.warn("[PocketPing] Already initialized"),y;let e=t.endpoint;if(!e&&t.projectId&&(e=`${Pn}/${t.projectId}`),!e)throw new Error("[PocketPing] endpoint or projectId is required");let n={...t,endpoint:e};return y=new ue(n),q=document.createElement("div"),q.id="pocketping-container",document.body.appendChild(q),Ie(Ee(wt,{client:y,config:t}),q),y.connect().catch(s=>{console.error("[PocketPing] Failed to connect:",s)}),y}function St(){q&&(Ie(null,q),q.remove(),q=null),y&&(y.disconnect(),y=null)}function Et(){y?.setOpen(!0)}function Pt(){y?.setOpen(!1)}function Tt(){y?.toggleOpen()}function It(t,e){if(!y)throw new Error("[PocketPing] Not initialized");return y.sendMessage(t,e)}async function Ct(t,e){if(!y)throw new Error("[PocketPing] Not initialized");return y.uploadFile(t,e)}async function Mt(t,e){if(!y)throw new Error("[PocketPing] Not initialized");return y.uploadFiles(t,e)}function $t(t,e,n){if(!y){console.warn("[PocketPing] Not initialized, cannot trigger event");return}y.trigger(t,e,n)}function At(t){if(!y){console.warn("[PocketPing] Not initialized, cannot setup tracked elements");return}y.setupTrackedElements(t)}function Rt(){return y?.getTrackedElements()||[]}function Ot(t,e){return y?y.onEvent(t,e):(console.warn("[PocketPing] Not initialized, cannot subscribe to event"),()=>{})}function Dt(t,e){y?.offEvent(t,e)}async function Lt(t){if(!y)throw new Error("[PocketPing] Not initialized");return y.identify(t)}async function Ht(t){if(!y){console.warn("[PocketPing] Not initialized");return}return y.reset(t)}function Ft(){return y?.getIdentity()||null}function Nt(t,e){return y?y.on(t,e):(console.warn("[PocketPing] Not initialized, cannot subscribe to event"),()=>{})}if(typeof document<"u"){let t=document.currentScript;if(t){let e=t.dataset.projectId,n=t.dataset.endpoint;(e||n)&&Ae({projectId:e,endpoint:n,theme:t.dataset.theme||"auto",position:t.dataset.position||"bottom-right"})}}var Tn={init:Ae,destroy:St,open:Et,close:Pt,toggle:Tt,sendMessage:It,uploadFile:Ct,uploadFiles:Mt,trigger:$t,onEvent:Ot,offEvent:Dt,on:Nt,identify:Lt,reset:Ht,getIdentity:Ft,setupTrackedElements:At,getTrackedElements:Rt};return an(In);})();
|