useyuva 0.0.6 → 0.0.8
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 +89 -1
- package/dist/esm/chat.js +2 -2
- package/dist/esm/docs.js +134 -0
- package/dist/esm/index-dj5dhqc1.js +12 -0
- package/dist/esm/index-e2tek7yk.js +2 -0
- package/dist/esm/index-jdxce2se.js +4 -0
- package/dist/esm/index-rdzxvj2r.js +2 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/nuxt/module.js +20 -0
- package/dist/esm/nuxt/runtime/components.js +88 -0
- package/dist/esm/react.js +1 -1
- package/dist/esm/thread-3ydc3xfc.js +61 -0
- package/dist/esm/{yuva-chat-tebg111a.js → yuva-chat-86e4mz63.js} +2 -4
- package/dist/types/client/api.d.ts +17 -0
- package/dist/types/client/client.d.ts +23 -1
- package/dist/types/client/reader.d.ts +12 -0
- package/dist/types/docs/base.d.ts +43 -0
- package/dist/types/docs/define.d.ts +1 -0
- package/dist/types/docs/discussions.d.ts +22 -0
- package/dist/types/docs/dom.d.ts +1 -0
- package/dist/types/docs/feedback.d.ts +21 -0
- package/dist/types/docs/page.d.ts +2 -0
- package/dist/types/docs/preview.d.ts +1 -0
- package/dist/types/docs/thread.d.ts +71 -0
- package/dist/types/docs.d.ts +7 -0
- package/dist/types/element.d.ts +0 -1
- package/dist/types/i18n.d.ts +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/locales/en/docs.d.ts +2 -0
- package/dist/types/locales/en/thread.d.ts +2 -0
- package/dist/types/locales/tr/docs.d.ts +2 -0
- package/dist/types/locales/tr/thread.d.ts +2 -0
- package/dist/types/nuxt/module.d.ts +12 -0
- package/dist/types/nuxt/runtime/components.d.ts +88 -0
- package/dist/types/react.d.ts +26 -2
- package/dist/types/schema.gen.d.ts +6638 -3874
- package/dist/types/translate.d.ts +2 -0
- package/dist/types/types.d.ts +1 -0
- package/dist/widget/yuva-docs-thread-4580g2ny.js +61 -0
- package/dist/yuva-chat.js +8 -8
- package/dist/yuva-docs.js +144 -0
- package/dist/yuva.js +2 -2
- package/package.json +39 -8
- package/dist/esm/index-d1vxbqpr.js +0 -12
- package/dist/esm/index-r5vcg0sx.js +0 -2
package/dist/types/types.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface LauncherStyle {
|
|
|
9
9
|
color?: string;
|
|
10
10
|
}
|
|
11
11
|
export declare function launcherOf(inbox: components["schemas"]["ClientInbox"]): LauncherStyle;
|
|
12
|
+
export declare function contrastOn(color: string): string;
|
|
12
13
|
export interface ChatConfig {
|
|
13
14
|
channel: string | null;
|
|
14
15
|
server: string;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var E=JSON.parse('{"2Hlmdt":["Write a reply…"],"3CApMv":["All discussions"],"3PqJQG":["Nothing to preview."],"4-S4QM":["Unmark as answer"],"5lWFkC":["Sign in"],"8wRl7c":["The opening post was deleted."],"99w-GZ":["Sign in to start a discussion. Your name is shown with your post."],"F_vGso":["Your reply"],"HkXOWm":["This reply was deleted."],"Hw3P48":["Replies: ",["0"]],"ImOQa9":["Reply"],"JfAIiv":["This discussion is locked. New replies are closed."],"Kl3TuI":["Get an e-mail when someone replies or an answer is accepted."],"Klsidc":["Delete this reply?"],"MHrjPM":["Title"],"MKEPCY":["Follow"],"NjUiZ4":["Ask a question, share an idea or describe a problem with this page."],"NrGspR":["Thanks! Your discussion will appear for everyone once the team approves it."],"OVijcR":["Remove your vote (",["0"]," votes)"],"PL0621":["Sign in to reply, vote and follow this discussion."],"PN38hZ":["Your question or idea"],"PZ_kxo":["Keep"],"Pwqkdw":["Loading…"],"RqsQKK":["Your first posts are checked by the team before they appear for everyone."],"Sad2tK":["Sending…"],"VGqKyv":["This discussion is no longer available."],"Vwy_nT":["Markdown is supported."],"YZayoP":["Thanks! Your reply will appear for everyone once the team approves it."],"cnGeoo":["Delete"],"dEgA5A":["Cancel"],"dNOvhg":["Upvote (",["0"]," votes)"],"ePK91l":["Edit"],"i4_LY_":["Write"],"jhu92n":["Mark as answer"],"k4b5_X":["edited"],"n5vqdp":["Start discussion"],"qzVesX":["Edit your post"],"rAl91-":["Delete this discussion?"],"rdUucN":["Preview"],"tfDRzk":["Save"],"y-KXxN":["Accepted answer"],"y6sq5j":["Following"],"z1qf6l":["Start a discussion"]}');var Q=JSON.parse('{"2Hlmdt":["Bir yanıt yazın…"],"3CApMv":["Tüm tartışmalar"],"3PqJQG":["Önizlenecek bir şey yok."],"4-S4QM":["Yanıt işaretini kaldır"],"5lWFkC":["Giriş yap"],"8wRl7c":["Açılış gönderisi silindi."],"99w-GZ":["Tartışma başlatmak için giriş yapın. Adınız gönderinizle birlikte gösterilir."],"F_vGso":["Yanıtınız"],"HkXOWm":["Bu yanıt silindi."],"Hw3P48":["Yanıtlar: ",["0"]],"ImOQa9":["Yanıtla"],"JfAIiv":["Bu tartışma kilitli. Yeni yanıt yazılamaz."],"Kl3TuI":["Biri yanıt yazdığında ya da bir yanıt kabul edildiğinde e-posta alın."],"Klsidc":["Bu yanıt silinsin mi?"],"MHrjPM":["Başlık"],"MKEPCY":["Takip et"],"NjUiZ4":["Bir soru sorun, bir fikir paylaşın ya da bu sayfadaki bir sorunu anlatın."],"NrGspR":["Teşekkürler! Tartışmanız ekip onayladığında herkese görünecek."],"OVijcR":["Oyunuzu geri alın (",["0"]," oy)"],"PL0621":["Bu tartışmada yanıt yazmak, oy vermek ve takip etmek için giriş yapın."],"PN38hZ":["Sorunuz ya da fikriniz"],"PZ_kxo":["Kalsın"],"Pwqkdw":["Yükleniyor…"],"RqsQKK":["İlk gönderileriniz herkese görünmeden önce ekip tarafından kontrol edilir."],"Sad2tK":["Gönderiliyor…"],"VGqKyv":["Bu tartışma artık mevcut değil."],"Vwy_nT":["Markdown desteklenir."],"YZayoP":["Teşekkürler! Yanıtınız ekip onayladığında herkese görünecek."],"cnGeoo":["Sil"],"dEgA5A":["Vazgeç"],"dNOvhg":["Oy ver (",["0"]," oy)"],"ePK91l":["Düzenle"],"i4_LY_":["Yaz"],"jhu92n":["Yanıt olarak işaretle"],"k4b5_X":["düzenlendi"],"n5vqdp":["Tartışmayı başlat"],"qzVesX":["Gönderinizi düzenleyin"],"rAl91-":["Bu tartışma silinsin mi?"],"rdUucN":["Önizleme"],"tfDRzk":["Kaydet"],"y-KXxN":["Kabul edilen yanıt"],"y6sq5j":["Takip ediliyor"],"z1qf6l":["Tartışma başlat"]}');function X(n,t,i){let f=n[t.id]??i[t.id],m=t.values??{};if(typeof f==="string")return f;if(Array.isArray(f))return f.map((p)=>typeof p==="string"?p:Array.isArray(p)?String(m[p[0]]??""):"").join("");return t.message??t.id}function o(n,t,i){let f=document.createElement(n);if(t)f.className=t;if(i!==void 0)f.textContent=i;return f}var ie=/(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\s][^*\n]*\*|_[^_\s][^_\n]*_)|((?:https?:\/\/|www\.)[^\s<>"]*[^\s<>".,:;'!?)\]])/g;function ae(n,t){let i=document.createElement("a");return i.href=n,i.textContent=t,i.target="_blank",i.rel="noopener noreferrer nofollow ugc",i}function C(n,t){let i=document.createElement(n);return i.append(...t),i}function z(n){let t=[],i=0;for(let f of n.matchAll(ie)){let m=f.index??0;if(m>i)t.push(document.createTextNode(n.slice(i,m)));let[p,g,u,y,h]=f;if(g)t.push(C("code",[document.createTextNode(g.slice(1,-1))]));else if(u)t.push(C("strong",z(u.slice(2,-2))));else if(y)t.push(C("em",z(y.slice(1,-1))));else if(h){let A=h.startsWith("www.")?`https://${h}`:h;try{let _=new URL(A);t.push(_.protocol==="http:"||_.protocol==="https:"?ae(_.href,h):document.createTextNode(h))}catch{t.push(document.createTextNode(h))}}i=m+p.length}if(i<n.length)t.push(document.createTextNode(n.slice(i)));return t}var re=/\[([^\]\n]+)\]\(([^)\s]+)\)/g;function U(n){let t=[],i=0;for(let f of n.matchAll(re)){let m=f.index??0;if(m>i)t.push(...z(n.slice(i,m)));let[p,g="",u=""]=f,y=null;try{y=new URL(u)}catch{}if(y&&(y.protocol==="http:"||y.protocol==="https:")){let h=document.createElement("a");h.href=y.href,h.target="_blank",h.rel="nofollow ugc noopener",h.append(...z(g)),t.push(h)}else t.push(document.createTextNode(p));i=m+p.length}if(i<n.length)t.push(...z(n.slice(i)));return t}function D(n,t){let i=document.createElement(n);return i.append(...U(t.join(" "))),i}function H(n){let t=document.createDocumentFragment(),i=n.replace(/\r\n?/g,`
|
|
2
|
+
`).split(`
|
|
3
|
+
`),f=[],m=null,p=[],g=()=>{if(f.length)t.append(D("p",f));if(p.length){let u=document.createElement("blockquote");u.append(H(p.join(`
|
|
4
|
+
`))),t.append(u)}f=[],p=[],m=null};for(let u=0;u<i.length;u++){let y=i[u]??"",h=/^\s*(```|~~~)/.exec(y);if(h){g();let M=[];while(++u<i.length&&!(i[u]??"").trimStart().startsWith(h[1]??"```"))M.push(i[u]??"");let T=document.createElement("pre");T.append(Object.assign(document.createElement("code"),{textContent:M.join(`
|
|
5
|
+
`)})),t.append(T);continue}if(/^\s*$/.test(y)){g();continue}let A=/^\s*>\s?(.*)$/.exec(y);if(A){if(f.length||m)g();p.push(A[1]??"");continue}let _=/^\s*(#{1,6})\s+(.*)$/.exec(y);if(_){g(),t.append(D(`h${Math.min(6,(_[1]?.length??1)+2)}`,[_[2]??""]));continue}let q=/^\s*(?:([-*+])|(\d+)[.)])\s+(.*)$/.exec(y);if(q){let M=q[1]?"ul":"ol";if(f.length||p.length||m&&m.tagName.toLowerCase()!==M)g();if(!m)m=document.createElement(M),t.append(m);m.append(D("li",[q[3]??""]));continue}if(p.length)g();if(m&&/^\s{2,}/.test(y)){m.lastElementChild?.append(" ",...U(y.trim()));continue}m=null,f.push(y.trim())}return g(),t}var de=1800000,se={en:E,tr:Q},G=(n)=>`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`,W=G('<circle cx="12" cy="12" r="9"/><path d="M8 12l3 3 5-6"/>'),oe=G('<path d="M19 12H5M12 19l-7-7 7-7"/>'),le=G('<path d="M18 8a6 6 0 10-12 0c0 7-3 9-3 9h18s-3-2-3-9M13.7 21a2 2 0 01-3.4 0"/>'),ke=`
|
|
6
|
+
.thread { display: flex; flex-direction: column; gap: 12px; }
|
|
7
|
+
.thread-head { display: flex; flex-direction: column; gap: 8px; }
|
|
8
|
+
.post { display: flex; gap: 12px; padding: 14px; border: 1px solid var(--yuva-border); border-radius: 12px; }
|
|
9
|
+
.post.accepted { border-color: var(--yuva-success); box-shadow: inset 0 0 0 1px var(--yuva-success); }
|
|
10
|
+
.post.pending { border-style: dashed; }
|
|
11
|
+
.side { display: flex; flex-direction: column; align-items: center; gap: 6px; }
|
|
12
|
+
.vote {
|
|
13
|
+
display: inline-flex; flex-direction: column; align-items: center; gap: 0; min-inline-size: 40px; padding: 4px 6px;
|
|
14
|
+
border: 1px solid var(--yuva-border); border-radius: 8px; background: none; cursor: pointer; font-size: 0.85em; font-weight: 600;
|
|
15
|
+
}
|
|
16
|
+
.vote:hover:not(:disabled) { border-color: var(--yuva-accent); }
|
|
17
|
+
.vote[aria-pressed="true"] { border-color: var(--yuva-accent); color: var(--yuva-accent); background: var(--yuva-soft); }
|
|
18
|
+
.post-body { flex: 1; min-inline-size: 0; display: flex; flex-direction: column; gap: 8px; }
|
|
19
|
+
.post-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 0.88em; }
|
|
20
|
+
.name { font-weight: 600; }
|
|
21
|
+
.answer-label { display: flex; align-items: center; gap: 6px; color: var(--yuva-success); font-weight: 600; font-size: 0.85em; }
|
|
22
|
+
.tools { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
|
|
23
|
+
.children { display: flex; flex-direction: column; gap: 10px; margin-block-start: 4px; padding-inline-start: 14px; border-inline-start: 2px solid var(--yuva-border); }
|
|
24
|
+
.children .post { padding: 10px 0; border: 0; box-shadow: none; }
|
|
25
|
+
.children .post + .post { border-block-start: 1px solid var(--yuva-border); border-radius: 0; }
|
|
26
|
+
.deleted { font-style: italic; opacity: 0.65; }
|
|
27
|
+
.signin { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 14px; border: 1px solid var(--yuva-border); border-radius: 12px; }
|
|
28
|
+
.composer { display: flex; flex-direction: column; border: 1px solid var(--yuva-border); border-radius: 12px; overflow: hidden; }
|
|
29
|
+
.composer:focus-within { border-color: var(--yuva-accent); }
|
|
30
|
+
.composer .ctabs { display: flex; gap: 4px; padding: 0 8px; border-block-end: 1px solid var(--yuva-border); }
|
|
31
|
+
.composer .ctab { padding: 7px 10px; border: 0; border-block-end: 2px solid transparent; background: none; cursor: pointer; font-size: 0.88em; opacity: 0.75; margin-block-end: -1px; }
|
|
32
|
+
.composer .ctab[aria-selected="true"] { border-block-end-color: var(--yuva-accent); font-weight: 600; opacity: 1; }
|
|
33
|
+
.composer .ctab:focus-visible { outline: 2px solid var(--yuva-accent); outline-offset: -2px; }
|
|
34
|
+
.composer textarea, .composer .preview { border: 0; border-radius: 0; min-block-size: 110px; padding: 10px 12px; }
|
|
35
|
+
.composer textarea:focus-visible { outline: none; }
|
|
36
|
+
.composer .preview { overflow-wrap: anywhere; }
|
|
37
|
+
.composer .foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 10px; border-block-start: 1px solid var(--yuva-border); }
|
|
38
|
+
.composer .hint { font-size: 0.8em; opacity: 0.7; }
|
|
39
|
+
.composer .buttons { display: flex; gap: 8px; margin-inline-start: auto; }
|
|
40
|
+
.field-title { font-size: 1.05em; font-weight: 600; }
|
|
41
|
+
.form { display: flex; flex-direction: column; gap: 10px; }
|
|
42
|
+
.md { overflow-wrap: anywhere; }
|
|
43
|
+
.md > :first-child { margin-block-start: 0; }
|
|
44
|
+
.md > :last-child { margin-block-end: 0; }
|
|
45
|
+
.md p, .md ul, .md ol, .md pre, .md blockquote, .md table { margin: 0 0 0.75em; }
|
|
46
|
+
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: 0.9em 0 0.4em; font-size: 1em; font-weight: 600; }
|
|
47
|
+
.md h1, .md h3 { font-size: 1.1em; }
|
|
48
|
+
.md ul, .md ol { padding-inline-start: 1.5em; }
|
|
49
|
+
.md a { color: var(--yuva-accent); }
|
|
50
|
+
.md code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.88em; padding: 1px 5px; border-radius: 5px; background: var(--yuva-soft); }
|
|
51
|
+
.md pre { padding: 10px 12px; border-radius: 8px; background: var(--yuva-soft); overflow-x: auto; }
|
|
52
|
+
.md pre code { padding: 0; background: none; }
|
|
53
|
+
.md blockquote { padding-inline-start: 12px; border-inline-start: 3px solid var(--yuva-border); opacity: 0.85; }
|
|
54
|
+
.md table { border-collapse: collapse; display: block; overflow-x: auto; }
|
|
55
|
+
.md th, .md td { border: 1px solid var(--yuva-border); padding: 4px 8px; }
|
|
56
|
+
.md img { max-inline-size: 100%; }
|
|
57
|
+
.md hr { border: 0; border-block-start: 1px solid var(--yuva-border); }
|
|
58
|
+
@media (max-width: 560px) {
|
|
59
|
+
.post { padding: 12px; gap: 10px; }
|
|
60
|
+
}
|
|
61
|
+
`;class N{area=o("textarea");previewing=!1;constructor(n){this.area.rows=n,this.area.maxLength=20000,this.area.dir="auto"}get value(){return this.area.value.trim()}clear(){this.area.value="",this.previewing=!1}}function _e(n){let t=n.s,i=(e)=>X(se[n.locale()]??E,e,E),f=new N(4),m=new N(6),p=o("input"),g=null,u=null;p.maxLength=200,p.dir="auto",p.className="field-title";for(let e of[f.area,m.area])e.addEventListener("input",()=>y());p.addEventListener("input",()=>y());function y(){for(let e of n.root.querySelectorAll("[data-requires]")){let a=e.dataset.requires,r=t.busy.has(e.dataset.busy??""),d=a==="start"?p.value.trim().length>=3&&m.value!=="":a==="reply"?f.value!=="":a==="inline"?!!g?.composer.value:a==="edit"?!!u?.composer.value&&(!!u.post||u.title.value.trim().length>=3):!0;e.disabled=r||!d}}async function h(){let e=p.value.trim(),a=m.value;if(e.length<3||!a)return;let r=n.page(),d=await n.act("start",()=>n.client().startDiscussion({page_url:r,page_title:n.pageTitle()||void 0,title:e,body:a}));if(!d)return;if(n.forget(),n.emit("yuva-discussion",{page:r,discussion_id:d.id,state:d.state}),n.page()!==r)return;p.value="",m.clear(),t.items=[d,...t.items.filter((c)=>c.id!==d.id)],t.notice=d.state==="pending"?i({id:"NrGspR"}):"",t.thread={discussion:d,posts:[]},await n.open(d.id,!0)}async function A(e,a){let r=t.thread,d=e.value;if(!r||!d)return;let c=n.page(),l=r.discussion.id,v=await n.act(a?`reply-${a}`:"reply",()=>n.client().replyToDiscussion(l,{body:d,parent_post_id:a}));if(!v)return;if(n.forget(),n.emit("yuva-post",{page:c,discussion_id:l,post_id:v.id,state:v.state}),e.clear(),a)g=null;if(t.notice=v.state==="pending"?i({id:"YZayoP"}):"",t.thread?.discussion.id===l)t.thread={...t.thread,posts:[...t.thread.posts,v]},t.focus=`post-${v.id}`,n.render(),n.open(l,!1)}async function _(e,a){if(!t.writer)return void n.signIn();let r=await n.act(`vote-${e.id}`,()=>n.client().voteDiscussionPost(e.id,!e.voted));if(!r||!t.thread)return;if(n.forget(),a){let d={...t.thread.discussion,votes:r.votes,voted:r.voted};t.thread={...t.thread,discussion:d},t.items=t.items.map((c)=>c.id===d.id?d:c)}else t.thread={...t.thread,posts:t.thread.posts.map((d)=>d.id===r.id?{...d,...r}:d)}}async function q(){let e=t.thread;if(!e)return;if(!t.writer)return void n.signIn();let a=!e.discussion.following;if(await n.act("follow",()=>n.client().followDiscussion(e.discussion.id,a).then(()=>!0))&&t.thread?.discussion.id===e.discussion.id)t.thread={...t.thread,discussion:{...t.thread.discussion,following:a}}}async function M(e){let a=t.thread;if(!a)return;let r=await n.act(`accept-${e?.id??"clear"}`,()=>n.client().acceptDiscussionAnswer(a.discussion.id,e?.id??null));if(!r)return;n.forget(),t.focus=e?`post-${e.id}`:"thread-title",await n.open(r.id,!1)}async function T(){let e=u,a=t.thread;if(!e||!a)return;let r=e.composer.value,d=!e.post,c=e.title.value.trim();if(!r||d&&c.length<3)return;let l=e.post?.id??a.discussion.opening_post_id;if(!await n.act(`edit-${l}`,()=>n.client().editDiscussionPost(l,d?{body:r,title:c}:{body:r})))return;n.forget(),u=null,t.focus=d?"thread-title":`post-${l}`,await n.open(a.discussion.id,!1)}async function J(e,a){let r=t.thread;if(!r)return;let d=await n.act(`delete-${e}`,()=>n.client().deleteDiscussionPost(e).then(()=>!0));if(t.confirm="",!d)return;if(n.forget(),a)try{await n.client().getDiscussion(r.discussion.id)}catch{return t.items=t.items.filter((c)=>c.id!==r.discussion.id),t.thread=null,n.toList()}await n.open(r.discussion.id,!1)}function R(e){let a=o("div","md");a.dir="auto",a.innerHTML=e;for(let r of a.querySelectorAll("a[href]"))r.setAttribute("target","_blank");return a}function S(e,a){let r=o("div","composer"),d=o("div","ctabs");d.setAttribute("role","tablist"),d.setAttribute("aria-label",a.label);let c=`p-${a.focusKey}`,l=n.button("ctab",i({id:"i4_LY_"}),`${a.focusKey}-write`,()=>{e.previewing=!1,t.focus=a.focusKey,n.render()}),v=n.button("ctab",i({id:"rdUucN"}),`${a.focusKey}-preview`,()=>{e.previewing=!0,n.render()});for(let[s,k]of[[l,!e.previewing],[v,e.previewing]])s.setAttribute("role","tab"),s.setAttribute("aria-selected",String(k)),s.setAttribute("aria-controls",c),s.tabIndex=k?0:-1,s.addEventListener("keydown",(K)=>{if(K.key!=="ArrowLeft"&&K.key!=="ArrowRight")return;K.preventDefault(),e.previewing=!e.previewing,t.focus=`${a.focusKey}-${e.previewing?"preview":"write"}`,n.render()});if(d.append(l,v),r.append(d),e.previewing){let s=o("div","preview md");if(s.dir="auto",s.id=c,s.setAttribute("role","tabpanel"),s.setAttribute("aria-label",i({id:"rdUucN"})),e.value)s.append(H(e.area.value));else s.append(o("p","muted",i({id:"3PqJQG"})));r.append(s)}else e.area.id=c,e.area.placeholder=a.placeholder,e.area.setAttribute("aria-label",a.label),e.area.dataset.key=a.focusKey,e.area.disabled=t.busy.has(a.busy),e.area.onkeydown=(s)=>{if(s.key==="Enter"&&(s.metaKey||s.ctrlKey))s.preventDefault(),a.onSubmit();else if(s.key==="Escape"&&a.onCancel)a.onCancel()},r.append(e.area);let x=o("div","foot");x.append(o("span","hint",i({id:"Vwy_nT"})));let w=o("div","buttons");if(a.onCancel)w.append(n.button("ghost",i({id:"dEgA5A"}),`${a.focusKey}-cancel`,a.onCancel));let b=n.button("send",t.busy.has(a.busy)?i({id:"Sad2tK"}):a.submit,`${a.focusKey}-submit`,a.onSubmit);return b.dataset.requires=a.requires,b.dataset.busy=a.busy,w.append(b),x.append(w),r.append(x),r}function Y(e){let a=o("div","signin");return a.append(o("p","",e)),a.append(n.button("send",i({id:"5lWFkC"}),"sign-in-box",()=>void n.signIn())),a}function L(){let e=n.button("plain",i({id:"3CApMv"}),"back",()=>n.toList(),oe);e.style.alignSelf="flex-start",e.style.display="inline-flex",e.style.gap="6px",e.style.alignItems="center";let a=e.querySelector("svg");if(a&&n.direction()==="rtl")a.style.transform="scaleX(-1)";return e}function ee(){let e=o("div","form");if(e.append(o("h3","",i({id:"z1qf6l"}))),!t.writer)return e.append(Y(i({id:"99w-GZ"}))),[L(),e];if(p.placeholder=i({id:"MHrjPM"}),p.setAttribute("aria-label",i({id:"MHrjPM"})),p.dataset.key="new-title",p.disabled=t.busy.has("start"),e.append(p),e.append(S(m,{label:i({id:"PN38hZ"}),placeholder:i({id:"NjUiZ4"}),submit:i({id:"n5vqdp"}),busy:"start",requires:"start",focusKey:"new-body",onSubmit:()=>void h(),onCancel:()=>n.toList()})),n.mode()==="moderated"&&t.reader)e.append(o("p","muted",i({id:"RqsQKK"})));return[L(),e]}function te(e){return!!e.mine&&!t.thread?.discussion.locked&&Date.now()-Date.parse(e.created_at)<de}function I(e,a){let r=t.thread;if(!r)return null;let d=r.discussion,c=!e,l=e?.id??d.opening_post_id,v=c?!!d.mine:!!e.mine,x=c?!!d.deleted:e.deleted,w=o("div","tools");if(x)return null;if(!c&&a&&!d.locked&&t.writer&&e.state==="published")w.append(n.button("plain",i({id:"ImOQa9"}),`reply-to-${e.id}`,()=>{g=g?.target===a.id?g:{target:a.id,composer:new N(3)},g.composer.area.oninput=()=>y(),t.focus=`inline-${a.id}`,n.render()}));if(!c&&d.mine&&!e.parent_post_id&&e.state==="published"&&!d.locked){let b=d.answer_post_id===e.id,s=n.button("plain",b?i({id:"4-S4QM"}):i({id:"jhu92n"}),`accept-${e.id}`,()=>void M(b?null:e),b?"":W);s.style.display="inline-flex",s.style.gap="4px",s.style.alignItems="center",s.disabled=t.busy.has(`accept-${e.id}`)||t.busy.has("accept-clear"),w.append(s)}if(v&&te(c?d:e))w.append(n.button("plain",i({id:"ePK91l"}),`edit-${l}`,()=>{let b=new N(c?6:4);b.area.value=c?d.body:e.body,b.area.oninput=()=>y();let s=o("input");s.className="field-title",s.maxLength=200,s.dir="auto",s.value=d.title,s.oninput=()=>y(),u={post:e,composer:b,title:s},t.focus=c?"edit-title":`edit-body-${l}`,n.render()}));if(v)if(t.confirm===l){let b=n.button("plain danger",i({id:"cnGeoo"}),`delete-yes-${l}`,()=>void J(l,c));b.disabled=t.busy.has(`delete-${l}`),w.append(o("span","muted",c?i({id:"rAl91-"}):i({id:"Klsidc"})),b,n.button("plain",i({id:"PZ_kxo"}),`delete-no-${l}`,()=>{t.confirm="",t.focus=`delete-${l}`,n.render()}))}else w.append(n.button("plain",i({id:"cnGeoo"}),`delete-${l}`,()=>{t.confirm=l,t.focus=`delete-no-${l}`,n.render()}));return w.childElementCount?w:null}function O(e,a){let r=n.button("vote",String(e.votes),`vote-${e.id}`,()=>void _(e,a),n.icons.up);return r.setAttribute("aria-pressed",String(!!e.voted)),r.setAttribute("aria-label",e.voted?i({id:"OVijcR",values:{0:e.votes}}):i({id:"dNOvhg",values:{0:e.votes}})),r.disabled=!!e.mine||!!t.thread?.discussion.locked||t.busy.has(`vote-${e.id}`),r}function B(e,a,r=[]){let c=t.thread.discussion.answer_post_id===e.id,l=o("article",`post${c?" accepted":""}${e.state==="pending"?" pending":""}`);l.dataset.key=`post-${e.id}`,l.tabIndex=-1,l.setAttribute("aria-label",n.authorName(e.author));let v=o("div","side");if(!e.deleted)v.append(O(e,!1));if(!a||a.id===e.id)l.append(v);let x=o("div","post-body");if(c){let b=o("div","answer-label");b.innerHTML=W,b.append(i({id:"y-KXxN"})),x.append(b)}if(x.append(j(e.author,e.created_at,e.edited_at,e.state,e.deleted)),u?.post?.id===e.id)x.append(F());else if(e.deleted)x.append(o("p","deleted",i({id:"HkXOWm"})));else x.append(R(e.body_html));let w=I(e,a);if(w)x.append(w);if(r.length||g?.target===e.id){let b=o("div","children");for(let s of r)b.append(B(s,e));if(g?.target===e.id){let s=g;b.append(S(s.composer,{label:i({id:"F_vGso"}),placeholder:i({id:"2Hlmdt"}),submit:i({id:"ImOQa9"}),busy:`reply-${e.id}`,requires:"inline",focusKey:`inline-${e.id}`,onSubmit:()=>void A(s.composer,e.id),onCancel:()=>{g=null,t.focus=`reply-to-${e.id}`,n.render()}}))}x.append(b)}return l.append(x),l}function j(e,a,r,d,c){let l=o("div","post-head");if(!c){if(l.append(n.avatar(e,!0),o("span","name",n.authorName(e))),e.kind==="member"&&!e.deleted)l.append(n.badge("team"))}if(l.append(n.time(a)),r&&!c)l.append(o("span","muted",i({id:"k4b5_X"})));if(d==="pending")l.append(n.badge("pending"));return l}function F(){let e=u,a=o("div","form");if(!e.post)e.title.setAttribute("aria-label",i({id:"MHrjPM"})),e.title.dataset.key="edit-title",a.append(e.title);let r=e.post?.id??t.thread.discussion.opening_post_id;return a.append(S(e.composer,{label:i({id:"qzVesX"}),placeholder:"",submit:i({id:"tfDRzk"}),busy:`edit-${r}`,requires:"edit",focusKey:`edit-body-${r}`,onSubmit:()=>void T(),onCancel:()=>{u=null,t.focus=`edit-${r}`,n.render()}})),a}function ne(){let e=[L()],a=t.thread;if(!a||t.threadState==="missing"){let s=o("div","empty");return s.append(o("p","",t.threadState==="loading"?i({id:"Pwqkdw"}):i({id:"VGqKyv"}))),e.push(s),e}let r=a.discussion,d=o("div","thread"),c=o("div","thread-head");if(u&&!u.post)c.append(j(r.author,r.created_at,r.edited_at,r.state,!1)),c.append(F()),d.append(c);else{let s=o("h3","",r.title);s.dir="auto",s.tabIndex=-1,s.dataset.key="thread-title",c.append(s);let k=o("div","meta");if(r.answer_post_id)k.append(n.badge("answered"));if(r.state==="pending")k.append(n.badge("pending"));if(r.locked)k.append(n.badge("locked"));if(k.childElementCount)c.append(k);d.append(c);let K=o("article",`post${r.state==="pending"?" pending":""}`),V=o("div","side");if(!r.deleted)V.append(O({id:r.opening_post_id,votes:r.votes,voted:r.voted,mine:r.mine},!0));let P=o("div","post-body");P.append(j(r.author,r.created_at,r.edited_at,r.state,!!r.deleted)),P.append(r.deleted?o("p","deleted",i({id:"8wRl7c"})):R(r.body_html));let Z=I(null,null);if(Z)P.append(Z);K.append(V,P),d.append(K)}let l=o("div","bar"),v=n.button("ghost",r.following?i({id:"y6sq5j"}):i({id:"MKEPCY"}),"follow",()=>void q(),le);v.setAttribute("aria-pressed",String(!!r.following)),v.title=i({id:"Kl3TuI"}),v.disabled=t.busy.has("follow");let x=o("span","muted",i({id:"Hw3P48",values:{0:r.reply_count}}));if(l.append(x,v),d.append(l),t.threadState==="loading"&&!a.posts.length&&r.reply_count>0){let s=o("div","skeleton");s.setAttribute("aria-busy","true"),s.setAttribute("aria-label",i({id:"Pwqkdw"})),d.append(s)}let w=a.posts.filter((s)=>!s.parent_post_id),b=o("div","thread");for(let s of w)b.append(B(s,s,a.posts.filter((k)=>k.parent_post_id===s.id)));if(w.length)d.append(b);if(t.notice)d.append(n.noticeBox(t.notice));if(r.locked)d.append(n.noticeBox(i({id:"JfAIiv"}),n.icons.lock));else if(!t.writer)d.append(Y(i({id:"PL0621"})));else d.append(S(f,{label:i({id:"F_vGso"}),placeholder:i({id:"2Hlmdt"}),submit:i({id:"ImOQa9"}),busy:"reply",requires:"reply",focusKey:"reply",onSubmit:()=>void A(f)}));return e.push(d),e}return{threadView:ne,newView:ee,syncSend:y,close(){g=null,u=null},reset(){g=null,u=null,f.clear()}}}export{_e as createThread,ke as styles};
|
package/dist/yuva-chat.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var S=(e)=>typeof e==="string",be=(e)=>typeof e==="function",Q=new Map,V="en";function j(e){return[...Array.isArray(e)?e:[e],V]}function N(e,t,i){let n=j(e);if(!i)i="default";let s;if(typeof i==="string")switch(s={day:"numeric",month:"short",year:"numeric"},i){case"full":s.weekday="long";case"long":s.month="long";break;case"short":s.month="numeric";break}else s=i;return z(()=>D("date",n,i),()=>new Intl.DateTimeFormat(n,s)).format(S(t)?new Date(t):t)}function xe(e,t,i){let n;if(!i)i="default";if(typeof i==="string")switch(n={second:"numeric",minute:"numeric",hour:"numeric"},i){case"full":case"long":n.timeZoneName="short";break;case"short":delete n.second}else n=i;return N(e,t,n)}function U(e,t,i){let n=j(e);return z(()=>D("number",n,i),()=>new Intl.NumberFormat(n,i)).format(t)}function X(e,t,i,{offset:n=0,...s}){let o=j(e),a=t?z(()=>D("plural-ordinal",o),()=>new Intl.PluralRules(o,{type:"ordinal"})):z(()=>D("plural-cardinal",o),()=>new Intl.PluralRules(o,{type:"cardinal"}));return s[i]??s[a.select(i-n)]??s.other}function z(e,t){let i=e(),n=Q.get(i);if(!n)n=t(),Q.set(i,n);return n}function D(e,t,i){let n=t.join("-");return`${e}-${n}-${JSON.stringify(i)}`}var Z=/\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/,ee=(e)=>e.replace(/\\u([a-fA-F0-9]{4})|\\x([a-fA-F0-9]{2})/g,(t,i,n)=>{if(i){let s=parseInt(i,16);return String.fromCharCode(s)}else{let s=parseInt(n,16);return String.fromCharCode(s)}}),te="%__lingui_octothorpe__%",we=(e,t,i={})=>{let n=t||e,s=(a)=>{if(typeof a==="object")return a;return i[a]},o=(a,l)=>{let c=Object.keys(i).length?s("number"):void 0,h=U(n,a,c);return l.replace(new RegExp(te,"g"),h)};return{plural:(a,l)=>{let{offset:c=0}=l,h=X(n,!1,a,l);return o(a-c,h)},selectordinal:(a,l)=>{let{offset:c=0}=l,h=X(n,!0,a,l);return o(a-c,h)},select:ke,number:(a,l)=>U(n,a,s(l)||{style:l}),date:(a,l)=>N(n,a,s(l)||l),time:(a,l)=>xe(n,a,s(l)||l)}},ke=(e,t)=>(Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0)??t.other;function Ce(e,t,i){return(n={},s)=>{let o=we(t,i,s),a=(c,h=!1)=>{if(!Array.isArray(c))return c;return c.reduce((p,u)=>{if(u==="#"&&h)return p+te;if(S(u))return p+u;let[y,g,_]=u,b={};if(g==="plural"||g==="selectordinal"||g==="select")Object.entries(_).forEach(([v,k])=>{b[v]=a(k,g==="plural"||g==="selectordinal")});else b=_;let d;if(g){let v=o[g];d=v(n[y],b)}else d=n[y];if(d==null)return p;return p+d},"")},l=a(e);if(S(l)&&Z.test(l))return ee(l);if(S(l))return l;return l?String(l):""}}class ie{_events={};on(e,t){return this._events[e]??=new Set,this._events[e].add(t),()=>this.removeListener(e,t)}removeListener(e,t){let i=this._events[e];if(i?.delete(t),i?.size===0)delete this._events[e]}emit(e,...t){let i=this._events[e];if(!i)return;for(let n of[...i])n.apply(this,t)}}class ne extends ie{_locale="";_locales;_messages={};_missing;_messageCompiler;constructor(e){super();if(e.missing!=null)this._missing=e.missing;if(e.messages!=null)this.load(e.messages);if(typeof e.locale==="string"||e.locales)this.activate(e.locale??V,e.locales)}get locale(){return this._locale}get locales(){return this._locales}get messages(){return this._messages[this._locale]??{}}setMessagesCompiler(e){return this._messageCompiler=e,this}_load(e,t){let i=Object.prototype.hasOwnProperty.call(this._messages,e)?this._messages[e]:void 0;if(!i)this._messages[e]=t;else Object.assign(i,t)}load(e,t){if(typeof e=="string"&&typeof t==="object")this._load(e,t);else Object.entries(e).forEach(([i,n])=>this._load(i,n));this.emit("change")}loadAndActivate({locale:e,locales:t,messages:i}){this._locale=e,this._locales=t||void 0,this._messages[this._locale]=i,this.emit("change")}activate(e,t){this._locale=e,this._locales=t,this.emit("change")}_(e,t,i){if(!this.locale)throw Error("Lingui: Attempted to call a translation function without setting a locale.\nMake sure to call `i18n.activate(locale)` before using Lingui functions.\nThis issue may also occur due to a race condition in your initialization logic.");let n=i?.message;if(!e)e="";if(!S(e))t=e.values||t,n=e.message,e=e.id;let s=this.messages,o=Object.prototype.hasOwnProperty.call(s,e)?s[e]:void 0,a=o===void 0,l=this._missing;if(l&&a)return be(l)?l(this._locale,e):l;if(a)this.emit("missing",{id:e,locale:this._locale});let c=o||n||e;if(S(c))if(this._messageCompiler)c=this._messageCompiler(c);else console.warn(`Uncompiled message detected! Message:
|
|
2
2
|
|
|
3
3
|
> ${c}
|
|
4
4
|
|
|
@@ -6,17 +6,17 @@ That means you use raw catalog or your catalog doesn't have a translation for th
|
|
|
6
6
|
ICU features such as interpolation and plurals will not work properly for that message.
|
|
7
7
|
|
|
8
8
|
Please compile your catalog first.
|
|
9
|
-
`);if(
|
|
9
|
+
`);if(S(c)&&Z.test(c))return ee(c);if(S(c))return c;return Ce(c,this._locale,this._locales)(t,i?.formats)}t=this._.bind(this);date(e,t){return N(this._locales||this._locale,e,t)}number(e,t){return U(this._locales||this._locale,e,t)}}function B(e={}){return new ne(e)}var $e=B();var Y=JSON.parse(`{"-HY5kX":["New conversation"],"-f5Tkb":["Bad"],"09Tv5j":["Reconnecting…"],"0XGLbP":["Your sign-in has expired. Reload the page and try again."],"1EICzz":["We're away right now"],"4TqZiz":["Could not send your rating. Try again."],"6Uau97":["Skip"],"6gRgw8":["Retry"],"6lGaum":["Seen"],"ASr-r0":["Show older conversations"],"Amai22":["Chat is not available right now."],"E_qvzP":["Enter a valid e-mail address."],"GQVIIl":["You seem to be offline."],"JkW3Ph":["This file type is not accepted."],"JlFcis":["Send"],"KDw4GX":["Try again"],"M62PBt":["Nobody is available right now. Leave your e-mail and we'll send the reply there too."],"N7m8E-":["Attach files"],"NBdIgR":["Comment"],"OEEQKT":["Good"],"Pwqkdw":["Loading…"],"PxYAul":["Typing…"],"RzWUUK":["Write a message…"],"S63MQu":["All conversations"],"SOk0EB":["Thanks for your feedback"],"Sad2tK":["Sending…"],"SdV5Cn":["Send us a message and we will reply here."],"UY1vmE":["Attachment"],"VggdQJ":["Usually replies in ",["duration"]],"XJURKP":["E-mail address"],"YyNOE7":["Conversation"],"ZxJcgC":["Could not save your e-mail address. Try again."],"axQ1h6":["Anything you'd like to add? (optional)"],"eOu9Px":["The file is too large."],"h69WC6":["Sent"],"iGNUZJ":["Thanks! We'll e-mail you at ",["known"]," if you're gone when we reply."],"meAa31":["No conversations yet"],"nhTADq":["We'll reply as soon as we can"],"njBr8W":["you@example.com"],"oXOSPE":["Online"],"t7TeQU":["Messages"],"tHaDPf":[["name"]," is typing…"],"tfDRzk":["Save"],"tzsBOP":["Too many attempts. Wait a moment and try again."],"uA8iBc":["How did we do?"],"upFvcp":["Not sent."],"w61W3L":["Remove ",["0"]],"xDAtGP":["Message"],"ydzYKJ":["You:"],"yz7wBu":["Close"],"zLzEI3":["Sign in to chat with us."]}`);var se=JSON.parse('{"-HY5kX":["Yeni konuşma"],"-f5Tkb":["Kötü"],"09Tv5j":["Yeniden bağlanıyor…"],"0XGLbP":["Oturumunuzun süresi doldu. Sayfayı yenileyip tekrar deneyin."],"1EICzz":["Şu anda uzaktayız"],"4TqZiz":["Değerlendirmeniz gönderilemedi. Tekrar deneyin."],"6Uau97":["Geç"],"6gRgw8":["Tekrar dene"],"6lGaum":["Görüldü"],"ASr-r0":["Eski konuşmaları göster"],"Amai22":["Sohbet şu anda kullanılamıyor."],"E_qvzP":["Geçerli bir e-posta adresi girin."],"GQVIIl":["Çevrimdışı görünüyorsunuz."],"JkW3Ph":["Bu dosya türü kabul edilmiyor."],"JlFcis":["Gönder"],"KDw4GX":["Tekrar dene"],"M62PBt":["Şu anda müsait kimse yok. E-posta adresinizi bırakın, yanıtı oraya da gönderelim."],"N7m8E-":["Dosya ekle"],"NBdIgR":["Yorum"],"OEEQKT":["İyi"],"Pwqkdw":["Yükleniyor…"],"PxYAul":["Yazıyor…"],"RzWUUK":["Bir mesaj yazın…"],"S63MQu":["Tüm konuşmalar"],"SOk0EB":["Geri bildiriminiz için teşekkürler"],"Sad2tK":["Gönderiliyor…"],"SdV5Cn":["Bize bir mesaj gönderin, yanıtımız burada görünecek."],"UY1vmE":["Ek"],"VggdQJ":["Genellikle ",["duration"]," içinde yanıt verir"],"XJURKP":["E-posta adresi"],"YyNOE7":["Konuşma"],"ZxJcgC":["E-posta adresiniz kaydedilemedi. Tekrar deneyin."],"axQ1h6":["Eklemek istediğiniz bir şey var mı? (isteğe bağlı)"],"eOu9Px":["Dosya çok büyük."],"h69WC6":["Gönderildi"],"iGNUZJ":["Teşekkürler! Yanıtladığımızda burada değilseniz ",["known"]," adresine e-posta göndereceğiz."],"meAa31":["Henüz konuşma yok"],"nhTADq":["En kısa sürede yanıt vereceğiz"],"njBr8W":["siz@ornek.com"],"oXOSPE":["Çevrimiçi"],"t7TeQU":["Mesajlar"],"tHaDPf":[["name"]," yazıyor…"],"tfDRzk":["Kaydet"],"tzsBOP":["Çok fazla deneme. Biraz bekleyip tekrar deneyin."],"uA8iBc":["Nasıldık?"],"upFvcp":["Gönderilemedi."],"w61W3L":[["0"]," kaldır"],"xDAtGP":["Mesaj"],"ydzYKJ":["Siz:"],"yz7wBu":["Kapat"],"zLzEI3":["Bizimle sohbet etmek için giriş yapın."]}');function re(e){return{position:e.chat.launcher_position,color:e.chat.launcher_color??e.branding.color}}function oe(e){return`yuva:${e}`}function K(e){try{let t=localStorage.getItem(oe(e));return t?JSON.parse(t):{}}catch{return{}}}function ae(e,t){try{localStorage.setItem(oe(e),JSON.stringify(t))}catch{}}class f extends Error{status;code;constructor(e,t){super(`${e} ${t}`);this.status=e;this.code=t}}async function le(e,t,i,{method:n="GET",json:s,body:o,headers:a={},token:l,blob:c}={}){if(a={...a},l)a.Authorization=`Bearer ${l}`;let h=o;if(s!==void 0)a["Content-Type"]="application/json",h=JSON.stringify(s);let p;try{p=await e(t+i,{method:n,headers:a,body:h,credentials:"omit"})}catch{throw new f(0,"network")}if(!p.ok){let u="error";try{u=(await p.json()).code??u}catch{}throw new f(p.status,u)}if(p.status===204)return;return c?await p.blob():await p.json()}class F{server;socketClass;handlers;#s=null;#m=0;#n=0;#r=null;#y=!0;constructor(e,t,i){this.server=e;this.socketClass=t;this.handlers=i}get connected(){return this.#s?.readyState===1}start(){if(this.#y=!1,!this.#s)this.#a()}stop(){if(this.#y=!0,this.#r)clearTimeout(this.#r);this.#r=null;let e=this.#s;this.#s=null,e?.close(1000)}reset(){this.#m=0}nudge(){if(this.#y||this.#s)return;if(this.#r)clearTimeout(this.#r);this.#r=null,this.#a()}#a(){let e=this.handlers.token();if(!e||this.#y)return;let t=new URL(`${this.server}/client/v1/realtime`,globalThis.location?.href);if(t.protocol=t.protocol==="https:"?"wss:":"ws:",this.#m>0)t.searchParams.set("last_event_id",String(this.#m));let i;try{i=new this.socketClass(t,["yuva",`yuva.token.${e}`])}catch{this.#u();return}this.#s=i,i.onmessage=(n)=>{let s;try{s=JSON.parse(String(n.data))}catch{return}if(s.type==="ready")this.#n=0,this.#m=Math.max(this.#m,s.last_event_id);else if("id"in s&&typeof s.id==="number")this.#m=Math.max(this.#m,s.id);this.handlers.event(s)},i.onclose=(n)=>{if(this.#s!==i)return;if(this.#s=null,this.#y)return;if(n.code===1008){this.#m=0,this.handlers.sessionEnded();return}this.#u()}}#u(){if(this.#y||this.#r)return;let e=this.#n++;this.handlers.reconnecting(e);let t=Math.min(30000,1000*2**e)*(0.75+Math.random()*0.5);this.#r=setTimeout(()=>{this.#r=null,this.#a()},t)}}function Se(e,t,i){let n=new URL("/account/connect",e);return n.searchParams.set("channel",t),n.searchParams.set("origin",i),n.href}function _e(e){let t=e;return!!t&&typeof t.token==="string"&&t.token.startsWith("yuva_rd_")&&typeof t.expires_at==="string"&&!Number.isNaN(Date.parse(t.expires_at))&&typeof t.channel_key==="string"&&typeof t.origin==="string"&&!!t.reader&&typeof t.reader.initials==="string"}function ce(e,t,{width:i=460,height:n=640}={}){let s=new URL(e).origin,o=location.origin,a=Math.max(0,(window.screenX??0)+((window.outerWidth??i)-i)/2),l=Math.max(0,(window.screenY??0)+((window.outerHeight??n)-n)/2),c=window.open(Se(e,t,o),"yuva-reader",`popup=yes,width=${i},height=${n},left=${Math.round(a)},top=${Math.round(l)}`);if(!c)return Promise.reject(new f(0,"popup_blocked"));return new Promise((h,p)=>{let u=!1,y=()=>{u=!0,window.removeEventListener("message",g),clearInterval(_)},g=(b)=>{if(u||b.origin!==s||b.source&&b.source!==c)return;let d=b.data;if(!_e(d)||d.channel_key!==t||d.origin!==o)return;y();try{c.close()}catch{}h({token:d.token,expires_at:d.expires_at,reader:d.reader})},_=setInterval(()=>{let b=!1;try{b=c.closed}catch{}if(!b)return;clearInterval(_),setTimeout(()=>{if(u)return;y(),p(new f(0,"sign_in_cancelled"))},300)},500);window.addEventListener("message",g)})}function de(e){return`yuva:${e}`}function he(e,t){return`yuva:reader:${e} ${t}`}function I(){if(typeof crypto.randomUUID==="function")return crypto.randomUUID();return Array.from(crypto.getRandomValues(new Uint8Array(16)),(e)=>e.toString(16).padStart(2,"0")).join("")}function Pe(e){try{let t=(e.split(".")[1]??"").replace(/-/g,"+").replace(/_/g,"/"),i=JSON.parse(atob(t));return typeof i.sub==="string"?i.sub:null}catch{return null}}function Te(){try{let t=globalThis.localStorage;if(t)return t}catch{}let e=new Map;return{getItem:(t)=>e.get(t)??null,setItem:(t,i)=>void e.set(t,i)}}function J(e){let t=new URLSearchParams;for(let[n,s]of Object.entries(e))if(s!==void 0)t.set(n,String(s));let i=t.toString();return i?`?${i}`:""}function Ee(e){return e.replace(/"/g,"%22").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function Re(e,t,i){let n=[];for(let[s,o]of e)n.push(`--${i}\r
|
|
10
10
|
Content-Disposition: form-data; name="${s}"\r
|
|
11
11
|
\r
|
|
12
12
|
${o}\r
|
|
13
|
-
`);for(let s of
|
|
14
|
-
Content-Disposition: form-data; name="files"; filename="${
|
|
13
|
+
`);for(let s of t){let o=s.name||"file";n.push(`--${i}\r
|
|
14
|
+
Content-Disposition: form-data; name="files"; filename="${Ee(o)}"\r
|
|
15
15
|
Content-Type: ${s.type||"application/octet-stream"}\r
|
|
16
16
|
\r
|
|
17
17
|
`,s,`\r
|
|
18
18
|
`)}return n.push(`--${i}--\r
|
|
19
|
-
`),new Blob(n)}class
|
|
19
|
+
`),new Blob(n)}class ue{server;channel;#s;#m;#n;#r;#y;#a=null;#u=null;#w=null;#C=null;#t=null;#v;#p=new Map;constructor(e){this.server=e.server.replace(/\/+$/,""),this.channel=e.channel,this.#s=e.fetch??((t,i)=>fetch(t,i)),this.#m=e.WebSocket??globalThis.WebSocket,this.#n=e.storage??Te(),this.#r=e.identityToken??null,this.#y=e.idempotencyKeys??typeof globalThis.document>"u"}get session(){return this.#u}get token(){return this.#a}get connected(){return this.#t?.connected??!1}on(e,t){let i=this.#p.get(e);if(!i)this.#p.set(e,i=new Set);return i.add(t),()=>void i.delete(t)}#l(e,t){for(let i of this.#p.get(e)??[])i(t)}stored(){try{let e=this.#n.getItem(de(this.channel));return e?JSON.parse(e):{}}catch{return{}}}#k(e){try{this.#n.setItem(de(this.channel),JSON.stringify(e))}catch{}}channelSettings(){return this.#f(`/client/v1/channels/${encodeURIComponent(this.channel)}`)}ratePage(e){return this.#f(`/client/v1/channels/${encodeURIComponent(this.channel)}/page-ratings`,{method:"POST",json:e})}setIdentityToken(e){this.#r=e,this.reset()}start(){if(this.#u)return Promise.resolve(this.#u);return this.#w??=this.#I(!1).then((e)=>(this.#l("session",{session:e,renewed:!1}),e)).finally(()=>{this.#w=null}),this.#w}async refresh(){let e=await this.#c("/client/v1/session");return this.#u={...this.#u,...e},this.#l("session",{session:this.#u,renewed:!1}),this.#u}reset(){this.#t?.stop(),this.#t?.reset(),this.#w=null,this.#C=null,this.#a=null,this.#u=null}async signOut(){let e=this.#a;this.reset();let t=this.stored();if(delete t.session,this.#k(t),e)await this.#f("/client/v1/session",{method:"DELETE",token:e}).catch(()=>{return})}async connect(){if(!this.#m)throw Error("Yuva: no WebSocket in this runtime; pass options.WebSocket");if(await this.start(),this.#t??=new F(this.server,this.#m,{token:()=>this.#a,event:(e)=>{if(e.type==="ready")this.#l("connection",{state:"open",attempt:0});this.#l("event",e)},sessionEnded:()=>void this.#D().catch(()=>this.#t?.nudge()),reconnecting:(e)=>{if(this.#l("connection",{state:"reconnecting",attempt:e}),e===2)this.#c("/client/v1/session").catch(()=>{return})}}),!this.#t.connected)this.#l("connection",{state:"connecting",attempt:0});this.#t.start()}disconnect(){this.#t?.stop(),this.#l("connection",{state:"closed",attempt:0})}reconnect(){this.#t?.nudge()}listConversations(e={}){return this.#c(`/client/v1/conversations${J({...e})}`)}getConversation(e){return this.#c(`/client/v1/conversations/${encodeURIComponent(e)}`)}startConversation(e){return this.#c("/client/v1/conversations",this.#R(e))}listMessages(e,t={}){return this.#c(`/client/v1/conversations/${encodeURIComponent(e)}/messages${J({...t})}`)}sendMessage(e,t){return this.#c(`/client/v1/conversations/${encodeURIComponent(e)}/messages`,this.#R(t))}markRead(e,t){return this.#c(`/client/v1/conversations/${encodeURIComponent(e)}/read`,{method:"POST",json:t?{message_id:t}:{}})}rate(e,t,i){let n={rating:t,comment:i?.trim()||void 0};return this.#c(`/client/v1/conversations/${encodeURIComponent(e)}/rating`,{method:"POST",json:n})}setTyping(e,t){return this.#c(`/client/v1/conversations/${encodeURIComponent(e)}/typing`,{method:"POST",json:{typing:t}})}setEmail(e){return this.#c("/client/v1/contact/email",{method:"PUT",json:{email:e}})}attachment(e){return this.#c(`/client/v1/attachments/${encodeURIComponent(e)}`,{blob:!0})}sendFeedback(e){let t=e.client_id??I();return this.#c("/client/v1/feedback",{method:"POST",headers:this.#x(t),json:{...e,client_id:t}})}get reader(){if(this.#v===void 0)try{let e=this.#n.getItem(he(this.server,this.channel));this.#v=e?JSON.parse(e):null}catch{this.#v=null}if(this.#v&&Date.parse(this.#v.expires_at)<=Date.now()+30000)this.#i(null);return this.#v}#i(e){let t=this.#v?.token!==e?.token;this.#v=e;try{this.#n.setItem(he(this.server,this.channel),e?JSON.stringify(e):"")}catch{}if(t)this.#l("reader",e)}readerSignIn(e){return ce(this.server,this.channel,e).then((t)=>(this.#i(t),t))}setReader(e){this.#i(e)}async readerSignOut(){let e=this.reader?.token;if(this.#i(null),e)await this.#f("/client/v1/reader-token",{method:"DELETE",token:e}).catch(()=>{return})}listDiscussions(e,t={}){return this.#b(`/client/v1/channels/${encodeURIComponent(this.channel)}/discussions${J({page:e,...t})}`,{},!1)}getDiscussion(e){return this.#b(`/client/v1/channels/${encodeURIComponent(this.channel)}/discussions/${encodeURIComponent(e)}`,{},!1)}startDiscussion(e){return this.#b("/client/v1/discussions",{method:"POST",json:e})}replyToDiscussion(e,t){return this.#b(`/client/v1/discussions/${encodeURIComponent(e)}/posts`,{method:"POST",json:t})}editDiscussionPost(e,t){return this.#b(`/client/v1/discussion-posts/${encodeURIComponent(e)}`,{method:"PATCH",json:t})}deleteDiscussionPost(e){return this.#b(`/client/v1/discussion-posts/${encodeURIComponent(e)}`,{method:"DELETE"})}voteDiscussionPost(e,t=!0){return this.#b(`/client/v1/discussion-posts/${encodeURIComponent(e)}/vote`,{method:t?"PUT":"DELETE"})}followDiscussion(e,t=!0){return this.#b(`/client/v1/discussions/${encodeURIComponent(e)}/follow`,{method:t?"PUT":"DELETE"})}acceptDiscussionAnswer(e,t){let i=`/client/v1/discussions/${encodeURIComponent(e)}/answer`;return this.#b(i,t?{method:"PUT",json:{post_id:t}}:{method:"DELETE"})}async discussionWriter(){if(this.reader)return"reader";if(this.#u)return this.#u.contact.identified?"contact":null;return await this.#r?.()?"contact":null}async#b(e,t,i=!0){let n=this.reader;if(n)try{return await this.#f(e,{...t,token:n.token})}catch(o){if(!(o instanceof f)||o.status!==401||this.#v?.token!==n.token)throw o;if(this.#i(null),i)throw new f(403,"sign_in_required")}if(await this.discussionWriter()==="contact")return this.#c(e,t);if(i)throw new f(403,"sign_in_required");return this.#f(e,t)}#x(e){return this.#y&&/^[\x20-\x7e]{1,255}$/.test(e)?{"Idempotency-Key":e}:{}}#R({body:e,subject:t,files:i=[],client_id:n=I()}){let s=this.#x(n);if(i.length===0)return{method:"POST",headers:s,json:{body:e,subject:t,client_id:n}};let o=[];if(t)o.push(["subject",t]);if(e)o.push(["body",e]);o.push(["client_id",n]);let a=`yuva-${n.replace(/[^\w-]/g,"").slice(0,60)}-${n.length}`;return s["Content-Type"]=`multipart/form-data; boundary=${a}`,{method:"POST",headers:s,body:Re(o,i,a)}}#f(e,t){return le(this.#s,this.server,e,t)}async#c(e,t={},i=!0){if(!this.#a)await this.start();try{return await this.#f(e,{...t,token:this.#a})}catch(n){if(!i||!(n instanceof f)||n.status!==401)throw n;return await this.#D(),this.#c(e,t,!1)}}#D(){return this.#C??=(async()=>{let e=await this.#I(!0);if(this.#t)this.#t.stop(),this.#t.reset(),this.#t.start();this.#l("session",{session:e,renewed:!0})})().finally(()=>{this.#C=null}),this.#C}async#I(e){let t=this.stored(),i=await this.#r?.()||null,n=i?Pe(i):null,s=t.session;if(!e&&s&&s.sub===n&&Date.parse(s.expires_at)>Date.now()+60000)try{let c=await this.#f("/client/v1/session",{token:s.token});return this.#M(c,s.token,n)}catch(c){if(!(c instanceof f)||c.status!==401&&c.status!==403)throw c}let o=await this.#f("/client/v1/session",{method:"POST",json:{channel_key:this.channel,identity_token:i??void 0,visitor_id:t.visitor_id}}),{token:a,...l}=o;return this.#M(l,a,n)}#M(e,t,i){this.#a=t,this.#u=e;let n=this.stored();if(n.session={token:t,expires_at:e.expires_at,sub:i},e.visitor_id)n.visitor_id=e.visitor_id;else if(e.contact.identified)delete n.visitor_id;return this.#k(n),e}}function pe(e){return new ue(e)}var fe=`
|
|
20
20
|
[hidden] { display: none !important; }
|
|
21
21
|
.header {
|
|
22
22
|
display: flex;
|
|
@@ -208,6 +208,6 @@ Content-Type: ${s.type||"application/octet-stream"}\r
|
|
|
208
208
|
.banner { padding: 6px 12px; background: var(--yuva-soft); color: var(--yuva-muted); font-size: 13px; text-align: center; }
|
|
209
209
|
@media (max-width: 480px) { .composer textarea, .card input, .card textarea { font-size: 16px; } }
|
|
210
210
|
.sr { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
211
|
-
`;var
|
|
212
|
-
`).split(/^```[^\n]*\n([\s\S]*?)^```[ \t]*$/m);return i.forEach((n,s)=>{if(s%2===1){let a=document.createElement("pre");a.textContent=n.replace(/\n$/,""),
|
|
213
|
-
`).forEach((a,l)=>{if(l>0)e.append(document.createElement("br"));e.append(...G(a))})}),e}var Tt={en:N,tr:nt},Pt=10,pt=300000,S={close:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>',back:'<svg class="flip" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 6l-6 6 6 6"/></svg>',attach:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 11.5l-8.3 8.3a5 5 0 01-7-7L13 4.5a3.3 3.3 0 014.7 4.7l-8.3 8.3a1.7 1.7 0 01-2.4-2.4L14.5 7.6"/></svg>',send:'<svg class="flip" width="20" height="20" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M3.4 20.4l17.5-7.5a1 1 0 000-1.8L3.4 3.6a1 1 0 00-1.4 1.2L4.5 12l-2.5 7.2a1 1 0 001.4 1.2zM4.5 12h7"/></svg>',file:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H6v18h12V7z M14 3v4h4"/></svg>'};function r(t,e,i){let n=document.createElement(t);if(e)n.className=e;if(i!==void 0)n.textContent=i;return n}function T(t,e,i,n="icon"){let s=r("button",n);return s.type="button",s.innerHTML=t,s.setAttribute("aria-label",e),s.title=e,s.addEventListener("click",i),s}var v=(t)=>Date.parse(t),ft=(t,e)=>v(t.created_at)-v(e.created_at),It=(t,e)=>v(e.last_message_at??e.created_at)-v(t.last_message_at??t.created_at),L=(t)=>t.author.type==="contact"?"contact":`${t.author.type}:${t.author.name??""}`,Rt=(t)=>/^image\/(png|jpeg|gif|webp)$/.test(t.content_type);class gt{#s;#p;#n;#r=null;#g=null;#a="loading";#f="";#v=null;#x=null;#e=new Map;#E;#l=new Map;#m=[];#b=new Map;#i=null;#h=!1;#y=[];#T=0;#k=null;#U=new Map;#G=new Map;#W=new Map;#q=!1;#w="";#H=!1;#C=new Map;#wt=r("div","card rate");#u=r("textarea");#Q="";#rt=null;#X=r("header","header");#V=r("div","banner");#L=r("div","body");#c=r("div","scroll");#S=r("div","card");#_=r("input");#ot=r("div","composer");#Z=r("div","chips");#d=r("textarea");#z=r("input");#A;#j;#tt=r("div","sr");#B;#I=!0;constructor(t){this.#s=t;let{server:e,channel:i}=t.config();this.#n=ht({server:e,channel:i??"",identityToken:()=>t.identityToken()}),this.#n.on("event",(s)=>this.#_t(s)),this.#n.on("connection",({state:s,attempt:o})=>{if(s!=="reconnecting")return;this.#h=o>0,this.#nt()}),this.#n.on("session",({session:s,renewed:o})=>{if(this.#Y(s.inbox),this.#g=s.contact,o)this.#pt()}),this.#lt(),this.#tt.setAttribute("aria-live","polite"),this.#c.addEventListener("scroll",()=>{if(this.#I=this.#c.scrollHeight-this.#c.scrollTop-this.#c.clientHeight<48,this.#c.scrollTop<60&&this.#i?.kind==="thread"&&this.#i.id)this.#F(this.#i.id,!0)}),this.#d.rows=1,this.#d.addEventListener("keydown",(s)=>{if(s.key==="Enter"&&!s.shiftKey&&!s.isComposing)s.preventDefault(),this.#it()}),this.#d.addEventListener("input",()=>{this.#gt(),this.#D(),this.#Tt()}),this.#d.addEventListener("paste",(s)=>{let o=Array.from(s.clipboardData?.files??[]);if(o.length===0)return;s.preventDefault(),this.#ft(o)}),this.#z.type="file",this.#z.multiple=!0,this.#z.hidden=!0,this.#z.addEventListener("change",()=>{this.#ft(Array.from(this.#z.files??[])),this.#z.value=""}),this.#j=T(S.attach,"",()=>this.#z.click()),this.#A=T(S.send,"",()=>void this.#it(),"icon send");let n=r("form");n.addEventListener("submit",(s)=>{s.preventDefault(),this.#it()}),n.append(this.#j,this.#d,this.#A,this.#z),this.#ot.append(this.#Z,n),this.#_.type="email",this.#_.required=!0,this.#_.autocomplete="email",this.#u.rows=2,this.#u.maxLength=2000,this.#u.dir="auto",document.addEventListener("visibilitychange",this.#N),window.addEventListener("online",this.#N),this.#kt(),this.#O()}update(){this.#lt(),this.#kt()}opened(){if(this.#a==="error"){this.#v=null,this.#O();return}if(this.#a==="ready")this.#n.token?this.#St():this.#ct().then(()=>this.#o()).catch(()=>{return});if(this.#o(),this.#P(),this.#$(),this.#s.config().layout==="launcher")this.#d.focus({preventScroll:!0})}closed(){this.#M()}identityChanged(){this.#at(),this.#O()}async signOut(){let t=this.#n.signOut();if(this.#at(),await t,this.#s.isOpen())this.#O();else this.#o()}destroy(){this.#n.reset(),this.#M(),document.removeEventListener("visibilitychange",this.#N),window.removeEventListener("online",this.#N);for(let t of this.#U.values())URL.revokeObjectURL(t)}#at(){this.#n.reset(),this.#v=null,this.#x=null,this.#r=null,this.#g=null,this.#a="loading",this.#e.clear(),this.#l.clear(),this.#m=[],this.#C.clear(),this.#Q="",this.#i=null,this.#H=!1,this.#s.setUnread(0)}#N=()=>{if(document.visibilityState!=="visible")return;this.#n.reconnect(),this.#$(),this.#ht()};#lt(){let{locale:t}=this.#s.config();this.#p=B({locale:t,messages:{[t]:Tt[t]??N}})}#t(t){return this.#p._(t)}#O(){return this.#v??=(async()=>{this.#a="loading",this.#o();let{channel:t}=this.#s.config();if(!t)throw new g(0,"not_configured");if(await this.#s.identityToken()||Y(t).session)await this.#Ct();else if(await this.#ct(),!this.#r?.chat.allow_anonymous)throw new g(403,"anonymous_not_allowed");if(this.#a="ready",!this.#i){let e=this.#xt();if(this.#i=e.length>1?{kind:"list"}:{kind:"thread",id:e[0]?.id??null},this.#i.kind==="thread"&&this.#i.id)await this.#F(this.#i.id)}this.#o(),this.#P(),this.#$()})().catch((t)=>{if(this.#v=null,this.#ut(t))return;this.#a="error",this.#f=t instanceof g?t.code:"error",this.#o()}),this.#v}async#ct(){let t=await this.#dt();if(!this.#n.token)this.#Y(t)}#dt(){if(!this.#s.config().channel)throw new g(0,"not_configured");return this.#n.channelSettings()}#Y(t){let{channel:e}=this.#s.config();this.#r=t;let i=st(t);if(this.#s.setLauncher(i),e)ot(e,{...Y(e),launcher:i})}async#ht(){if(this.#a!=="ready")return;try{this.#Y(await this.#dt()),this.#o()}catch(t){this.#ut(t,!0)}}#ut(t,e=!this.#n.token){let i=t instanceof g&&(t.code==="origin_not_allowed"||t.status===404&&e);if(i)this.#s.refused();return i}#Ct(){return this.#x??=(async()=>{await this.#n.start(),await this.#K(),await this.#n.connect()})().finally(()=>{this.#x=null}),this.#x}async#St(){try{await this.#n.refresh(),this.#o()}catch{}}async#K(t=!1){let e=await this.#n.listConversations({limit:50,cursor:t?this.#E:void 0});if(!t)this.#e.clear();for(let i of e.items)this.#e.set(i.id,i);this.#E=e.next_cursor,this.#R()}async#pt(){await this.#K();let t=this.#i?.kind==="thread"?this.#i.id:null;for(let e of[...this.#l.keys()])if(e!==t)this.#l.delete(e);if(t)this.#l.delete(t),await this.#F(t);this.#o()}async#F(t,e=!1){let i=this.#l.get(t);if(!i)i={messages:[],complete:!1,loading:!1},this.#l.set(t,i);if(i.loading||e&&(i.complete||!i.cursor))return;i.loading=!0;let n=this.#c.scrollHeight-this.#c.scrollTop;try{let s=await this.#n.listMessages(t,{order:"desc",limit:30,cursor:e?i.cursor:void 0}),o=new Set(i.messages.map((a)=>a.id));i.messages=[...i.messages,...s.items.filter((a)=>!o.has(a.id))].sort(ft),i.cursor=s.next_cursor,i.complete=!s.next_cursor}finally{i.loading=!1}if(e)this.#o(),this.#c.scrollTop=this.#c.scrollHeight-n}#_t(t){switch(t.type){case"ready":if(this.#h=!1,this.#nt(),this.#H)this.#ht();this.#H=!0;return;case"inbox.updated":{let e=this.#r?.ask_for_rating;if(this.#Y(t.data),e!==void 0&&e!==t.data.ask_for_rating)this.#K().then(()=>this.#o()).catch(()=>{return});break}case"resync_required":this.#pt();return;case"presence":if(this.#r)this.#r={...this.#r,presence:t.data};break;case"conversation.created":if(!this.#e.has(t.data.id))this.#e.set(t.data.id,t.data);if(this.#i?.kind==="thread"&&this.#i.id===null&&this.#e.size>1)this.#i=this.#m.some((e)=>e.conversation===null)?this.#i:{kind:"list"};this.#R();break;case"conversation.updated":{let e=this.#e.get(t.data.id),{status:i,can_rate:n,rating:s}=t.data;if(e)this.#e.set(e.id,{...e,status:i,can_rate:n,rating:s});if(!n)this.#C.delete(t.data.id);break}case"message.created":case"message.updated":this.#et(t.data,t.type==="message.created");break;case"read":{let e=this.#e.get(t.data.conversation_id),i=e?.last_read_by_member_at;if(e&&(!i||v(t.data.read_at)>v(i)))this.#e.set(e.id,{...e,last_read_by_member_at:t.data.read_at});break}case"typing":{let e=t.data.conversation_id,i=this.#b.get(e);if(i)clearTimeout(i.timer);if(t.data.typing){let n=t.data.author.name??"";this.#b.set(e,{name:n,timer:setTimeout(()=>this.#b.delete(e)&&this.#o(),8000)})}else this.#b.delete(e);break}}this.#o()}#et(t,e){let i=t.conversation_id,n=this.#l.get(i);if(n){let o=n.messages.findIndex((a)=>a.id===t.id);if(o>=0)n.messages[o]=t;else n.messages=[...n.messages,t].sort(ft)}if(t.client_id)this.#m=this.#m.filter((o)=>o.client_id!==t.client_id);let s=this.#e.get(i);if(!s){this.#n.getConversation(i).then((o)=>{this.#e.set(o.id,o),this.#R(),this.#o()}).catch(()=>{return});return}if(e){let o=t.body.replace(/\s+/g," ").trim();if(this.#e.set(i,{...s,last_message:{id:t.id,author_type:t.author.type,text:o.length>140?`${o.slice(0,139)}…`:o,created_at:t.created_at},last_message_at:t.created_at,unread:s.unread||t.author.type!=="contact"}),t.author.type!=="contact"){let a=this.#b.get(i);if(a)clearTimeout(a.timer);this.#b.delete(i),this.#zt(t)}}this.#R(),this.#$()}#zt(t){this.#tt.textContent=`${t.author.name||this.#r?.name||""}: ${t.body.slice(0,200)}`}#R(){let t=0;for(let e of this.#e.values())if(e.unread)t++;this.#s.setUnread(t)}#Et(){if(!this.#s.isOpen()||document.visibilityState!=="visible")return null;return this.#i?.kind==="thread"?this.#i.id:null}#$(){let t=this.#Et(),e=t?this.#e.get(t):void 0;if(!t||!e?.unread)return;this.#e.set(t,{...e,unread:!1}),this.#R(),this.#n.markRead(t).catch(()=>{let i=this.#e.get(t);if(i)this.#e.set(t,{...i,unread:!0});this.#R()})}#ft(t){this.#y=[...this.#y,...t].slice(0,Pt),this.#J(),this.#D(),this.#d.focus()}#gt(){if(this.#d.style.blockSize="",this.#d.value==="")return;this.#d.style.blockSize="auto",this.#d.style.blockSize=`${Math.max(38,Math.min(this.#d.scrollHeight,140))}px`}#D(){this.#A.disabled=this.#d.value.trim()===""&&this.#y.length===0}#Tt(){let t=this.#i?.kind==="thread"?this.#i.id:null;if(!t||this.#d.value.trim()===""){this.#M();return}if(Date.now()-this.#T>3000)this.#T=Date.now(),this.#n.setTyping(t,!0).catch(()=>{return});if(this.#k)clearTimeout(this.#k);this.#k=setTimeout(()=>this.#M(),4000)}#M(){if(this.#k)clearTimeout(this.#k);if(this.#k=null,this.#T===0)return;this.#T=0;let t=this.#i?.kind==="thread"?this.#i.id:null;if(t)this.#n.setTyping(t,!1).catch(()=>{return})}async#it(){if(this.#a!=="ready"||this.#i?.kind!=="thread")return;let t=this.#d.value.trim(),e=this.#y;if(!t&&e.length===0)return;if(this.#i.id===null&&this.#m.some((n)=>n.conversation===null))return;this.#M(),this.#d.value="",this.#y=[],this.#gt(),this.#J(),this.#D();let i={client_id:F(),conversation:this.#i.id,body:t,files:e,state:"sending"};this.#m.push(i),this.#o(),this.#P(),await this.#mt(i)}async#mt(t){t.state="sending",this.#o();let e={body:t.body,files:t.files,client_id:t.client_id};try{if(t.conversation===null){let i=await this.#n.startConversation(e),n=i.conversation.id;if(!this.#e.has(n))this.#e.set(n,i.conversation);if(!this.#l.has(n))this.#l.set(n,{messages:[],complete:!0,loading:!1});if(this.#i?.kind==="thread"&&this.#i.id===null)this.#i={kind:"thread",id:n};this.#et(i.message,!1)}else{let i=await this.#n.sendMessage(t.conversation,e);this.#et(i,!0)}this.#m=this.#m.filter((i)=>i!==t)}catch(i){let n=i instanceof g?i.status:0;t.state=n===413||n===415?"refused":"failed",t.status=n}this.#o(),this.#P()}async rate(t,e,i){try{let n=await this.#n.rate(t,e,i);return this.#e.set(n.id,n),this.#C.delete(t),this.#o(),n}catch(n){if(n instanceof g&&n.status===409){let s=await this.#n.getConversation(t).catch(()=>null);if(s)this.#e.set(s.id,s);this.#C.delete(t),this.#o()}throw n}}#Pt(t,e){if(this.#C.get(t)?.state==="sending")return;if(this.#C.set(t,{choice:e,state:"choosing"}),this.#o(),this.#u.focus({preventScroll:!0}),this.#I)this.#P()}async#yt(t,e){let i=this.#C.get(t);if(!i||i.state==="sending")return;i.state="sending",this.#o();try{await this.rate(t,i.choice,e?this.#u.value:void 0),this.#u.value=""}catch(n){if(n instanceof g&&n.status===409)return;i.state="failed",this.#o()}}async#It(){let t=this.#_.value.trim();if(!t||!this.#_.checkValidity()){this.#w=this.#t({id:"E_qvzP"}),this.#st();return}try{this.#g=await this.#n.setEmail(t),this.#q=!0,this.#w=""}catch{this.#w=this.#t({id:"ZxJcgC"})}this.#st()}#vt(t){let e=this.#U.get(t.id);if(e)return Promise.resolve(e);let i=this.#G.get(t.id);if(!i)i=this.#n.attachment(t.id).then((n)=>{let s=URL.createObjectURL(n);return this.#U.set(t.id,s),s}),i.catch(()=>this.#G.delete(t.id)),this.#G.set(t.id,i);return i}async#bt(t){let e=await this.#vt(t),i=r("a");i.href=e,i.download=t.filename,i.rel="noopener",i.click()}#xt(){return[...this.#e.values()].sort(It)}#Rt(){let t=this.#r;if(!t)return!1;return!t.open_now||t.mode==="async"||!t.presence?.available}#P(){this.#I=!0,this.#c.scrollTop=this.#c.scrollHeight,requestAnimationFrame(()=>{if(this.#I)this.#c.scrollTop=this.#c.scrollHeight})}#kt(){this.#d.placeholder=this.#t({id:"RzWUUK"}),this.#d.setAttribute("aria-label",this.#t({id:"xDAtGP"})),this.#j.setAttribute("aria-label",this.#t({id:"N7m8E-"})),this.#j.title=this.#t({id:"N7m8E-"}),this.#A.setAttribute("aria-label",this.#t({id:"JlFcis"})),this.#A.title=this.#t({id:"JlFcis"}),this.#_.placeholder=this.#t({id:"njBr8W"}),this.#_.setAttribute("aria-label",this.#t({id:"XJURKP"})),this.#D(),this.#J(),this.#o()}#o(){let t=this.#s.panel;if(t.childElementCount===0){let e=r("style");e.textContent=ut,t.append(e,this.#X,this.#V,this.#L,this.#tt),this.#X.id="yuva-title",t.setAttribute("aria-labelledby","yuva-title")}if(this.#Lt(),this.#nt(),this.#a!=="ready"){this.#B=void 0;let e=r("div","center");if(this.#a==="loading")e.append(r("p","hint",this.#t({id:"Pwqkdw"})));else{e.append(r("p","empty",this.#Mt()));let i=r("button","primary",this.#t({id:"KDw4GX"}));i.type="button",i.addEventListener("click",()=>{this.#v=null,this.#O()}),e.append(i)}this.#L.replaceChildren(e);return}if(this.#i?.kind==="list")this.#Ot();else this.#Ut()}#Mt(){switch(this.#f){case"anonymous_not_allowed":return this.#t({id:"zLzEI3"});case"invalid_identity_token":return this.#t({id:"0XGLbP"});case"rate_limited":return this.#t({id:"tzsBOP"});case"network":return this.#t({id:"GQVIIl"});default:return this.#t({id:"Amai22"})}}#Lt(){let{layout:t}=this.#s.config(),e=this.#r,i=[],n=this.#i;if(this.#a==="ready"&&n?.kind==="thread"&&(this.#e.size>1||n.id===null&&this.#e.size>0))i.push(T(S.back,this.#t({id:"S63MQu"}),()=>{this.#M(),this.#i={kind:"list"},this.#o()}));let s=r("div","heading");if(s.append(r("h2","title",e?.name||this.#t({id:"t7TeQU"}))),e){let o=r("div","status");if(e.mode==="live"&&e.open_now&&e.presence?.available){let l=r("div","avatars");for(let c of e.presence?.members.slice(0,3)??[]){let h=r("span","avatar",c.initials||"•");h.title=c.name,l.append(h)}o.append(l,r("span","dot"),r("span","",this.#t({id:"oXOSPE"})))}else if(!e.open_now||e.mode==="live")o.append(r("span","dot away"),r("span","",this.#t({id:"1EICzz"})));else o.append(r("span","",this.#At(e.expected_reply_minutes)));s.append(o)}if(i.push(s),t==="launcher")i.push(T(S.close,this.#t({id:"yz7wBu"}),()=>this.#s.close()));this.#X.replaceChildren(...i)}#At(t){if(!t)return this.#t({id:"nhTADq"});let{locale:e}=this.#s.config(),[i,n]=t<60?[t,"minute"]:t<1440?[Math.round(t/60),"hour"]:[Math.round(t/1440),"day"],s=new Intl.NumberFormat(e,{style:"unit",unit:n,unitDisplay:"long"}).format(i);return this.#t({id:"VggdQJ",values:{duration:s}})}#nt(){this.#V.hidden=!this.#h,this.#V.textContent=this.#t({id:"09Tv5j"})}#Ot(){this.#B=void 0;let{locale:t}=this.#s.config(),e=r("ul","list"),i=new Date().toDateString();for(let s of this.#xt()){let o=r("button",s.unread?"item unread":"item");o.type="button";let a=r("div","item-main"),l=r("div","item-top");l.append(r("span","item-subject",s.subject||this.#r?.name||this.#t({id:"YyNOE7"})));let c=new Date(s.last_message_at??s.created_at);l.append(r("span","item-time",new Intl.DateTimeFormat(t,c.toDateString()===i?{timeStyle:"short"}:{month:"short",day:"numeric"}).format(c)));let h=s.last_message?`${s.last_message.author_type==="contact"?this.#t({id:"ydzYKJ"})+" ":""}${s.last_message.text||this.#t({id:"UY1vmE"})}`:"",p=r("div","item-preview",h.replace(/\*\*|`/g,""));if(p.dir="auto",a.append(l,p),o.append(a),s.unread)o.append(r("span","unread-dot"));o.addEventListener("click",()=>void this.#$t(s.id));let u=r("li");u.append(o),e.append(u)}if(this.#E){let s=r("button","link",this.#t({id:"ASr-r0"}));s.type="button",s.style.margin="8px auto",s.style.display="block",s.addEventListener("click",()=>void this.#K(!0).then(()=>this.#o())),e.append(s)}let n=r("button","primary",this.#t({id:"-HY5kX"}));n.type="button",n.addEventListener("click",()=>{this.#i={kind:"thread",id:null},this.#o(),this.#d.focus()}),this.#L.replaceChildren(e,n)}async#$t(t){if(this.#i={kind:"thread",id:t},this.#o(),!this.#l.get(t)?.complete&&!this.#l.get(t)?.messages.length)await this.#F(t).catch(()=>{return});this.#o(),this.#P(),this.#$()}#Dt(t){let e=r("span","avatar",t.initials||""),i=t.avatar_url,n=i?this.#W.get(i):!1;if(!i||n===!1)return e;let s=r("img");if(s.alt="",s.referrerPolicy="no-referrer",n)return s.src=i,e.replaceChildren(s),e;return s.addEventListener("load",()=>{if(this.#W.set(i,!0),e.isConnected)e.replaceChildren(s)}),s.addEventListener("error",()=>this.#W.set(i,!1)),s.src=i,e}#Ut(){let t=this.#i;if(t?.kind!=="thread")return;let e=t.id,i=this.#B===e,n=this.#I,s=e?this.#l.get(e):void 0,o=s?.messages??[],a=this.#m.filter((d)=>d.conversation===e),l=[],c=this.#r?.chat.greeting;if(!s||s.complete){if(c){let d=r("div","bubble greeting");d.append(M(c)),l.push(d)}else if(o.length===0&&a.length===0){let d=r("div","center");d.append(r("p","empty",this.#t({id:"meAa31"})),r("p","hint",this.#t({id:"SdV5Cn"}))),l.push(d)}}else if(s.loading)l.push(r("p","hint",this.#t({id:"Pwqkdw"})));o.forEach((d,m)=>{let k=o[m-1],x=o[m+1]??(a.length>0?null:void 0),f=d.author.type==="contact",w=!k||L(k)!==L(d)||v(d.created_at)-v(k.created_at)>pt,W=x===void 0||(x===null?!f:L(x)!==L(d)||v(x.created_at)-v(d.created_at)>pt);if(!f&&w&&d.author.name)l.push(r("div","author",d.author.name));let A=r("div",`row ${f?"mine":"theirs"}${w&&m>0?" group-gap":""}`);if(!f){let E=this.#Dt(d.author);if(!W)E.style.visibility="hidden";A.append(E)}let z=r("div","bubble");if(z.dir="auto",z.title=new Date(d.created_at).toLocaleString(this.#s.config().locale),d.body.trim())z.append(M(d.body));if(d.attachments.length>0)z.append(this.#Bt(d.attachments));if(A.append(z),l.push(A),W){let E=this.#Nt(d.created_at);if(f&&m===o.length-1&&a.length===0){let q=e?this.#e.get(e)?.last_read_by_member_at:void 0,mt=q&&v(q)>=v(d.created_at);E+=` · ${mt?this.#t({id:"6lGaum"}):this.#t({id:"h69WC6"})}`}let O=r("div","meta",E);if(!f)O.style.alignSelf="flex-start";if(!f)O.style.marginInlineStart="36px";l.push(O)}});let h=e?this.#e.get(e):void 0,p=h?this.#jt(h):null;if(p)l.push(p);a.forEach((d,m)=>{let k=r("div",`row mine${m===0&&o.length>0&&o[o.length-1]?.author.type!=="contact"?" group-gap":""}`),x=r("div","bubble");if(x.dir="auto",d.body)x.append(M(d.body));if(d.files.length>0){let f=r("div","files");for(let w of d.files)f.append(r("span","file",w.name||"image"));x.append(f)}if(k.append(x),l.push(k),d.state==="failed"){let f=r("div","meta failed",`${this.#t({id:"upFvcp"})} `),w=r("button","link",this.#t({id:"6gRgw8"}));w.type="button",w.addEventListener("click",()=>void this.#mt(d)),f.append(w),l.push(f)}else if(d.state==="refused"){let f=d.status===413?this.#t({id:"eOu9Px"}):this.#t({id:"JkW3Ph"});l.push(r("div","meta failed",`${this.#t({id:"upFvcp"})} ${f}`))}else if(m===a.length-1)l.push(r("div","meta",this.#t({id:"Sad2tK"})))});let u=e?this.#b.get(e):void 0;if(u){let d=r("div","typing");d.append(r("i"),r("i"),r("i"));let m=u.name;d.append(r("span","",m?this.#t({id:"tHaDPf",values:{name:m}}):this.#t({id:"PxYAul"}))),l.push(d)}let y=this.#c.getRootNode().activeElement===this.#u,{selectionStart:P,selectionEnd:_}=this.#u;if(this.#c.replaceChildren(...l),y&&this.#u.isConnected)this.#u.focus({preventScroll:!0}),this.#u.setSelectionRange(P,_);if(this.#st(),this.#L.firstChild!==this.#c)this.#L.replaceChildren(this.#c,this.#S,this.#ot);if(this.#B=e,!i||n)this.#P()}#jt(t){let e=t.status==="closed"?t.rating:void 0,i=t.can_rate&&this.#r?.ask_for_rating?this.#C.get(t.id):void 0;if(!e&&!(t.can_rate&&this.#r?.ask_for_rating))return null;let n=this.#wt,s=[t.id,e,i?.choice,i?.state,this.#s.config().locale].join(":");if(s===this.#Q)return n;if(this.#Q=s,this.#rt!==t.id)this.#rt=t.id,this.#u.value="";let o=this.#t({id:"uA8iBc"});n.setAttribute("role","group"),n.setAttribute("aria-label",o);let a=r("div","choices");for(let u of["good","bad"]){if(e&&e!==u)continue;let b=r("button","choice",u==="good"?"\uD83D\uDC4D":"\uD83D\uDC4E");b.type="button";let y=u==="good"?this.#t({id:"OEEQKT"}):this.#t({id:"-f5Tkb"});b.setAttribute("aria-label",y),b.title=y,b.setAttribute("aria-pressed",String((e??i?.choice)===u)),b.disabled=!!e||i?.state==="sending",b.addEventListener("click",()=>this.#Pt(t.id,u)),a.append(b)}if(e)return n.replaceChildren(a,r("p","",this.#t({id:"SOk0EB"}))),n;if(n.replaceChildren(r("p","",o),a),!i)return n;this.#u.placeholder=this.#t({id:"axQ1h6"}),this.#u.setAttribute("aria-label",this.#t({id:"NBdIgR"})),this.#u.disabled=i.state==="sending";let l=r("form");l.addEventListener("submit",(u)=>{u.preventDefault(),this.#yt(t.id,!0)});let c=r("button","link",this.#t({id:"6Uau97"}));c.type="button",c.disabled=i.state==="sending",c.addEventListener("click",()=>void this.#yt(t.id,!1));let h=r("button","",i.state==="sending"?this.#t({id:"Sad2tK"}):this.#t({id:"JlFcis"}));h.type="submit",h.disabled=i.state==="sending";let p=r("div","actions");if(p.append(c,h),l.append(this.#u,p),n.append(l),i.state==="failed")n.append(r("p","error",this.#t({id:"4TqZiz"})));return n}#Bt(t){let e=r("div","files");for(let i of t)if(Rt(i)){let n=r("img");n.alt=i.filename;let s=this.#U.get(i.id);if(s)n.src=s;else this.#vt(i).then((o)=>{n.src=o}).catch(()=>{return});n.addEventListener("load",()=>{if(this.#I)this.#c.scrollTop=this.#c.scrollHeight}),n.addEventListener("click",()=>void this.#bt(i)),e.append(n)}else{let n=r("button","file");n.type="button",n.innerHTML=S.file,n.append(r("span","",i.filename)),n.addEventListener("click",()=>void this.#bt(i)),e.append(n)}return e}#Nt(t){return new Intl.DateTimeFormat(this.#s.config().locale,{timeStyle:"short"}).format(new Date(t))}#st(){let t=this.#g,e=this.#r?.chat,n=(this.#i?.kind==="thread"?this.#i.id:null)!==null||this.#m.length>0,s=t?.email||t?.typed_email,o=!!e?.ask_email_offline&&this.#Rt()&&n&&(!s||this.#q);if(this.#S.hidden=!o,!o)return;if(s&&this.#q){this.#S.replaceChildren(r("p","",this.#t({id:"iGNUZJ",values:{known:s}})));return}if(this.#S.querySelector("form")){let c=this.#S.querySelector(".error");if(c)c.textContent=this.#w;else if(this.#w)this.#S.append(r("p","error",this.#w));return}let a=r("form");a.noValidate=!0,a.addEventListener("submit",(c)=>{c.preventDefault(),this.#It()});let l=r("button","",this.#t({id:"tfDRzk"}));if(l.type="submit",a.append(this.#_,l),this.#S.replaceChildren(r("p","",this.#t({id:"M62PBt"})),a),this.#w)this.#S.append(r("p","error",this.#w))}#J(){this.#Z.hidden=this.#y.length===0,this.#Z.replaceChildren(...this.#y.map((t,e)=>{let i=r("span","chip");return i.append(r("span","",t.name||"image"),T(S.close,this.#t({id:"w61W3L",values:{0:t.name}}),()=>{this.#y=this.#y.filter((n,s)=>s!==e),this.#J(),this.#D()})),i}))}}function Mt(t){return new gt(t)}export{Mt as mount};
|
|
211
|
+
`;var ze=/(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\s][^*\n]*\*|_[^_\s][^_\n]*_)|((?:https?:\/\/|www\.)[^\s<>"]*[^\s<>".,:;'!?)\]])/g;function De(e,t){let i=document.createElement("a");return i.href=e,i.textContent=t,i.target="_blank",i.rel="noopener noreferrer nofollow ugc",i}function W(e,t){let i=document.createElement(e);return i.append(...t),i}function G(e){let t=[],i=0;for(let n of e.matchAll(ze)){let s=n.index??0;if(s>i)t.push(document.createTextNode(e.slice(i,s)));let[o,a,l,c,h]=n;if(a)t.push(W("code",[document.createTextNode(a.slice(1,-1))]));else if(l)t.push(W("strong",G(l.slice(2,-2))));else if(c)t.push(W("em",G(c.slice(1,-1))));else if(h){let p=h.startsWith("www.")?`https://${h}`:h;try{let u=new URL(p);t.push(u.protocol==="http:"||u.protocol==="https:"?De(u.href,h):document.createTextNode(h))}catch{t.push(document.createTextNode(h))}}i=s+o.length}if(i<e.length)t.push(document.createTextNode(e.slice(i)));return t}function M(e){let t=document.createDocumentFragment(),i=e.trim().replace(/\r\n?/g,`
|
|
212
|
+
`).split(/^```[^\n]*\n([\s\S]*?)^```[ \t]*$/m);return i.forEach((n,s)=>{if(s%2===1){let a=document.createElement("pre");a.textContent=n.replace(/\n$/,""),t.append(a);return}(i.length>1?n.replace(/^\n|\n$/g,""):n).split(`
|
|
213
|
+
`).forEach((a,l)=>{if(l>0)t.append(document.createElement("br"));t.append(...G(a))})}),t}var Ie={en:Y,tr:se},Me=10,ge=300000,P={close:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>',back:'<svg class="flip" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 6l-6 6 6 6"/></svg>',attach:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 11.5l-8.3 8.3a5 5 0 01-7-7L13 4.5a3.3 3.3 0 014.7 4.7l-8.3 8.3a1.7 1.7 0 01-2.4-2.4L14.5 7.6"/></svg>',send:'<svg class="flip" width="20" height="20" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M3.4 20.4l17.5-7.5a1 1 0 000-1.8L3.4 3.6a1 1 0 00-1.4 1.2L4.5 12l-2.5 7.2a1 1 0 001.4 1.2zM4.5 12h7"/></svg>',file:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H6v18h12V7z M14 3v4h4"/></svg>'};function r(e,t,i){let n=document.createElement(e);if(t)n.className=t;if(i!==void 0)n.textContent=i;return n}function R(e,t,i,n="icon"){let s=r("button",n);return s.type="button",s.innerHTML=e,s.setAttribute("aria-label",t),s.title=t,s.addEventListener("click",i),s}var x=(e)=>Date.parse(e),me=(e,t)=>x(e.created_at)-x(t.created_at),Le=(e,t)=>x(t.last_message_at??t.created_at)-x(e.last_message_at??e.created_at),L=(e)=>e.author.type==="contact"?"contact":`${e.author.type}:${e.author.name??""}`,Oe=(e)=>/^image\/(png|jpeg|gif|webp)$/.test(e.content_type);class ye{#s;#m;#n;#r=null;#y=null;#a="loading";#u="";#w=null;#C=null;#t=new Map;#v;#p=new Map;#l=[];#k=new Map;#i=null;#b=!1;#x=[];#R=0;#f=null;#c=new Map;#D=new Map;#I=new Map;#M=!1;#S="";#q=!1;#_=new Map;#ke=r("div","card rate");#g=r("textarea");#Q="";#re=null;#X=r("header","header");#V=r("div","banner");#$=r("div","body");#d=r("div","scroll");#P=r("div","card");#T=r("input");#oe=r("div","composer");#Z=r("div","chips");#h=r("textarea");#E=r("input");#U;#Y;#ee=r("div","sr");#K;#L=!0;constructor(e){this.#s=e;let{server:t,channel:i}=e.config();this.#n=pe({server:t,channel:i??"",identityToken:()=>e.identityToken()}),this.#n.on("event",(s)=>this.#_e(s)),this.#n.on("connection",({state:s,attempt:o})=>{if(s!=="reconnecting")return;this.#b=o>0,this.#ne()}),this.#n.on("session",({session:s,renewed:o})=>{if(this.#J(s.inbox),this.#y=s.contact,o)this.#pe()}),this.#le(),this.#ee.setAttribute("aria-live","polite"),this.#d.addEventListener("scroll",()=>{if(this.#L=this.#d.scrollHeight-this.#d.scrollTop-this.#d.clientHeight<48,this.#d.scrollTop<60&&this.#i?.kind==="thread"&&this.#i.id)this.#G(this.#i.id,!0)}),this.#h.rows=1,this.#h.addEventListener("keydown",(s)=>{if(s.key==="Enter"&&!s.shiftKey&&!s.isComposing)s.preventDefault(),this.#ie()}),this.#h.addEventListener("input",()=>{this.#ge(),this.#B(),this.#Ee()}),this.#h.addEventListener("paste",(s)=>{let o=Array.from(s.clipboardData?.files??[]);if(o.length===0)return;s.preventDefault(),this.#fe(o)}),this.#E.type="file",this.#E.multiple=!0,this.#E.hidden=!0,this.#E.addEventListener("change",()=>{this.#fe(Array.from(this.#E.files??[])),this.#E.value=""}),this.#Y=R(P.attach,"",()=>this.#E.click()),this.#U=R(P.send,"",()=>void this.#ie(),"icon send");let n=r("form");n.addEventListener("submit",(s)=>{s.preventDefault(),this.#ie()}),n.append(this.#Y,this.#h,this.#U,this.#E),this.#oe.append(this.#Z,n),this.#T.type="email",this.#T.required=!0,this.#T.autocomplete="email",this.#g.rows=2,this.#g.maxLength=2000,this.#g.dir="auto",document.addEventListener("visibilitychange",this.#F),window.addEventListener("online",this.#F),this.#we(),this.#j()}update(){this.#le(),this.#we()}opened(){if(this.#a==="error"){this.#w=null,this.#j();return}if(this.#a==="ready")this.#n.token?this.#Se():this.#ce().then(()=>this.#o()).catch(()=>{return});if(this.#o(),this.#z(),this.#N(),this.#s.config().layout==="launcher")this.#h.focus({preventScroll:!0})}closed(){this.#A()}identityChanged(){this.#ae(),this.#j()}async signOut(){let e=this.#n.signOut();if(this.#ae(),await e,this.#s.isOpen())this.#j();else this.#o()}destroy(){this.#n.reset(),this.#A(),document.removeEventListener("visibilitychange",this.#F),window.removeEventListener("online",this.#F);for(let e of this.#c.values())URL.revokeObjectURL(e)}#ae(){this.#n.reset(),this.#w=null,this.#C=null,this.#r=null,this.#y=null,this.#a="loading",this.#t.clear(),this.#p.clear(),this.#l=[],this.#_.clear(),this.#Q="",this.#i=null,this.#q=!1,this.#s.setUnread(0)}#F=()=>{if(document.visibilityState!=="visible")return;this.#n.reconnect(),this.#N(),this.#he()};#le(){let{locale:e}=this.#s.config();this.#m=B({locale:e,messages:{[e]:Ie[e]??Y}})}#e(e){return this.#m._(e)}#j(){return this.#w??=(async()=>{this.#a="loading",this.#o();let{channel:e}=this.#s.config();if(!e)throw new f(0,"not_configured");if(await this.#s.identityToken()||K(e).session)await this.#Ce();else if(await this.#ce(),!this.#r?.chat.allow_anonymous)throw new f(403,"anonymous_not_allowed");if(this.#a="ready",!this.#i){let t=this.#xe();if(this.#i=t.length>1?{kind:"list"}:{kind:"thread",id:t[0]?.id??null},this.#i.kind==="thread"&&this.#i.id)await this.#G(this.#i.id)}this.#o(),this.#z(),this.#N()})().catch((e)=>{if(this.#w=null,this.#ue(e))return;this.#a="error",this.#u=e instanceof f?e.code:"error",this.#o()}),this.#w}async#ce(){let e=await this.#de();if(!this.#n.token)this.#J(e)}#de(){if(!this.#s.config().channel)throw new f(0,"not_configured");return this.#n.channelSettings()}#J(e){let{channel:t}=this.#s.config();this.#r=e;let i=re(e);if(this.#s.setLauncher(i),t)ae(t,{...K(t),launcher:i})}async#he(){if(this.#a!=="ready")return;try{this.#J(await this.#de()),this.#o()}catch(e){this.#ue(e,!0)}}#ue(e,t=!this.#n.token){let i=e instanceof f&&(e.code==="origin_not_allowed"||e.status===404&&t);if(i)this.#s.refused();return i}#Ce(){return this.#C??=(async()=>{await this.#n.start(),await this.#W(),await this.#n.connect()})().finally(()=>{this.#C=null}),this.#C}async#Se(){try{await this.#n.refresh(),this.#o()}catch{}}async#W(e=!1){let t=await this.#n.listConversations({limit:50,cursor:e?this.#v:void 0});if(!e)this.#t.clear();for(let i of t.items)this.#t.set(i.id,i);this.#v=t.next_cursor,this.#O()}async#pe(){await this.#W();let e=this.#i?.kind==="thread"?this.#i.id:null;for(let t of this.#p.keys())if(t!==e)this.#p.delete(t);if(e)this.#p.delete(e),await this.#G(e);this.#o()}async#G(e,t=!1){let i=this.#p.get(e);if(!i)i={messages:[],complete:!1,loading:!1},this.#p.set(e,i);if(i.loading||t&&(i.complete||!i.cursor))return;i.loading=!0;let n=this.#d.scrollHeight-this.#d.scrollTop;try{let s=await this.#n.listMessages(e,{order:"desc",limit:30,cursor:t?i.cursor:void 0}),o=new Set(i.messages.map((a)=>a.id));i.messages=[...i.messages,...s.items.filter((a)=>!o.has(a.id))].sort(me),i.cursor=s.next_cursor,i.complete=!s.next_cursor}finally{i.loading=!1}if(t)this.#o(),this.#d.scrollTop=this.#d.scrollHeight-n}#_e(e){switch(e.type){case"ready":if(this.#b=!1,this.#ne(),this.#q)this.#he();this.#q=!0;return;case"inbox.updated":{let t=this.#r?.ask_for_rating;if(this.#J(e.data),t!==void 0&&t!==e.data.ask_for_rating)this.#W().then(()=>this.#o()).catch(()=>{return});break}case"resync_required":this.#pe();return;case"presence":if(this.#r)this.#r={...this.#r,presence:e.data};break;case"conversation.created":if(!this.#t.has(e.data.id))this.#t.set(e.data.id,e.data);if(this.#i?.kind==="thread"&&this.#i.id===null&&this.#t.size>1)this.#i=this.#l.some((t)=>t.conversation===null)?this.#i:{kind:"list"};this.#O();break;case"conversation.updated":{let t=this.#t.get(e.data.id),{status:i,can_rate:n,rating:s}=e.data;if(t)this.#t.set(t.id,{...t,status:i,can_rate:n,rating:s});if(!n)this.#_.delete(e.data.id);break}case"message.created":case"message.updated":this.#te(e.data,e.type==="message.created");break;case"read":{let t=this.#t.get(e.data.conversation_id),i=t?.last_read_by_member_at;if(t&&(!i||x(e.data.read_at)>x(i)))this.#t.set(t.id,{...t,last_read_by_member_at:e.data.read_at});break}case"typing":{let t=e.data.conversation_id,i=this.#k.get(t);if(i)clearTimeout(i.timer);if(e.data.typing){let n=e.data.author.name??"";this.#k.set(t,{name:n,timer:setTimeout(()=>this.#k.delete(t)&&this.#o(),8000)})}else this.#k.delete(t);break}}this.#o()}#te(e,t){let i=e.conversation_id,n=this.#p.get(i);if(n){let o=n.messages.findIndex((a)=>a.id===e.id);if(o>=0)n.messages[o]=e;else n.messages=[...n.messages,e].sort(me)}if(e.client_id)this.#l=this.#l.filter((o)=>o.client_id!==e.client_id);let s=this.#t.get(i);if(!s){this.#n.getConversation(i).then((o)=>{this.#t.set(o.id,o),this.#O(),this.#o()}).catch(()=>{return});return}if(t){let o=e.body.replace(/\s+/g," ").trim();if(this.#t.set(i,{...s,last_message:{id:e.id,author_type:e.author.type,text:o.length>140?`${o.slice(0,139)}…`:o,created_at:e.created_at},last_message_at:e.created_at,unread:s.unread||e.author.type!=="contact"}),e.author.type!=="contact"){let a=this.#k.get(i);if(a)clearTimeout(a.timer);this.#k.delete(i),this.#Pe(e)}}this.#O(),this.#N()}#Pe(e){this.#ee.textContent=`${e.author.name||this.#r?.name||""}: ${e.body.slice(0,200)}`}#O(){let e=0;for(let t of this.#t.values())if(t.unread)e++;this.#s.setUnread(e)}#Te(){if(!this.#s.isOpen()||document.visibilityState!=="visible")return null;return this.#i?.kind==="thread"?this.#i.id:null}#N(){let e=this.#Te(),t=e?this.#t.get(e):void 0;if(!e||!t?.unread)return;this.#t.set(e,{...t,unread:!1}),this.#O(),this.#n.markRead(e).catch(()=>{let i=this.#t.get(e);if(i)this.#t.set(e,{...i,unread:!0});this.#O()})}#fe(e){this.#x=[...this.#x,...e].slice(0,Me),this.#H(),this.#B(),this.#h.focus()}#ge(){if(this.#h.style.blockSize="",this.#h.value==="")return;this.#h.style.blockSize="auto",this.#h.style.blockSize=`${Math.max(38,Math.min(this.#h.scrollHeight,140))}px`}#B(){this.#U.disabled=this.#h.value.trim()===""&&this.#x.length===0}#Ee(){let e=this.#i?.kind==="thread"?this.#i.id:null;if(!e||this.#h.value.trim()===""){this.#A();return}if(Date.now()-this.#R>3000)this.#R=Date.now(),this.#n.setTyping(e,!0).catch(()=>{return});if(this.#f)clearTimeout(this.#f);this.#f=setTimeout(()=>this.#A(),4000)}#A(){if(this.#f)clearTimeout(this.#f);if(this.#f=null,this.#R===0)return;this.#R=0;let e=this.#i?.kind==="thread"?this.#i.id:null;if(e)this.#n.setTyping(e,!1).catch(()=>{return})}async#ie(){if(this.#a!=="ready"||this.#i?.kind!=="thread")return;let e=this.#h.value.trim(),t=this.#x;if(!e&&t.length===0)return;if(this.#i.id===null&&this.#l.some((n)=>n.conversation===null))return;this.#A(),this.#h.value="",this.#x=[],this.#ge(),this.#H(),this.#B();let i={client_id:I(),conversation:this.#i.id,body:e,files:t,state:"sending"};this.#l.push(i),this.#o(),this.#z(),await this.#me(i)}async#me(e){e.state="sending",this.#o();let t={body:e.body,files:e.files,client_id:e.client_id};try{if(e.conversation===null){let i=await this.#n.startConversation(t),n=i.conversation.id;if(!this.#t.has(n))this.#t.set(n,i.conversation);if(!this.#p.has(n))this.#p.set(n,{messages:[],complete:!0,loading:!1});if(this.#i?.kind==="thread"&&this.#i.id===null)this.#i={kind:"thread",id:n};this.#te(i.message,!1)}else{let i=await this.#n.sendMessage(e.conversation,t);this.#te(i,!0)}this.#l=this.#l.filter((i)=>i!==e)}catch(i){let n=i instanceof f?i.status:0;e.state=n===413||n===415?"refused":"failed",e.status=n}this.#o(),this.#z()}async rate(e,t,i){try{let n=await this.#n.rate(e,t,i);return this.#t.set(n.id,n),this.#_.delete(e),this.#o(),n}catch(n){if(n instanceof f&&n.status===409){let s=await this.#n.getConversation(e).catch(()=>null);if(s)this.#t.set(s.id,s);this.#_.delete(e),this.#o()}throw n}}#Re(e,t){if(this.#_.get(e)?.state==="sending")return;if(this.#_.set(e,{choice:t,state:"choosing"}),this.#o(),this.#g.focus({preventScroll:!0}),this.#L)this.#z()}async#ye(e,t){let i=this.#_.get(e);if(!i||i.state==="sending")return;i.state="sending",this.#o();try{await this.rate(e,i.choice,t?this.#g.value:void 0),this.#g.value=""}catch(n){if(n instanceof f&&n.status===409)return;i.state="failed",this.#o()}}async#ze(){let e=this.#T.value.trim();if(!e||!this.#T.checkValidity()){this.#S=this.#e({id:"E_qvzP"}),this.#se();return}try{this.#y=await this.#n.setEmail(e),this.#M=!0,this.#S=""}catch{this.#S=this.#e({id:"ZxJcgC"})}this.#se()}#ve(e){let t=this.#c.get(e.id);if(t)return Promise.resolve(t);let i=this.#D.get(e.id);if(!i)i=this.#n.attachment(e.id).then((n)=>{let s=URL.createObjectURL(n);return this.#c.set(e.id,s),s}),i.catch(()=>this.#D.delete(e.id)),this.#D.set(e.id,i);return i}async#be(e){let t=await this.#ve(e),i=r("a");i.href=t,i.download=e.filename,i.rel="noopener",i.click()}#xe(){return[...this.#t.values()].sort(Le)}#De(){let e=this.#r;if(!e)return!1;return!e.open_now||e.mode==="async"||!e.presence?.available}#z(){this.#L=!0,this.#d.scrollTop=this.#d.scrollHeight,requestAnimationFrame(()=>{if(this.#L)this.#d.scrollTop=this.#d.scrollHeight})}#we(){this.#h.placeholder=this.#e({id:"RzWUUK"}),this.#h.setAttribute("aria-label",this.#e({id:"xDAtGP"})),this.#Y.setAttribute("aria-label",this.#e({id:"N7m8E-"})),this.#Y.title=this.#e({id:"N7m8E-"}),this.#U.setAttribute("aria-label",this.#e({id:"JlFcis"})),this.#U.title=this.#e({id:"JlFcis"}),this.#T.placeholder=this.#e({id:"njBr8W"}),this.#T.setAttribute("aria-label",this.#e({id:"XJURKP"})),this.#B(),this.#H(),this.#o()}#o(){let e=this.#s.panel;if(e.childElementCount===0){let t=r("style");t.textContent=fe,e.append(t,this.#X,this.#V,this.#$,this.#ee),this.#X.id="yuva-title",e.setAttribute("aria-labelledby","yuva-title")}if(this.#Me(),this.#ne(),this.#a!=="ready"){this.#K=void 0;let t=r("div","center");if(this.#a==="loading")t.append(r("p","hint",this.#e({id:"Pwqkdw"})));else{t.append(r("p","empty",this.#Ie()));let i=r("button","primary",this.#e({id:"KDw4GX"}));i.type="button",i.addEventListener("click",()=>{this.#w=null,this.#j()}),t.append(i)}this.#$.replaceChildren(t);return}if(this.#i?.kind==="list")this.#Oe();else this.#Ue()}#Ie(){switch(this.#u){case"anonymous_not_allowed":return this.#e({id:"zLzEI3"});case"invalid_identity_token":return this.#e({id:"0XGLbP"});case"rate_limited":return this.#e({id:"tzsBOP"});case"network":return this.#e({id:"GQVIIl"});default:return this.#e({id:"Amai22"})}}#Me(){let{layout:e}=this.#s.config(),t=this.#r,i=[],n=this.#i;if(this.#a==="ready"&&n?.kind==="thread"&&(this.#t.size>1||n.id===null&&this.#t.size>0))i.push(R(P.back,this.#e({id:"S63MQu"}),()=>{this.#A(),this.#i={kind:"list"},this.#o()}));let s=r("div","heading");if(s.append(r("h2","title",t?.name||this.#e({id:"t7TeQU"}))),t){let o=r("div","status");if(t.mode==="live"&&t.open_now&&t.presence?.available){let l=r("div","avatars");for(let c of t.presence?.members.slice(0,3)??[]){let h=r("span","avatar",c.initials||"•");h.title=c.name,l.append(h)}o.append(l,r("span","dot"),r("span","",this.#e({id:"oXOSPE"})))}else if(!t.open_now||t.mode==="live")o.append(r("span","dot away"),r("span","",this.#e({id:"1EICzz"})));else o.append(r("span","",this.#Le(t.expected_reply_minutes)));s.append(o)}if(i.push(s),e==="launcher")i.push(R(P.close,this.#e({id:"yz7wBu"}),()=>this.#s.close()));this.#X.replaceChildren(...i)}#Le(e){if(!e)return this.#e({id:"nhTADq"});let{locale:t}=this.#s.config(),[i,n]=e<60?[e,"minute"]:e<1440?[Math.round(e/60),"hour"]:[Math.round(e/1440),"day"],s=new Intl.NumberFormat(t,{style:"unit",unit:n,unitDisplay:"long"}).format(i);return this.#e({id:"VggdQJ",values:{duration:s}})}#ne(){this.#V.hidden=!this.#b,this.#V.textContent=this.#e({id:"09Tv5j"})}#Oe(){this.#K=void 0;let{locale:e}=this.#s.config(),t=r("ul","list"),i=new Date().toDateString();for(let s of this.#xe()){let o=r("button",s.unread?"item unread":"item");o.type="button";let a=r("div","item-main"),l=r("div","item-top");l.append(r("span","item-subject",s.subject||this.#r?.name||this.#e({id:"YyNOE7"})));let c=new Date(s.last_message_at??s.created_at);l.append(r("span","item-time",new Intl.DateTimeFormat(e,c.toDateString()===i?{timeStyle:"short"}:{month:"short",day:"numeric"}).format(c)));let h=s.last_message?`${s.last_message.author_type==="contact"?this.#e({id:"ydzYKJ"})+" ":""}${s.last_message.text||this.#e({id:"UY1vmE"})}`:"",p=r("div","item-preview",h.replace(/\*\*|`/g,""));if(p.dir="auto",a.append(l,p),o.append(a),s.unread)o.append(r("span","unread-dot"));o.addEventListener("click",()=>void this.#Ae(s.id));let u=r("li");u.append(o),t.append(u)}if(this.#v){let s=r("button","link",this.#e({id:"ASr-r0"}));s.type="button",s.style.margin="8px auto",s.style.display="block",s.addEventListener("click",()=>void this.#W(!0).then(()=>this.#o())),t.append(s)}let n=r("button","primary",this.#e({id:"-HY5kX"}));n.type="button",n.addEventListener("click",()=>{this.#i={kind:"thread",id:null},this.#o(),this.#h.focus()}),this.#$.replaceChildren(t,n)}async#Ae(e){if(this.#i={kind:"thread",id:e},this.#o(),!this.#p.get(e)?.complete&&!this.#p.get(e)?.messages.length)await this.#G(e).catch(()=>{return});this.#o(),this.#z(),this.#N()}#$e(e){let t=r("span","avatar",e.initials||""),i=e.avatar_url,n=i?this.#I.get(i):!1;if(!i||n===!1)return t;let s=r("img");if(s.alt="",s.referrerPolicy="no-referrer",n)return s.src=i,t.replaceChildren(s),t;return s.addEventListener("load",()=>{if(this.#I.set(i,!0),t.isConnected)t.replaceChildren(s)}),s.addEventListener("error",()=>this.#I.set(i,!1)),s.src=i,t}#Ue(){let e=this.#i;if(e?.kind!=="thread")return;let t=e.id,i=this.#K===t,n=this.#L,s=t?this.#p.get(t):void 0,o=s?.messages??[],a=this.#l.filter((d)=>d.conversation===t),l=[],c=this.#r?.chat.greeting;if(!s||s.complete){if(c){let d=r("div","bubble greeting");d.append(M(c)),l.push(d)}else if(o.length===0&&a.length===0){let d=r("div","center");d.append(r("p","empty",this.#e({id:"meAa31"})),r("p","hint",this.#e({id:"SdV5Cn"}))),l.push(d)}}else if(s.loading)l.push(r("p","hint",this.#e({id:"Pwqkdw"})));o.forEach((d,v)=>{let k=o[v-1],w=o[v+1]??(a.length>0?null:void 0),m=d.author.type==="contact",C=!k||L(k)!==L(d)||x(d.created_at)-x(k.created_at)>ge,H=w===void 0||(w===null?!m:L(w)!==L(d)||x(w.created_at)-x(d.created_at)>ge);if(!m&&C&&d.author.name)l.push(r("div","author",d.author.name));let O=r("div",`row ${m?"mine":"theirs"}${C&&v>0?" group-gap":""}`);if(!m){let E=this.#$e(d.author);if(!H)E.style.visibility="hidden";O.append(E)}let T=r("div","bubble");if(T.dir="auto",T.title=new Date(d.created_at).toLocaleString(this.#s.config().locale),d.body.trim())T.append(M(d.body));if(d.attachments.length>0)T.append(this.#Ne(d.attachments));if(O.append(T),l.push(O),H){let E=this.#Be(d.created_at);if(m&&v===o.length-1&&a.length===0){let q=t?this.#t.get(t)?.last_read_by_member_at:void 0,ve=q&&x(q)>=x(d.created_at);E+=` · ${ve?this.#e({id:"6lGaum"}):this.#e({id:"h69WC6"})}`}let A=r("div","meta",E);if(!m)A.style.alignSelf="flex-start";if(!m)A.style.marginInlineStart="36px";l.push(A)}});let h=t?this.#t.get(t):void 0,p=h?this.#je(h):null;if(p)l.push(p);a.forEach((d,v)=>{let k=r("div",`row mine${v===0&&o.length>0&&o[o.length-1]?.author.type!=="contact"?" group-gap":""}`),w=r("div","bubble");if(w.dir="auto",d.body)w.append(M(d.body));if(d.files.length>0){let m=r("div","files");for(let C of d.files)m.append(r("span","file",C.name||"image"));w.append(m)}if(k.append(w),l.push(k),d.state==="failed"){let m=r("div","meta failed",`${this.#e({id:"upFvcp"})} `),C=r("button","link",this.#e({id:"6gRgw8"}));C.type="button",C.addEventListener("click",()=>void this.#me(d)),m.append(C),l.push(m)}else if(d.state==="refused"){let m=d.status===413?this.#e({id:"eOu9Px"}):this.#e({id:"JkW3Ph"});l.push(r("div","meta failed",`${this.#e({id:"upFvcp"})} ${m}`))}else if(v===a.length-1)l.push(r("div","meta",this.#e({id:"Sad2tK"})))});let u=t?this.#k.get(t):void 0;if(u){let d=r("div","typing");d.append(r("i"),r("i"),r("i"));let v=u.name;d.append(r("span","",v?this.#e({id:"tHaDPf",values:{name:v}}):this.#e({id:"PxYAul"}))),l.push(d)}let g=this.#d.getRootNode().activeElement===this.#g,{selectionStart:_,selectionEnd:b}=this.#g;if(this.#d.replaceChildren(...l),g&&this.#g.isConnected)this.#g.focus({preventScroll:!0}),this.#g.setSelectionRange(_,b);if(this.#se(),this.#$.firstChild!==this.#d)this.#$.replaceChildren(this.#d,this.#P,this.#oe);if(this.#K=t,!i||n)this.#z()}#je(e){let t=e.status==="closed"?e.rating:void 0,i=e.can_rate&&this.#r?.ask_for_rating?this.#_.get(e.id):void 0;if(!t&&!(e.can_rate&&this.#r?.ask_for_rating))return null;let n=this.#ke,s=[e.id,t,i?.choice,i?.state,this.#s.config().locale].join(":");if(s===this.#Q)return n;if(this.#Q=s,this.#re!==e.id)this.#re=e.id,this.#g.value="";let o=this.#e({id:"uA8iBc"});n.setAttribute("role","group"),n.setAttribute("aria-label",o);let a=r("div","choices");for(let u of["good","bad"]){if(t&&t!==u)continue;let y=r("button","choice",u==="good"?"\uD83D\uDC4D":"\uD83D\uDC4E");y.type="button";let g=u==="good"?this.#e({id:"OEEQKT"}):this.#e({id:"-f5Tkb"});y.setAttribute("aria-label",g),y.title=g,y.setAttribute("aria-pressed",String((t??i?.choice)===u)),y.disabled=!!t||i?.state==="sending",y.addEventListener("click",()=>this.#Re(e.id,u)),a.append(y)}if(t)return n.replaceChildren(a,r("p","",this.#e({id:"SOk0EB"}))),n;if(n.replaceChildren(r("p","",o),a),!i)return n;this.#g.placeholder=this.#e({id:"axQ1h6"}),this.#g.setAttribute("aria-label",this.#e({id:"NBdIgR"})),this.#g.disabled=i.state==="sending";let l=r("form");l.addEventListener("submit",(u)=>{u.preventDefault(),this.#ye(e.id,!0)});let c=r("button","link",this.#e({id:"6Uau97"}));c.type="button",c.disabled=i.state==="sending",c.addEventListener("click",()=>void this.#ye(e.id,!1));let h=r("button","",i.state==="sending"?this.#e({id:"Sad2tK"}):this.#e({id:"JlFcis"}));h.type="submit",h.disabled=i.state==="sending";let p=r("div","actions");if(p.append(c,h),l.append(this.#g,p),n.append(l),i.state==="failed")n.append(r("p","error",this.#e({id:"4TqZiz"})));return n}#Ne(e){let t=r("div","files");for(let i of e)if(Oe(i)){let n=r("img");n.alt=i.filename;let s=this.#c.get(i.id);if(s)n.src=s;else this.#ve(i).then((o)=>{n.src=o}).catch(()=>{return});n.addEventListener("load",()=>{if(this.#L)this.#d.scrollTop=this.#d.scrollHeight}),n.addEventListener("click",()=>void this.#be(i)),t.append(n)}else{let n=r("button","file");n.type="button",n.innerHTML=P.file,n.append(r("span","",i.filename)),n.addEventListener("click",()=>void this.#be(i)),t.append(n)}return t}#Be(e){return new Intl.DateTimeFormat(this.#s.config().locale,{timeStyle:"short"}).format(new Date(e))}#se(){let e=this.#y,t=this.#r?.chat,n=(this.#i?.kind==="thread"?this.#i.id:null)!==null||this.#l.length>0,s=e?.email||e?.typed_email,o=!!t?.ask_email_offline&&this.#De()&&n&&(!s||this.#M);if(this.#P.hidden=!o,!o)return;if(s&&this.#M){this.#P.replaceChildren(r("p","",this.#e({id:"iGNUZJ",values:{known:s}})));return}if(this.#P.querySelector("form")){let c=this.#P.querySelector(".error");if(c)c.textContent=this.#S;else if(this.#S)this.#P.append(r("p","error",this.#S));return}let a=r("form");a.noValidate=!0,a.addEventListener("submit",(c)=>{c.preventDefault(),this.#ze()});let l=r("button","",this.#e({id:"tfDRzk"}));if(l.type="submit",a.append(this.#T,l),this.#P.replaceChildren(r("p","",this.#e({id:"M62PBt"})),a),this.#S)this.#P.append(r("p","error",this.#S))}#H(){this.#Z.hidden=this.#x.length===0,this.#Z.replaceChildren(...this.#x.map((e,t)=>{let i=r("span","chip");return i.append(r("span","",e.name||"image"),R(P.close,this.#e({id:"w61W3L",values:{0:e.name}}),()=>{this.#x=this.#x.filter((n,s)=>s!==t),this.#H(),this.#B()})),i}))}}function Ae(e){return new ye(e)}export{Ae as mount};
|