signalbird 2.2.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.2.2")` |
97
+ | Kotlin (Android) | `implementation("io.signalbird:signalbird-sdk:2.3.0")` |
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
@@ -486,5 +486,5 @@ display:flex;align-items:center;justify-content:center;margin-bottom:8px;animati
486
486
  border:1px solid var(--sb-b);border-radius:14px;text-align:center;display:none}
487
487
  .notice.on{display:block}
488
488
  .notice button{color:var(--sb-c);font-weight:650;margin-left:6px}
489
- `;function a(s,e,...t){let i=document.createElement(s);if(e)for(let n in e){let r=e[n];r==null||r===false||(n==="class"?i.className=String(r):n==="style"?i.setAttribute("style",String(r)):n.startsWith("on")&&typeof r=="function"?i.addEventListener(n.slice(2).toLowerCase(),r):n==="html"?i.innerHTML=String(r):n in i&&n!=="list"&&n!=="form"?i[n]=r:i.setAttribute(n,String(r)));}return _e(i,t),i}function _e(s,e){for(let t of e)t==null||t===false||s.appendChild(typeof t=="object"?t:document.createTextNode(String(t)));}function k(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=ze[s],t}function W(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 ze={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"/>',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 B(s){return (s||"?").trim().split(/\s+/).slice(0,2).map(e=>e[0]||"").join("").toUpperCase()}function C(s,e){let t=A(s);return t?a("img",{src:t,alt:"",loading:"lazy"}):document.createTextNode(B(e))}function A(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}"],ge=["\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"],Ae=900*1e3,Re=300*1e3;function be(s,e){let t=O(s),i=s.childNodes.length===0,n=Pe(s);if(k(s),e.messages.length===0){s.appendChild(je(e));return}let r="";for(let o=0;o<e.messages.length;o++){let l=e.messages[o],d=J(l.created_at),c=d===r&&e.messages[o-1]||null,h=e.messages[o+1]||null;d!==r&&(s.appendChild(a("div",{class:"day"},$e(l.created_at,e))),r=d),s.appendChild(Ne(l,e,c,He(l,h)?h:null,!i&&!n.has(l.id)));}(t||i)&&z(s);}function O(s,e=60){return s.scrollHeight-s.scrollTop-s.clientHeight<e}function z(s,e=false){if(e&&typeof s.scrollTo=="function"){s.scrollTo({top:s.scrollHeight,behavior:"smooth"});return}s.scrollTop=s.scrollHeight;}function Pe(s){let e=new Set;return s.querySelectorAll("[data-id]").forEach(t=>{let i=t.dataset.id;i&&e.add(i);}),e}function je(s){let e=a("div",{class:"hero"});e.appendChild(a("div",{class:"hv"},a("span",null,C(s.agentAvatar,s.brandName||s.agentName)))),e.appendChild(a("h4",null,s.greeting||s.t.greeting)),s.responseHint&&e.appendChild(a("p",null,s.responseHint));let t=s.quick||[];if(t.length&&s.onQuick){let i=a("div",{class:"qk"});for(let n of t.slice(0,6))i.appendChild(a("button",{type:"button",onclick:()=>s.onQuick(n)},n));e.appendChild(i);}return e}function Ne(s,e,t,i,n){var x;let r=s.sender_type==="visitor"?"v":s.sender_type==="system"?"s":"a",o=!pe(t,s),l=!pe(s,i),d=a("div",{class:`row ${r}`+(o&&t?" gap":"")+(l?"":" mid")+(s._pending?" pend":"")+(s._failed?" fail":"")+(n?" new":""),"data-id":s.id});if(r==="s")return d.appendChild(a("div",{class:"bb"},s.body||"")),d;r==="a"&&d.appendChild(a("div",{class:`av${l?"":" gh"}`},C(e.agentAvatar,s.sender_name||e.agentName)));let c=a("div",{class:"cl"}),h=a("div",{class:`bb${s.deleted_at?" del":""}`});if(s.deleted_at)return h.textContent=e.t.deleted,c.appendChild(h),d.appendChild(c),d;if(s.reply_to_id){let b=e.find(s.reply_to_id),g=b?b.sender_type==="visitor"?e.t.you:b.sender_name||e.agentName:"";h.appendChild(a("span",{class:"q"},g?`${g}: `:"",b?$(b,e.t):"\u2026"));}if(s._files&&s._files.length){let b=a("div",{class:"imgs"});for(let g of s._files)g.type.startsWith("image/")?b.appendChild(a("img",{src:URL.createObjectURL(g),alt:g.name})):h.appendChild(ce({name:g.name,url:"",mime:g.type,size:g.size},e));b.childNodes.length&&h.appendChild(b);}let p=s.attachments||[],u=p.filter(b=>he(b.mime));if(u.length){let b=a("div",{class:"imgs"});for(let g of u)b.appendChild(a("img",{src:g.url,alt:g.name,loading:"lazy",onclick:()=>e.actions.openImage(g.url)}));h.appendChild(b);}for(let b of p.filter(g=>!he(g.mime)))h.appendChild(ce(b,e));let m=(r==="v"?null:(x=s.translation)==null?void 0:x.body)||s.body;m&&h.appendChild(Oe(m)),s._failed&&(h.appendChild(a("div",{style:"font-size:11px;margin-top:5px;font-weight:600"},e.t.failed)),h.addEventListener("click",()=>e.actions.retry(s))),c.appendChild(h);let f=s.reactions&&Object.keys(s.reactions).length?s.reactions:null;if(f){let b=a("div",{class:"rx"});for(let g in f){let L=f[g]||[];if(!L.length)continue;let w=L.includes("visitor");b.appendChild(a("button",{class:w?"me":"",type:"button",onclick:()=>e.actions.react(s,g)},`${g} ${L.length}`));}b.childNodes.length&&c.appendChild(b);}if(l){let b=a("div",{class:"mt"},Ve(s.created_at,e.locale));if(s.edited_at&&b.appendChild(a("span",{class:"ed"},`\xB7 ${e.t.edited}`)),r==="v"&&!s._failed){let g=a("span",{class:`tk${s.read_at?" rd":""}`});g.appendChild(s._pending?y("check",12):s.read_at||s.delivered_at?y("checks",13):y("check",12)),s._pending&&(g.style.opacity=".4"),b.appendChild(g);}c.appendChild(b);}return d.appendChild(c),!s._pending&&!s._failed&&(d.appendChild(Ie(s,e,d)),Be(d)),d}function pe(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<Re}function He(s,e){return !!e&&J(s.created_at)===J(e.created_at)}function Ie(s,e,t){let i=a("div",{class:"ac"});for(let o of de.slice(0,3))i.appendChild(a("button",{type:"button",title:e.t.react,onclick:()=>e.actions.react(s,o)},o));i.appendChild(a("button",{type:"button",title:e.t.reply,onclick:()=>e.actions.reply(s)},y("reply",15)));let n=a("div",{class:"menu"});for(let o of de.slice(3))n.appendChild(a("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)<Ae&&(n.appendChild(a("button",{type:"button",onclick:()=>{n.classList.remove("show"),e.actions.edit(s);}},e.t.edit)),n.appendChild(a("button",{type:"button",class:"dg",onclick:()=>{n.classList.remove("show"),e.actions.remove(s);}},e.t.delete))),i.appendChild(a("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 Be(s){let e=null,t=()=>{e=setTimeout(()=>{var r;s.classList.add("acts");try{(r=navigator.vibrate)==null||r.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 ce(s,e){return a("a",{class:"fr",href:s.url||void 0,target:"_blank",rel:"noopener"},y("file",18),a("span",{class:"fn"},s.name||e.t.attachment),a("span",{class:"fs"},oe(s.size||0)))}function Oe(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 r=n[1].replace(/[.,;:!?)]+$/,"");e.appendChild(a("a",{href:r,target:"_blank",rel:"noopener noreferrer nofollow"},r)),i=n.index+r.length;}return i<s.length&&e.appendChild(document.createTextNode(s.slice(i))),e}function $(s,e){var n,r;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=(r=s.attachments)==null?void 0:r[0];return i?`\u{1F4CE} ${i.name}`:"\u2026"}function he(s){return !!s&&s.startsWith("image/")}function J(s){let e=new Date(s);return `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function $e(s,e){let t=new Date(s),i=new Date,n=Math.round((ue(i)-ue(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(r){return t.toLocaleDateString()}}function ue(s){return new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime()}function Ve(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 De={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."},Ke={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 X(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 Z(s){return s==="tr"?De:Ke}function R(s,e){return s.replace(/\{(\w+)\}/g,(t,i)=>{var n;return String((n=e[i])!=null?n:"")})}var Fe=["image/jpeg","image/png","image/gif","image/webp"],Ue=420,Ye=60,qe=11e3,Ge=9e3,me="sb_teaser",fe="sb_seen",K=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=a("div",{id:"signalbird-widget"}),this.root=this.host.attachShadow({mode:"open"}),this.root.appendChild(a("style",null,ae));let i=e.settings.position==="left"?"left":"right",n=e.settings.layout==="sidebar"?" sidebar":"";if(this.wrap=a("div",{class:`sb ${i}${n}${Xe(e.settings.theme)?" dark":""}`,style:`--sb-c:${Ze(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=a("span",{class:"badge"});let r=e.settings.launcher_text;this.launcher=a("button",{class:`ln${r?"":" icon-only"}`,type:"button","aria-label":r||t.launcher,onclick:()=>this.onLauncher()},a("span",{class:"lm"},this.launcherMark()),r?a("span",{class:"lt"},r):null,a("span",{class:"ln-on"}),a("span",{class:"ln-pulse"}),this.badge),this.dismissBtn=a("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=a("div",{class:"ph"},this.brandAvatar()),this.headerDot=a("span",{class:"dot"}),this.headerName=a("div",{class:"hn"},e.appName||t.title),this.headerStatus=a("div",{class:"hs"},t.offline),this.endBtn=a("button",{class:"hb hide",type:"button",title:t.endChat,"aria-label":t.endChat,onclick:()=>e.actions.endChat()},y("done",19));let o=a("div",{class:"hd"},a("div",{class:"av"},this.headerPhoto,this.headerDot),a("div",{class:"hi"},this.headerName,this.headerStatus),a("div",{class:"ha"},this.endBtn,a("button",{class:"hb",type:"button",title:t.close,"aria-label":t.close,onclick:()=>e.actions.close()},y("close",20))));this.dragBar=a("div",{class:"drag","aria-hidden":"true"},a("i")),this.banner=a("div",{class:"bn"}),this.body=a("div",{class:"bd"}),this.grip=a("div",{class:"gp",title:t.resize,"aria-hidden":"true"}),this.panel=a("div",{class:"pn",role:"dialog","aria-modal":"false","aria-label":t.title},a("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=D())==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?(ye(this.key(fe)),this.hideTeaser(false),this.hideToast(),this.lockScroll(),this.bindViewport(),requestAnimationFrame(()=>{var i;this.list&&z(this.list),S()||(i=this.textarea)==null||i.focus();})):(this.unlockScroll(),(t=D())==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 r;let i=this.o.t;this.agent=e,this.online=(r=e==null?void 0:e.online)!=null?r:t;let n=(e==null?void 0:e.name)||this.o.appName||i.title;this.headerName.textContent=n,k(this.headerPhoto),this.headerPhoto.appendChild(e?C(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&&(k(this.typingAvatar),this.typingAvatar.appendChild(C(e==null?void 0:e.avatar,n)));}setBanner(e,t=false){k(this.banner),this.banner.className=`bn${t?" err":""}${e?" on":""}`,e&&(this.banner.appendChild(y(t?"close":"chat",15)),this.banner.appendChild(a("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,k(this.body);let n=ve("text",t.name,e.name||"","name"),r=ve("email",t.email,e.email||"","email"),o=this.o.topics||[],l=o.length?a("select",{"aria-label":t.topicLabel},a("option",{value:""},t.topicPlaceholder),...o.map(p=>a("option",{value:p.slug},p.name))):null,d=l?a("div",{class:"fld"},l,a("label",null,t.topicLabel),a("span",{class:"cv"},y("chevron",16))):null,c=()=>{let p=n.input.value.trim(),u=r.input.value.trim();if(i.required&&(i.name&&!p||i.email&&!u)){let m=i.name&&!p?n:r;m.wrap.classList.add("bad"),m.input.focus();return}if(u&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u)){r.wrap.classList.add("bad"),r.input.focus();return}this.o.actions.submitPrechat(p,u,(l==null?void 0:l.value)||null);},h=a("form",{class:"fm",onsubmit:p=>{p.preventDefault(),c();}},a("h3",null,t.prechatTitle),a("p",null,this.o.settings.greeting||t.prechatHint),i.name?n.wrap:null,i.email?r.wrap:null,d,a("button",{class:"btn",type:"submit"},t.start),i.required?null:a("button",{class:"btn gh",type:"button",onclick:()=>this.o.actions.skipPrechat((l==null?void 0:l.value)||null)},t.skip));this.body.appendChild(h),S()||setTimeout(()=>(i.name?n.input:r.input).focus(),60);}showChat(){var t,i;if(this.view==="chat"&&this.list)return;let e=this.o.t;this.view="chat",k(this.body),this.list=a("div",{class:"ml"}),this.list.addEventListener("scroll",()=>this.syncJump(),{passive:true}),this.jumpBtn=a("button",{class:"jump",type:"button","aria-label":e.jump,onclick:()=>this.list&&z(this.list,true)},y("down",14),a("span",null,e.jump)),this.typingAvatar=a("div",{class:"av"},C((t=this.agent)==null?void 0:t.avatar,((i=this.agent)==null?void 0:i.name)||this.o.appName)),this.typingEl=a("div",{class:"tp","aria-live":"polite"},this.typingAvatar,a("div",{class:"dots"},a("i"),a("i"),a("i"))),this.notice=a("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(a("div",{class:"drop"},y("image",26),a("span",null,e.dropHere)));}showRating(){let e=this.o.t;this.view="rating",this.list=null,this.textarea=null,k(this.body);let t=0,i=[],n=a("div",{class:"rl"}),r=()=>{i.forEach((c,h)=>c.classList.toggle("on",h<t)),n.textContent=t?e.rateScale[t-1]:"";},o=a("div",{class:"stars"});for(let c=1;c<=5;c++){let h=a("button",{type:"button","aria-label":String(c),onclick:()=>{t=c,r();}},y("star",32));i.push(h),o.appendChild(h);}let l=a("textarea",{placeholder:e.rateComment,rows:3}),d=a("form",{class:"fm",onsubmit:c=>{c.preventDefault(),this.o.actions.rate(t,l.value.trim());}},a("h3",{style:"text-align:center"},e.rateTitle),o,n,l,a("button",{class:"btn",type:"submit"},e.rateSend),a("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,k(this.body);let i=a("div",{class:"ok"},a("div",{class:"ic"},y("done",30)),a("h3",null,t.rateThanksTitle),a("p",null,t.rateThanks));e!=null&&e.url&&(i.appendChild(a("p",{style:"margin-top:16px"},t.reviewIntro)),i.appendChild(a("a",{class:"btn",href:e.url,target:"_blank",rel:"noopener noreferrer"},e.label||t.reviewCta))),i.appendChild(a("button",{class:"btn gh",type:"button",onclick:()=>this.o.actions.newChat()},t.newChat)),this.body.appendChild(i);}render(e){var t,i;this.list&&(be(this.list,{...e,t:this.o.t,locale:this.o.locale,actions:this.o.actions,agentAvatar:((t=this.agent)==null?void 0:t.avatar)||A(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&&O(this.list,120)&&z(this.list,true));}setNotice(e,t){this.notice&&(k(this.notice),this.notice.classList.toggle("on",!!e),e&&(this.notice.appendChild(document.createTextNode(e)),t&&this.notice.appendChild(a("button",{type:"button",onclick:t.fn},t.label))));}setReply(e){var i;if(this.replyTo=e,!this.replyBar||(k(this.replyBar),this.replyBar.classList.toggle("on",!!e),!e))return;let t=e.sender_type==="visitor"?this.o.t.you:e.sender_name||this.o.t.agent;this.replyBar.appendChild(y("reply",14)),this.replyBar.appendChild(a("span",{class:"rt"},`${this.o.t.replyingTo} ${t}: ${$(e,this.o.t)}`)),this.replyBar.appendChild(a("button",{type:"button","aria-label":this.o.t.cancel,onclick:()=>this.setReply(null)},y("close",14))),(i=this.textarea)==null||i.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(),k(this.replyBar),this.replyBar.classList.add("on"),this.replyBar.appendChild(a("span",{class:"rt"},`${this.o.t.edit}: ${$(e,this.o.t)}`)),this.replyBar.appendChild(a("button",{type:"button","aria-label":this.o.t.cancel,onclick:()=>this.cancelEdit()},y("close",14))));}buildComposer(){let e=this.o.t;this.replyBar=a("div",{class:"rq"}),this.chips=a("div",{class:"chips"}),this.textarea=a("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 r=Array.from(((o=n.clipboardData)==null?void 0:o.files)||[]);r.length&&(n.preventDefault(),this.addFiles(r));}});let t=a("input",{type:"file",multiple:true,style:"display:none",accept:this.allowedMimes.join(","),onchange:()=>{this.addFiles(Array.from(t.files||[])),t.value="";}});return this.emojiBox=a("div",{class:"emj"},...ge.map(n=>a("button",{type:"button",onclick:()=>this.insertEmoji(n)},n))),this.sendBtn=a("button",{class:"cb sd",type:"button",title:e.send,"aria-label":e.send,disabled:true,onclick:()=>this.submit()},y("send",17)),this.counter=a("div",{class:"cnt"}),a("div",{class:"cp"},this.emojiBox,this.replyBar,this.chips,this.counter,a("div",{class:"cr"},a("button",{class:"cb",type:"button",title:e.attach,"aria-label":e.attach,onclick:()=>t.click()},y("clip",19)),this.textarea,a("button",{class:"cb",type:"button",title:e.emoji,"aria-label":e.emoji,onclick:n=>{n.stopPropagation(),this.toggleEmoji();}},y("smile",19)),this.sendBtn),t,a("div",{class:"pw"},a("a",{href:"https://signalbird.io",target:"_blank",rel:"noopener",title:e.poweredBy},a("span",{class:"pk"},W(13)),a("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(R(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),S()||this.textarea.focus();}cancelEdit(){this.editing=null,this.textarea&&(this.textarea.value="",this.autosize(),this.syncSend()),this.replyBar&&(k(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(R(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&&(k(this.chips),this.chips.classList.toggle("on",this.files.length>0),this.files.forEach((e,t)=>{this.chips.appendChild(a("div",{class:"chip"},e.type.startsWith("image/")?a("img",{src:URL.createObjectURL(e),alt:""}):y("file",16),a("span",null,e.name),a("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<=Ye;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,r;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((r=t.selectionEnd)!=null?r: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",!O(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 a("div",{class:"teaser",role:"button",tabindex:0,onclick:()=>{this.hideTeaser(true),this.o.actions.open();}},a("div",{class:"tv"},this.brandAvatar()),a("div",{class:"tc"},a("div",{class:"tn"},this.o.appName||e.title),a("div",{class:"tb"},t.greeting||e.greeting)),a("button",{class:"tx",type:"button","aria-label":e.close,onclick:i=>{i.stopPropagation(),this.hideTeaser(true);}},y("close",13)))}buildToast(){return a("div",{class:"toast",role:"button",tabindex:0,onclick:()=>{this.hideToast(),this.o.actions.open();}},a("div",{class:"tv"}),a("div",{class:"tc"},a("div",{class:"tn"}),a("div",{class:"tb"})))}scheduleTeaser(){xe(this.key(me))||xe(this.key(fe))||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");},qe));}hideTeaser(e){this.teaserTimer&&clearTimeout(this.teaserTimer),this.teaserTimer=null,this.wrap.classList.remove("tz"),e&&ye(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"),r=this.toast.querySelector(".tb");k(i),i.appendChild(C(e.avatar||((l=this.agent)==null?void 0:l.avatar),t)),n.textContent=t,r.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(),Ge);}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:Fe}get maxChars(){let e=Number(this.o.settings.max_message_chars);return Number.isFinite(e)&&e>0?e:Ue}quickStarters(){return (this.o.topics||[]).slice(0,4).map(e=>e.name).filter(Boolean)}bindViewport(){let e=D();e&&(e.addEventListener("resize",this.onViewport),this.onViewport());}onViewport(){let e=D();if(!e||!S())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&&z(this.list));}lockScroll(){if(this.locked||!S())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",r),removeEventListener("pointerup",n),removeEventListener("pointercancel",n));},r=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=>{S()&&(i=true,e=o.clientY,t=0,this.wrap.classList.add("dragging"),addEventListener("pointermove",r),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=A(e.logo_url);return e.launcher_icon==="logo"&&t?a("img",{class:"lg",src:t,alt:""}):e.launcher_icon==="chat"?y("chat",25):W(27)}brandAvatar(){let e=A(this.o.settings.logo_url);return e?a("img",{src:e,alt:""}):document.createTextNode(B(this.o.appName))}restoreGeometry(){let e=We();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(){Je({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||S()||t.target.closest("button"))return;let i=t.clientX,n=t.clientY,r=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=p=>{let u=p.clientX-i,m=p.clientY-n;if(!d&&Math.abs(u)+Math.abs(m)<4)return;d=true,this.wrap.classList.add("moving");let f=Math.max(0,innerWidth-this.panel.offsetWidth-24),x=Math.max(0,innerHeight-this.panel.offsetHeight-24);this.wrap.style.setProperty("--sb-dx",`${V(r-u*l,0,f)}px`),this.wrap.style.setProperty("--sb-dy",`${V(o-m,0,x)}px`);},h=()=>{removeEventListener("pointermove",c),removeEventListener("pointerup",h),this.wrap.classList.remove("moving"),d&&this.saveGeometry();};addEventListener("pointermove",c),addEventListener("pointerup",h);});}enableResize(){this.grip.addEventListener("pointerdown",e=>{if(e.button!==0||S())return;e.preventDefault();let t=e.clientX,i=e.clientY,n=this.panel.offsetWidth,r=this.panel.offsetHeight,o=this.wrap.classList.contains("left")?-1:1;this.wrap.classList.add("sizing");let l=c=>{this.panel.style.width=`${V(n+(t-c.clientX)*o,340,innerWidth-40)}px`,this.panel.style.height=`${V(r+(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 ve(s,e,t,i){let n=a("input",{type:s,value:t,autocomplete:i,placeholder:" "});return t&&n.classList.add("has"),n.addEventListener("input",()=>{var r;n.classList.toggle("has",n.value.length>0),(r=n.parentElement)==null||r.classList.remove("bad");}),{wrap:a("div",{class:"fld"},n,a("label",null,e)),input:n}}var we="sb_geometry";function We(){try{let s=localStorage.getItem(we);if(!s)return null;let e=JSON.parse(s);return !e||e.w>innerWidth||e.h>innerHeight?null:e}catch(s){return null}}function Je(s){try{localStorage.setItem(we,JSON.stringify(s));}catch(e){}}function ye(s){try{localStorage.setItem(s,"1");}catch(e){}}function xe(s){try{return localStorage.getItem(s)==="1"}catch(e){return false}}function V(s,e,t){return Math.min(Math.max(s,e),t)}function S(){return innerWidth<=640}function D(){return typeof window!="undefined"&&window.visualViewport||null}function Xe(s){return s==="dark"?true:s!=="auto"||typeof matchMedia!="function"?false:matchMedia("(prefers-color-scheme: dark)").matches}function Ze(s){return s&&/^(#[0-9a-f]{3,8}|rgba?\([\d\s.,%]+\)|hsla?\([\d\s.,%]+\))$/i.test(s)?s:"#4f46e5"}var F=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 _=null;function Q(){try{let s=window.AudioContext||window.webkitAudioContext;if(!s)return;_||(_=new s),_.state==="suspended"&&_.resume();let e=_.currentTime,t=_.createGain();t.gain.setValueAtTime(1e-4,e),t.gain.exponentialRampToValueAtTime(.12,e+.02),t.gain.exponentialRampToValueAtTime(1e-4,e+.35),t.connect(_.destination);let i=_.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 Qe="https://live.signalbird.io/api",T="/v1/sdk/chat/conversations",U=class{constructor(e){this.opts=e;this.title=new F;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||Qe).replace(/\/$/,""),this.store=new N(e.publicKey),this.api=new j(this.baseUrl,e.publicKey,e.chatKey,()=>this.store.secret,(...t)=>this.log(...t)),this.poller=new H(()=>this.tick()),this.identity=e.user&&(e.user.name||e.user.email||e.user.external_id)?e.user:null,this.locale=X(null,e.locale),this.t=Z(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 h;let e=await this.api.post("/v1/sdk/bootstrap",{page_url:location.href,locale:this.opts.locale});if(!e.ok||!((h=e.data)!=null&&h.app)){this.log("bootstrap failed",e);return}if(this.destroyed)return;let{app:t,online:i,within_hours:n,visitor:r,conversation:o,topics:l,realtime:d}=e.data;if(!t.chat_enabled){this.log("chat disabled for app");return}this.settings=t.chat||{},this.appName=t.name||"",this.locale=X(this.settings.locale,this.opts.locale),this.t=Z(this.locale),this.store.visitor&&!r&&this.store.clearVisitor(),r&&this.store.setVisitor({id:r.id,name:r.name,email:r.email}),this.store.online=!!i,this.store.withinHours=n!==false,o&&this.store.setConversation(o);let c=Number(this.settings.max_attachment_mb||t.max_attachment_mb||10);this.ui=new K({t:this.t,locale:this.locale,publicKey:this.opts.publicKey,settings:this.settings,appName:this.appName,maxMb:c,topics:l||[],actions:{open:()=>this.open(),close:()=>this.close(),send:(p,u,m)=>{this.send(p,u,m);},typing:p=>{this.typing(p);},submitPrechat:(p,u,m)=>{this.submitPrechat(p,u,m);},skipPrechat:p=>{this.topic=p,this.enterChat();},rate:(p,u)=>{this.rate(p,u);},dismiss:()=>this.dismiss(),endChat:()=>this.endChat(),newChat:()=>this.newChat(),saveEdit:(p,u)=>{this.saveEdit(p,u);},reply:p=>{var u;return (u=this.ui)==null?void 0:u.setReply(p)},react:(p,u)=>{this.react(p,u);},edit:p=>{var u;return (u=this.ui)==null?void 0:u.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((r==null?void 0:r.unread)||(o==null?void 0:o.visitor_unread)||0),this.syncUnread(),this.started=true,this.poller.start(),d!=null&&d.enabled&&(this.socket=new I(d,(p,u)=>this.authorizeChannel(p,u),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=>R(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")){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 r;if(await this.ready,this.destroyed)return;this.identity={...this.identity||{},...e},((r=this.ui)==null?void 0:r.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:ke(),...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 r,o;if(!this.ui||!this.settings)return;let e=this.settings.prechat,t=this.store.visitor;!!!((r=this.identity)!=null&&r.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 r;this.topic=i,await this.session({name:e||void 0,email:t||void 0})?this.enterChat():(r=this.ui)==null||r.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 r;let i=this.store.conversation,n=this.ratingMode;if(this.ratingMode=null,!(!i||!this.ui)){if(e>0){let o=await this.api.post(`${T}/${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(`${T}/${i.id}/close`);this.check(o),((r=this.store.conversation)==null?void 0:r.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,r,o,l;let t=(((n=this.settings)==null?void 0:n.review_url)||"").trim(),i=Number((o=(r=this.settings)==null?void 0:r.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:ke(),page_url:location.href,user_agent:navigator.userAgent});if(i.ok&&((n=i.data)!=null&&n.visitor)){let r=i.data.visitor;return !r.secret&&!this.store.visitor?(this.log("session returned no secret"),false):(this.store.setVisitor(r),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(`${T}/${e.id}`,{limit:50});this.applyPayload(t,true)&&this.store.isOpen&&!document.hidden&&this.store.setUnread(0);}applyPayload(e,t){var n,r,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,(r=this.ui)==null||r.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,h,p,u,m,f,x;if(!this.started||!this.store.visitor)return false;this.pollCount++;let e=this.store.conversation;if(this.store.isOpen&&e){let b=this.pollCount%5===0||this.forceFull;this.forceFull=false;let g=b?void 0:this.store.lastServerMessageId||void 0,L=await this.api.get(`${T}/${e.id}`,g?{after:g}:{limit:50}),w=this.applyPayload(L,!g);return w>0&&(document.hidden?(this.store.setUnread(this.store.unread+w),(d=this.settings)!=null&&d.sound&&Q()):this.markRead()),w>0}if(this.store.isOpen&&!e&&this.pollCount%10!==0)return false;let t=await this.api.get(T);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)||[],r=n.find(b=>b.status==="open")||null,o=n.reduce((b,g)=>b+(g.visitor_unread||0),0),l=o>this.store.unread;return r&&r.id!==((c=this.store.conversation)==null?void 0:c.id)&&(this.store.setConversation(r),this.store.isOpen&&this.loadConversation()),(!this.store.isOpen||document.hidden)&&(this.store.setUnread(o),l&&((h=this.settings)!=null&&h.sound&&Q(),(x=this.ui)==null||x.attention({name:((p=r==null?void 0:r.agent)==null?void 0:p.name)||((u=this.store.agent)==null?void 0:u.name)||this.t.agent,avatar:((m=r==null?void 0:r.agent)==null?void 0:m.avatar)||((f=this.store.agent)==null?void 0:f.avatar)||null,body:(r==null?void 0:r.last_message_sender)==="agent"&&(r==null?void 0:r.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(`${T}/${e.id}/read`,{last_message_id:t},true));}async send(e,t,i,n=le()){var l;let r={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(r);let o=()=>{let d=this.store.find(r.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 m=await this.api.post(T,{body:e,page_url:location.href,client_id:n,...this.topic?{topic:this.topic}:{}});if(!m.ok)return this.sendFailed(m,o);this.store.setConversation(m.data.conversation),this.store.mergeMessages(m.data.messages||[]),this.reconcile(r,m.data.messages),this.pendingSends.delete(n),this.poller.poke(3e3);return}if(c){let m=await this.api.post(T,{page_url:location.href,...this.topic?{topic:this.topic}:{}});if(!m.ok)return this.sendFailed(m,o);this.store.setConversation(m.data.conversation),this.store.mergeMessages(m.data.messages||[]),d=m.data.conversation;}if(!d)return o();let h=[];for(let m of t){let f=await this.api.upload(`${T}/${d.id}/attachments`,m);if(!f.ok)return this.sendFailed(f,o);h.push(f.data);}let p=await this.api.post(`${T}/${d.id}/messages`,{body:e||void 0,attachments:h.length?h:void 0,reply_to_id:(i==null?void 0:i.id)||void 0,client_id:n});if(!p.ok)return this.sendFailed(p,o);let u=((l=p.data)==null?void 0:l.message)||p.data;this.reconcile(r,[u]),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(`${T}/${t.id}/typing`,{is_typing:e},true));}async react(e,t){var c,h,p,u;let i=this.store.conversation;if(!i)return;let n={...e.reactions||{}},r=[...n[t]||[]],o=r.indexOf("visitor");o>=0?r.splice(o,1):r.push("visitor"),n[t]=r,this.store.upsertMessage({...e,reactions:n});let l=await this.api.post(`${T}/${i.id}/messages/${e.id}/reactions`,{emoji:t});if(!l.ok){this.check(l),this.store.upsertMessage({...e});return}let d=(u=(h=(c=l.data)==null?void 0:c.message)==null?void 0:h.reactions)!=null?u:(p=l.data)==null?void 0:p.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(`${T}/${i.id}/messages/${e.id}`,{body:t});if(!n.ok){this.check(n),this.store.upsertMessage({...e});return}let r=((o=n.data)==null?void 0:o.message)||n.data;r&&r.id&&this.store.upsertMessage(r);}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(`${T}/${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 ke(){var s;try{return ((s=navigator.languages)==null?void 0:s[0])||navigator.language||void 0}catch(e){return}}var et={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 tt(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 it(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 Te(s){var u,m;let e=et[(u=s.language)!=null?u:"tr"],t=new Map,i=null,n=null,r=null,o=(m=s.theme)!=null?m:"auto",l=false,d=(f,x)=>{var b;(b=t.get(f))==null||b.forEach(g=>{try{g(x);}catch(L){console.warn("[signalbird]",L);}});},c=()=>{r&&(window.removeEventListener("message",r),r=null),n=null,i&&(i.textContent="");},h=(f,x)=>{var L;if(!i)return;i.textContent="";let b=document.createElement("div");b.setAttribute("data-signalbird-status",""),b.style.cssText=`display:flex;align-items:center;justify-content:center;gap:12px;min-height:${(L=s.minHeight)!=null?L:220}px;font:13px/1.5 system-ui,-apple-system,sans-serif;color:#6b7280;text-align:center;padding:24px;`;let g=document.createElement("span");if(g.textContent=f,b.appendChild(g),x){let w=document.createElement("button");w.type="button",w.textContent=e.retry,w.style.cssText="border:1px solid currentColor;border-radius:8px;background:transparent;color:inherit;padding:4px 10px;font:inherit;cursor:pointer;",w.addEventListener("click",()=>{p();}),b.appendChild(w);}i.appendChild(b);},p=async()=>{var L;if(!i||l)return;c(),h(e.loading,false);let f=tt(o),x=null;try{s.url?(x=s.url,s={...s,url:void 0}):s.mint&&(x=it(await s.mint({module:s.module,theme:f,locale:s.locale})));}catch(w){d("error",w),h(w instanceof Error?w.message:e.failed,true);return}if(!x){d("error",new Error("EMBED_URL_MISSING")),h(e.expired,!!s.mint);return}let b=x;try{let w=new URL(x);w.searchParams.set("theme",f),s.locale&&w.searchParams.set("locale",s.locale),s.accent&&w.searchParams.set("accent",s.accent.replace(/^#/,"")),b=w.toString();}catch(w){}let g=document.createElement("iframe");g.src=b,g.title="Signalbird",g.style.cssText="width:100%;border:0;display:block;",g.style.height=`${typeof s.height=="number"?s.height:(L=s.minHeight)!=null?L:640}px`,g.setAttribute("allow","clipboard-write; fullscreen; autoplay"),g.setAttribute("sandbox","allow-same-origin allow-scripts allow-forms allow-popups allow-downloads"),g.setAttribute("referrerpolicy","strict-origin-when-cross-origin"),g.setAttribute("loading","lazy"),s.className&&(g.className=s.className),i.textContent="",i.appendChild(g),n=g,r=w=>{var ee,te;if(!n||w.source!==n.contentWindow)return;let M=w.data;if(!(!M||typeof M.type!="string")){if(M.type==="signalbird:ready"){d("ready",M.module);return}if(M.type==="signalbird:height"&&typeof M.px=="number"&&(d("height",M.px),((ee=s.height)!=null?ee:"auto")==="auto")){let Ee=Math.max(M.px,(te=s.minHeight)!=null?te:220);n.style.height=`${Ee}px`;}}},window.addEventListener("message",r);};return {async mount(f){let x=typeof f=="string"?document.querySelector(f):f;if(!(x instanceof HTMLElement))throw new Error("Signalbird: g\xF6mme kab\u0131 bulunamad\u0131 \u2014 "+String(f));i=x,l=false,await p();},refresh:()=>p(),async setTheme(f){o=f,await p();},destroy(){l=true,c(),t.clear(),i=null;},on(f,x){t.has(f)||t.set(f,new Set),t.get(f).add(x);},off(f,x){var b;(b=t.get(f))==null||b.delete(x);}}}var Pt="2.2.2",v=null,Y=[],P=null;function E(s,e){try{return s()}catch(t){try{console.warn("[signalbird]",t);}catch(i){}return e}}function Le(s){s.catch(()=>{});}function st(s){E(()=>{if(!s||!s.publicKey){console.warn("[signalbird] init: publicKey zorunlu");return}if(!(typeof document=="undefined"||typeof window=="undefined")){v&&v.destroy(),v=new U(s);for(let{event:e,fn:t}of Y)v.on(e,t);if(P){let e=P;P=null,Le(v.identify(e));}}},void 0);}function jt(s){E(()=>{if(s){if(!v){P={...P||{},...s};return}Le(v.identify(s));}},void 0);}var Nt={open(){E(()=>v==null?void 0:v.open(),void 0);},close(){E(()=>v==null?void 0:v.close(),void 0);},toggle(){E(()=>v==null?void 0:v.toggle(),void 0);},isOpen(){return E(()=>!!(v!=null&&v.isOpen()),false)},on(s,e){E(()=>{typeof e=="function"&&(Y.push({event:s,fn:e}),v==null||v.on(s,e));},void 0);},off(s,e){E(()=>{let t=Y.findIndex(i=>i.event===s&&i.fn===e);t>=0&&Y.splice(t,1),v==null||v.off(s,e);},void 0);}},Ht={register(s){return E(()=>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"}))}},It=Te;function Bt(){E(()=>{v==null||v.destroy(),v=null;},void 0);}E(()=>{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=()=>st({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);
489
+ `;function a(s,e,...t){let i=document.createElement(s);if(e)for(let n in e){let r=e[n];r==null||r===false||(n==="class"?i.className=String(r):n==="style"?i.setAttribute("style",String(r)):n.startsWith("on")&&typeof r=="function"?i.addEventListener(n.slice(2).toLowerCase(),r):n==="html"?i.innerHTML=String(r):n in i&&n!=="list"&&n!=="form"?i[n]=r:i.setAttribute(n,String(r)));}return _e(i,t),i}function _e(s,e){for(let t of e)t==null||t===false||s.appendChild(typeof t=="object"?t:document.createTextNode(String(t)));}function k(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=ze[s],t}function W(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 ze={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"/>',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 B(s){return (s||"?").trim().split(/\s+/).slice(0,2).map(e=>e[0]||"").join("").toUpperCase()}function C(s,e){let t=A(s);return t?a("img",{src:t,alt:"",loading:"lazy"}):document.createTextNode(B(e))}function A(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}"],ge=["\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"],Ae=900*1e3,Re=300*1e3;function be(s,e){let t=O(s),i=s.childNodes.length===0,n=Pe(s);if(k(s),e.messages.length===0){s.appendChild(je(e));return}let r="";for(let o=0;o<e.messages.length;o++){let l=e.messages[o],d=J(l.created_at),c=d===r&&e.messages[o-1]||null,h=e.messages[o+1]||null;d!==r&&(s.appendChild(a("div",{class:"day"},$e(l.created_at,e))),r=d),s.appendChild(Ne(l,e,c,He(l,h)?h:null,!i&&!n.has(l.id)));}(t||i)&&z(s);}function O(s,e=60){return s.scrollHeight-s.scrollTop-s.clientHeight<e}function z(s,e=false){if(e&&typeof s.scrollTo=="function"){s.scrollTo({top:s.scrollHeight,behavior:"smooth"});return}s.scrollTop=s.scrollHeight;}function Pe(s){let e=new Set;return s.querySelectorAll("[data-id]").forEach(t=>{let i=t.dataset.id;i&&e.add(i);}),e}function je(s){let e=a("div",{class:"hero"});e.appendChild(a("div",{class:"hv"},a("span",null,C(s.agentAvatar,s.brandName||s.agentName)))),e.appendChild(a("h4",null,s.greeting||s.t.greeting)),s.responseHint&&e.appendChild(a("p",null,s.responseHint));let t=s.quick||[];if(t.length&&s.onQuick){let i=a("div",{class:"qk"});for(let n of t.slice(0,6))i.appendChild(a("button",{type:"button",onclick:()=>s.onQuick(n)},n));e.appendChild(i);}return e}function Ne(s,e,t,i,n){var x;let r=s.sender_type==="visitor"?"v":s.sender_type==="system"?"s":"a",o=!pe(t,s),l=!pe(s,i),d=a("div",{class:`row ${r}`+(o&&t?" gap":"")+(l?"":" mid")+(s._pending?" pend":"")+(s._failed?" fail":"")+(n?" new":""),"data-id":s.id});if(r==="s")return d.appendChild(a("div",{class:"bb"},s.body||"")),d;r==="a"&&d.appendChild(a("div",{class:`av${l?"":" gh"}`},C(e.agentAvatar,s.sender_name||e.agentName)));let c=a("div",{class:"cl"}),h=a("div",{class:`bb${s.deleted_at?" del":""}`});if(s.deleted_at)return h.textContent=e.t.deleted,c.appendChild(h),d.appendChild(c),d;if(s.reply_to_id){let b=e.find(s.reply_to_id),g=b?b.sender_type==="visitor"?e.t.you:b.sender_name||e.agentName:"";h.appendChild(a("span",{class:"q"},g?`${g}: `:"",b?$(b,e.t):"\u2026"));}if(s._files&&s._files.length){let b=a("div",{class:"imgs"});for(let g of s._files)g.type.startsWith("image/")?b.appendChild(a("img",{src:URL.createObjectURL(g),alt:g.name})):h.appendChild(ce({name:g.name,url:"",mime:g.type,size:g.size},e));b.childNodes.length&&h.appendChild(b);}let p=s.attachments||[],u=p.filter(b=>he(b.mime));if(u.length){let b=a("div",{class:"imgs"});for(let g of u)b.appendChild(a("img",{src:g.url,alt:g.name,loading:"lazy",onclick:()=>e.actions.openImage(g.url)}));h.appendChild(b);}for(let b of p.filter(g=>!he(g.mime)))h.appendChild(ce(b,e));let m=(r==="v"?null:(x=s.translation)==null?void 0:x.body)||s.body;m&&h.appendChild(Oe(m)),s._failed&&(h.appendChild(a("div",{style:"font-size:11px;margin-top:5px;font-weight:600"},e.t.failed)),h.addEventListener("click",()=>e.actions.retry(s))),c.appendChild(h);let f=s.reactions&&Object.keys(s.reactions).length?s.reactions:null;if(f){let b=a("div",{class:"rx"});for(let g in f){let L=f[g]||[];if(!L.length)continue;let w=L.includes("visitor");b.appendChild(a("button",{class:w?"me":"",type:"button",onclick:()=>e.actions.react(s,g)},`${g} ${L.length}`));}b.childNodes.length&&c.appendChild(b);}if(l){let b=a("div",{class:"mt"},Ve(s.created_at,e.locale));if(s.edited_at&&b.appendChild(a("span",{class:"ed"},`\xB7 ${e.t.edited}`)),r==="v"&&!s._failed){let g=a("span",{class:`tk${s.read_at?" rd":""}`});g.appendChild(s._pending?y("check",12):s.read_at||s.delivered_at?y("checks",13):y("check",12)),s._pending&&(g.style.opacity=".4"),b.appendChild(g);}c.appendChild(b);}return d.appendChild(c),!s._pending&&!s._failed&&(d.appendChild(Ie(s,e,d)),Be(d)),d}function pe(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<Re}function He(s,e){return !!e&&J(s.created_at)===J(e.created_at)}function Ie(s,e,t){let i=a("div",{class:"ac"});for(let o of de.slice(0,3))i.appendChild(a("button",{type:"button",title:e.t.react,onclick:()=>e.actions.react(s,o)},o));i.appendChild(a("button",{type:"button",title:e.t.reply,onclick:()=>e.actions.reply(s)},y("reply",15)));let n=a("div",{class:"menu"});for(let o of de.slice(3))n.appendChild(a("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)<Ae&&(n.appendChild(a("button",{type:"button",onclick:()=>{n.classList.remove("show"),e.actions.edit(s);}},e.t.edit)),n.appendChild(a("button",{type:"button",class:"dg",onclick:()=>{n.classList.remove("show"),e.actions.remove(s);}},e.t.delete))),i.appendChild(a("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 Be(s){let e=null,t=()=>{e=setTimeout(()=>{var r;s.classList.add("acts");try{(r=navigator.vibrate)==null||r.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 ce(s,e){return a("a",{class:"fr",href:s.url||void 0,target:"_blank",rel:"noopener"},y("file",18),a("span",{class:"fn"},s.name||e.t.attachment),a("span",{class:"fs"},oe(s.size||0)))}function Oe(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 r=n[1].replace(/[.,;:!?)]+$/,"");e.appendChild(a("a",{href:r,target:"_blank",rel:"noopener noreferrer nofollow"},r)),i=n.index+r.length;}return i<s.length&&e.appendChild(document.createTextNode(s.slice(i))),e}function $(s,e){var n,r;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=(r=s.attachments)==null?void 0:r[0];return i?`\u{1F4CE} ${i.name}`:"\u2026"}function he(s){return !!s&&s.startsWith("image/")}function J(s){let e=new Date(s);return `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function $e(s,e){let t=new Date(s),i=new Date,n=Math.round((ue(i)-ue(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(r){return t.toLocaleDateString()}}function ue(s){return new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime()}function Ve(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 De={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."},Ke={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 X(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 Z(s){return s==="tr"?De:Ke}function R(s,e){return s.replace(/\{(\w+)\}/g,(t,i)=>{var n;return String((n=e[i])!=null?n:"")})}var Fe=["image/jpeg","image/png","image/gif","image/webp"],Ue=420,Ye=60,qe=11e3,Ge=9e3,me="sb_teaser",fe="sb_seen",K=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=a("div",{id:"signalbird-widget"}),this.root=this.host.attachShadow({mode:"open"}),this.root.appendChild(a("style",null,ae));let i=e.settings.position==="left"?"left":"right",n=e.settings.layout==="sidebar"?" sidebar":"";if(this.wrap=a("div",{class:`sb ${i}${n}${Xe(e.settings.theme)?" dark":""}`,style:`--sb-c:${Ze(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=a("span",{class:"badge"});let r=e.settings.launcher_text;this.launcher=a("button",{class:`ln${r?"":" icon-only"}`,type:"button","aria-label":r||t.launcher,onclick:()=>this.onLauncher()},a("span",{class:"lm"},this.launcherMark()),r?a("span",{class:"lt"},r):null,a("span",{class:"ln-on"}),a("span",{class:"ln-pulse"}),this.badge),this.dismissBtn=a("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=a("div",{class:"ph"},this.brandAvatar()),this.headerDot=a("span",{class:"dot"}),this.headerName=a("div",{class:"hn"},e.appName||t.title),this.headerStatus=a("div",{class:"hs"},t.offline),this.endBtn=a("button",{class:"hb hide",type:"button",title:t.endChat,"aria-label":t.endChat,onclick:()=>e.actions.endChat()},y("done",19));let o=a("div",{class:"hd"},a("div",{class:"av"},this.headerPhoto,this.headerDot),a("div",{class:"hi"},this.headerName,this.headerStatus),a("div",{class:"ha"},this.endBtn,a("button",{class:"hb",type:"button",title:t.close,"aria-label":t.close,onclick:()=>e.actions.close()},y("close",20))));this.dragBar=a("div",{class:"drag","aria-hidden":"true"},a("i")),this.banner=a("div",{class:"bn"}),this.body=a("div",{class:"bd"}),this.grip=a("div",{class:"gp",title:t.resize,"aria-hidden":"true"}),this.panel=a("div",{class:"pn",role:"dialog","aria-modal":"false","aria-label":t.title},a("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=D())==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?(ye(this.key(fe)),this.hideTeaser(false),this.hideToast(),this.lockScroll(),this.bindViewport(),requestAnimationFrame(()=>{var i;this.list&&z(this.list),S()||(i=this.textarea)==null||i.focus();})):(this.unlockScroll(),(t=D())==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 r;let i=this.o.t;this.agent=e,this.online=(r=e==null?void 0:e.online)!=null?r:t;let n=(e==null?void 0:e.name)||this.o.appName||i.title;this.headerName.textContent=n,k(this.headerPhoto),this.headerPhoto.appendChild(e?C(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&&(k(this.typingAvatar),this.typingAvatar.appendChild(C(e==null?void 0:e.avatar,n)));}setBanner(e,t=false){k(this.banner),this.banner.className=`bn${t?" err":""}${e?" on":""}`,e&&(this.banner.appendChild(y(t?"close":"chat",15)),this.banner.appendChild(a("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,k(this.body);let n=ve("text",t.name,e.name||"","name"),r=ve("email",t.email,e.email||"","email"),o=this.o.topics||[],l=o.length?a("select",{"aria-label":t.topicLabel},a("option",{value:""},t.topicPlaceholder),...o.map(p=>a("option",{value:p.slug},p.name))):null,d=l?a("div",{class:"fld"},l,a("label",null,t.topicLabel),a("span",{class:"cv"},y("chevron",16))):null,c=()=>{let p=n.input.value.trim(),u=r.input.value.trim();if(i.required&&(i.name&&!p||i.email&&!u)){let m=i.name&&!p?n:r;m.wrap.classList.add("bad"),m.input.focus();return}if(u&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u)){r.wrap.classList.add("bad"),r.input.focus();return}this.o.actions.submitPrechat(p,u,(l==null?void 0:l.value)||null);},h=a("form",{class:"fm",onsubmit:p=>{p.preventDefault(),c();}},a("h3",null,t.prechatTitle),a("p",null,this.o.settings.greeting||t.prechatHint),i.name?n.wrap:null,i.email?r.wrap:null,d,a("button",{class:"btn",type:"submit"},t.start),i.required?null:a("button",{class:"btn gh",type:"button",onclick:()=>this.o.actions.skipPrechat((l==null?void 0:l.value)||null)},t.skip));this.body.appendChild(h),S()||setTimeout(()=>(i.name?n.input:r.input).focus(),60);}showChat(){var t,i;if(this.view==="chat"&&this.list)return;let e=this.o.t;this.view="chat",k(this.body),this.list=a("div",{class:"ml"}),this.list.addEventListener("scroll",()=>this.syncJump(),{passive:true}),this.jumpBtn=a("button",{class:"jump",type:"button","aria-label":e.jump,onclick:()=>this.list&&z(this.list,true)},y("down",14),a("span",null,e.jump)),this.typingAvatar=a("div",{class:"av"},C((t=this.agent)==null?void 0:t.avatar,((i=this.agent)==null?void 0:i.name)||this.o.appName)),this.typingEl=a("div",{class:"tp","aria-live":"polite"},this.typingAvatar,a("div",{class:"dots"},a("i"),a("i"),a("i"))),this.notice=a("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(a("div",{class:"drop"},y("image",26),a("span",null,e.dropHere)));}showRating(){let e=this.o.t;this.view="rating",this.list=null,this.textarea=null,k(this.body);let t=0,i=[],n=a("div",{class:"rl"}),r=()=>{i.forEach((c,h)=>c.classList.toggle("on",h<t)),n.textContent=t?e.rateScale[t-1]:"";},o=a("div",{class:"stars"});for(let c=1;c<=5;c++){let h=a("button",{type:"button","aria-label":String(c),onclick:()=>{t=c,r();}},y("star",32));i.push(h),o.appendChild(h);}let l=a("textarea",{placeholder:e.rateComment,rows:3}),d=a("form",{class:"fm",onsubmit:c=>{c.preventDefault(),this.o.actions.rate(t,l.value.trim());}},a("h3",{style:"text-align:center"},e.rateTitle),o,n,l,a("button",{class:"btn",type:"submit"},e.rateSend),a("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,k(this.body);let i=a("div",{class:"ok"},a("div",{class:"ic"},y("done",30)),a("h3",null,t.rateThanksTitle),a("p",null,t.rateThanks));e!=null&&e.url&&(i.appendChild(a("p",{style:"margin-top:16px"},t.reviewIntro)),i.appendChild(a("a",{class:"btn",href:e.url,target:"_blank",rel:"noopener noreferrer"},e.label||t.reviewCta))),i.appendChild(a("button",{class:"btn gh",type:"button",onclick:()=>this.o.actions.newChat()},t.newChat)),this.body.appendChild(i);}render(e){var t,i;this.list&&(be(this.list,{...e,t:this.o.t,locale:this.o.locale,actions:this.o.actions,agentAvatar:((t=this.agent)==null?void 0:t.avatar)||A(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&&O(this.list,120)&&z(this.list,true));}setNotice(e,t){this.notice&&(k(this.notice),this.notice.classList.toggle("on",!!e),e&&(this.notice.appendChild(document.createTextNode(e)),t&&this.notice.appendChild(a("button",{type:"button",onclick:t.fn},t.label))));}setReply(e){var i;if(this.replyTo=e,!this.replyBar||(k(this.replyBar),this.replyBar.classList.toggle("on",!!e),!e))return;let t=e.sender_type==="visitor"?this.o.t.you:e.sender_name||this.o.t.agent;this.replyBar.appendChild(y("reply",14)),this.replyBar.appendChild(a("span",{class:"rt"},`${this.o.t.replyingTo} ${t}: ${$(e,this.o.t)}`)),this.replyBar.appendChild(a("button",{type:"button","aria-label":this.o.t.cancel,onclick:()=>this.setReply(null)},y("close",14))),(i=this.textarea)==null||i.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(),k(this.replyBar),this.replyBar.classList.add("on"),this.replyBar.appendChild(a("span",{class:"rt"},`${this.o.t.edit}: ${$(e,this.o.t)}`)),this.replyBar.appendChild(a("button",{type:"button","aria-label":this.o.t.cancel,onclick:()=>this.cancelEdit()},y("close",14))));}buildComposer(){let e=this.o.t;this.replyBar=a("div",{class:"rq"}),this.chips=a("div",{class:"chips"}),this.textarea=a("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 r=Array.from(((o=n.clipboardData)==null?void 0:o.files)||[]);r.length&&(n.preventDefault(),this.addFiles(r));}});let t=a("input",{type:"file",multiple:true,style:"display:none",accept:this.allowedMimes.join(","),onchange:()=>{this.addFiles(Array.from(t.files||[])),t.value="";}});return this.emojiBox=a("div",{class:"emj"},...ge.map(n=>a("button",{type:"button",onclick:()=>this.insertEmoji(n)},n))),this.sendBtn=a("button",{class:"cb sd",type:"button",title:e.send,"aria-label":e.send,disabled:true,onclick:()=>this.submit()},y("send",17)),this.counter=a("div",{class:"cnt"}),a("div",{class:"cp"},this.emojiBox,this.replyBar,this.chips,this.counter,a("div",{class:"cr"},a("button",{class:"cb",type:"button",title:e.attach,"aria-label":e.attach,onclick:()=>t.click()},y("clip",19)),this.textarea,a("button",{class:"cb",type:"button",title:e.emoji,"aria-label":e.emoji,onclick:n=>{n.stopPropagation(),this.toggleEmoji();}},y("smile",19)),this.sendBtn),t,a("div",{class:"pw"},a("a",{href:"https://signalbird.io",target:"_blank",rel:"noopener",title:e.poweredBy},a("span",{class:"pk"},W(13)),a("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(R(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),S()||this.textarea.focus();}cancelEdit(){this.editing=null,this.textarea&&(this.textarea.value="",this.autosize(),this.syncSend()),this.replyBar&&(k(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(R(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&&(k(this.chips),this.chips.classList.toggle("on",this.files.length>0),this.files.forEach((e,t)=>{this.chips.appendChild(a("div",{class:"chip"},e.type.startsWith("image/")?a("img",{src:URL.createObjectURL(e),alt:""}):y("file",16),a("span",null,e.name),a("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<=Ye;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,r;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((r=t.selectionEnd)!=null?r: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",!O(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 a("div",{class:"teaser",role:"button",tabindex:0,onclick:()=>{this.hideTeaser(true),this.o.actions.open();}},a("div",{class:"tv"},this.brandAvatar()),a("div",{class:"tc"},a("div",{class:"tn"},this.o.appName||e.title),a("div",{class:"tb"},t.greeting||e.greeting)),a("button",{class:"tx",type:"button","aria-label":e.close,onclick:i=>{i.stopPropagation(),this.hideTeaser(true);}},y("close",13)))}buildToast(){return a("div",{class:"toast",role:"button",tabindex:0,onclick:()=>{this.hideToast(),this.o.actions.open();}},a("div",{class:"tv"}),a("div",{class:"tc"},a("div",{class:"tn"}),a("div",{class:"tb"})))}scheduleTeaser(){xe(this.key(me))||xe(this.key(fe))||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");},qe));}hideTeaser(e){this.teaserTimer&&clearTimeout(this.teaserTimer),this.teaserTimer=null,this.wrap.classList.remove("tz"),e&&ye(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"),r=this.toast.querySelector(".tb");k(i),i.appendChild(C(e.avatar||((l=this.agent)==null?void 0:l.avatar),t)),n.textContent=t,r.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(),Ge);}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:Fe}get maxChars(){let e=Number(this.o.settings.max_message_chars);return Number.isFinite(e)&&e>0?e:Ue}quickStarters(){return (this.o.topics||[]).slice(0,4).map(e=>e.name).filter(Boolean)}bindViewport(){let e=D();e&&(e.addEventListener("resize",this.onViewport),this.onViewport());}onViewport(){let e=D();if(!e||!S())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&&z(this.list));}lockScroll(){if(this.locked||!S())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",r),removeEventListener("pointerup",n),removeEventListener("pointercancel",n));},r=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=>{S()&&(i=true,e=o.clientY,t=0,this.wrap.classList.add("dragging"),addEventListener("pointermove",r),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=A(e.logo_url);return e.launcher_icon==="logo"&&t?a("img",{class:"lg",src:t,alt:""}):e.launcher_icon==="chat"?y("chat",25):W(27)}brandAvatar(){let e=A(this.o.settings.logo_url);return e?a("img",{src:e,alt:""}):document.createTextNode(B(this.o.appName))}restoreGeometry(){let e=We();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(){Je({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||S()||t.target.closest("button"))return;let i=t.clientX,n=t.clientY,r=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=p=>{let u=p.clientX-i,m=p.clientY-n;if(!d&&Math.abs(u)+Math.abs(m)<4)return;d=true,this.wrap.classList.add("moving");let f=Math.max(0,innerWidth-this.panel.offsetWidth-24),x=Math.max(0,innerHeight-this.panel.offsetHeight-24);this.wrap.style.setProperty("--sb-dx",`${V(r-u*l,0,f)}px`),this.wrap.style.setProperty("--sb-dy",`${V(o-m,0,x)}px`);},h=()=>{removeEventListener("pointermove",c),removeEventListener("pointerup",h),this.wrap.classList.remove("moving"),d&&this.saveGeometry();};addEventListener("pointermove",c),addEventListener("pointerup",h);});}enableResize(){this.grip.addEventListener("pointerdown",e=>{if(e.button!==0||S())return;e.preventDefault();let t=e.clientX,i=e.clientY,n=this.panel.offsetWidth,r=this.panel.offsetHeight,o=this.wrap.classList.contains("left")?-1:1;this.wrap.classList.add("sizing");let l=c=>{this.panel.style.width=`${V(n+(t-c.clientX)*o,340,innerWidth-40)}px`,this.panel.style.height=`${V(r+(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 ve(s,e,t,i){let n=a("input",{type:s,value:t,autocomplete:i,placeholder:" "});return t&&n.classList.add("has"),n.addEventListener("input",()=>{var r;n.classList.toggle("has",n.value.length>0),(r=n.parentElement)==null||r.classList.remove("bad");}),{wrap:a("div",{class:"fld"},n,a("label",null,e)),input:n}}var we="sb_geometry";function We(){try{let s=localStorage.getItem(we);if(!s)return null;let e=JSON.parse(s);return !e||e.w>innerWidth||e.h>innerHeight?null:e}catch(s){return null}}function Je(s){try{localStorage.setItem(we,JSON.stringify(s));}catch(e){}}function ye(s){try{localStorage.setItem(s,"1");}catch(e){}}function xe(s){try{return localStorage.getItem(s)==="1"}catch(e){return false}}function V(s,e,t){return Math.min(Math.max(s,e),t)}function S(){return innerWidth<=640}function D(){return typeof window!="undefined"&&window.visualViewport||null}function Xe(s){return s==="dark"?true:s!=="auto"||typeof matchMedia!="function"?false:matchMedia("(prefers-color-scheme: dark)").matches}function Ze(s){return s&&/^(#[0-9a-f]{3,8}|rgba?\([\d\s.,%]+\)|hsla?\([\d\s.,%]+\))$/i.test(s)?s:"#4f46e5"}var F=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 _=null;function Q(){try{let s=window.AudioContext||window.webkitAudioContext;if(!s)return;_||(_=new s),_.state==="suspended"&&_.resume();let e=_.currentTime,t=_.createGain();t.gain.setValueAtTime(1e-4,e),t.gain.exponentialRampToValueAtTime(.12,e+.02),t.gain.exponentialRampToValueAtTime(1e-4,e+.35),t.connect(_.destination);let i=_.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 Qe="https://live.signalbird.io/api",T="/v1/sdk/chat/conversations",U=class{constructor(e){this.opts=e;this.title=new F;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||Qe).replace(/\/$/,""),this.store=new N(e.publicKey),this.api=new j(this.baseUrl,e.publicKey,e.chatKey,()=>this.store.secret,(...t)=>this.log(...t)),this.poller=new H(()=>this.tick()),this.identity=e.user&&(e.user.name||e.user.email||e.user.external_id)?e.user:null,this.locale=X(null,e.locale),this.t=Z(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 h;let e=await this.api.post("/v1/sdk/bootstrap",{page_url:location.href,locale:this.opts.locale});if(!e.ok||!((h=e.data)!=null&&h.app)){this.log("bootstrap failed",e);return}if(this.destroyed)return;let{app:t,online:i,within_hours:n,visitor:r,conversation:o,topics:l,realtime:d}=e.data;if(!t.chat_enabled){this.log("chat disabled for app");return}this.settings=t.chat||{},this.appName=t.name||"",this.locale=X(this.settings.locale,this.opts.locale),this.t=Z(this.locale),this.store.visitor&&!r&&this.store.clearVisitor(),r&&this.store.setVisitor({id:r.id,name:r.name,email:r.email}),this.store.online=!!i,this.store.withinHours=n!==false,o&&this.store.setConversation(o);let c=Number(this.settings.max_attachment_mb||t.max_attachment_mb||10);this.ui=new K({t:this.t,locale:this.locale,publicKey:this.opts.publicKey,settings:this.settings,appName:this.appName,maxMb:c,topics:l||[],actions:{open:()=>this.open(),close:()=>this.close(),send:(p,u,m)=>{this.send(p,u,m);},typing:p=>{this.typing(p);},submitPrechat:(p,u,m)=>{this.submitPrechat(p,u,m);},skipPrechat:p=>{this.topic=p,this.enterChat();},rate:(p,u)=>{this.rate(p,u);},dismiss:()=>this.dismiss(),endChat:()=>this.endChat(),newChat:()=>this.newChat(),saveEdit:(p,u)=>{this.saveEdit(p,u);},reply:p=>{var u;return (u=this.ui)==null?void 0:u.setReply(p)},react:(p,u)=>{this.react(p,u);},edit:p=>{var u;return (u=this.ui)==null?void 0:u.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((r==null?void 0:r.unread)||(o==null?void 0:o.visitor_unread)||0),this.syncUnread(),this.started=true,this.poller.start(),d!=null&&d.enabled&&(this.socket=new I(d,(p,u)=>this.authorizeChannel(p,u),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=>R(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")){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 r;if(await this.ready,this.destroyed)return;this.identity={...this.identity||{},...e},((r=this.ui)==null?void 0:r.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:ke(),...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 r,o;if(!this.ui||!this.settings)return;let e=this.settings.prechat,t=this.store.visitor;!!!((r=this.identity)!=null&&r.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 r;this.topic=i,await this.session({name:e||void 0,email:t||void 0})?this.enterChat():(r=this.ui)==null||r.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 r;let i=this.store.conversation,n=this.ratingMode;if(this.ratingMode=null,!(!i||!this.ui)){if(e>0){let o=await this.api.post(`${T}/${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(`${T}/${i.id}/close`);this.check(o),((r=this.store.conversation)==null?void 0:r.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,r,o,l;let t=(((n=this.settings)==null?void 0:n.review_url)||"").trim(),i=Number((o=(r=this.settings)==null?void 0:r.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:ke(),page_url:location.href,user_agent:navigator.userAgent});if(i.ok&&((n=i.data)!=null&&n.visitor)){let r=i.data.visitor;return !r.secret&&!this.store.visitor?(this.log("session returned no secret"),false):(this.store.setVisitor(r),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(`${T}/${e.id}`,{limit:50});this.applyPayload(t,true)&&this.store.isOpen&&!document.hidden&&this.store.setUnread(0);}applyPayload(e,t){var n,r,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,(r=this.ui)==null||r.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,h,p,u,m,f,x;if(!this.started||!this.store.visitor)return false;this.pollCount++;let e=this.store.conversation;if(this.store.isOpen&&e){let b=this.pollCount%5===0||this.forceFull;this.forceFull=false;let g=b?void 0:this.store.lastServerMessageId||void 0,L=await this.api.get(`${T}/${e.id}`,g?{after:g}:{limit:50}),w=this.applyPayload(L,!g);return w>0&&(document.hidden?(this.store.setUnread(this.store.unread+w),(d=this.settings)!=null&&d.sound&&Q()):this.markRead()),w>0}if(this.store.isOpen&&!e&&this.pollCount%10!==0)return false;let t=await this.api.get(T);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)||[],r=n.find(b=>b.status==="open")||null,o=n.reduce((b,g)=>b+(g.visitor_unread||0),0),l=o>this.store.unread;return r&&r.id!==((c=this.store.conversation)==null?void 0:c.id)&&(this.store.setConversation(r),this.store.isOpen&&this.loadConversation()),(!this.store.isOpen||document.hidden)&&(this.store.setUnread(o),l&&((h=this.settings)!=null&&h.sound&&Q(),(x=this.ui)==null||x.attention({name:((p=r==null?void 0:r.agent)==null?void 0:p.name)||((u=this.store.agent)==null?void 0:u.name)||this.t.agent,avatar:((m=r==null?void 0:r.agent)==null?void 0:m.avatar)||((f=this.store.agent)==null?void 0:f.avatar)||null,body:(r==null?void 0:r.last_message_sender)==="agent"&&(r==null?void 0:r.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(`${T}/${e.id}/read`,{last_message_id:t},true));}async send(e,t,i,n=le()){var l;let r={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(r);let o=()=>{let d=this.store.find(r.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 m=await this.api.post(T,{body:e,page_url:location.href,client_id:n,...this.topic?{topic:this.topic}:{}});if(!m.ok)return this.sendFailed(m,o);this.store.setConversation(m.data.conversation),this.store.mergeMessages(m.data.messages||[]),this.reconcile(r,m.data.messages),this.pendingSends.delete(n),this.poller.poke(3e3);return}if(c){let m=await this.api.post(T,{page_url:location.href,...this.topic?{topic:this.topic}:{}});if(!m.ok)return this.sendFailed(m,o);this.store.setConversation(m.data.conversation),this.store.mergeMessages(m.data.messages||[]),d=m.data.conversation;}if(!d)return o();let h=[];for(let m of t){let f=await this.api.upload(`${T}/${d.id}/attachments`,m);if(!f.ok)return this.sendFailed(f,o);h.push(f.data);}let p=await this.api.post(`${T}/${d.id}/messages`,{body:e||void 0,attachments:h.length?h:void 0,reply_to_id:(i==null?void 0:i.id)||void 0,client_id:n});if(!p.ok)return this.sendFailed(p,o);let u=((l=p.data)==null?void 0:l.message)||p.data;this.reconcile(r,[u]),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(`${T}/${t.id}/typing`,{is_typing:e},true));}async react(e,t){var c,h,p,u;let i=this.store.conversation;if(!i)return;let n={...e.reactions||{}},r=[...n[t]||[]],o=r.indexOf("visitor");o>=0?r.splice(o,1):r.push("visitor"),n[t]=r,this.store.upsertMessage({...e,reactions:n});let l=await this.api.post(`${T}/${i.id}/messages/${e.id}/reactions`,{emoji:t});if(!l.ok){this.check(l),this.store.upsertMessage({...e});return}let d=(u=(h=(c=l.data)==null?void 0:c.message)==null?void 0:h.reactions)!=null?u:(p=l.data)==null?void 0:p.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(`${T}/${i.id}/messages/${e.id}`,{body:t});if(!n.ok){this.check(n),this.store.upsertMessage({...e});return}let r=((o=n.data)==null?void 0:o.message)||n.data;r&&r.id&&this.store.upsertMessage(r);}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(`${T}/${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 ke(){var s;try{return ((s=navigator.languages)==null?void 0:s[0])||navigator.language||void 0}catch(e){return}}var et={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 tt(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 it(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 Te(s){var u,m;let e=et[(u=s.language)!=null?u:"tr"],t=new Map,i=null,n=null,r=null,o=(m=s.theme)!=null?m:"auto",l=false,d=(f,x)=>{var b;(b=t.get(f))==null||b.forEach(g=>{try{g(x);}catch(L){console.warn("[signalbird]",L);}});},c=()=>{r&&(window.removeEventListener("message",r),r=null),n=null,i&&(i.textContent="");},h=(f,x)=>{var L;if(!i)return;i.textContent="";let b=document.createElement("div");b.setAttribute("data-signalbird-status",""),b.style.cssText=`display:flex;align-items:center;justify-content:center;gap:12px;min-height:${(L=s.minHeight)!=null?L:220}px;font:13px/1.5 system-ui,-apple-system,sans-serif;color:#6b7280;text-align:center;padding:24px;`;let g=document.createElement("span");if(g.textContent=f,b.appendChild(g),x){let w=document.createElement("button");w.type="button",w.textContent=e.retry,w.style.cssText="border:1px solid currentColor;border-radius:8px;background:transparent;color:inherit;padding:4px 10px;font:inherit;cursor:pointer;",w.addEventListener("click",()=>{p();}),b.appendChild(w);}i.appendChild(b);},p=async()=>{var L;if(!i||l)return;c(),h(e.loading,false);let f=tt(o),x=null;try{s.url?(x=s.url,s={...s,url:void 0}):s.mint&&(x=it(await s.mint({module:s.module,theme:f,locale:s.locale})));}catch(w){d("error",w),h(w instanceof Error?w.message:e.failed,true);return}if(!x){d("error",new Error("EMBED_URL_MISSING")),h(e.expired,!!s.mint);return}let b=x;try{let w=new URL(x);w.searchParams.set("theme",f),s.locale&&w.searchParams.set("locale",s.locale),s.accent&&w.searchParams.set("accent",s.accent.replace(/^#/,"")),b=w.toString();}catch(w){}let g=document.createElement("iframe");g.src=b,g.title="Signalbird",g.style.cssText="width:100%;border:0;display:block;",g.style.height=`${typeof s.height=="number"?s.height:(L=s.minHeight)!=null?L:640}px`,g.setAttribute("allow","clipboard-write; fullscreen; autoplay"),g.setAttribute("sandbox","allow-same-origin allow-scripts allow-forms allow-popups allow-downloads"),g.setAttribute("referrerpolicy","strict-origin-when-cross-origin"),g.setAttribute("loading","lazy"),s.className&&(g.className=s.className),i.textContent="",i.appendChild(g),n=g,r=w=>{var ee,te;if(!n||w.source!==n.contentWindow)return;let M=w.data;if(!(!M||typeof M.type!="string")){if(M.type==="signalbird:ready"){d("ready",M.module);return}if(M.type==="signalbird:height"&&typeof M.px=="number"&&(d("height",M.px),((ee=s.height)!=null?ee:"auto")==="auto")){let Ee=Math.max(M.px,(te=s.minHeight)!=null?te:220);n.style.height=`${Ee}px`;}}},window.addEventListener("message",r);};return {async mount(f){let x=typeof f=="string"?document.querySelector(f):f;if(!(x instanceof HTMLElement))throw new Error("Signalbird: g\xF6mme kab\u0131 bulunamad\u0131 \u2014 "+String(f));i=x,l=false,await p();},refresh:()=>p(),async setTheme(f){o=f,await p();},destroy(){l=true,c(),t.clear(),i=null;},on(f,x){t.has(f)||t.set(f,new Set),t.get(f).add(x);},off(f,x){var b;(b=t.get(f))==null||b.delete(x);}}}var Pt="2.3.0",v=null,Y=[],P=null;function E(s,e){try{return s()}catch(t){try{console.warn("[signalbird]",t);}catch(i){}return e}}function Le(s){s.catch(()=>{});}function st(s){E(()=>{if(!s||!s.publicKey){console.warn("[signalbird] init: publicKey zorunlu");return}if(!(typeof document=="undefined"||typeof window=="undefined")){v&&v.destroy(),v=new U(s);for(let{event:e,fn:t}of Y)v.on(e,t);if(P){let e=P;P=null,Le(v.identify(e));}}},void 0);}function jt(s){E(()=>{if(s){if(!v){P={...P||{},...s};return}Le(v.identify(s));}},void 0);}var Nt={open(){E(()=>v==null?void 0:v.open(),void 0);},close(){E(()=>v==null?void 0:v.close(),void 0);},toggle(){E(()=>v==null?void 0:v.toggle(),void 0);},isOpen(){return E(()=>!!(v!=null&&v.isOpen()),false)},on(s,e){E(()=>{typeof e=="function"&&(Y.push({event:s,fn:e}),v==null||v.on(s,e));},void 0);},off(s,e){E(()=>{let t=Y.findIndex(i=>i.event===s&&i.fn===e);t>=0&&Y.splice(t,1),v==null||v.off(s,e);},void 0);}},Ht={register(s){return E(()=>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"}))}},It=Te;function Bt(){E(()=>{v==null||v.destroy(),v=null;},void 0);}E(()=>{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=()=>st({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);
490
490
  exports.chat=Nt;exports.destroy=Bt;exports.embed=It;exports.identify=jt;exports.init=st;exports.push=Ht;exports.version=Pt;return exports;})({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "signalbird",
3
- "version": "2.2.2",
3
+ "version": "2.3.0",
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",