useyuva 0.0.0-stage → 0.0.4

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.
@@ -0,0 +1,48 @@
1
+ import type { IdentityTokenSource } from "./client/client.js";
2
+ import type { components } from "./schema.gen.js";
3
+ export type { IdentityTokenSource };
4
+ export type Layout = "launcher" | "embedded";
5
+ export interface LauncherStyle {
6
+ position: "right" | "left";
7
+ color?: string;
8
+ }
9
+ export declare function launcherOf(inbox: components["schemas"]["ClientInbox"]): LauncherStyle;
10
+ export interface ChatConfig {
11
+ channel: string | null;
12
+ server: string;
13
+ layout: Layout;
14
+ locale: string;
15
+ }
16
+ export interface PanelHost {
17
+ panel: HTMLElement;
18
+ config(): ChatConfig;
19
+ identityToken(): Promise<string | null>;
20
+ isOpen(): boolean;
21
+ close(): void;
22
+ setUnread(count: number): void;
23
+ setLauncher(style: LauncherStyle): void;
24
+ refused(): void;
25
+ }
26
+ export interface PanelController {
27
+ update(): void;
28
+ opened(): void;
29
+ closed(): void;
30
+ identityChanged(): void;
31
+ signOut(): Promise<void>;
32
+ destroy(): void;
33
+ }
34
+ export interface PanelModule {
35
+ mount(host: PanelHost): PanelController;
36
+ }
37
+ export interface StoredState {
38
+ visitor_id?: string;
39
+ session?: {
40
+ token: string;
41
+ expires_at: string;
42
+ sub: string | null;
43
+ };
44
+ launcher?: LauncherStyle;
45
+ }
46
+ export declare function storageKey(channel: string): string;
47
+ export declare function readStored(channel: string): StoredState;
48
+ export declare function writeStored(channel: string, state: StoredState): void;
@@ -0,0 +1 @@
1
+ export { mount } from "./panel/chat.js";
@@ -0,0 +1,201 @@
1
+ var b=(e)=>typeof e==="string",he=(e)=>typeof e==="function",K=new Map,J="en";function L(e){return[...Array.isArray(e)?e:[e],J]}function R(e,t,i){let n=L(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(()=>T("date",n,i),()=>new Intl.DateTimeFormat(n,s)).format(b(t)?new Date(t):t)}function ue(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 R(e,t,n)}function M(e,t,i){let n=L(e);return z(()=>T("number",n,i),()=>new Intl.NumberFormat(n,i)).format(t)}function F(e,t,i,{offset:n=0,...s}){let o=L(e),a=t?z(()=>T("plural-ordinal",o),()=>new Intl.PluralRules(o,{type:"ordinal"})):z(()=>T("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=K.get(i);if(!n)n=t(),K.set(i,n);return n}function T(e,t,i){let n=t.join("-");return`${e}-${n}-${JSON.stringify(i)}`}var W=/\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/,G=(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)}}),H="%__lingui_octothorpe__%",pe=(e,t,i={})=>{let n=t||e,s=(a)=>{if(typeof a==="object")return a;return i[a]},o=(a,l)=>{let d=Object.keys(i).length?s("number"):void 0,h=M(n,a,d);return l.replace(new RegExp(H,"g"),h)};return{plural:(a,l)=>{let{offset:d=0}=l,h=F(n,!1,a,l);return o(a-d,h)},selectordinal:(a,l)=>{let{offset:d=0}=l,h=F(n,!0,a,l);return o(a-d,h)},select:fe,number:(a,l)=>M(n,a,s(l)||{style:l}),date:(a,l)=>R(n,a,s(l)||l),time:(a,l)=>ue(n,a,s(l)||l)}},fe=(e,t)=>(Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0)??t.other;function me(e,t,i){return(n={},s)=>{let o=pe(t,i,s),a=(d,h=!1)=>{if(!Array.isArray(d))return d;return d.reduce((c,u)=>{if(u==="#"&&h)return c+H;if(b(u))return c+u;let[v,f,p]=u,g={};if(f==="plural"||f==="selectordinal"||f==="select")Object.entries(p).forEach(([w,k])=>{g[w]=a(k,f==="plural"||f==="selectordinal")});else g=p;let x;if(f){let w=o[f];x=w(n[v],g)}else x=n[v];if(x==null)return c;return c+x},"")},l=a(e);if(b(l)&&W.test(l))return G(l);if(b(l))return l;return l?String(l):""}}class q{_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 X extends q{_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??J,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(!b(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 he(l)?l(this._locale,e):l;if(a)this.emit("missing",{id:e,locale:this._locale});let d=o||n||e;if(b(d))if(this._messageCompiler)d=this._messageCompiler(d);else console.warn(`Uncompiled message detected! Message:
2
+
3
+ > ${d}
4
+
5
+ That means you use raw catalog or your catalog doesn't have a translation for the message and fallback was used.
6
+ ICU features such as interpolation and plurals will not work properly for that message.
7
+
8
+ Please compile your catalog first.
9
+ `);if(b(d)&&W.test(d))return G(d);if(b(d))return d;return me(d,this._locale,this._locales)(t,i?.formats)}t=this._.bind(this);date(e,t){return R(this._locales||this._locale,e,t)}number(e,t){return M(this._locales||this._locale,e,t)}}function O(e={}){return new X(e)}var Te=O();var A=JSON.parse(`{"-HY5kX":["New conversation"],"09Tv5j":["Reconnecting…"],"0XGLbP":["Your sign-in has expired. Reload the page and try again."],"1EICzz":["We're away right now"],"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"],"Pwqkdw":["Loading…"],"PxYAul":["Typing…"],"RzWUUK":["Write a message…"],"S63MQu":["All conversations"],"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."],"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."],"upFvcp":["Not sent."],"w61W3L":["Remove ",["0"]],"xDAtGP":["Message"],"ydzYKJ":["You:"],"yz7wBu":["Close"],"zLzEI3":["Sign in to chat with us."]}`);var V=JSON.parse('{"-HY5kX":["Yeni konuşma"],"09Tv5j":["Yeniden bağlanıyor…"],"0XGLbP":["Oturumunuzun süresi doldu. Sayfayı yenileyip tekrar deneyin."],"1EICzz":["Şu anda uzaktayız"],"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"],"Pwqkdw":["Yükleniyor…"],"PxYAul":["Yazıyor…"],"RzWUUK":["Bir mesaj yazın…"],"S63MQu":["Tüm konuşmalar"],"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."],"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."],"upFvcp":["Gönderilemedi."],"w61W3L":[["0"]," kaldır"],"xDAtGP":["Mesaj"],"ydzYKJ":["Siz:"],"yz7wBu":["Kapat"],"zLzEI3":["Bizimle sohbet etmek için giriş yapın."]}');function Q(e){return{position:e.chat.launcher_position,color:e.chat.launcher_color??e.branding.color}}function Z(e){return`yuva:${e}`}function D(e){try{let t=localStorage.getItem(Z(e));return t?JSON.parse(t):{}}catch{return{}}}function ee(e,t){try{localStorage.setItem(Z(e),JSON.stringify(t))}catch{}}class m extends Error{status;code;constructor(e,t){super(`${e} ${t}`);this.status=e;this.code=t}}async function te(e,t,i,{method:n="GET",json:s,body:o,headers:a={},token:l,blob:d}={}){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 c;try{c=await e(t+i,{method:n,headers:a,body:h,credentials:"omit"})}catch{throw new m(0,"network")}if(!c.ok){let u="error";try{u=(await c.json()).code??u}catch{}throw new m(c.status,u)}if(c.status===204)return;return d?await c.blob():await c.json()}class U{server;socketClass;handlers;#n=null;#u=0;#s=0;#r=null;#f=!0;constructor(e,t,i){this.server=e;this.socketClass=t;this.handlers=i}get connected(){return this.#n?.readyState===1}start(){if(this.#f=!1,!this.#n)this.#o()}stop(){if(this.#f=!0,this.#r)clearTimeout(this.#r);this.#r=null;let e=this.#n;this.#n=null,e?.close(1000)}reset(){this.#u=0}nudge(){if(this.#f||this.#n)return;if(this.#r)clearTimeout(this.#r);this.#r=null,this.#o()}#o(){let e=this.handlers.token();if(!e||this.#f)return;let t=new URL(`${this.server}/client/v1/realtime`,globalThis.location?.href);if(t.protocol=t.protocol==="https:"?"wss:":"ws:",this.#u>0)t.searchParams.set("last_event_id",String(this.#u));let i;try{i=new this.socketClass(t,["yuva",`yuva.token.${e}`])}catch{this.#p();return}this.#n=i,i.onmessage=(n)=>{let s;try{s=JSON.parse(String(n.data))}catch{return}if(s.type==="ready")this.#s=0,this.#u=Math.max(this.#u,s.last_event_id);else if("id"in s&&typeof s.id==="number")this.#u=Math.max(this.#u,s.id);this.handlers.event(s)},i.onclose=(n)=>{if(this.#n!==i)return;if(this.#n=null,this.#f)return;if(n.code===1008){this.#u=0,this.handlers.sessionEnded();return}this.#p()}}#p(){if(this.#f||this.#r)return;let e=this.#s++;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.#o()},t)}}function ie(e){return`yuva:${e}`}function j(){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 ge(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 ye(){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 ne(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 ve(e){return e.replace(/"/g,"%22").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function be(e,t,i){let n=[];for(let[s,o]of e)n.push(`--${i}\r
10
+ Content-Disposition: form-data; name="${s}"\r
11
+ \r
12
+ ${o}\r
13
+ `);for(let s of t){let o=s.name||"file";n.push(`--${i}\r
14
+ Content-Disposition: form-data; name="files"; filename="${ve(o)}"\r
15
+ Content-Type: ${s.type||"application/octet-stream"}\r
16
+ \r
17
+ `,s,`\r
18
+ `)}return n.push(`--${i}--\r
19
+ `),new Blob(n)}class se{server;channel;#n;#u;#s;#r;#f;#o=null;#p=null;#y=null;#b=null;#i=null;#S=new Map;constructor(e){this.server=e.server.replace(/\/+$/,""),this.channel=e.channel,this.#n=e.fetch??((t,i)=>fetch(t,i)),this.#u=e.WebSocket??globalThis.WebSocket,this.#s=e.storage??ye(),this.#r=e.identityToken??null,this.#f=e.idempotencyKeys??typeof globalThis.document>"u"}get session(){return this.#p}get token(){return this.#o}get connected(){return this.#i?.connected??!1}on(e,t){let i=this.#S.get(e);if(!i)this.#S.set(e,i=new Set);return i.add(t),()=>void i.delete(t)}#l(e,t){for(let i of this.#S.get(e)??[])i(t)}stored(){try{let e=this.#s.getItem(ie(this.channel));return e?JSON.parse(e):{}}catch{return{}}}#m(e){try{this.#s.setItem(ie(this.channel),JSON.stringify(e))}catch{}}channelSettings(){return this.#t(`/client/v1/channels/${encodeURIComponent(this.channel)}`)}setIdentityToken(e){this.#r=e,this.reset()}start(){if(this.#p)return Promise.resolve(this.#p);return this.#y??=this.#z(!1).then((e)=>(this.#l("session",{session:e,renewed:!1}),e)).finally(()=>{this.#y=null}),this.#y}async refresh(){let e=await this.#h("/client/v1/session");return this.#p={...this.#p,...e},this.#l("session",{session:this.#p,renewed:!1}),this.#p}reset(){this.#i?.stop(),this.#i?.reset(),this.#y=null,this.#b=null,this.#o=null,this.#p=null}async signOut(){let e=this.#o;this.reset();let t=this.stored();if(delete t.session,this.#m(t),e)await this.#t("/client/v1/session",{method:"DELETE",token:e}).catch(()=>{return})}async connect(){if(!this.#u)throw Error("Yuva: no WebSocket in this runtime; pass options.WebSocket");if(await this.start(),this.#i??=new U(this.server,this.#u,{token:()=>this.#o,event:(e)=>{if(e.type==="ready")this.#l("connection",{state:"open",attempt:0});this.#l("event",e)},sessionEnded:()=>void this.#g().catch(()=>this.#i?.nudge()),reconnecting:(e)=>{if(this.#l("connection",{state:"reconnecting",attempt:e}),e===2)this.#h("/client/v1/session").catch(()=>{return})}}),!this.#i.connected)this.#l("connection",{state:"connecting",attempt:0});this.#i.start()}disconnect(){this.#i?.stop(),this.#l("connection",{state:"closed",attempt:0})}reconnect(){this.#i?.nudge()}listConversations(e={}){return this.#h(`/client/v1/conversations${ne({...e})}`)}getConversation(e){return this.#h(`/client/v1/conversations/${encodeURIComponent(e)}`)}startConversation(e){return this.#h("/client/v1/conversations",this.#v(e))}listMessages(e,t={}){return this.#h(`/client/v1/conversations/${encodeURIComponent(e)}/messages${ne({...t})}`)}sendMessage(e,t){return this.#h(`/client/v1/conversations/${encodeURIComponent(e)}/messages`,this.#v(t))}markRead(e,t){return this.#h(`/client/v1/conversations/${encodeURIComponent(e)}/read`,{method:"POST",json:t?{message_id:t}:{}})}setTyping(e,t){return this.#h(`/client/v1/conversations/${encodeURIComponent(e)}/typing`,{method:"POST",json:{typing:t}})}setEmail(e){return this.#h("/client/v1/contact/email",{method:"PUT",json:{email:e}})}attachment(e){return this.#h(`/client/v1/attachments/${encodeURIComponent(e)}`,{blob:!0})}#v({body:e,subject:t,files:i=[],client_id:n=j()}){let s=this.#f&&/^[\x20-\x7e]{1,255}$/.test(n)?{"Idempotency-Key":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:be(o,i,a)}}#t(e,t){return te(this.#n,this.server,e,t)}async#h(e,t={},i=!0){if(!this.#o)await this.start();try{return await this.#t(e,{...t,token:this.#o})}catch(n){if(!i||!(n instanceof m)||n.status!==401)throw n;return await this.#g(),this.#h(e,t,!1)}}#g(){return this.#b??=(async()=>{let e=await this.#z(!0);if(this.#i)this.#i.stop(),this.#i.reset(),this.#i.start();this.#l("session",{session:e,renewed:!0})})().finally(()=>{this.#b=null}),this.#b}async#z(e){let t=this.stored(),i=await this.#r?.()||null,n=i?ge(i):null,s=t.session;if(!e&&s&&s.sub===n&&Date.parse(s.expires_at)>Date.now()+60000)try{let d=await this.#t("/client/v1/session",{token:s.token});return this.#x(d,s.token,n)}catch(d){if(!(d instanceof m)||d.status!==401&&d.status!==403)throw d}let o=await this.#t("/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.#x(l,a,n)}#x(e,t,i){this.#o=t,this.#p=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.#m(n),e}}function re(e){return new se(e)}var oe=`
20
+ [hidden] { display: none !important; }
21
+ .header {
22
+ display: flex;
23
+ align-items: center;
24
+ gap: 10px;
25
+ padding-block: 12px;
26
+ padding-inline: 14px 10px;
27
+ background: var(--yuva-accent);
28
+ color: var(--yuva-on-accent);
29
+ }
30
+ .heading { flex: 1; min-inline-size: 0; }
31
+ .title {
32
+ margin: 0;
33
+ font-size: 16px;
34
+ font-weight: 600;
35
+ overflow: hidden;
36
+ text-overflow: ellipsis;
37
+ white-space: nowrap;
38
+ }
39
+ .status { display: flex; align-items: center; gap: 6px; font-size: 13px; opacity: 0.9; }
40
+ .dot { inline-size: 8px; block-size: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 2px rgb(255 255 255 / 0.6); }
41
+ .dot.away { background: #9ca3af; }
42
+ .avatars { display: flex; }
43
+ .avatars .avatar { margin-inline-start: -8px; box-shadow: 0 0 0 2px var(--yuva-accent); }
44
+ .avatars .avatar:first-child { margin-inline-start: 0; }
45
+ .avatar {
46
+ display: grid;
47
+ place-items: center;
48
+ flex: none;
49
+ inline-size: 28px;
50
+ block-size: 28px;
51
+ border-radius: 50%;
52
+ background: var(--yuva-soft);
53
+ color: var(--yuva-fg);
54
+ font-size: 11px;
55
+ font-weight: 700;
56
+ text-transform: uppercase;
57
+ }
58
+ .icon {
59
+ display: grid;
60
+ place-items: center;
61
+ flex: none;
62
+ inline-size: 32px;
63
+ block-size: 32px;
64
+ padding: 0;
65
+ border: 0;
66
+ border-radius: 8px;
67
+ background: transparent;
68
+ color: inherit;
69
+ cursor: pointer;
70
+ }
71
+ .icon:hover { background: rgb(127 127 127 / 0.18); }
72
+ .icon:focus-visible { outline: 2px solid currentColor; outline-offset: -4px; }
73
+ [dir="rtl"] .flip { transform: scaleX(-1); }
74
+ .body { position: relative; flex: 1; min-block-size: 0; display: flex; flex-direction: column; }
75
+ .scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
76
+ .center { flex: 1; display: grid; place-content: center; gap: 6px; padding: 24px; text-align: center; }
77
+ .empty { margin: 0; font-weight: 600; }
78
+ .hint { margin: 0; color: var(--yuva-muted); font-size: 14px; }
79
+ .list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
80
+ .item {
81
+ display: flex;
82
+ gap: 10px;
83
+ align-items: center;
84
+ inline-size: 100%;
85
+ padding: 10px;
86
+ border: 0;
87
+ border-radius: 10px;
88
+ background: transparent;
89
+ color: inherit;
90
+ font: inherit;
91
+ text-align: start;
92
+ cursor: pointer;
93
+ }
94
+ .item:hover, .item:focus-visible { background: var(--yuva-soft); outline: none; }
95
+ .item-main { flex: 1; min-inline-size: 0; }
96
+ .item-top { display: flex; gap: 8px; justify-content: space-between; }
97
+ .item-subject, .item-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
98
+ .item-subject { font-weight: 600; }
99
+ .item-preview { color: var(--yuva-muted); font-size: 14px; }
100
+ .item.unread .item-preview { color: var(--yuva-fg); font-weight: 600; }
101
+ .item-time { flex: none; color: var(--yuva-muted); font-size: 12px; }
102
+ .unread-dot { flex: none; inline-size: 9px; block-size: 9px; border-radius: 50%; background: var(--yuva-accent); }
103
+ .primary {
104
+ margin: 10px;
105
+ padding: 10px 14px;
106
+ border: 0;
107
+ border-radius: 10px;
108
+ background: var(--yuva-accent);
109
+ color: var(--yuva-on-accent);
110
+ font: inherit;
111
+ font-weight: 600;
112
+ cursor: pointer;
113
+ }
114
+ .row { display: flex; gap: 8px; align-items: flex-end; max-inline-size: 85%; }
115
+ .row.mine { align-self: flex-end; }
116
+ .row.theirs .avatar { margin-block-end: 2px; }
117
+ .avatar img { inline-size: 100%; block-size: 100%; border-radius: 50%; object-fit: cover; }
118
+ .group-gap { margin-block-start: 8px; }
119
+ .author { margin: 6px 0 2px; margin-inline-start: 36px; color: var(--yuva-muted); font-size: 12px; }
120
+ .bubble {
121
+ padding: 8px 12px;
122
+ border-radius: 16px;
123
+ background: var(--yuva-soft);
124
+ overflow-wrap: anywhere;
125
+ white-space: normal;
126
+ }
127
+ .mine .bubble { background: var(--yuva-accent); color: var(--yuva-on-accent); border-end-end-radius: 4px; }
128
+ .theirs .bubble { border-end-start-radius: 4px; }
129
+ .bubble a { color: inherit; text-decoration: underline; }
130
+ .bubble code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; padding: 1px 4px; border-radius: 4px; background: rgb(127 127 127 / 0.2); }
131
+ .bubble pre { margin: 4px 0; padding: 8px; border-radius: 8px; background: rgb(127 127 127 / 0.2); font-family: ui-monospace, Menlo, monospace; font-size: 13px; white-space: pre-wrap; }
132
+ .greeting { align-self: flex-start; max-inline-size: 85%; }
133
+ .files { display: flex; flex-direction: column; gap: 4px; margin-block-start: 4px; }
134
+ .files img { display: block; max-inline-size: 100%; max-block-size: 220px; border-radius: 10px; cursor: zoom-in; }
135
+ .file {
136
+ display: inline-flex;
137
+ gap: 6px;
138
+ align-items: center;
139
+ padding: 6px 10px;
140
+ border: 1px solid currentColor;
141
+ border-radius: 8px;
142
+ background: transparent;
143
+ color: inherit;
144
+ font: inherit;
145
+ font-size: 13px;
146
+ cursor: pointer;
147
+ }
148
+ .meta { align-self: flex-end; color: var(--yuva-muted); font-size: 12px; margin-block-start: 2px; }
149
+ .meta.failed { color: var(--yuva-danger); }
150
+ .link { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }
151
+ .typing { display: flex; gap: 6px; align-items: center; color: var(--yuva-muted); font-size: 13px; margin-block-start: 6px; }
152
+ .typing i { display: inline-block; inline-size: 6px; block-size: 6px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite both; }
153
+ .typing i:nth-child(2) { animation-delay: 0.2s; }
154
+ .typing i:nth-child(3) { animation-delay: 0.4s; }
155
+ @keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
156
+ @media (prefers-reduced-motion: reduce) { .typing i { animation: none; } }
157
+ .card { margin-block-start: 10px; padding: 12px; border: 1px solid var(--yuva-border); border-radius: 12px; font-size: 14px; }
158
+ .card p { margin: 0 0 8px; }
159
+ .card form { display: flex; gap: 6px; }
160
+ .card input {
161
+ flex: 1;
162
+ min-inline-size: 0;
163
+ padding: 8px 10px;
164
+ border: 1px solid var(--yuva-border);
165
+ border-radius: 8px;
166
+ background: var(--yuva-bg);
167
+ color: inherit;
168
+ font: inherit;
169
+ }
170
+ .card button { padding: 8px 12px; border: 0; border-radius: 8px; background: var(--yuva-accent); color: var(--yuva-on-accent); font: inherit; font-weight: 600; cursor: pointer; }
171
+ .card .error { margin: 6px 0 0; color: var(--yuva-danger); }
172
+ .composer { border-block-start: 1px solid var(--yuva-border); padding: 8px; }
173
+ .composer form { display: flex; gap: 4px; align-items: flex-end; }
174
+ .composer textarea {
175
+ flex: 1;
176
+ min-inline-size: 0;
177
+ box-sizing: border-box;
178
+ block-size: 38px;
179
+ max-block-size: 140px;
180
+ padding: 8px 10px;
181
+ border: 0;
182
+ border-radius: 10px;
183
+ background: transparent;
184
+ color: inherit;
185
+ font: inherit;
186
+ resize: none;
187
+ outline: none;
188
+ }
189
+ .composer .icon { color: var(--yuva-muted); }
190
+ .composer .send { color: var(--yuva-accent); }
191
+ .composer .send:disabled { opacity: 0.4; cursor: default; }
192
+ .chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 6px 6px; }
193
+ .chip { display: inline-flex; gap: 4px; align-items: center; max-inline-size: 100%; padding: 2px 4px 2px 10px; border-radius: 999px; background: var(--yuva-soft); font-size: 13px; }
194
+ .chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-inline-size: 180px; }
195
+ .chip .icon { inline-size: 22px; block-size: 22px; }
196
+ .banner { padding: 6px 12px; background: var(--yuva-soft); color: var(--yuva-muted); font-size: 13px; text-align: center; }
197
+ @media (max-width: 480px) { .composer textarea, .card input { font-size: 16px; } }
198
+ .sr { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
199
+ `;var xe=/(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\s][^*\n]*\*|_[^_\s][^_\n]*_)|((?:https?:\/\/|www\.)[^\s<>"]*[^\s<>".,:;'!?)\]])/g;function we(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 N(e,t){let i=document.createElement(e);return i.append(...t),i}function Y(e){let t=[],i=0;for(let n of e.matchAll(xe)){let s=n.index??0;if(s>i)t.push(document.createTextNode(e.slice(i,s)));let[o,a,l,d,h]=n;if(a)t.push(N("code",[document.createTextNode(a.slice(1,-1))]));else if(l)t.push(N("strong",Y(l.slice(2,-2))));else if(d)t.push(N("em",Y(d.slice(1,-1))));else if(h){let c=h.startsWith("www.")?`https://${h}`:h;try{let u=new URL(c);t.push(u.protocol==="http:"||u.protocol==="https:"?we(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 E(e){let t=document.createDocumentFragment(),i=e.trim().replace(/\r\n?/g,`
200
+ `).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(`
201
+ `).forEach((a,l)=>{if(l>0)t.append(document.createElement("br"));t.append(...Y(a))})}),t}var ke={en:A,tr:V},Ce=10,ae=300000,C={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 S(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 y=(e)=>Date.parse(e),le=(e,t)=>y(e.created_at)-y(t.created_at),_e=(e,t)=>y(t.last_message_at??t.created_at)-y(e.last_message_at??e.created_at),P=(e)=>e.author.type==="contact"?"contact":`${e.author.type}:${e.author.name??""}`,Se=(e)=>/^image\/(png|jpeg|gif|webp)$/.test(e.content_type);class ce{#n;#u;#s;#r=null;#f=null;#o="loading";#p="";#y=null;#b=null;#i=new Map;#S;#l=new Map;#m=[];#v=new Map;#t=null;#h=!1;#g=[];#z=0;#x=null;#$=new Map;#K=new Map;#F=new Map;#J=!1;#w="";#W=!1;#G=r("header","header");#H=r("div","banner");#I=r("div","body");#d=r("div","scroll");#k=r("div","card");#C=r("input");#ie=r("div","composer");#q=r("div","chips");#c=r("textarea");#_=r("input");#M;#D;#X=r("div","sr");#U;#L=!0;constructor(e){this.#n=e;let{server:t,channel:i}=e.config();this.#s=re({server:t,channel:i??"",identityToken:()=>e.identityToken()}),this.#s.on("event",(s)=>this.#be(s)),this.#s.on("connection",({state:s,attempt:o})=>{if(s!=="reconnecting")return;this.#h=o>0,this.#ee()}),this.#s.on("session",({session:s,renewed:o})=>{if(this.#N(s.inbox),this.#f=s.contact,o)this.#ce()}),this.#se(),this.#X.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.#t?.kind==="thread"&&this.#t.id)this.#Y(this.#t.id,!0)}),this.#c.rows=1,this.#c.addEventListener("keydown",(s)=>{if(s.key==="Enter"&&!s.shiftKey&&!s.isComposing)s.preventDefault(),this.#Z()}),this.#c.addEventListener("input",()=>{this.#he(),this.#A(),this.#ke()}),this.#c.addEventListener("paste",(s)=>{let o=Array.from(s.clipboardData?.files??[]);if(o.length===0)return;s.preventDefault(),this.#de(o)}),this.#_.type="file",this.#_.multiple=!0,this.#_.hidden=!0,this.#_.addEventListener("change",()=>{this.#de(Array.from(this.#_.files??[])),this.#_.value=""}),this.#D=S(C.attach,"",()=>this.#_.click()),this.#M=S(C.send,"",()=>void this.#Z(),"icon send");let n=r("form");n.addEventListener("submit",(s)=>{s.preventDefault(),this.#Z()}),n.append(this.#D,this.#c,this.#M,this.#_),this.#ie.append(this.#q,n),this.#C.type="email",this.#C.required=!0,this.#C.autocomplete="email",document.addEventListener("visibilitychange",this.#j),window.addEventListener("online",this.#j),this.#ge(),this.#R()}update(){this.#se(),this.#ge()}opened(){if(this.#o==="error"){this.#y=null,this.#R();return}if(this.#o==="ready")this.#s.token?this.#ve():this.#re().then(()=>this.#a()).catch(()=>{return});if(this.#a(),this.#P(),this.#O(),this.#n.config().layout==="launcher")this.#c.focus({preventScroll:!0})}closed(){this.#E()}identityChanged(){this.#ne(),this.#R()}async signOut(){let e=this.#s.signOut();if(this.#ne(),await e,this.#n.isOpen())this.#R();else this.#a()}destroy(){this.#s.reset(),this.#E(),document.removeEventListener("visibilitychange",this.#j),window.removeEventListener("online",this.#j);for(let e of this.#$.values())URL.revokeObjectURL(e)}#ne(){this.#s.reset(),this.#y=null,this.#b=null,this.#r=null,this.#f=null,this.#o="loading",this.#i.clear(),this.#l.clear(),this.#m=[],this.#t=null,this.#W=!1,this.#n.setUnread(0)}#j=()=>{if(document.visibilityState!=="visible")return;this.#s.reconnect(),this.#O(),this.#ae()};#se(){let{locale:e}=this.#n.config();this.#u=O({locale:e,messages:{[e]:ke[e]??A}})}#e(e){return this.#u._(e)}#R(){return this.#y??=(async()=>{this.#o="loading",this.#a();let{channel:e}=this.#n.config();if(!e)throw new m(0,"not_configured");if(await this.#n.identityToken()||D(e).session)await this.#ye();else if(await this.#re(),!this.#r?.chat.allow_anonymous)throw new m(403,"anonymous_not_allowed");if(this.#o="ready",!this.#t){let t=this.#me();if(this.#t=t.length>1?{kind:"list"}:{kind:"thread",id:t[0]?.id??null},this.#t.kind==="thread"&&this.#t.id)await this.#Y(this.#t.id)}this.#a(),this.#P(),this.#O()})().catch((e)=>{if(this.#y=null,this.#le(e))return;this.#o="error",this.#p=e instanceof m?e.code:"error",this.#a()}),this.#y}async#re(){let e=await this.#oe();if(!this.#s.token)this.#N(e)}#oe(){if(!this.#n.config().channel)throw new m(0,"not_configured");return this.#s.channelSettings()}#N(e){let{channel:t}=this.#n.config();this.#r=e;let i=Q(e);if(this.#n.setLauncher(i),t)ee(t,{...D(t),launcher:i})}async#ae(){if(this.#o!=="ready")return;try{this.#N(await this.#oe()),this.#a()}catch(e){this.#le(e,!0)}}#le(e,t=!this.#s.token){let i=e instanceof m&&(e.code==="origin_not_allowed"||e.status===404&&t);if(i)this.#n.refused();return i}#ye(){return this.#b??=(async()=>{await this.#s.start(),await this.#V(),await this.#s.connect()})().finally(()=>{this.#b=null}),this.#b}async#ve(){try{await this.#s.refresh(),this.#a()}catch{}}async#V(e=!1){let t=await this.#s.listConversations({limit:50,cursor:e?this.#S:void 0});if(!e)this.#i.clear();for(let i of t.items)this.#i.set(i.id,i);this.#S=t.next_cursor,this.#T()}async#ce(){await this.#V();let e=this.#t?.kind==="thread"?this.#t.id:null;for(let t of[...this.#l.keys()])if(t!==e)this.#l.delete(t);if(e)this.#l.delete(e),await this.#Y(e);this.#a()}async#Y(e,t=!1){let i=this.#l.get(e);if(!i)i={messages:[],complete:!1,loading:!1},this.#l.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.#s.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(le),i.cursor=s.next_cursor,i.complete=!s.next_cursor}finally{i.loading=!1}if(t)this.#a(),this.#d.scrollTop=this.#d.scrollHeight-n}#be(e){switch(e.type){case"ready":if(this.#h=!1,this.#ee(),this.#W)this.#ae();this.#W=!0;return;case"inbox.updated":this.#N(e.data);break;case"resync_required":this.#ce();return;case"presence":if(this.#r)this.#r={...this.#r,presence:e.data};break;case"conversation.created":if(!this.#i.has(e.data.id))this.#i.set(e.data.id,e.data);if(this.#t?.kind==="thread"&&this.#t.id===null&&this.#i.size>1)this.#t=this.#m.some((t)=>t.conversation===null)?this.#t:{kind:"list"};this.#T();break;case"conversation.updated":{let t=this.#i.get(e.data.id);if(t)this.#i.set(t.id,{...t,status:e.data.status});break}case"message.created":case"message.updated":this.#Q(e.data,e.type==="message.created");break;case"read":{let t=this.#i.get(e.data.conversation_id),i=t?.last_read_by_member_at;if(t&&(!i||y(e.data.read_at)>y(i)))this.#i.set(t.id,{...t,last_read_by_member_at:e.data.read_at});break}case"typing":{let t=e.data.conversation_id,i=this.#v.get(t);if(i)clearTimeout(i.timer);if(e.data.typing){let n=e.data.author.name??"";this.#v.set(t,{name:n,timer:setTimeout(()=>this.#v.delete(t)&&this.#a(),8000)})}else this.#v.delete(t);break}}this.#a()}#Q(e,t){let i=e.conversation_id,n=this.#l.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(le)}if(e.client_id)this.#m=this.#m.filter((o)=>o.client_id!==e.client_id);let s=this.#i.get(i);if(!s){this.#s.getConversation(i).then((o)=>{this.#i.set(o.id,o),this.#T(),this.#a()}).catch(()=>{return});return}if(t){let o=e.body.replace(/\s+/g," ").trim();if(this.#i.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.#v.get(i);if(a)clearTimeout(a.timer);this.#v.delete(i),this.#xe(e)}}this.#T(),this.#O()}#xe(e){this.#X.textContent=`${e.author.name||this.#r?.name||""}: ${e.body.slice(0,200)}`}#T(){let e=0;for(let t of this.#i.values())if(t.unread)e++;this.#n.setUnread(e)}#we(){if(!this.#n.isOpen()||document.visibilityState!=="visible")return null;return this.#t?.kind==="thread"?this.#t.id:null}#O(){let e=this.#we(),t=e?this.#i.get(e):void 0;if(!e||!t?.unread)return;this.#i.set(e,{...t,unread:!1}),this.#T(),this.#s.markRead(e).catch(()=>{let i=this.#i.get(e);if(i)this.#i.set(e,{...i,unread:!0});this.#T()})}#de(e){this.#g=[...this.#g,...e].slice(0,Ce),this.#B(),this.#A(),this.#c.focus()}#he(){if(this.#c.style.blockSize="",this.#c.value==="")return;this.#c.style.blockSize="auto",this.#c.style.blockSize=`${Math.max(38,Math.min(this.#c.scrollHeight,140))}px`}#A(){this.#M.disabled=this.#c.value.trim()===""&&this.#g.length===0}#ke(){let e=this.#t?.kind==="thread"?this.#t.id:null;if(!e||this.#c.value.trim()===""){this.#E();return}if(Date.now()-this.#z>3000)this.#z=Date.now(),this.#s.setTyping(e,!0).catch(()=>{return});if(this.#x)clearTimeout(this.#x);this.#x=setTimeout(()=>this.#E(),4000)}#E(){if(this.#x)clearTimeout(this.#x);if(this.#x=null,this.#z===0)return;this.#z=0;let e=this.#t?.kind==="thread"?this.#t.id:null;if(e)this.#s.setTyping(e,!1).catch(()=>{return})}async#Z(){if(this.#o!=="ready"||this.#t?.kind!=="thread")return;let e=this.#c.value.trim(),t=this.#g;if(!e&&t.length===0)return;if(this.#t.id===null&&this.#m.some((n)=>n.conversation===null))return;this.#E(),this.#c.value="",this.#g=[],this.#he(),this.#B(),this.#A();let i={client_id:j(),conversation:this.#t.id,body:e,files:t,state:"sending"};this.#m.push(i),this.#a(),this.#P(),await this.#ue(i)}async#ue(e){e.state="sending",this.#a();let t={body:e.body,files:e.files,client_id:e.client_id};try{if(e.conversation===null){let i=await this.#s.startConversation(t),n=i.conversation.id;if(!this.#i.has(n))this.#i.set(n,i.conversation);if(!this.#l.has(n))this.#l.set(n,{messages:[],complete:!0,loading:!1});if(this.#t?.kind==="thread"&&this.#t.id===null)this.#t={kind:"thread",id:n};this.#Q(i.message,!1)}else{let i=await this.#s.sendMessage(e.conversation,t);this.#Q(i,!0)}this.#m=this.#m.filter((i)=>i!==e)}catch(i){let n=i instanceof m?i.status:0;e.state=n===413||n===415?"refused":"failed",e.status=n}this.#a(),this.#P()}async#Ce(){let e=this.#C.value.trim();if(!e||!this.#C.checkValidity()){this.#w=this.#e({id:"E_qvzP"}),this.#te();return}try{this.#f=await this.#s.setEmail(e),this.#J=!0,this.#w=""}catch{this.#w=this.#e({id:"ZxJcgC"})}this.#te()}#pe(e){let t=this.#$.get(e.id);if(t)return Promise.resolve(t);let i=this.#K.get(e.id);if(!i)i=this.#s.attachment(e.id).then((n)=>{let s=URL.createObjectURL(n);return this.#$.set(e.id,s),s}),i.catch(()=>this.#K.delete(e.id)),this.#K.set(e.id,i);return i}async#fe(e){let t=await this.#pe(e),i=r("a");i.href=t,i.download=e.filename,i.rel="noopener",i.click()}#me(){return[...this.#i.values()].sort(_e)}#_e(){let e=this.#r;if(!e)return!1;return!e.open_now||e.mode==="async"||!e.presence?.available}#P(){this.#L=!0,this.#d.scrollTop=this.#d.scrollHeight,requestAnimationFrame(()=>{if(this.#L)this.#d.scrollTop=this.#d.scrollHeight})}#ge(){this.#c.placeholder=this.#e({id:"RzWUUK"}),this.#c.setAttribute("aria-label",this.#e({id:"xDAtGP"})),this.#D.setAttribute("aria-label",this.#e({id:"N7m8E-"})),this.#D.title=this.#e({id:"N7m8E-"}),this.#M.setAttribute("aria-label",this.#e({id:"JlFcis"})),this.#M.title=this.#e({id:"JlFcis"}),this.#C.placeholder=this.#e({id:"njBr8W"}),this.#C.setAttribute("aria-label",this.#e({id:"XJURKP"})),this.#A(),this.#B(),this.#a()}#a(){let e=this.#n.panel;if(e.childElementCount===0){let t=r("style");t.textContent=oe,e.append(t,this.#G,this.#H,this.#I,this.#X),this.#G.id="yuva-title",e.setAttribute("aria-labelledby","yuva-title")}if(this.#ze(),this.#ee(),this.#o!=="ready"){this.#U=void 0;let t=r("div","center");if(this.#o==="loading")t.append(r("p","hint",this.#e({id:"Pwqkdw"})));else{t.append(r("p","empty",this.#Se()));let i=r("button","primary",this.#e({id:"KDw4GX"}));i.type="button",i.addEventListener("click",()=>{this.#y=null,this.#R()}),t.append(i)}this.#I.replaceChildren(t);return}if(this.#t?.kind==="list")this.#Ee();else this.#Me()}#Se(){switch(this.#p){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"})}}#ze(){let{layout:e}=this.#n.config(),t=this.#r,i=[],n=this.#t;if(this.#o==="ready"&&n?.kind==="thread"&&(this.#i.size>1||n.id===null&&this.#i.size>0))i.push(S(C.back,this.#e({id:"S63MQu"}),()=>{this.#E(),this.#t={kind:"list"},this.#a()}));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 d of t.presence?.members.slice(0,3)??[]){let h=r("span","avatar",d.initials||"•");h.title=d.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.#Te(t.expected_reply_minutes)));s.append(o)}if(i.push(s),e==="launcher")i.push(S(C.close,this.#e({id:"yz7wBu"}),()=>this.#n.close()));this.#G.replaceChildren(...i)}#Te(e){if(!e)return this.#e({id:"nhTADq"});let{locale:t}=this.#n.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}})}#ee(){this.#H.hidden=!this.#h,this.#H.textContent=this.#e({id:"09Tv5j"})}#Ee(){this.#U=void 0;let{locale:e}=this.#n.config(),t=r("ul","list"),i=new Date().toDateString();for(let s of this.#me()){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 d=new Date(s.last_message_at??s.created_at);l.append(r("span","item-time",new Intl.DateTimeFormat(e,d.toDateString()===i?{timeStyle:"short"}:{month:"short",day:"numeric"}).format(d)));let h=s.last_message?`${s.last_message.author_type==="contact"?this.#e({id:"ydzYKJ"})+" ":""}${s.last_message.text||this.#e({id:"UY1vmE"})}`:"",c=r("div","item-preview",h.replace(/\*\*|`/g,""));if(c.dir="auto",a.append(l,c),o.append(a),s.unread)o.append(r("span","unread-dot"));o.addEventListener("click",()=>void this.#Pe(s.id));let u=r("li");u.append(o),t.append(u)}if(this.#S){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.#V(!0).then(()=>this.#a())),t.append(s)}let n=r("button","primary",this.#e({id:"-HY5kX"}));n.type="button",n.addEventListener("click",()=>{this.#t={kind:"thread",id:null},this.#a(),this.#c.focus()}),this.#I.replaceChildren(t,n)}async#Pe(e){if(this.#t={kind:"thread",id:e},this.#a(),!this.#l.get(e)?.complete&&!this.#l.get(e)?.messages.length)await this.#Y(e).catch(()=>{return});this.#a(),this.#P(),this.#O()}#Ie(e){let t=r("span","avatar",e.initials||""),i=e.avatar_url,n=i?this.#F.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.#F.set(i,!0),t.isConnected)t.replaceChildren(s)}),s.addEventListener("error",()=>this.#F.set(i,!1)),s.src=i,t}#Me(){let e=this.#t;if(e?.kind!=="thread")return;let t=e.id,i=this.#U===t,n=this.#L,s=t?this.#l.get(t):void 0,o=s?.messages??[],a=this.#m.filter((c)=>c.conversation===t),l=[],d=this.#r?.chat.greeting;if(!s||s.complete){if(d){let c=r("div","bubble greeting");c.append(E(d)),l.push(c)}else if(o.length===0&&a.length===0){let c=r("div","center");c.append(r("p","empty",this.#e({id:"meAa31"})),r("p","hint",this.#e({id:"SdV5Cn"}))),l.push(c)}}else if(s.loading)l.push(r("p","hint",this.#e({id:"Pwqkdw"})));o.forEach((c,u)=>{let v=o[u-1],f=o[u+1]??(a.length>0?null:void 0),p=c.author.type==="contact",g=!v||P(v)!==P(c)||y(c.created_at)-y(v.created_at)>ae,x=f===void 0||(f===null?!p:P(f)!==P(c)||y(f.created_at)-y(c.created_at)>ae);if(!p&&g&&c.author.name)l.push(r("div","author",c.author.name));let w=r("div",`row ${p?"mine":"theirs"}${g&&u>0?" group-gap":""}`);if(!p){let _=this.#Ie(c.author);if(!x)_.style.visibility="hidden";w.append(_)}let k=r("div","bubble");if(k.dir="auto",k.title=new Date(c.created_at).toLocaleString(this.#n.config().locale),c.body.trim())k.append(E(c.body));if(c.attachments.length>0)k.append(this.#Le(c.attachments));if(w.append(k),l.push(w),x){let _=this.#Re(c.created_at);if(p&&u===o.length-1&&a.length===0){let B=t?this.#i.get(t)?.last_read_by_member_at:void 0,de=B&&y(B)>=y(c.created_at);_+=` · ${de?this.#e({id:"6lGaum"}):this.#e({id:"h69WC6"})}`}let I=r("div","meta",_);if(!p)I.style.alignSelf="flex-start";if(!p)I.style.marginInlineStart="36px";l.push(I)}}),a.forEach((c,u)=>{let v=r("div",`row mine${u===0&&o.length>0&&o[o.length-1]?.author.type!=="contact"?" group-gap":""}`),f=r("div","bubble");if(f.dir="auto",c.body)f.append(E(c.body));if(c.files.length>0){let p=r("div","files");for(let g of c.files)p.append(r("span","file",g.name||"image"));f.append(p)}if(v.append(f),l.push(v),c.state==="failed"){let p=r("div","meta failed",`${this.#e({id:"upFvcp"})} `),g=r("button","link",this.#e({id:"6gRgw8"}));g.type="button",g.addEventListener("click",()=>void this.#ue(c)),p.append(g),l.push(p)}else if(c.state==="refused"){let p=c.status===413?this.#e({id:"eOu9Px"}):this.#e({id:"JkW3Ph"});l.push(r("div","meta failed",`${this.#e({id:"upFvcp"})} ${p}`))}else if(u===a.length-1)l.push(r("div","meta",this.#e({id:"Sad2tK"})))});let h=t?this.#v.get(t):void 0;if(h){let c=r("div","typing");c.append(r("i"),r("i"),r("i"));let u=h.name;c.append(r("span","",u?this.#e({id:"tHaDPf",values:{name:u}}):this.#e({id:"PxYAul"}))),l.push(c)}if(this.#d.replaceChildren(...l),this.#te(),this.#I.firstChild!==this.#d)this.#I.replaceChildren(this.#d,this.#k,this.#ie);if(this.#U=t,!i||n)this.#P()}#Le(e){let t=r("div","files");for(let i of e)if(Se(i)){let n=r("img");n.alt=i.filename;let s=this.#$.get(i.id);if(s)n.src=s;else this.#pe(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.#fe(i)),t.append(n)}else{let n=r("button","file");n.type="button",n.innerHTML=C.file,n.append(r("span","",i.filename)),n.addEventListener("click",()=>void this.#fe(i)),t.append(n)}return t}#Re(e){return new Intl.DateTimeFormat(this.#n.config().locale,{timeStyle:"short"}).format(new Date(e))}#te(){let e=this.#f,t=this.#r?.chat,n=(this.#t?.kind==="thread"?this.#t.id:null)!==null||this.#m.length>0,s=e?.email||e?.typed_email,o=!!t?.ask_email_offline&&this.#_e()&&n&&(!s||this.#J);if(this.#k.hidden=!o,!o)return;if(s&&this.#J){this.#k.replaceChildren(r("p","",this.#e({id:"iGNUZJ",values:{known:s}})));return}if(this.#k.querySelector("form")){let d=this.#k.querySelector(".error");if(d)d.textContent=this.#w;else if(this.#w)this.#k.append(r("p","error",this.#w));return}let a=r("form");a.noValidate=!0,a.addEventListener("submit",(d)=>{d.preventDefault(),this.#Ce()});let l=r("button","",this.#e({id:"tfDRzk"}));if(l.type="submit",a.append(this.#C,l),this.#k.replaceChildren(r("p","",this.#e({id:"M62PBt"})),a),this.#w)this.#k.append(r("p","error",this.#w))}#B(){this.#q.hidden=this.#g.length===0,this.#q.replaceChildren(...this.#g.map((e,t)=>{let i=r("span","chip");return i.append(r("span","",e.name||"image"),S(C.close,this.#e({id:"w61W3L",values:{0:e.name}}),()=>{this.#g=this.#g.filter((n,s)=>s!==t),this.#B(),this.#A()})),i}))}}function ze(e){return new ce(e)}export{ze as mount};
package/dist/yuva.js ADDED
@@ -0,0 +1,109 @@
1
+ (()=>{var o=JSON.parse('{"6I7cJR":["Open chat"],"OkHvGB":["Open chat, ",["count"]," unread"],"pqZJT2":["Close chat"]}');var d=JSON.parse('{"6I7cJR":["Sohbeti aç"],"OkHvGB":["Sohbeti aç, ",["count"]," okunmamış"],"pqZJT2":["Sohbeti kapat"]}');var l={en:o,tr:d},k=new Set(["ar","fa","he","ur"]),S="en";function p(...e){for(let t of e){if(!t)continue;let i=t.toLowerCase();if(l[i])return i;let n=i.split(/[-_]/)[0]??"";if(l[n])return n}return S}function f(e){return k.has(e.split(/[-_]/)[0]??"")?"rtl":"ltr"}function g(e){return l[e]??o}function r(e,t){let i=e[t.id]??o[t.id],n=t.values??{};if(typeof i==="string")return i;if(Array.isArray(i))return i.map((s)=>typeof s==="string"?s:Array.isArray(s)?String(n[s[0]]??""):"").join("");return t.message??t.id}function y(e){return{position:e.chat.launcher_position,color:e.chat.launcher_color??e.branding.color}}function b(e){return`yuva:${e}`}function c(e){try{let t=localStorage.getItem(b(e));return t?JSON.parse(t):{}}catch{return{}}}function v(e,t){try{localStorage.setItem(b(e),JSON.stringify(t))}catch{}}var w=`
2
+ :host {
3
+ --yuva-accent: #2563eb;
4
+ --yuva-on-accent: #ffffff;
5
+ --yuva-bg: #ffffff;
6
+ --yuva-fg: #111827;
7
+ --yuva-muted: #6b7280;
8
+ --yuva-border: #e5e7eb;
9
+ --yuva-soft: #f3f4f6;
10
+ --yuva-danger: #dc2626;
11
+ --yuva-shadow: 0 12px 40px rgb(15 23 42 / 0.18);
12
+ color-scheme: light;
13
+ position: fixed;
14
+ bottom: 20px;
15
+ right: 20px;
16
+ z-index: 2147483000;
17
+ font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
18
+ font-size: 15px;
19
+ line-height: 1.45;
20
+ color: var(--yuva-fg);
21
+ }
22
+ :host([position="left"]) { right: auto; left: 20px; }
23
+ @media (prefers-color-scheme: dark) {
24
+ :host {
25
+ --yuva-bg: #1c1f24;
26
+ --yuva-fg: #f3f4f6;
27
+ --yuva-muted: #9ca3af;
28
+ --yuva-border: #30343b;
29
+ --yuva-soft: #2a2e35;
30
+ --yuva-danger: #f87171;
31
+ --yuva-shadow: 0 12px 40px rgb(0 0 0 / 0.5);
32
+ color-scheme: dark;
33
+ }
34
+ }
35
+ :host([layout="embedded"]) {
36
+ position: relative;
37
+ inset: auto;
38
+ z-index: auto;
39
+ display: block;
40
+ block-size: 100%;
41
+ }
42
+ .launcher {
43
+ position: relative;
44
+ display: grid;
45
+ place-items: center;
46
+ inline-size: 56px;
47
+ block-size: 56px;
48
+ padding: 0;
49
+ border: 0;
50
+ border-radius: 50%;
51
+ background: var(--yuva-accent);
52
+ color: var(--yuva-on-accent);
53
+ box-shadow: var(--yuva-shadow);
54
+ cursor: pointer;
55
+ }
56
+ .launcher:focus-visible { outline: 3px solid var(--yuva-accent); outline-offset: 3px; }
57
+ .badge {
58
+ position: absolute;
59
+ top: -4px;
60
+ right: -4px;
61
+ min-inline-size: 20px;
62
+ block-size: 20px;
63
+ padding-inline: 5px;
64
+ box-sizing: border-box;
65
+ border-radius: 10px;
66
+ background: var(--yuva-danger);
67
+ color: #fff;
68
+ font-size: 12px;
69
+ font-weight: 700;
70
+ line-height: 20px;
71
+ text-align: center;
72
+ }
73
+ .badge[hidden] { display: none; }
74
+ .panel {
75
+ display: flex;
76
+ flex-direction: column;
77
+ overflow: hidden;
78
+ box-sizing: border-box;
79
+ background: var(--yuva-bg);
80
+ border: 1px solid var(--yuva-border);
81
+ border-radius: 16px;
82
+ }
83
+ .panel[hidden] { display: none; }
84
+ :host(:not([layout="embedded"])) .panel {
85
+ position: absolute;
86
+ bottom: 72px;
87
+ right: 0;
88
+ inline-size: min(380px, calc(100vw - 32px));
89
+ block-size: min(600px, calc(100vh - 112px));
90
+ box-shadow: var(--yuva-shadow);
91
+ }
92
+ :host([position="left"]:not([layout="embedded"])) .panel { right: auto; left: 0; }
93
+ @media (max-width: 480px) {
94
+ :host(:not([layout="embedded"])) .panel {
95
+ position: fixed;
96
+ inset: 0;
97
+ inline-size: auto;
98
+ block-size: auto;
99
+ border: 0;
100
+ border-radius: 0;
101
+ }
102
+ :host([open-panel]:not([layout="embedded"])) .launcher { display: none; }
103
+ }
104
+ :host([layout="embedded"]) .panel {
105
+ inline-size: 100%;
106
+ block-size: 100%;
107
+ min-block-size: 320px;
108
+ }
109
+ `,C='<svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><path d="M4 5h16v11H9l-5 4z"/></svg>',L='<svg width="24" height="24" 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>',h=document.currentScript instanceof HTMLScriptElement?document.currentScript.src:"";function A(e){let t=Number.parseInt(e.slice(1),16),[i,n,s]=[t>>16&255,t>>8&255,t&255].map((x)=>{let a=x/255;return a<=0.03928?a/12.92:((a+0.055)/1.055)**2.4});return 0.2126*i+0.7152*n+0.0722*s>0.4?"#111827":"#ffffff"}class u extends HTMLElement{static observedAttributes=["channel","server","layout","locale","dir","identity-token","open"];static loadPanel=()=>import(new URL("yuva-chat.js",h||location.href).href);#r;#s=null;#n=null;#i;#e=null;#a={};#t=!1;#u=0;#l=null;#o=!1;constructor(){super();this.#r=this.attachShadow({mode:"open"}),this.#i=document.createElement("section"),this.#i.className="panel",this.#i.setAttribute("role","dialog"),this.#i.hidden=!0,this.#i.addEventListener("keydown",(e)=>{if(e.key==="Escape"&&this.layout==="launcher")this.close()})}get layout(){return this.getAttribute("layout")==="embedded"?"embedded":"launcher"}get channel(){return this.getAttribute("channel")}get server(){return(this.getAttribute("server")||(h?new URL(h).origin:location.origin)).replace(/\/+$/,"")}get locale(){return p(this.getAttribute("locale"),navigator.language)}get isOpen(){return this.#t}get unread(){return this.#u}setIdentityToken(e){if(this.#l=e,this.#e)this.#e.then((t)=>t.identityChanged())}async signOut(){if(this.#l=null,this.removeAttribute("identity-token"),this.#e)await(await this.#e).signOut()}connectedCallback(){this.#c();let e=this.channel;if(this.layout==="embedded"||this.hasAttribute("open")||!e)return;let t=c(e);if(t.launcher)this.#d(t.launcher);let i=()=>{if(!this.isConnected||this.#e||this.channel!==e)return;if(t.session)this.#p();else this.#g(e)};if("requestIdleCallback"in window)requestIdleCallback(i,{timeout:3000});else setTimeout(i,1000)}#g(e){fetch(`${this.server}/client/v1/channels/${encodeURIComponent(e)}`,{credentials:"omit"}).then((t)=>{if(t.status===403||t.status===404)this.#f();return t.ok?t.json():null}).then((t)=>{if(!t||this.channel!==e||this.#e)return;let i=y(t);this.#d(i),v(e,{...c(e),launcher:i})}).catch(()=>{return})}disconnectedCallback(){let e=this.#e;if(this.#e=null,e)e.then((t)=>t.destroy())}attributeChangedCallback(e,t,i){if(!this.isConnected||t===i)return;if(e==="open"){i===null?this.close():this.open();return}if(e==="identity-token"){if(this.#e)this.#e.then((n)=>n.identityChanged());return}if(e==="channel"||e==="server"){this.disconnectedCallback(),this.#o=!1,this.#c();return}if(this.#c(),this.#e)this.#e.then((n)=>n.update())}async open(){if(this.#t||this.#o)return;this.#t=!0,this.toggleAttribute("open-panel",!0),this.#h();let e=await this.#p();if(!this.#t)return;this.#i.hidden=!1,e.opened()}close(){if(!this.#t||this.layout==="embedded")return;if(this.#t=!1,this.toggleAttribute("open-panel",!1),this.#i.hidden=!0,this.#h(),this.#s?.focus(),this.#e)this.#e.then((e)=>e.closed())}toggle(){return this.#t?this.close():this.open()}#y(){return{channel:this.channel,server:this.server,layout:this.layout,locale:this.locale}}#p(){return this.#e??=u.loadPanel().then(({mount:e})=>e({panel:this.#i,config:()=>this.#y(),identityToken:async()=>this.#l?await this.#l()??null:this.getAttribute("identity-token"),isOpen:()=>this.#t,close:()=>this.close(),setUnread:(t)=>{this.#u=t,this.#h(),this.dispatchEvent(new CustomEvent("yuva-unread",{detail:{count:t}}))},setLauncher:(t)=>this.#d(t),refused:()=>this.#f()})),this.#e}#f(){if(this.#o)return;this.#o=!0,console.warn(`Yuva: channel ${this.channel} is unknown or does not allow ${location.origin}`),this.#t=!1,this.toggleAttribute("open-panel",!1),this.disconnectedCallback(),this.#c()}#d(e){if(this.setAttribute("position",e.position==="left"?"left":"right"),e.color&&/^#[0-9a-f]{6}$/i.test(e.color))this.style.setProperty("--yuva-accent",e.color),this.style.setProperty("--yuva-on-accent",A(e.color))}#c(){let e=this.locale;this.#a=g(e),this.setAttribute("lang",e);let t=document.createElement("style");if(t.textContent=w,this.#i.dir=this.getAttribute("dir")??f(e),this.#i.setAttribute("aria-modal","false"),this.#o){this.#s=null,this.#n=null,this.#r.replaceChildren();return}if(this.layout==="embedded"){this.#s=null,this.#n=null,this.#r.replaceChildren(t,this.#i),this.#t=!1,this.open();return}let i=document.createElement("button");if(i.type="button",i.className="launcher",i.addEventListener("click",()=>void this.toggle()),this.#s=i,this.#n=document.createElement("span"),this.#n.className="badge",this.#n.setAttribute("aria-hidden","true"),this.#r.replaceChildren(t,this.#i,i),this.#h(),this.hasAttribute("open")&&!this.#t)this.open()}#h(){let e=this.#s,t=this.#n;if(!e||!t)return;let i=this.#u;e.setAttribute("aria-expanded",String(this.#t)),e.setAttribute("aria-label",this.#t?r(this.#a,{id:"pqZJT2"}):i>0?r(this.#a,{id:"OkHvGB",values:{count:i}}):r(this.#a,{id:"6I7cJR"})),e.innerHTML=this.#t?L:C,t.textContent=i>9?"9+":String(i),t.hidden=this.#t||i===0,e.append(t)}}function m(){if(!customElements.get("yuva-chat"))customElements.define("yuva-chat",u)}m();})();
package/package.json CHANGED
@@ -1,6 +1,86 @@
1
1
  {
2
2
  "name": "useyuva",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.4",
4
+ "description": "Yuva for the web: a headless client for contacts, the <yuva-chat> element, React hooks and a typed /v1 client.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/productdevbook/yuva.git",
9
+ "directory": "sdk/js"
10
+ },
11
+ "bugs": "https://github.com/productdevbook/yuva/issues",
12
+ "keywords": [
13
+ "yuva",
14
+ "chat",
15
+ "support",
16
+ "live-chat",
17
+ "web-component",
18
+ "customer-messaging"
19
+ ],
20
+ "type": "module",
21
+ "sideEffects": [
22
+ "./dist/esm/chat.js",
23
+ "./dist/yuva.js",
24
+ "./dist/yuva-chat.js"
25
+ ],
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/types/index.d.ts",
29
+ "default": "./dist/esm/index.js"
30
+ },
31
+ "./chat": {
32
+ "types": "./dist/types/chat.d.ts",
33
+ "default": "./dist/esm/chat.js"
34
+ },
35
+ "./react": {
36
+ "types": "./dist/types/react.d.ts",
37
+ "default": "./dist/esm/react.js"
38
+ },
39
+ "./api": {
40
+ "types": "./dist/types/api.d.ts",
41
+ "default": "./dist/esm/api.js"
42
+ },
43
+ "./package.json": "./package.json"
44
+ },
45
+ "types": "./dist/types/index.d.ts",
46
+ "files": [
47
+ "dist"
48
+ ],
49
+ "publishConfig": {
50
+ "access": "public"
51
+ },
52
+ "scripts": {
53
+ "generate": "bunx openapi-typescript@7.13.0 ../../openapi/openapi.yaml -o src/schema.gen.ts",
54
+ "extract": "lingui extract --clean --workers 1",
55
+ "compile": "lingui compile --strict --typescript",
56
+ "typecheck": "tsc --noEmit",
57
+ "check": "bun run compile && bun run typecheck && bun test",
58
+ "build": "bun run compile && bun scripts/build.ts",
59
+ "example": "bun scripts/serve.ts",
60
+ "prepublishOnly": "bun run check && bun run build"
61
+ },
62
+ "dependencies": {
63
+ "@lingui/core": "^6.9.0",
64
+ "openapi-fetch": "0.17.0"
65
+ },
66
+ "peerDependencies": {
67
+ "react": ">=18"
68
+ },
69
+ "peerDependenciesMeta": {
70
+ "react": {
71
+ "optional": true
72
+ }
73
+ },
74
+ "devDependencies": {
75
+ "@happy-dom/global-registrator": "^20.14.5",
76
+ "@lingui/cli": "^6.9.0",
77
+ "@lingui/conf": "^6.9.0",
78
+ "@lingui/format-po": "^6.9.0",
79
+ "@lingui/native-tools": "^0.1.5",
80
+ "@types/bun": "^1.4.2",
81
+ "@types/react": "19.2.2",
82
+ "happy-dom": "^20.14.5",
83
+ "react": "19.2.0",
84
+ "typescript": "^7.0.2"
85
+ }
86
+ }