@upstep/js 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class h extends Error{constructor(t,s){super(t),this.status=s}}function c(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{const t=Math.floor(Math.random()*16);return(a==="x"?t:t&3|8).toString(16)})}class u{constructor(t,s,e=fetch){this.storage=s,this.transport=e,this.token=null,this.session=null,this.epoch=0,this.baseUrl=(t.baseUrl||"https://upstep.dev").replace(/\/$/,""),this.key=t.apiKey,this.identityToken=t.supportIdentityToken,this.storageKey=`upstep:support:${this.baseUrl}:${this.key}`}async identify(t){var s;t!==this.identityToken&&(this.epoch++,this.identityToken=t,this.token=null,this.session=null,await((s=this.storage)==null?void 0:s.removeItem(this.storageKey).catch(()=>{})))}async request(t,s){var o;const e=new AbortController,r=setTimeout(()=>e.abort(),2e4);try{const i=await this.transport(`${this.baseUrl}/api/sdk/support${t}`,{method:s===void 0?"GET":"POST",headers:{"Content-Type":"application/json","x-api-key":this.key,...this.token?{Authorization:`Bearer ${this.token}`}:{}},...s===void 0?{}:{body:JSON.stringify(s)},credentials:"omit",redirect:"error",signal:e.signal}),n=await i.json();if(!i.ok)throw i.status===401&&t&&(this.token=null,await((o=this.storage)==null?void 0:o.removeItem(this.storageKey).catch(()=>{}))),new h(typeof n.error=="string"?n.error:"Could not connect to support.",i.status);return n}finally{clearTimeout(r)}}async configuration(){try{return await this.request("")}catch(t){if(t instanceof h&&[402,404].includes(t.status))return null;throw t}}async ensureSession(){if(!this.token){if(!this.session){const t=this.epoch,s=this.identityToken,e=(async()=>{var o,i;if(!s)try{const n=await((o=this.storage)==null?void 0:o.getItem(this.storageKey));if(n&&t===this.epoch){this.token=n;return}}catch{}if(t!==this.epoch)throw new Error("Customer identity changed.");const r=await this.request("",s?{identityToken:s}:{});if(t!==this.epoch)throw new Error("Customer identity changed.");this.token=r.token,s||await((i=this.storage)==null?void 0:i.setItem(this.storageKey,r.token).catch(()=>{}))})();this.session=e,e.finally(()=>{this.session===e&&(this.session=null)}).catch(()=>{})}await this.session}}async conversations(){return await this.ensureSession(),(await this.request("/conversations")).conversations}async startConversation(){return await this.ensureSession(),this.request("/conversations",{})}async conversation(t){return await this.ensureSession(),this.request(`/conversations/${encodeURIComponent(t)}`)}async send(t,s,e=c()){await this.ensureSession(),await this.request(`/conversations/${encodeURIComponent(t)}`,{action:"message",content:s,clientMessageId:e})}async details(t,s){await this.ensureSession(),await this.request(`/conversations/${encodeURIComponent(t)}`,{action:"details",...s,clientMessageId:s.clientMessageId||c()})}async handoff(t,s,e){await this.ensureSession(),await this.request(`/conversations/${encodeURIComponent(t)}`,{action:"handoff",name:s,email:e})}}exports.SupportApiError=h;exports.SupportClient=u;exports.supportMessageId=c;
@@ -0,0 +1,47 @@
1
+ import { SupportConfiguration, SupportConversation, UpstepConfig } from '@upstep/types';
2
+ export interface SupportStorage {
3
+ getItem(key: string): Promise<string | null>;
4
+ setItem(key: string, value: string): Promise<void>;
5
+ removeItem(key: string): Promise<void>;
6
+ }
7
+ export declare class SupportApiError extends Error {
8
+ readonly status: number;
9
+ constructor(message: string, status: number);
10
+ }
11
+ export declare function supportMessageId(): string;
12
+ /** Portable chat client. No DOM, WebView or browser globals are required. */
13
+ export declare class SupportClient {
14
+ private storage?;
15
+ private transport;
16
+ private token;
17
+ private session;
18
+ private identityToken;
19
+ private epoch;
20
+ private readonly baseUrl;
21
+ private readonly key;
22
+ private readonly storageKey;
23
+ constructor(config: Pick<UpstepConfig, "apiKey" | "baseUrl" | "supportIdentityToken">, storage?: SupportStorage | undefined, transport?: typeof fetch);
24
+ identify(token: string | undefined): Promise<void>;
25
+ private request;
26
+ configuration(): Promise<SupportConfiguration | null>;
27
+ private ensureSession;
28
+ conversations(): Promise<{
29
+ id: string;
30
+ state: string;
31
+ }[]>;
32
+ startConversation(): Promise<{
33
+ id: string;
34
+ state: string;
35
+ }>;
36
+ conversation(id: string): Promise<SupportConversation>;
37
+ send(id: string, content: string, clientMessageId?: string): Promise<void>;
38
+ details(id: string, values: {
39
+ widgetId: string;
40
+ summary: string;
41
+ details?: string;
42
+ reference?: string;
43
+ clientMessageId?: string;
44
+ }): Promise<void>;
45
+ handoff(id: string, name: string, email: string): Promise<void>;
46
+ }
47
+ //# sourceMappingURL=support.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"support.d.ts","sourceRoot":"","sources":["../src/support.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACb,MAAM,eAAe,CAAC;AACvB,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC;AACD,qBAAa,eAAgB,SAAQ,KAAK;IAGtC,QAAQ,CAAC,MAAM,EAAE,MAAM;gBADvB,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,MAAM;CAI1B;AACD,wBAAgB,gBAAgB,WAK/B;AACD,6EAA6E;AAC7E,qBAAa,aAAa;IAUtB,OAAO,CAAC,OAAO,CAAC;IAChB,OAAO,CAAC,SAAS;IAVnB,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,OAAO,CAA8B;IAC7C,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAElC,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,GAAG,SAAS,GAAG,sBAAsB,CAAC,EACjE,OAAO,CAAC,EAAE,cAAc,YAAA,EACxB,SAAS,GAAE,OAAO,KAAa;IAOnC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS;YAQ1B,OAAO;IAkCf,aAAa,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;YAS7C,aAAa;IAsCrB,aAAa;YAG2B,MAAM;eAAS,MAAM;;IAK7D,iBAAiB;YAEK,MAAM;eAAS,MAAM;;IAE3C,YAAY,CAAC,EAAE,EAAE,MAAM;IAMvB,IAAI,CACR,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,MAAM,EACf,eAAe,SAAqB;IAShC,OAAO,CACX,EAAE,EAAE,MAAM,EACV,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B;IASG,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAQtD"}
@@ -0,0 +1,127 @@
1
+ class h extends Error {
2
+ constructor(t, s) {
3
+ super(t), this.status = s;
4
+ }
5
+ }
6
+ function c() {
7
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (a) => {
8
+ const t = Math.floor(Math.random() * 16);
9
+ return (a === "x" ? t : t & 3 | 8).toString(16);
10
+ });
11
+ }
12
+ class u {
13
+ constructor(t, s, e = fetch) {
14
+ this.storage = s, this.transport = e, this.token = null, this.session = null, this.epoch = 0, this.baseUrl = (t.baseUrl || "https://upstep.dev").replace(/\/$/, ""), this.key = t.apiKey, this.identityToken = t.supportIdentityToken, this.storageKey = `upstep:support:${this.baseUrl}:${this.key}`;
15
+ }
16
+ async identify(t) {
17
+ var s;
18
+ t !== this.identityToken && (this.epoch++, this.identityToken = t, this.token = null, this.session = null, await ((s = this.storage) == null ? void 0 : s.removeItem(this.storageKey).catch(() => {
19
+ })));
20
+ }
21
+ async request(t, s) {
22
+ var o;
23
+ const e = new AbortController(), r = setTimeout(() => e.abort(), 2e4);
24
+ try {
25
+ const i = await this.transport(`${this.baseUrl}/api/sdk/support${t}`, {
26
+ method: s === void 0 ? "GET" : "POST",
27
+ headers: {
28
+ "Content-Type": "application/json",
29
+ "x-api-key": this.key,
30
+ ...this.token ? { Authorization: `Bearer ${this.token}` } : {}
31
+ },
32
+ ...s === void 0 ? {} : { body: JSON.stringify(s) },
33
+ credentials: "omit",
34
+ redirect: "error",
35
+ signal: e.signal
36
+ }), n = await i.json();
37
+ if (!i.ok)
38
+ throw i.status === 401 && t && (this.token = null, await ((o = this.storage) == null ? void 0 : o.removeItem(this.storageKey).catch(() => {
39
+ }))), new h(
40
+ typeof n.error == "string" ? n.error : "Could not connect to support.",
41
+ i.status
42
+ );
43
+ return n;
44
+ } finally {
45
+ clearTimeout(r);
46
+ }
47
+ }
48
+ async configuration() {
49
+ try {
50
+ return await this.request("");
51
+ } catch (t) {
52
+ if (t instanceof h && [402, 404].includes(t.status))
53
+ return null;
54
+ throw t;
55
+ }
56
+ }
57
+ async ensureSession() {
58
+ if (!this.token) {
59
+ if (!this.session) {
60
+ const t = this.epoch, s = this.identityToken, e = (async () => {
61
+ var o, i;
62
+ if (!s)
63
+ try {
64
+ const n = await ((o = this.storage) == null ? void 0 : o.getItem(this.storageKey));
65
+ if (n && t === this.epoch) {
66
+ this.token = n;
67
+ return;
68
+ }
69
+ } catch {
70
+ }
71
+ if (t !== this.epoch) throw new Error("Customer identity changed.");
72
+ const r = await this.request(
73
+ "",
74
+ s ? { identityToken: s } : {}
75
+ );
76
+ if (t !== this.epoch) throw new Error("Customer identity changed.");
77
+ this.token = r.token, s || await ((i = this.storage) == null ? void 0 : i.setItem(this.storageKey, r.token).catch(() => {
78
+ }));
79
+ })();
80
+ this.session = e, e.finally(() => {
81
+ this.session === e && (this.session = null);
82
+ }).catch(() => {
83
+ });
84
+ }
85
+ await this.session;
86
+ }
87
+ }
88
+ async conversations() {
89
+ return await this.ensureSession(), (await this.request(
90
+ "/conversations"
91
+ )).conversations;
92
+ }
93
+ async startConversation() {
94
+ return await this.ensureSession(), this.request("/conversations", {});
95
+ }
96
+ async conversation(t) {
97
+ return await this.ensureSession(), this.request(
98
+ `/conversations/${encodeURIComponent(t)}`
99
+ );
100
+ }
101
+ async send(t, s, e = c()) {
102
+ await this.ensureSession(), await this.request(`/conversations/${encodeURIComponent(t)}`, {
103
+ action: "message",
104
+ content: s,
105
+ clientMessageId: e
106
+ });
107
+ }
108
+ async details(t, s) {
109
+ await this.ensureSession(), await this.request(`/conversations/${encodeURIComponent(t)}`, {
110
+ action: "details",
111
+ ...s,
112
+ clientMessageId: s.clientMessageId || c()
113
+ });
114
+ }
115
+ async handoff(t, s, e) {
116
+ await this.ensureSession(), await this.request(`/conversations/${encodeURIComponent(t)}`, {
117
+ action: "handoff",
118
+ name: s,
119
+ email: e
120
+ });
121
+ }
122
+ }
123
+ export {
124
+ h as SupportApiError,
125
+ u as SupportClient,
126
+ c as supportMessageId
127
+ };
@@ -1,81 +1,81 @@
1
- (function(){"use strict";const b="upstep-anonymous-id";function $(){const s=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;if(typeof window>"u")return s;try{const t=window.localStorage.getItem(b);return t||(window.localStorage.setItem(b,s),s)}catch{return s}}class I{constructor(t){this.baseUrl=(t.baseUrl??"https://upstep.dev").replace(/\/$/,""),this.apiKey=t.apiKey,this.supportIdentityToken=t.supportIdentityToken,this.chat=t.chat!==!1,t.userId!==void 0&&(this.userId=t.userId),this.anonymousId=$()}setUserId(t){this.userId=t}headers(){return{"Content-Type":"application/json","x-api-key":this.apiKey}}async supportEnabled(){if(!this.chat)return!1;try{const t=await fetch(`${this.baseUrl}/api/sdk/support`,{headers:this.headers()});return t.ok&&(await t.json()).enabled===!0}catch{return!1}}supportFrameUrl(t){return`${this.baseUrl}/support/${encodeURIComponent(this.apiKey)}?theme=${encodeURIComponent(t)}`}connectSupportFrame(t){const e=new URL(this.baseUrl).origin,o=()=>{var n;return(n=t.contentWindow)==null?void 0:n.postMessage({type:"upstep:support:identity",token:this.supportIdentityToken},e)},i=n=>{var a;n.origin===e&&n.source===t.contentWindow&&((a=n.data)==null?void 0:a.type)==="upstep:support:ready"&&o()};return t.addEventListener("load",o),window.addEventListener("message",i),()=>{t.removeEventListener("load",o),window.removeEventListener("message",i)}}async listFeedback(t){const e=new URLSearchParams;t!=null&&t.cursor&&e.set("cursor",t.cursor),t!=null&&t.limit&&e.set("limit",String(t.limit)),t!=null&&t.type&&e.set("type",t.type),t!=null&&t.status&&e.set("status",t.status),t!=null&&t.sort&&e.set("sort",t.sort),this.userId&&e.set("endUserId",this.userId),this.anonymousId&&e.set("anonymousId",this.anonymousId);const o=await fetch(`${this.baseUrl}/api/sdk/feedback?${e}`,{headers:this.headers()});if(!o.ok)throw new Error(`Upstep: ${o.status}`);return o.json()}async submitFeedback(t){const e=await fetch(`${this.baseUrl}/api/sdk/feedback`,{method:"POST",headers:this.headers(),body:JSON.stringify({...t,endUserId:t.endUserId??this.userId,anonymousId:t.anonymousId??this.anonymousId})});if(!e.ok)throw new Error(`Upstep: ${e.status}`);return e.json()}async vote(t,e){const o=await fetch(`${this.baseUrl}/api/sdk/feedback/${t}/vote`,{method:"POST",headers:this.headers(),body:JSON.stringify({value:e,endUserId:this.userId,anonymousId:this.anonymousId})});if(!o.ok)throw new Error(`Upstep: ${o.status}`)}async getItem(t){const e=new URLSearchParams;this.userId&&e.set("endUserId",this.userId),this.anonymousId&&e.set("anonymousId",this.anonymousId);const o=await fetch(`${this.baseUrl}/api/sdk/feedback/${t}?${e}`,{headers:this.headers()});if(!o.ok)throw new Error(`Upstep: ${o.status}`);return o.json()}async removeVote(t){if(!this.userId&&!this.anonymousId)return;const e=new URLSearchParams;this.userId&&e.set("endUserId",this.userId),this.anonymousId&&e.set("anonymousId",this.anonymousId);const o=await fetch(`${this.baseUrl}/api/sdk/feedback/${t}/vote?${e}`,{method:"DELETE",headers:this.headers()});if(!o.ok)throw new Error(`Upstep: ${o.status}`)}}const E="#D97757",f={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},g={bg:"#000000",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function m(s){if(s==="light"||s==="dark")return s;if(typeof document<"u"){const t=document.documentElement;return t.classList.contains("dark")||t.getAttribute("data-theme")==="dark"?"dark":"light"}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function S(s,t,e){return`
1
+ (function(){"use strict";const u="upstep-anonymous-id";function m(){const s=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;if(typeof window>"u")return s;try{const e=window.localStorage.getItem(u);return e||(window.localStorage.setItem(u,s),s)}catch{return s}}class x{constructor(e){this.baseUrl=(e.baseUrl??"https://upstep.dev").replace(/\/$/,""),this.apiKey=e.apiKey,this.supportIdentityToken=e.supportIdentityToken,this.chat=e.chat!==!1,e.userId!==void 0&&(this.userId=e.userId),this.anonymousId=m()}setUserId(e){this.userId=e}headers(){return{"Content-Type":"application/json","x-api-key":this.apiKey}}async supportEnabled(){if(!this.chat)return!1;try{const e=await fetch(`${this.baseUrl}/api/sdk/support`,{headers:this.headers()});return e.ok&&(await e.json()).enabled===!0}catch{return!1}}supportFrameUrl(e){return`${this.baseUrl}/support/${encodeURIComponent(this.apiKey)}?theme=${encodeURIComponent(e)}`}connectSupportFrame(e){const t=new URL(this.baseUrl).origin,o=()=>{var n;return(n=e.contentWindow)==null?void 0:n.postMessage({type:"upstep:support:identity",token:this.supportIdentityToken},t)},i=n=>{var a;n.origin===t&&n.source===e.contentWindow&&((a=n.data)==null?void 0:a.type)==="upstep:support:ready"&&o()};return e.addEventListener("load",o),window.addEventListener("message",i),()=>{e.removeEventListener("load",o),window.removeEventListener("message",i)}}async listFeedback(e){const t=new URLSearchParams;e!=null&&e.cursor&&t.set("cursor",e.cursor),e!=null&&e.limit&&t.set("limit",String(e.limit)),e!=null&&e.type&&t.set("type",e.type),e!=null&&e.status&&t.set("status",e.status),e!=null&&e.sort&&t.set("sort",e.sort),this.userId&&t.set("endUserId",this.userId),this.anonymousId&&t.set("anonymousId",this.anonymousId);const o=await fetch(`${this.baseUrl}/api/sdk/feedback?${t}`,{headers:this.headers()});if(!o.ok)throw new Error(`Upstep: ${o.status}`);return o.json()}async submitFeedback(e){const t=await fetch(`${this.baseUrl}/api/sdk/feedback`,{method:"POST",headers:this.headers(),body:JSON.stringify({...e,endUserId:e.endUserId??this.userId,anonymousId:e.anonymousId??this.anonymousId})});if(!t.ok)throw new Error(`Upstep: ${t.status}`);return t.json()}async vote(e,t){const o=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}/vote`,{method:"POST",headers:this.headers(),body:JSON.stringify({value:t,endUserId:this.userId,anonymousId:this.anonymousId})});if(!o.ok)throw new Error(`Upstep: ${o.status}`)}async getItem(e){const t=new URLSearchParams;this.userId&&t.set("endUserId",this.userId),this.anonymousId&&t.set("anonymousId",this.anonymousId);const o=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}?${t}`,{headers:this.headers()});if(!o.ok)throw new Error(`Upstep: ${o.status}`);return o.json()}async removeVote(e){if(!this.userId&&!this.anonymousId)return;const t=new URLSearchParams;this.userId&&t.set("endUserId",this.userId),this.anonymousId&&t.set("anonymousId",this.anonymousId);const o=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}/vote?${t}`,{method:"DELETE",headers:this.headers()});if(!o.ok)throw new Error(`Upstep: ${o.status}`)}}const g="#5B7168",l={bg:"#ffffff",bgSoft:"#f4f6f4",bgHover:"#eaf0eb",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},c={bg:"#000000",bgSoft:"#191d1b",bgHover:"#252d28",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function h(s){if(s==="light"||s==="dark")return s;if(typeof document<"u"){const e=document.documentElement;return e.classList.contains("dark")||e.getAttribute("data-theme")==="dark"?"dark":"light"}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function y(s,e,t){return`
2
2
  #upstep-root *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}
3
- #upstep-btn{position:fixed;bottom:24px;${t==="left"?"left:24px":"right:24px"};z-index:9998;display:inline-flex;align-items:center;gap:7px;background:${s};color:#fff;border:none;border-radius:9999px;padding:12px 18px;font-size:14px;font-weight:600;cursor:grab;touch-action:none;box-shadow:0 6px 20px rgba(26,25,21,.18);transition:transform .15s,box-shadow .15s}
3
+ #upstep-btn{position:fixed;bottom:24px;right:24px;left:auto;z-index:9998;display:inline-flex;align-items:center;gap:7px;background:${s};color:#fff;border:none;border-radius:9999px;padding:12px 18px;font-size:14px;font-weight:600;cursor:pointer;box-shadow:0 6px 20px rgba(26,25,21,.18);transition:transform .15s,box-shadow .15s}
4
4
  #upstep-btn svg{width:16px;height:16px;flex-shrink:0}
5
5
  #upstep-btn:hover{transform:translateY(-1px);box-shadow:0 8px 26px rgba(26,25,21,.24)}
6
- #upstep-btn.upstep-dragging{cursor:grabbing;transform:scale(1.06);box-shadow:0 10px 32px rgba(26,25,21,.28);transition:transform .08s,box-shadow .08s}
7
6
  @media(max-width:639px){#upstep-btn{padding:12px}#upstep-btn span{display:none}}
8
- #upstep-backdrop{position:fixed;inset:0;background:${e.overlay};backdrop-filter:blur(3px);z-index:9999;display:flex;align-items:center;justify-content:center;padding:16px;animation:upstep-fade .2s ease}
7
+ @media(max-width:639px){#upstep-backdrop{padding:0 12px 80px!important}#upstep-modal{max-height:calc(100dvh - 104px)!important}}
8
+ #upstep-backdrop{position:fixed;inset:0;background:transparent;z-index:9999;display:flex;align-items:flex-end;justify-content:flex-end;padding:0 24px 88px;animation:upstep-fade .2s ease}
9
9
  @keyframes upstep-fade{from{opacity:0}to{opacity:1}}
10
10
  @keyframes upstep-rise{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:translateY(0)}}
11
- #upstep-modal{background:${e.bg};border:1px solid ${e.border};border-radius:20px;width:100%;max-width:440px;max-height:88vh;display:flex;flex-direction:column;overflow:hidden;box-shadow:0 24px 64px rgba(0,0,0,.28);animation:upstep-rise .26s cubic-bezier(.16,1,.3,1)}
11
+ #upstep-modal{background:${t.bg};border:1px solid ${t.border};border-radius:20px;width:100%;max-width:440px;max-height:calc(100dvh - 112px);display:flex;flex-direction:column;overflow:hidden;box-shadow:0 24px 64px rgba(0,0,0,.28);animation:upstep-rise .26s cubic-bezier(.16,1,.3,1)}
12
12
  #upstep-header{display:flex;align-items:flex-start;justify-content:space-between;padding:20px 20px 0}
13
- #upstep-header h2{margin:0;font-size:16px;font-weight:700;color:${e.text};letter-spacing:-.01em}
14
- #upstep-header p{margin:2px 0 0;font-size:12.5px;color:${e.textFaint}}
15
- #upstep-close{background:${e.bgSoft};border:none;width:28px;height:28px;border-radius:8px;font-size:14px;cursor:pointer;color:${e.textSoft};line-height:1;display:flex;align-items:center;justify-content:center;transition:background .15s}
16
- #upstep-close:hover{background:${e.bgHover};color:${e.text}}
17
- #upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${e.bgSoft};border-radius:11px}
18
- .upstep-tab{flex:1;padding:8px;background:none;border:none;border-radius:8px;font-size:13px;font-weight:600;color:${e.textSoft};cursor:pointer;transition:all .15s}
19
- .upstep-mode .upstep-tab.active{background:${e.bgSoft};box-shadow:none}
20
- .upstep-tab.active{background:${e.bg};color:${e.text};box-shadow:0 1px 3px rgba(0,0,0,.08)}
13
+ #upstep-header h2{margin:0;font-size:16px;font-weight:700;color:${t.text};letter-spacing:-.01em}
14
+ #upstep-header p{margin:2px 0 0;font-size:14px;color:${t.textFaint}}
15
+ #upstep-close{background:${t.bgSoft};border:none;width:28px;height:28px;border-radius:8px;font-size:14px;cursor:pointer;color:${t.textSoft};line-height:1;display:flex;align-items:center;justify-content:center;transition:background .15s}
16
+ #upstep-close:hover{background:${t.bgHover};color:${t.text}}
17
+ #upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${t.bgSoft};border-radius:11px}
18
+ .upstep-tab{flex:1;padding:8px;background:none;border:none;border-radius:8px;font-size:14px;font-weight:600;color:${t.textSoft};cursor:pointer;transition:all .15s}
19
+ .upstep-mode .upstep-tab.active{background:${t.bgSoft};box-shadow:none}
20
+ .upstep-tab.active{background:${t.bg};color:${t.text};box-shadow:0 1px 3px rgba(0,0,0,.08)}
21
21
  #upstep-body{flex:1;overflow-y:auto;padding:18px 20px 22px}
22
- .upstep-form textarea{width:100%;min-height:104px;border:1px solid ${e.border};border-radius:12px;padding:12px;font-size:14px;line-height:1.5;resize:vertical;outline:none;background:${e.bgSoft};color:${e.text};transition:border-color .15s}
23
- .upstep-form textarea::placeholder{color:${e.textFaint}}
24
- .upstep-form textarea:focus{border-color:${s};background:${e.bg}}
22
+ .upstep-form textarea{width:100%;min-height:104px;border:1px solid ${t.border};border-radius:12px;padding:12px;font-size:16px;line-height:1.6;resize:vertical;outline:none;background:${t.bgSoft};color:${t.text};transition:border-color .15s}
23
+ .upstep-form textarea::placeholder{color:${t.textFaint}}
24
+ .upstep-form textarea:focus{border-color:${s};background:${t.bg}}
25
25
  .upstep-type-row{display:flex;gap:7px;margin:12px 0 4px}
26
- .upstep-type-btn{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;padding:8px 10px;border-radius:9px;border:1px solid ${e.border};background:${e.bg};color:${e.textSoft};font-size:12.5px;font-weight:600;cursor:pointer;transition:all .15s}
26
+ .upstep-type-btn{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;padding:8px 10px;border-radius:9px;border:1px solid ${t.border};background:${t.bg};color:${t.textSoft};font-size:14px;font-weight:600;cursor:pointer;transition:all .15s}
27
27
  .upstep-type-btn svg{width:12px;height:12px;flex-shrink:0}
28
- .upstep-type-btn:hover{border-color:${e.textFaint}}
28
+ .upstep-type-btn:hover{border-color:${t.textFaint}}
29
29
  .upstep-type-btn.selected{background:${s};color:#fff;border-color:${s}}
30
30
  .upstep-submit{width:100%;padding:12px;background:${s};color:#fff;border:none;border-radius:11px;font-size:14px;font-weight:600;cursor:pointer;margin-top:14px;transition:filter .15s}
31
31
  .upstep-submit:hover{filter:brightness(.94)}
32
32
  .upstep-submit:disabled{opacity:.5;cursor:not-allowed}
33
- #upstep-form-msg{font-size:13px;text-align:center;margin-top:12px;color:${s};font-weight:500}
34
- .upstep-feedback-item{display:flex;gap:12px;padding:14px;border:1px solid ${e.border};border-radius:14px;margin-bottom:10px;background:${e.bg};transition:border-color .15s}
35
- .upstep-feedback-item:hover{border-color:${e.textFaint}}
36
- .upstep-vote{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;min-width:46px;padding:7px 0;border-radius:11px;border:1px solid ${e.border};background:${e.bgSoft};cursor:pointer;transition:all .15s}
33
+ #upstep-form-msg{font-size:14px;text-align:center;margin-top:12px;color:${s};font-weight:500}
34
+ .upstep-feedback-item{display:flex;gap:12px;padding:14px;border:1px solid ${t.border};border-radius:14px;margin-bottom:10px;background:${t.bg};transition:border-color .15s}
35
+ .upstep-feedback-item:hover{border-color:${t.textFaint}}
36
+ .upstep-vote{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;min-width:46px;padding:7px 0;border-radius:11px;border:1px solid ${t.border};background:${t.bgSoft};cursor:pointer;transition:all .15s}
37
37
  .upstep-vote:hover{border-color:${s}}
38
38
  .upstep-vote.voted{border-color:${s};background:${s}1a}
39
39
  .upstep-vote-arrow{font-size:11px;line-height:1;color:${s}}
40
- .upstep-vote-count{font-size:14px;font-weight:700;color:${e.text};line-height:1.1}
40
+ .upstep-vote-count{font-size:14px;font-weight:700;color:${t.text};line-height:1.1}
41
41
  .upstep-feedback-main{flex:1;min-width:0}
42
- .upstep-feedback-content{font-size:13.5px;line-height:1.5;color:${e.text};margin:0 0 8px;word-break:break-word}
42
+ .upstep-feedback-content{font-size:16px;line-height:1.5;color:${t.text};margin:0 0 8px;word-break:break-word}
43
43
  .upstep-feedback-meta{display:flex;align-items:center;gap:7px}
44
44
  .upstep-badge{display:inline-flex;align-items:center;padding:2px 8px;border-radius:9999px;font-size:10.5px;font-weight:700;letter-spacing:.02em}
45
45
  .upstep-badge-bug{background:#fdecec;color:#d6453d}
46
46
  .upstep-badge-feature{background:#e9f0fd;color:#3b76d6}
47
- .upstep-badge-general{background:${e.bgSoft};color:${e.textSoft}}
48
- .upstep-feedback-date{font-size:11px;color:${e.textFaint}}
49
- .upstep-empty{text-align:center;color:${e.textFaint};font-size:14px;padding:40px 0}
50
- .upstep-empty strong{display:block;color:${e.textSoft};font-size:15px;margin-bottom:4px}
51
- `}const M='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>';class U{constructor(t,e={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.dragMoved=!1,this.hasSupport=!1,this.disconnectSupport=null,this.client=t,this.accent=e.accentColor??E,this.position=e.position??"right",this.showLauncher=e.launcher!==!1,this.themeMode=e.theme??"auto",this.palette=m(this.themeMode)==="dark"?g:f}mount(){this.injectStyles(),this.showLauncher&&this.renderButton(),this.client.supportEnabled().then(t=>{if(this.hasSupport=t,t){const e=document.querySelector("#upstep-btn span");e&&(e.textContent="Help & feedback"),this.isOpen&&this.renderModal()}})}openWidget(){this.openModal()}closeWidget(){this.closeModal()}injectStyles(){var e;(e=document.getElementById("upstep-styles"))==null||e.remove();const t=document.createElement("style");t.id="upstep-styles",t.textContent=S(this.accent,this.position,this.palette),document.head.appendChild(t)}renderButton(){const t=document.createElement("button");t.id="upstep-btn",t.setAttribute("aria-label","Open help and feedback"),t.innerHTML=`${M}<span>Feedback</span>`,t.addEventListener("click",()=>{this.dragMoved||this.openModal()}),document.body.appendChild(t),this.makeDraggable(t)}makeDraggable(t){const i="upstep-btn-pos";try{const r=localStorage.getItem(i);if(r){const{side:p,bottom:u}=JSON.parse(r);t.style.left=p==="left"?"24px":"auto",t.style.right=p==="right"?"24px":"auto",t.style.top="auto",t.style.bottom=`${u}px`}}catch{}let n=0,a=0,l=0,v=0,h=!1;const L=()=>{const r=t.getBoundingClientRect(),p=r.left+r.width/2<window.innerWidth/2?"left":"right",u=Math.max(24,Math.min(window.innerHeight-r.height-24,r.top)),w=window.innerHeight-u-r.height;t.style.transition="left .25s cubic-bezier(.16,1,.3,1),right .25s cubic-bezier(.16,1,.3,1),top .25s cubic-bezier(.16,1,.3,1),bottom .25s cubic-bezier(.16,1,.3,1),transform .15s,box-shadow .15s",t.style.left=p==="left"?"24px":"auto",t.style.right=p==="right"?"24px":"auto",t.style.top="auto",t.style.bottom=`${w}px`;try{localStorage.setItem(i,JSON.stringify({side:p,bottom:w}))}catch{}},F=r=>{if(r.pointerType==="mouse"&&r.button!==0)return;this.dragMoved=!1,h=!0;const p=t.getBoundingClientRect();n=r.clientX,a=r.clientY,l=p.left,v=p.top,t.setPointerCapture(r.pointerId),t.style.transition="none"},C=r=>{if(!h)return;const p=r.clientX-n,u=r.clientY-a;!this.dragMoved&&Math.hypot(p,u)<6||(this.dragMoved||t.classList.add("upstep-dragging"),this.dragMoved=!0,t.style.left=`${l+p}px`,t.style.right="auto",t.style.top=`${v+u}px`,t.style.bottom="auto")},k=()=>{h&&(h=!1,t.classList.remove("upstep-dragging"),this.dragMoved&&L())};t.addEventListener("pointerdown",F),t.addEventListener("pointermove",C),t.addEventListener("pointerup",k),t.addEventListener("pointercancel",k)}openModal(){this.isOpen=!0,this.palette=m(this.themeMode)==="dark"?g:f,this.injectStyles(),this.fetchFeed(),this.renderModal()}closeModal(){var t,e;(t=this.disconnectSupport)==null||t.call(this),this.disconnectSupport=null,this.isOpen=!1,(e=document.getElementById("upstep-backdrop"))==null||e.remove()}async fetchFeed(){try{const t=await this.client.listFeedback({sort:"votes",limit:20});this.feedItems=t.items,this.renderFeedList()}catch{}}renderModal(){var o,i,n;(o=this.disconnectSupport)==null||o.call(this),this.disconnectSupport=null;const t=document.createElement("div");t.id="upstep-backdrop",t.addEventListener("click",a=>{a.target===t&&this.closeModal()}),t.innerHTML=`
47
+ .upstep-badge-general{background:${t.bgSoft};color:${t.textSoft}}
48
+ .upstep-feedback-date{font-size:11px;color:${t.textFaint}}
49
+ .upstep-empty{text-align:center;color:${t.textFaint};font-size:14px;padding:40px 0}
50
+ .upstep-empty strong{display:block;color:${t.textSoft};font-size:15px;margin-bottom:4px}
51
+ `}const k='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>';class v{constructor(e,t={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.hasSupport=!1,this.disconnectSupport=null,this.client=e,this.accent=t.accentColor??g,this.position="right",this.showLauncher=t.launcher!==!1,this.themeMode=t.theme??"auto",this.palette=h(this.themeMode)==="dark"?c:l}mount(){this.injectStyles(),this.showLauncher&&this.renderButton(),this.client.supportEnabled().then(e=>{if(this.hasSupport=e,e){const t=document.querySelector("#upstep-btn span");t&&(t.textContent="Help & feedback"),this.isOpen&&this.renderModal()}})}openWidget(){this.openModal()}closeWidget(){this.closeModal()}injectStyles(){var t;(t=document.getElementById("upstep-styles"))==null||t.remove();const e=document.createElement("style");e.id="upstep-styles",e.textContent=y(this.accent,this.position,this.palette),document.head.appendChild(e)}renderButton(){const e=document.createElement("button");e.id="upstep-btn",e.setAttribute("aria-label","Open help and feedback"),e.innerHTML=`${k}<span>Feedback</span>`,e.addEventListener("click",()=>{this.openModal()}),document.body.appendChild(e)}openModal(){!this.isOpen&&this.hasSupport&&(this.tab="support"),this.isOpen=!0,this.palette=h(this.themeMode)==="dark"?c:l,this.injectStyles(),this.fetchFeed(),this.renderModal()}closeModal(){var e,t;(e=this.disconnectSupport)==null||e.call(this),this.disconnectSupport=null,this.isOpen=!1,(t=document.getElementById("upstep-backdrop"))==null||t.remove()}async fetchFeed(){try{const e=await this.client.listFeedback({sort:"votes",limit:20});this.feedItems=e.items,this.renderFeedList()}catch{}}renderModal(){var o,i,n;(o=this.disconnectSupport)==null||o.call(this),this.disconnectSupport=null;const e=document.createElement("div");e.id="upstep-backdrop",e.addEventListener("click",a=>{a.target===e&&this.closeModal()}),e.innerHTML=`
52
52
  <div id="upstep-modal" style="max-width:${this.hasSupport?"460px":"440px"}">
53
53
  ${this.hasSupport?`<div class="upstep-mode" style="display:flex;align-items:center;gap:14px;padding:10px 14px;border-bottom:1px solid ${this.palette.border}"><div id="upstep-tabs" style="margin:0;padding:0;background:transparent;flex:1"><button class="upstep-tab ${this.tab==="support"?"active":""}" data-tab="support">Support</button><button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Feedback</button><button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Ideas</button></div><button id="upstep-close" aria-label="Close" style="flex-shrink:0;background:transparent">✕</button></div>`:`<div id="upstep-header"><div><h2>Share your feedback</h2><p>Tell us what to build next, or vote on ideas.</p></div><button id="upstep-close" aria-label="Close">✕</button></div><div id="upstep-tabs"><button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Give feedback</button><button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Vote on ideas</button></div>`}
54
54
  <div id="upstep-body" style="${this.tab==="support"?"padding:0;overflow:hidden":""}">
55
- ${this.tab==="support"?`<iframe id="upstep-support-frame" title="Customer support" src="${this.client.supportFrameUrl(this.palette.bg==="#000000"?"dark":"light")}" style="width:100%;height:min(560px,calc(88dvh - 56px));min-height:300px;border:0;display:block"></iframe>`:this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
55
+ ${this.tab==="support"?`<iframe id="upstep-support-frame" title="Customer support" src="${this.client.supportFrameUrl(this.palette.bg==="#000000"?"dark":"light")}" style="width:100%;height:min(560px,calc(100dvh - 168px));min-height:300px;border:0;display:block"></iframe>`:this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
56
56
  </div>
57
57
  </div>
58
- `,(i=document.getElementById("upstep-backdrop"))==null||i.remove(),document.body.appendChild(t),(n=t.querySelector("#upstep-close"))==null||n.addEventListener("click",()=>this.closeModal()),t.querySelectorAll(".upstep-tab").forEach(a=>{a.addEventListener("click",()=>{this.tab=a.dataset.tab,this.renderModal()})});const e=t.querySelector("#upstep-support-frame");e&&(this.disconnectSupport=this.client.connectSupportFrame(e)),this.bindSubmitForm(),this.bindVoteButtons()}renderSubmitForm(){const t=["BUG","FEATURE","GENERAL"],e={BUG:"Bug",FEATURE:"Feature",GENERAL:"General"},o={BUG:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="8" cy="10" rx="3.5" ry="4.5"/><path d="M8 5.5V4M5.5 6.5 3.5 5M10.5 6.5 12.5 5M4.5 10.5 2.5 10M11.5 10.5 13.5 10"/></svg>',FEATURE:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.1 4.1l1 1M10.9 10.9l1 1M11.9 4.1l-1 1M5.1 10.9l-1 1"/><circle cx="8" cy="8" r="2.5"/></svg>',GENERAL:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M14 9a2 2 0 0 1-2 2H5L2 14V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v5z"/></svg>'};return`
58
+ `,(i=document.getElementById("upstep-backdrop"))==null||i.remove(),document.body.appendChild(e),(n=e.querySelector("#upstep-close"))==null||n.addEventListener("click",()=>this.closeModal()),e.querySelectorAll(".upstep-tab").forEach(a=>{a.addEventListener("click",()=>{this.tab=a.dataset.tab,this.renderModal()})});const t=e.querySelector("#upstep-support-frame");t&&(this.disconnectSupport=this.client.connectSupportFrame(t)),this.bindSubmitForm(),this.bindVoteButtons()}renderSubmitForm(){const e=["BUG","FEATURE","GENERAL"],t={BUG:"Bug",FEATURE:"Feature",GENERAL:"General"},o={BUG:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="8" cy="10" rx="3.5" ry="4.5"/><path d="M8 5.5V4M5.5 6.5 3.5 5M10.5 6.5 12.5 5M4.5 10.5 2.5 10M11.5 10.5 13.5 10"/></svg>',FEATURE:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.1 4.1l1 1M10.9 10.9l1 1M11.9 4.1l-1 1M5.1 10.9l-1 1"/><circle cx="8" cy="8" r="2.5"/></svg>',GENERAL:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M14 9a2 2 0 0 1-2 2H5L2 14V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v5z"/></svg>'};return`
59
59
  <div class="upstep-form">
60
60
  <textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
61
61
  <div class="upstep-type-row">
62
- ${t.map(i=>`<button class="upstep-type-btn${this.selectedType===i?" selected":""}" data-type="${i}">${o[i]}${e[i]}</button>`).join("")}
62
+ ${e.map(i=>`<button class="upstep-type-btn${this.selectedType===i?" selected":""}" data-type="${i}">${o[i]}${t[i]}</button>`).join("")}
63
63
  </div>
64
64
  <button class="upstep-submit" id="upstep-submit-btn">Send feedback</button>
65
65
  <div id="upstep-form-msg"></div>
66
66
  </div>
67
- `}renderFeed(){return this.feedItems.length?this.feedItems.map(t=>{var e;return`
68
- <div class="upstep-feedback-item" data-id="${t.id}">
69
- <button class="upstep-vote${t.userVote==="UP"?" voted":""}" data-vote="UP" data-feedback="${t.id}">
67
+ `}renderFeed(){return this.feedItems.length?this.feedItems.map(e=>{var t;return`
68
+ <div class="upstep-feedback-item" data-id="${e.id}">
69
+ <button class="upstep-vote${e.userVote==="UP"?" voted":""}" data-vote="UP" data-feedback="${e.id}">
70
70
  <span class="upstep-vote-arrow">▲</span>
71
- <span class="upstep-vote-count">${t.upvotes}</span>
71
+ <span class="upstep-vote-count">${e.upvotes}</span>
72
72
  </button>
73
73
  <div class="upstep-feedback-main">
74
- <p class="upstep-feedback-content">${x(t.content)}</p>
74
+ <p class="upstep-feedback-content">${b(e.content)}</p>
75
75
  <div class="upstep-feedback-meta">
76
- <span class="upstep-badge upstep-badge-${t.type.toLowerCase()}">${t.type}</span>
77
- <span class="upstep-badge upstep-badge-general">${x(((e=t.boardStatus)==null?void 0:e.name)??t.status.replace("_"," "))}</span>
78
- <span class="upstep-feedback-date">${new Date(t.createdAt).toLocaleDateString()}</span>
76
+ <span class="upstep-badge upstep-badge-${e.type.toLowerCase()}">${e.type}</span>
77
+ <span class="upstep-badge upstep-badge-general">${b(((t=e.boardStatus)==null?void 0:t.name)??e.status.replace("_"," "))}</span>
78
+ <span class="upstep-feedback-date">${new Date(e.createdAt).toLocaleDateString()}</span>
79
79
  </div>
80
80
  </div>
81
- </div>`}).join(""):'<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>'}renderFeedList(){const t=document.getElementById("upstep-body");!t||this.tab!=="feed"||(t.innerHTML=this.renderFeed(),this.bindVoteButtons())}bindSubmitForm(){var t;document.querySelectorAll(".upstep-type-btn").forEach(e=>{e.addEventListener("click",()=>{this.selectedType=e.dataset.type,document.querySelectorAll(".upstep-type-btn").forEach(o=>o.classList.remove("selected")),e.classList.add("selected")})}),(t=document.getElementById("upstep-submit-btn"))==null||t.addEventListener("click",async()=>{const e=document.getElementById("upstep-textarea"),o=document.getElementById("upstep-form-msg"),i=document.getElementById("upstep-submit-btn");if(!e||this.loading)return;const n=e.value.trim();if(n){this.loading=!0,i&&(i.disabled=!0,i.textContent="Sending…");try{await this.client.submitFeedback({content:n,type:this.selectedType}),e.value="",o&&(o.textContent="Feedback received. Thank you."),await this.fetchFeed()}catch{o&&(o.textContent="Something went wrong. Please try again.")}finally{this.loading=!1,i&&(i.disabled=!1,i.textContent="Send feedback")}}})}bindVoteButtons(){document.querySelectorAll(".upstep-vote").forEach(t=>{t.addEventListener("click",async()=>{const e=t.dataset.feedback;try{await this.client.vote(e,"UP"),await this.fetchFeed()}catch{}})})}}function x(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}let d=null,c=null;const y={init(s){if(d=new I(s),typeof window<"u"){const t={};s.accentColor!==void 0&&(t.accentColor=s.accentColor),s.position!==void 0&&(t.position=s.position),s.theme!==void 0&&(t.theme=s.theme),s.launcher!==void 0&&(t.launcher=s.launcher);const e=()=>{c=new U(d,t),c.mount()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):e()}return d},open(){c==null||c.openWidget()},close(){c==null||c.closeWidget()},identify(s){d==null||d.setUserId(s)},identifySupport(s){var e;d&&(d.supportIdentityToken=s);const t=document.querySelector("#upstep-support-frame");t&&d&&((e=t.contentWindow)==null||e.postMessage({type:"upstep:support:identity",token:s},new URL(d.baseUrl).origin))},get client(){if(!d)throw new Error("Upstep.init() must be called first");return d}};if(typeof document<"u"){const s=document.currentScript,t=s==null?void 0:s.dataset.apiKey,e=s==null?void 0:s.dataset.userId,o=s==null?void 0:s.dataset.baseUrl,i=s==null?void 0:s.dataset.accentColor,n=s==null?void 0:s.dataset.position,a=s==null?void 0:s.dataset.theme;if(t){const l={apiKey:t};e&&(l.userId=e),(s==null?void 0:s.dataset.chat)!==void 0&&(l.chat=s.dataset.chat!=="false"),o&&(l.baseUrl=o),i&&(l.accentColor=i),(n==="left"||n==="right")&&(l.position=n),(a==="light"||a==="dark"||a==="auto")&&(l.theme=a),y.init(l)}}window.Upstep=y})();
81
+ </div>`}).join(""):'<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>'}renderFeedList(){const e=document.getElementById("upstep-body");!e||this.tab!=="feed"||(e.innerHTML=this.renderFeed(),this.bindVoteButtons())}bindSubmitForm(){var e;document.querySelectorAll(".upstep-type-btn").forEach(t=>{t.addEventListener("click",()=>{this.selectedType=t.dataset.type,document.querySelectorAll(".upstep-type-btn").forEach(o=>o.classList.remove("selected")),t.classList.add("selected")})}),(e=document.getElementById("upstep-submit-btn"))==null||e.addEventListener("click",async()=>{const t=document.getElementById("upstep-textarea"),o=document.getElementById("upstep-form-msg"),i=document.getElementById("upstep-submit-btn");if(!t||this.loading)return;const n=t.value.trim();if(n){this.loading=!0,i&&(i.disabled=!0,i.textContent="Sending…");try{await this.client.submitFeedback({content:n,type:this.selectedType}),t.value="",o&&(o.textContent="Feedback received. Thank you."),await this.fetchFeed()}catch{o&&(o.textContent="Something went wrong. Please try again.")}finally{this.loading=!1,i&&(i.disabled=!1,i.textContent="Send feedback")}}})}bindVoteButtons(){document.querySelectorAll(".upstep-vote").forEach(e=>{e.addEventListener("click",async()=>{const t=e.dataset.feedback;try{await this.client.vote(t,"UP"),await this.fetchFeed()}catch{}})})}}function b(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}let r=null,d=null;const f={init(s){if(r=new x(s),typeof window<"u"){const e={};s.accentColor!==void 0&&(e.accentColor=s.accentColor),s.position!==void 0&&(e.position=s.position),s.theme!==void 0&&(e.theme=s.theme),s.launcher!==void 0&&(e.launcher=s.launcher);const t=()=>{d=new v(r,e),d.mount()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t()}return r},open(){d==null||d.openWidget()},close(){d==null||d.closeWidget()},identify(s){r==null||r.setUserId(s)},identifySupport(s){var t;r&&(r.supportIdentityToken=s);const e=document.querySelector("#upstep-support-frame");e&&r&&((t=e.contentWindow)==null||t.postMessage({type:"upstep:support:identity",token:s},new URL(r.baseUrl).origin))},get client(){if(!r)throw new Error("Upstep.init() must be called first");return r}};if(typeof document<"u"){const s=document.currentScript,e=s==null?void 0:s.dataset.apiKey,t=s==null?void 0:s.dataset.userId,o=s==null?void 0:s.dataset.baseUrl,i=s==null?void 0:s.dataset.accentColor,n=s==null?void 0:s.dataset.position,a=s==null?void 0:s.dataset.theme;if(e){const p={apiKey:e};t&&(p.userId=t),(s==null?void 0:s.dataset.chat)!==void 0&&(p.chat=s.dataset.chat!=="false"),o&&(p.baseUrl=o),i&&(p.accentColor=i),(n==="left"||n==="right")&&(p.position=n),(a==="light"||a==="dark"||a==="auto")&&(p.theme=a),f.init(p)}}window.Upstep=f})();
package/dist/widget.d.ts CHANGED
@@ -20,7 +20,6 @@ export declare class UpstepWidget {
20
20
  private showLauncher;
21
21
  private themeMode;
22
22
  private palette;
23
- private dragMoved;
24
23
  private hasSupport;
25
24
  private disconnectSupport;
26
25
  constructor(client: UpstepApiClient, options?: WidgetOptions);
@@ -31,7 +30,6 @@ export declare class UpstepWidget {
31
30
  closeWidget(): void;
32
31
  private injectStyles;
33
32
  private renderButton;
34
- private makeDraggable;
35
33
  private openModal;
36
34
  private closeModal;
37
35
  private fetchFeed;
@@ -1 +1 @@
1
- {"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAIxC,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAqH3C,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,yEAAyE;IACzE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,GAAG,CAAiB;IAC5B,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAmB;IACnC,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,iBAAiB,CAA6B;gBAE1C,MAAM,EAAE,eAAe,EAAE,OAAO,GAAE,aAAkB;IAShE,KAAK;IAML,4EAA4E;IAC5E,UAAU;IAIV,iDAAiD;IACjD,WAAW;IAIX,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,YAAY;IAYpB,OAAO,CAAC,aAAa;IA4ErB,OAAO,CAAC,SAAS;IAUjB,OAAO,CAAC,UAAU;YAMJ,SAAS;IAUvB,OAAO,CAAC,WAAW;IAkCnB,OAAO,CAAC,gBAAgB;IAoBxB,OAAO,CAAC,UAAU;IAyBlB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,cAAc;IAyCtB,OAAO,CAAC,eAAe;CAaxB"}
1
+ {"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAIxC,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AA4H3C,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,yEAAyE;IACzE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,GAAG,CAAiB;IAC5B,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAmB;IACnC,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,iBAAiB,CAA6B;gBAE1C,MAAM,EAAE,eAAe,EAAE,OAAO,GAAE,aAAkB;IAShE,KAAK;IAaL,4EAA4E;IAC5E,UAAU;IAIV,iDAAiD;IACjD,WAAW;IAIX,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,SAAS;IAWjB,OAAO,CAAC,UAAU;YAOJ,SAAS;IAUvB,OAAO,CAAC,WAAW;IAuCnB,OAAO,CAAC,gBAAgB;IA0BxB,OAAO,CAAC,UAAU;IAyBlB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,cAAc;IAsDtB,OAAO,CAAC,eAAe;CAaxB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@upstep/js",
3
- "version": "0.6.1",
4
- "description": "Upstep feedback widget for web apps",
3
+ "version": "0.7.0",
4
+ "description": "UpStep feedback, voting and AI support widgets for web apps",
5
5
  "license": "MIT",
6
6
  "homepage": "https://upstep.dev",
7
7
  "repository": {
@@ -31,13 +31,18 @@
31
31
  "import": "./dist/react.js",
32
32
  "require": "./dist/react.cjs"
33
33
  },
34
- "./embed": "./dist/upstep.global.js"
34
+ "./embed": "./dist/upstep.global.js",
35
+ "./support": {
36
+ "types": "./dist/support.d.ts",
37
+ "import": "./dist/support.js",
38
+ "require": "./dist/support.cjs"
39
+ }
35
40
  },
36
41
  "files": [
37
42
  "dist"
38
43
  ],
39
44
  "dependencies": {
40
- "@upstep/types": "0.6.0"
45
+ "@upstep/types": "0.7.0"
41
46
  },
42
47
  "peerDependencies": {
43
48
  "react": ">=18",