signalbird 2.4.0 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -94,7 +94,7 @@ değil, kasıtlı bir duvardır — anahtar bir kez istemciye indiğinde herkesi
94
94
  | Go | `go get github.com/Pariette-Inc/signalbird.sdk` |
95
95
  | .NET, ASP.NET Core | `dotnet add package Signalbird.Sdk` |
96
96
  | Swift (iOS, macOS) | SPM: `https://github.com/Pariette-Inc/signalbird.sdk` |
97
- | Kotlin (Android) | `implementation("io.signalbird:signalbird-sdk:2.4.0")` |
97
+ | Kotlin (Android) | `implementation("io.signalbird:signalbird-sdk:2.4.2")` |
98
98
  | Canlı sohbet widget'ı (herhangi bir site) | `<script async src="https://signalbird.io/sdk/v1/signalbird.js" data-key="sb_public_live_…" data-channel="destek"></script>` |
99
99
 
100
100
  > Hepsi **bu repodan** çıkar ve **aynı sürümü** taşır — ayrı SDK reposu ya da
@@ -496,5 +496,5 @@ display:flex;align-items:center;justify-content:center;margin-bottom:8px;animati
496
496
  border:1px solid var(--sb-b);border-radius:14px;text-align:center;display:none}
497
497
  .notice.on{display:block}
498
498
  .notice button{color:var(--sb-c);font-weight:650;margin-left:6px}
