@commversion/libs 0.17.10 → 0.18.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/README.md CHANGED
@@ -51,6 +51,7 @@ All scripts are available under the `scripts/` directory.
51
51
  - lc-utm-params
52
52
  - lc-whatsapp-widget-only
53
53
  - lc-whatsapp-widget-combo
54
+ - lc-channel-widgets
54
55
 
55
56
  ## Release new versions
56
57
 
@@ -0,0 +1,134 @@
1
+ var lcChannelWidgets=function(m){"use strict";var Fe=Object.defineProperty,je=Object.defineProperties;var Ge=Object.getOwnPropertyDescriptors;var de=Object.getOwnPropertySymbols;var Xe=Object.prototype.hasOwnProperty,Ye=Object.prototype.propertyIsEnumerable;var ue=(m,g,v)=>g in m?Fe(m,g,{enumerable:!0,configurable:!0,writable:!0,value:v}):m[g]=v,L=(m,g)=>{for(var v in g||(g={}))Xe.call(g,v)&&ue(m,v,g[v]);if(de)for(var v of de(g))Ye.call(g,v)&&ue(m,v,g[v]);return m},he=(m,g)=>je(m,Ge(g));const fe={whatsapp:{label:"WhatsApp",icon:'<?xml version="1.0" encoding="utf-8"?><svg xmlns="http://www.w3.org/2000/svg" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" image-rendering="optimizeQuality" fill-rule="evenodd" clip-rule="evenodd" viewBox="0 0 509 511.514"><path fill="#fff" d="M434.762 74.334C387.553 26.81 323.245 0 256.236 0h-.768C115.795.001 2.121 113.696 2.121 253.456l.001.015a253.516 253.516 0 0033.942 126.671L0 511.514l134.373-35.269a253.416 253.416 0 00121.052 30.9h.003.053C395.472 507.145 509 393.616 509 253.626c0-67.225-26.742-131.727-74.252-179.237l.014-.055zM255.555 464.453c-37.753 0-74.861-10.22-107.293-29.479l-7.72-4.602-79.741 20.889 21.207-77.726-4.984-7.975c-21.147-33.606-32.415-72.584-32.415-112.308 0-116.371 94.372-210.743 210.741-210.743 56.011 0 109.758 22.307 149.277 61.98a210.93 210.93 0 0161.744 149.095c0 116.44-94.403 210.869-210.844 210.869h.028zm115.583-157.914c-6.363-3.202-37.474-18.472-43.243-20.593-5.769-2.121-10.01-3.202-14.315 3.203-4.305 6.404-16.373 20.593-20.063 24.855-3.69 4.263-7.401 4.815-13.679 1.612-6.278-3.202-26.786-9.883-50.899-31.472a192.748 192.748 0 01-35.411-43.867c-3.712-6.363-.404-9.777 2.82-12.873 3.224-3.096 6.363-7.381 9.48-11.092a41.58 41.58 0 006.357-10.597 11.678 11.678 0 00-.508-11.09c-1.718-3.18-14.444-34.357-19.534-47.06-5.09-12.703-10.37-10.603-14.272-10.901-3.902-.297-7.911-.19-12.089-.19a23.322 23.322 0 00-16.964 7.911c-5.707 6.298-22.1 21.673-22.1 52.849s22.671 61.249 25.852 65.532c3.182 4.284 44.663 68.227 108.288 95.649 15.099 6.489 26.891 10.392 36.053 13.403a87.504 87.504 0 0025.216 3.718c4.905 0 9.82-.416 14.65-1.237 12.174-1.782 37.453-15.291 42.776-30.073s5.303-27.57 3.711-30.093c-1.591-2.524-5.704-4.369-12.088-7.615l-.038.021z"/></svg>',backgroundColor:"#25D366",prefilledmessage:"Hi, I'd like to learn more.",mobile:{enabled:!1,url:"https://wa.me/{number}[?text={prefilledmessage}]"},desktop:{enabled:!1,url:"https://web.whatsapp.com/send?phone={number}[&text={prefilledmessage}]"}},sms:{label:"SMS",icon:'<?xml version="1.0" encoding="utf-8"?><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#fff"><path d="M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM8 13H6v-2h2v2zm5 0h-2v-2h2v2zm5 0h-2v-2h2v2z"/></svg>',backgroundColor:"#3478F6",prefilledmessage:"Hi, I'd like to learn more.",mobile:{enabled:!1,url:"sms:{number}[?body={prefilledmessage}]"},desktop:{enabled:!1,url:"sms:{number}[?body={prefilledmessage}]"},popover:{title:"Text us \u2014 we're available 24/7",description:"US numbers only. Msg & carrier rates may apply. Reply STOP to opt out.",buttonLabel:"Start Conversation"}}},pe=new Set(["prefilledmessage"]);function me(e,n){return e.replace(/\[([^\]]*)\]/g,(r,o)=>{for(const[,c]of o.matchAll(/\{(\w+)\}/g)){const a=n[c];if(a==null||a==="")return""}return o}).replace(/\{(\w+)\}/g,(r,o)=>{const c=n[o];if(c==null)return"";const a=String(c);return pe.has(o)?encodeURIComponent(a):a})}const j=e=>e&&typeof e.enabled=="boolean"?{enabled:e.enabled}:{},ge=e=>e===!0?!0:e&&typeof e=="object"?e.enabled===!0:!1,G={title:60,description:140,buttonLabel:24},be=(e,n)=>{if(!e||e===!0||typeof e!="object")return{};const t={},r=o=>{if(typeof e[o]!="string")return;const c=G[o];if(c!=null&&e[o].length>c){console.warn(`[lc-channel-widgets] ${n} popover.${o} exceeds ${c} chars (got ${e[o].length}); using registry default`);return}t[o]=e[o]};return Object.keys(G).forEach(r),t};function _e(e,n){if(!e||typeof e.type!="string")return null;const t=fe[e.type];if(!t)return null;const r=t[n]||{},o=he(L({},e),{prefilledmessage:typeof e.prefilledmessage=="string"?e.prefilledmessage:t.prefilledmessage||""});return{type:e.type,label:t.label,icon:t.icon,backgroundColor:t.backgroundColor,mobile:L(L({},t.mobile),j(e.mobile)),desktop:L(L({},t.desktop),j(e.desktop)),popover:t.popover&&ge(e.popover)?L(L({},t.popover),be(e.popover,e.type)):void 0,href:r.url?me(r.url,o):""}}const we="screen and (max-width: 992px) and (pointer: coarse)",ye=()=>window.matchMedia(we).matches?"mobile":"desktop",C=[];function X(){for(let e=C.length-1;e>=0;e--){const n=C[e];n&&n.parentNode&&n.parentNode.removeChild(n),C.splice(e,1)}}let Y=!1;function ve(){Y||(Y=!0,document.addEventListener("click",e=>{for(let n=0;n<C.length;n++){const t=C[n];t.__isOpen&&!t.contains(e.target)&&O(t)}}))}function Ce(){if(window.__lcHistoryPatched)return;window.__lcHistoryPatched=!0,window.__lcLastUrl=window.__lcLastUrl||location.href;const e=r=>{const o=window.__lcLastUrl,c=location.href,a=o!==c;window.__lcLastUrl=c,!(!a&&r!=="popstate")&&window.dispatchEvent(new Event("lc:locationchange"))},n=history.pushState;typeof n=="function"&&(history.pushState=function(...r){const o=n.apply(this,r);return e("pushState"),o});const t=history.replaceState;typeof t=="function"&&(history.replaceState=function(...r){const o=t.apply(this,r);return e("replaceState"),o}),window.addEventListener("popstate",()=>e("popstate")),window.addEventListener("hashchange",()=>e("hashchange"))}function Q(e){var r;if(document.__lcVisibilityBound&&!e)return!0;if(typeof((r=window.LiveChatWidget)==null?void 0:r.on)!="function")return!1;const n=document.__lcVisibilityCb;if(n&&typeof window.LiveChatWidget.off=="function")try{window.LiveChatWidget.off("visibility_changed",n)}catch(o){}const t=o=>{var a,s;const c=document.__lcStack;!c||!c.isConnected||(o&&typeof o.visibility=="string"&&(c.__lcVisibility=o.visibility),(a=document.__lcCurrentRebind)==null||a.call(document),(s=document.__lcCurrentSync)==null||s.call(document))};return window.LiveChatWidget.on("visibility_changed",t),document.__lcVisibilityCb=t,document.__lcVisibilityBound=!0,!0}function xe(e){if(Q(e)||document.__lcVisibilityPolling)return;document.__lcVisibilityPolling=!0;let n=0;const t=setInterval(()=>{(Q(e)||++n>=200)&&(clearInterval(t),document.__lcVisibilityPolling=!1)},200)}function Se(){document.__lcBodyMutationObs||typeof MutationObserver!="undefined"&&(document.__lcBodyMutationObs=new MutationObserver(e=>{const n=document.__lcStack;if(!!n)for(let t=0;t<e.length;t++){const r=e[t].removedNodes;if(!(!r||r.length===0))for(let o=0;o<r.length;o++){const c=r[o];if(c.nodeType===1&&(c===n||c.contains&&c.contains(n))){const a=document.__lcChannelWidgetsConfig;a&&Z(a);return}}}}),document.__lcBodyMutationObs.observe(document.body,{childList:!0,subtree:!0}))}let I=null,H=null;function Z(e){H=e,!I&&(I=setTimeout(()=>{I=null;const n=H;H=null,V(n)},100))}const Be=["#chat-widget-minimized","#chat-overlay-container"],Ee=15,J=100,Le=150;function Oe(e){return{width:e.width,height:e.height,fromLeft:e.left,fromRight:window.innerWidth-e.right,fromTop:e.top,fromBottom:window.innerHeight-e.bottom}}function ke(e){const n=e.fromLeft<=e.fromRight,t=e.fromTop<=e.fromBottom,r=n?e.fromLeft:window.innerWidth-e.fromRight-e.width,o=t?e.fromTop:window.innerHeight-e.fromBottom-e.height;return{left:r,top:o,right:r+e.width,bottom:o+e.height,width:e.width,height:e.height}}const k=60;function Ae(e){const n=window.innerWidth-e.right<=e.left,t=e.bottom,r=t-k,o=n?e.right:e.left+k;return{left:o-k,right:o,top:r,bottom:t,width:k,height:k}}const ze=200,Te=150;function K(e,n,{interval:t=ze,maxRetries:r=Te}={}){let o=0;const c=setInterval(()=>{const a=document.querySelector(e);if(a){clearInterval(c),n(a);return}++o>=r&&clearInterval(c)},t)}function We(){if(document.getElementById("lc-channel-widgets-style"))return;const e=document.createElement("style");e.id="lc-channel-widgets-style",e.textContent=`
2
+ .lc-channel-stack {
3
+ position: fixed;
4
+ top: 0;
5
+ left: 0;
6
+ z-index: 999999;
7
+ display: flex;
8
+ align-items: center;
9
+ pointer-events: auto;
10
+ /* All position changes go through transform: translate(...) rather
11
+ than top/left so they don't contribute to CLS \u2014 top/left changes
12
+ are layout shifts; transforms are compositor-only and excluded. */
13
+ will-change: transform;
14
+ /* Sizes are driven inline by syncPosition so widget icons match
15
+ LC's bubble (which itself resizes with branding/state). */
16
+ --lc-channel-size: 48px;
17
+ --lc-channel-icon-size: 28px;
18
+ /* Stay invisible until syncPosition commits a verified transform.
19
+ .lc-stack-ready is added one frame after that first commit;
20
+ until then the stack occupies its position but is not painted,
21
+ so the user never sees the brief "wrong position" frame caused
22
+ by LC's open/close animation producing a panel rect mid-flight
23
+ (sync N) before the resize observer catches up (sync N+1). */
24
+ opacity: 0;
25
+ }
26
+ .lc-channel-stack.lc-stack-ready {
27
+ opacity: 1;
28
+ /* Smooth subsequent moves (chat open/close, viewport resize) on
29
+ the same timescale as LC's own animation. Compositor-only;
30
+ no CLS impact. */
31
+ transition: transform 220ms cubic-bezier(0.22, 0.61, 0.36, 1),
32
+ opacity 120ms ease-out;
33
+ }
34
+ /* Mobile = vertical column below the bubble. Desktop = horizontal row
35
+ next to the chat button. Exact transform (left- vs right-of-button)
36
+ is set inline by syncPosition. */
37
+ .lc-channel-stack--horizontal {
38
+ flex-direction: row;
39
+ }
40
+
41
+ .lc-channel-button {
42
+ cursor: pointer;
43
+ width: var(--lc-channel-size);
44
+ height: var(--lc-channel-size);
45
+ flex: 0 0 auto;
46
+ display: flex;
47
+ justify-content: center;
48
+ align-items: center;
49
+ border-radius: 50%;
50
+ }
51
+
52
+ .lc-channel-icon {
53
+ display: block;
54
+ pointer-events: none;
55
+ width: var(--lc-channel-icon-size);
56
+ height: var(--lc-channel-icon-size);
57
+ }
58
+
59
+ .lc-channel-popover {
60
+ position: fixed;
61
+ /* Anchor at (0,0); visual position is driven entirely by transform
62
+ so repositioning is a compositor matrix update \u2014 no layout pass. */
63
+ top: 0;
64
+ left: 0;
65
+ z-index: 2147483641;
66
+ width: 280px;
67
+ padding: 18px 22px 16px 18px;
68
+ background: #fff;
69
+ color: #1a1a1a;
70
+ border-radius: 12px;
71
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
72
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
73
+ /* Pre-promote to own compositor layer. Box-shadow / border-radius /
74
+ text are painted once into the backing store at init; subsequent
75
+ open/close pays only a GPU matrix/alpha update \u2014 no layout, no paint.
76
+ Declaring BOTH animated properties lets Chrome schedule them in a
77
+ single compositor frame instead of two GPU passes. */
78
+ will-change: opacity, transform;
79
+ }
80
+ .lc-channel-popover-title {
81
+ margin: 0 0 6px;
82
+ padding-right: 16px;
83
+ font-size: 15px;
84
+ font-weight: 600;
85
+ line-height: 1.3;
86
+ }
87
+ .lc-channel-popover-description {
88
+ margin: 0 0 14px;
89
+ font-size: 13px;
90
+ line-height: 1.4;
91
+ color: #555;
92
+ }
93
+ .lc-channel-popover-button {
94
+ width: 100%;
95
+ padding: 10px 14px;
96
+ border: none;
97
+ border-radius: 8px;
98
+ color: #fff;
99
+ font-size: 14px;
100
+ font-weight: 600;
101
+ cursor: pointer;
102
+ }
103
+ .lc-channel-popover-close {
104
+ position: absolute;
105
+ top: 6px;
106
+ right: 8px;
107
+ background: transparent;
108
+ border: none;
109
+ font-size: 18px;
110
+ line-height: 1;
111
+ color: #888;
112
+ cursor: pointer;
113
+ padding: 4px 6px;
114
+ }
115
+ /* Directional arrow. 12px square rotated 45\xB0 so half sits outside
116
+ the popover as a triangular tip. Inline left/top is set per open
117
+ so the tip aligns with the trigger button's center. */
118
+ .lc-channel-popover-arrow {
119
+ position: absolute;
120
+ width: 12px;
121
+ height: 12px;
122
+ background: #fff;
123
+ transform: rotate(45deg);
124
+ pointer-events: none;
125
+ }
126
+ .lc-channel-popover--arrow-bottom > .lc-channel-popover-arrow {
127
+ bottom: -6px;
128
+ box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.08);
129
+ }
130
+ .lc-channel-popover--arrow-top > .lc-channel-popover-arrow {
131
+ top: -6px;
132
+ box-shadow: -3px -3px 6px rgba(0, 0, 0, 0.06);
133
+ }
134
+ `,document.head.appendChild(e)}function Pe(e,n){if(typeof e!="string"||e.length===0)return null;if(/^(data:|https?:\/\/)/.test(e)){const o=document.createElement("img");return o.className="lc-channel-icon",o.alt=n||"",o.src=e,o}const t=document.createElement("span");t.className="lc-channel-icon",t.setAttribute("aria-hidden","true"),t.innerHTML=e;const r=t.querySelector("svg");return r&&(r.setAttribute("width","100%"),r.setAttribute("height","100%"),r.style.display="block"),t}function Me(e,n,t){const a=e.left+e.width/2;let s=e.top-t-12,A="bottom";s<8&&(s=e.bottom+12,A="top"),s+t>window.innerHeight-8&&(s=window.innerHeight-t-8),s<8&&(s=8);let S=a-n/2;S<8&&(S=8),S+n>window.innerWidth-8&&(S=window.innerWidth-n-8);const i=18,z=Math.max(i,n-18),N=Math.max(i,Math.min(z,a-S));return{tx:S,ty:s,arrowSide:A,arrowOffset:N}}function ee(e,n,t){e.__appliedArrowSide!==n&&(e.classList.remove("lc-channel-popover--arrow-top","lc-channel-popover--arrow-bottom"),e.classList.add(`lc-channel-popover--arrow-${n}`),e.__appliedArrowSide=n),e.__arrowEl.style.left=`${t-6}px`}function O(e){e.__isOpen=!1,e.style.opacity="0",e.style.pointerEvents="none",requestAnimationFrame(()=>{e.setAttribute("aria-hidden","true")})}function Re(e){C.forEach(n=>{n!==e&&n.__isOpen&&O(n)}),e.__cachedTransform&&(e.style.transform=e.__cachedTransform),e.__arrowSide&&e.__arrowEl&&ee(e,e.__arrowSide,e.__arrowOffset),e.style.opacity="1",e.style.pointerEvents="auto",requestAnimationFrame(()=>{e.removeAttribute("aria-hidden")}),e.__isOpen=!0}function Ie(e){const n=e.popover,t=document.createElement("div");if(t.className="lc-channel-popover",t.setAttribute("data-popover-channel-id",e.type),n.title){const s=document.createElement("h3");s.className="lc-channel-popover-title",s.textContent=n.title,t.appendChild(s)}if(n.description){const s=document.createElement("p");s.className="lc-channel-popover-description",s.textContent=n.description,t.appendChild(s)}const r=document.createElement("button");r.type="button",r.className="lc-channel-popover-button",r.textContent=n.buttonLabel||"Start Conversation",r.style.backgroundColor=e.backgroundColor||"#1a1a1a",r.onclick=s=>{s.stopPropagation(),typeof e.href=="string"&&e.href.length>0&&window.open(e.href,"_blank","noopener,noreferrer"),O(t)},t.appendChild(r);const o=document.createElement("button");o.type="button",o.className="lc-channel-popover-close",o.setAttribute("aria-label","Close"),o.textContent="\xD7",o.onclick=s=>{s.stopPropagation(),O(t)},t.appendChild(o);const c=document.createElement("div");c.className="lc-channel-popover-arrow",t.appendChild(c),t.__arrowEl=c,t.__isOpen=!1,t.style.opacity="0",t.style.pointerEvents="none",t.setAttribute("aria-hidden","true"),t.style.transform="translate3d(0,0,0)",document.body.appendChild(t);const a=t.getBoundingClientRect();return t.__cachedWidth=a.width>0?a.width:280,t.__cachedHeight=a.height,C.push(t),ve(),t}function He(e){const n=document.createElement("div");n.className="lc-channel-button",n.setAttribute("data-channel-id",e.type),e.label&&n.setAttribute("aria-label",e.label),e.backgroundColor&&(n.style.backgroundColor=e.backgroundColor);const t=e.popover?Ie(e):null;n.__popoverEl=t,n.onclick=o=>{if(t){o.stopPropagation(),t.__isOpen?O(t):Re(t);return}typeof e.href=="string"&&e.href.length>0&&window.open(e.href,"_blank","noopener,noreferrer")};const r=Pe(e.icon,e.label||e.type);return r&&n.appendChild(r),n}function Ve(e,n){const t=e==null?void 0:e[n];return t&&typeof t.enabled=="boolean"?t.enabled:n==="mobile"}function Ne(e){var W,ne,oe;const{deviceType:n,chatWidgetSelector:t,channels:r,bubbleSelector:o}=e,c=e[n];if(!document.querySelector(t))return;const s=()=>document.querySelector(t),A=[];r.forEach(l=>{const u=_e(l,n);if(!u){console.warn("[lc-channel-widgets] unknown or invalid channel \u2014 skipping:",l);return}A.push(u)});const S=A.filter(l=>Ve(l,n));if(S.length===0)return;We();let i=document.body.querySelector(":scope > .lc-channel-stack");if(!i){X(),i=document.createElement("div");const l=n==="mobile"?"vertical":"horizontal";i.className=`lc-channel-stack lc-channel-stack--${l}`,i.style.gap=c.gap,i.setAttribute("role","group"),i.setAttribute("aria-label","Contact channels"),document.body.appendChild(i)}document.__lcStack=i,S.forEach(l=>{i.querySelector(`[data-channel-id="${CSS.escape(l.type)}"]`)||i.appendChild(He(l))});const z=parseInt(c.gapBelow,10)||8,N=()=>{const l=s();for(let u=0;u<o.length;u++){const f=o[u],b=l&&l.querySelector(f)||document.querySelector(f);if(!b)continue;const _=b.getBoundingClientRect();if(_.width>0&&_.height>0)return _}return null},De=()=>{const l=s(),u=[];for(let f=0;f<o.length;f++){const b=o[f],_=l?l.querySelector(b):null,T=document.querySelector(b);_&&u.indexOf(_)===-1&&u.push(_),T&&T!==_&&u.indexOf(T)===-1&&u.push(T)}return l&&u.indexOf(l)===-1&&u.push(l),u};let te="minimized";try{const l=(oe=(ne=(W=window.LiveChatWidget)==null?void 0:W.get)==null?void 0:ne.call(W,"state"))==null?void 0:oe.visibility;typeof l=="string"&&(te=l)}catch(l){}i.__lcVisibility=te;const D=()=>{const l=N();l&&i.__lcVisibility==="minimized"&&l.width<=J&&l.height<=J&&window.innerHeight-l.bottom<=Le&&(document.__lcBubbleAnchor=Oe(l));let u=null,f=null;if(i.__lcVisibility==="minimized")l&&(u=l,f=l);else if(i.__lcVisibility==="maximized"&&n!=="mobile"){const d=s();if(d){const h=d.getBoundingClientRect();h.width>0&&h.height>0&&(u=h,f=document.__lcBubbleAnchor?ke(document.__lcBubbleAnchor):Ae(h))}}if(!u||!f){for(let d=0;d<C.length;d++)C[d].__isOpen&&O(C[d]);i.style.display="none";return}i.style.display="flex";const b=f,_=Math.max(b.width,b.height),P=Math.min(_,n==="mobile"?60:40),Ue=Math.round(P*.5),ie=i.__lcLastButtonSize!==P;ie&&(i.style.setProperty("--lc-channel-size",`${P}px`),i.style.setProperty("--lc-channel-icon-size",`${Ue}px`),i.__lcCachedDims=null,i.__lcLastButtonSize=P);const w=8,re=i.children.length,le=i.__lcLastButtonCount!==re;le&&(i.__lcCachedDims=null);const B=i.__lcCachedDims||i.getBoundingClientRect();i.__lcCachedDims=B,i.__lcLastButtonCount=re;let M,R;if(n==="mobile"){const d=f,h=Math.min(d.height,d.width,80);let x=d.left<window.innerWidth-d.right?d.left+h/2:d.right-h/2;const p=B.width/2;x-p<w&&(x=p+w),x+p>window.innerWidth-w&&(x=window.innerWidth-p-w),M=x-B.width/2,R=d.bottom+z-Ee}else{const d=u.left+u.width/2<window.innerWidth/2,h=B.height/2;let E=f.top+f.height/2;E-h<w&&(E=h+w),E+h>window.innerHeight-w&&(E=window.innerHeight-h-w);const x=-h;let p,y;d?(p=u.right+z,p+B.width>window.innerWidth-w&&(p=window.innerWidth-B.width-w),y=0):(p=u.left-z,p-B.width<w&&(p=B.width+w),y=-B.width),M=p+y,R=E+x}const F=`translate(${M}px, ${R}px)`;!(F!==i.__lcLastTransform)&&!ie&&!le||(i.style.transform=F,i.__lcLastTransform=F,i.__lcTransitionActivated||requestAnimationFrame(()=>{i.classList.add("lc-stack-ready"),i.__lcTransitionActivated=!0}),i.querySelectorAll(".lc-channel-button").forEach(d=>{const h=M+d.offsetLeft,E=R+d.offsetTop,x=d.offsetWidth,p=d.offsetHeight;if(d.__cachedRect={left:h,top:E,right:h+x,bottom:E+p,width:x,height:p},d.__popoverEl){const y=d.__popoverEl,{tx:qe,ty:$e,arrowSide:ce,arrowOffset:se}=Me(d.__cachedRect,y.__cachedWidth,y.__cachedHeight),ae=`translate3d(${qe}px,${$e}px,0)`;y.__cachedTransform=ae,y.__arrowSide=ce,y.__arrowOffset=se,y.__isOpen&&(y.style.transform=ae,ee(y,ce,se))}}))};let U=0;const q=()=>{U||(U=requestAnimationFrame(()=>{U=0,D()}))};D(),document.__lcCurrentSync=q,document.__lcWindowListenersBound||(window.addEventListener("resize",()=>{var l;return(l=document.__lcCurrentSync)==null?void 0:l.call(document)}),window.addEventListener("orientationchange",()=>{var l;document.__lcBubbleAnchor=null,(l=document.__lcCurrentSync)==null||l.call(document)}),document.__lcWindowListenersBound=!0),typeof ResizeObserver!="undefined"&&!i.__lcResizeObserved&&(new ResizeObserver(q).observe(i),i.__lcResizeObserved=!0);const $=()=>{const l=De();if(l.length===0)return;const u=i.__lcObservedBubbles||[];l.length===u.length&&l.every((b,_)=>b===u[_])||(i.__lcBubbleObserver&&i.__lcBubbleObserver.disconnect(),i.__lcObservedBubbles=l,typeof ResizeObserver!="undefined"&&(i.__lcBubbleObserver=new ResizeObserver(q),l.forEach(b=>i.__lcBubbleObserver.observe(b))))};$(),(!i.__lcObservedBubbles||i.__lcObservedBubbles.length===0)&&o.forEach(l=>{K(l,()=>{$(),D()})}),document.__lcCurrentRebind=$,document.__lcVisibilityBound=!1,xe(!0)}function V(e={}){const n=e.channelWidgetsConfig||{},t={gap:"8px",gapBelow:"8px"},r={gap:"8px",gapBelow:"8px"},o={chatWidgetSelector:n.chatWidgetSelector||"#chat-widget-container",bubbleSelector:Be,channels:Array.isArray(n.channels)?n.channels:[],mobile:Object.assign({},t,n.mobile),desktop:Object.assign({},r,n.desktop)},c=ye();if(o.deviceType=c,o.channels.length===0)return;document.__lcChannelWidgetsConfig=e,K(o.chatWidgetSelector,()=>{Ne(o),Se()});const a=()=>{document.__lcBubbleAnchor=null,document.__lcVisibilityBound=!1,X();const s=document.__lcChannelWidgetsConfig;s&&Z(s)};document.__lcChannelWidgetsSpaBound||(Ce(),window.addEventListener("lc:locationchange",a),document.__lcChannelWidgetsSpaBound=!0),document.__lcChannelWidgetsTurbolinksBound||(document.addEventListener("turbolinks:load",a),document.__lcChannelWidgetsTurbolinksBound=!0)}return window.commversion=window.commversion||{},window.LiveChatWidget.on("ready",()=>V(window.commversion)),m.lcAddChannelWidgets=V,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),m}({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commversion/libs",
3
- "version": "0.17.10",
3
+ "version": "0.18.0",
4
4
  "author": "Commversion",
5
5
  "license": "UNLICENSED",
6
6
  "scripts": {
@@ -58,7 +58,9 @@
58
58
  "dev:lc-whatsapp-widget-combo": "vite serve scripts/lc-whatsapp-widget-combo/src/",
59
59
  "build:lc-whatsapp-widget-combo": "vite build -c scripts/lc-whatsapp-widget-combo/vite.config.js",
60
60
  "dev:lc-whatsapp-widget-only": "vite serve scripts/lc-whatsapp-widget-only/src/",
61
- "build:lc-whatsapp-widget-only": "vite build -c scripts/lc-whatsapp-widget-only/vite.config.js"
61
+ "build:lc-whatsapp-widget-only": "vite build -c scripts/lc-whatsapp-widget-only/vite.config.js",
62
+ "dev:lc-channel-widgets": "vite serve scripts/lc-channel-widgets/src/",
63
+ "build:lc-channel-widgets": "vite build -c scripts/lc-channel-widgets/vite.config.js"
62
64
  },
63
65
  "publishConfig": {
64
66
  "access": "public"