useyuva 0.0.28 → 0.0.30

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.
@@ -125,4 +125,4 @@ var we=JSON.parse(`{"-g5O6h":["Choose at least one list."],"-qzaeL":["Voting and
125
125
  .wn-label.fixed { color: var(--yuva-muted); }
126
126
  .wn-image { display: block; max-inline-size: 100%; block-size: auto; border-radius: 10px; border: 1px solid var(--yuva-border); }
127
127
  .who-line b { font-weight: 500; }
128
- `;var ht=2100;function Ue(n,e,l){let{client:r,locale:d}=n,s=[],c="",b=0,y=!1,N=!1,x="idle",_=!1,g="",S="",C="",V=!1,W=new Set,I=t("input","field");I.type="email",I.autocomplete="email",I.value=r.session?.contact.email??"",I.placeholder=e({id:"njBr8W"}),I.setAttribute("aria-label",e({id:"XJURKP"}));let D=t("input");D.type="checkbox",D.id="yuva-consent",D.addEventListener("change",()=>{C="",k()});function R(){return s.filter((h)=>W.has(h.id))}function A(h){let v=new Intl.ListFormat(d,{type:"conjunction"}).format(h.map((P)=>P.name)),U=n.inbox.name;return e({id:"dMJfG5",values:{list:v,inbox:U}})}async function B(){try{let h=await r.lists();s=h.lists,c=h.form_token,b=Date.now();for(let v of s)W.add(v.id)}catch{N=!0}y=!0,k()}async function z(){if(x!=="idle")return;let h=R(),v=I.value.trim();if(g=h.length===0?e({id:"-g5O6h"}):"",S=I.checkValidity()&&v?"":e({id:"E_qvzP"}),C=D.checked?"":e({id:"lDEbTy"}),g||S||C){k();return}x="sending",k();let U=async(P)=>{let p=b+ht-Date.now();if(p>0)await new Promise((o)=>setTimeout(o,p));try{_=(await r.subscribe({email:v,list_ids:h.map((u)=>u.id),locale:d,page_url:location.href.split("#")[0].slice(0,2000),consent_text:A(h),form_token:c})).confirmation}catch(o){if(P&&o instanceof te&&o.code==="form_token")return c=(await r.lists()).form_token,b=Date.now(),U(!1);throw o}};try{await U(!0),x="done"}catch(P){if(x="idle",P instanceof te&&P.code==="invalid_email")S=e({id:"E_qvzP"});else g=P instanceof te&&P.code==="rate_limited"?e({id:"tzsBOP"}):P instanceof te&&P.code==="network"?e({id:"GQVIIl"}):e({id:"jWgNnM"})}if(!V)k()}function k(){if(V)return;let h=t("section","sec");if(h.append(t("h2","label",`01 — ${e({id:"7kOr80"})}`)),!y)h.append(t("p","hint",e({id:"Pwqkdw"})));else if(N||s.length===0)h.append(t("p","hint",e({id:"jWgNnM"})));else if(x==="done"){let v=t("div","done-card");v.insertAdjacentHTML("beforeend",j.check),v.append(t("p","empty",_?e({id:"y3k2zM"}):e({id:"rgySXy"}))),h.append(v)}else{let v=t("form","form");v.noValidate=!0,v.addEventListener("submit",(o)=>{o.preventDefault(),z()});let U=t("div","row2"),P=t("button","btn",x==="sending"?e({id:"1w51t9"}):e({id:"EDl9kS"}));if(P.type="submit",P.disabled=x==="sending",U.append(I,P),v.append(U),S)v.append(t("p","error",S));if(s.length>1){let o=t("div","lists");o.setAttribute("role","group"),o.setAttribute("aria-label",e({id:"h16FyT"}));for(let u of s){let F=t("label","check"),T=t("input");T.type="checkbox",T.checked=W.has(u.id),T.addEventListener("change",()=>{if(T.checked)W.add(u.id);else W.delete(u.id);g="",k()});let J=t("span");if(J.append(t("b","",u.name)),u.description)J.append(u.description);F.append(T,J),o.append(F)}v.append(o)}let p=t("label","check");if(p.htmlFor=D.id,p.append(D,t("span","",A(R().length>0?R():s))),v.append(p),C)v.append(t("p","error",C));if(g)v.append(t("p","error",g));h.append(v)}l.replaceChildren(h)}return k(),B(),()=>{V=!0}}function Ve(n){return`yuva:${n}`}function Ce(n){try{let e=localStorage.getItem(Ve(n));return e?JSON.parse(e):{}}catch{return{}}}function Qe(n,e){try{localStorage.setItem(Ve(n),JSON.stringify(e))}catch{}}var bt=2592000000;function Ke(n){return n&&Date.parse(n)||Date.now()-bt}var yt=20;function Ge(n,e,l){let{client:r,locale:d}=n,s=Ke(Ce(r.channel).whats_new_seen),c=[],b=[],y=n.params.entry?{kind:"entry",id:n.params.entry}:{kind:"list"};if(n.params.entry)b.push({kind:"list"});let N,x=!1,_=!1,g=!1,S={},C=!1,V=(p)=>p==="new"?e({id:"isRobC"}):p==="improved"?e({id:"5j51A1"}):e({id:"TpqW74"});function W(p){let o=new Date(p);return new Intl.DateTimeFormat(d,o.getFullYear()===new Date().getFullYear()?{month:"short",day:"numeric"}:{year:"numeric",month:"short",day:"numeric"}).format(o)}function I(){let p=c.reduce((u,F)=>Math.max(u,Date.parse(F.published_at)),0);if(!p||p<=s)return;let o=Ce(r.channel);if(o.whats_new_seen&&Date.parse(o.whats_new_seen)>=p)return;Qe(r.channel,{...o,whats_new_seen:new Date(p).toISOString()}),n.seenUpdates()}function D(p){let o=t("div","wn-meta");for(let u of p.labels)o.append(t("span",`wn-label ${u}`,V(u)));if(o.append(t("span","wn-date",W(p.published_at))),Date.parse(p.published_at)>s){let u=t("span","unread-dot");u.setAttribute("role","img"),u.setAttribute("aria-label",e({id:"KuVpz-"})),o.append(u)}return o}async function R(p){if(x)return;x=!0,g=!1,P();try{let o=await r.whatsNew({locale:d,limit:yt,cursor:p?N:void 0}),u=new Set(c.map((F)=>F.id));c.push(...o.items.filter((F)=>!u.has(F.id))),N=o.next_cursor,_=!0,I()}catch{g=!0}x=!1,P()}async function A(p){S={};let o=c.find((u)=>u.id===p);if(o)return S={entry:o},P();P();try{S={entry:await r.whatsNewEntry(p,{locale:d})}}catch{S={failed:!0}}P()}function B(p){if(b.push(y),y=p,p.kind==="entry")A(p.id);P(),l.scrollTop=0}function z(){let p=b.pop();if(!p)return n.back();y=p,P(),l.scrollTop=0}function k(p,o){let u=t("section","sec");if(u.append(t("p",o?"empty":"hint",p)),o)u.append(O(e({id:"KDw4GX"}),"primary",o));return u}function h(){if(g&&c.length===0)return[k(e({id:"5isRv0"}),()=>void R(!1))];if(c.length===0)return[k(_?e({id:"xwh17S"}):e({id:"Pwqkdw"}))];let p=t("section","sec wn-list");for(let o of c){let u=t("button","wn-entry");u.type="button";let F=t("b","",o.title);if(F.dir="auto",u.append(D(o),F),o.excerpt){let T=t("span","wn-lede",o.excerpt);T.dir="auto",u.append(T)}u.addEventListener("click",()=>B({kind:"entry",id:o.id})),p.append(u)}if(N)p.append(O(x?e({id:"Pwqkdw"}):e({id:"yQ2kGp"}),"link brand",()=>void R(!0)));if(g)p.append(t("p","error",e({id:"5isRv0"})));return[p,t("div","fill")]}function v(p){if(S.failed)return[k(e({id:"5isRv0"}),()=>void A(p))];let o=S.entry;if(!o)return[k(e({id:"Pwqkdw"}))];let u=t("section","sec"),F=t("h1","article-title",o.title);if(F.dir="auto",u.append(D(o),F),o.image){let J=t("img","wn-image");J.src=o.image.url,J.alt="",J.width=o.image.width,J.height=o.image.height,J.loading="lazy",u.append(J)}u.append(pe(o.html));let T=t("a","link brand",e({id:"HQrBQl"}));return T.href=o.url,T.target="_blank",T.rel="noopener noreferrer",u.append(T),[u,t("div","fill")]}function U(){let p=t("div","hback"),o=O("","link soft",z);return o.insertAdjacentHTML("beforeend",j.back),o.append(e({id:"iH8pgl"})),p.append(o),p}function P(){if(C)return;let p=[];if(y.kind==="list")p.push(...h());else p.push(U(),...v(y.id));let o=l.scrollTop;l.replaceChildren(...p),l.scrollTop=o}if(y.kind==="entry")A(y.id);return R(!1),()=>{C=!0}}var vt={feedback:Fe,help:qe,roadmap:$e,status:We,subscribe:Ue,"whats-new":Ge},xt=(n)=>import(new URL(wt('{"cs":"./yuva-apps-cs-szpm8fq7.js","ar":"./yuva-apps-ar-wk63tmr6.js","de":"./yuva-apps-de-fd1snm0x.js","es-mx":"./yuva-apps-es-mx-23h92xvs.js","id":"./yuva-apps-id-rvr6g27r.js","en":"./yuva-apps-en-skz2hc45.js","tr":"./yuva-apps-tr-9bq6yzyy.js","ja":"./yuva-apps-ja-71z2p7a6.js","ca":"./yuva-apps-ca-mxrszyen.js","vi":"./yuva-apps-vi-hs9e6h1q.js","sv":"./yuva-apps-sv-bfchg8n0.js","hi":"./yuva-apps-hi-zezzdfb4.js","zh-hans":"./yuva-apps-zh-hans-bc7j7gt0.js","or":"./yuva-apps-or-6ggz8n7c.js","ko":"./yuva-apps-ko-5b90egt2.js","ms":"./yuva-apps-ms-2et5c44x.js","pl":"./yuva-apps-pl-ayf5z37n.js","pt-br":"./yuva-apps-pt-br-pmegf5s7.js","fr-ca":"./yuva-apps-fr-ca-ma4cfsvr.js","zh-hant":"./yuva-apps-zh-hant-9ke56jnf.js","hu":"./yuva-apps-hu-q79hae7c.js","th":"./yuva-apps-th-tq3fdyxf.js","sk":"./yuva-apps-sk-n0st8g80.js","ru":"./yuva-apps-ru-k3vhm4n9.js","he":"./yuva-apps-he-yy8ajb9j.js","ro":"./yuva-apps-ro-kq1mexyc.js","pa":"./yuva-apps-pa-p0zp743s.js","uk":"./yuva-apps-uk-0azd9r77.js","hr":"./yuva-apps-hr-skjtsrz6.js","ml":"./yuva-apps-ml-qyjc0208.js","ta":"./yuva-apps-ta-zgn0hzpc.js","nb":"./yuva-apps-nb-hnr4p136.js","fi":"./yuva-apps-fi-9tffjg50.js","ur":"./yuva-apps-ur-j8m34b8k.js","it":"./yuva-apps-it-hkfb6swg.js","te":"./yuva-apps-te-eyyyp1fs.js","mr":"./yuva-apps-mr-wh0985vm.js","fr":"./yuva-apps-fr-v6fmnc7n.js","da":"./yuva-apps-da-v9sx8j55.js","sl":"./yuva-apps-sl-5yzf8nkk.js","kn":"./yuva-apps-kn-xm2wsv24.js","el":"./yuva-apps-el-wecybgxk.js","es":"./yuva-apps-es-18nqt6cs.js","bn":"./yuva-apps-bn-mv215pfz.js","nl":"./yuva-apps-nl-m5z18z8w.js","pt-pt":"./yuva-apps-pt-pt-fqqmhnsg.js","gu":"./yuva-apps-gu-4v1dxzbn.js"}',n),import.meta.url).href).then((e)=>e.messages).catch(()=>we),wt=(n,e)=>JSON.parse(n)[e]??"about:blank";async function yn(n,e){let l=await xt(e.locale),r=(y)=>De(l,y,we),d=t("div","app"),s=t("div","page"),c=Pe(e.root,Be);d.append(...c?[c]:[],s);let b=vt[n](e,r,s);return{element:d,destroy:b}}export{yn as mountApp};
128
+ `;var ht=2100;function Ue(n,e,l){let{client:r,locale:d}=n,s=[],c="",b=0,y=!1,N=!1,x="idle",_=!1,g="",S="",C="",V=!1,W=new Set,I=t("input","field");I.type="email",I.autocomplete="email",I.value=r.session?.contact.email??"",I.placeholder=e({id:"njBr8W"}),I.setAttribute("aria-label",e({id:"XJURKP"}));let D=t("input");D.type="checkbox",D.id="yuva-consent",D.addEventListener("change",()=>{C="",k()});function R(){return s.filter((h)=>W.has(h.id))}function A(h){let v=new Intl.ListFormat(d,{type:"conjunction"}).format(h.map((P)=>P.name)),U=n.inbox.name;return e({id:"dMJfG5",values:{list:v,inbox:U}})}async function B(){try{let h=await r.lists();s=h.lists,c=h.form_token,b=Date.now();for(let v of s)W.add(v.id)}catch{N=!0}y=!0,k()}async function z(){if(x!=="idle")return;let h=R(),v=I.value.trim();if(g=h.length===0?e({id:"-g5O6h"}):"",S=I.checkValidity()&&v?"":e({id:"E_qvzP"}),C=D.checked?"":e({id:"lDEbTy"}),g||S||C){k();return}x="sending",k();let U=async(P)=>{let p=b+ht-Date.now();if(p>0)await new Promise((o)=>setTimeout(o,p));try{_=(await r.subscribe({email:v,list_ids:h.map((u)=>u.id),locale:d,page_url:location.href.split("#")[0].slice(0,2000),consent_text:A(h),form_token:c})).confirmation}catch(o){if(P&&o instanceof te&&o.code==="form_token")return c=(await r.lists()).form_token,b=Date.now(),U(!1);throw o}};try{await U(!0),x="done"}catch(P){if(x="idle",P instanceof te&&P.code==="invalid_email")S=e({id:"E_qvzP"});else g=P instanceof te&&P.code==="rate_limited"?e({id:"tzsBOP"}):P instanceof te&&P.code==="network"?e({id:"GQVIIl"}):e({id:"jWgNnM"})}if(!V)k()}function k(){if(V)return;let h=t("section","sec");if(h.append(t("h2","label",`01 — ${e({id:"7kOr80"})}`)),!y)h.append(t("p","hint",e({id:"Pwqkdw"})));else if(N||s.length===0)h.append(t("p","hint",e({id:"jWgNnM"})));else if(x==="done"){let v=t("div","done-card");v.insertAdjacentHTML("beforeend",j.check),v.append(t("p","empty",_?e({id:"y3k2zM"}):e({id:"rgySXy"}))),h.append(v)}else{let v=t("form","form");v.noValidate=!0,v.addEventListener("submit",(o)=>{o.preventDefault(),z()});let U=t("div","row2"),P=t("button","btn",x==="sending"?e({id:"1w51t9"}):e({id:"EDl9kS"}));if(P.type="submit",P.disabled=x==="sending",U.append(I,P),v.append(U),S)v.append(t("p","error",S));if(s.length>1){let o=t("div","lists");o.setAttribute("role","group"),o.setAttribute("aria-label",e({id:"h16FyT"}));for(let u of s){let F=t("label","check"),T=t("input");T.type="checkbox",T.checked=W.has(u.id),T.addEventListener("change",()=>{if(T.checked)W.add(u.id);else W.delete(u.id);g="",k()});let J=t("span");if(J.append(t("b","",u.name)),u.description)J.append(u.description);F.append(T,J),o.append(F)}v.append(o)}let p=t("label","check");if(p.htmlFor=D.id,p.append(D,t("span","",A(R().length>0?R():s))),v.append(p),C)v.append(t("p","error",C));if(g)v.append(t("p","error",g));h.append(v)}l.replaceChildren(h)}return k(),B(),()=>{V=!0}}function Ve(n){return`yuva:${n}`}function Ce(n){try{let e=localStorage.getItem(Ve(n));return e?JSON.parse(e):{}}catch{return{}}}function Qe(n,e){try{localStorage.setItem(Ve(n),JSON.stringify(e))}catch{}}var bt=2592000000;function Ke(n){return n&&Date.parse(n)||Date.now()-bt}var yt=20;function Ge(n,e,l){let{client:r,locale:d}=n,s=Ke(Ce(r.channel).whats_new_seen),c=[],b=[],y=n.params.entry?{kind:"entry",id:n.params.entry}:{kind:"list"};if(n.params.entry)b.push({kind:"list"});let N,x=!1,_=!1,g=!1,S={},C=!1,V=(p)=>p==="new"?e({id:"isRobC"}):p==="improved"?e({id:"5j51A1"}):e({id:"TpqW74"});function W(p){let o=new Date(p);return new Intl.DateTimeFormat(d,o.getFullYear()===new Date().getFullYear()?{month:"short",day:"numeric"}:{year:"numeric",month:"short",day:"numeric"}).format(o)}function I(){let p=c.reduce((u,F)=>Math.max(u,Date.parse(F.published_at)),0);if(!p||p<=s)return;let o=Ce(r.channel);if(o.whats_new_seen&&Date.parse(o.whats_new_seen)>=p)return;Qe(r.channel,{...o,whats_new_seen:new Date(p).toISOString()}),n.seenUpdates()}function D(p){let o=t("div","wn-meta");for(let u of p.labels)o.append(t("span",`wn-label ${u}`,V(u)));if(o.append(t("span","wn-date",W(p.published_at))),Date.parse(p.published_at)>s){let u=t("span","unread-dot");u.setAttribute("role","img"),u.setAttribute("aria-label",e({id:"KuVpz-"})),o.append(u)}return o}async function R(p){if(x)return;x=!0,g=!1,P();try{let o=await r.whatsNew({locale:d,limit:yt,cursor:p?N:void 0}),u=new Set(c.map((F)=>F.id));c.push(...o.items.filter((F)=>!u.has(F.id))),N=o.next_cursor,_=!0,I()}catch{g=!0}x=!1,P()}async function A(p){S={};let o=c.find((u)=>u.id===p);if(o)return S={entry:o},P();P();try{S={entry:await r.whatsNewEntry(p,{locale:d})}}catch{S={failed:!0}}P()}function B(p){if(b.push(y),y=p,p.kind==="entry")A(p.id);P(),l.scrollTop=0}function z(){let p=b.pop();if(!p)return n.back();y=p,P(),l.scrollTop=0}function k(p,o){let u=t("section","sec");if(u.append(t("p",o?"empty":"hint",p)),o)u.append(O(e({id:"KDw4GX"}),"primary",o));return u}function h(){if(g&&c.length===0)return[k(e({id:"5isRv0"}),()=>void R(!1))];if(c.length===0)return[k(_?e({id:"xwh17S"}):e({id:"Pwqkdw"}))];let p=t("section","sec wn-list");for(let o of c){let u=t("button","wn-entry");u.type="button";let F=t("b","",o.title);if(F.dir="auto",u.append(D(o),F),o.excerpt){let T=t("span","wn-lede",o.excerpt);T.dir="auto",u.append(T)}u.addEventListener("click",()=>B({kind:"entry",id:o.id})),p.append(u)}if(N)p.append(O(x?e({id:"Pwqkdw"}):e({id:"yQ2kGp"}),"link brand",()=>void R(!0)));if(g)p.append(t("p","error",e({id:"5isRv0"})));return[p,t("div","fill")]}function v(p){if(S.failed)return[k(e({id:"5isRv0"}),()=>void A(p))];let o=S.entry;if(!o)return[k(e({id:"Pwqkdw"}))];let u=t("section","sec"),F=t("h1","article-title",o.title);if(F.dir="auto",u.append(D(o),F),o.image){let J=t("img","wn-image");J.src=o.image.url,J.alt="",J.width=o.image.width,J.height=o.image.height,J.loading="lazy",u.append(J)}u.append(pe(o.html));let T=t("a","link brand",e({id:"HQrBQl"}));return T.href=o.url,T.target="_blank",T.rel="noopener noreferrer",u.append(T),[u,t("div","fill")]}function U(){let p=t("div","hback"),o=O("","link soft",z);return o.insertAdjacentHTML("beforeend",j.back),o.append(e({id:"iH8pgl"})),p.append(o),p}function P(){if(C)return;let p=[];if(y.kind==="list")p.push(...h());else p.push(U(),...v(y.id));let o=l.scrollTop;l.replaceChildren(...p),l.scrollTop=o}if(y.kind==="entry")A(y.id);return R(!1),()=>{C=!0}}var vt={feedback:Fe,help:qe,roadmap:$e,status:We,subscribe:Ue,"whats-new":Ge},xt=(n)=>import(new URL(wt('{"el":"./yuva-apps-el-wecybgxk.js","tr":"./yuva-apps-tr-9bq6yzyy.js","ml":"./yuva-apps-ml-qyjc0208.js","vi":"./yuva-apps-vi-hs9e6h1q.js","nb":"./yuva-apps-nb-hnr4p136.js","bn":"./yuva-apps-bn-mv215pfz.js","ta":"./yuva-apps-ta-zgn0hzpc.js","ar":"./yuva-apps-ar-wk63tmr6.js","pa":"./yuva-apps-pa-p0zp743s.js","te":"./yuva-apps-te-eyyyp1fs.js","hi":"./yuva-apps-hi-zezzdfb4.js","pl":"./yuva-apps-pl-ayf5z37n.js","th":"./yuva-apps-th-tq3fdyxf.js","ja":"./yuva-apps-ja-71z2p7a6.js","es":"./yuva-apps-es-18nqt6cs.js","pt-pt":"./yuva-apps-pt-pt-fqqmhnsg.js","ru":"./yuva-apps-ru-k3vhm4n9.js","hr":"./yuva-apps-hr-skjtsrz6.js","mr":"./yuva-apps-mr-wh0985vm.js","ms":"./yuva-apps-ms-2et5c44x.js","zh-hant":"./yuva-apps-zh-hant-9ke56jnf.js","ur":"./yuva-apps-ur-j8m34b8k.js","pt-br":"./yuva-apps-pt-br-pmegf5s7.js","or":"./yuva-apps-or-6ggz8n7c.js","en":"./yuva-apps-en-skz2hc45.js","id":"./yuva-apps-id-rvr6g27r.js","de":"./yuva-apps-de-fd1snm0x.js","fi":"./yuva-apps-fi-9tffjg50.js","ko":"./yuva-apps-ko-5b90egt2.js","uk":"./yuva-apps-uk-0azd9r77.js","es-mx":"./yuva-apps-es-mx-23h92xvs.js","fr":"./yuva-apps-fr-v6fmnc7n.js","he":"./yuva-apps-he-yy8ajb9j.js","hu":"./yuva-apps-hu-q79hae7c.js","zh-hans":"./yuva-apps-zh-hans-bc7j7gt0.js","sl":"./yuva-apps-sl-5yzf8nkk.js","cs":"./yuva-apps-cs-szpm8fq7.js","sv":"./yuva-apps-sv-bfchg8n0.js","ca":"./yuva-apps-ca-mxrszyen.js","fr-ca":"./yuva-apps-fr-ca-ma4cfsvr.js","gu":"./yuva-apps-gu-4v1dxzbn.js","sk":"./yuva-apps-sk-n0st8g80.js","ro":"./yuva-apps-ro-kq1mexyc.js","da":"./yuva-apps-da-v9sx8j55.js","nl":"./yuva-apps-nl-m5z18z8w.js","it":"./yuva-apps-it-hkfb6swg.js","kn":"./yuva-apps-kn-xm2wsv24.js"}',n),import.meta.url).href).then((e)=>e.messages).catch(()=>we),wt=(n,e)=>JSON.parse(n)[e]??"about:blank";async function yn(n,e){let l=await xt(e.locale),r=(y)=>De(l,y,we),d=t("div","app"),s=t("div","page"),c=Pe(e.root,Be);d.append(...c?[c]:[],s);let b=vt[n](e,r,s);return{element:d,destroy:b}}export{yn as mountApp};
package/dist/yuva-chat.js CHANGED
@@ -299,4 +299,4 @@ textarea.field { padding: 10px 12px; min-block-size: 96px; resize: vertical; inl
299
299
  .sr { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
300
300
  `;var ot=/(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\s][^*\n]*\*|_[^_\s][^_\n]*_)|((?:https?:\/\/|www\.)[^\s<>"]*[^\s<>".,:;'!?)\]])/g;function lt(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 te(e,t){let i=document.createElement(e);return i.append(...t),i}function ie(e){let t=[],i=0;for(let n of e.matchAll(ot)){let s=n.index??0;if(s>i)t.push(document.createTextNode(e.slice(i,s)));let[a,o,l,c,d]=n;if(o)t.push(te("code",[document.createTextNode(o.slice(1,-1))]));else if(l)t.push(te("strong",ie(l.slice(2,-2))));else if(c)t.push(te("em",ie(c.slice(1,-1))));else if(d){let p=d.startsWith("www.")?`https://${d}`:d;try{let u=new URL(p);t.push(u.protocol==="http:"||u.protocol==="https:"?lt(u.href,d):document.createTextNode(d))}catch{t.push(document.createTextNode(d))}}i=s+a.length}if(i<e.length)t.push(document.createTextNode(e.slice(i)));return t}function q(e){let t=document.createDocumentFragment(),i=e.trim().replace(/\r\n?/g,`
301
301
  `).split(/^```[^\n]*\n([\s\S]*?)^```[ \t]*$/m);return i.forEach((n,s)=>{if(s%2===1){let o=document.createElement("pre");o.textContent=n.replace(/\n$/,""),t.append(o);return}(i.length>1?n.replace(/^\n|\n$/g,""):n).split(`
302
- `).forEach((o,l)=>{if(l>0)t.append(document.createElement("br"));t.append(...ie(o))})}),t}var ct=(e)=>import(new URL(dt('{"cs":"widget/yuva-panel-cs-jxdap7hk.js","ar":"widget/yuva-panel-ar-w9kxar7b.js","de":"widget/yuva-panel-de-z1haaaf5.js","es-mx":"widget/yuva-panel-es-mx-593ry1sp.js","id":"widget/yuva-panel-id-egadejce.js","en":"widget/yuva-panel-en-yntqp1wb.js","tr":"widget/yuva-panel-tr-ywyzb4rn.js","ja":"widget/yuva-panel-ja-5ep2nhr6.js","ca":"widget/yuva-panel-ca-3xmep2qy.js","vi":"widget/yuva-panel-vi-t97hnjrg.js","sv":"widget/yuva-panel-sv-175kbch1.js","hi":"widget/yuva-panel-hi-hyqwxkva.js","zh-hans":"widget/yuva-panel-zh-hans-djf7yajw.js","or":"widget/yuva-panel-or-q6eks6dh.js","ko":"widget/yuva-panel-ko-7cr7d0zc.js","ms":"widget/yuva-panel-ms-7xavwv7n.js","pl":"widget/yuva-panel-pl-6bsq33w3.js","pt-br":"widget/yuva-panel-pt-br-5bf6ja6w.js","fr-ca":"widget/yuva-panel-fr-ca-kwqpxepb.js","zh-hant":"widget/yuva-panel-zh-hant-a9cgjbmw.js","hu":"widget/yuva-panel-hu-dsf2tr60.js","th":"widget/yuva-panel-th-rx5h6eq6.js","sk":"widget/yuva-panel-sk-50gc8kfg.js","ru":"widget/yuva-panel-ru-1ydh24ae.js","he":"widget/yuva-panel-he-kwf5a5r1.js","ro":"widget/yuva-panel-ro-9255bnc4.js","pa":"widget/yuva-panel-pa-26mhm7me.js","uk":"widget/yuva-panel-uk-9h1czxf0.js","hr":"widget/yuva-panel-hr-xyc32ytv.js","ml":"widget/yuva-panel-ml-0vb742gf.js","ta":"widget/yuva-panel-ta-x4nnzatk.js","nb":"widget/yuva-panel-nb-34x0g8mq.js","fi":"widget/yuva-panel-fi-dw2qy2ep.js","ur":"widget/yuva-panel-ur-peb4hk7h.js","it":"widget/yuva-panel-it-dstzsdpt.js","te":"widget/yuva-panel-te-35y4486b.js","mr":"widget/yuva-panel-mr-f7sn0acm.js","fr":"widget/yuva-panel-fr-mksekp2w.js","da":"widget/yuva-panel-da-xy0gn2ch.js","sl":"widget/yuva-panel-sl-0j7nnz7k.js","kn":"widget/yuva-panel-kn-ggsqc21e.js","el":"widget/yuva-panel-el-vhskf13n.js","es":"widget/yuva-panel-es-91gq45ad.js","bn":"widget/yuva-panel-bn-w0jg8rz0.js","nl":"widget/yuva-panel-nl-rkak2t5r.js","pt-pt":"widget/yuva-panel-pt-pt-2a7vh8y9.js","gu":"widget/yuva-panel-gu-9brj4atb.js"}',e),import.meta.url).href).then((t)=>t.messages).catch(()=>Q),dt=(e,t)=>JSON.parse(e)[t]??"about:blank",pt=()=>import(new URL("widget/yuva-chat-apps-z6dvevmz.js",import.meta.url).href),je={none:0,minor:1,major:2,critical:3},ht=10,ut=300000,mt=60000,ft=2147483647;class Ne{#t;#g;#i;#s=null;#w=0;#u="";#m=0;#k=null;#f="loading";#v="";#y=null;#P=null;#a=new Map;#$;#p=new Map;#c=[];#C=new Map;#n=null;#O=!1;#l=[];#o=0;#T=null;#L=new Map;#U=new Map;#me=new Map;#fe=!1;#I="";#J="";#R=!1;#G=!1;#j="";#N=null;#ge=!1;#A=new Map;#et=r("div","card rate");#x=r("textarea");#ae="";#Ie=null;#re=!1;#ve=!1;#oe=null;#F=0;#ye=!1;#Q=null;#Y=0;#Ae="";ready;#X=r("header","header");#be=r("div","banner");#_=r("div","body");#d=r("div","scroll");#H=r("div","notice");#b=r("div","");#S=r("input","field");#Ee=r("div","sec composer");#xe=r("div","chips");#h=r("textarea");#E=r("input");#Z;#le;#ee;#D=r("button","jump");#De=r("span","hintkey");#we=r("div","sr");#K;#z=!0;constructor(e){this.#t=e;let{server:t,channel:i}=e.config();this.#i=xe({server:t,channel:i??"",identityToken:()=>e.identityToken()}),this.#i.on("event",(a)=>this.#at(a)),this.#i.on("connection",({state:a,attempt:o})=>{if(a!=="reconnecting")return;this.#O=o>0,this.#Te()}),this.#i.on("session",({session:a,renewed:o})=>{if(this.#de(a.inbox),this.#k=a.contact,o)this.#Ye();else if(!this.#P)this.#i.connect().catch(()=>{return})}),this.ready=this.#$e(),this.#we.setAttribute("aria-live","polite"),this.#d.setAttribute("role","log"),this.#d.addEventListener("scroll",()=>{if(this.#z=this.#d.scrollHeight-this.#d.scrollTop-this.#d.clientHeight<48,this.#z)this.#Y=0;if(this.#Pe(),this.#d.scrollTop<60&&this.#n?.kind==="thread"&&this.#n.id)this.#ke(this.#n.id,!0)}),this.#D.type="button",this.#D.addEventListener("click",()=>{this.#Y=0,this.#M(),this.#Pe()}),this.#h.rows=2,this.#h.addEventListener("keydown",(a)=>{if(a.key==="Enter"&&!a.shiftKey&&!a.isComposing)a.preventDefault(),this.#_e()}),this.#h.addEventListener("input",()=>{this.#We(),this.#ie(),this.#lt()}),this.#h.addEventListener("paste",(a)=>{let o=Array.from(a.clipboardData?.files??[]);if(o.length===0)return;a.preventDefault(),this.#Se(o)}),this.#E.type="file",this.#E.multiple=!0,this.#E.hidden=!0,this.#E.addEventListener("change",()=>{this.#Se(Array.from(this.#E.files??[])),this.#E.value=""}),this.#le=H(f.attach,"",()=>this.#E.click(),"icon tool"),this.#ee=H(f.shot,"",()=>void this.#ot(),"icon tool"),this.#ee.hidden=!Ie(),this.#Z=H(f.send,"",()=>void this.#_e(),"send");let n=r("div","tools");n.append(this.#le,this.#ee,r("span","grow"),this.#De,this.#Z,this.#E);let s=r("form","box");s.addEventListener("submit",(a)=>{a.preventDefault(),this.#_e()}),s.append(this.#xe,this.#h,n),this.#Ee.append(this.#D,s),this.#S.type="email",this.#S.required=!0,this.#S.autocomplete="email",this.#x.rows=2,this.#x.maxLength=2000,this.#x.dir="auto",document.addEventListener("visibilitychange",this.#ce),window.addEventListener("online",this.#ce),this.ready.then(()=>{this.#Xe(),this.#W()})}update(){this.#$e().then(()=>{this.#j="",this.#ae="",this.#Xe()})}opened(){if(this.#f==="error"){this.#y=null,this.#W();return}if(this.#f==="ready"){if(this.#i.token)this.#st();else if(this.#He())this.#Ue().then(()=>this.#r()).catch(()=>{return});this.#Oe()}if(this.#r(),this.#M(),this.#te(),this.#t.config().layout==="launcher"&&this.#n?.kind==="thread")this.#h.focus({preventScroll:!0})}async openApp(e,t={}){if(await this.ready,await this.#W(),this.#f==="ready")await this.#se(e,t)}closed(){this.#q()}identityChanged(){this.#Le(),this.#W()}async signOut(){let e=this.#i.signOut();if(this.#Le(),await e,this.#t.isOpen())this.#W();else this.#r()}destroy(){if(this.#i.reset(),this.#q(),this.#ne(),this.#N)clearTimeout(this.#N);document.removeEventListener("visibilitychange",this.#ce),window.removeEventListener("online",this.#ce);for(let e of this.#L.values())URL.revokeObjectURL(e)}#Le(){this.#i.reset(),this.#ne(),this.#y=null,this.#P=null,this.#s=null,this.#k=null,this.#f="loading",this.#a.clear(),this.#p.clear(),this.#c=[],this.#A.clear(),this.#ae="",this.#n=null,this.#re=!1,this.#ve=!1,this.#fe=!1,this.#R=!1,this.#j="",this.#ge=!1,this.#Y=0,this.#t.setUnread(0),this.#w=0,this.#u="",this.#m=0,this.#t.setUpdates(0)}#ce=()=>{if(document.visibilityState!=="visible")return;if(this.#i.reconnect(),this.#te(),this.#i.connected||this.#He())this.#Ne()};#He(){return!this.#i.connected&&Date.now()-this.#m>=mt}async#$e(){let{locale:e}=this.#t.config();if(this.#g??=Y({locale:"en",messages:{en:Q}}),this.#Ae===e)return;let t=await ct(e);if(e!==this.#t.config().locale)return;this.#g=Y({locale:e,messages:{[e]:t}}),this.#Ae=e}#e(e){return this.#g._(e)}#W(){return this.#y??=(async()=>{this.#f="loading",this.#r();let{channel:e}=this.#t.config();if(!e)throw new w(0,"not_configured");if(await this.#t.identityToken()||L(e).session)await this.#nt();else if(await this.#Ue(),!this.#s?.chat.allow_anonymous)throw new w(403,"anonymous_not_allowed");this.#f="ready",this.#n??={kind:"home"},this.#Oe(),this.#r(),this.#M(),this.#te()})().catch((e)=>{if(this.#y=null,this.#Fe(e))return;this.#f="error",this.#v=e instanceof w?e.code:"error",this.#r()}),this.#y}#Oe(){if(this.#ve||!this.#t.config().channel)return;this.#ve=!0,this.#i.lists().then((e)=>{this.#re=(e?.lists.length??0)>0,this.#r()}).catch(()=>{return})}async#Ue(){let e=await this.#je();if(!this.#i.token)this.#de(e)}async#je(){if(!this.#t.config().channel)throw new w(0,"not_configured");let e=await this.#i.channelSettings();return this.#m=Date.now(),e}#de(e){let{channel:t}=this.#t.config();this.#s=e;let i=pe(e);if(this.#t.setLauncher(i),!t)return;let n=L(t),s=new Set(e.status?.open.map((l)=>l.id)),a=Object.fromEntries(Object.entries(n.dismissed_status??{}).filter(([l])=>s.has(l))),o={...n,launcher:i};if(Object.keys(a).length>0)o.dismissed_status=a;else delete o.dismissed_status;X(t,o),this.#tt()}#tt(){let{channel:e,server:t,locale:i}=this.#t.config(),n=this.#s;if(!e||!n?.whats_new)return this.#Ce(0);let s=`${n.whats_new.latest_published_at}|${L(e).whats_new_seen??""}`;if(s===this.#u)return;this.#u=s,De(t,e,n,i).then((a)=>{if(s===this.#u)this.#Ce(a)}).catch(()=>{if(s===this.#u)this.#u=""})}#Ce(e){if(e===this.#w)return;if(this.#w=e,this.#t.setUpdates(this.#s?.chat.announce_updates?e:0),this.#n?.kind==="home")this.#r()}#it(){let{channel:e}=this.#t.config(),t=e&&L(e).dismissed_status||{},i=[...this.#s?.status?.open??[]].filter((o)=>t[o.id]!==o.updated_at).sort((o,l)=>je[l.impact]-je[o.impact])[0];if(this.#H.hidden=!i,!i)return this.#H.replaceChildren();let n={investigating:{id:"WAnUgI"},identified:{id:"tddaHo"},monitoring:{id:"1gZQhL"},resolved:{id:"O6H89R"},scheduled:{id:"4ba0NE"},in_progress:{id:"_LCAwL"},completed:{id:"qqWcBV"}},s=r("a","",i.title);s.href=i.url,s.target="_blank",s.rel="noopener noreferrer",s.dir="auto";let a=r("div","notice-text");a.append(r("strong","",this.#e(n[i.state]))," ",s),this.#H.className=`notice impact-${i.impact}`,this.#H.replaceChildren(a,H(f.closeSmall,this.#e({id:"1QfxQT"}),()=>{if(!e)return;let o=L(e);X(e,{...o,dismissed_status:{...o.dismissed_status,[i.id]:i.updated_at}}),this.#r()},"icon sm"))}async#Ne(){if(this.#f!=="ready")return;try{this.#de(await this.#je()),this.#r()}catch(e){this.#Fe(e,!0)}}#Fe(e,t=!this.#i.token){let i=e instanceof w&&(e.code==="origin_not_allowed"||e.status===404&&t);if(i)this.#t.refused();return i}#nt(){return this.#P??=(async()=>{await this.#i.start(),await this.#pe(),await this.#i.connect()})().finally(()=>{this.#P=null}),this.#P}async#st(){try{await this.#i.refresh(),this.#r()}catch{}}async#pe(e=!1){let t=await this.#i.listConversations({limit:50,cursor:e?this.#$:void 0});if(!e)this.#a.clear();for(let i of t.items)this.#a.set(i.id,i);this.#$=t.next_cursor,this.#B()}async#Ye(){await this.#pe();let e=this.#n?.kind==="thread"?this.#n.id:null;for(let t of this.#p.keys())if(t!==e)this.#p.delete(t);if(e)this.#p.delete(e),await this.#ke(e);this.#r()}async#ke(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.#i.listMessages(e,{order:"desc",limit:30,cursor:t?i.cursor:void 0}),a=new Set(i.messages.map((o)=>o.id));i.messages=[...i.messages,...s.items.filter((o)=>!a.has(o.id))].sort(ee),i.cursor=s.next_cursor,i.complete=!s.next_cursor}finally{i.loading=!1}if(t)this.#r(),this.#d.scrollTop=this.#d.scrollHeight-n}#at(e){switch(e.type){case"ready":if(this.#O=!1,this.#Te(),this.#ge)this.#Ne();this.#ge=!0;return;case"inbox.updated":{let t=this.#s?.ask_for_rating;if(this.#de(e.data),t!==void 0&&t!==e.data.ask_for_rating)this.#pe().then(()=>this.#r()).catch(()=>{return});break}case"contact.updated":this.#k=e.data;break;case"resync_required":this.#Ye();return;case"presence":if(this.#s)this.#s={...this.#s,presence:e.data};break;case"conversation.created":if(!this.#a.has(e.data.id))this.#a.set(e.data.id,e.data);if(this.#n?.kind==="thread"&&this.#n.id===null&&this.#a.size>1)this.#n=this.#c.some((t)=>t.conversation===null)?this.#n:{kind:"home"};this.#B();break;case"conversation.updated":{let t=this.#a.get(e.data.id),{status:i,can_rate:n,rating:s}=e.data;if(t)this.#a.set(t.id,{...t,status:i,can_rate:n,rating:s});if(!n)this.#A.delete(e.data.id);break}case"message.created":case"message.updated":this.#he(e.data,e.type==="message.created");break;case"read":{let t=this.#a.get(e.data.conversation_id),i=t?.last_read_by_member_at;if(t&&(!i||R(e.data.read_at)>R(i)))this.#a.set(t.id,{...t,last_read_by_member_at:e.data.read_at});break}case"typing":{let t=e.data.conversation_id,i=this.#C.get(t);if(i)clearTimeout(i.timer);if(e.data.typing){let n=e.data.author.name??"";this.#C.set(t,{name:n,timer:setTimeout(()=>this.#C.delete(t)&&this.#r(),8000)})}else this.#C.delete(t);break}}this.#r()}#he(e,t){let i=e.conversation_id,n=this.#p.get(i);if(n){let a=n.messages.findIndex((o)=>o.id===e.id);if(a>=0)n.messages[a]=e;else n.messages=[...n.messages,e].sort(ee)}if(e.client_id)this.#c=this.#c.filter((a)=>a.client_id!==e.client_id);let s=this.#a.get(i);if(!s){this.#i.getConversation(i).then((a)=>{this.#a.set(a.id,a),this.#B(),this.#r()}).catch(()=>{return});return}if(t){let a=e.body.replace(/\s+/g," ").trim();if(this.#a.set(i,{...s,last_message:{id:e.id,author_type:e.author.type,text:a.length>140?`${a.slice(0,139)}…`:a,created_at:e.created_at},last_message_at:e.created_at,unread:s.unread||e.author.type!=="contact"}),e.author.type!=="contact"){let o=this.#C.get(i);if(o)clearTimeout(o.timer);if(this.#C.delete(i),this.#rt(e),!this.#z&&this.#Ke()===i)this.#Y++}}this.#B(),this.#te()}#rt(e){this.#we.textContent=`${e.author.name||this.#s?.name||""}: ${e.body.slice(0,200)}`}#B(){let e=0;for(let t of this.#a.values())if(t.unread)e++;this.#t.setUnread(e)}#Ke(){if(!this.#t.isOpen()||document.visibilityState!=="visible")return null;return this.#n?.kind==="thread"?this.#n.id:null}#te(){let e=this.#Ke(),t=e?this.#a.get(e):void 0;if(!e||!t?.unread)return;this.#a.set(e,{...t,unread:!1}),this.#B(),this.#i.markRead(e).catch(()=>{let i=this.#a.get(e);if(i)this.#a.set(e,{...i,unread:!0});this.#B()})}#Se(e){this.#l=[...this.#l,...e].slice(0,ht),this.#ue(),this.#ie(),this.#h.focus()}async#ot(){let e=await Ae(this.#t.panel);if(e)this.#Se([e])}#We(){if(this.#h.style.blockSize="",this.#h.value==="")return;this.#h.style.blockSize="auto",this.#h.style.blockSize=`${Math.max(44,Math.min(this.#h.scrollHeight,140))}px`}#ie(){this.#Z.disabled=this.#h.value.trim()===""&&this.#l.length===0}#lt(){let e=this.#n?.kind==="thread"?this.#n.id:null;if(!e||this.#h.value.trim()===""){this.#q();return}if(Date.now()-this.#o>3000)this.#o=Date.now(),this.#i.setTyping(e,!0).catch(()=>{return});if(this.#T)clearTimeout(this.#T);this.#T=setTimeout(()=>this.#q(),4000)}#q(){if(this.#T)clearTimeout(this.#T);if(this.#T=null,this.#o===0)return;this.#o=0;let e=this.#n?.kind==="thread"?this.#n.id:null;if(e)this.#i.setTyping(e,!1).catch(()=>{return})}async#_e(){if(this.#f!=="ready"||this.#n?.kind!=="thread")return;let e=this.#h.value.trim(),t=this.#l;if(!e&&t.length===0)return;if(this.#n.id===null&&this.#c.some((n)=>n.conversation===null))return;this.#q(),this.#h.value="",this.#l=[],this.#We(),this.#ue(),this.#ie();let i={client_id:W(),conversation:this.#n.id,body:e,files:t,state:"sending"};if(this.#n.id===null&&this.#Q)i.help_article_id=this.#Q,this.#Q=null;this.#c.push(i),this.#r(),this.#M(),await this.#Be(i)}async#Be(e){e.state="sending",this.#r();let t={body:e.body,files:e.files,client_id:e.client_id};try{if(e.conversation===null){let i=await this.#i.startConversation({...t,help_article_id:e.help_article_id}),n=i.conversation.id;if(!this.#a.has(n))this.#a.set(n,i.conversation);if(!this.#p.has(n))this.#p.set(n,{messages:[],complete:!0,loading:!1});if(this.#n?.kind==="thread"&&this.#n.id===null)this.#n={kind:"thread",id:n};this.#he(i.message,!1)}else{let i=await this.#i.sendMessage(e.conversation,t);this.#he(i,!0)}this.#c=this.#c.filter((i)=>i!==e)}catch(i){let n=i instanceof w?i.status:0;e.state=n===413||n===415?"refused":"failed",e.status=n}this.#r(),this.#M()}async rate(e,t,i){try{let n=await this.#i.rate(e,t,i);return this.#a.set(n.id,n),this.#A.delete(e),this.#r(),n}catch(n){if(n instanceof w&&n.status===409){let s=await this.#i.getConversation(e).catch(()=>null);if(s)this.#a.set(s.id,s);this.#A.delete(e),this.#r()}throw n}}#ct(e,t){if(this.#A.get(e)?.state==="sending")return;if(this.#A.set(e,{choice:t,state:"choosing"}),this.#r(),this.#x.focus({preventScroll:!0}),this.#z)this.#M()}async#qe(e,t){let i=this.#A.get(e);if(!i||i.state==="sending")return;i.state="sending",this.#r();try{await this.rate(e,i.choice,t?this.#x.value:void 0),this.#x.value=""}catch(n){if(n instanceof w&&n.status===409)return;i.state="failed",this.#r()}}async#Ve(e){let t=(e??this.#S.value).trim();if(!t||e===void 0&&!this.#S.checkValidity()){this.#I=this.#e({id:"E_qvzP"}),this.#Me();return}if(this.#G)return;this.#G=!0;try{this.#k=await this.#i.setEmail(t),this.#fe=!0,this.#R=!1,this.#I="",this.#J=e===void 0?"":this.#e({id:"mj_YKf"})}catch(i){this.#I=i instanceof w&&i.status===429?this.#e({id:"tzsBOP"}):this.#e({id:"ZxJcgC"})}finally{this.#G=!1}this.#Me(),this.#r()}#Je(e){let t=this.#L.get(e.id);if(t)return Promise.resolve(t);let i=this.#U.get(e.id);if(!i)i=this.#i.attachment(e.id).then((n)=>{let s=URL.createObjectURL(n);return this.#L.set(e.id,s),s}),i.catch(()=>this.#U.delete(e.id)),this.#U.set(e.id,i);return i}async#Ge(e){let t=await this.#Je(e),i=r("a");i.href=t,i.download=e.filename,i.rel="noopener",i.click()}#Qe(){return[...this.#a.values()].sort(Se)}#dt(){let e=this.#s;if(!e)return!1;return!e.open_now||e.mode==="async"||!e.presence?.available}#M(){this.#z=!0,this.#Y=0,this.#d.scrollTop=this.#d.scrollHeight,requestAnimationFrame(()=>{if(this.#z)this.#d.scrollTop=this.#d.scrollHeight})}#Pe(){let e=!this.#z&&this.#n?.kind==="thread";if(this.#D.hidden=!e,!e)return;this.#D.setAttribute("aria-label",this.#e({id:"ju1Z9b"}));let t=this.#Y;this.#D.replaceChildren(),this.#D.insertAdjacentHTML("beforeend",f.down),this.#D.append(t>0?this.#e({id:"RnNe7a",values:{count:t}}):this.#e({id:"ju1Z9b"}))}#Xe(){this.#h.placeholder=this.#e({id:"RzWUUK"}),this.#h.setAttribute("aria-label",this.#e({id:"xDAtGP"})),this.#le.setAttribute("aria-label",this.#e({id:"N7m8E-"})),this.#le.title=this.#e({id:"N7m8E-"}),this.#ee.setAttribute("aria-label",this.#e({id:"TZglEu"})),this.#ee.title=this.#e({id:"TZglEu"}),this.#Z.setAttribute("aria-label",this.#e({id:"JlFcis"})),this.#Z.title=this.#e({id:"JlFcis"}),this.#De.replaceChildren(r("kbd","",this.#e({id:"9Vnjc9"})),this.#e({id:"0IRz4M"})),this.#S.placeholder=this.#e({id:"njBr8W"}),this.#S.setAttribute("aria-label",this.#e({id:"XJURKP"})),this.#d.setAttribute("aria-label",this.#e({id:"YyNOE7"})),this.#ie(),this.#ue(),this.#r()}#V(e){if(this.#q(),e.kind!=="thread"||e.id!==null)this.#Q=null;if(e.kind!=="app")this.#ne();if(this.#n=e,this.#r(),e.kind==="thread")this.#M(),this.#h.focus({preventScroll:!0})}#ne(){this.#F++,this.#ye=!1,this.#oe?.handle.destroy(),this.#oe=null}async#se(e,t={}){this.#ne();let i=this.#F;this.#n={kind:"app",app:e},this.#r();try{let n=await pt(),s=this.#s;if(i!==this.#F||!s)return;let{locale:a}=this.#t.config(),o=await n.mountApp(e,{root:this.#t.panel.getRootNode(),client:this.#i,inbox:s,locale:a,mailingLists:this.#re,params:t,back:()=>this.#V({kind:"home"}),open:(l,c)=>void this.#se(l,c),ask:(l)=>{this.#V({kind:"thread",id:null}),this.#Q=l??null},created:(l)=>{let c=l.conversation.id;if(!this.#a.has(c))this.#a.set(c,l.conversation);if(!this.#p.has(c))this.#p.set(c,{messages:[],complete:!0,loading:!1});this.#he(l.message,!1)},viewConversation:(l)=>void this.#Re(l),seenUpdates:()=>this.#Ce(0)});if(i!==this.#F)return o.destroy();this.#oe={kind:e,handle:o}}catch{if(i===this.#F)this.#ye=!0}if(i===this.#F)this.#r()}#r(){let e=this.#t.panel;if(e.childElementCount===0){let i=Ce(e.getRootNode(),Ue);e.append(...i?[i]:[],this.#X,this.#be,this.#_,this.#we),this.#X.id="yuva-title",e.setAttribute("aria-labelledby","yuva-title")}if(this.#ut(),this.#Te(),this.#f!=="ready"){this.#K=void 0;let i=r("div","center");if(this.#f==="loading")i.append(r("p","hint",this.#e({id:"Pwqkdw"})));else{i.append(r("p","empty",this.#pt()));let n=z(this.#e({id:"KDw4GX"}),"primary",()=>{this.#y=null,this.#W()});i.append(n)}this.#_.replaceChildren(i);return}this.#it();let t=this.#n??{kind:"home"};if(t.kind==="home")this.#ft();else if(t.kind==="list")this.#vt();else if(t.kind==="app")this.#gt();else this.#yt();this.#Pe()}#pt(){switch(this.#v){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"})}}#ht(e){if(e.mode==="live"&&e.open_now&&e.presence?.available)return[r("span","",this.#e({id:"oXOSPE"}))];if(!e.open_now||e.mode==="live")return[r("span","",this.#e({id:"1EICzz"}))];return[r("span","",this.#mt(e.expected_reply_minutes))]}#ut(){let{layout:e}=this.#t.config(),t=this.#s,i=this.#f==="ready"?this.#n??{kind:"home"}:{kind:"home"},n=[],s=e==="launcher"?H(f.close,this.#e({id:"yz7wBu"}),()=>this.#t.close()):null;if(i.kind==="home"){this.#X.className="header home";let a=r("div","headbrand"),o=r("span","mark"),l=t?.branding.logo_url;if(l&&/^https?:/i.test(l)){let c=r("img");c.alt="",c.referrerPolicy="no-referrer",c.addEventListener("error",()=>o.replaceChildren((t?.name||"Y").slice(0,1))),c.src=l,o.append(c)}else o.textContent=(t?.name||"Y").slice(0,1);a.append(o,r("h2","title",t?.name||this.#e({id:"t7TeQU"}))),n.push(a)}else if(this.#X.className="header",n.push(H(f.back,this.#e({id:"iH8pgl"}),()=>this.#V({kind:"home"}))),i.kind==="thread"&&t){let a=r("div","who"),o=t.mode==="live"&&t.open_now&&t.presence?.available,l=o?t.presence?.members[0]:void 0;a.append(r("span","avatar lg",l?.initials||(t.name||"").slice(0,2)),r("span",o?"dot":"dot away")),a.querySelector(".dot")?.setAttribute("aria-hidden","true");let c=r("div","heading");c.append(r("h2","title",t.name||this.#e({id:"t7TeQU"})));let d=r("div","status");d.append(...this.#ht(t)),c.append(d),n.push(a,c)}else{let a=r("div","heading");a.append(r("h2","title",i.kind==="app"?this.#e(He(i.app)):this.#e({id:"S63MQu"}))),n.push(a)}if(s)n.push(s);this.#X.replaceChildren(...n)}#mt(e){if(!e)return this.#e({id:"nhTADq"});let{locale:t}=this.#t.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}})}#Te(){this.#be.hidden=!this.#O,this.#be.textContent=this.#e({id:"09Tv5j"})}#ft(){this.#K=void 0;let e=this.#s;if(!e)return;let t=$e({inbox:e,conversations:this.#Qe(),mailingLists:this.#re,updates:this.#w,locale:this.#t.config().locale,t:(i)=>this.#e(i),notice:this.#H,openConversation:(i)=>void this.#Re(i),allConversations:()=>this.#V({kind:"list"}),newConversation:()=>this.#V({kind:"thread",id:null}),openApp:(i,n)=>void this.#se(i,n)});this.#_.replaceChildren(t)}#gt(){this.#K=void 0;let e=this.#oe;if(e){if(this.#_.firstChild!==e.handle.element||this.#_.childElementCount!==1)this.#_.replaceChildren(e.handle.element);return}let t=r("div","center");if(this.#ye)t.append(r("p","empty",this.#e({id:"5isRv0"})),z(this.#e({id:"KDw4GX"}),"primary",()=>{let i=this.#n;if(i?.kind==="app")this.#se(i.app)}));else t.append(r("p","hint",this.#e({id:"Pwqkdw"})));this.#_.replaceChildren(t)}#vt(){this.#K=void 0;let{locale:e}=this.#t.config(),t=r("ul","list"),i=new Date().toDateString();for(let a of this.#Qe()){let o=r("button",a.unread?"item unread":"item");o.type="button";let l=r("div","item-main"),c=r("div","item-top");if(c.append(r("span","item-subject",a.subject||this.#s?.name||this.#e({id:"YyNOE7"}))),a.kind==="feedback"&&a.status==="closed")c.append(r("span","item-state",this.#e({id:"O6H89R"})));let d=new Date(a.last_message_at??a.created_at);c.append(r("span","item-time",new Intl.DateTimeFormat(e,d.toDateString()===i?{timeStyle:"short"}:{month:"short",day:"numeric"}).format(d)));let p=a.last_message?`${a.last_message.author_type==="contact"?this.#e({id:"ydzYKJ"})+" ":""}${a.last_message.text||this.#e({id:"UY1vmE"})}`:"",u=r("div","item-preview",p.replace(/\*\*|`/g,""));if(u.dir="auto",l.append(c,u),o.append(l),a.unread)o.append(r("span","unread-dot"));o.addEventListener("click",()=>void this.#Re(a.id));let x=r("li");x.append(o),t.append(x)}let n=r("div","page");if(n.append(this.#H,t),this.#$){let a=z(this.#e({id:"ASr-r0"}),"link soft",()=>void this.#pe(!0).then(()=>this.#r()));a.style.margin="8px auto",n.append(a)}let s=z(this.#e({id:"-HY5kX"}),"primary",()=>this.#V({kind:"thread",id:null}));s.style.margin="16px 32px",n.append(r("div","fill"),s),this.#_.replaceChildren(n)}async#Re(e){if(this.#ne(),this.#n={kind:"thread",id:e},this.#r(),!this.#p.get(e)?.complete&&!this.#p.get(e)?.messages.length)await this.#ke(e).catch(()=>{return});this.#r(),this.#M(),this.#te()}#Ze(e){let t=r("span","avatar",e.initials||Te(e.name??"")),i=e.avatar_url,n=i?this.#me.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.#me.set(i,!0),t.isConnected)t.replaceChildren(s)}),s.addEventListener("error",()=>this.#me.set(i,!1)),s.src=i,t}#yt(){let e=this.#n;if(e?.kind!=="thread")return;let t=e.id,{locale:i}=this.#t.config(),n=this.#K===t,s=this.#z,a=t?this.#p.get(t):void 0,o=a?.messages??[],l=this.#c.filter((v)=>v.conversation===t),c=t?this.#a.get(t):void 0,d=[],p=this.#s?.chat.greeting;if(!a||a.complete){if(p){let v=r("div","bubble greeting");v.append(q(p)),d.push(v)}else if(o.length===0&&l.length===0){let v=r("div","center");v.append(r("p","empty",this.#e({id:"meAa31"})),r("p","hint",this.#e({id:"SdV5Cn"}))),d.push(v)}}else if(a.loading)d.push(r("p","hint",this.#e({id:"Pwqkdw"})));let u=[...o.map((v)=>({kind:"message",message:v})),...l.map((v)=>({kind:"pending",pending:v}))],x=new Set,C="",h=null,m=(v)=>{if(!h)return;let{node:O,stack:y,mine:T,at:E}=h,U=this.#bt(u,v,T,E,t);if(U){if(!T)U.classList.add("theirs-meta");y.append(U)}d.push(O),h=null};if(u.forEach((v,O)=>{let y=v.kind==="message"?v.message:null,T=y?.created_at??"",E=!y||y.author.type==="contact",U=y?_e(y):"contact";if(y&&T&&!Me(T,C||"1970-01-01"))m(!1),d.push(r("div","day",ze(i,T))),C=T;if(y&&!E&&y.author.type==="member"&&y.author.name){let k=y.author.name;if(!x.has(k)){if(x.add(k),a?.complete&&O>0){m(!1);let _=r("div","sys");_.insertAdjacentHTML("beforeend",f.person),_.append(this.#e({id:"A4P5nB",values:{name:k}})),d.push(_)}}}if(!h||h.key!==U||y&&R(T)-R(h.at)>ut||!1){m(!1);let k=r("div",E?"group mine":"row theirs"),_=E?k:r("div","stack");if(!E&&y){let j=this.#Ze(y.author);if(j.style.marginBlockEnd="22px",k.append(j,_),y.author.name)_.append(r("div","author",y.author.name))}h={mine:E,key:U,at:T||new Date().toISOString(),node:k,stack:_}}if(!h)return;if(y){if(h.at=T,y.body.trim()){let k=r("div","bubble");k.dir="auto",k.title=new Date(T).toLocaleString(i),k.append(q(y.body)),h.stack.append(k)}if(y.attachments.length>0)h.stack.append(this.#kt(y.attachments,E));for(let k of y.cards??[])h.stack.append(this.#Ct(k))}else if(v.kind==="pending"){let k=v.pending;if(k.body){let _=r("div","bubble");_.dir="auto",_.append(q(k.body)),h.stack.append(_)}if(k.files.length>0){let _=r("div","files");for(let j of k.files)_.append(this.#xt(j,k));h.stack.append(_)}}}),m(!0),c?.kind==="feedback"&&c.status==="closed")d.push(r("p","hint resolved",this.#e({id:"O6H89R"})));else if(c?.status==="closed"&&o.length>0){let v=r("div","sys");v.insertAdjacentHTML("beforeend",f.check),v.append(this.#e({id:"otDzIg"})),d.push(v)}let g=c?this.#wt(c):null;if(g)d.push(g);if(this.#Me(),!this.#b.hidden)d.push(this.#b);let S=t?this.#C.get(t):void 0;if(S){let v=r("div","typing");v.setAttribute("role","status");let O=S.name,y=r("div","dots");y.append(r("i"),r("i"),r("i")),v.append(this.#Ze({name:O}),y,r("span","sr",O?this.#e({id:"tHaDPf",values:{name:O}}):this.#e({id:"PxYAul"}))),d.push(v)}let P=this.#d.getRootNode(),A=P.activeElement===this.#x||P.activeElement===this.#S,I=P.activeElement,{selectionStart:Fe,selectionEnd:Ye}=this.#x;if(this.#d.replaceChildren(...d),A&&I instanceof HTMLElement&&I.isConnected){if(I.focus({preventScroll:!0}),I===this.#x)this.#x.setSelectionRange(Fe,Ye)}if(this.#_.firstChild!==this.#d)this.#_.replaceChildren(this.#d,this.#H,this.#Ee);if(this.#K=t,!n||s)this.#M()}#bt(e,t,i,n,s){let a=e[e.length-1];if(!i)return r("div","meta",this.#ze(n));if(t&&a?.kind==="pending"){let l=a.pending;if(l.state==="failed"){let c=r("div","meta failed",`${this.#e({id:"upFvcp"})} `);return c.append(z(this.#e({id:"6gRgw8"}),"link",()=>void this.#Be(l))),c}if(l.state==="refused"){let c=l.status===413?this.#e({id:"eOu9Px"}):this.#e({id:"JkW3Ph"});return r("div","meta failed",`${this.#e({id:"upFvcp"})} ${c}`)}return r("div","meta",this.#e({id:"Sad2tK"}))}let o=r("div","meta",this.#ze(n));if(t&&a?.kind==="message"){let l=s?this.#a.get(s)?.last_read_by_member_at:void 0,c=!!l&&R(l)>=R(a.message.created_at);if(o.textContent=`${c?this.#e({id:"6lGaum"}):this.#e({id:"h69WC6"})} ${this.#ze(n)}`,c)o.classList.add("seen"),o.insertAdjacentHTML("beforeend",f.seen)}return o}#xt(e,t){let i=t.state!=="sending",n=r("div",i?"att bad":"att busy"),s=r("span","thumb");s.innerHTML=f.file;let a=r("span","info"),{locale:o}=this.#t.config();return a.append(r("span","name",e.name||"image"),r("span","sub",i?this.#e({id:"upFvcp"}):this.#e({id:"gANddk"})+" · "+B(o,e.size))),n.append(s,a),n}#wt(e){let t=e.status==="closed"?e.rating:void 0,i=e.can_rate&&this.#s?.ask_for_rating?this.#A.get(e.id):void 0;if(!t&&!(e.can_rate&&this.#s?.ask_for_rating))return null;let n=this.#et,s=[e.id,t,i?.choice,i?.state,this.#t.config().locale].join(":");if(s===this.#ae)return n;if(this.#ae=s,this.#Ie!==e.id)this.#Ie=e.id,this.#x.value="";let a=this.#e({id:"uA8iBc"});n.setAttribute("role","group"),n.setAttribute("aria-label",a);let o=r("div","choices");for(let u of["good","bad"]){if(t&&t!==u)continue;let x=r("button","choice",u==="good"?"\uD83D\uDC4D":"\uD83D\uDC4E");x.type="button";let C=u==="good"?this.#e({id:"OEEQKT"}):this.#e({id:"-f5Tkb"});x.setAttribute("aria-label",C),x.title=C,x.setAttribute("aria-pressed",String((t??i?.choice)===u)),x.disabled=!!t||i?.state==="sending",x.addEventListener("click",()=>this.#ct(e.id,u)),o.append(x)}if(t)return n.replaceChildren(o,r("p","",this.#e({id:"SOk0EB"}))),n;if(n.replaceChildren(r("p","",a),o),!i)return n;this.#x.placeholder=this.#e({id:"axQ1h6"}),this.#x.setAttribute("aria-label",this.#e({id:"NBdIgR"})),this.#x.disabled=i.state==="sending";let l=r("form");l.addEventListener("submit",(u)=>{u.preventDefault(),this.#qe(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.#qe(e.id,!1));let d=r("button","",i.state==="sending"?this.#e({id:"Sad2tK"}):this.#e({id:"JlFcis"}));d.type="submit",d.disabled=i.state==="sending";let p=r("div","actions");if(p.append(c,d),l.append(this.#x,p),n.append(l),i.state==="failed")n.append(r("p","error",this.#e({id:"4TqZiz"})));return n}#Ct(e){let t=r("a","article-card");t.href=e.url,t.target="_blank",t.rel="noopener noreferrer",t.dir="auto";let i=r("span","article-card-text");if(i.append(r("b","",e.title)),e.excerpt)i.append(r("span","",e.excerpt));return t.insertAdjacentHTML("beforeend",f.book),t.append(i),t.insertAdjacentHTML("beforeend",f.chevron),t.addEventListener("click",(n)=>{if(!this.#s?.help||n.metaKey||n.ctrlKey||n.shiftKey)return;n.preventDefault(),this.#se("help",{article:e.article_id})}),t}#kt(e,t){let i=r("div","files"),{locale:n}=this.#t.config();for(let s of e)if(Pe(s)){let a=r("img","preview");a.alt=s.filename;let o=this.#L.get(s.id);if(o)a.src=o;else this.#Je(s).then((l)=>{a.src=l}).catch(()=>{return});a.addEventListener("load",()=>{if(this.#z)this.#d.scrollTop=this.#d.scrollHeight}),a.addEventListener("click",()=>void this.#Ge(s)),i.append(a)}else{let a=r("button","att");a.type="button";let o=r("span","thumb");o.innerHTML=f.file;let l=r("span","info");l.append(r("span","name",s.filename),r("span","sub",[Re(s.filename,s.content_type),B(n,s.size)].filter(Boolean).join(" · "))),a.append(o,l),a.addEventListener("click",()=>void this.#Ge(s)),i.append(a)}if(!t)i.style.alignItems="flex-start";return i}#ze(e){return new Intl.DateTimeFormat(this.#t.config().locale,{timeStyle:"short"}).format(new Date(e))}#St(){let e=this.#k,t=this.#n;if(t?.kind!=="thread")return null;if(!(t.id!==null||this.#c.length>0))return null;let n=e?.email_confirmation,s=n?.state==="sent"&&(!n.expires_at||Date.parse(n.expires_at)>Date.now());if(n?.state==="undeliverable"&&!this.#R)return"bad";if(s&&!this.#R)return"sent";if(n?.state==="confirmed"&&!this.#R)return"confirmed";let a=!!e?.email;if(this.#R||n?.state==="sent"&&!a)return"ask";if(this.#fe&&(a||e?.typed_email))return"saved";if(this.#s?.chat.ask_email_offline&&this.#dt()&&!a)return"ask";return null}#Me(){let e=this.#St();if(this.#b.hidden=!e,this.#N)clearTimeout(this.#N);if(this.#N=null,!e){this.#j="";return}let t=this.#k?.email_confirmation,i=t?.email??this.#k?.typed_email??this.#k?.email??"";if(e==="sent"&&t?.expires_at){let c=Math.min(Date.parse(t.expires_at)-Date.now()+100,ft);this.#N=setTimeout(()=>this.#r(),Math.max(c,0))}let n=[e,i,this.#I,this.#J,this.#G,this.#t.config().locale].join("|");if(n===this.#j)return;if(this.#j.split("|")[0]!==e)this.#S.value=e==="bad"||e==="ask"?i:"";this.#j=n;let s=()=>this.#J?[r("span","soft",this.#J)]:[],a=()=>this.#I?[r("p","error",this.#I)]:[],o=()=>{let c=r("form","inline-form");c.noValidate=!0,c.addEventListener("submit",(p)=>{p.preventDefault(),this.#Ve()});let d=r("button","btn",this.#e({id:"tfDRzk"}));return d.type="submit",d.disabled=this.#G,c.append(this.#S,d),c},l=(c)=>r("b","",c);if(e==="sent"){this.#b.className="mail",this.#b.innerHTML=f.mail;let c=r("div","text"),d=r("span","soft"),p="\x01",u=((m)=>this.#e({id:"gmPmD9",values:{address:m}}))(p),[x="",C=""]=u.split(p);d.append(x,l(i),C);let h=r("div","acts");h.append(z(this.#e({id:"c4RuNX"}),"link brand",()=>{this.#R=!0,this.#I="",this.#J="",this.#r(),this.#S.focus()}),z(this.#e({id:"J_jxKQ"}),"link soft",()=>void this.#Ve(i))),c.append(r("b","",this.#e({id:"5IXWmO"})),d,h,...s(),...a()),this.#b.append(c)}else if(e==="bad"){this.#b.className="mail bad";let c=r("div","head");c.insertAdjacentHTML("beforeend",f.alert),c.append(this.#e({id:"io8YUT",values:{address:i}})),this.#b.replaceChildren(c,r("span","soft",this.#e({id:"7b0Aa9"})),o(),...a())}else if(e==="confirmed")this.#b.className="mail ok",this.#b.innerHTML=f.check,this.#b.append(this.#e({id:"gxoeD3",values:{address:i}}));else if(e==="saved"){this.#b.className="mail ok",this.#b.innerHTML=f.check;let c=i;this.#b.append(this.#e({id:"iGNUZJ",values:{known:c}}))}else{this.#b.className="card";let c=this.#R?[z(this.#e({id:"dEgA5A"}),"link soft",()=>{this.#R=!1,this.#I="",this.#r()})]:[];this.#b.replaceChildren(r("p","",this.#e({id:"M62PBt"})),o(),...a(),...c)}}#ue(){let{locale:e}=this.#t.config();this.#xe.hidden=this.#l.length===0,this.#xe.replaceChildren(...this.#l.map((t,i)=>{let n=r("span","chip");n.insertAdjacentHTML("beforeend",f.file);let s=r("span","two");return s.append(r("b","",t.name||"image"),r("span","",B(e,t.size))),n.append(s,H(f.closeSmall,this.#e({id:"w61W3L",values:{0:t.name}}),()=>{this.#l=this.#l.filter((a,o)=>o!==i),this.#ue(),this.#ie()},"icon sm")),n}))}}function gt(e){return new Ne(e)}export{gt as mount};
302
+ `).forEach((o,l)=>{if(l>0)t.append(document.createElement("br"));t.append(...ie(o))})}),t}var ct=(e)=>import(new URL(dt('{"el":"widget/yuva-panel-el-vhskf13n.js","tr":"widget/yuva-panel-tr-ywyzb4rn.js","ml":"widget/yuva-panel-ml-0vb742gf.js","vi":"widget/yuva-panel-vi-t97hnjrg.js","nb":"widget/yuva-panel-nb-34x0g8mq.js","bn":"widget/yuva-panel-bn-w0jg8rz0.js","ta":"widget/yuva-panel-ta-x4nnzatk.js","ar":"widget/yuva-panel-ar-w9kxar7b.js","pa":"widget/yuva-panel-pa-26mhm7me.js","te":"widget/yuva-panel-te-35y4486b.js","hi":"widget/yuva-panel-hi-hyqwxkva.js","pl":"widget/yuva-panel-pl-6bsq33w3.js","th":"widget/yuva-panel-th-rx5h6eq6.js","ja":"widget/yuva-panel-ja-5ep2nhr6.js","es":"widget/yuva-panel-es-91gq45ad.js","pt-pt":"widget/yuva-panel-pt-pt-2a7vh8y9.js","ru":"widget/yuva-panel-ru-1ydh24ae.js","hr":"widget/yuva-panel-hr-xyc32ytv.js","mr":"widget/yuva-panel-mr-f7sn0acm.js","ms":"widget/yuva-panel-ms-7xavwv7n.js","zh-hant":"widget/yuva-panel-zh-hant-a9cgjbmw.js","ur":"widget/yuva-panel-ur-peb4hk7h.js","pt-br":"widget/yuva-panel-pt-br-5bf6ja6w.js","or":"widget/yuva-panel-or-q6eks6dh.js","en":"widget/yuva-panel-en-yntqp1wb.js","id":"widget/yuva-panel-id-egadejce.js","de":"widget/yuva-panel-de-z1haaaf5.js","fi":"widget/yuva-panel-fi-dw2qy2ep.js","ko":"widget/yuva-panel-ko-7cr7d0zc.js","uk":"widget/yuva-panel-uk-9h1czxf0.js","es-mx":"widget/yuva-panel-es-mx-593ry1sp.js","fr":"widget/yuva-panel-fr-mksekp2w.js","he":"widget/yuva-panel-he-kwf5a5r1.js","hu":"widget/yuva-panel-hu-dsf2tr60.js","zh-hans":"widget/yuva-panel-zh-hans-djf7yajw.js","sl":"widget/yuva-panel-sl-0j7nnz7k.js","cs":"widget/yuva-panel-cs-jxdap7hk.js","sv":"widget/yuva-panel-sv-175kbch1.js","ca":"widget/yuva-panel-ca-3xmep2qy.js","fr-ca":"widget/yuva-panel-fr-ca-kwqpxepb.js","gu":"widget/yuva-panel-gu-9brj4atb.js","sk":"widget/yuva-panel-sk-50gc8kfg.js","ro":"widget/yuva-panel-ro-9255bnc4.js","da":"widget/yuva-panel-da-xy0gn2ch.js","nl":"widget/yuva-panel-nl-rkak2t5r.js","it":"widget/yuva-panel-it-dstzsdpt.js","kn":"widget/yuva-panel-kn-ggsqc21e.js"}',e),import.meta.url).href).then((t)=>t.messages).catch(()=>Q),dt=(e,t)=>JSON.parse(e)[t]??"about:blank",pt=()=>import(new URL("widget/yuva-chat-apps-yrvvqdf9.js",import.meta.url).href),je={none:0,minor:1,major:2,critical:3},ht=10,ut=300000,mt=60000,ft=2147483647;class Ne{#t;#g;#i;#s=null;#w=0;#u="";#m=0;#k=null;#f="loading";#v="";#y=null;#P=null;#a=new Map;#$;#p=new Map;#c=[];#C=new Map;#n=null;#O=!1;#l=[];#o=0;#T=null;#L=new Map;#U=new Map;#me=new Map;#fe=!1;#I="";#J="";#R=!1;#G=!1;#j="";#N=null;#ge=!1;#A=new Map;#et=r("div","card rate");#x=r("textarea");#ae="";#Ie=null;#re=!1;#ve=!1;#oe=null;#F=0;#ye=!1;#Q=null;#Y=0;#Ae="";ready;#X=r("header","header");#be=r("div","banner");#_=r("div","body");#d=r("div","scroll");#H=r("div","notice");#b=r("div","");#S=r("input","field");#Ee=r("div","sec composer");#xe=r("div","chips");#h=r("textarea");#E=r("input");#Z;#le;#ee;#D=r("button","jump");#De=r("span","hintkey");#we=r("div","sr");#K;#z=!0;constructor(e){this.#t=e;let{server:t,channel:i}=e.config();this.#i=xe({server:t,channel:i??"",identityToken:()=>e.identityToken()}),this.#i.on("event",(a)=>this.#at(a)),this.#i.on("connection",({state:a,attempt:o})=>{if(a!=="reconnecting")return;this.#O=o>0,this.#Te()}),this.#i.on("session",({session:a,renewed:o})=>{if(this.#de(a.inbox),this.#k=a.contact,o)this.#Ye();else if(!this.#P)this.#i.connect().catch(()=>{return})}),this.ready=this.#$e(),this.#we.setAttribute("aria-live","polite"),this.#d.setAttribute("role","log"),this.#d.addEventListener("scroll",()=>{if(this.#z=this.#d.scrollHeight-this.#d.scrollTop-this.#d.clientHeight<48,this.#z)this.#Y=0;if(this.#Pe(),this.#d.scrollTop<60&&this.#n?.kind==="thread"&&this.#n.id)this.#ke(this.#n.id,!0)}),this.#D.type="button",this.#D.addEventListener("click",()=>{this.#Y=0,this.#M(),this.#Pe()}),this.#h.rows=2,this.#h.addEventListener("keydown",(a)=>{if(a.key==="Enter"&&!a.shiftKey&&!a.isComposing)a.preventDefault(),this.#_e()}),this.#h.addEventListener("input",()=>{this.#We(),this.#ie(),this.#lt()}),this.#h.addEventListener("paste",(a)=>{let o=Array.from(a.clipboardData?.files??[]);if(o.length===0)return;a.preventDefault(),this.#Se(o)}),this.#E.type="file",this.#E.multiple=!0,this.#E.hidden=!0,this.#E.addEventListener("change",()=>{this.#Se(Array.from(this.#E.files??[])),this.#E.value=""}),this.#le=H(f.attach,"",()=>this.#E.click(),"icon tool"),this.#ee=H(f.shot,"",()=>void this.#ot(),"icon tool"),this.#ee.hidden=!Ie(),this.#Z=H(f.send,"",()=>void this.#_e(),"send");let n=r("div","tools");n.append(this.#le,this.#ee,r("span","grow"),this.#De,this.#Z,this.#E);let s=r("form","box");s.addEventListener("submit",(a)=>{a.preventDefault(),this.#_e()}),s.append(this.#xe,this.#h,n),this.#Ee.append(this.#D,s),this.#S.type="email",this.#S.required=!0,this.#S.autocomplete="email",this.#x.rows=2,this.#x.maxLength=2000,this.#x.dir="auto",document.addEventListener("visibilitychange",this.#ce),window.addEventListener("online",this.#ce),this.ready.then(()=>{this.#Xe(),this.#W()})}update(){this.#$e().then(()=>{this.#j="",this.#ae="",this.#Xe()})}opened(){if(this.#f==="error"){this.#y=null,this.#W();return}if(this.#f==="ready"){if(this.#i.token)this.#st();else if(this.#He())this.#Ue().then(()=>this.#r()).catch(()=>{return});this.#Oe()}if(this.#r(),this.#M(),this.#te(),this.#t.config().layout==="launcher"&&this.#n?.kind==="thread")this.#h.focus({preventScroll:!0})}async openApp(e,t={}){if(await this.ready,await this.#W(),this.#f==="ready")await this.#se(e,t)}closed(){this.#q()}identityChanged(){this.#Le(),this.#W()}async signOut(){let e=this.#i.signOut();if(this.#Le(),await e,this.#t.isOpen())this.#W();else this.#r()}destroy(){if(this.#i.reset(),this.#q(),this.#ne(),this.#N)clearTimeout(this.#N);document.removeEventListener("visibilitychange",this.#ce),window.removeEventListener("online",this.#ce);for(let e of this.#L.values())URL.revokeObjectURL(e)}#Le(){this.#i.reset(),this.#ne(),this.#y=null,this.#P=null,this.#s=null,this.#k=null,this.#f="loading",this.#a.clear(),this.#p.clear(),this.#c=[],this.#A.clear(),this.#ae="",this.#n=null,this.#re=!1,this.#ve=!1,this.#fe=!1,this.#R=!1,this.#j="",this.#ge=!1,this.#Y=0,this.#t.setUnread(0),this.#w=0,this.#u="",this.#m=0,this.#t.setUpdates(0)}#ce=()=>{if(document.visibilityState!=="visible")return;if(this.#i.reconnect(),this.#te(),this.#i.connected||this.#He())this.#Ne()};#He(){return!this.#i.connected&&Date.now()-this.#m>=mt}async#$e(){let{locale:e}=this.#t.config();if(this.#g??=Y({locale:"en",messages:{en:Q}}),this.#Ae===e)return;let t=await ct(e);if(e!==this.#t.config().locale)return;this.#g=Y({locale:e,messages:{[e]:t}}),this.#Ae=e}#e(e){return this.#g._(e)}#W(){return this.#y??=(async()=>{this.#f="loading",this.#r();let{channel:e}=this.#t.config();if(!e)throw new w(0,"not_configured");if(await this.#t.identityToken()||L(e).session)await this.#nt();else if(await this.#Ue(),!this.#s?.chat.allow_anonymous)throw new w(403,"anonymous_not_allowed");this.#f="ready",this.#n??={kind:"home"},this.#Oe(),this.#r(),this.#M(),this.#te()})().catch((e)=>{if(this.#y=null,this.#Fe(e))return;this.#f="error",this.#v=e instanceof w?e.code:"error",this.#r()}),this.#y}#Oe(){if(this.#ve||!this.#t.config().channel)return;this.#ve=!0,this.#i.lists().then((e)=>{this.#re=(e?.lists.length??0)>0,this.#r()}).catch(()=>{return})}async#Ue(){let e=await this.#je();if(!this.#i.token)this.#de(e)}async#je(){if(!this.#t.config().channel)throw new w(0,"not_configured");let e=await this.#i.channelSettings();return this.#m=Date.now(),e}#de(e){let{channel:t}=this.#t.config();this.#s=e;let i=pe(e);if(this.#t.setLauncher(i),!t)return;let n=L(t),s=new Set(e.status?.open.map((l)=>l.id)),a=Object.fromEntries(Object.entries(n.dismissed_status??{}).filter(([l])=>s.has(l))),o={...n,launcher:i};if(Object.keys(a).length>0)o.dismissed_status=a;else delete o.dismissed_status;X(t,o),this.#tt()}#tt(){let{channel:e,server:t,locale:i}=this.#t.config(),n=this.#s;if(!e||!n?.whats_new)return this.#Ce(0);let s=`${n.whats_new.latest_published_at}|${L(e).whats_new_seen??""}`;if(s===this.#u)return;this.#u=s,De(t,e,n,i).then((a)=>{if(s===this.#u)this.#Ce(a)}).catch(()=>{if(s===this.#u)this.#u=""})}#Ce(e){if(e===this.#w)return;if(this.#w=e,this.#t.setUpdates(this.#s?.chat.announce_updates?e:0),this.#n?.kind==="home")this.#r()}#it(){let{channel:e}=this.#t.config(),t=e&&L(e).dismissed_status||{},i=[...this.#s?.status?.open??[]].filter((o)=>t[o.id]!==o.updated_at).sort((o,l)=>je[l.impact]-je[o.impact])[0];if(this.#H.hidden=!i,!i)return this.#H.replaceChildren();let n={investigating:{id:"WAnUgI"},identified:{id:"tddaHo"},monitoring:{id:"1gZQhL"},resolved:{id:"O6H89R"},scheduled:{id:"4ba0NE"},in_progress:{id:"_LCAwL"},completed:{id:"qqWcBV"}},s=r("a","",i.title);s.href=i.url,s.target="_blank",s.rel="noopener noreferrer",s.dir="auto";let a=r("div","notice-text");a.append(r("strong","",this.#e(n[i.state]))," ",s),this.#H.className=`notice impact-${i.impact}`,this.#H.replaceChildren(a,H(f.closeSmall,this.#e({id:"1QfxQT"}),()=>{if(!e)return;let o=L(e);X(e,{...o,dismissed_status:{...o.dismissed_status,[i.id]:i.updated_at}}),this.#r()},"icon sm"))}async#Ne(){if(this.#f!=="ready")return;try{this.#de(await this.#je()),this.#r()}catch(e){this.#Fe(e,!0)}}#Fe(e,t=!this.#i.token){let i=e instanceof w&&(e.code==="origin_not_allowed"||e.status===404&&t);if(i)this.#t.refused();return i}#nt(){return this.#P??=(async()=>{await this.#i.start(),await this.#pe(),await this.#i.connect()})().finally(()=>{this.#P=null}),this.#P}async#st(){try{await this.#i.refresh(),this.#r()}catch{}}async#pe(e=!1){let t=await this.#i.listConversations({limit:50,cursor:e?this.#$:void 0});if(!e)this.#a.clear();for(let i of t.items)this.#a.set(i.id,i);this.#$=t.next_cursor,this.#B()}async#Ye(){await this.#pe();let e=this.#n?.kind==="thread"?this.#n.id:null;for(let t of this.#p.keys())if(t!==e)this.#p.delete(t);if(e)this.#p.delete(e),await this.#ke(e);this.#r()}async#ke(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.#i.listMessages(e,{order:"desc",limit:30,cursor:t?i.cursor:void 0}),a=new Set(i.messages.map((o)=>o.id));i.messages=[...i.messages,...s.items.filter((o)=>!a.has(o.id))].sort(ee),i.cursor=s.next_cursor,i.complete=!s.next_cursor}finally{i.loading=!1}if(t)this.#r(),this.#d.scrollTop=this.#d.scrollHeight-n}#at(e){switch(e.type){case"ready":if(this.#O=!1,this.#Te(),this.#ge)this.#Ne();this.#ge=!0;return;case"inbox.updated":{let t=this.#s?.ask_for_rating;if(this.#de(e.data),t!==void 0&&t!==e.data.ask_for_rating)this.#pe().then(()=>this.#r()).catch(()=>{return});break}case"contact.updated":this.#k=e.data;break;case"resync_required":this.#Ye();return;case"presence":if(this.#s)this.#s={...this.#s,presence:e.data};break;case"conversation.created":if(!this.#a.has(e.data.id))this.#a.set(e.data.id,e.data);if(this.#n?.kind==="thread"&&this.#n.id===null&&this.#a.size>1)this.#n=this.#c.some((t)=>t.conversation===null)?this.#n:{kind:"home"};this.#B();break;case"conversation.updated":{let t=this.#a.get(e.data.id),{status:i,can_rate:n,rating:s}=e.data;if(t)this.#a.set(t.id,{...t,status:i,can_rate:n,rating:s});if(!n)this.#A.delete(e.data.id);break}case"message.created":case"message.updated":this.#he(e.data,e.type==="message.created");break;case"read":{let t=this.#a.get(e.data.conversation_id),i=t?.last_read_by_member_at;if(t&&(!i||R(e.data.read_at)>R(i)))this.#a.set(t.id,{...t,last_read_by_member_at:e.data.read_at});break}case"typing":{let t=e.data.conversation_id,i=this.#C.get(t);if(i)clearTimeout(i.timer);if(e.data.typing){let n=e.data.author.name??"";this.#C.set(t,{name:n,timer:setTimeout(()=>this.#C.delete(t)&&this.#r(),8000)})}else this.#C.delete(t);break}}this.#r()}#he(e,t){let i=e.conversation_id,n=this.#p.get(i);if(n){let a=n.messages.findIndex((o)=>o.id===e.id);if(a>=0)n.messages[a]=e;else n.messages=[...n.messages,e].sort(ee)}if(e.client_id)this.#c=this.#c.filter((a)=>a.client_id!==e.client_id);let s=this.#a.get(i);if(!s){this.#i.getConversation(i).then((a)=>{this.#a.set(a.id,a),this.#B(),this.#r()}).catch(()=>{return});return}if(t){let a=e.body.replace(/\s+/g," ").trim();if(this.#a.set(i,{...s,last_message:{id:e.id,author_type:e.author.type,text:a.length>140?`${a.slice(0,139)}…`:a,created_at:e.created_at},last_message_at:e.created_at,unread:s.unread||e.author.type!=="contact"}),e.author.type!=="contact"){let o=this.#C.get(i);if(o)clearTimeout(o.timer);if(this.#C.delete(i),this.#rt(e),!this.#z&&this.#Ke()===i)this.#Y++}}this.#B(),this.#te()}#rt(e){this.#we.textContent=`${e.author.name||this.#s?.name||""}: ${e.body.slice(0,200)}`}#B(){let e=0;for(let t of this.#a.values())if(t.unread)e++;this.#t.setUnread(e)}#Ke(){if(!this.#t.isOpen()||document.visibilityState!=="visible")return null;return this.#n?.kind==="thread"?this.#n.id:null}#te(){let e=this.#Ke(),t=e?this.#a.get(e):void 0;if(!e||!t?.unread)return;this.#a.set(e,{...t,unread:!1}),this.#B(),this.#i.markRead(e).catch(()=>{let i=this.#a.get(e);if(i)this.#a.set(e,{...i,unread:!0});this.#B()})}#Se(e){this.#l=[...this.#l,...e].slice(0,ht),this.#ue(),this.#ie(),this.#h.focus()}async#ot(){let e=await Ae(this.#t.panel);if(e)this.#Se([e])}#We(){if(this.#h.style.blockSize="",this.#h.value==="")return;this.#h.style.blockSize="auto",this.#h.style.blockSize=`${Math.max(44,Math.min(this.#h.scrollHeight,140))}px`}#ie(){this.#Z.disabled=this.#h.value.trim()===""&&this.#l.length===0}#lt(){let e=this.#n?.kind==="thread"?this.#n.id:null;if(!e||this.#h.value.trim()===""){this.#q();return}if(Date.now()-this.#o>3000)this.#o=Date.now(),this.#i.setTyping(e,!0).catch(()=>{return});if(this.#T)clearTimeout(this.#T);this.#T=setTimeout(()=>this.#q(),4000)}#q(){if(this.#T)clearTimeout(this.#T);if(this.#T=null,this.#o===0)return;this.#o=0;let e=this.#n?.kind==="thread"?this.#n.id:null;if(e)this.#i.setTyping(e,!1).catch(()=>{return})}async#_e(){if(this.#f!=="ready"||this.#n?.kind!=="thread")return;let e=this.#h.value.trim(),t=this.#l;if(!e&&t.length===0)return;if(this.#n.id===null&&this.#c.some((n)=>n.conversation===null))return;this.#q(),this.#h.value="",this.#l=[],this.#We(),this.#ue(),this.#ie();let i={client_id:W(),conversation:this.#n.id,body:e,files:t,state:"sending"};if(this.#n.id===null&&this.#Q)i.help_article_id=this.#Q,this.#Q=null;this.#c.push(i),this.#r(),this.#M(),await this.#Be(i)}async#Be(e){e.state="sending",this.#r();let t={body:e.body,files:e.files,client_id:e.client_id};try{if(e.conversation===null){let i=await this.#i.startConversation({...t,help_article_id:e.help_article_id}),n=i.conversation.id;if(!this.#a.has(n))this.#a.set(n,i.conversation);if(!this.#p.has(n))this.#p.set(n,{messages:[],complete:!0,loading:!1});if(this.#n?.kind==="thread"&&this.#n.id===null)this.#n={kind:"thread",id:n};this.#he(i.message,!1)}else{let i=await this.#i.sendMessage(e.conversation,t);this.#he(i,!0)}this.#c=this.#c.filter((i)=>i!==e)}catch(i){let n=i instanceof w?i.status:0;e.state=n===413||n===415?"refused":"failed",e.status=n}this.#r(),this.#M()}async rate(e,t,i){try{let n=await this.#i.rate(e,t,i);return this.#a.set(n.id,n),this.#A.delete(e),this.#r(),n}catch(n){if(n instanceof w&&n.status===409){let s=await this.#i.getConversation(e).catch(()=>null);if(s)this.#a.set(s.id,s);this.#A.delete(e),this.#r()}throw n}}#ct(e,t){if(this.#A.get(e)?.state==="sending")return;if(this.#A.set(e,{choice:t,state:"choosing"}),this.#r(),this.#x.focus({preventScroll:!0}),this.#z)this.#M()}async#qe(e,t){let i=this.#A.get(e);if(!i||i.state==="sending")return;i.state="sending",this.#r();try{await this.rate(e,i.choice,t?this.#x.value:void 0),this.#x.value=""}catch(n){if(n instanceof w&&n.status===409)return;i.state="failed",this.#r()}}async#Ve(e){let t=(e??this.#S.value).trim();if(!t||e===void 0&&!this.#S.checkValidity()){this.#I=this.#e({id:"E_qvzP"}),this.#Me();return}if(this.#G)return;this.#G=!0;try{this.#k=await this.#i.setEmail(t),this.#fe=!0,this.#R=!1,this.#I="",this.#J=e===void 0?"":this.#e({id:"mj_YKf"})}catch(i){this.#I=i instanceof w&&i.status===429?this.#e({id:"tzsBOP"}):this.#e({id:"ZxJcgC"})}finally{this.#G=!1}this.#Me(),this.#r()}#Je(e){let t=this.#L.get(e.id);if(t)return Promise.resolve(t);let i=this.#U.get(e.id);if(!i)i=this.#i.attachment(e.id).then((n)=>{let s=URL.createObjectURL(n);return this.#L.set(e.id,s),s}),i.catch(()=>this.#U.delete(e.id)),this.#U.set(e.id,i);return i}async#Ge(e){let t=await this.#Je(e),i=r("a");i.href=t,i.download=e.filename,i.rel="noopener",i.click()}#Qe(){return[...this.#a.values()].sort(Se)}#dt(){let e=this.#s;if(!e)return!1;return!e.open_now||e.mode==="async"||!e.presence?.available}#M(){this.#z=!0,this.#Y=0,this.#d.scrollTop=this.#d.scrollHeight,requestAnimationFrame(()=>{if(this.#z)this.#d.scrollTop=this.#d.scrollHeight})}#Pe(){let e=!this.#z&&this.#n?.kind==="thread";if(this.#D.hidden=!e,!e)return;this.#D.setAttribute("aria-label",this.#e({id:"ju1Z9b"}));let t=this.#Y;this.#D.replaceChildren(),this.#D.insertAdjacentHTML("beforeend",f.down),this.#D.append(t>0?this.#e({id:"RnNe7a",values:{count:t}}):this.#e({id:"ju1Z9b"}))}#Xe(){this.#h.placeholder=this.#e({id:"RzWUUK"}),this.#h.setAttribute("aria-label",this.#e({id:"xDAtGP"})),this.#le.setAttribute("aria-label",this.#e({id:"N7m8E-"})),this.#le.title=this.#e({id:"N7m8E-"}),this.#ee.setAttribute("aria-label",this.#e({id:"TZglEu"})),this.#ee.title=this.#e({id:"TZglEu"}),this.#Z.setAttribute("aria-label",this.#e({id:"JlFcis"})),this.#Z.title=this.#e({id:"JlFcis"}),this.#De.replaceChildren(r("kbd","",this.#e({id:"9Vnjc9"})),this.#e({id:"0IRz4M"})),this.#S.placeholder=this.#e({id:"njBr8W"}),this.#S.setAttribute("aria-label",this.#e({id:"XJURKP"})),this.#d.setAttribute("aria-label",this.#e({id:"YyNOE7"})),this.#ie(),this.#ue(),this.#r()}#V(e){if(this.#q(),e.kind!=="thread"||e.id!==null)this.#Q=null;if(e.kind!=="app")this.#ne();if(this.#n=e,this.#r(),e.kind==="thread")this.#M(),this.#h.focus({preventScroll:!0})}#ne(){this.#F++,this.#ye=!1,this.#oe?.handle.destroy(),this.#oe=null}async#se(e,t={}){this.#ne();let i=this.#F;this.#n={kind:"app",app:e},this.#r();try{let n=await pt(),s=this.#s;if(i!==this.#F||!s)return;let{locale:a}=this.#t.config(),o=await n.mountApp(e,{root:this.#t.panel.getRootNode(),client:this.#i,inbox:s,locale:a,mailingLists:this.#re,params:t,back:()=>this.#V({kind:"home"}),open:(l,c)=>void this.#se(l,c),ask:(l)=>{this.#V({kind:"thread",id:null}),this.#Q=l??null},created:(l)=>{let c=l.conversation.id;if(!this.#a.has(c))this.#a.set(c,l.conversation);if(!this.#p.has(c))this.#p.set(c,{messages:[],complete:!0,loading:!1});this.#he(l.message,!1)},viewConversation:(l)=>void this.#Re(l),seenUpdates:()=>this.#Ce(0)});if(i!==this.#F)return o.destroy();this.#oe={kind:e,handle:o}}catch{if(i===this.#F)this.#ye=!0}if(i===this.#F)this.#r()}#r(){let e=this.#t.panel;if(e.childElementCount===0){let i=Ce(e.getRootNode(),Ue);e.append(...i?[i]:[],this.#X,this.#be,this.#_,this.#we),this.#X.id="yuva-title",e.setAttribute("aria-labelledby","yuva-title")}if(this.#ut(),this.#Te(),this.#f!=="ready"){this.#K=void 0;let i=r("div","center");if(this.#f==="loading")i.append(r("p","hint",this.#e({id:"Pwqkdw"})));else{i.append(r("p","empty",this.#pt()));let n=z(this.#e({id:"KDw4GX"}),"primary",()=>{this.#y=null,this.#W()});i.append(n)}this.#_.replaceChildren(i);return}this.#it();let t=this.#n??{kind:"home"};if(t.kind==="home")this.#ft();else if(t.kind==="list")this.#vt();else if(t.kind==="app")this.#gt();else this.#yt();this.#Pe()}#pt(){switch(this.#v){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"})}}#ht(e){if(e.mode==="live"&&e.open_now&&e.presence?.available)return[r("span","",this.#e({id:"oXOSPE"}))];if(!e.open_now||e.mode==="live")return[r("span","",this.#e({id:"1EICzz"}))];return[r("span","",this.#mt(e.expected_reply_minutes))]}#ut(){let{layout:e}=this.#t.config(),t=this.#s,i=this.#f==="ready"?this.#n??{kind:"home"}:{kind:"home"},n=[],s=e==="launcher"?H(f.close,this.#e({id:"yz7wBu"}),()=>this.#t.close()):null;if(i.kind==="home"){this.#X.className="header home";let a=r("div","headbrand"),o=r("span","mark"),l=t?.branding.logo_url;if(l&&/^https?:/i.test(l)){let c=r("img");c.alt="",c.referrerPolicy="no-referrer",c.addEventListener("error",()=>o.replaceChildren((t?.name||"Y").slice(0,1))),c.src=l,o.append(c)}else o.textContent=(t?.name||"Y").slice(0,1);a.append(o,r("h2","title",t?.name||this.#e({id:"t7TeQU"}))),n.push(a)}else if(this.#X.className="header",n.push(H(f.back,this.#e({id:"iH8pgl"}),()=>this.#V({kind:"home"}))),i.kind==="thread"&&t){let a=r("div","who"),o=t.mode==="live"&&t.open_now&&t.presence?.available,l=o?t.presence?.members[0]:void 0;a.append(r("span","avatar lg",l?.initials||(t.name||"").slice(0,2)),r("span",o?"dot":"dot away")),a.querySelector(".dot")?.setAttribute("aria-hidden","true");let c=r("div","heading");c.append(r("h2","title",t.name||this.#e({id:"t7TeQU"})));let d=r("div","status");d.append(...this.#ht(t)),c.append(d),n.push(a,c)}else{let a=r("div","heading");a.append(r("h2","title",i.kind==="app"?this.#e(He(i.app)):this.#e({id:"S63MQu"}))),n.push(a)}if(s)n.push(s);this.#X.replaceChildren(...n)}#mt(e){if(!e)return this.#e({id:"nhTADq"});let{locale:t}=this.#t.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}})}#Te(){this.#be.hidden=!this.#O,this.#be.textContent=this.#e({id:"09Tv5j"})}#ft(){this.#K=void 0;let e=this.#s;if(!e)return;let t=$e({inbox:e,conversations:this.#Qe(),mailingLists:this.#re,updates:this.#w,locale:this.#t.config().locale,t:(i)=>this.#e(i),notice:this.#H,openConversation:(i)=>void this.#Re(i),allConversations:()=>this.#V({kind:"list"}),newConversation:()=>this.#V({kind:"thread",id:null}),openApp:(i,n)=>void this.#se(i,n)});this.#_.replaceChildren(t)}#gt(){this.#K=void 0;let e=this.#oe;if(e){if(this.#_.firstChild!==e.handle.element||this.#_.childElementCount!==1)this.#_.replaceChildren(e.handle.element);return}let t=r("div","center");if(this.#ye)t.append(r("p","empty",this.#e({id:"5isRv0"})),z(this.#e({id:"KDw4GX"}),"primary",()=>{let i=this.#n;if(i?.kind==="app")this.#se(i.app)}));else t.append(r("p","hint",this.#e({id:"Pwqkdw"})));this.#_.replaceChildren(t)}#vt(){this.#K=void 0;let{locale:e}=this.#t.config(),t=r("ul","list"),i=new Date().toDateString();for(let a of this.#Qe()){let o=r("button",a.unread?"item unread":"item");o.type="button";let l=r("div","item-main"),c=r("div","item-top");if(c.append(r("span","item-subject",a.subject||this.#s?.name||this.#e({id:"YyNOE7"}))),a.kind==="feedback"&&a.status==="closed")c.append(r("span","item-state",this.#e({id:"O6H89R"})));let d=new Date(a.last_message_at??a.created_at);c.append(r("span","item-time",new Intl.DateTimeFormat(e,d.toDateString()===i?{timeStyle:"short"}:{month:"short",day:"numeric"}).format(d)));let p=a.last_message?`${a.last_message.author_type==="contact"?this.#e({id:"ydzYKJ"})+" ":""}${a.last_message.text||this.#e({id:"UY1vmE"})}`:"",u=r("div","item-preview",p.replace(/\*\*|`/g,""));if(u.dir="auto",l.append(c,u),o.append(l),a.unread)o.append(r("span","unread-dot"));o.addEventListener("click",()=>void this.#Re(a.id));let x=r("li");x.append(o),t.append(x)}let n=r("div","page");if(n.append(this.#H,t),this.#$){let a=z(this.#e({id:"ASr-r0"}),"link soft",()=>void this.#pe(!0).then(()=>this.#r()));a.style.margin="8px auto",n.append(a)}let s=z(this.#e({id:"-HY5kX"}),"primary",()=>this.#V({kind:"thread",id:null}));s.style.margin="16px 32px",n.append(r("div","fill"),s),this.#_.replaceChildren(n)}async#Re(e){if(this.#ne(),this.#n={kind:"thread",id:e},this.#r(),!this.#p.get(e)?.complete&&!this.#p.get(e)?.messages.length)await this.#ke(e).catch(()=>{return});this.#r(),this.#M(),this.#te()}#Ze(e){let t=r("span","avatar",e.initials||Te(e.name??"")),i=e.avatar_url,n=i?this.#me.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.#me.set(i,!0),t.isConnected)t.replaceChildren(s)}),s.addEventListener("error",()=>this.#me.set(i,!1)),s.src=i,t}#yt(){let e=this.#n;if(e?.kind!=="thread")return;let t=e.id,{locale:i}=this.#t.config(),n=this.#K===t,s=this.#z,a=t?this.#p.get(t):void 0,o=a?.messages??[],l=this.#c.filter((v)=>v.conversation===t),c=t?this.#a.get(t):void 0,d=[],p=this.#s?.chat.greeting;if(!a||a.complete){if(p){let v=r("div","bubble greeting");v.append(q(p)),d.push(v)}else if(o.length===0&&l.length===0){let v=r("div","center");v.append(r("p","empty",this.#e({id:"meAa31"})),r("p","hint",this.#e({id:"SdV5Cn"}))),d.push(v)}}else if(a.loading)d.push(r("p","hint",this.#e({id:"Pwqkdw"})));let u=[...o.map((v)=>({kind:"message",message:v})),...l.map((v)=>({kind:"pending",pending:v}))],x=new Set,C="",h=null,m=(v)=>{if(!h)return;let{node:O,stack:y,mine:T,at:E}=h,U=this.#bt(u,v,T,E,t);if(U){if(!T)U.classList.add("theirs-meta");y.append(U)}d.push(O),h=null};if(u.forEach((v,O)=>{let y=v.kind==="message"?v.message:null,T=y?.created_at??"",E=!y||y.author.type==="contact",U=y?_e(y):"contact";if(y&&T&&!Me(T,C||"1970-01-01"))m(!1),d.push(r("div","day",ze(i,T))),C=T;if(y&&!E&&y.author.type==="member"&&y.author.name){let k=y.author.name;if(!x.has(k)){if(x.add(k),a?.complete&&O>0){m(!1);let _=r("div","sys");_.insertAdjacentHTML("beforeend",f.person),_.append(this.#e({id:"A4P5nB",values:{name:k}})),d.push(_)}}}if(!h||h.key!==U||y&&R(T)-R(h.at)>ut||!1){m(!1);let k=r("div",E?"group mine":"row theirs"),_=E?k:r("div","stack");if(!E&&y){let j=this.#Ze(y.author);if(j.style.marginBlockEnd="22px",k.append(j,_),y.author.name)_.append(r("div","author",y.author.name))}h={mine:E,key:U,at:T||new Date().toISOString(),node:k,stack:_}}if(!h)return;if(y){if(h.at=T,y.body.trim()){let k=r("div","bubble");k.dir="auto",k.title=new Date(T).toLocaleString(i),k.append(q(y.body)),h.stack.append(k)}if(y.attachments.length>0)h.stack.append(this.#kt(y.attachments,E));for(let k of y.cards??[])h.stack.append(this.#Ct(k))}else if(v.kind==="pending"){let k=v.pending;if(k.body){let _=r("div","bubble");_.dir="auto",_.append(q(k.body)),h.stack.append(_)}if(k.files.length>0){let _=r("div","files");for(let j of k.files)_.append(this.#xt(j,k));h.stack.append(_)}}}),m(!0),c?.kind==="feedback"&&c.status==="closed")d.push(r("p","hint resolved",this.#e({id:"O6H89R"})));else if(c?.status==="closed"&&o.length>0){let v=r("div","sys");v.insertAdjacentHTML("beforeend",f.check),v.append(this.#e({id:"otDzIg"})),d.push(v)}let g=c?this.#wt(c):null;if(g)d.push(g);if(this.#Me(),!this.#b.hidden)d.push(this.#b);let S=t?this.#C.get(t):void 0;if(S){let v=r("div","typing");v.setAttribute("role","status");let O=S.name,y=r("div","dots");y.append(r("i"),r("i"),r("i")),v.append(this.#Ze({name:O}),y,r("span","sr",O?this.#e({id:"tHaDPf",values:{name:O}}):this.#e({id:"PxYAul"}))),d.push(v)}let P=this.#d.getRootNode(),A=P.activeElement===this.#x||P.activeElement===this.#S,I=P.activeElement,{selectionStart:Fe,selectionEnd:Ye}=this.#x;if(this.#d.replaceChildren(...d),A&&I instanceof HTMLElement&&I.isConnected){if(I.focus({preventScroll:!0}),I===this.#x)this.#x.setSelectionRange(Fe,Ye)}if(this.#_.firstChild!==this.#d)this.#_.replaceChildren(this.#d,this.#H,this.#Ee);if(this.#K=t,!n||s)this.#M()}#bt(e,t,i,n,s){let a=e[e.length-1];if(!i)return r("div","meta",this.#ze(n));if(t&&a?.kind==="pending"){let l=a.pending;if(l.state==="failed"){let c=r("div","meta failed",`${this.#e({id:"upFvcp"})} `);return c.append(z(this.#e({id:"6gRgw8"}),"link",()=>void this.#Be(l))),c}if(l.state==="refused"){let c=l.status===413?this.#e({id:"eOu9Px"}):this.#e({id:"JkW3Ph"});return r("div","meta failed",`${this.#e({id:"upFvcp"})} ${c}`)}return r("div","meta",this.#e({id:"Sad2tK"}))}let o=r("div","meta",this.#ze(n));if(t&&a?.kind==="message"){let l=s?this.#a.get(s)?.last_read_by_member_at:void 0,c=!!l&&R(l)>=R(a.message.created_at);if(o.textContent=`${c?this.#e({id:"6lGaum"}):this.#e({id:"h69WC6"})} ${this.#ze(n)}`,c)o.classList.add("seen"),o.insertAdjacentHTML("beforeend",f.seen)}return o}#xt(e,t){let i=t.state!=="sending",n=r("div",i?"att bad":"att busy"),s=r("span","thumb");s.innerHTML=f.file;let a=r("span","info"),{locale:o}=this.#t.config();return a.append(r("span","name",e.name||"image"),r("span","sub",i?this.#e({id:"upFvcp"}):this.#e({id:"gANddk"})+" · "+B(o,e.size))),n.append(s,a),n}#wt(e){let t=e.status==="closed"?e.rating:void 0,i=e.can_rate&&this.#s?.ask_for_rating?this.#A.get(e.id):void 0;if(!t&&!(e.can_rate&&this.#s?.ask_for_rating))return null;let n=this.#et,s=[e.id,t,i?.choice,i?.state,this.#t.config().locale].join(":");if(s===this.#ae)return n;if(this.#ae=s,this.#Ie!==e.id)this.#Ie=e.id,this.#x.value="";let a=this.#e({id:"uA8iBc"});n.setAttribute("role","group"),n.setAttribute("aria-label",a);let o=r("div","choices");for(let u of["good","bad"]){if(t&&t!==u)continue;let x=r("button","choice",u==="good"?"\uD83D\uDC4D":"\uD83D\uDC4E");x.type="button";let C=u==="good"?this.#e({id:"OEEQKT"}):this.#e({id:"-f5Tkb"});x.setAttribute("aria-label",C),x.title=C,x.setAttribute("aria-pressed",String((t??i?.choice)===u)),x.disabled=!!t||i?.state==="sending",x.addEventListener("click",()=>this.#ct(e.id,u)),o.append(x)}if(t)return n.replaceChildren(o,r("p","",this.#e({id:"SOk0EB"}))),n;if(n.replaceChildren(r("p","",a),o),!i)return n;this.#x.placeholder=this.#e({id:"axQ1h6"}),this.#x.setAttribute("aria-label",this.#e({id:"NBdIgR"})),this.#x.disabled=i.state==="sending";let l=r("form");l.addEventListener("submit",(u)=>{u.preventDefault(),this.#qe(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.#qe(e.id,!1));let d=r("button","",i.state==="sending"?this.#e({id:"Sad2tK"}):this.#e({id:"JlFcis"}));d.type="submit",d.disabled=i.state==="sending";let p=r("div","actions");if(p.append(c,d),l.append(this.#x,p),n.append(l),i.state==="failed")n.append(r("p","error",this.#e({id:"4TqZiz"})));return n}#Ct(e){let t=r("a","article-card");t.href=e.url,t.target="_blank",t.rel="noopener noreferrer",t.dir="auto";let i=r("span","article-card-text");if(i.append(r("b","",e.title)),e.excerpt)i.append(r("span","",e.excerpt));return t.insertAdjacentHTML("beforeend",f.book),t.append(i),t.insertAdjacentHTML("beforeend",f.chevron),t.addEventListener("click",(n)=>{if(!this.#s?.help||n.metaKey||n.ctrlKey||n.shiftKey)return;n.preventDefault(),this.#se("help",{article:e.article_id})}),t}#kt(e,t){let i=r("div","files"),{locale:n}=this.#t.config();for(let s of e)if(Pe(s)){let a=r("img","preview");a.alt=s.filename;let o=this.#L.get(s.id);if(o)a.src=o;else this.#Je(s).then((l)=>{a.src=l}).catch(()=>{return});a.addEventListener("load",()=>{if(this.#z)this.#d.scrollTop=this.#d.scrollHeight}),a.addEventListener("click",()=>void this.#Ge(s)),i.append(a)}else{let a=r("button","att");a.type="button";let o=r("span","thumb");o.innerHTML=f.file;let l=r("span","info");l.append(r("span","name",s.filename),r("span","sub",[Re(s.filename,s.content_type),B(n,s.size)].filter(Boolean).join(" · "))),a.append(o,l),a.addEventListener("click",()=>void this.#Ge(s)),i.append(a)}if(!t)i.style.alignItems="flex-start";return i}#ze(e){return new Intl.DateTimeFormat(this.#t.config().locale,{timeStyle:"short"}).format(new Date(e))}#St(){let e=this.#k,t=this.#n;if(t?.kind!=="thread")return null;if(!(t.id!==null||this.#c.length>0))return null;let n=e?.email_confirmation,s=n?.state==="sent"&&(!n.expires_at||Date.parse(n.expires_at)>Date.now());if(n?.state==="undeliverable"&&!this.#R)return"bad";if(s&&!this.#R)return"sent";if(n?.state==="confirmed"&&!this.#R)return"confirmed";let a=!!e?.email;if(this.#R||n?.state==="sent"&&!a)return"ask";if(this.#fe&&(a||e?.typed_email))return"saved";if(this.#s?.chat.ask_email_offline&&this.#dt()&&!a)return"ask";return null}#Me(){let e=this.#St();if(this.#b.hidden=!e,this.#N)clearTimeout(this.#N);if(this.#N=null,!e){this.#j="";return}let t=this.#k?.email_confirmation,i=t?.email??this.#k?.typed_email??this.#k?.email??"";if(e==="sent"&&t?.expires_at){let c=Math.min(Date.parse(t.expires_at)-Date.now()+100,ft);this.#N=setTimeout(()=>this.#r(),Math.max(c,0))}let n=[e,i,this.#I,this.#J,this.#G,this.#t.config().locale].join("|");if(n===this.#j)return;if(this.#j.split("|")[0]!==e)this.#S.value=e==="bad"||e==="ask"?i:"";this.#j=n;let s=()=>this.#J?[r("span","soft",this.#J)]:[],a=()=>this.#I?[r("p","error",this.#I)]:[],o=()=>{let c=r("form","inline-form");c.noValidate=!0,c.addEventListener("submit",(p)=>{p.preventDefault(),this.#Ve()});let d=r("button","btn",this.#e({id:"tfDRzk"}));return d.type="submit",d.disabled=this.#G,c.append(this.#S,d),c},l=(c)=>r("b","",c);if(e==="sent"){this.#b.className="mail",this.#b.innerHTML=f.mail;let c=r("div","text"),d=r("span","soft"),p="\x01",u=((m)=>this.#e({id:"gmPmD9",values:{address:m}}))(p),[x="",C=""]=u.split(p);d.append(x,l(i),C);let h=r("div","acts");h.append(z(this.#e({id:"c4RuNX"}),"link brand",()=>{this.#R=!0,this.#I="",this.#J="",this.#r(),this.#S.focus()}),z(this.#e({id:"J_jxKQ"}),"link soft",()=>void this.#Ve(i))),c.append(r("b","",this.#e({id:"5IXWmO"})),d,h,...s(),...a()),this.#b.append(c)}else if(e==="bad"){this.#b.className="mail bad";let c=r("div","head");c.insertAdjacentHTML("beforeend",f.alert),c.append(this.#e({id:"io8YUT",values:{address:i}})),this.#b.replaceChildren(c,r("span","soft",this.#e({id:"7b0Aa9"})),o(),...a())}else if(e==="confirmed")this.#b.className="mail ok",this.#b.innerHTML=f.check,this.#b.append(this.#e({id:"gxoeD3",values:{address:i}}));else if(e==="saved"){this.#b.className="mail ok",this.#b.innerHTML=f.check;let c=i;this.#b.append(this.#e({id:"iGNUZJ",values:{known:c}}))}else{this.#b.className="card";let c=this.#R?[z(this.#e({id:"dEgA5A"}),"link soft",()=>{this.#R=!1,this.#I="",this.#r()})]:[];this.#b.replaceChildren(r("p","",this.#e({id:"M62PBt"})),o(),...a(),...c)}}#ue(){let{locale:e}=this.#t.config();this.#xe.hidden=this.#l.length===0,this.#xe.replaceChildren(...this.#l.map((t,i)=>{let n=r("span","chip");n.insertAdjacentHTML("beforeend",f.file);let s=r("span","two");return s.append(r("b","",t.name||"image"),r("span","",B(e,t.size))),n.append(s,H(f.closeSmall,this.#e({id:"w61W3L",values:{0:t.name}}),()=>{this.#l=this.#l.filter((a,o)=>o!==i),this.#ue(),this.#ie()},"icon sm")),n}))}}function gt(e){return new Ne(e)}export{gt as mount};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "useyuva",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "description": "Yuva for the web: a headless client for contacts, the <yuva-chat> element, documentation page feedback and discussions, the <yuva-subscribe> mailing list form, the <yuva-status> footer band, cookieless web analytics, React hooks, a Nuxt module, a typed /v1 client and server helpers for identity tokens, webhooks and server-side analytics.",
5
5
  "license": "MIT",
6
6
  "repository": {