499
- `;function r(s,e,...t){let i=document.createElement(s);if(e)for(let n in e){let a=e[n];a==null||a===false||(n==="class"?i.className=String(a):n==="style"?i.setAttribute("style",String(a)):n.startsWith("on")&&typeof a=="function"?i.addEventListener(n.slice(2).toLowerCase(),a):n==="html"?i.innerHTML=String(a):n in i&&n!=="list"&&n!=="form"?i[n]=a:i.setAttribute(n,String(a)));}return ze(i,t),i}function ze(s,e){for(let t of e)t==null||t===false||s.appendChild(typeof t=="object"?t:document.createTextNode(String(t)));}function T(s){for(;s.firstChild;)s.removeChild(s.firstChild);}function y(s,e=18){let t=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width",String(e)),t.setAttribute("height",String(e)),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","2"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.innerHTML=Ae[s],t}function X(s=26){let e=document.createElementNS("http://www.w3.org/2000/svg","svg");return e.setAttribute("viewBox","10 2 28 38"),e.setAttribute("width",String(s)),e.setAttribute("height",String(s)),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","2"),e.setAttribute("stroke-linejoin","round"),e.setAttribute("aria-hidden","true"),e.innerHTML='<path d="M16 16 L30 16 L33 18 L24 33 L15 18 Z" fill="currentColor" fill-opacity=".18" stroke="none"/><path d="M23 4 L31 9 L23 14 L16 9 Z" fill="currentColor" fill-opacity=".28" stroke="none"/><path d="M30 16 L33 18 L36 27 L34 34 L41 32 L44 38 L31 37 L24 37 L17 35 L13 27 L15 18 L16 16"/><path d="M16 16 L16 9 L23 4 L31 9 L30 16"/><path d="M21.4 12.4 L23.2 18.6 L25 12.4 Z" fill="currentColor" fill-opacity=".35"/><circle cx="28.4" cy="11.4" r="1.6" fill="currentColor" stroke="none"/>',e}var Ae={chat:'<path d="M21 11.5a8.4 8.4 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.4 8.4 0 0 1-3.8-.9L3 21l1.9-5.7a8.4 8.4 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.4 8.4 0 0 1 3.8-.9h.5a8.5 8.5 0 0 1 8 8v.5z"/>',close:'<path d="M18 6 6 18M6 6l12 12"/>',send:'<path d="m22 2-7 20-4-9-9-4 20-7z"/><path d="M22 2 11 13"/>',clip:'<path d="m21.4 11.05-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"/>',file:'<path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><path d="M14 2v6h6"/>',check:'<path d="M20 6 9 17l-5-5"/>',link:'<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><path d="M15 3h6v6"/><path d="M10 14 21 3"/>',checks:'<path d="M18 6 7 17l-4-4"/><path d="m22 10-7.5 7.5L13 16"/>',reply:'<path d="M9 17H5a2 2 0 0 1-2-2V9"/><path d="m3 9 4-4"/><path d="m3 9 4 4"/><path d="M9 17h6a6 6 0 0 0 0-12h-2"/>',more:'<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>',star:'<path d="m12 2 3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/>',chevron:'<path d="m6 9 6 6 6-6"/>',smile:'<circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><path d="M9 9h.01M15 9h.01"/>',done:'<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><path d="m22 4-10 10-3-3"/>',down:'<path d="M12 5v14"/><path d="m19 12-7 7-7-7"/>',image:'<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="1.5"/><path d="m21 15-4.5-4.5L9 18"/>',heart:'<path d="M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1-1.1a5.5 5.5 0 0 0-7.8 7.8l1.1 1L12 21l7.7-7.6 1.1-1a5.5 5.5 0 0 0 0-7.8z"/>'};function $(s){return (s||"?").trim().split(/\s+/).slice(0,2).map(e=>e[0]||"").join("").toUpperCase()}function S(s,e){let t=P(s);return t?r("img",{src:t,alt:"",loading:"lazy"}):document.createTextNode($(e))}function P(s){return typeof s=="string"&&/^(https:\/\/|data:image\/)/i.test(s)?s:null}function oe(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(0)} KB`:`${(s/1024/1024).toFixed(1)} MB`}function le(){return typeof crypto!="undefined"&&"randomUUID"in crypto?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{let e=Math.random()*16|0;return (s==="x"?e:e&3|8).toString(16)})}var de=["\u{1F44D}","\u2764\uFE0F","\u{1F602}","\u{1F62E}","\u{1F622}","\u{1F64F}"],be=["\u{1F600}","\u{1F604}","\u{1F60A}","\u{1F642}","\u{1F609}","\u{1F60D}","\u{1F929}","\u{1F60E}","\u{1F914}","\u{1F610}","\u{1F615}","\u{1F641}","\u{1F622}","\u{1F62D}","\u{1F621}","\u{1F92F}","\u{1F44D}","\u{1F44E}","\u{1F44F}","\u{1F64F}","\u{1F4AA}","\u{1F525}","\u2705","\u2764\uFE0F"],Re=900*1e3,Pe=300*1e3;function fe(s,e){let t=V(s),i=s.childNodes.length===0,n=je(s);if(T(s),e.messages.length===0){s.appendChild(Ne(e));return}let a="";for(let o=0;o<e.messages.length;o++){let l=e.messages[o],d=Z(l.created_at),c=d===a&&e.messages[o-1]||null,g=e.messages[o+1]||null;d!==a&&(s.appendChild(r("div",{class:"day"},Ve(l.created_at,e))),a=d),s.appendChild(He(l,e,c,Ie(l,g)?g:null,!i&&!n.has(l.id)));}(t||i)&&R(s);}function V(s,e=60){return s.scrollHeight-s.scrollTop-s.clientHeight<e}function R(s,e=false){if(e&&typeof s.scrollTo=="function"){s.scrollTo({top:s.scrollHeight,behavior:"smooth"});return}s.scrollTop=s.scrollHeight;}function je(s){let e=new Set;return s.querySelectorAll("[data-id]").forEach(t=>{let i=t.dataset.id;i&&e.add(i);}),e}function Ne(s){let e=r("div",{class:"hero"});e.appendChild(r("div",{class:"hv"},r("span",null,S(s.agentAvatar,s.brandName||s.agentName)))),e.appendChild(r("h4",null,s.greeting||s.t.greeting)),s.responseHint&&e.appendChild(r("p",null,s.responseHint));let t=s.quick||[];if(t.length&&s.onQuick){let i=r("div",{class:"qk"});for(let n of t.slice(0,6))i.appendChild(r("button",{type:"button",onclick:()=>s.onQuick(n)},n));e.appendChild(i);}return e}function He(s,e,t,i,n){var k,w,M;let a=s.sender_type==="visitor"?"v":s.sender_type==="system"?"s":"a",o=!ce(t,s),l=!ce(s,i),d=r("div",{class:`row ${a}`+(o&&t?" gap":"")+(l?"":" mid")+(s._pending?" pend":"")+(s._failed?" fail":"")+(n?" new":""),"data-id":s.id});if(a==="s")return d.appendChild(r("div",{class:"bb"},s.body||"")),d;a==="a"&&d.appendChild(r("div",{class:`av${l?"":" gh"}`},S(e.agentAvatar,pe(s)||e.agentName)));let c=r("div",{class:"cl"}),g=r("div",{class:`bb${s.deleted_at?" del":""}`});if(s.deleted_at)return g.textContent=e.t.deleted,c.appendChild(g),d.appendChild(c),d;if(s.reply_to_id){let u=e.find(s.reply_to_id),b=u?u.sender_type==="visitor"?e.t.you:pe(u)||e.agentName:"";g.appendChild(r("span",{class:"q"},b?`${b}: `:"",u?D(u,e.t):"\u2026"));}if(s._files&&s._files.length){let u=r("div",{class:"imgs"});for(let b of s._files)b.type.startsWith("image/")?u.appendChild(r("img",{src:URL.createObjectURL(b),alt:b.name})):g.appendChild(he({name:b.name,url:"",mime:b.type,size:b.size},e));u.childNodes.length&&g.appendChild(u);}let f=s.attachments||[],p=f.filter(u=>ue(u.mime));if(p.length){let u=r("div",{class:"imgs"});for(let b of p)u.appendChild(r("img",{src:b.url,alt:b.name,loading:"lazy",onclick:()=>e.actions.openImage(b.url)}));g.appendChild(u);}for(let u of f.filter(b=>!ue(b.mime)))g.appendChild(he(u,e));let h=(a==="v"?null:(k=s.translation)==null?void 0:k.body)||s.body;h&&g.appendChild($e(h)),s._failed&&(g.appendChild(r("div",{style:"font-size:11px;margin-top:5px;font-weight:600"},e.t.failed)),g.addEventListener("click",()=>e.actions.retry(s))),c.appendChild(g);let m=a==="a"&&((M=(w=s.meta)==null?void 0:w.options)!=null&&M.length)?s.meta.options.slice(0,6):null;if(m){let u=!i||i.sender_type==="system",b=r("div",{class:`opts${u?"":" past"}`});for(let L of m)!L||!L.label||(L.url?b.appendChild(r("a",{href:L.url,target:"_top",rel:"noopener"},L.label,y("link",12))):b.appendChild(r("button",{type:"button",disabled:u?null:"disabled",onclick:()=>{var z;return (z=e.onQuick)==null?void 0:z.call(e,L.value||L.label)}},L.label)));b.childNodes.length&&c.appendChild(b);}let x=s.reactions&&Object.keys(s.reactions).length?s.reactions:null;if(x){let u=r("div",{class:"rx"});for(let b in x){let L=x[b]||[];if(!L.length)continue;let z=L.includes("visitor");u.appendChild(r("button",{class:z?"me":"",type:"button",onclick:()=>e.actions.react(s,b)},`${b} ${L.length}`));}u.childNodes.length&&c.appendChild(u);}if(l){let u=r("div",{class:"mt"},De(s.created_at,e.locale));if(s.edited_at&&u.appendChild(r("span",{class:"ed"},`\xB7 ${e.t.edited}`)),a==="v"&&!s._failed){let b=r("span",{class:`tk${s.read_at?" rd":""}`});b.appendChild(s._pending?y("check",12):s.read_at||s.delivered_at?y("checks",13):y("check",12)),s._pending&&(b.style.opacity=".4"),u.appendChild(b);}c.appendChild(u);}return d.appendChild(c),!s._pending&&!s._failed&&(d.appendChild(Be(s,e,d)),Oe(d)),d}function pe(s){var e,t;return ((e=s.agent)==null?void 0:e.name)||s.sender_name||((t=s.meta)==null?void 0:t.agent_name)||null}function ce(s,e){if(!s||!e||s.sender_type!==e.sender_type||s.sender_type==="system"||s.sender_id!==e.sender_id)return false;let t=Date.parse(e.created_at)-Date.parse(s.created_at);return t>=0&&t<Pe}function Ie(s,e){return !!e&&Z(s.created_at)===Z(e.created_at)}function Be(s,e,t){let i=r("div",{class:"ac"});for(let o of de.slice(0,3))i.appendChild(r("button",{type:"button",title:e.t.react,onclick:()=>e.actions.react(s,o)},o));i.appendChild(r("button",{type:"button",title:e.t.reply,onclick:()=>e.actions.reply(s)},y("reply",15)));let n=r("div",{class:"menu"});for(let o of de.slice(3))n.appendChild(r("button",{type:"button",onclick:()=>{n.classList.remove("show"),e.actions.react(s,o);}},`${o} ${e.t.react}`));return s.sender_type==="visitor"&&Date.now()-Date.parse(s.created_at)<Re&&(n.appendChild(r("button",{type:"button",onclick:()=>{n.classList.remove("show"),e.actions.edit(s);}},e.t.edit)),n.appendChild(r("button",{type:"button",class:"dg",onclick:()=>{n.classList.remove("show"),e.actions.remove(s);}},e.t.delete))),i.appendChild(r("button",{type:"button",title:e.t.react,onclick:o=>{o.stopPropagation(),n.classList.toggle("show"),n.style.top=`${t.offsetHeight+4}px`;}},y("more",15))),t.appendChild(n),document.addEventListener("click",()=>n.classList.remove("show"),{once:true,capture:true}),i}function Oe(s){let e=null,t=()=>{e=setTimeout(()=>{var a;s.classList.add("acts");try{(a=navigator.vibrate)==null||a.call(navigator,8);}catch(o){}let n=o=>{s.contains(o.target)||(s.classList.remove("acts"),document.removeEventListener("touchstart",n,true));};document.addEventListener("touchstart",n,true);},420);},i=()=>e&&clearTimeout(e);s.addEventListener("touchstart",t,{passive:true}),s.addEventListener("touchend",i),s.addEventListener("touchmove",i,{passive:true});}function he(s,e){return r("a",{class:"fr",href:s.url||void 0,target:"_blank",rel:"noopener"},y("file",18),r("span",{class:"fn"},s.name||e.t.attachment),r("span",{class:"fs"},oe(s.size||0)))}function $e(s){let e=document.createDocumentFragment(),t=/(https?:\/\/[^\s<]+)/g,i=0,n;for(;n=t.exec(s);){n.index>i&&e.appendChild(document.createTextNode(s.slice(i,n.index)));let a=n[1].replace(/[.,;:!?)]+$/,"");e.appendChild(r("a",{href:a,target:"_blank",rel:"noopener noreferrer nofollow"},a)),i=n.index+a.length;}return i<s.length&&e.appendChild(document.createTextNode(s.slice(i))),e}function D(s,e){var n,a;if(s.deleted_at)return e.deleted;let t=(s.sender_type==="visitor"?null:(n=s.translation)==null?void 0:n.body)||s.body;if(t)return t.length>90?t.slice(0,90)+"\u2026":t;let i=(a=s.attachments)==null?void 0:a[0];return i?`\u{1F4CE} ${i.name}`:"\u2026"}function ue(s){return !!s&&s.startsWith("image/")}function Z(s){let e=new Date(s);return `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function Ve(s,e){let t=new Date(s),i=new Date,n=Math.round((ge(i)-ge(t))/864e5);if(n===0)return e.t.today;if(n===1)return e.t.yesterday;try{return new Intl.DateTimeFormat(e.locale,{day:"numeric",month:"long",year:t.getFullYear()!==i.getFullYear()?"numeric":void 0}).format(t)}catch(a){return t.toLocaleDateString()}}function ge(s){return new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime()}function De(s,e){let t=new Date(s);try{return new Intl.DateTimeFormat(e,{hour:"2-digit",minute:"2-digit"}).format(t)}catch(i){return t.toLocaleTimeString()}}var Ke={launcher:"Sohbet",title:"Sohbet",online:"\xC7evrimi\xE7i",offline:"Genelde birka\xE7 dakika i\xE7inde yan\u0131tl\u0131yoruz",greeting:"Merhaba! Size nas\u0131l yard\u0131mc\u0131 olabiliriz?",offlineMessage:"\u015Eu an \xE7evrimd\u0131\u015F\u0131y\u0131z. Mesaj\u0131n\u0131z\u0131 b\u0131rak\u0131n, en k\u0131sa s\xFCrede d\xF6nelim.",prechatTitle:"Ba\u015Flamadan \xF6nce",prechatHint:"Size geri d\xF6nebilmemiz i\xE7in bilgilerinizi b\u0131rak\u0131n.",topicLabel:"Konu",topicPlaceholder:"Konu se\xE7in (iste\u011Fe ba\u011Fl\u0131)",name:"Ad\u0131n\u0131z",email:"E-posta",start:"Sohbete ba\u015Fla",skip:"Atla",placeholder:"Mesaj\u0131n\u0131z\u0131 yaz\u0131n\u2026",send:"G\xF6nder",attach:"Dosya ekle",typing:"yaz\u0131yor\u2026",today:"Bug\xFCn",yesterday:"D\xFCn",reply:"Yan\u0131tla",react:"Tepki ver",edit:"D\xFCzenle",delete:"Sil",deleted:"Bu mesaj silindi",edited:"d\xFCzenlendi",save:"Kaydet",cancel:"Vazge\xE7",you:"Siz",agent:"Destek",system:"Sistem",endChat:"Sohbeti bitir",newChat:"Yeni sohbet",resolved:"Bu sohbet \xE7\xF6z\xFCld\xFC olarak i\u015Faretlendi.",closed:"Bu sohbet kapat\u0131ld\u0131.",rateTitle:"Bu sohbeti nas\u0131l buldunuz?",rateComment:"Eklemek istedi\u011Finiz bir \u015Fey var m\u0131? (iste\u011Fe ba\u011Fl\u0131)",rateSend:"G\xF6nder",rateThanks:"Geri bildiriminiz bize ula\u015Ft\u0131.",rateThanksTitle:"Te\u015Fekk\xFCrler!",rateScale:["Hi\xE7 iyi de\u011Fildi","Bekledi\u011Fim gibi olmad\u0131","\u0130dare eder","\u0130yiydi","Harikayd\u0131"],reviewIntro:"Yard\u0131mc\u0131 olabildiysek bizi yorumlar m\u0131s\u0131n\u0131z?",reviewCta:"De\u011Ferlendir",failed:"G\xF6nderilemedi \u2014 tekrar dene",fileTooLarge:"Dosya \xE7ok b\xFCy\xFCk (en fazla {mb} MB)",fileNotAllowed:"Bu dosya t\xFCr\xFCn\xFC y\xFCkleyemezsiniz",tooLong:"Mesaj en fazla {max} karakter olabilir",unavailable:"Sohbet \u015Fu an kullan\u0131lam\u0131yor. L\xFCtfen daha sonra tekrar deneyin.",close:"Kapat",dismiss:"Sohbet balonunu gizle",minimize:"K\xFC\xE7\xFClt",unreadTitle:"({n}) Yeni mesaj",dropHere:"Dosyay\u0131 buraya b\u0131rak\u0131n",replyingTo:"Yan\u0131tlan\u0131yor",attachment:"Ek",poweredBy:"Signalbird ile",resize:"Boyutland\u0131r",emoji:"Emoji ekle",jump:"En alta in",newMessage:"Yeni mesaj",replyFast:"\u015Eu an buraday\u0131z \u2014 genelde birka\xE7 dakika i\xE7inde yan\u0131tl\u0131yoruz."},Fe={launcher:"Chat",title:"Chat",online:"Online",offline:"We usually reply within a few minutes",greeting:"Hi there! How can we help you?",offlineMessage:"We're offline right now. Leave a message and we'll get back to you.",prechatTitle:"Before we start",prechatHint:"Leave your details so we can get back to you.",topicLabel:"Topic",topicPlaceholder:"Pick a topic (optional)",name:"Your name",email:"Email",start:"Start chat",skip:"Skip",placeholder:"Type your message\u2026",send:"Send",attach:"Attach file",typing:"is typing\u2026",today:"Today",yesterday:"Yesterday",reply:"Reply",react:"React",edit:"Edit",delete:"Delete",deleted:"This message was deleted",edited:"edited",save:"Save",cancel:"Cancel",you:"You",agent:"Support",system:"System",endChat:"End chat",newChat:"New chat",resolved:"This conversation was marked as resolved.",closed:"This conversation was closed.",rateTitle:"How was this conversation?",rateComment:"Anything to add? (optional)",rateSend:"Send",rateThanks:"Your feedback reached us.",rateThanksTitle:"Thank you!",rateScale:["Not good at all","Not what I expected","It was okay","Good","Excellent"],reviewIntro:"If we were helpful, would you leave us a review?",reviewCta:"Leave a review",failed:"Not sent \u2014 tap to retry",fileTooLarge:"File is too large (max {mb} MB)",fileNotAllowed:"That file type cannot be uploaded",tooLong:"A message may be at most {max} characters",unavailable:"Chat is unavailable right now. Please try again later.",close:"Close",dismiss:"Hide the chat bubble",minimize:"Minimize",unreadTitle:"({n}) New message",dropHere:"Drop the file here",replyingTo:"Replying to",attachment:"Attachment",poweredBy:"Powered by Signalbird",resize:"Resize",emoji:"Add emoji",jump:"Jump to latest",newMessage:"New message",replyFast:"We're here right now \u2014 we usually reply within a few minutes."};function Q(s,e){let t=n=>n&&n!=="auto"?n.toLowerCase().slice(0,2):null;return (t(e)||t(s)||t(typeof navigator!="undefined"?navigator.language:null)||"en")==="tr"?"tr":"en"}function ee(s){return s==="tr"?Ke:Fe}function j(s,e){return s.replace(/\{(\w+)\}/g,(t,i)=>{var n;return String((n=e[i])!=null?n:"")})}var Ue=["image/jpeg","image/png","image/gif","image/webp"],Ye=420,qe=60,Ge=11e3,We=9e3,me="sb_teaser",ve="sb_seen",U=class{constructor(e){this.o=e;this.list=null;this.typingEl=null;this.typingAvatar=null;this.jumpBtn=null;this.textarea=null;this.sendBtn=null;this.emojiBox=null;this.chips=null;this.replyBar=null;this.notice=null;this.files=[];this.counter=null;this.replyTo=null;this.editing=null;this.view="none";this.agent=null;this.online=false;this.typingTimer=null;this.teaserTimer=null;this.toastTimer=null;this.attnTimer=null;this.wasTyping=false;this.scrollLock=0;this.locked=false;var l;let t=e.t;this.host=r("div",{id:"signalbird-widget"}),this.root=this.host.attachShadow({mode:"open"}),this.root.appendChild(r("style",null,re));let i=e.settings.position==="left"?"left":"right",n=e.settings.layout==="sidebar"?" sidebar":"";if(this.wrap=r("div",{class:`sb ${i}${n}${Ze(e.settings.theme)?" dark":""}`,style:`--sb-c:${Qe(e.settings.color)}`}),e.settings.theme==="auto"&&typeof matchMedia=="function"){let d=matchMedia("(prefers-color-scheme: dark)");(l=d.addEventListener)==null||l.call(d,"change",c=>this.wrap.classList.toggle("dark",c.matches));}this.badge=r("span",{class:"badge"});let a=e.settings.launcher_text;this.launcher=r("button",{class:`ln${a?"":" icon-only"}`,type:"button","aria-label":a||t.launcher,onclick:()=>this.onLauncher()},r("span",{class:"lm"},this.launcherMark()),a?r("span",{class:"lt"},a):null,r("span",{class:"ln-on"}),r("span",{class:"ln-pulse"}),this.badge),this.dismissBtn=r("button",{class:"dm",type:"button",title:t.dismiss,"aria-label":t.dismiss,onclick:d=>{d.stopPropagation(),e.actions.dismiss();}},y("close",13)),this.teaser=this.buildTeaser(),this.toast=this.buildToast(),this.headerPhoto=r("div",{class:"ph"},this.brandAvatar()),this.headerDot=r("span",{class:"dot"}),this.headerName=r("div",{class:"hn"},e.appName||t.title),this.headerStatus=r("div",{class:"hs"},t.offline),this.endBtn=r("button",{class:"hb hide",type:"button",title:t.endChat,"aria-label":t.endChat,onclick:()=>e.actions.endChat()},y("done",19));let o=r("div",{class:"hd"},r("div",{class:"av"},this.headerPhoto,this.headerDot),r("div",{class:"hi"},this.headerName,this.headerStatus),r("div",{class:"ha"},this.endBtn,r("button",{class:"hb",type:"button",title:t.close,"aria-label":t.close,onclick:()=>e.actions.close()},y("close",20))));this.dragBar=r("div",{class:"drag","aria-hidden":"true"},r("i")),this.banner=r("div",{class:"bn"}),this.body=r("div",{class:"bd"}),this.grip=r("div",{class:"gp",title:t.resize,"aria-hidden":"true"}),this.panel=r("div",{class:"pn",role:"dialog","aria-modal":"false","aria-label":t.title},r("div",{class:"glow","aria-hidden":"true"}),this.dragBar,o,this.banner,this.body,this.grip),e.settings.layout!=="sidebar"&&(this.restoreGeometry(),this.enableMove(o),this.enableResize()),this.enableSwipeClose(),this.wrap.appendChild(this.launcher),this.wrap.appendChild(this.dismissBtn),this.wrap.appendChild(this.teaser),this.wrap.appendChild(this.toast),this.wrap.appendChild(this.panel),this.root.appendChild(this.wrap),this.enableDrop(),this.onKey=this.onKey.bind(this),this.onViewport=this.onViewport.bind(this);}key(e){return `${e}_${this.o.publicKey}`}mount(){this.host.isConnected||document.body.appendChild(this.host),document.addEventListener("keydown",this.onKey),this.scheduleTeaser();}unmount(){var e;this.clearTimers(),this.unlockScroll(),document.removeEventListener("keydown",this.onKey),(e=F())==null||e.removeEventListener("resize",this.onViewport),this.host.remove();}setDismissed(e){this.wrap.classList.toggle("hidden",e),e&&this.hideTeaser(false);}setLauncherHidden(e){this.wrap.classList.toggle("no-ln",e),e&&this.hideTeaser(false);}setOpen(e){var t;this.wrap.classList.toggle("open",e),e?(xe(this.key(ve)),this.hideTeaser(false),this.hideToast(),this.lockScroll(),this.bindViewport(),requestAnimationFrame(()=>{var i;this.list&&R(this.list),_()||(i=this.textarea)==null||i.focus();})):(this.unlockScroll(),(t=F())==null||t.removeEventListener("resize",this.onViewport),this.wrap.style.setProperty("--sb-kb","0px"),this.wrap.classList.remove("kb"),this.hideEmoji());}setUnread(e){this.badge.textContent=e>99?"99+":String(e),this.badge.classList.toggle("on",e>0),this.wrap.classList.toggle("pulse",e>0),e===0&&this.hideToast();}attention(e){let t=this.launcher;t.classList.remove("attn"),t.offsetWidth,t.classList.add("attn"),this.attnTimer&&clearTimeout(this.attnTimer),this.attnTimer=setTimeout(()=>t.classList.remove("attn"),2400),e&&(e.body||e.name)&&this.showToast(e);}setHeader(e,t){var a;let i=this.o.t;this.agent=e,this.online=(a=e==null?void 0:e.online)!=null?a:t;let n=(e==null?void 0:e.name)||this.o.appName||i.title;this.headerName.textContent=n,T(this.headerPhoto),this.headerPhoto.appendChild(e?S(e.avatar,n):this.brandAvatar()),this.headerDot.classList.toggle("on",this.online),this.headerStatus.textContent=this.online?i.online:i.offline,this.wrap.classList.toggle("agent-on",this.online),this.typingAvatar&&(T(this.typingAvatar),this.typingAvatar.appendChild(S(e==null?void 0:e.avatar,n)));}setBanner(e,t=false){T(this.banner),this.banner.className=`bn${t?" err":""}${e?" on":""}`,e&&(this.banner.appendChild(y(t?"close":"chat",15)),this.banner.appendChild(r("span",null,e)));}setEndVisible(e){this.endBtn.classList.toggle("hide",!e);}get currentView(){return this.view}showPrechat(e){let t=this.o.t,i=this.o.settings.prechat||{name:true,email:true,required:false};this.view="prechat",this.list=null,this.textarea=null,T(this.body);let n=ye("text",t.name,e.name||"","name"),a=ye("email",t.email,e.email||"","email"),o=this.o.topics||[],l=o.length?r("select",{"aria-label":t.topicLabel},r("option",{value:""},t.topicPlaceholder),...o.map(f=>r("option",{value:f.slug},f.name))):null,d=l?r("div",{class:"fld"},l,r("label",null,t.topicLabel),r("span",{class:"cv"},y("chevron",16))):null,c=()=>{let f=n.input.value.trim(),p=a.input.value.trim();if(i.required&&(i.name&&!f||i.email&&!p)){let h=i.name&&!f?n:a;h.wrap.classList.add("bad"),h.input.focus();return}if(p&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(p)){a.wrap.classList.add("bad"),a.input.focus();return}this.o.actions.submitPrechat(f,p,(l==null?void 0:l.value)||null);},g=r("form",{class:"fm",onsubmit:f=>{f.preventDefault(),c();}},r("h3",null,t.prechatTitle),r("p",null,this.o.settings.greeting||t.prechatHint),i.name?n.wrap:null,i.email?a.wrap:null,d,r("button",{class:"btn",type:"submit"},t.start),i.required?null:r("button",{class:"btn gh",type:"button",onclick:()=>this.o.actions.skipPrechat((l==null?void 0:l.value)||null)},t.skip));this.body.appendChild(g),_()||setTimeout(()=>(i.name?n.input:a.input).focus(),60);}showChat(){var t,i;if(this.view==="chat"&&this.list)return;let e=this.o.t;this.view="chat",T(this.body),this.list=r("div",{class:"ml"}),this.list.addEventListener("scroll",()=>this.syncJump(),{passive:true}),this.jumpBtn=r("button",{class:"jump",type:"button","aria-label":e.jump,onclick:()=>this.list&&R(this.list,true)},y("down",14),r("span",null,e.jump)),this.typingAvatar=r("div",{class:"av"},S((t=this.agent)==null?void 0:t.avatar,((i=this.agent)==null?void 0:i.name)||this.o.appName)),this.typingEl=r("div",{class:"tp","aria-live":"polite"},this.typingAvatar,r("div",{class:"dots"},r("i"),r("i"),r("i"))),this.notice=r("div",{class:"notice"}),this.body.appendChild(this.list),this.body.appendChild(this.jumpBtn),this.body.appendChild(this.typingEl),this.body.appendChild(this.notice),this.body.appendChild(this.buildComposer()),this.body.appendChild(r("div",{class:"drop"},y("image",26),r("span",null,e.dropHere)));}showRating(){let e=this.o.t;this.view="rating",this.list=null,this.textarea=null,T(this.body);let t=0,i=[],n=r("div",{class:"rl"}),a=()=>{i.forEach((c,g)=>c.classList.toggle("on",g<t)),n.textContent=t?e.rateScale[t-1]:"";},o=r("div",{class:"stars"});for(let c=1;c<=5;c++){let g=r("button",{type:"button","aria-label":String(c),onclick:()=>{t=c,a();}},y("star",32));i.push(g),o.appendChild(g);}let l=r("textarea",{placeholder:e.rateComment,rows:3}),d=r("form",{class:"fm",onsubmit:c=>{c.preventDefault(),this.o.actions.rate(t,l.value.trim());}},r("h3",{style:"text-align:center"},e.rateTitle),o,n,l,r("button",{class:"btn",type:"submit"},e.rateSend),r("button",{class:"btn gh",type:"button",onclick:()=>this.o.actions.rate(0,"")},e.skip));this.body.appendChild(d);}showThanks(e){let t=this.o.t;this.view="none",this.list=null,this.textarea=null,T(this.body);let i=r("div",{class:"ok"},r("div",{class:"ic"},y("done",30)),r("h3",null,t.rateThanksTitle),r("p",null,t.rateThanks));e!=null&&e.url&&(i.appendChild(r("p",{style:"margin-top:16px"},t.reviewIntro)),i.appendChild(r("a",{class:"btn",href:e.url,target:"_blank",rel:"noopener noreferrer"},e.label||t.reviewCta))),i.appendChild(r("button",{class:"btn gh",type:"button",onclick:()=>this.o.actions.newChat()},t.newChat)),this.body.appendChild(i);}render(e){var t,i;this.list&&(fe(this.list,{...e,t:this.o.t,locale:this.o.locale,actions:this.o.actions,agentAvatar:((t=this.agent)==null?void 0:t.avatar)||P(this.o.settings.logo_url),brandName:((i=this.agent)==null?void 0:i.name)||this.o.appName,responseHint:this.online?this.o.t.replyFast:this.o.settings.offline_message||this.o.t.offlineMessage,quick:this.quickStarters(),onQuick:n=>this.o.actions.send(n,[],null)}),this.syncJump());}setTyping(e,t){this.typingEl&&(this.typingEl.classList.toggle("on",e),this.typingEl.setAttribute("aria-label",`${t} ${this.o.t.typing}`),e&&this.list&&V(this.list,120)&&R(this.list,true));}setNotice(e,t){this.notice&&(T(this.notice),this.notice.classList.toggle("on",!!e),e&&(this.notice.appendChild(document.createTextNode(e)),t&&this.notice.appendChild(r("button",{type:"button",onclick:t.fn},t.label))));}setReply(e){var i,n;if(this.replyTo=e,!this.replyBar||(T(this.replyBar),this.replyBar.classList.toggle("on",!!e),!e))return;let t=e.sender_type==="visitor"?this.o.t.you:((i=e.agent)==null?void 0:i.name)||e.sender_name||this.o.t.agent;this.replyBar.appendChild(y("reply",14)),this.replyBar.appendChild(r("span",{class:"rt"},`${this.o.t.replyingTo} ${t}: ${D(e,this.o.t)}`)),this.replyBar.appendChild(r("button",{type:"button","aria-label":this.o.t.cancel,onclick:()=>this.setReply(null)},y("close",14))),(n=this.textarea)==null||n.focus();}startEdit(e){!this.textarea||!this.replyBar||(this.editing=e,this.setReply(null),this.textarea.value=e.body||"",this.autosize(),this.syncSend(),this.textarea.focus(),T(this.replyBar),this.replyBar.classList.add("on"),this.replyBar.appendChild(r("span",{class:"rt"},`${this.o.t.edit}: ${D(e,this.o.t)}`)),this.replyBar.appendChild(r("button",{type:"button","aria-label":this.o.t.cancel,onclick:()=>this.cancelEdit()},y("close",14))));}buildComposer(){let e=this.o.t;this.replyBar=r("div",{class:"rq"}),this.chips=r("div",{class:"chips"}),this.textarea=r("textarea",{rows:1,placeholder:e.placeholder,"aria-label":e.placeholder,maxLength:this.maxChars,onkeydown:n=>{n.key==="Enter"&&!n.shiftKey&&!n.isComposing?(n.preventDefault(),this.submit()):n.key==="Escape"&&(this.editing?this.cancelEdit():this.replyTo?this.setReply(null):this.hideEmoji());},oninput:()=>{this.autosize(),this.syncSend(),this.notifyTyping();},onpaste:n=>{var o;let a=Array.from(((o=n.clipboardData)==null?void 0:o.files)||[]);a.length&&(n.preventDefault(),this.addFiles(a));}});let t=r("input",{type:"file",multiple:true,style:"display:none",accept:this.allowedMimes.join(","),onchange:()=>{this.addFiles(Array.from(t.files||[])),t.value="";}});return this.emojiBox=r("div",{class:"emj"},...be.map(n=>r("button",{type:"button",onclick:()=>this.insertEmoji(n)},n))),this.sendBtn=r("button",{class:"cb sd",type:"button",title:e.send,"aria-label":e.send,disabled:true,onclick:()=>this.submit()},y("send",17)),this.counter=r("div",{class:"cnt"}),r("div",{class:"cp"},this.emojiBox,this.replyBar,this.chips,this.counter,r("div",{class:"cr"},r("button",{class:"cb",type:"button",title:e.attach,"aria-label":e.attach,onclick:()=>t.click()},y("clip",19)),this.textarea,r("button",{class:"cb",type:"button",title:e.emoji,"aria-label":e.emoji,onclick:n=>{n.stopPropagation(),this.toggleEmoji();}},y("smile",19)),this.sendBtn),t,r("div",{class:"pw"},r("a",{href:"https://signalbird.io",target:"_blank",rel:"noopener",title:e.poweredBy},r("span",{class:"pk"},X(13)),r("span",{class:"pn2"},"Signalbird"))))}submit(){if(!this.textarea)return;let e=this.textarea.value.trim();if(this.editing){let n=this.editing;this.cancelEdit(),e&&e!==n.body&&this.o.actions.saveEdit(n,e);return}if(!e&&this.files.length===0)return;if(this.textarea.value.length>this.maxChars){this.flash(j(this.o.t.tooLong,{max:this.maxChars}));return}let t=this.files,i=this.replyTo;this.files=[],this.renderChips(),this.setReply(null),this.hideEmoji(),this.textarea.value="",this.autosize(),this.syncSend(),this.stopTyping(),this.o.actions.send(e,t,i),_()||this.textarea.focus();}cancelEdit(){this.editing=null,this.textarea&&(this.textarea.value="",this.autosize(),this.syncSend()),this.replyBar&&(T(this.replyBar),this.replyBar.classList.remove("on"));}addFiles(e){let t=this.o.maxMb*1024*1024;for(let i of e){if(i.size>t){this.flash(j(this.o.t.fileTooLarge,{mb:this.o.maxMb}));continue}if(i.type&&!this.allowedMimes.includes(i.type)){this.flash(this.o.t.fileNotAllowed);continue}if(this.files.length>=5)break;this.files.push(i);}this.renderChips(),this.syncSend();}renderChips(){this.chips&&(T(this.chips),this.chips.classList.toggle("on",this.files.length>0),this.files.forEach((e,t)=>{this.chips.appendChild(r("div",{class:"chip"},e.type.startsWith("image/")?r("img",{src:URL.createObjectURL(e),alt:""}):y("file",16),r("span",null,e.name),r("button",{type:"button","aria-label":this.o.t.delete,onclick:()=>{this.files.splice(t,1),this.renderChips(),this.syncSend();}},y("close",12))));}));}syncSend(){if(!this.sendBtn||!this.textarea)return;let e=!this.textarea.value.trim()&&this.files.length===0;this.sendBtn.disabled=e||this.textarea.value.length>this.maxChars,this.syncCounter();}syncCounter(){if(!this.counter||!this.textarea)return;let e=this.maxChars-this.textarea.value.length,t=e<=qe;this.counter.classList.toggle("on",t),this.counter.classList.toggle("full",e<=0),this.counter.textContent=t?String(e):"";}toggleEmoji(){if(!this.emojiBox)return;this.emojiBox.classList.toggle("on")&&document.addEventListener("click",()=>this.hideEmoji(),{once:true,capture:true});}hideEmoji(){var e;(e=this.emojiBox)==null||e.classList.remove("on");}insertEmoji(e){var n,a;if(!this.textarea)return;let t=this.textarea,i=(n=t.selectionStart)!=null?n:t.value.length;t.value=t.value.slice(0,i)+e+t.value.slice((a=t.selectionEnd)!=null?a:i),t.selectionStart=t.selectionEnd=i+e.length,this.autosize(),this.syncSend(),t.focus();}autosize(){let e=this.textarea;e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,132)}px`);}notifyTyping(){this.wasTyping||(this.wasTyping=true,this.o.actions.typing(true)),this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=setTimeout(()=>this.stopTyping(),2500);}stopTyping(){this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=null,this.wasTyping&&(this.wasTyping=false,this.o.actions.typing(false));}syncJump(){!this.jumpBtn||!this.list||this.jumpBtn.classList.toggle("on",!V(this.list,160));}flash(e){this.setBanner(e,true),setTimeout(()=>this.setBanner(null),3200);}buildTeaser(){let e=this.o.t,t=this.o.settings;return r("div",{class:"teaser",role:"button",tabindex:0,onclick:()=>{this.hideTeaser(true),this.o.actions.open();}},r("div",{class:"tv"},this.brandAvatar()),r("div",{class:"tc"},r("div",{class:"tn"},this.o.appName||e.title),r("div",{class:"tb"},t.greeting||e.greeting)),r("button",{class:"tx",type:"button","aria-label":e.close,onclick:i=>{i.stopPropagation(),this.hideTeaser(true);}},y("close",13)))}buildToast(){return r("div",{class:"toast",role:"button",tabindex:0,onclick:()=>{this.hideToast(),this.o.actions.open();}},r("div",{class:"tv"}),r("div",{class:"tc"},r("div",{class:"tn"}),r("div",{class:"tb"})))}scheduleTeaser(){we(this.key(me))||we(this.key(ve))||this.o.settings.launcher_mode!=="manual"&&(this.teaserTimer=setTimeout(()=>{this.wrap.classList.contains("open")||this.wrap.classList.contains("hidden")||this.wrap.classList.contains("no-ln")||this.wrap.classList.contains("tst")||this.wrap.classList.add("tz");},Ge));}hideTeaser(e){this.teaserTimer&&clearTimeout(this.teaserTimer),this.teaserTimer=null,this.wrap.classList.remove("tz"),e&&xe(this.key(me));}showToast(e){var o,l;let t=e.name||((o=this.agent)==null?void 0:o.name)||this.o.appName||this.o.t.agent,i=this.toast.querySelector(".tv"),n=this.toast.querySelector(".tn"),a=this.toast.querySelector(".tb");T(i),i.appendChild(S(e.avatar||((l=this.agent)==null?void 0:l.avatar),t)),n.textContent=t,a.textContent=e.body||this.o.t.newMessage,this.hideTeaser(false),this.wrap.classList.add("tst"),this.toastTimer&&clearTimeout(this.toastTimer),this.toastTimer=setTimeout(()=>this.hideToast(),We);}hideToast(){this.toastTimer&&clearTimeout(this.toastTimer),this.toastTimer=null,this.wrap.classList.remove("tst");}onLauncher(){this.hideTeaser(true),this.hideToast(),this.o.actions.open();}get allowedMimes(){let e=this.o.settings.attachment_mimes;return Array.isArray(e)&&e.length?e:Ue}get maxChars(){let e=Number(this.o.settings.max_message_chars);return Number.isFinite(e)&&e>0?e:Ye}quickStarters(){return (this.o.topics||[]).slice(0,4).map(e=>e.name).filter(Boolean)}bindViewport(){let e=F();e&&(e.addEventListener("resize",this.onViewport),this.onViewport());}onViewport(){let e=F();if(!e||!_())return;let t=Math.max(0,window.innerHeight-e.height-e.offsetTop);this.wrap.style.setProperty("--sb-kb",`${t}px`),this.wrap.classList.toggle("kb",t>40),t>40&&this.list&&requestAnimationFrame(()=>this.list&&R(this.list));}lockScroll(){if(this.locked||!_())return;this.locked=true,this.scrollLock=window.scrollY||0;let e=document.body.style;e.position="fixed",e.top=`-${this.scrollLock}px`,e.left="0",e.right="0",e.width="100%";}unlockScroll(){if(!this.locked)return;this.locked=false;let e=document.body.style;e.position="",e.top="",e.left="",e.right="",e.width="",window.scrollTo(0,this.scrollLock);}enableSwipeClose(){let e=0,t=0,i=false,n=()=>{i&&(i=false,this.wrap.classList.remove("dragging"),this.panel.style.transform="",t>110&&this.o.actions.close(),removeEventListener("pointermove",a),removeEventListener("pointerup",n),removeEventListener("pointercancel",n));},a=o=>{i&&(t=Math.max(0,o.clientY-e),this.panel.style.transform=`translateY(${t}px)`,this.panel.style.opacity=String(Math.max(.5,1-t/420)));};this.dragBar.addEventListener("pointerdown",o=>{_()&&(i=true,e=o.clientY,t=0,this.wrap.classList.add("dragging"),addEventListener("pointermove",a),addEventListener("pointerup",n),addEventListener("pointercancel",n));});}onKey(e){var t;if(e.key==="Escape"){if((t=this.emojiBox)!=null&&t.classList.contains("on")){this.hideEmoji();return}this.wrap.classList.contains("open")&&this.o.actions.close();}}enableDrop(){let e=0;this.body.addEventListener("dragenter",t=>{t.preventDefault(),e++,this.view==="chat"&&this.body.classList.add("dragover");}),this.body.addEventListener("dragover",t=>t.preventDefault()),this.body.addEventListener("dragleave",()=>{--e<=0&&(e=0,this.body.classList.remove("dragover"));}),this.body.addEventListener("drop",t=>{var i;t.preventDefault(),e=0,this.body.classList.remove("dragover"),this.view==="chat"&&((i=t.dataTransfer)!=null&&i.files)&&this.addFiles(Array.from(t.dataTransfer.files));});}clearTimers(){for(let e of [this.typingTimer,this.teaserTimer,this.toastTimer,this.attnTimer])e&&clearTimeout(e);}launcherMark(){let e=this.o.settings,t=P(e.logo_url);return e.launcher_icon==="logo"&&t?r("img",{class:"lg",src:t,alt:""}):e.launcher_icon==="chat"?y("chat",25):X(27)}brandAvatar(){let e=P(this.o.settings.logo_url);return e?r("img",{src:e,alt:""}):document.createTextNode($(this.o.appName))}restoreGeometry(){let e=Je();e&&(e.w&&(this.panel.style.width=`${e.w}px`),e.h&&(this.panel.style.height=`${e.h}px`),this.wrap.style.setProperty("--sb-dx",`${e.dx||0}px`),this.wrap.style.setProperty("--sb-dy",`${e.dy||0}px`));}saveGeometry(){Xe({w:this.panel.offsetWidth,h:this.panel.offsetHeight,dx:parseFloat(this.wrap.style.getPropertyValue("--sb-dx"))||0,dy:parseFloat(this.wrap.style.getPropertyValue("--sb-dy"))||0});}enableMove(e){e.addEventListener("pointerdown",t=>{if(t.button!==0||_()||t.target.closest("button"))return;let i=t.clientX,n=t.clientY,a=parseFloat(this.wrap.style.getPropertyValue("--sb-dx"))||0,o=parseFloat(this.wrap.style.getPropertyValue("--sb-dy"))||0,l=this.wrap.classList.contains("left")?-1:1,d=false,c=f=>{let p=f.clientX-i,h=f.clientY-n;if(!d&&Math.abs(p)+Math.abs(h)<4)return;d=true,this.wrap.classList.add("moving");let m=Math.max(0,innerWidth-this.panel.offsetWidth-24),x=Math.max(0,innerHeight-this.panel.offsetHeight-24);this.wrap.style.setProperty("--sb-dx",`${K(a-p*l,0,m)}px`),this.wrap.style.setProperty("--sb-dy",`${K(o-h,0,x)}px`);},g=()=>{removeEventListener("pointermove",c),removeEventListener("pointerup",g),this.wrap.classList.remove("moving"),d&&this.saveGeometry();};addEventListener("pointermove",c),addEventListener("pointerup",g);});}enableResize(){this.grip.addEventListener("pointerdown",e=>{if(e.button!==0||_())return;e.preventDefault();let t=e.clientX,i=e.clientY,n=this.panel.offsetWidth,a=this.panel.offsetHeight,o=this.wrap.classList.contains("left")?-1:1;this.wrap.classList.add("sizing");let l=c=>{this.panel.style.width=`${K(n+(t-c.clientX)*o,340,innerWidth-40)}px`,this.panel.style.height=`${K(a+(i-c.clientY),400,innerHeight-40)}px`;},d=()=>{removeEventListener("pointermove",l),removeEventListener("pointerup",d),this.wrap.classList.remove("sizing"),this.saveGeometry();};addEventListener("pointermove",l),addEventListener("pointerup",d);});}};function ye(s,e,t,i){let n=r("input",{type:s,value:t,autocomplete:i,placeholder:" "});return t&&n.classList.add("has"),n.addEventListener("input",()=>{var a;n.classList.toggle("has",n.value.length>0),(a=n.parentElement)==null||a.classList.remove("bad");}),{wrap:r("div",{class:"fld"},n,r("label",null,e)),input:n}}var ke="sb_geometry";function Je(){try{let s=localStorage.getItem(ke);if(!s)return null;let e=JSON.parse(s);return !e||e.w>innerWidth||e.h>innerHeight?null:e}catch(s){return null}}function Xe(s){try{localStorage.setItem(ke,JSON.stringify(s));}catch(e){}}function xe(s){try{localStorage.setItem(s,"1");}catch(e){}}function we(s){try{return localStorage.getItem(s)==="1"}catch(e){return false}}function K(s,e,t){return Math.min(Math.max(s,e),t)}function _(){return innerWidth<=640}function F(){return typeof window!="undefined"&&window.visualViewport||null}function Ze(s){return s==="dark"?true:s!=="auto"||typeof matchMedia!="function"?false:matchMedia("(prefers-color-scheme: dark)").matches}function Qe(s){return s&&/^(#[0-9a-f]{3,8}|rgba?\([\d\s.,%]+\)|hsla?\([\d\s.,%]+\))$/i.test(s)?s:"#4f46e5"}var Y=class{constructor(){this.original=null;this.timer=null;this.label="";}update(e,t){e>0&&document.hidden?(this.label=t(e),this.begin()):this.end();}begin(){if(this.timer)return;this.original=document.title;let e=false;this.timer=setInterval(()=>{if(!document.hidden)return this.end();e=!e,document.title=e?this.label:this.original||"";},1200);}end(){this.timer&&clearInterval(this.timer),this.timer=null,this.original!==null&&(document.title=this.original,this.original=null);}};var A=null;function te(){try{let s=window.AudioContext||window.webkitAudioContext;if(!s)return;A||(A=new s),A.state==="suspended"&&A.resume();let e=A.currentTime,t=A.createGain();t.gain.setValueAtTime(1e-4,e),t.gain.exponentialRampToValueAtTime(.12,e+.02),t.gain.exponentialRampToValueAtTime(1e-4,e+.35),t.connect(A.destination);let i=A.createOscillator();i.type="sine",i.frequency.setValueAtTime(880,e),i.frequency.setValueAtTime(1175,e+.12),i.connect(t),i.start(e),i.stop(e+.36);}catch(s){}}var et="https://live.signalbird.io/api",E="/v1/sdk/chat/conversations",q=class{constructor(e){this.opts=e;this.title=new Y;this.topic=null;this.ui=null;this.settings=null;this.appName="";this.started=false;this.destroyed=false;this.pendingSends=new Map;this.ratingMode=null;this.autoOpened=false;this.identity=null;this.lastTypingSent=0;this.pollCount=0;this.forceFull=false;this.socket=null;this.onVisibility=()=>{this.syncUnread(),!document.hidden&&this.store.isOpen&&this.store.conversation&&this.markRead();};this.baseUrl=(e.baseUrl||et).replace(/\/$/,""),this.store=new I(e.publicKey),this.api=new H(this.baseUrl,e.publicKey,e.chatKey,()=>this.store.secret,(...t)=>this.log(...t)),this.poller=new B(()=>this.tick()),this.identity=e.user&&(e.user.name||e.user.email||e.user.external_id)?e.user:null,this.locale=Q(null,e.locale),this.t=ee(this.locale),this.ready=this.start().catch(t=>this.log("start failed",t));}log(...e){this.opts.debug&&console.debug("[signalbird]",...e);}async start(){var f;let e=await this.api.post("/v1/sdk/bootstrap",{page_url:location.href,locale:this.opts.locale});if(!e.ok||!e.data){this.log("bootstrap failed",e);return}let t=(f=e.data.channel)!=null?f:e.data.app;if(!t){this.log("bootstrap failed",e);return}if(this.destroyed)return;let{online:i,within_hours:n,visitor:a,conversation:o,topics:l,realtime:d}=e.data;if(!t.chat_enabled){this.log("chat disabled for app");return}let c=t.chat||{};this.settings=c,this.appName=t.name||"",this.locale=Q(c.locale,this.opts.locale),this.t=ee(this.locale),this.store.visitor&&!a&&this.store.clearVisitor(),a&&this.store.setVisitor({id:a.id,name:a.name,email:a.email}),this.store.online=!!i,this.store.withinHours=n!==false,o&&this.store.setConversation(o);let g=Number(c.max_attachment_mb||t.max_attachment_mb||10);this.ui=new U({t:this.t,locale:this.locale,publicKey:this.opts.publicKey,settings:c,appName:this.appName,maxMb:g,topics:l||[],actions:{open:()=>this.open(),close:()=>this.close(),send:(p,h,m)=>{this.send(p,h,m);},typing:p=>{this.typing(p);},submitPrechat:(p,h,m)=>{this.submitPrechat(p,h,m);},skipPrechat:p=>{this.topic=p,this.enterChat();},rate:(p,h)=>{this.rate(p,h);},dismiss:()=>this.dismiss(),endChat:()=>this.endChat(),newChat:()=>this.newChat(),saveEdit:(p,h)=>{this.saveEdit(p,h);},reply:p=>{var h;return (h=this.ui)==null?void 0:h.setReply(p)},react:(p,h)=>{this.react(p,h);},edit:p=>{var h;return (h=this.ui)==null?void 0:h.startEdit(p)},remove:p=>{this.remove(p);},retry:p=>{this.retry(p);},openImage:p=>window.open(p,"_blank","noopener")}}),this.store.on("unread",()=>this.syncUnread()),this.store.on("messages",()=>this.render()),this.store.on("change",()=>this.render()),document.addEventListener("visibilitychange",this.onVisibility),this.ui.mount(),this.ui.setDismissed(this.store.dismissed),this.syncLauncher(),this.ui.setHeader(this.store.agent,this.store.online),this.applyBanner(),this.store.setUnread((a==null?void 0:a.unread)||(o==null?void 0:o.visitor_unread)||0),this.syncUnread(),this.started=true,this.poller.start(),d!=null&&d.enabled&&(this.socket=new O(d,(p,h)=>this.authorizeChannel(p,h),p=>this.onSocketEvent(p),p=>{this.log("socket",p?"connected":"disconnected"),this.poller.setLive(p),p&&this.poller.poke(0);},(...p)=>this.log(...p)),this.socket.connect(),this.subscribeVisitor()),this.opts.user&&this.identify(this.opts.user);}applyBanner(){!this.ui||!this.settings||this.ui.setBanner(this.store.withinHours?null:this.settings.offline_message||this.t.offlineMessage);}syncUnread(){var t;let e=this.store.isOpen&&!document.hidden?0:this.store.unread;(t=this.ui)==null||t.setUnread(this.store.unread),this.title.update(e,i=>j(this.t.unreadTitle,{n:i})),this.store.emit("public:unread",this.store.unread),this.syncLauncher();}syncLauncher(){var i;if(!this.ui)return;if(((i=this.settings)==null?void 0:i.launcher_mode)!=="manual"){this.ui.setLauncherHidden(false);return}let e=this.store.conversation,t=!!e&&e.status!=="closed";this.ui.setLauncherHidden(!(this.store.isOpen||t||this.store.unread>0));}dismiss(){var e;this.store.setDismissed(true),this.close(),(e=this.ui)==null||e.setDismissed(true);}open(){var e,t;this.store.dismissed&&(this.store.setDismissed(false),(e=this.ui)==null||e.setDismissed(false)),!(!this.ui||this.store.isOpen)&&(((t=this.store.conversation)==null?void 0:t.status)==="closed"&&(this.store.setConversation(null),this.ratingMode=null),this.store.isOpen=true,this.ui.setOpen(true),this.syncLauncher(),this.poller.setOpen(true),this.decideView(),this.store.emit("public:open"),this.store.conversation?this.loadConversation():this.store.setUnread(0),this.syncUnread());}close(){if(!this.ui||!this.store.isOpen)return;let e=this.store.conversation;if(e&&e.status==="resolved"&&!this.store.wasRated(e.id)&&this.ui.currentView==="chat"&&this.store.messages.some(t=>t.sender_type==="agent"||t.sender_type==="bot")){this.ratingMode="resolved",this.ui.setEndVisible(false),this.ui.showRating();return}this.store.isOpen=false,this.ui.setOpen(false),this.poller.setOpen(false),this.typing(false),this.store.emit("public:close"),this.syncUnread(),this.syncLauncher();}toggle(){this.store.isOpen?this.close():this.open();}isOpen(){return this.store.isOpen}on(e,t){this.store.on(`public:${e}`,t);}off(e,t){this.store.off(`public:${e}`,t);}async identify(e){var a;if(await this.ready,this.destroyed)return;this.identity={...this.identity||{},...e},((a=this.ui)==null?void 0:a.currentView)==="prechat"&&this.enterChat();let[t,...i]=(e.name||"").trim().split(/\s+/),n={external_id:e.external_id,email:e.email,phone:e.phone,first_name:t||void 0,last_name:i.join(" ")||void 0,attributes:e.attributes};e.external_id&&this.check(await this.api.post("/v1/sdk/identify",n)),await this.session({name:e.name,email:e.email,external_id:e.external_id});}async pushRegister(e){return await this.ready,this.api.post("/v1/sdk/devices",{provider:e.platform==="ios"?"apns":"fcm",locale:Te(),...e})}destroy(){var e,t;this.destroyed=true,(e=this.socket)==null||e.close(),this.socket=null,this.poller.stop(),this.title.end(),document.removeEventListener("visibilitychange",this.onVisibility),(t=this.ui)==null||t.unmount(),this.ui=null;}decideView(){var a,o;if(!this.ui||!this.settings)return;let e=this.settings.prechat,t=this.store.visitor;!!!((a=this.identity)!=null&&a.name||(o=this.identity)!=null&&o.email||t!=null&&t.name||t!=null&&t.email)&&!this.store.conversation&&e&&(e.name||e.email)?this.ui.showPrechat({}):this.enterChat();}enterChat(){var e;this.ui&&(this.ratingMode=null,this.ui.showChat(),this.ui.setEndVisible(((e=this.store.conversation)==null?void 0:e.status)==="open"),this.render());}render(){var t,i;if(!this.ui||this.ui.currentView!=="chat")return;let e=this.store.conversation;this.ui.render({messages:this.store.messages,greeting:((t=this.settings)==null?void 0:t.greeting)||this.t.greeting,agentName:((i=this.store.agent)==null?void 0:i.name)||this.t.agent,find:n=>this.store.find(n)}),this.ui.setEndVisible((e==null?void 0:e.status)==="open"),e&&e.status!=="open"?this.ui.setNotice(e.status==="resolved"?this.t.resolved:this.t.closed,{label:this.t.newChat,fn:()=>this.newChat()}):this.ui.setNotice(null);}async submitPrechat(e,t,i){var a;this.topic=i,await this.session({name:e||void 0,email:t||void 0})?this.enterChat():(a=this.ui)==null||a.setBanner(this.t.unavailable,true);}newChat(){this.ratingMode=null,this.store.setConversation(null),this.enterChat(),this.store.isOpen||this.open();}endChat(){!this.ui||!this.store.conversation||(this.ratingMode="end",this.ui.setEndVisible(false),this.ui.showRating());}async rate(e,t){var a;let i=this.store.conversation,n=this.ratingMode;if(this.ratingMode=null,!(!i||!this.ui)){if(e>0){let o=await this.api.post(`${E}/${i.id}/rate`,{rating:e,comment:t||void 0});this.check(o),this.store.markRated(i.id);}if(n==="end"){let o=await this.api.post(`${E}/${i.id}/close`);this.check(o),((a=this.store.conversation)==null?void 0:a.id)===i.id&&this.store.setConversation({...i,status:"closed"}),this.ui.showThanks(this.reviewFor(e));return}e===0&&this.store.markRated(i.id),this.enterChat(),this.close();}}reviewFor(e){var n,a,o,l;let t=(((n=this.settings)==null?void 0:n.review_url)||"").trim(),i=Number((o=(a=this.settings)==null?void 0:a.review_min_rating)!=null?o:3);return !t||!/^https?:\/\//i.test(t)?null:e>0&&e>=i?{url:t,label:((l=this.settings)==null?void 0:l.review_label)||null}:null}async session(e={}){var n;let t=this.identity?{name:this.identity.name,email:this.identity.email,external_id:this.identity.external_id}:{},i=await this.api.post("/v1/sdk/chat/session",{...t,...e,locale:Te(),page_url:location.href,user_agent:navigator.userAgent});if(i.ok&&((n=i.data)!=null&&n.visitor)){let a=i.data.visitor;return !a.secret&&!this.store.visitor?(this.log("session returned no secret"),false):(this.store.setVisitor(a),this.subscribeVisitor(),true)}return !i.ok&&i.code==="VISITOR_INVALID"&&this.store.visitor?(this.store.clearVisitor(),this.session(e)):(this.check(i),false)}subscribeVisitor(){var t;let e=(t=this.store.visitor)==null?void 0:t.id;this.socket&&e&&this.socket.subscribe(`visitor.${e}`);}async authorizeChannel(e,t){var n;let i=await this.api.post("/v1/sdk/chat/socket/auth",{socket_id:e,channel:t});return i.ok&&((n=i.data)!=null&&n.auth)?{auth:i.data.auth,at:i.data.at}:null}onSocketEvent(e){var t,i;if(e.name==="chat.typing"){e.data.who==="agent"&&(this.store.agentTyping=e.data.active===true,(i=this.ui)==null||i.setTyping(this.store.agentTyping,((t=this.store.agent)==null?void 0:t.name)||this.t.agent));return}e.data.updated===true&&(this.forceFull=true),this.poller.poke(0);}async loadConversation(){let e=this.store.conversation;if(!e)return;let t=await this.api.get(`${E}/${e.id}`,{limit:50});this.applyPayload(t,true)&&this.store.isOpen&&!document.hidden&&this.store.setUnread(0);}applyPayload(e,t){var n,a,o,l;if(!e.ok)return this.check(e),e.status===404&&this.store.setConversation(null),-1;let i=e.data;if(i.conversation){let d=(n=this.store.conversation)==null?void 0:n.status;this.store.conversation=i.conversation,d!==i.conversation.status&&this.store.emit("change");}return i.agent!==void 0&&(this.store.agent=i.agent||null),this.store.agentTyping=!!i.agent_typing,(a=this.ui)==null||a.setHeader(this.store.agent,this.store.online),(l=this.ui)==null||l.setTyping(this.store.agentTyping,((o=this.store.agent)==null?void 0:o.name)||this.t.agent),this.store.mergeMessages(i.messages||[],t)}async tick(){var d,c,g,f,p,h,m,x;if(!this.started||!this.store.visitor)return false;this.pollCount++;let e=this.store.conversation;if(this.store.isOpen&&e){let k=this.pollCount%5===0||this.forceFull;this.forceFull=false;let w=k?void 0:this.store.lastServerMessageId||void 0,M=await this.api.get(`${E}/${e.id}`,w?{after:w}:{limit:50}),u=this.applyPayload(M,!w);return u>0&&(document.hidden?(this.store.setUnread(this.store.unread+u),(d=this.settings)!=null&&d.sound&&te()):this.markRead()),u>0}if(this.store.isOpen&&!e&&this.pollCount%10!==0)return false;let t=await this.api.get(E);if(!t.ok)return this.check(t),false;let i=t.data,n=Array.isArray(i)?i:(i==null?void 0:i.conversations)||(i==null?void 0:i.data)||[],a=n.find(k=>k.status==="open")||null,o=n.reduce((k,w)=>k+(w.visitor_unread||0),0),l=o>this.store.unread;return a&&a.id!==((c=this.store.conversation)==null?void 0:c.id)&&(this.store.setConversation(a),this.store.isOpen&&this.loadConversation()),(!this.store.isOpen||document.hidden)&&(this.store.setUnread(o),l&&((g=this.settings)!=null&&g.sound&&te(),(x=this.ui)==null||x.attention({name:((f=a==null?void 0:a.agent)==null?void 0:f.name)||((p=this.store.agent)==null?void 0:p.name)||this.t.agent,avatar:((h=a==null?void 0:a.agent)==null?void 0:h.avatar)||((m=this.store.agent)==null?void 0:m.avatar)||null,body:(a==null?void 0:a.last_message_sender)==="agent"&&(a==null?void 0:a.last_message_preview)||null}),!this.autoOpened&&!document.hidden&&(this.autoOpened=true,this.open()))),l}async markRead(){let e=this.store.conversation,t=this.store.lastServerMessageId;!e||!t||(this.store.setUnread(0),await this.api.post(`${E}/${e.id}/read`,{last_message_id:t},true));}async send(e,t,i,n=le()){var l;let a={id:`local_${n}`,client_id:n,sender_type:"visitor",type:t.length?t[0].type.startsWith("image/")?"image":"file":"text",body:e||null,attachments:null,reply_to_id:(i==null?void 0:i.id)||null,created_at:new Date().toISOString(),_pending:true,_files:t};this.pendingSends.set(n,{text:e,files:t,replyTo:(i==null?void 0:i.id)||null}),this.store.upsertMessage(a);let o=()=>{let d=this.store.find(a.id);d&&this.store.upsertMessage({...d,_pending:false,_failed:true});};try{if(!this.store.visitor&&!await this.session())return o();let d=this.store.conversation,c=!d||d.status!=="open";if(c&&t.length===0){let h=await this.api.post(E,{body:e,page_url:location.href,client_id:n,...this.topic?{topic:this.topic}:{}});if(!h.ok)return this.sendFailed(h,o);this.store.setConversation(h.data.conversation),this.store.mergeMessages(h.data.messages||[]),this.reconcile(a,h.data.messages),this.pendingSends.delete(n),this.poller.poke(3e3);return}if(c){let h=await this.api.post(E,{page_url:location.href,...this.topic?{topic:this.topic}:{}});if(!h.ok)return this.sendFailed(h,o);this.store.setConversation(h.data.conversation),this.store.mergeMessages(h.data.messages||[]),d=h.data.conversation;}if(!d)return o();let g=[];for(let h of t){let m=await this.api.upload(`${E}/${d.id}/attachments`,h);if(!m.ok)return this.sendFailed(m,o);g.push(m.data);}let f=await this.api.post(`${E}/${d.id}/messages`,{body:e||void 0,attachments:g.length?g:void 0,reply_to_id:(i==null?void 0:i.id)||void 0,client_id:n});if(!f.ok)return this.sendFailed(f,o);let p=((l=f.data)==null?void 0:l.message)||f.data;this.reconcile(a,[p]),this.pendingSends.delete(n),this.poller.poke(3e3);}catch(d){this.log("send error",d),o();}}reconcile(e,t){let i=(t||[]).find(n=>n.client_id===e.client_id);i?this.store.mergeMessages([{...i,client_id:e.client_id}]):t&&t.length&&(this.store.removeMessage(e.id),this.store.mergeMessages(t));}sendFailed(e,t){var i;this.check(e),(e.code==="CHAT_UNAVAILABLE"||e.status===503)&&((i=this.ui)==null||i.setBanner(this.t.unavailable,true)),t();}async retry(e){let t=e.client_id?this.pendingSends.get(e.client_id):null;this.store.removeMessage(e.id),!(!t||!e.client_id)&&await this.send(t.text,t.files,this.store.find(t.replyTo)||null,e.client_id);}async typing(e){let t=this.store.conversation;if(!t||t.status!=="open"||!this.store.visitor)return;let i=Date.now();e&&i-this.lastTypingSent<4e3||(this.lastTypingSent=e?i:0,await this.api.post(`${E}/${t.id}/typing`,{is_typing:e},true));}async react(e,t){var c,g,f,p;let i=this.store.conversation;if(!i)return;let n={...e.reactions||{}},a=[...n[t]||[]],o=a.indexOf("visitor");o>=0?a.splice(o,1):a.push("visitor"),n[t]=a,this.store.upsertMessage({...e,reactions:n});let l=await this.api.post(`${E}/${i.id}/messages/${e.id}/reactions`,{emoji:t});if(!l.ok){this.check(l),this.store.upsertMessage({...e});return}let d=(p=(g=(c=l.data)==null?void 0:c.message)==null?void 0:g.reactions)!=null?p:(f=l.data)==null?void 0:f.reactions;d&&this.store.upsertMessage({...e,reactions:d});}async saveEdit(e,t){var o;let i=this.store.conversation;if(!i)return;this.store.upsertMessage({...e,body:t,edited_at:new Date().toISOString()});let n=await this.api.patch(`${E}/${i.id}/messages/${e.id}`,{body:t});if(!n.ok){this.check(n),this.store.upsertMessage({...e});return}let a=((o=n.data)==null?void 0:o.message)||n.data;a&&a.id&&this.store.upsertMessage(a);}async remove(e){let t=this.store.conversation;if(!t)return;this.store.upsertMessage({...e,deleted_at:new Date().toISOString()});let i=await this.api.delete(`${E}/${t.id}/messages/${e.id}`);i.ok||(this.check(i),this.store.upsertMessage({...e}));}check(e){e.ok||(e.code==="VISITOR_INVALID"||e.status===401&&this.store.visitor)&&(this.store.clearVisitor(),this.store.isOpen&&this.decideView());}};function Te(){var s;try{return ((s=navigator.languages)==null?void 0:s[0])||navigator.language||void 0}catch(e){return}}var tt={tr:{loading:"Y\xFCkleniyor\u2026",failed:"Ekran y\xFCklenemedi.",expired:"Bu ba\u011Flant\u0131n\u0131n s\xFCresi doldu.",retry:"Yeniden dene"},en:{loading:"Loading\u2026",failed:"The screen could not be loaded.",expired:"This link has expired.",retry:"Try again"}};function it(s){if(s==="light"||s==="dark")return s;if(typeof document!="undefined"){let e=document.documentElement;if(e.classList.contains("dark")||e.dataset.theme==="dark")return "dark";if(e.classList.contains("light")||e.dataset.theme==="light")return "light"}return typeof window!="undefined"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function st(s){if(typeof s=="string")return s||null;if(s&&typeof s=="object"){let e=s;if(typeof e.url=="string")return e.url;if(e.data&&typeof e.data.url=="string")return e.data.url}return null}function Le(s){var p,h;let e=tt[(p=s.language)!=null?p:"tr"],t=new Map,i=null,n=null,a=null,o=(h=s.theme)!=null?h:"auto",l=false,d=(m,x)=>{var k;(k=t.get(m))==null||k.forEach(w=>{try{w(x);}catch(M){console.warn("[signalbird]",M);}});},c=()=>{a&&(window.removeEventListener("message",a),a=null),n=null,i&&(i.textContent="");},g=(m,x)=>{var M;if(!i)return;i.textContent="";let k=document.createElement("div");k.setAttribute("data-signalbird-status",""),k.style.cssText=`display:flex;align-items:center;justify-content:center;gap:12px;min-height:${(M=s.minHeight)!=null?M:220}px;font:13px/1.5 system-ui,-apple-system,sans-serif;color:#6b7280;text-align:center;padding:24px;`;let w=document.createElement("span");if(w.textContent=m,k.appendChild(w),x){let u=document.createElement("button");u.type="button",u.textContent=e.retry,u.style.cssText="border:1px solid currentColor;border-radius:8px;background:transparent;color:inherit;padding:4px 10px;font:inherit;cursor:pointer;",u.addEventListener("click",()=>{f();}),k.appendChild(u);}i.appendChild(k);},f=async()=>{var M;if(!i||l)return;c(),g(e.loading,false);let m=it(o),x=null;try{s.url?(x=s.url,s={...s,url:void 0}):s.mint&&(x=st(await s.mint({module:s.module,theme:m,locale:s.locale})));}catch(u){d("error",u),g(u instanceof Error?u.message:e.failed,true);return}if(!x){d("error",new Error("EMBED_URL_MISSING")),g(e.expired,!!s.mint);return}let k=x;try{let u=new URL(x);u.searchParams.set("theme",m),s.locale&&u.searchParams.set("locale",s.locale),s.accent&&u.searchParams.set("accent",s.accent.replace(/^#/,"")),k=u.toString();}catch(u){}let w=document.createElement("iframe");w.src=k,w.title="Signalbird",w.style.cssText="width:100%;border:0;display:block;",w.style.height=`${typeof s.height=="number"?s.height:(M=s.minHeight)!=null?M:640}px`,w.setAttribute("allow","clipboard-write; fullscreen; autoplay"),w.setAttribute("sandbox","allow-same-origin allow-scripts allow-forms allow-popups allow-downloads"),w.setAttribute("referrerpolicy","strict-origin-when-cross-origin"),w.setAttribute("loading","lazy"),s.className&&(w.className=s.className),i.textContent="",i.appendChild(w),n=w,a=u=>{var L,z;if(!n||u.source!==n.contentWindow)return;let b=u.data;if(!(!b||typeof b.type!="string")){if(b.type==="signalbird:ready"){d("ready",b.module);return}if(b.type==="signalbird:height"&&typeof b.px=="number"&&(d("height",b.px),((L=s.height)!=null?L:"auto")==="auto")){let Me=Math.max(b.px,(z=s.minHeight)!=null?z:220);n.style.height=`${Me}px`;}}},window.addEventListener("message",a);};return {async mount(m){let x=typeof m=="string"?document.querySelector(m):m;if(!(x instanceof HTMLElement))throw new Error("Signalbird: g\xF6mme kab\u0131 bulunamad\u0131 \u2014 "+String(m));i=x,l=false,await f();},refresh:()=>f(),async setTheme(m){o=m,await f();},destroy(){l=true,c(),t.clear(),i=null;},on(m,x){t.has(m)||t.set(m,new Set),t.get(m).add(x);},off(m,x){var k;(k=t.get(m))==null||k.delete(x);}}}var jt="2.4.0",v=null,G=[],N=null;function C(s,e){try{return s()}catch(t){try{console.warn("[signalbird]",t);}catch(i){}return e}}function Ee(s){s.catch(()=>{});}function nt(s){C(()=>{if(!s||!s.publicKey){console.warn("[signalbird] init: publicKey zorunlu");return}if(!(typeof document=="undefined"||typeof window=="undefined")){v&&v.destroy(),v=new q(s);for(let{event:e,fn:t}of G)v.on(e,t);if(N){let e=N;N=null,Ee(v.identify(e));}}},void 0);}function Nt(s){C(()=>{if(s){if(!v){N={...N||{},...s};return}Ee(v.identify(s));}},void 0);}var Ht={open(){C(()=>v==null?void 0:v.open(),void 0);},close(){C(()=>v==null?void 0:v.close(),void 0);},toggle(){C(()=>v==null?void 0:v.toggle(),void 0);},isOpen(){return C(()=>!!(v!=null&&v.isOpen()),false)},on(s,e){C(()=>{typeof e=="function"&&(G.push({event:s,fn:e}),v==null||v.on(s,e));},void 0);},off(s,e){C(()=>{let t=G.findIndex(i=>i.event===s&&i.fn===e);t>=0&&G.splice(t,1),v==null||v.off(s,e);},void 0);}},It={register(s){return C(()=>v?v.pushRegister(s).catch(e=>({ok:!1,status:0,code:"NETWORK_ERROR",message:String(e)})):Promise.resolve({ok:!1,status:0,code:"NOT_INITIALIZED",message:"Signalbird.init \xE7a\u011Fr\u0131lmad\u0131"}),Promise.resolve({ok:false,status:0,code:"WIDGET_ERROR",message:"widget error"}))}},Bt=Le;function Ot(){C(()=>{v==null||v.destroy(),v=null;},void 0);}C(()=>{if(typeof document=="undefined")return;let s=document.currentScript||document.querySelector('script[data-key][src*="signalbird"]'),e=s==null?void 0:s.dataset;if(!e||!e.key)return;let t=()=>nt({publicKey:e.key,chatKey:e.channel||void 0,baseUrl:e.baseUrl||void 0,locale:e.locale||void 0,debug:e.debug==="true"||e.debug==="1"});document.body?t():document.addEventListener("DOMContentLoaded",t,{once:!0});},void 0);
499
+ `;function r(s,e,...t){let i=document.createElement(s);if(e)for(let n in e){let a=e[n];a==null||a===false||(n==="class"?i.className=String(a):n==="style"?i.setAttribute("style",String(a)):n.startsWith("on")&&typeof a=="function"?i.addEventListener(n.slice(2).toLowerCase(),a):n==="html"?i.innerHTML=String(a):n in i&&n!=="list"&&n!=="form"?i[n]=a:i.setAttribute(n,String(a)));}return ze(i,t),i}function ze(s,e){for(let t of e)t==null||t===false||s.appendChild(typeof t=="object"?t:document.createTextNode(String(t)));}function T(s){for(;s.firstChild;)s.removeChild(s.firstChild);}function y(s,e=18){let t=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width",String(e)),t.setAttribute("height",String(e)),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","2"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.innerHTML=Ae[s],t}function X(s=26){let e=document.createElementNS("http://www.w3.org/2000/svg","svg");return e.setAttribute("viewBox","10 2 28 38"),e.setAttribute("width",String(s)),e.setAttribute("height",String(s)),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","2"),e.setAttribute("stroke-linejoin","round"),e.setAttribute("aria-hidden","true"),e.innerHTML='<path d="M16 16 L30 16 L33 18 L24 33 L15 18 Z" fill="currentColor" fill-opacity=".18" stroke="none"/><path d="M23 4 L31 9 L23 14 L16 9 Z" fill="currentColor" fill-opacity=".28" stroke="none"/><path d="M30 16 L33 18 L36 27 L34 34 L41 32 L44 38 L31 37 L24 37 L17 35 L13 27 L15 18 L16 16"/><path d="M16 16 L16 9 L23 4 L31 9 L30 16"/><path d="M21.4 12.4 L23.2 18.6 L25 12.4 Z" fill="currentColor" fill-opacity=".35"/><circle cx="28.4" cy="11.4" r="1.6" fill="currentColor" stroke="none"/>',e}var Ae={chat:'<path d="M21 11.5a8.4 8.4 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.4 8.4 0 0 1-3.8-.9L3 21l1.9-5.7a8.4 8.4 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.4 8.4 0 0 1 3.8-.9h.5a8.5 8.5 0 0 1 8 8v.5z"/>',close:'<path d="M18 6 6 18M6 6l12 12"/>',send:'<path d="m22 2-7 20-4-9-9-4 20-7z"/><path d="M22 2 11 13"/>',clip:'<path d="m21.4 11.05-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"/>',file:'<path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><path d="M14 2v6h6"/>',check:'<path d="M20 6 9 17l-5-5"/>',link:'<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><path d="M15 3h6v6"/><path d="M10 14 21 3"/>',checks:'<path d="M18 6 7 17l-4-4"/><path d="m22 10-7.5 7.5L13 16"/>',reply:'<path d="M9 17H5a2 2 0 0 1-2-2V9"/><path d="m3 9 4-4"/><path d="m3 9 4 4"/><path d="M9 17h6a6 6 0 0 0 0-12h-2"/>',more:'<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>',star:'<path d="m12 2 3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/>',chevron:'<path d="m6 9 6 6 6-6"/>',smile:'<circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><path d="M9 9h.01M15 9h.01"/>',done:'<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><path d="m22 4-10 10-3-3"/>',down:'<path d="M12 5v14"/><path d="m19 12-7 7-7-7"/>',image:'<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="1.5"/><path d="m21 15-4.5-4.5L9 18"/>',heart:'<path d="M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1-1.1a5.5 5.5 0 0 0-7.8 7.8l1.1 1L12 21l7.7-7.6 1.1-1a5.5 5.5 0 0 0 0-7.8z"/>'};function $(s){return (s||"?").trim().split(/\s+/).slice(0,2).map(e=>e[0]||"").join("").toUpperCase()}function S(s,e){let t=P(s);return t?r("img",{src:t,alt:"",loading:"lazy"}):document.createTextNode($(e))}function P(s){return typeof s=="string"&&/^(https:\/\/|data:image\/)/i.test(s)?s:null}function oe(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(0)} KB`:`${(s/1024/1024).toFixed(1)} MB`}function le(){return typeof crypto!="undefined"&&"randomUUID"in crypto?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{let e=Math.random()*16|0;return (s==="x"?e:e&3|8).toString(16)})}var de=["\u{1F44D}","\u2764\uFE0F","\u{1F602}","\u{1F62E}","\u{1F622}","\u{1F64F}"],be=["\u{1F600}","\u{1F604}","\u{1F60A}","\u{1F642}","\u{1F609}","\u{1F60D}","\u{1F929}","\u{1F60E}","\u{1F914}","\u{1F610}","\u{1F615}","\u{1F641}","\u{1F622}","\u{1F62D}","\u{1F621}","\u{1F92F}","\u{1F44D}","\u{1F44E}","\u{1F44F}","\u{1F64F}","\u{1F4AA}","\u{1F525}","\u2705","\u2764\uFE0F"],Re=900*1e3,Pe=300*1e3;function fe(s,e){let t=V(s),i=s.childNodes.length===0,n=je(s);if(T(s),e.messages.length===0){s.appendChild(Ne(e));return}let a="";for(let o=0;o<e.messages.length;o++){let l=e.messages[o],d=Z(l.created_at),c=d===a&&e.messages[o-1]||null,g=e.messages[o+1]||null;d!==a&&(s.appendChild(r("div",{class:"day"},Ve(l.created_at,e))),a=d),s.appendChild(He(l,e,c,Ie(l,g)?g:null,!i&&!n.has(l.id)));}(t||i)&&R(s);}function V(s,e=60){return s.scrollHeight-s.scrollTop-s.clientHeight<e}function R(s,e=false){if(e&&typeof s.scrollTo=="function"){s.scrollTo({top:s.scrollHeight,behavior:"smooth"});return}s.scrollTop=s.scrollHeight;}function je(s){let e=new Set;return s.querySelectorAll("[data-id]").forEach(t=>{let i=t.dataset.id;i&&e.add(i);}),e}function Ne(s){let e=r("div",{class:"hero"});e.appendChild(r("div",{class:"hv"},r("span",null,S(s.agentAvatar,s.brandName||s.agentName)))),e.appendChild(r("h4",null,s.greeting||s.t.greeting)),s.responseHint&&e.appendChild(r("p",null,s.responseHint));let t=s.quick||[];if(t.length&&s.onQuick){let i=r("div",{class:"qk"});for(let n of t.slice(0,6))i.appendChild(r("button",{type:"button",onclick:()=>s.onQuick(n)},n));e.appendChild(i);}return e}function He(s,e,t,i,n){var k,w,M;let a=s.sender_type==="visitor"?"v":s.sender_type==="system"?"s":"a",o=!ce(t,s),l=!ce(s,i),d=r("div",{class:`row ${a}`+(o&&t?" gap":"")+(l?"":" mid")+(s._pending?" pend":"")+(s._failed?" fail":"")+(n?" new":""),"data-id":s.id});if(a==="s")return d.appendChild(r("div",{class:"bb"},s.body||"")),d;a==="a"&&d.appendChild(r("div",{class:`av${l?"":" gh"}`},S(e.agentAvatar,pe(s)||e.agentName)));let c=r("div",{class:"cl"}),g=r("div",{class:`bb${s.deleted_at?" del":""}`});if(s.deleted_at)return g.textContent=e.t.deleted,c.appendChild(g),d.appendChild(c),d;if(s.reply_to_id){let u=e.find(s.reply_to_id),b=u?u.sender_type==="visitor"?e.t.you:pe(u)||e.agentName:"";g.appendChild(r("span",{class:"q"},b?`${b}: `:"",u?D(u,e.t):"\u2026"));}if(s._files&&s._files.length){let u=r("div",{class:"imgs"});for(let b of s._files)b.type.startsWith("image/")?u.appendChild(r("img",{src:URL.createObjectURL(b),alt:b.name})):g.appendChild(he({name:b.name,url:"",mime:b.type,size:b.size},e));u.childNodes.length&&g.appendChild(u);}let f=s.attachments||[],p=f.filter(u=>ue(u.mime));if(p.length){let u=r("div",{class:"imgs"});for(let b of p)u.appendChild(r("img",{src:b.url,alt:b.name,loading:"lazy",onclick:()=>e.actions.openImage(b.url)}));g.appendChild(u);}for(let u of f.filter(b=>!ue(b.mime)))g.appendChild(he(u,e));let h=(a==="v"?null:(k=s.translation)==null?void 0:k.body)||s.body;h&&g.appendChild($e(h)),s._failed&&(g.appendChild(r("div",{style:"font-size:11px;margin-top:5px;font-weight:600"},e.t.failed)),g.addEventListener("click",()=>e.actions.retry(s))),c.appendChild(g);let m=a==="a"&&((M=(w=s.meta)==null?void 0:w.options)!=null&&M.length)?s.meta.options.slice(0,6):null;if(m){let u=!i||i.sender_type==="system",b=r("div",{class:`opts${u?"":" past"}`});for(let L of m)!L||!L.label||(L.url?b.appendChild(r("a",{href:L.url,target:"_top",rel:"noopener"},L.label,y("link",12))):b.appendChild(r("button",{type:"button",disabled:u?null:"disabled",onclick:()=>{var z;return (z=e.onQuick)==null?void 0:z.call(e,L.value||L.label)}},L.label)));b.childNodes.length&&c.appendChild(b);}let x=s.reactions&&Object.keys(s.reactions).length?s.reactions:null;if(x){let u=r("div",{class:"rx"});for(let b in x){let L=x[b]||[];if(!L.length)continue;let z=L.includes("visitor");u.appendChild(r("button",{class:z?"me":"",type:"button",onclick:()=>e.actions.react(s,b)},`${b} ${L.length}`));}u.childNodes.length&&c.appendChild(u);}if(l){let u=r("div",{class:"mt"},De(s.created_at,e.locale));if(s.edited_at&&u.appendChild(r("span",{class:"ed"},`\xB7 ${e.t.edited}`)),a==="v"&&!s._failed){let b=r("span",{class:`tk${s.read_at?" rd":""}`});b.appendChild(s._pending?y("check",12):s.read_at||s.delivered_at?y("checks",13):y("check",12)),s._pending&&(b.style.opacity=".4"),u.appendChild(b);}c.appendChild(u);}return d.appendChild(c),!s._pending&&!s._failed&&(d.appendChild(Be(s,e,d)),Oe(d)),d}function pe(s){var e,t;return ((e=s.agent)==null?void 0:e.name)||s.sender_name||((t=s.meta)==null?void 0:t.agent_name)||null}function ce(s,e){if(!s||!e||s.sender_type!==e.sender_type||s.sender_type==="system"||s.sender_id!==e.sender_id)return false;let t=Date.parse(e.created_at)-Date.parse(s.created_at);return t>=0&&t<Pe}function Ie(s,e){return !!e&&Z(s.created_at)===Z(e.created_at)}function Be(s,e,t){let i=r("div",{class:"ac"});for(let o of de.slice(0,3))i.appendChild(r("button",{type:"button",title:e.t.react,onclick:()=>e.actions.react(s,o)},o));i.appendChild(r("button",{type:"button",title:e.t.reply,onclick:()=>e.actions.reply(s)},y("reply",15)));let n=r("div",{class:"menu"});for(let o of de.slice(3))n.appendChild(r("button",{type:"button",onclick:()=>{n.classList.remove("show"),e.actions.react(s,o);}},`${o} ${e.t.react}`));return s.sender_type==="visitor"&&Date.now()-Date.parse(s.created_at)<Re&&(n.appendChild(r("button",{type:"button",onclick:()=>{n.classList.remove("show"),e.actions.edit(s);}},e.t.edit)),n.appendChild(r("button",{type:"button",class:"dg",onclick:()=>{n.classList.remove("show"),e.actions.remove(s);}},e.t.delete))),i.appendChild(r("button",{type:"button",title:e.t.react,onclick:o=>{o.stopPropagation(),n.classList.toggle("show"),n.style.top=`${t.offsetHeight+4}px`;}},y("more",15))),t.appendChild(n),document.addEventListener("click",()=>n.classList.remove("show"),{once:true,capture:true}),i}function Oe(s){let e=null,t=()=>{e=setTimeout(()=>{var a;s.classList.add("acts");try{(a=navigator.vibrate)==null||a.call(navigator,8);}catch(o){}let n=o=>{s.contains(o.target)||(s.classList.remove("acts"),document.removeEventListener("touchstart",n,true));};document.addEventListener("touchstart",n,true);},420);},i=()=>e&&clearTimeout(e);s.addEventListener("touchstart",t,{passive:true}),s.addEventListener("touchend",i),s.addEventListener("touchmove",i,{passive:true});}function he(s,e){return r("a",{class:"fr",href:s.url||void 0,target:"_blank",rel:"noopener"},y("file",18),r("span",{class:"fn"},s.name||e.t.attachment),r("span",{class:"fs"},oe(s.size||0)))}function $e(s){let e=document.createDocumentFragment(),t=/(https?:\/\/[^\s<]+)/g,i=0,n;for(;n=t.exec(s);){n.index>i&&e.appendChild(document.createTextNode(s.slice(i,n.index)));let a=n[1].replace(/[.,;:!?)]+$/,"");e.appendChild(r("a",{href:a,target:"_blank",rel:"noopener noreferrer nofollow"},a)),i=n.index+a.length;}return i<s.length&&e.appendChild(document.createTextNode(s.slice(i))),e}function D(s,e){var n,a;if(s.deleted_at)return e.deleted;let t=(s.sender_type==="visitor"?null:(n=s.translation)==null?void 0:n.body)||s.body;if(t)return t.length>90?t.slice(0,90)+"\u2026":t;let i=(a=s.attachments)==null?void 0:a[0];return i?`\u{1F4CE} ${i.name}`:"\u2026"}function ue(s){return !!s&&s.startsWith("image/")}function Z(s){let e=new Date(s);return `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function Ve(s,e){let t=new Date(s),i=new Date,n=Math.round((ge(i)-ge(t))/864e5);if(n===0)return e.t.today;if(n===1)return e.t.yesterday;try{return new Intl.DateTimeFormat(e.locale,{day:"numeric",month:"long",year:t.getFullYear()!==i.getFullYear()?"numeric":void 0}).format(t)}catch(a){return t.toLocaleDateString()}}function ge(s){return new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime()}function De(s,e){let t=new Date(s);try{return new Intl.DateTimeFormat(e,{hour:"2-digit",minute:"2-digit"}).format(t)}catch(i){return t.toLocaleTimeString()}}var Ke={launcher:"Sohbet",title:"Sohbet",online:"\xC7evrimi\xE7i",offline:"Genelde birka\xE7 dakika i\xE7inde yan\u0131tl\u0131yoruz",greeting:"Merhaba! Size nas\u0131l yard\u0131mc\u0131 olabiliriz?",offlineMessage:"\u015Eu an \xE7evrimd\u0131\u015F\u0131y\u0131z. Mesaj\u0131n\u0131z\u0131 b\u0131rak\u0131n, en k\u0131sa s\xFCrede d\xF6nelim.",prechatTitle:"Ba\u015Flamadan \xF6nce",prechatHint:"Size geri d\xF6nebilmemiz i\xE7in bilgilerinizi b\u0131rak\u0131n.",topicLabel:"Konu",topicPlaceholder:"Konu se\xE7in (iste\u011Fe ba\u011Fl\u0131)",name:"Ad\u0131n\u0131z",email:"E-posta",start:"Sohbete ba\u015Fla",skip:"Atla",placeholder:"Mesaj\u0131n\u0131z\u0131 yaz\u0131n\u2026",send:"G\xF6nder",attach:"Dosya ekle",typing:"yaz\u0131yor\u2026",today:"Bug\xFCn",yesterday:"D\xFCn",reply:"Yan\u0131tla",react:"Tepki ver",edit:"D\xFCzenle",delete:"Sil",deleted:"Bu mesaj silindi",edited:"d\xFCzenlendi",save:"Kaydet",cancel:"Vazge\xE7",you:"Siz",agent:"Destek",system:"Sistem",endChat:"Sohbeti bitir",newChat:"Yeni sohbet",resolved:"Bu sohbet \xE7\xF6z\xFCld\xFC olarak i\u015Faretlendi.",closed:"Bu sohbet kapat\u0131ld\u0131.",rateTitle:"Bu sohbeti nas\u0131l buldunuz?",rateComment:"Eklemek istedi\u011Finiz bir \u015Fey var m\u0131? (iste\u011Fe ba\u011Fl\u0131)",rateSend:"G\xF6nder",rateThanks:"Geri bildiriminiz bize ula\u015Ft\u0131.",rateThanksTitle:"Te\u015Fekk\xFCrler!",rateScale:["Hi\xE7 iyi de\u011Fildi","Bekledi\u011Fim gibi olmad\u0131","\u0130dare eder","\u0130yiydi","Harikayd\u0131"],reviewIntro:"Yard\u0131mc\u0131 olabildiysek bizi yorumlar m\u0131s\u0131n\u0131z?",reviewCta:"De\u011Ferlendir",failed:"G\xF6nderilemedi \u2014 tekrar dene",fileTooLarge:"Dosya \xE7ok b\xFCy\xFCk (en fazla {mb} MB)",fileNotAllowed:"Bu dosya t\xFCr\xFCn\xFC y\xFCkleyemezsiniz",tooLong:"Mesaj en fazla {max} karakter olabilir",unavailable:"Sohbet \u015Fu an kullan\u0131lam\u0131yor. L\xFCtfen daha sonra tekrar deneyin.",close:"Kapat",dismiss:"Sohbet balonunu gizle",minimize:"K\xFC\xE7\xFClt",unreadTitle:"({n}) Yeni mesaj",dropHere:"Dosyay\u0131 buraya b\u0131rak\u0131n",replyingTo:"Yan\u0131tlan\u0131yor",attachment:"Ek",poweredBy:"Signalbird ile",resize:"Boyutland\u0131r",emoji:"Emoji ekle",jump:"En alta in",newMessage:"Yeni mesaj",replyFast:"\u015Eu an buraday\u0131z \u2014 genelde birka\xE7 dakika i\xE7inde yan\u0131tl\u0131yoruz."},Fe={launcher:"Chat",title:"Chat",online:"Online",offline:"We usually reply within a few minutes",greeting:"Hi there! How can we help you?",offlineMessage:"We're offline right now. Leave a message and we'll get back to you.",prechatTitle:"Before we start",prechatHint:"Leave your details so we can get back to you.",topicLabel:"Topic",topicPlaceholder:"Pick a topic (optional)",name:"Your name",email:"Email",start:"Start chat",skip:"Skip",placeholder:"Type your message\u2026",send:"Send",attach:"Attach file",typing:"is typing\u2026",today:"Today",yesterday:"Yesterday",reply:"Reply",react:"React",edit:"Edit",delete:"Delete",deleted:"This message was deleted",edited:"edited",save:"Save",cancel:"Cancel",you:"You",agent:"Support",system:"System",endChat:"End chat",newChat:"New chat",resolved:"This conversation was marked as resolved.",closed:"This conversation was closed.",rateTitle:"How was this conversation?",rateComment:"Anything to add? (optional)",rateSend:"Send",rateThanks:"Your feedback reached us.",rateThanksTitle:"Thank you!",rateScale:["Not good at all","Not what I expected","It was okay","Good","Excellent"],reviewIntro:"If we were helpful, would you leave us a review?",reviewCta:"Leave a review",failed:"Not sent \u2014 tap to retry",fileTooLarge:"File is too large (max {mb} MB)",fileNotAllowed:"That file type cannot be uploaded",tooLong:"A message may be at most {max} characters",unavailable:"Chat is unavailable right now. Please try again later.",close:"Close",dismiss:"Hide the chat bubble",minimize:"Minimize",unreadTitle:"({n}) New message",dropHere:"Drop the file here",replyingTo:"Replying to",attachment:"Attachment",poweredBy:"Powered by Signalbird",resize:"Resize",emoji:"Add emoji",jump:"Jump to latest",newMessage:"New message",replyFast:"We're here right now \u2014 we usually reply within a few minutes."};function Q(s,e){let t=n=>n&&n!=="auto"?n.toLowerCase().slice(0,2):null;return (t(e)||t(s)||t(typeof navigator!="undefined"?navigator.language:null)||"en")==="tr"?"tr":"en"}function ee(s){return s==="tr"?Ke:Fe}function j(s,e){return s.replace(/\{(\w+)\}/g,(t,i)=>{var n;return String((n=e[i])!=null?n:"")})}var Ue=["image/jpeg","image/png","image/gif","image/webp"],Ye=420,qe=60,Ge=11e3,We=9e3,me="sb_teaser",ve="sb_seen",U=class{constructor(e){this.o=e;this.list=null;this.typingEl=null;this.typingAvatar=null;this.jumpBtn=null;this.textarea=null;this.sendBtn=null;this.emojiBox=null;this.chips=null;this.replyBar=null;this.notice=null;this.files=[];this.counter=null;this.replyTo=null;this.editing=null;this.view="none";this.agent=null;this.online=false;this.typingTimer=null;this.teaserTimer=null;this.toastTimer=null;this.attnTimer=null;this.wasTyping=false;this.scrollLock=0;this.locked=false;var l;let t=e.t;this.host=r("div",{id:"signalbird-widget"}),this.root=this.host.attachShadow({mode:"open"}),this.root.appendChild(r("style",null,re));let i=e.settings.position==="left"?"left":"right",n=e.settings.layout==="sidebar"?" sidebar":"";if(this.wrap=r("div",{class:`sb ${i}${n}${Ze(e.settings.theme)?" dark":""}`,style:`--sb-c:${Qe(e.settings.color)}`}),e.settings.theme==="auto"&&typeof matchMedia=="function"){let d=matchMedia("(prefers-color-scheme: dark)");(l=d.addEventListener)==null||l.call(d,"change",c=>this.wrap.classList.toggle("dark",c.matches));}this.badge=r("span",{class:"badge"});let a=e.settings.launcher_text;this.launcher=r("button",{class:`ln${a?"":" icon-only"}`,type:"button","aria-label":a||t.launcher,onclick:()=>this.onLauncher()},r("span",{class:"lm"},this.launcherMark()),a?r("span",{class:"lt"},a):null,r("span",{class:"ln-on"}),r("span",{class:"ln-pulse"}),this.badge),this.dismissBtn=r("button",{class:"dm",type:"button",title:t.dismiss,"aria-label":t.dismiss,onclick:d=>{d.stopPropagation(),e.actions.dismiss();}},y("close",13)),this.teaser=this.buildTeaser(),this.toast=this.buildToast(),this.headerPhoto=r("div",{class:"ph"},this.brandAvatar()),this.headerDot=r("span",{class:"dot"}),this.headerName=r("div",{class:"hn"},e.appName||t.title),this.headerStatus=r("div",{class:"hs"},t.offline),this.endBtn=r("button",{class:"hb hide",type:"button",title:t.endChat,"aria-label":t.endChat,onclick:()=>e.actions.endChat()},y("done",19));let o=r("div",{class:"hd"},r("div",{class:"av"},this.headerPhoto,this.headerDot),r("div",{class:"hi"},this.headerName,this.headerStatus),r("div",{class:"ha"},this.endBtn,r("button",{class:"hb",type:"button",title:t.close,"aria-label":t.close,onclick:()=>e.actions.close()},y("close",20))));this.dragBar=r("div",{class:"drag","aria-hidden":"true"},r("i")),this.banner=r("div",{class:"bn"}),this.body=r("div",{class:"bd"}),this.grip=r("div",{class:"gp",title:t.resize,"aria-hidden":"true"}),this.panel=r("div",{class:"pn",role:"dialog","aria-modal":"false","aria-label":t.title},r("div",{class:"glow","aria-hidden":"true"}),this.dragBar,o,this.banner,this.body,this.grip),e.settings.layout!=="sidebar"&&(this.restoreGeometry(),this.enableMove(o),this.enableResize()),this.enableSwipeClose(),this.wrap.appendChild(this.launcher),this.wrap.appendChild(this.dismissBtn),this.wrap.appendChild(this.teaser),this.wrap.appendChild(this.toast),this.wrap.appendChild(this.panel),this.root.appendChild(this.wrap),this.enableDrop(),this.onKey=this.onKey.bind(this),this.onViewport=this.onViewport.bind(this);}key(e){return `${e}_${this.o.publicKey}`}mount(){this.host.isConnected||document.body.appendChild(this.host),document.addEventListener("keydown",this.onKey),this.scheduleTeaser();}unmount(){var e;this.clearTimers(),this.unlockScroll(),document.removeEventListener("keydown",this.onKey),(e=F())==null||e.removeEventListener("resize",this.onViewport),this.host.remove();}setDismissed(e){this.wrap.classList.toggle("hidden",e),e&&this.hideTeaser(false);}setLauncherHidden(e){this.wrap.classList.toggle("no-ln",e),e&&this.hideTeaser(false);}setOpen(e){var t;this.wrap.classList.toggle("open",e),e?(xe(this.key(ve)),this.hideTeaser(false),this.hideToast(),this.lockScroll(),this.bindViewport(),requestAnimationFrame(()=>{var i;this.list&&R(this.list),_()||(i=this.textarea)==null||i.focus();})):(this.unlockScroll(),(t=F())==null||t.removeEventListener("resize",this.onViewport),this.wrap.style.setProperty("--sb-kb","0px"),this.wrap.classList.remove("kb"),this.hideEmoji());}setUnread(e){this.badge.textContent=e>99?"99+":String(e),this.badge.classList.toggle("on",e>0),this.wrap.classList.toggle("pulse",e>0),e===0&&this.hideToast();}attention(e){let t=this.launcher;t.classList.remove("attn"),t.offsetWidth,t.classList.add("attn"),this.attnTimer&&clearTimeout(this.attnTimer),this.attnTimer=setTimeout(()=>t.classList.remove("attn"),2400),e&&(e.body||e.name)&&this.showToast(e);}setHeader(e,t){var a;let i=this.o.t;this.agent=e,this.online=(a=e==null?void 0:e.online)!=null?a:t;let n=(e==null?void 0:e.name)||this.o.appName||i.title;this.headerName.textContent=n,T(this.headerPhoto),this.headerPhoto.appendChild(e?S(e.avatar,n):this.brandAvatar()),this.headerDot.classList.toggle("on",this.online),this.headerStatus.textContent=this.online?i.online:i.offline,this.wrap.classList.toggle("agent-on",this.online),this.typingAvatar&&(T(this.typingAvatar),this.typingAvatar.appendChild(S(e==null?void 0:e.avatar,n)));}setBanner(e,t=false){T(this.banner),this.banner.className=`bn${t?" err":""}${e?" on":""}`,e&&(this.banner.appendChild(y(t?"close":"chat",15)),this.banner.appendChild(r("span",null,e)));}setEndVisible(e){this.endBtn.classList.toggle("hide",!e);}get currentView(){return this.view}showPrechat(e){let t=this.o.t,i=this.o.settings.prechat||{name:true,email:true,required:false};this.view="prechat",this.list=null,this.textarea=null,T(this.body);let n=ye("text",t.name,e.name||"","name"),a=ye("email",t.email,e.email||"","email"),o=this.o.topics||[],l=o.length?r("select",{"aria-label":t.topicLabel},r("option",{value:""},t.topicPlaceholder),...o.map(f=>r("option",{value:f.slug},f.name))):null,d=l?r("div",{class:"fld"},l,r("label",null,t.topicLabel),r("span",{class:"cv"},y("chevron",16))):null,c=()=>{let f=n.input.value.trim(),p=a.input.value.trim();if(i.required&&(i.name&&!f||i.email&&!p)){let h=i.name&&!f?n:a;h.wrap.classList.add("bad"),h.input.focus();return}if(p&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(p)){a.wrap.classList.add("bad"),a.input.focus();return}this.o.actions.submitPrechat(f,p,(l==null?void 0:l.value)||null);},g=r("form",{class:"fm",onsubmit:f=>{f.preventDefault(),c();}},r("h3",null,t.prechatTitle),r("p",null,this.o.settings.greeting||t.prechatHint),i.name?n.wrap:null,i.email?a.wrap:null,d,r("button",{class:"btn",type:"submit"},t.start),i.required?null:r("button",{class:"btn gh",type:"button",onclick:()=>this.o.actions.skipPrechat((l==null?void 0:l.value)||null)},t.skip));this.body.appendChild(g),_()||setTimeout(()=>(i.name?n.input:a.input).focus(),60);}showChat(){var t,i;if(this.view==="chat"&&this.list)return;let e=this.o.t;this.view="chat",T(this.body),this.list=r("div",{class:"ml"}),this.list.addEventListener("scroll",()=>this.syncJump(),{passive:true}),this.jumpBtn=r("button",{class:"jump",type:"button","aria-label":e.jump,onclick:()=>this.list&&R(this.list,true)},y("down",14),r("span",null,e.jump)),this.typingAvatar=r("div",{class:"av"},S((t=this.agent)==null?void 0:t.avatar,((i=this.agent)==null?void 0:i.name)||this.o.appName)),this.typingEl=r("div",{class:"tp","aria-live":"polite"},this.typingAvatar,r("div",{class:"dots"},r("i"),r("i"),r("i"))),this.notice=r("div",{class:"notice"}),this.body.appendChild(this.list),this.body.appendChild(this.jumpBtn),this.body.appendChild(this.typingEl),this.body.appendChild(this.notice),this.body.appendChild(this.buildComposer()),this.body.appendChild(r("div",{class:"drop"},y("image",26),r("span",null,e.dropHere)));}showRating(){let e=this.o.t;this.view="rating",this.list=null,this.textarea=null,T(this.body);let t=0,i=[],n=r("div",{class:"rl"}),a=()=>{i.forEach((c,g)=>c.classList.toggle("on",g<t)),n.textContent=t?e.rateScale[t-1]:"";},o=r("div",{class:"stars"});for(let c=1;c<=5;c++){let g=r("button",{type:"button","aria-label":String(c),onclick:()=>{t=c,a();}},y("star",32));i.push(g),o.appendChild(g);}let l=r("textarea",{placeholder:e.rateComment,rows:3}),d=r("form",{class:"fm",onsubmit:c=>{c.preventDefault(),this.o.actions.rate(t,l.value.trim());}},r("h3",{style:"text-align:center"},e.rateTitle),o,n,l,r("button",{class:"btn",type:"submit"},e.rateSend),r("button",{class:"btn gh",type:"button",onclick:()=>this.o.actions.rate(0,"")},e.skip));this.body.appendChild(d);}showThanks(e){let t=this.o.t;this.view="none",this.list=null,this.textarea=null,T(this.body);let i=r("div",{class:"ok"},r("div",{class:"ic"},y("done",30)),r("h3",null,t.rateThanksTitle),r("p",null,t.rateThanks));e!=null&&e.url&&(i.appendChild(r("p",{style:"margin-top:16px"},t.reviewIntro)),i.appendChild(r("a",{class:"btn",href:e.url,target:"_blank",rel:"noopener noreferrer"},e.label||t.reviewCta))),i.appendChild(r("button",{class:"btn gh",type:"button",onclick:()=>this.o.actions.newChat()},t.newChat)),this.body.appendChild(i);}render(e){var t,i;this.list&&(fe(this.list,{...e,t:this.o.t,locale:this.o.locale,actions:this.o.actions,agentAvatar:((t=this.agent)==null?void 0:t.avatar)||P(this.o.settings.logo_url),brandName:((i=this.agent)==null?void 0:i.name)||this.o.appName,responseHint:this.online?this.o.t.replyFast:this.o.settings.offline_message||this.o.t.offlineMessage,quick:this.quickStarters(),onQuick:n=>this.o.actions.send(n,[],null)}),this.syncJump());}setTyping(e,t){this.typingEl&&(this.typingEl.classList.toggle("on",e),this.typingEl.setAttribute("aria-label",`${t} ${this.o.t.typing}`),e&&this.list&&V(this.list,120)&&R(this.list,true));}setNotice(e,t){this.notice&&(T(this.notice),this.notice.classList.toggle("on",!!e),e&&(this.notice.appendChild(document.createTextNode(e)),t&&this.notice.appendChild(r("button",{type:"button",onclick:t.fn},t.label))));}setReply(e){var i,n;if(this.replyTo=e,!this.replyBar||(T(this.replyBar),this.replyBar.classList.toggle("on",!!e),!e))return;let t=e.sender_type==="visitor"?this.o.t.you:((i=e.agent)==null?void 0:i.name)||e.sender_name||this.o.t.agent;this.replyBar.appendChild(y("reply",14)),this.replyBar.appendChild(r("span",{class:"rt"},`${this.o.t.replyingTo} ${t}: ${D(e,this.o.t)}`)),this.replyBar.appendChild(r("button",{type:"button","aria-label":this.o.t.cancel,onclick:()=>this.setReply(null)},y("close",14))),(n=this.textarea)==null||n.focus();}startEdit(e){!this.textarea||!this.replyBar||(this.editing=e,this.setReply(null),this.textarea.value=e.body||"",this.autosize(),this.syncSend(),this.textarea.focus(),T(this.replyBar),this.replyBar.classList.add("on"),this.replyBar.appendChild(r("span",{class:"rt"},`${this.o.t.edit}: ${D(e,this.o.t)}`)),this.replyBar.appendChild(r("button",{type:"button","aria-label":this.o.t.cancel,onclick:()=>this.cancelEdit()},y("close",14))));}buildComposer(){let e=this.o.t;this.replyBar=r("div",{class:"rq"}),this.chips=r("div",{class:"chips"}),this.textarea=r("textarea",{rows:1,placeholder:e.placeholder,"aria-label":e.placeholder,maxLength:this.maxChars,onkeydown:n=>{n.key==="Enter"&&!n.shiftKey&&!n.isComposing?(n.preventDefault(),this.submit()):n.key==="Escape"&&(this.editing?this.cancelEdit():this.replyTo?this.setReply(null):this.hideEmoji());},oninput:()=>{this.autosize(),this.syncSend(),this.notifyTyping();},onpaste:n=>{var o;let a=Array.from(((o=n.clipboardData)==null?void 0:o.files)||[]);a.length&&(n.preventDefault(),this.addFiles(a));}});let t=r("input",{type:"file",multiple:true,style:"display:none",accept:this.allowedMimes.join(","),onchange:()=>{this.addFiles(Array.from(t.files||[])),t.value="";}});return this.emojiBox=r("div",{class:"emj"},...be.map(n=>r("button",{type:"button",onclick:()=>this.insertEmoji(n)},n))),this.sendBtn=r("button",{class:"cb sd",type:"button",title:e.send,"aria-label":e.send,disabled:true,onclick:()=>this.submit()},y("send",17)),this.counter=r("div",{class:"cnt"}),r("div",{class:"cp"},this.emojiBox,this.replyBar,this.chips,this.counter,r("div",{class:"cr"},r("button",{class:"cb",type:"button",title:e.attach,"aria-label":e.attach,onclick:()=>t.click()},y("clip",19)),this.textarea,r("button",{class:"cb",type:"button",title:e.emoji,"aria-label":e.emoji,onclick:n=>{n.stopPropagation(),this.toggleEmoji();}},y("smile",19)),this.sendBtn),t,r("div",{class:"pw"},r("a",{href:"https://signalbird.io",target:"_blank",rel:"noopener",title:e.poweredBy},r("span",{class:"pk"},X(13)),r("span",{class:"pn2"},"Signalbird"))))}submit(){if(!this.textarea)return;let e=this.textarea.value.trim();if(this.editing){let n=this.editing;this.cancelEdit(),e&&e!==n.body&&this.o.actions.saveEdit(n,e);return}if(!e&&this.files.length===0)return;if(this.textarea.value.length>this.maxChars){this.flash(j(this.o.t.tooLong,{max:this.maxChars}));return}let t=this.files,i=this.replyTo;this.files=[],this.renderChips(),this.setReply(null),this.hideEmoji(),this.textarea.value="",this.autosize(),this.syncSend(),this.stopTyping(),this.o.actions.send(e,t,i),_()||this.textarea.focus();}cancelEdit(){this.editing=null,this.textarea&&(this.textarea.value="",this.autosize(),this.syncSend()),this.replyBar&&(T(this.replyBar),this.replyBar.classList.remove("on"));}addFiles(e){let t=this.o.maxMb*1024*1024;for(let i of e){if(i.size>t){this.flash(j(this.o.t.fileTooLarge,{mb:this.o.maxMb}));continue}if(i.type&&!this.allowedMimes.includes(i.type)){this.flash(this.o.t.fileNotAllowed);continue}if(this.files.length>=5)break;this.files.push(i);}this.renderChips(),this.syncSend();}renderChips(){this.chips&&(T(this.chips),this.chips.classList.toggle("on",this.files.length>0),this.files.forEach((e,t)=>{this.chips.appendChild(r("div",{class:"chip"},e.type.startsWith("image/")?r("img",{src:URL.createObjectURL(e),alt:""}):y("file",16),r("span",null,e.name),r("button",{type:"button","aria-label":this.o.t.delete,onclick:()=>{this.files.splice(t,1),this.renderChips(),this.syncSend();}},y("close",12))));}));}syncSend(){if(!this.sendBtn||!this.textarea)return;let e=!this.textarea.value.trim()&&this.files.length===0;this.sendBtn.disabled=e||this.textarea.value.length>this.maxChars,this.syncCounter();}syncCounter(){if(!this.counter||!this.textarea)return;let e=this.maxChars-this.textarea.value.length,t=e<=qe;this.counter.classList.toggle("on",t),this.counter.classList.toggle("full",e<=0),this.counter.textContent=t?String(e):"";}toggleEmoji(){if(!this.emojiBox)return;this.emojiBox.classList.toggle("on")&&document.addEventListener("click",()=>this.hideEmoji(),{once:true,capture:true});}hideEmoji(){var e;(e=this.emojiBox)==null||e.classList.remove("on");}insertEmoji(e){var n,a;if(!this.textarea)return;let t=this.textarea,i=(n=t.selectionStart)!=null?n:t.value.length;t.value=t.value.slice(0,i)+e+t.value.slice((a=t.selectionEnd)!=null?a:i),t.selectionStart=t.selectionEnd=i+e.length,this.autosize(),this.syncSend(),t.focus();}autosize(){let e=this.textarea;e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,132)}px`);}notifyTyping(){this.wasTyping||(this.wasTyping=true,this.o.actions.typing(true)),this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=setTimeout(()=>this.stopTyping(),2500);}stopTyping(){this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=null,this.wasTyping&&(this.wasTyping=false,this.o.actions.typing(false));}syncJump(){!this.jumpBtn||!this.list||this.jumpBtn.classList.toggle("on",!V(this.list,160));}flash(e){this.setBanner(e,true),setTimeout(()=>this.setBanner(null),3200);}buildTeaser(){let e=this.o.t,t=this.o.settings;return r("div",{class:"teaser",role:"button",tabindex:0,onclick:()=>{this.hideTeaser(true),this.o.actions.open();}},r("div",{class:"tv"},this.brandAvatar()),r("div",{class:"tc"},r("div",{class:"tn"},this.o.appName||e.title),r("div",{class:"tb"},t.greeting||e.greeting)),r("button",{class:"tx",type:"button","aria-label":e.close,onclick:i=>{i.stopPropagation(),this.hideTeaser(true);}},y("close",13)))}buildToast(){return r("div",{class:"toast",role:"button",tabindex:0,onclick:()=>{this.hideToast(),this.o.actions.open();}},r("div",{class:"tv"}),r("div",{class:"tc"},r("div",{class:"tn"}),r("div",{class:"tb"})))}scheduleTeaser(){we(this.key(me))||we(this.key(ve))||this.o.settings.launcher_mode!=="manual"&&(this.teaserTimer=setTimeout(()=>{this.wrap.classList.contains("open")||this.wrap.classList.contains("hidden")||this.wrap.classList.contains("no-ln")||this.wrap.classList.contains("tst")||this.wrap.classList.add("tz");},Ge));}hideTeaser(e){this.teaserTimer&&clearTimeout(this.teaserTimer),this.teaserTimer=null,this.wrap.classList.remove("tz"),e&&xe(this.key(me));}showToast(e){var o,l;let t=e.name||((o=this.agent)==null?void 0:o.name)||this.o.appName||this.o.t.agent,i=this.toast.querySelector(".tv"),n=this.toast.querySelector(".tn"),a=this.toast.querySelector(".tb");T(i),i.appendChild(S(e.avatar||((l=this.agent)==null?void 0:l.avatar),t)),n.textContent=t,a.textContent=e.body||this.o.t.newMessage,this.hideTeaser(false),this.wrap.classList.add("tst"),this.toastTimer&&clearTimeout(this.toastTimer),this.toastTimer=setTimeout(()=>this.hideToast(),We);}hideToast(){this.toastTimer&&clearTimeout(this.toastTimer),this.toastTimer=null,this.wrap.classList.remove("tst");}onLauncher(){this.hideTeaser(true),this.hideToast(),this.o.actions.open();}get allowedMimes(){let e=this.o.settings.attachment_mimes;return Array.isArray(e)&&e.length?e:Ue}get maxChars(){let e=Number(this.o.settings.max_message_chars);return Number.isFinite(e)&&e>0?e:Ye}quickStarters(){return (this.o.topics||[]).slice(0,4).map(e=>e.name).filter(Boolean)}bindViewport(){let e=F();e&&(e.addEventListener("resize",this.onViewport),this.onViewport());}onViewport(){let e=F();if(!e||!_())return;let t=Math.max(0,window.innerHeight-e.height-e.offsetTop);this.wrap.style.setProperty("--sb-kb",`${t}px`),this.wrap.classList.toggle("kb",t>40),t>40&&this.list&&requestAnimationFrame(()=>this.list&&R(this.list));}lockScroll(){if(this.locked||!_())return;this.locked=true,this.scrollLock=window.scrollY||0;let e=document.body.style;e.position="fixed",e.top=`-${this.scrollLock}px`,e.left="0",e.right="0",e.width="100%";}unlockScroll(){if(!this.locked)return;this.locked=false;let e=document.body.style;e.position="",e.top="",e.left="",e.right="",e.width="",window.scrollTo(0,this.scrollLock);}enableSwipeClose(){let e=0,t=0,i=false,n=()=>{i&&(i=false,this.wrap.classList.remove("dragging"),this.panel.style.transform="",t>110&&this.o.actions.close(),removeEventListener("pointermove",a),removeEventListener("pointerup",n),removeEventListener("pointercancel",n));},a=o=>{i&&(t=Math.max(0,o.clientY-e),this.panel.style.transform=`translateY(${t}px)`,this.panel.style.opacity=String(Math.max(.5,1-t/420)));};this.dragBar.addEventListener("pointerdown",o=>{_()&&(i=true,e=o.clientY,t=0,this.wrap.classList.add("dragging"),addEventListener("pointermove",a),addEventListener("pointerup",n),addEventListener("pointercancel",n));});}onKey(e){var t;if(e.key==="Escape"){if((t=this.emojiBox)!=null&&t.classList.contains("on")){this.hideEmoji();return}this.wrap.classList.contains("open")&&this.o.actions.close();}}enableDrop(){let e=0;this.body.addEventListener("dragenter",t=>{t.preventDefault(),e++,this.view==="chat"&&this.body.classList.add("dragover");}),this.body.addEventListener("dragover",t=>t.preventDefault()),this.body.addEventListener("dragleave",()=>{--e<=0&&(e=0,this.body.classList.remove("dragover"));}),this.body.addEventListener("drop",t=>{var i;t.preventDefault(),e=0,this.body.classList.remove("dragover"),this.view==="chat"&&((i=t.dataTransfer)!=null&&i.files)&&this.addFiles(Array.from(t.dataTransfer.files));});}clearTimers(){for(let e of [this.typingTimer,this.teaserTimer,this.toastTimer,this.attnTimer])e&&clearTimeout(e);}launcherMark(){let e=this.o.settings,t=P(e.logo_url);return e.launcher_icon==="logo"&&t?r("img",{class:"lg",src:t,alt:""}):e.launcher_icon==="chat"?y("chat",25):X(27)}brandAvatar(){let e=P(this.o.settings.logo_url);return e?r("img",{src:e,alt:""}):document.createTextNode($(this.o.appName))}restoreGeometry(){let e=Je();e&&(e.w&&(this.panel.style.width=`${e.w}px`),e.h&&(this.panel.style.height=`${e.h}px`),this.wrap.style.setProperty("--sb-dx",`${e.dx||0}px`),this.wrap.style.setProperty("--sb-dy",`${e.dy||0}px`));}saveGeometry(){Xe({w:this.panel.offsetWidth,h:this.panel.offsetHeight,dx:parseFloat(this.wrap.style.getPropertyValue("--sb-dx"))||0,dy:parseFloat(this.wrap.style.getPropertyValue("--sb-dy"))||0});}enableMove(e){e.addEventListener("pointerdown",t=>{if(t.button!==0||_()||t.target.closest("button"))return;let i=t.clientX,n=t.clientY,a=parseFloat(this.wrap.style.getPropertyValue("--sb-dx"))||0,o=parseFloat(this.wrap.style.getPropertyValue("--sb-dy"))||0,l=this.wrap.classList.contains("left")?-1:1,d=false,c=f=>{let p=f.clientX-i,h=f.clientY-n;if(!d&&Math.abs(p)+Math.abs(h)<4)return;d=true,this.wrap.classList.add("moving");let m=Math.max(0,innerWidth-this.panel.offsetWidth-24),x=Math.max(0,innerHeight-this.panel.offsetHeight-24);this.wrap.style.setProperty("--sb-dx",`${K(a-p*l,0,m)}px`),this.wrap.style.setProperty("--sb-dy",`${K(o-h,0,x)}px`);},g=()=>{removeEventListener("pointermove",c),removeEventListener("pointerup",g),this.wrap.classList.remove("moving"),d&&this.saveGeometry();};addEventListener("pointermove",c),addEventListener("pointerup",g);});}enableResize(){this.grip.addEventListener("pointerdown",e=>{if(e.button!==0||_())return;e.preventDefault();let t=e.clientX,i=e.clientY,n=this.panel.offsetWidth,a=this.panel.offsetHeight,o=this.wrap.classList.contains("left")?-1:1;this.wrap.classList.add("sizing");let l=c=>{this.panel.style.width=`${K(n+(t-c.clientX)*o,340,innerWidth-40)}px`,this.panel.style.height=`${K(a+(i-c.clientY),400,innerHeight-40)}px`;},d=()=>{removeEventListener("pointermove",l),removeEventListener("pointerup",d),this.wrap.classList.remove("sizing"),this.saveGeometry();};addEventListener("pointermove",l),addEventListener("pointerup",d);});}};function ye(s,e,t,i){let n=r("input",{type:s,value:t,autocomplete:i,placeholder:" "});return t&&n.classList.add("has"),n.addEventListener("input",()=>{var a;n.classList.toggle("has",n.value.length>0),(a=n.parentElement)==null||a.classList.remove("bad");}),{wrap:r("div",{class:"fld"},n,r("label",null,e)),input:n}}var ke="sb_geometry";function Je(){try{let s=localStorage.getItem(ke);if(!s)return null;let e=JSON.parse(s);return !e||e.w>innerWidth||e.h>innerHeight?null:e}catch(s){return null}}function Xe(s){try{localStorage.setItem(ke,JSON.stringify(s));}catch(e){}}function xe(s){try{localStorage.setItem(s,"1");}catch(e){}}function we(s){try{return localStorage.getItem(s)==="1"}catch(e){return false}}function K(s,e,t){return Math.min(Math.max(s,e),t)}function _(){return innerWidth<=640}function F(){return typeof window!="undefined"&&window.visualViewport||null}function Ze(s){return s==="dark"?true:s!=="auto"||typeof matchMedia!="function"?false:matchMedia("(prefers-color-scheme: dark)").matches}function Qe(s){return s&&/^(#[0-9a-f]{3,8}|rgba?\([\d\s.,%]+\)|hsla?\([\d\s.,%]+\))$/i.test(s)?s:"#4f46e5"}var Y=class{constructor(){this.original=null;this.timer=null;this.label="";}update(e,t){e>0&&document.hidden?(this.label=t(e),this.begin()):this.end();}begin(){if(this.timer)return;this.original=document.title;let e=false;this.timer=setInterval(()=>{if(!document.hidden)return this.end();e=!e,document.title=e?this.label:this.original||"";},1200);}end(){this.timer&&clearInterval(this.timer),this.timer=null,this.original!==null&&(document.title=this.original,this.original=null);}};var A=null;function te(){try{let s=window.AudioContext||window.webkitAudioContext;if(!s)return;A||(A=new s),A.state==="suspended"&&A.resume();let e=A.currentTime,t=A.createGain();t.gain.setValueAtTime(1e-4,e),t.gain.exponentialRampToValueAtTime(.12,e+.02),t.gain.exponentialRampToValueAtTime(1e-4,e+.35),t.connect(A.destination);let i=A.createOscillator();i.type="sine",i.frequency.setValueAtTime(880,e),i.frequency.setValueAtTime(1175,e+.12),i.connect(t),i.start(e),i.stop(e+.36);}catch(s){}}var et="https://live.signalbird.io/api",E="/v1/sdk/chat/conversations",q=class{constructor(e){this.opts=e;this.title=new Y;this.topic=null;this.ui=null;this.settings=null;this.appName="";this.started=false;this.destroyed=false;this.pendingSends=new Map;this.ratingMode=null;this.autoOpened=false;this.identity=null;this.lastTypingSent=0;this.pollCount=0;this.forceFull=false;this.socket=null;this.onVisibility=()=>{this.syncUnread(),!document.hidden&&this.store.isOpen&&this.store.conversation&&this.markRead();};this.baseUrl=(e.baseUrl||et).replace(/\/$/,""),this.store=new I(e.publicKey),this.api=new H(this.baseUrl,e.publicKey,e.chatKey,()=>this.store.secret,(...t)=>this.log(...t)),this.poller=new B(()=>this.tick()),this.identity=e.user&&(e.user.name||e.user.email||e.user.external_id)?e.user:null,this.locale=Q(null,e.locale),this.t=ee(this.locale),this.ready=this.start().catch(t=>this.log("start failed",t));}log(...e){this.opts.debug&&console.debug("[signalbird]",...e);}async start(){var f;let e=await this.api.post("/v1/sdk/bootstrap",{page_url:location.href,locale:this.opts.locale});if(!e.ok||!e.data){this.log("bootstrap failed",e);return}let t=(f=e.data.channel)!=null?f:e.data.app;if(!t){this.log("bootstrap failed",e);return}if(this.destroyed)return;let{online:i,within_hours:n,visitor:a,conversation:o,topics:l,realtime:d}=e.data;if(!t.chat_enabled){this.log("chat disabled for app");return}let c=t.chat||{};this.settings=c,this.appName=t.name||"",this.locale=Q(c.locale,this.opts.locale),this.t=ee(this.locale),this.store.visitor&&!a&&this.store.clearVisitor(),a&&this.store.setVisitor({id:a.id,name:a.name,email:a.email}),this.store.online=!!i,this.store.withinHours=n!==false,o&&this.store.setConversation(o);let g=Number(c.max_attachment_mb||t.max_attachment_mb||10);this.ui=new U({t:this.t,locale:this.locale,publicKey:this.opts.publicKey,settings:c,appName:this.appName,maxMb:g,topics:l||[],actions:{open:()=>this.open(),close:()=>this.close(),send:(p,h,m)=>{this.send(p,h,m);},typing:p=>{this.typing(p);},submitPrechat:(p,h,m)=>{this.submitPrechat(p,h,m);},skipPrechat:p=>{this.topic=p,this.enterChat();},rate:(p,h)=>{this.rate(p,h);},dismiss:()=>this.dismiss(),endChat:()=>this.endChat(),newChat:()=>this.newChat(),saveEdit:(p,h)=>{this.saveEdit(p,h);},reply:p=>{var h;return (h=this.ui)==null?void 0:h.setReply(p)},react:(p,h)=>{this.react(p,h);},edit:p=>{var h;return (h=this.ui)==null?void 0:h.startEdit(p)},remove:p=>{this.remove(p);},retry:p=>{this.retry(p);},openImage:p=>window.open(p,"_blank","noopener")}}),this.store.on("unread",()=>this.syncUnread()),this.store.on("messages",()=>this.render()),this.store.on("change",()=>this.render()),document.addEventListener("visibilitychange",this.onVisibility),this.ui.mount(),this.ui.setDismissed(this.store.dismissed),this.syncLauncher(),this.ui.setHeader(this.store.agent,this.store.online),this.applyBanner(),this.store.setUnread((a==null?void 0:a.unread)||(o==null?void 0:o.visitor_unread)||0),this.syncUnread(),this.started=true,this.poller.start(),d!=null&&d.enabled&&(this.socket=new O(d,(p,h)=>this.authorizeChannel(p,h),p=>this.onSocketEvent(p),p=>{this.log("socket",p?"connected":"disconnected"),this.poller.setLive(p),p&&this.poller.poke(0);},(...p)=>this.log(...p)),this.socket.connect(),this.subscribeVisitor()),this.opts.user&&this.identify(this.opts.user);}applyBanner(){!this.ui||!this.settings||this.ui.setBanner(this.store.withinHours?null:this.settings.offline_message||this.t.offlineMessage);}syncUnread(){var t;let e=this.store.isOpen&&!document.hidden?0:this.store.unread;(t=this.ui)==null||t.setUnread(this.store.unread),this.title.update(e,i=>j(this.t.unreadTitle,{n:i})),this.store.emit("public:unread",this.store.unread),this.syncLauncher();}syncLauncher(){var i;if(!this.ui)return;if(((i=this.settings)==null?void 0:i.launcher_mode)!=="manual"){this.ui.setLauncherHidden(false);return}let e=this.store.conversation,t=!!e&&e.status!=="closed";this.ui.setLauncherHidden(!(this.store.isOpen||t||this.store.unread>0));}dismiss(){var e;this.store.setDismissed(true),this.close(),(e=this.ui)==null||e.setDismissed(true);}open(){var e,t;this.store.dismissed&&(this.store.setDismissed(false),(e=this.ui)==null||e.setDismissed(false)),!(!this.ui||this.store.isOpen)&&(((t=this.store.conversation)==null?void 0:t.status)==="closed"&&(this.store.setConversation(null),this.ratingMode=null),this.store.isOpen=true,this.ui.setOpen(true),this.syncLauncher(),this.poller.setOpen(true),this.decideView(),this.store.emit("public:open"),this.store.conversation?this.loadConversation():this.store.setUnread(0),this.syncUnread());}close(){if(!this.ui||!this.store.isOpen)return;let e=this.store.conversation;if(e&&e.status==="resolved"&&!this.store.wasRated(e.id)&&this.ui.currentView==="chat"&&this.store.messages.some(t=>t.sender_type==="agent"||t.sender_type==="bot")){this.ratingMode="resolved",this.ui.setEndVisible(false),this.ui.showRating();return}this.store.isOpen=false,this.ui.setOpen(false),this.poller.setOpen(false),this.typing(false),this.store.emit("public:close"),this.syncUnread(),this.syncLauncher();}toggle(){this.store.isOpen?this.close():this.open();}isOpen(){return this.store.isOpen}on(e,t){this.store.on(`public:${e}`,t);}off(e,t){this.store.off(`public:${e}`,t);}async identify(e){var a;if(await this.ready,this.destroyed)return;this.identity={...this.identity||{},...e},((a=this.ui)==null?void 0:a.currentView)==="prechat"&&this.enterChat();let[t,...i]=(e.name||"").trim().split(/\s+/),n={external_id:e.external_id,email:e.email,phone:e.phone,first_name:t||void 0,last_name:i.join(" ")||void 0,attributes:e.attributes};e.external_id&&this.check(await this.api.post("/v1/sdk/identify",n)),await this.session({name:e.name,email:e.email,external_id:e.external_id});}async pushRegister(e){return await this.ready,this.api.post("/v1/sdk/devices",{provider:e.platform==="ios"?"apns":"fcm",locale:Te(),...e})}destroy(){var e,t;this.destroyed=true,(e=this.socket)==null||e.close(),this.socket=null,this.poller.stop(),this.title.end(),document.removeEventListener("visibilitychange",this.onVisibility),(t=this.ui)==null||t.unmount(),this.ui=null;}decideView(){var a,o;if(!this.ui||!this.settings)return;let e=this.settings.prechat,t=this.store.visitor;!!!((a=this.identity)!=null&&a.name||(o=this.identity)!=null&&o.email||t!=null&&t.name||t!=null&&t.email)&&!this.store.conversation&&e&&(e.name||e.email)?this.ui.showPrechat({}):this.enterChat();}enterChat(){var e;this.ui&&(this.ratingMode=null,this.ui.showChat(),this.ui.setEndVisible(((e=this.store.conversation)==null?void 0:e.status)==="open"),this.render());}render(){var t,i;if(!this.ui||this.ui.currentView!=="chat")return;let e=this.store.conversation;this.ui.render({messages:this.store.messages,greeting:((t=this.settings)==null?void 0:t.greeting)||this.t.greeting,agentName:((i=this.store.agent)==null?void 0:i.name)||this.t.agent,find:n=>this.store.find(n)}),this.ui.setEndVisible((e==null?void 0:e.status)==="open"),e&&e.status!=="open"?this.ui.setNotice(e.status==="resolved"?this.t.resolved:this.t.closed,{label:this.t.newChat,fn:()=>this.newChat()}):this.ui.setNotice(null);}async submitPrechat(e,t,i){var a;this.topic=i,await this.session({name:e||void 0,email:t||void 0})?this.enterChat():(a=this.ui)==null||a.setBanner(this.t.unavailable,true);}newChat(){this.ratingMode=null,this.store.setConversation(null),this.enterChat(),this.store.isOpen||this.open();}endChat(){!this.ui||!this.store.conversation||(this.ratingMode="end",this.ui.setEndVisible(false),this.ui.showRating());}async rate(e,t){var a;let i=this.store.conversation,n=this.ratingMode;if(this.ratingMode=null,!(!i||!this.ui)){if(e>0){let o=await this.api.post(`${E}/${i.id}/rate`,{rating:e,comment:t||void 0});this.check(o),this.store.markRated(i.id);}if(n==="end"){let o=await this.api.post(`${E}/${i.id}/close`);this.check(o),((a=this.store.conversation)==null?void 0:a.id)===i.id&&this.store.setConversation({...i,status:"closed"}),this.ui.showThanks(this.reviewFor(e));return}e===0&&this.store.markRated(i.id),this.enterChat(),this.close();}}reviewFor(e){var n,a,o,l;let t=(((n=this.settings)==null?void 0:n.review_url)||"").trim(),i=Number((o=(a=this.settings)==null?void 0:a.review_min_rating)!=null?o:3);return !t||!/^https?:\/\//i.test(t)?null:e>0&&e>=i?{url:t,label:((l=this.settings)==null?void 0:l.review_label)||null}:null}async session(e={}){var n;let t=this.identity?{name:this.identity.name,email:this.identity.email,external_id:this.identity.external_id}:{},i=await this.api.post("/v1/sdk/chat/session",{...t,...e,locale:Te(),...this.opts.locale?{language:this.opts.locale}:{},page_url:location.href,user_agent:navigator.userAgent});if(i.ok&&((n=i.data)!=null&&n.visitor)){let a=i.data.visitor;return !a.secret&&!this.store.visitor?(this.log("session returned no secret"),false):(this.store.setVisitor(a),this.subscribeVisitor(),true)}return !i.ok&&i.code==="VISITOR_INVALID"&&this.store.visitor?(this.store.clearVisitor(),this.session(e)):(this.check(i),false)}subscribeVisitor(){var t;let e=(t=this.store.visitor)==null?void 0:t.id;this.socket&&e&&this.socket.subscribe(`visitor.${e}`);}async authorizeChannel(e,t){var n;let i=await this.api.post("/v1/sdk/chat/socket/auth",{socket_id:e,channel:t});return i.ok&&((n=i.data)!=null&&n.auth)?{auth:i.data.auth,at:i.data.at}:null}onSocketEvent(e){var t,i;if(e.name==="chat.typing"){e.data.who==="agent"&&(this.store.agentTyping=e.data.active===true,(i=this.ui)==null||i.setTyping(this.store.agentTyping,((t=this.store.agent)==null?void 0:t.name)||this.t.agent));return}e.data.updated===true&&(this.forceFull=true),this.poller.poke(0);}async loadConversation(){let e=this.store.conversation;if(!e)return;let t=await this.api.get(`${E}/${e.id}`,{limit:50});this.applyPayload(t,true)&&this.store.isOpen&&!document.hidden&&this.store.setUnread(0);}applyPayload(e,t){var n,a,o,l;if(!e.ok)return this.check(e),e.status===404&&this.store.setConversation(null),-1;let i=e.data;if(i.conversation){let d=(n=this.store.conversation)==null?void 0:n.status;this.store.conversation=i.conversation,d!==i.conversation.status&&this.store.emit("change");}return i.agent!==void 0&&(this.store.agent=i.agent||null),this.store.agentTyping=!!i.agent_typing,(a=this.ui)==null||a.setHeader(this.store.agent,this.store.online),(l=this.ui)==null||l.setTyping(this.store.agentTyping,((o=this.store.agent)==null?void 0:o.name)||this.t.agent),this.store.mergeMessages(i.messages||[],t)}async tick(){var d,c,g,f,p,h,m,x;if(!this.started||!this.store.visitor)return false;this.pollCount++;let e=this.store.conversation;if(this.store.isOpen&&e){let k=this.pollCount%5===0||this.forceFull;this.forceFull=false;let w=k?void 0:this.store.lastServerMessageId||void 0,M=await this.api.get(`${E}/${e.id}`,w?{after:w}:{limit:50}),u=this.applyPayload(M,!w);return u>0&&(document.hidden?(this.store.setUnread(this.store.unread+u),(d=this.settings)!=null&&d.sound&&te()):this.markRead()),u>0}if(this.store.isOpen&&!e&&this.pollCount%10!==0)return false;let t=await this.api.get(E);if(!t.ok)return this.check(t),false;let i=t.data,n=Array.isArray(i)?i:(i==null?void 0:i.conversations)||(i==null?void 0:i.data)||[],a=n.find(k=>k.status==="open")||null,o=n.reduce((k,w)=>k+(w.visitor_unread||0),0),l=o>this.store.unread;return a&&a.id!==((c=this.store.conversation)==null?void 0:c.id)&&(this.store.setConversation(a),this.store.isOpen&&this.loadConversation()),(!this.store.isOpen||document.hidden)&&(this.store.setUnread(o),l&&((g=this.settings)!=null&&g.sound&&te(),(x=this.ui)==null||x.attention({name:((f=a==null?void 0:a.agent)==null?void 0:f.name)||((p=this.store.agent)==null?void 0:p.name)||this.t.agent,avatar:((h=a==null?void 0:a.agent)==null?void 0:h.avatar)||((m=this.store.agent)==null?void 0:m.avatar)||null,body:(a==null?void 0:a.last_message_sender)==="agent"&&(a==null?void 0:a.last_message_preview)||null}),!this.autoOpened&&!document.hidden&&(this.autoOpened=true,this.open()))),l}async markRead(){let e=this.store.conversation,t=this.store.lastServerMessageId;!e||!t||(this.store.setUnread(0),await this.api.post(`${E}/${e.id}/read`,{last_message_id:t},true));}async send(e,t,i,n=le()){var l;let a={id:`local_${n}`,client_id:n,sender_type:"visitor",type:t.length?t[0].type.startsWith("image/")?"image":"file":"text",body:e||null,attachments:null,reply_to_id:(i==null?void 0:i.id)||null,created_at:new Date().toISOString(),_pending:true,_files:t};this.pendingSends.set(n,{text:e,files:t,replyTo:(i==null?void 0:i.id)||null}),this.store.upsertMessage(a);let o=()=>{let d=this.store.find(a.id);d&&this.store.upsertMessage({...d,_pending:false,_failed:true});};try{if(!this.store.visitor&&!await this.session())return o();let d=this.store.conversation,c=!d||d.status!=="open";if(c&&t.length===0){let h=await this.api.post(E,{body:e,page_url:location.href,client_id:n,...this.topic?{topic:this.topic}:{}});if(!h.ok)return this.sendFailed(h,o);this.store.setConversation(h.data.conversation),this.store.mergeMessages(h.data.messages||[]),this.reconcile(a,h.data.messages),this.pendingSends.delete(n),this.poller.poke(3e3);return}if(c){let h=await this.api.post(E,{page_url:location.href,...this.topic?{topic:this.topic}:{}});if(!h.ok)return this.sendFailed(h,o);this.store.setConversation(h.data.conversation),this.store.mergeMessages(h.data.messages||[]),d=h.data.conversation;}if(!d)return o();let g=[];for(let h of t){let m=await this.api.upload(`${E}/${d.id}/attachments`,h);if(!m.ok)return this.sendFailed(m,o);g.push(m.data);}let f=await this.api.post(`${E}/${d.id}/messages`,{body:e||void 0,attachments:g.length?g:void 0,reply_to_id:(i==null?void 0:i.id)||void 0,client_id:n});if(!f.ok)return this.sendFailed(f,o);let p=((l=f.data)==null?void 0:l.message)||f.data;this.reconcile(a,[p]),this.pendingSends.delete(n),this.poller.poke(3e3);}catch(d){this.log("send error",d),o();}}reconcile(e,t){let i=(t||[]).find(n=>n.client_id===e.client_id);i?this.store.mergeMessages([{...i,client_id:e.client_id}]):t&&t.length&&(this.store.removeMessage(e.id),this.store.mergeMessages(t));}sendFailed(e,t){var i;this.check(e),(e.code==="CHAT_UNAVAILABLE"||e.status===503)&&((i=this.ui)==null||i.setBanner(this.t.unavailable,true)),t();}async retry(e){let t=e.client_id?this.pendingSends.get(e.client_id):null;this.store.removeMessage(e.id),!(!t||!e.client_id)&&await this.send(t.text,t.files,this.store.find(t.replyTo)||null,e.client_id);}async typing(e){let t=this.store.conversation;if(!t||t.status!=="open"||!this.store.visitor)return;let i=Date.now();e&&i-this.lastTypingSent<4e3||(this.lastTypingSent=e?i:0,await this.api.post(`${E}/${t.id}/typing`,{is_typing:e},true));}async react(e,t){var c,g,f,p;let i=this.store.conversation;if(!i)return;let n={...e.reactions||{}},a=[...n[t]||[]],o=a.indexOf("visitor");o>=0?a.splice(o,1):a.push("visitor"),n[t]=a,this.store.upsertMessage({...e,reactions:n});let l=await this.api.post(`${E}/${i.id}/messages/${e.id}/reactions`,{emoji:t});if(!l.ok){this.check(l),this.store.upsertMessage({...e});return}let d=(p=(g=(c=l.data)==null?void 0:c.message)==null?void 0:g.reactions)!=null?p:(f=l.data)==null?void 0:f.reactions;d&&this.store.upsertMessage({...e,reactions:d});}async saveEdit(e,t){var o;let i=this.store.conversation;if(!i)return;this.store.upsertMessage({...e,body:t,edited_at:new Date().toISOString()});let n=await this.api.patch(`${E}/${i.id}/messages/${e.id}`,{body:t});if(!n.ok){this.check(n),this.store.upsertMessage({...e});return}let a=((o=n.data)==null?void 0:o.message)||n.data;a&&a.id&&this.store.upsertMessage(a);}async remove(e){let t=this.store.conversation;if(!t)return;this.store.upsertMessage({...e,deleted_at:new Date().toISOString()});let i=await this.api.delete(`${E}/${t.id}/messages/${e.id}`);i.ok||(this.check(i),this.store.upsertMessage({...e}));}check(e){e.ok||(e.code==="VISITOR_INVALID"||e.status===401&&this.store.visitor)&&(this.store.clearVisitor(),this.store.isOpen&&this.decideView());}};function Te(){var s;try{return ((s=navigator.languages)==null?void 0:s[0])||navigator.language||void 0}catch(e){return}}var tt={tr:{loading:"Y\xFCkleniyor\u2026",failed:"Ekran y\xFCklenemedi.",expired:"Bu ba\u011Flant\u0131n\u0131n s\xFCresi doldu.",retry:"Yeniden dene"},en:{loading:"Loading\u2026",failed:"The screen could not be loaded.",expired:"This link has expired.",retry:"Try again"}};function it(s){if(s==="light"||s==="dark")return s;if(typeof document!="undefined"){let e=document.documentElement;if(e.classList.contains("dark")||e.dataset.theme==="dark")return "dark";if(e.classList.contains("light")||e.dataset.theme==="light")return "light"}return typeof window!="undefined"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function st(s){if(typeof s=="string")return s||null;if(s&&typeof s=="object"){let e=s;if(typeof e.url=="string")return e.url;if(e.data&&typeof e.data.url=="string")return e.data.url}return null}function Le(s){var p,h;let e=tt[(p=s.language)!=null?p:"tr"],t=new Map,i=null,n=null,a=null,o=(h=s.theme)!=null?h:"auto",l=false,d=(m,x)=>{var k;(k=t.get(m))==null||k.forEach(w=>{try{w(x);}catch(M){console.warn("[signalbird]",M);}});},c=()=>{a&&(window.removeEventListener("message",a),a=null),n=null,i&&(i.textContent="");},g=(m,x)=>{var M;if(!i)return;i.textContent="";let k=document.createElement("div");k.setAttribute("data-signalbird-status",""),k.style.cssText=`display:flex;align-items:center;justify-content:center;gap:12px;min-height:${(M=s.minHeight)!=null?M:220}px;font:13px/1.5 system-ui,-apple-system,sans-serif;color:#6b7280;text-align:center;padding:24px;`;let w=document.createElement("span");if(w.textContent=m,k.appendChild(w),x){let u=document.createElement("button");u.type="button",u.textContent=e.retry,u.style.cssText="border:1px solid currentColor;border-radius:8px;background:transparent;color:inherit;padding:4px 10px;font:inherit;cursor:pointer;",u.addEventListener("click",()=>{f();}),k.appendChild(u);}i.appendChild(k);},f=async()=>{var M;if(!i||l)return;c(),g(e.loading,false);let m=it(o),x=null;try{s.url?(x=s.url,s={...s,url:void 0}):s.mint&&(x=st(await s.mint({module:s.module,theme:m,locale:s.locale})));}catch(u){d("error",u),g(u instanceof Error?u.message:e.failed,true);return}if(!x){d("error",new Error("EMBED_URL_MISSING")),g(e.expired,!!s.mint);return}let k=x;try{let u=new URL(x);u.searchParams.set("theme",m),s.locale&&u.searchParams.set("locale",s.locale),s.accent&&u.searchParams.set("accent",s.accent.replace(/^#/,"")),k=u.toString();}catch(u){}let w=document.createElement("iframe");w.src=k,w.title="Signalbird",w.style.cssText="width:100%;border:0;display:block;",w.style.height=`${typeof s.height=="number"?s.height:(M=s.minHeight)!=null?M:640}px`,w.setAttribute("allow","clipboard-write; fullscreen; autoplay"),w.setAttribute("sandbox","allow-same-origin allow-scripts allow-forms allow-popups allow-downloads"),w.setAttribute("referrerpolicy","strict-origin-when-cross-origin"),w.setAttribute("loading","lazy"),s.className&&(w.className=s.className),i.textContent="",i.appendChild(w),n=w,a=u=>{var L,z;if(!n||u.source!==n.contentWindow)return;let b=u.data;if(!(!b||typeof b.type!="string")){if(b.type==="signalbird:ready"){d("ready",b.module);return}if(b.type==="signalbird:height"&&typeof b.px=="number"&&(d("height",b.px),((L=s.height)!=null?L:"auto")==="auto")){let Me=Math.max(b.px,(z=s.minHeight)!=null?z:220);n.style.height=`${Me}px`;}}},window.addEventListener("message",a);};return {async mount(m){let x=typeof m=="string"?document.querySelector(m):m;if(!(x instanceof HTMLElement))throw new Error("Signalbird: g\xF6mme kab\u0131 bulunamad\u0131 \u2014 "+String(m));i=x,l=false,await f();},refresh:()=>f(),async setTheme(m){o=m,await f();},destroy(){l=true,c(),t.clear(),i=null;},on(m,x){t.has(m)||t.set(m,new Set),t.get(m).add(x);},off(m,x){var k;(k=t.get(m))==null||k.delete(x);}}}var jt="2.4.2",v=null,G=[],N=null;function C(s,e){try{return s()}catch(t){try{console.warn("[signalbird]",t);}catch(i){}return e}}function Ee(s){s.catch(()=>{});}function nt(s){C(()=>{if(!s||!s.publicKey){console.warn("[signalbird] init: publicKey zorunlu");return}if(!(typeof document=="undefined"||typeof window=="undefined")){v&&v.destroy(),v=new q(s);for(let{event:e,fn:t}of G)v.on(e,t);if(N){let e=N;N=null,Ee(v.identify(e));}}},void 0);}function Nt(s){C(()=>{if(s){if(!v){N={...N||{},...s};return}Ee(v.identify(s));}},void 0);}var Ht={open(){C(()=>v==null?void 0:v.open(),void 0);},close(){C(()=>v==null?void 0:v.close(),void 0);},toggle(){C(()=>v==null?void 0:v.toggle(),void 0);},isOpen(){return C(()=>!!(v!=null&&v.isOpen()),false)},on(s,e){C(()=>{typeof e=="function"&&(G.push({event:s,fn:e}),v==null||v.on(s,e));},void 0);},off(s,e){C(()=>{let t=G.findIndex(i=>i.event===s&&i.fn===e);t>=0&&G.splice(t,1),v==null||v.off(s,e);},void 0);}},It={register(s){return C(()=>v?v.pushRegister(s).catch(e=>({ok:!1,status:0,code:"NETWORK_ERROR",message:String(e)})):Promise.resolve({ok:!1,status:0,code:"NOT_INITIALIZED",message:"Signalbird.init \xE7a\u011Fr\u0131lmad\u0131"}),Promise.resolve({ok:false,status:0,code:"WIDGET_ERROR",message:"widget error"}))}},Bt=Le;function Ot(){C(()=>{v==null||v.destroy(),v=null;},void 0);}C(()=>{if(typeof document=="undefined")return;let s=document.currentScript||document.querySelector('script[data-key][src*="signalbird"]'),e=s==null?void 0:s.dataset;if(!e||!e.key)return;let t=()=>nt({publicKey:e.key,chatKey:e.channel||void 0,baseUrl:e.baseUrl||void 0,locale:e.locale||void 0,debug:e.debug==="true"||e.debug==="1"});document.body?t():document.addEventListener("DOMContentLoaded",t,{once:!0});},void 0);
500
500
  exports.chat=Ht;exports.destroy=Ot;exports.embed=Bt;exports.identify=Nt;exports.init=nt;exports.push=It;exports.version=jt;return exports;})({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "signalbird",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "Signalbird SDK — Telsiz (Radio), Gönderim (Messaging), Yönetim (Management) ve son kullanıcı sohbet/push istemcisi: sunucu, tarayıcı, mobil",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",