@webority/support-react 0.134.1 → 0.135.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -0
- package/dist/guidance.json +38 -1
- package/dist/support-react.js +1 -1
- package/dist/types/SupportContact.d.ts +2 -2
- package/dist/types/agent/SupportAgentProvider.d.ts +17 -0
- package/dist/types/agent/SupportAgentTicket.d.ts +15 -0
- package/dist/types/agent/SupportAgentTicket.meta.d.ts +31 -0
- package/dist/types/agent/SupportQueue.d.ts +25 -0
- package/dist/types/agent/SupportQueue.meta.d.ts +58 -0
- package/dist/types/agent/client.d.ts +106 -0
- package/dist/types/agent/context.d.ts +120 -0
- package/dist/types/agent/labels.d.ts +84 -0
- package/dist/types/client.d.ts +2 -0
- package/dist/types/index.d.ts +5 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -197,6 +197,59 @@ line is left out when an article has no publish date.
|
|
|
197
197
|
`useHelpCentre(client)` returns the settings, the article list (with its paging) and the search for a
|
|
198
198
|
screen that draws its own layout.
|
|
199
199
|
|
|
200
|
+
## Agent side
|
|
201
|
+
|
|
202
|
+
The support agent's screens: a queue of tickets to work, and one ticket's thread with its reply,
|
|
203
|
+
its internal note and the controls for status, priority, category and assignee. The agent client
|
|
204
|
+
talks to the agent endpoints the product's backend hosts, under `/api/support/agent` by default.
|
|
205
|
+
The server half is `MapWeboritySupportAgentEndpoints` in `Webority.Support.AspNetCore`.
|
|
206
|
+
|
|
207
|
+
```jsx
|
|
208
|
+
import { createSupportAgentClient, SupportAgentProvider, SupportAgentTicket, SupportQueue } from "@webority/support-react";
|
|
209
|
+
|
|
210
|
+
const agentClient = createSupportAgentClient(userClient, { basePath: "/api/support/agent" });
|
|
211
|
+
|
|
212
|
+
<SupportAgentProvider client={agentClient} timeZone="Asia/Kolkata">
|
|
213
|
+
<SupportQueue getTicketHref={(id) => `/support/agent/${id}`} />
|
|
214
|
+
<SupportAgentTicket ticketId={id} onBack={() => navigate("/support/agent")} />
|
|
215
|
+
</SupportAgentProvider>;
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
`createSupportAgentClient(http, { basePath })` takes the same axios-like instance as
|
|
219
|
+
`createSupportClient`, and every method rejects with a `SupportApiError` written for the person.
|
|
220
|
+
|
|
221
|
+
`SupportAgentProvider` takes the client, plus `timeZone` (IANA, default `Asia/Kolkata`),
|
|
222
|
+
`renderTime` (as on `SupportProvider`) and `labels`, which overrides the built-in English per scope:
|
|
223
|
+
`supportQueue` and `agentTicket`.
|
|
224
|
+
|
|
225
|
+
| `SupportQueue` prop | What it does |
|
|
226
|
+
|---|---|
|
|
227
|
+
| `onOpenTicket(id)` | Opens a ticket in place when its number is clicked. A modified click keeps the link's own behaviour. |
|
|
228
|
+
| `getTicketHref(id)` | The address of each ticket number, for a router link. |
|
|
229
|
+
| `status` | The status filter's value, when the product drives it. |
|
|
230
|
+
| `onStatusChange(status)` | Called with the status the agent picks. |
|
|
231
|
+
| `defaultStatus` | The status to start on when `status` is not passed. Default `all`, which lists every status, settled tickets included. |
|
|
232
|
+
| `queue` | The queue key to list. Every queue when left out. |
|
|
233
|
+
| `pageSize` | Tickets per page. Default 10. |
|
|
234
|
+
|
|
235
|
+
Every filter, the search and the paging go to the server; the component only shows what it is given.
|
|
236
|
+
|
|
237
|
+
| `SupportAgentTicket` prop | What it does |
|
|
238
|
+
|---|---|
|
|
239
|
+
| `ticketId` | The ticket to show. Nothing loads while it is empty. |
|
|
240
|
+
| `onBack()` | The back action to the queue. |
|
|
241
|
+
| `labels` | Overrides the built-in English for this screen, over the provider's `agentTicket` labels. |
|
|
242
|
+
|
|
243
|
+
Attachments open through `openAttachment(ticketId, attachmentId)`: the client fetches the file
|
|
244
|
+
with the portal's bearer token and opens it in a new tab. `attachmentUrl` returns only the path,
|
|
245
|
+
which carries no token, so it cannot be used as an image source.
|
|
246
|
+
|
|
247
|
+
For a screen of its own, the agent hooks are `useSupportQueue(query)` and `useSupportQueueCounts()`
|
|
248
|
+
for the queue, `useSupportAgentTicket(id)` for one ticket and its changes, `useSupportAgents()` and
|
|
249
|
+
`useSupportAgentSettings()` for the lists the controls use, and `useSupportAgentClient()`,
|
|
250
|
+
`useSupportAgentTimeZone()`, `useSupportAgentRenderTime()` and `useSupportAgentLabels(scope, defaults)`
|
|
251
|
+
for the provider's values.
|
|
252
|
+
|
|
200
253
|
## Hooks
|
|
201
254
|
|
|
202
255
|
`useSupportConfig()`, `useSupportTickets(query)`, `useSupportTicketCounts()` and
|
package/dist/guidance.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"format": "webority-guidance/1",
|
|
3
3
|
"package": {
|
|
4
4
|
"name": "@webority/support-react",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.135.0"
|
|
6
6
|
},
|
|
7
7
|
"components": [
|
|
8
8
|
{
|
|
@@ -64,6 +64,26 @@
|
|
|
64
64
|
]
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
|
+
{
|
|
68
|
+
"name": "SupportAgentTicket",
|
|
69
|
+
"usage": {
|
|
70
|
+
"when": [
|
|
71
|
+
"A support agent works one ticket: reads the thread, replies or adds an internal note, and changes its status, priority, category or assignee."
|
|
72
|
+
],
|
|
73
|
+
"whenNot": [
|
|
74
|
+
{
|
|
75
|
+
"text": "The customer reads or replies to their own ticket.",
|
|
76
|
+
"instead": "SupportCenter"
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"do": [],
|
|
80
|
+
"dont": [],
|
|
81
|
+
"a11y": [
|
|
82
|
+
"The conversation is an ordered list named Conversation, and an internal note carries an Internal badge in its text.",
|
|
83
|
+
"A conflict or failure is shown as an alert above the reply box, and the reply text is kept."
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
},
|
|
67
87
|
{
|
|
68
88
|
"name": "SupportCenter",
|
|
69
89
|
"usage": {
|
|
@@ -99,6 +119,23 @@
|
|
|
99
119
|
"The copy button for the email address is labelled Copy email."
|
|
100
120
|
]
|
|
101
121
|
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "SupportQueue",
|
|
125
|
+
"usage": {
|
|
126
|
+
"when": [
|
|
127
|
+
"A support agent works through the tickets in their queue.",
|
|
128
|
+
"The agent narrows the queue by status, priority, category, place, assignee, unassigned or overdue, or searches it."
|
|
129
|
+
],
|
|
130
|
+
"whenNot": [],
|
|
131
|
+
"do": [],
|
|
132
|
+
"dont": [],
|
|
133
|
+
"a11y": [
|
|
134
|
+
"The queue is a section labelled by its Ticket queue heading, and the counts strip is a list of figures.",
|
|
135
|
+
"Each ticket number is a link to the ticket, and a plain click opens it in place.",
|
|
136
|
+
"Overdue is shown as text beside the due time, never as colour alone."
|
|
137
|
+
]
|
|
138
|
+
}
|
|
102
139
|
}
|
|
103
140
|
]
|
|
104
141
|
}
|
package/dist/support-react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createContext as e,useCallback as t,useContext as n,useEffect as r,useId as i,useMemo as a,useRef as o,useState as s}from"react";import{AppActionIcon as c,AppAlert as l,AppAvatar as u,AppBadge as d,AppButton as f,AppCard as p,AppChip as m,AppChipGroup as h,AppConfirmDialog as g,AppCopyButton as _,AppDataTable as v,AppDescriptions as y,AppEmptyState as b,AppFileAttachment as x,AppFloatingButton as S,AppFormActions as C,AppIcon as w,AppInput as T,AppLink as E,AppMarkdown as D,AppModal as O,AppSearch as k,AppSelect as ee,AppSkeleton as A,AppSpinner as j,AppStatusBadge as M,AppTabs as N,AppTextarea as P,warnInvalidValue as F}from"@webority/ui-react";import{IST_TIME_ZONE as I,formatDateTime as L,formatFileSize as R,timeZoneLabel as z}from"@webority/ui-elements/helpers";import{Fragment as B,jsx as V,jsxs as H}from"react/jsx-runtime";import{toBlob as te}from"html-to-image";var U=`Something went wrong. Please try again.`,W=class extends Error{constructor(e,t,n){super(t),this.name=`SupportApiError`,this.code=e,this.status=n}};async function ne(e){if(e&&typeof Blob<`u`&&e instanceof Blob)try{return JSON.parse(await e.text())}catch{return null}if(typeof e==`string`)try{return JSON.parse(e)}catch{return null}return e??null}async function re(e){if(e instanceof W)return e;let t=e?.response;if(!t)return new W(`network`,U);let n=await ne(t.data);return new W(typeof n?.code==`string`&&n.code?n.code:`unknown`,typeof n?.detail==`string`&&n.detail.trim()?n.detail:U,t.status)}async function G(e){try{return(await e()).data}catch(e){throw await re(e)}}function K(e,t,n){n!=null&&String(n).trim()!==``&&e.append(t,String(n))}function q(e,t,n,r){(n??[]).forEach((n,i)=>{let a=n?.name||`${r}-${i+1}.png`;e.append(t,n,a)})}var ie=20;function ae(e,t){return(e??[]).map((e,n)=>e?.name||`${t}-${n+1}.png`).join(`|`)}function oe(e){return e instanceof W&&typeof e.status==`number`&&e.status>=400&&e.status<=499&&e.status!==408&&e.status!==429}function se(e,t=`/api/support`){let n=(typeof t==`string`?t:t?.base??`/api/support`).replace(/\/+$/,``),r=e=>`${n}/tickets/${encodeURIComponent(e)}`,i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map;function o(){for(let e of i.keys()){if(i.size<=ie)return;a.has(e)||i.delete(e)}}async function s(e,t){let n=i.get(e)||crypto.randomUUID();i.delete(e),i.set(e,n),a.set(e,(a.get(e)??0)+1),o();try{let r=await t(n);return i.delete(e),r}catch(t){throw oe(t)&&i.delete(e),t}finally{let t=a.get(e)-1;t>0?a.set(e,t):a.delete(e)}}return{getConfig:()=>G(()=>e.get(`${n}/settings`)),listTickets:({status:t,search:r,page:i,pageSize:a}={})=>{let o=new URLSearchParams;K(o,`status`,t),K(o,`search`,r?.trim()),K(o,`page`,i),K(o,`pageSize`,a);let s=o.toString();return G(()=>e.get(`${n}/tickets${s?`?${s}`:``}`))},getTicketCounts:()=>G(()=>e.get(`${n}/tickets/counts`)),getTicket:t=>G(()=>e.get(r(t))),createTicket:({category:t,subject:r,body:i,pageUrl:a,userAgent:o,appVersion:c,files:l,screenshots:u})=>{let d=new FormData;return d.append(`category`,t??``),d.append(`subject`,r??``),d.append(`body`,i??``),K(d,`pageUrl`,a),K(d,`userAgent`,o),K(d,`appVersion`,c),q(d,`files`,l,`file`),q(d,`screenshots`,u,`screenshot`),s([`ticket`,t,r,i,ae(l,`file`),ae(u,`screenshot`)].join(`\0`),t=>G(()=>e.post(`${n}/tickets`,d,{headers:{"Idempotency-Key":t}})))},getSuggestions:async(t,{signal:r}={})=>{try{return await G(()=>e.get(`${n}/suggestions`,{params:{subject:t},signal:r}))}catch(e){if(e instanceof W&&e.status===404)return[];throw e}},reply:(t,{body:n,files:i,screenshots:a})=>{let o=new FormData;return o.append(`body`,n??``),q(o,`files`,i,`file`),q(o,`screenshots`,a,`screenshot`),s([`reply`,t,n,ae(i,`file`),ae(a,`screenshot`)].join(`\0`),n=>G(()=>e.post(`${r(t)}/replies`,o,{headers:{"Idempotency-Key":n}})))},reopen:t=>G(()=>e.post(`${r(t)}/reopen`)),cancel:t=>G(()=>e.post(`${r(t)}/cancel`)),rate:(t,{satisfaction:n,comment:i})=>{let a={satisfaction:n};return i!=null&&i.trim()!==``&&(a.comment=i.trim()),G(()=>e.post(`${r(t)}/rating`,a))},fetchAttachment:t=>G(()=>e.get(`${n}/attachments/${encodeURIComponent(t)}`,{responseType:`blob`})),confirmAction:t=>G(()=>e.post(`${n}/actions/confirm`,{token:t}))}}var ce=3e4,le=e(null);function ue(){let e=n(le);if(!e)throw Error(`Support components and hooks must be used inside <SupportProvider>.`);return e}function J(){return ue().client}function de(){return ue().timeZone}function fe(){return ue().renderTime??null}function Y(e,t){let n=ue().labels?.[e];return a(()=>n?{...t,...n}:t,[n,t])}function pe(e,n,i=!0){let[a,c]=s({data:null,loading:i,error:null}),[l,u]=s(0),d=o(e);d.current=e;let f=o(n);r(()=>{let e=f.current!==n;if(f.current=n,!i){c({data:null,loading:!1,error:null});return}let t=!0;return c(t=>({data:e?null:t.data,loading:!0,error:null})),d.current(l>0).then(e=>t&&c({data:e,loading:!1,error:null}),e=>t&&c(t=>({...t,loading:!1,error:e}))),()=>{t=!1}},[n,i,l]);let p=t(()=>u(e=>e+1),[]),m=t(e=>c(t=>({...t,data:typeof e==`function`?e(t.data):e})),[]);return{...a,reload:p,setData:m}}function me(){let{loadConfig:e}=ue(),{data:t,loading:n,error:r,reload:i}=pe(e,`config`);return{config:t,loading:n,error:r,reload:i}}function he(e={}){let t=J(),{status:n,search:r,page:i,pageSize:a}=e,{data:o,loading:s,error:c,reload:l}=pe(()=>t.listTickets({status:n,search:r,page:i,pageSize:a}),JSON.stringify([`tickets`,n??null,r??null,i??null,a??null]));return{tickets:o?.items??[],totalCount:o?.totalCount??0,totalPages:o?.totalPages??0,loading:s,error:c,reload:l}}function ge(){let e=J(),{data:t,loading:n,error:r,reload:i}=pe(()=>e.getTicketCounts(),`ticket-counts`);return{counts:t,loading:n,error:r,reload:i}}function _e(e){let n=J(),{data:i,loading:a,error:s,reload:c,setData:l}=pe(()=>n.getTicket(e),e??``,!!e),u=o(0),d=o(e);d.current=e;let f=t(async e=>{u.current+=1;try{let t=await e();return l(t),t}finally{--u.current}},[l]),p=t(async()=>{if(u.current>0)return;let t=e;try{let e=await n.getTicket(t);if(d.current!==t)return;l(t=>t?Date.parse(e.updatedDateTimeUtc)>=Date.parse(t.updatedDateTimeUtc)?e:t:e)}catch{}},[n,e,l]);return r(()=>{if(!e)return;let t=null,n=()=>{t===null&&(t=setInterval(p,ce))},r=()=>{t!==null&&clearInterval(t),t=null},i=()=>{document.hidden?r():(p(),n())};return document.addEventListener(`visibilitychange`,i),document.hidden||n(),()=>{r(),document.removeEventListener(`visibilitychange`,i)}},[e,p]),{ticket:i,loading:a,error:s,reload:c,reply:t(t=>f(()=>n.reply(e,t)),[f,n,e]),reopen:t(()=>f(()=>n.reopen(e)),[f,n,e]),cancel:t(()=>f(()=>n.cancel(e)),[f,n,e]),rate:t(t=>f(()=>n.rate(e,t)),[f,n,e])}}function ve({baseUrl:e,http:t}){if(typeof e!=`string`||e.trim()===``)throw TypeError(`createHelpCentreClient needs a baseUrl.`);if(typeof t?.get!=`function`)throw TypeError(`createHelpCentreClient needs an http client with get().`);let n=e.trim().replace(/\/+$/,``),r=async e=>{try{return(await e()).data}catch(e){throw await re(e)}};return{settings:e=>r(()=>t.get(`${n}/settings`,{signal:e?.signal})),list:({page:e,pageSize:i}={},a)=>{let o=new URLSearchParams;e!=null&&o.set(`page`,String(e)),i!=null&&o.set(`pageSize`,String(i));let s=o.toString();return r(()=>t.get(`${n}/articles${s?`?${s}`:``}`,{signal:a?.signal}))},get:(e,i)=>r(()=>t.get(`${n}/articles/${encodeURIComponent(e)}`,{signal:i?.signal})),search:(e,i)=>r(()=>t.get(`${n}/search?${new URLSearchParams({q:String(e??``)}).toString()}`,{signal:i?.signal}))}}function X({iso:e,className:t}){let n=fe(),r=de();return n?n(e):/* @__PURE__ */ V(`time`,{dateTime:e,className:t,children:L(e,{timeZone:r})})}function Z(e,t){return String(e).replace(/[{]([A-Za-z0-9_]+)[}]/g,(e,n)=>n in t?String(t[n]):e)}var Q={offline:`We could not reach support. Check your connection and try again.`,attachOne:`You can attach one file.`,attachMany:`You can attach up to {count} files.`,typeNotAccepted:`{name} is a file type we cannot accept.`,tooLarge:`{name} is larger than {size}.`,thisFile:`This file`,alreadyAttached:`{name} is already attached.`};function $(e,t,n=Q.offline){if(e instanceof W){if(e.code===`network`)return n;if(e.code!==`unknown`)return e.message}return t}var ye={heading:`Help centre`,searchPlaceholder:`Search help articles`,searchLabel:`Search help articles`,tableLabel:`Help articles`,columnArticle:`Article`,columnUpdated:`Last updated`,listError:`We could not load the help articles.`,settingsError:`We could not load the help centre.`,retry:`Try again`,emptyTitle:`No articles yet`,emptyText:`Help articles from the support team show here.`,noMatchTitle:`No articles match`,noMatchText:`Try other words.`},be={back:`Back to help`,published:`Published {date}`,updated:`Updated {date}`,loadError:`We could not load this article.`,notFoundTitle:`This article could not be found.`,retry:`Try again`},xe=`article_not_found`,Se=`{date}`;function Ce({template:e,iso:t}){let n=e.indexOf(Se);return n===-1?/* @__PURE__ */ H(B,{children:[e,` `,/* @__PURE__ */ V(X,{iso:t})]}):/* @__PURE__ */ H(B,{children:[e.slice(0,n),/* @__PURE__ */ V(X,{iso:t}),e.slice(n+6)]})}function we({client:e,slug:n,onBack:i}){let a=Y(`helpArticle`,be),c=Y(`shared`,Q),[u,d]=s({article:null,loading:!0,error:null}),p=o(null),m=t(()=>{p.current?.abort();let t=new AbortController;p.current=t,d({article:null,loading:!0,error:null}),e.get(n,{signal:t.signal}).then(e=>{t.signal.aborted||d({article:e,loading:!1,error:null})},e=>{t.signal.aborted||d({article:null,loading:!1,error:e})})},[e,n]);r(()=>(m(),()=>p.current?.abort()),[m]);let{article:h,loading:g,error:_}=u,v=_?.code===xe;return/* @__PURE__ */ H(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-busy":g||void 0,children:[i&&/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,leftIcon:`arrow-left`,onClick:i,className:`align-self-start`,children:a.back}),g&&/* @__PURE__ */ V(A,{height:160}),v&&/* @__PURE__ */ V(b,{variant:`card`,icon:`search`,title:a.notFoundTitle}),_&&!v&&/* @__PURE__ */ H(l,{tone:`danger`,children:[$(_,a.loadError,c.offline),` `,/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:m,children:a.retry})]}),h&&/* @__PURE__ */ H(`article`,{className:`d-flex flex-column gap-3`,children:[/* @__PURE__ */ V(`h2`,{className:`h4 mb-0`,children:h.title}),/* @__PURE__ */ H(`div`,{className:`d-flex flex-wrap gap-3 wui-text-sm text-body-secondary`,children:[h.publishedDateTimeUtc!=null&&/* @__PURE__ */ V(`span`,{children:/* @__PURE__ */ V(Ce,{template:a.published,iso:h.publishedDateTimeUtc})}),/* @__PURE__ */ V(`span`,{children:/* @__PURE__ */ V(Ce,{template:a.updated,iso:h.updatedDateTimeUtc})})]}),/* @__PURE__ */ V(D,{value:h.bodyMarkdown})]})]})}function Te(e,t){let[n,i]=s(e);return r(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[e,t]),n}var Ee=10,De=300,Oe=2;function ke(){let e=o(null),n=t(()=>{e.current?.abort(),e.current=null},[]);r(()=>n,[n]);let i=t((t,n,r)=>{e.current?.abort();let i=new AbortController;e.current=i,t(i.signal).then(e=>{i.signal.aborted||n(e)},e=>{i.signal.aborted||r(e)})},[]);return a(()=>({run:i,cancel:n}),[i,n])}function Ae(e){let[n,i]=s({data:null,loading:!0,error:null}),[a,o]=s({page:1,pageSize:Ee}),[c,l]=s({data:null,loading:!0,error:null}),[u,d]=s(``),[f,p]=s({term:``,data:[],loading:!1,error:null}),m=Te(u.trim(),De),h=ke(),g=ke(),_=ke(),{page:v,pageSize:y}=a,b=n.data?.searchAvailable===!0,x=b&&m.length>=Oe,S=c.data?.totalPages??0,C=t(()=>{i(e=>({...e,loading:!0,error:null})),h.run(t=>e.settings({signal:t}),e=>i({data:e,loading:!1,error:null}),e=>i({data:null,loading:!1,error:e}))},[e,h]),w=t(()=>{l(e=>({...e,loading:!0,error:null})),g.run(t=>e.list({page:v,pageSize:y},{signal:t}),e=>l({data:e,loading:!1,error:null}),e=>l(t=>({...t,loading:!1,error:e})))},[e,v,y,g]),T=t(()=>{p(e=>({term:m,data:e.data,loading:!0,error:null})),_.run(t=>e.search(m,{signal:t}),e=>p({term:m,data:e,loading:!1,error:null}),e=>p({term:m,data:[],loading:!1,error:e}))},[e,m,_]);r(()=>{C()},[C]),r(()=>{w()},[w]),r(()=>{x?T():_.cancel()},[T,x,_]);let E=t(e=>{d(e),e.trim()===``&&_.cancel()},[_]);r(()=>{S>0&&v>S&&o(e=>({...e,page:S}))},[v,S]);let D=t(e=>o(t=>({...t,page:e})),[]),O=t(e=>o({page:1,pageSize:e}),[]);return{settings:{data:n.data,loading:n.loading,error:n.error,reload:C},articles:{items:c.data?.items??[],page:v,pageSize:y,totalCount:c.data?.totalCount??0,totalPages:S,loading:c.loading,error:c.error,setPage:D,setPageSize:O,reload:w},search:{enabled:b,query:u,setQuery:E,active:x,results:f.data,loading:x&&(f.loading||f.term!==m),error:x?f.error:null,reload:T}}}function je({client:e,onOpen:t,linkTo:n}){let r=Y(`helpCentre`,ye),i=Y(`shared`,Q),{settings:a,articles:o,search:s}=Ae(e),c=s.active,u=c?s.results:o.items,d=c?s.loading:o.loading,p=c?s.error:o.error,m=c?s.reload:o.reload,h=(e,n)=>{t&&(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t(n)))},g=[{key:`title`,label:r.columnArticle,render:e=>/* @__PURE__ */ H(`div`,{className:`d-flex flex-column min-w-0`,children:[n?/* @__PURE__ */ V(E,{href:n(e.slug),animation:`none`,className:`fw-semibold text-break`,onClick:t=>h(t,e.slug),children:e.title}):/* @__PURE__ */ V(f,{variant:`link`,size:`sm`,className:`fw-semibold text-break text-start p-0`,onClick:()=>t?.(e.slug),children:e.title}),/* @__PURE__ */ V(`span`,{className:`wui-text-sm text-body-secondary`,children:e.summary})]})},{key:`updatedDateTimeUtc`,label:r.columnUpdated,cellClassName:`wui-text-sm text-body-secondary text-nowrap`,render:e=>/* @__PURE__ */ V(X,{iso:e.updatedDateTimeUtc})}],_={page:o.page,totalPages:Math.max(1,o.totalPages),pageSize:o.pageSize,total:o.totalCount,setPage:o.setPage,setPageSize:o.setPageSize};return/* @__PURE__ */ H(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-labelledby":`help-centre-title`,children:[/* @__PURE__ */ V(`h2`,{id:`help-centre-title`,className:`h5 mb-0`,children:r.heading}),a.error&&/* @__PURE__ */ H(l,{tone:`warning`,children:[$(a.error,r.settingsError,i.offline),` `,/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:a.reload,children:r.retry})]}),s.enabled&&/* @__PURE__ */ V(k,{value:s.query,onChange:s.setQuery,placeholder:r.searchPlaceholder,ariaLabel:r.searchLabel}),p&&/* @__PURE__ */ H(l,{tone:`danger`,children:[$(p,r.listError,i.offline),` `,/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:m,children:r.retry})]}),/* @__PURE__ */ V(v,{columns:g,rows:u,loading:d,skeletonRows:4,ariaLabel:r.tableLabel,stackOnMobile:!0,pagination:c?void 0:_,empty:c?/* @__PURE__ */ V(b,{variant:`table`,icon:`search`,title:r.noMatchTitle,description:r.noMatchText}):/* @__PURE__ */ V(b,{variant:`table`,icon:`message-square`,title:r.emptyTitle,description:r.emptyText})})]})}function Me(e){return(e?.allowedContentTypes??[]).join(`,`)}function Ne(e,t){if(t.length===0)return!0;let n=(e||``).toLowerCase();return t.some(e=>{let t=e.toLowerCase();return t.endsWith(`/*`)?n.startsWith(t.slice(0,-1)):n===t})}function Pe(e,t,n=Q){let r=e??[],i=t?.maxAttachmentsPerMessage??0,a=t?.maxAttachmentBytes??0,o=t?.allowedContentTypes??[];if(i>0&&r.length>i)return i===1?n.attachOne:Z(n.attachMany,{count:i});for(let e of r){let t=e.name||n.thisFile;if(!Ne(e.type,o))return Z(n.typeNotAccepted,{name:t});if(a>0&&e.size>a)return Z(n.tooLarge,{name:t,size:R(a)})}return null}var Fe=(e,t)=>e===1?t.attachOne:Z(t.attachMany,{count:e});function Ie(e){return`${e.name}|${e.size}|${e.lastModified}`}function Le(e,t,n,r=Q){let i=n?.maxAttachmentsPerMessage??0,a=new Set(e.map(Ie)),o=[],s=null;for(let e of t){let t=Ie(e);a.has(t)?s??=e.name:(a.add(t),o.push(e))}let c=i>0?Math.max(0,i-e.length):o.length,l=[...e,...o.slice(0,c)];return{files:l,notice:(o.length>c?Fe(i,r):null)??Pe(l,n,r)??(s?Z(r.alreadyAttached,{name:s}):``)}}function Re(e){let t=Array.from(e.clipboardData?.items??[]),n=Date.now();return t.filter(e=>e.kind===`file`&&e.type.startsWith(`image/`)).map(e=>e.getAsFile()).filter(Boolean).map((e,t)=>{let r=(e.type.split(`/`)[1]||`png`).replace(`jpeg`,`jpg`);return new File([e],`pasted-image-${n}-${t+1}.${r}`,{type:e.type})})}var ze=80;function Be(e,t){let n=Math.min(t,ze),r=(e??``).split(/\r?\n/).find(e=>e.trim()!==``);if(r===void 0)return``;let i=r.replace(/\s+/g,` `).trim();if(i.length<=n)return i;let a=i.slice(0,n+1).lastIndexOf(` `);return(a>0?i.slice(0,a):i.slice(0,n)).replace(/[ ,;:.-]+$/,``)}function Ve({id:e,label:t=`Attachments`,files:n,onChange:r,config:i,error:a}){let o=i?.maxAttachmentBytes??0,s=o>0?Math.max(.1,Math.round(o/1048576*10)/10):0;return/* @__PURE__ */ V(x,{id:e,label:t,optional:!0,multiple:!0,value:n,onChange:r,accept:Me(i),maxSizeMb:s,validate:!1,error:a||void 0})}var He={title:`These may already answer your question`};function Ue({items:e}){let t=Y(`suggestedAnswers`,He);return e.length===0?null:/* @__PURE__ */ V(p,{variant:`filled`,padding:`sm`,title:t.title,children:/* @__PURE__ */ V(`ul`,{className:`list-unstyled mb-0 d-flex flex-column gap-2`,children:e.map(e=>/* @__PURE__ */ H(`li`,{children:[/* @__PURE__ */ V(`div`,{className:`fw-semibold`,children:e.title}),/* @__PURE__ */ V(`div`,{className:`small text-body-secondary`,children:e.summary})]},e.title))})})}var We={bodyRequired:`Enter what happened.`,sendFailed:`Your ticket did not send. Please try again.`,messageLabel:`Message`,messagePlaceholder:`What happened, and what did you expect to happen?`,messageHint:`You can paste an image into the message.`,subjectLabel:`Subject`,subjectPlaceholder:`A short summary`,subjectHint:`Filled in from your message. You can change it.`,categoryLabel:`Category (optional)`,categoryPlaceholder:`Choose a category`,categoryHint:`Not sure? Leave it empty and we will sort it.`},Ge=500,Ke=3,qe=5;function Je(e,t){return t&&e.includes(t)?t:``}function Ye({id:e,config:t,defaultCategory:n,initialValues:i,onValuesChange:a,extraFiles:o=[],onSubmit:c,onBusyChange:u,children:d}){let f=Y(`ticketForm`,We),p=Y(`shared`,Q),m=t?.categories??[],h=t?.subjectMaxLength??1/0,[g,_]=s(()=>i?.category??Je(m,n)),[v,y]=s(i?.body??``),[b,x]=s(()=>i?.subject||Be(i?.body??``,h)),[S,C]=s(()=>{let e=(i?.subject??``).trim();return e!==``&&e!==Be(i?.body??``,h)}),[w,E]=s(i?.files??[]),[D,O]=s({}),[k,A]=s(``),j=J(),[M,N]=s(``),[F,I]=s([]),L=Te(b.trim(),Ge);r(()=>{a?.({category:g,subject:b,body:v,files:w})},[g,b,v,w,a]),r(()=>{N(L)},[L]),r(()=>{if(M.length<Ke){I([]);return}let e=!0,t=new AbortController;return I([]),j.getSuggestions(M,{signal:t.signal}).then(t=>{e&&I(Array.isArray(t)?t.slice(0,qe):[])},()=>{e&&I([])}),()=>{e=!1,t.abort()}},[j,M]);let R=e=>{E(e),O(n=>({...n,files:Pe([...o,...e],t,p)??void 0}))},z=e=>{let t=Re(e);t.length>0&&R([...w,...t])},B=e=>{let t=e.target.value;y(t),S||x(Be(t,h)),D.body&&O(e=>({...e,body:t.trim()?void 0:f.bodyRequired}))},te=e=>{let t=e.target.value;x(t),C(t.trim()!==``)};function U(){let e={};v.trim()||(e.body=f.bodyRequired);let n=Pe([...o,...w],t,p);return n&&(e.files=n),O(e),Object.keys(e).length===0}async function W(e){if(e.preventDefault(),A(``),U()){u?.(!0);try{await c({category:g,subject:b.trim()||Be(v,h),body:v.trim(),files:w})}catch(e){A($(e,f.sendFailed,p.offline))}finally{u?.(!1)}}}return/* @__PURE__ */ H(`form`,{id:e,onSubmit:W,noValidate:!0,className:`d-flex flex-column gap-3`,children:[k&&/* @__PURE__ */ V(l,{tone:`danger`,children:k}),/* @__PURE__ */ V(P,{id:`${e}-body`,label:f.messageLabel,required:!0,rows:6,maxLength:t?.bodyMaxLength,showCount:!0,placeholder:f.messagePlaceholder,value:v,onChange:B,onPaste:z,helperText:f.messageHint,error:D.body}),/* @__PURE__ */ V(T,{id:`${e}-subject`,label:f.subjectLabel,maxLength:t?.subjectMaxLength,showCount:!0,placeholder:f.subjectPlaceholder,helperText:f.subjectHint,value:b,onChange:te,onBlur:()=>N(b.trim())}),/* @__PURE__ */ V(Ue,{items:F}),/* @__PURE__ */ V(ee,{id:`${e}-category`,label:f.categoryLabel,value:g,onChange:_,options:m.map(e=>({value:e,label:e})),placeholder:f.categoryPlaceholder,helperText:f.categoryHint,error:D.category}),d,/* @__PURE__ */ V(Ve,{id:`${e}-files`,files:w,onChange:R,config:t,error:D.files})]})}var Xe={captureEmpty:`The page capture came back empty.`,retake:`Retake`,removeScreenshot:`Remove screenshot`,addScreenshot:`Add a screenshot`,screenshotNote:`Only what is on your screen now. You can remove it before sending.`,screenshotFailed:`We could not take a screenshot of this page. You can attach an image instead, or send the report without one.`,screenshotTitle:`Screenshot`,screenshotLabel:`Screenshot of the page you were on`,viewTicket:`View ticket`,close:`Close`,cancel:`Cancel`,submit:`Submit`,takingScreenshot:`Taking a screenshot`,title:`Report an issue`,subtitle:`Tell us what went wrong. You can add a screenshot of this page if it helps.`,confirmDiscard:`Discard this report?`,createdTitle:`Ticket {number} is with the support team`,createdText:`We reply by email. You can follow the ticket on your support page.`,configError:`We could not load the support settings.`,loading:`Loading the form.`},Ze=`supportCapture`,Qe={zIndex:`var(--wui-z-fixed)`,bottom:0,insetInlineEnd:0},$e={zIndex:`var(--wui-z-fixed)`},et={maxWidth:`20rem`},tt=e=>e.dataset?.[Ze]===`exclude`||e.matches?.(`.modal-backdrop`)?!1:!(e.matches?.(`.modal`)&&e.querySelector?.(`[data-support-capture="exclude"]`)),nt=()=>new Promise(e=>requestAnimationFrame(()=>e()));async function rt(e){let t=await te(document.body,{filter:tt,pixelRatio:Math.min(window.devicePixelRatio||1,2),style:{overflow:`visible`,paddingRight:`0px`}});if(!t)throw Error(e);return new File([t],`screenshot.png`,{type:`image/png`})}function it({t:e,file:t,failed:n,disabled:i,hintId:a,controlRef:o,onAdd:c,onRemove:u}){let[d,p]=s(null);return r(()=>{if(!t)return;let e=URL.createObjectURL(t);return p(e),()=>URL.revokeObjectURL(e)},[t]),/* @__PURE__ */ H(`div`,{className:`d-flex flex-column gap-2`,children:[/* @__PURE__ */ V(`span`,{className:`wui-text-sm fw-semibold`,children:e.screenshotTitle}),t&&d&&/* @__PURE__ */ V(`img`,{src:d,alt:e.screenshotLabel,className:`d-block w-100 border rounded`,style:et}),/* @__PURE__ */ V(`div`,{ref:o,className:`d-flex flex-wrap gap-2`,children:t?/* @__PURE__ */ H(B,{children:[/* @__PURE__ */ V(f,{variant:`outline`,size:`sm`,leftIcon:`refresh-cw`,onClick:c,disabled:i,"aria-describedby":a,children:e.retake}),/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,leftIcon:`x`,onClick:u,disabled:i,children:e.removeScreenshot})]}):/* @__PURE__ */ V(f,{variant:`outline`,size:`sm`,leftIcon:`camera`,onClick:c,disabled:i,"aria-describedby":a,children:e.addScreenshot})}),/* @__PURE__ */ V(`span`,{id:a,className:`wui-text-sm text-body-secondary`,children:e.screenshotNote}),n&&/* @__PURE__ */ V(l,{tone:`info`,children:e.screenshotFailed})]})}function at({label:e=`Report an issue`,floating:t=!1,compact:n=!1,defaultCategory:a=`Bug report`,appVersion:c,getTicketHref:u,onOpenTicket:d,onCreated:p,className:m,style:h}){let g=Y(`reportIssue`,Xe),_=Y(`shared`,Q),v=J(),{config:y,error:b}=me(),x=`support-report-${i().replace(/[^a-zA-Z0-9-]/g,``)}`,[C,w]=s(!1),[T,E]=s(!1),[D,k]=s(null),[ee,A]=s(!1),[j,M]=s(!1),[N,P]=s(null),[F,I]=s(null),L=o(null),R=o(!1);r(()=>{!T&&R.current&&(R.current=!1,L.current?.querySelector(`button`)?.focus())},[T]);function z(){P(null),k(null),A(!1),I(null),w(!0)}async function te(){E(!0),A(!1),await nt(),await nt();try{k(await rt(g.captureEmpty))}catch{k(null),A(!0)}finally{R.current=!0,E(!1)}}let U=()=>{j||(w(!1),k(null),A(!1),P(null),I(null))};async function W(e){let t=await v.createTicket({...e,pageUrl:window.location.href,userAgent:navigator.userAgent,appVersion:c,screenshots:D?[D]:[]});P(t),k(null),p?.(t)}let ne=!N&&(!!D||!!F&&(F.subject.trim()!==``||F.body.trim()!==``||F.files.length>0)),re=N&&u?u(N.id):void 0,G=N&&(re||d)?/* @__PURE__ */ V(f,{href:re,onClick:re?void 0:()=>{w(!1),P(null),d(N)},children:g.viewTicket}):null,K=N?/* @__PURE__ */ H(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ V(f,{variant:`soft`,onClick:U,children:g.close}),G]}):/* @__PURE__ */ H(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ V(f,{variant:`soft`,onClick:U,disabled:j,children:g.cancel}),/* @__PURE__ */ V(f,{type:`submit`,form:x,loading:j,disabled:!y,children:g.submit})]}),q=n?/* @__PURE__ */ V(S,{icon:`bug`,label:e,order:`secondary`,size:`sm`,variant:`soft`,stacked:t,className:t?m:void 0,style:t?h:void 0,disabled:T,onClick:z,"aria-haspopup":`dialog`}):/* @__PURE__ */ V(f,{leftIcon:`bug`,variant:t?`solid`:`outline`,disabled:T,onClick:z,"aria-haspopup":`dialog`,children:e});return/* @__PURE__ */ H(B,{children:[t&&n?q:/* @__PURE__ */ V(`span`,{"data-support-capture":`exclude`,className:[t?`position-fixed m-3`:`d-inline-block`,m].filter(Boolean).join(` `),style:t?{...Qe,...h}:h,children:q}),T&&/* @__PURE__ */ H(`div`,{"data-support-capture":`exclude`,role:`status`,className:`position-fixed top-0 start-50 translate-middle-x mt-3 d-flex align-items-center gap-2 px-3 py-2 bg-body border rounded-pill shadow-sm wui-text-sm`,style:$e,children:[/* @__PURE__ */ V(`span`,{className:`spinner-border spinner-border-sm`,"aria-hidden":`true`}),g.takingScreenshot]}),/* @__PURE__ */ V(O,{open:C,size:`lg`,title:g.title,subtitle:g.subtitle,headerIcon:`bug`,confirmDiscard:g.confirmDiscard,dirty:ne&&!j,onClose:U,footer:K,"data-support-capture":`exclude`,children:N?/* @__PURE__ */ V(l,{tone:`success`,role:`status`,title:Z(g.createdTitle,{number:N.number}),children:g.createdText}):y?/* @__PURE__ */ V(Ye,{id:x,config:y,defaultCategory:a,initialValues:F,onValuesChange:I,extraFiles:D?[D]:[],onSubmit:W,onBusyChange:M,children:/* @__PURE__ */ V(it,{t:g,file:D,failed:ee,disabled:j||T,hintId:`${x}-screenshot-hint`,controlRef:L,onAdd:te,onRemove:()=>k(null)})}):/* @__PURE__ */ V(l,{tone:b?`danger`:`info`,children:b?$(b,g.configError,_.offline):g.loading})})]})}var ot={title:`New ticket`,subtitle:`Tell us what you need. We reply by email and on this page.`,confirmDiscard:`Discard this ticket?`,cancel:`Cancel`,send:`Send ticket`};function st({open:e,onClose:t,onCreated:n,config:r,defaultCategory:a,appVersion:o}){let c=Y(`newTicketModal`,ot),l=J(),u=`support-new-${i().replace(/[^a-zA-Z0-9-]/g,``)}`,[d,p]=s(!1),[m,h]=s(null),g=!!m&&(m.subject.trim()!==``||m.body.trim()!==``||m.files.length>0);async function _(e){n(await l.createTicket({...e,userAgent:typeof navigator>`u`?void 0:navigator.userAgent,appVersion:o}))}return/* @__PURE__ */ V(O,{open:e,size:`lg`,title:c.title,subtitle:c.subtitle,headerIcon:`message-square`,confirmDiscard:c.confirmDiscard,dirty:g&&!d,onClose:()=>{d||t()},footer:/* @__PURE__ */ H(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ V(f,{variant:`soft`,onClick:t,disabled:d,children:c.cancel}),/* @__PURE__ */ V(f,{type:`submit`,form:u,loading:d,children:c.send})]}),children:e&&/* @__PURE__ */ V(Ye,{id:u,config:r,defaultCategory:a,onSubmit:_,onBusyChange:p,onValuesChange:h})})}var ct={Open:`info`,InProgress:`info`,WaitingOnCustomer:`warning`,Resolved:`success`,Closed:`success`,Cancelled:`neutral`};function lt(e){return ct[e]??`neutral`}var ut={loading:`Loading {name}`,failed:`Could not load this file. Click to try again.`},dt=6e4,ft=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`application/pdf`];function pt({attachment:e}){let t=Y(`attachmentThumb`,ut),n=J(),[r,i]=s(!1),[a,o]=s(!1);async function c(){i(!0),o(!1);let t=ft.includes(e.contentType)?window.open(``,`_blank`):null;t&&(t.opener=null);try{let r=await n.fetchAttachment(e.id),i=URL.createObjectURL(r);if(setTimeout(()=>URL.revokeObjectURL(i),dt),t)t.location.href=i;else{let t=document.createElement(`a`);t.href=i,t.download=e.fileName,t.click()}}catch{t?.close(),o(!0)}finally{i(!1)}}let l=Number.isFinite(e.sizeBytes)?R(e.sizeBytes):`-`;return/* @__PURE__ */ H(B,{children:[/* @__PURE__ */ V(m,{leadingIcon:a?`x-circle`:`paperclip`,label:r?/* @__PURE__ */ H(B,{children:[/* @__PURE__ */ V(j,{size:`sm`,label:Z(t.loading,{name:e.fileName})}),` `,e.fileName]}):e.fileName,onClick:c,disabled:r,"aria-busy":r||void 0,title:`${e.fileName}, ${l}`}),a&&/* @__PURE__ */ V(`span`,{role:`status`,className:`wui-text-xs text-danger align-self-center`,children:t.failed})]})}var mt={conversation:`Conversation`,you:`You`,supportTeam:`Support team`,supportBadge:`Support`},ht={whiteSpace:`pre-wrap`,overflowWrap:`anywhere`};function gt({messages:e}){let t=Y(`messageThread`,mt);return/* @__PURE__ */ V(`ol`,{className:`list-unstyled d-flex flex-column gap-3 mb-0`,"aria-label":t.conversation,children:e.map(e=>{let n=/* @__PURE__ */ V(X,{iso:e.createdDateTimeUtc,className:`wui-text-xs text-body-secondary text-nowrap`});if(e.authorKind===`System`)return/* @__PURE__ */ H(`li`,{className:`text-center wui-text-xs text-body-secondary`,"data-author":`system`,children:[/* @__PURE__ */ V(`span`,{className:`d-block`,children:e.body}),n]},e.id);let r=e.authorKind===`Customer`,i=e.authorName||(r?t.you:t.supportTeam);return/* @__PURE__ */ H(`li`,{className:`d-flex align-items-start gap-2${r?` flex-row-reverse`:``}`,"data-author":r?`customer`:`agent`,children:[/* @__PURE__ */ V(u,{name:i,size:32,tone:r?`neutral`:`primary`}),/* @__PURE__ */ H(p,{className:`flex-grow-1 border`,padding:`sm`,variant:r?`flat`:`accent`,style:{minWidth:0},children:[/* @__PURE__ */ H(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2 mb-2`,children:[/* @__PURE__ */ H(`span`,{className:`d-inline-flex flex-wrap align-items-center gap-2 fw-semibold wui-text-sm text-break`,children:[i,!r&&/* @__PURE__ */ V(d,{tone:`primary`,children:t.supportBadge})]}),n]}),/* @__PURE__ */ V(`div`,{className:`wui-text-sm`,style:ht,children:e.body}),e.attachments?.length>0&&/* @__PURE__ */ V(`div`,{className:`d-flex flex-wrap gap-2 mt-2`,children:e.attachments.map(e=>/* @__PURE__ */ V(pt,{attachment:e},e.id))})]})]},e.id)})})}var _t={solved:`You told us this solved your problem.`,notSolved:`You told us this did not solve your problem.`,sendFailed:`Your rating did not send. Please try again.`,commentLabel:`Anything to add?`,commentHint:`Optional. Your comment goes to the support team.`,yes:`Yes, it is solved`,no:`No, it is not`,heading:`Did this solve your problem?`,yourComment:`Your comment:`};function vt({satisfaction:e,comment:t,canRate:n=!1,commentMaxLength:r,onRate:a}){let o=Y(`ratingPanel`,_t),c=Y(`shared`,Q),u=i(),[d,m]=s(``),[h,g]=s(null),[_,v]=s(``);if(e)return/* @__PURE__ */ H(l,{tone:e===`Satisfied`?`success`:`info`,role:`status`,children:[e===`Satisfied`?o.solved:o.notSolved,t?/* @__PURE__ */ H(`span`,{className:`d-block mt-1`,children:[o.yourComment,` `,t]}):null]});if(!n)return null;async function y(e){v(``),g(e);try{await a({satisfaction:e,comment:d})}catch(e){v($(e,o.sendFailed,c.offline))}finally{g(null)}}return/* @__PURE__ */ V(p,{padding:`sm`,className:`border`,title:o.heading,children:/* @__PURE__ */ H(`div`,{className:`d-flex flex-column gap-2`,children:[_&&/* @__PURE__ */ V(l,{tone:`danger`,children:_}),/* @__PURE__ */ V(P,{id:`${u}-comment`,label:o.commentLabel,rows:2,maxLength:r,value:d,onChange:e=>m(e.target.value),helperText:o.commentHint}),/* @__PURE__ */ H(`div`,{className:`d-flex flex-wrap gap-2`,children:[/* @__PURE__ */ V(f,{variant:`outline`,leftIcon:`check-circle`,loading:h===`Satisfied`,disabled:h!==null,onClick:()=>y(`Satisfied`),children:o.yes}),/* @__PURE__ */ V(f,{variant:`outline`,leftIcon:`x-circle`,loading:h===`Unsatisfied`,disabled:h!==null,onClick:()=>y(`Unsatisfied`),children:o.no})]})]})})}var yt={emptyReply:`Write a message before you send it.`,sendFailed:`Your reply did not send. Please try again.`,replyLabel:`Your reply`,hintReopens:`Sending a reply reopens this ticket. You can paste an image into the message.`,hint:`You can paste an image into the message.`,attachedFiles:`Attached files`,removeFile:`Remove {name}`,attach:`Attach a file`,send:`Send reply`,formLabel:`Reply to this ticket`};function bt({onSend:e,config:t,reopens:n=!1}){let r=Y(`replyBox`,yt),a=Y(`shared`,Q),o=i(),[u,d]=s(``),[p,g]=s([]),[_,v]=s(``),[y,b]=s(``),[x,S]=s(!1),C=e=>{let n=Le(p,e,t,a);g(n.files),v(n.notice)},w=e=>{let n=p.filter((t,n)=>n!==e);g(n),v(Pe(n,t,a)??``)},T=e=>{let t=Re(e);t.length>0&&C(t)};async function E(n){n.preventDefault();let i=u.trim();if(!i){b(r.emptyReply);return}let o=Pe(p,t,a);if(o)v(o);else{b(``),S(!0);try{await e({body:i,files:p}),d(``),g([]),v(``)}catch(e){b($(e,r.sendFailed,a.offline))}finally{S(!1)}}}let D=y||_;return/* @__PURE__ */ H(`form`,{onSubmit:E,noValidate:!0,className:`d-flex flex-column gap-2 flex-grow-1 min-w-0`,"aria-label":r.formLabel,children:[D&&/* @__PURE__ */ V(l,{tone:`danger`,children:D}),/* @__PURE__ */ V(P,{id:`${o}-body`,label:r.replyLabel,rows:2,autoGrow:!0,maxLength:t?.bodyMaxLength,value:u,onChange:e=>{d(e.target.value),b(``)},onPaste:T,helperText:n?r.hintReopens:r.hint,required:!0}),p.length>0&&/* @__PURE__ */ V(h,{label:r.attachedFiles,children:p.map((e,t)=>/* @__PURE__ */ V(m,{leadingIcon:`paperclip`,label:e.name,removeLabel:Z(r.removeFile,{name:e.name}),onRemove:()=>w(t)},Ie(e)))}),/* @__PURE__ */ H(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2`,children:[/* @__PURE__ */ V(c,{iconVariant:`bulk`,icon:`paperclip`,label:r.attach,multiple:t?.maxAttachmentsPerMessage!==1,accept:Me(t),onFiles:C}),/* @__PURE__ */ V(f,{type:`submit`,leftIcon:`send`,loading:x,children:r.send})]})]})}var xt={reopenFailed:`The ticket did not reopen. Please try again.`,withdrawFailed:`The request was not withdrawn. Please try again.`,back:`Back to tickets`,loadError:`We could not load this ticket.`,retry:`Try again`,fieldStatus:`Status`,fieldCategory:`Category`,fieldTicket:`Ticket`,fieldOpened:`Opened`,fieldUpdated:`Last update`,openedLabel:`Opened`,summaryLabel:`Ticket summary`,detailsLabel:`Ticket details`,detailsTitle:`Ticket details`,timeZoneNote:`Times are shown in {zone}.`,mergedText:`This ticket was merged into {number}. The conversation carries on there.`,openMerged:`Open {number}`,resolvedHint:`If you still need help, reopen the ticket or send a reply.`,waitingHint:`We need your answer to carry on. Reply below and the ticket goes back to our team.`,openHint:`Our team marks this resolved once your question is answered. Replying reopens it.`,reopen:`Reopen ticket`,withdraw:`Withdraw request`,withdrawTitle:`Withdraw this request?`,withdrawMessage:`Our team will stop working on this ticket. You can open a new ticket later if you still need help.`,withdrawConfirm:`Withdraw request`,withdrawCancel:`Keep request`,merged:`Merged into this ticket`};function St({ticketId:e,onBack:t,onChanged:n,onOpenTicket:r}){let{config:i}=me(),a=Y(`ticketDetail`,xt),o=Y(`shared`,Q),c=de(),u=fe(),{ticket:d,loading:m,error:h,reload:_,reply:v,reopen:b,cancel:x,rate:S}=_e(e),[T,E]=s(!1),[D,O]=s(!1),[k,ee]=s(!1),[j,N]=s(``),P=async e=>{let t=await e();return n?.(),t};async function F(){N(``),E(!0);try{await P(b)}catch(e){N($(e,a.reopenFailed,o.offline))}finally{E(!1)}}async function I(){N(``),ee(!0);try{await P(x)}catch(e){N($(e,a.withdrawFailed,o.offline))}finally{ee(!1),O(!1)}}let L=/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,leftIcon:`arrow-left`,onClick:t,className:`align-self-start`,children:a.back});if(!d)return/* @__PURE__ */ H(`section`,{className:`d-flex flex-column gap-3`,"aria-busy":m||void 0,children:[L,h?/* @__PURE__ */ H(l,{tone:`danger`,children:[$(h,a.loadError,o.offline),` `,/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:_,children:a.retry})]}):/* @__PURE__ */ V(A,{height:160})]});let R=lt(d.status),B=[{key:`status`,label:a.fieldStatus,value:d.statusLabel?/* @__PURE__ */ V(M,{label:d.statusLabel,tone:R}):`-`},{key:`category`,label:a.fieldCategory,value:d.category||`-`},{key:`ticket`,label:a.fieldTicket,value:d.number},{key:`opened`,label:a.fieldOpened,value:/* @__PURE__ */ V(X,{iso:d.createdDateTimeUtc})},{key:`updated`,label:a.fieldUpdated,value:/* @__PURE__ */ V(X,{iso:d.updatedDateTimeUtc})}];return/* @__PURE__ */ H(`section`,{className:`d-flex flex-column gap-3`,"aria-labelledby":`support-ticket-${d.id}`,children:[L,/* @__PURE__ */ H(`div`,{className:`row g-3`,children:[/* @__PURE__ */ H(`div`,{className:`col-12 col-lg-8 d-flex flex-column gap-3`,children:[/* @__PURE__ */ H(`header`,{className:`d-flex flex-column gap-2`,children:[/* @__PURE__ */ H(`div`,{className:`d-flex flex-wrap align-items-center gap-2`,children:[/* @__PURE__ */ V(`h2`,{id:`support-ticket-${d.id}`,className:`h5 mb-0 text-break`,children:d.subject}),d.statusLabel&&/* @__PURE__ */ V(M,{label:d.statusLabel,tone:R})]}),/* @__PURE__ */ H(`ul`,{className:`list-unstyled d-flex flex-wrap gap-3 mb-0 wui-text-sm text-body-secondary`,"aria-label":a.summaryLabel,children:[d.number&&/* @__PURE__ */ H(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ V(w,{variant:`bulk`,name:`receipt-text`,size:16}),d.number]}),d.category&&/* @__PURE__ */ H(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ V(w,{variant:`bulk`,name:`folder-2`,size:16}),d.category]}),/* @__PURE__ */ H(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ V(w,{variant:`bulk`,name:`calendar-1`,size:16}),a.openedLabel,` `,/* @__PURE__ */ V(X,{iso:d.createdDateTimeUtc})]})]}),u===null&&/* @__PURE__ */ V(`p`,{className:`wui-text-xs text-body-secondary mb-0`,children:Z(a.timeZoneNote,{zone:z(c)})})]}),j&&/* @__PURE__ */ V(l,{tone:`danger`,children:j}),d.mergedInto&&/* @__PURE__ */ H(l,{tone:`info`,role:`status`,children:[Z(a.mergedText,{number:d.mergedInto.number}),` `,r&&/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:()=>r(d.mergedInto.id),children:Z(a.openMerged,{number:d.mergedInto.number})})]}),d.canReopen&&/* @__PURE__ */ V(l,{tone:`success`,role:`status`,children:a.resolvedHint}),d.status===`WaitingOnCustomer`&&/* @__PURE__ */ V(l,{tone:`warning`,role:`status`,children:a.waitingHint}),!d.canReopen&&/* @__PURE__ */ V(`p`,{className:`wui-text-sm text-body-secondary mb-0`,children:a.openHint}),d.canReopen&&/* @__PURE__ */ V(f,{variant:`soft`,leftIcon:`history`,loading:T,onClick:F,className:`align-self-start`,children:a.reopen}),d.canCancel&&/* @__PURE__ */ V(f,{variant:`soft`,onClick:()=>O(!0),className:`align-self-start`,children:a.withdraw}),/* @__PURE__ */ V(g,{open:D,title:a.withdrawTitle,description:a.withdrawMessage,confirmLabel:a.withdrawConfirm,cancelLabel:a.withdrawCancel,tone:`danger`,loading:k,onConfirm:I,onClose:()=>O(!1)}),/* @__PURE__ */ V(vt,{satisfaction:d.satisfaction,comment:d.satisfactionComment,canRate:d.canRate,commentMaxLength:i?.satisfactionCommentMaxLength,onRate:e=>P(()=>S(e))}),/* @__PURE__ */ V(gt,{messages:d.messages??[]}),d.mergedTickets?.length>0&&/* @__PURE__ */ H(`section`,{"aria-labelledby":`support-merged-${d.id}`,className:`d-flex flex-column gap-1`,children:[/* @__PURE__ */ V(`h3`,{id:`support-merged-${d.id}`,className:`h6 mb-0`,children:a.merged}),/* @__PURE__ */ V(`ul`,{className:`list-unstyled d-flex flex-column gap-1 mb-0 wui-text-sm`,children:d.mergedTickets.map(e=>/* @__PURE__ */ V(`li`,{children:r?/* @__PURE__ */ H(f,{variant:`ghost`,size:`sm`,onClick:()=>r(e.id),children:[e.number,`: `,e.subject]}):`${e.number}: ${e.subject}`},e.id))})]}),!d.mergedInto&&/* @__PURE__ */ V(C,{sticky:!0,align:`start`,children:/* @__PURE__ */ V(bt,{config:i,reopens:d.canReopen,onSend:e=>P(()=>v(e))})})]}),/* @__PURE__ */ V(`aside`,{"aria-label":a.detailsLabel,className:`col-12 col-lg-4`,children:/* @__PURE__ */ H(p,{padding:`sm`,className:`border`,children:[/* @__PURE__ */ V(`h3`,{className:`h6`,children:a.detailsTitle}),/* @__PURE__ */ V(y,{columns:1,items:B})]})})]})]})}var Ct=`ticket`;function wt(){return typeof window>`u`?null:new URLSearchParams(window.location.search).get(Ct)}function Tt(e){if(typeof window>`u`)return e?`?${Ct}=${encodeURIComponent(e)}`:`?`;let t=new URL(window.location.href);return e?t.searchParams.set(Ct,e):t.searchParams.delete(Ct),`${t.pathname}${t.search}${t.hash}`}function Et(e){if(typeof window>`u`)return;let t=Tt(e);t!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,t)}var Dt={tabAll:`All`,tabOpen:`Open`,tabNeedsReply:`Needs your reply`,tabResolved:`Resolved`,tabWithdrawn:`Withdrawn`,columnSubject:`Subject`,columnStatus:`Status`,columnMessages:`Messages`,columnLastUpdate:`Last update`,loadError:`We could not load your tickets.`,retry:`Try again`,statusSelect:`Status`,filterByStatus:`Filter tickets by status`,searchPlaceholder:`Search tickets`,searchLabel:`Search tickets`,tableLabel:`Support tickets`,actions:`Actions`,openTicket:`Open ticket {subject}`,emptyTitle:`No tickets yet`,emptyText:`When you raise a ticket, it shows here with its status.`,noMatchTitle:`No tickets match`,noMatchText:`Try another search or status.`},Ot=[`tabs`,`select`,`none`];function kt({tickets:e,loading:t,error:n,onRetry:r,onOpen:i,status:a,onStatusChange:o,statusFilter:s=`tabs`,counts:u,search:d,onSearchChange:p,pagination:m}){let h=Y(`ticketList`,Dt),g=Y(`shared`,Q);F(`SupportCenter`,`statusFilter`,s,Ot);let _=[{key:`all`,label:h.tabAll,countKey:`total`},{key:`Open`,label:h.tabOpen,countKey:`open`},{key:`NeedsReply`,label:h.tabNeedsReply,countKey:`needsReply`},{key:`Resolved`,label:h.tabResolved,countKey:`resolved`},{key:`Withdrawn`,label:h.tabWithdrawn,countKey:`withdrawn`}],y=_.map(({key:e,label:t,countKey:n})=>{let r=u?.[n];return{value:e,label:r==null?t:`${t} (${r})`}}),x=(e,t)=>{e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),i(t))},S=[{key:`subject`,label:h.columnSubject,render:e=>/* @__PURE__ */ H(`div`,{className:`d-flex flex-column`,style:{minWidth:0},children:[/* @__PURE__ */ V(E,{href:Tt(e.id),animation:`none`,className:`fw-semibold text-break`,onClick:t=>x(t,e.id),children:e.subject}),/* @__PURE__ */ H(`span`,{className:`wui-text-xs text-body-secondary`,children:[e.number,`, `,e.category]})]})},{key:`status`,label:h.columnStatus,render:e=>e.statusLabel?/* @__PURE__ */ V(M,{label:e.statusLabel,tone:lt(e.status)}):`-`},{key:`messageCount`,label:h.columnMessages,cellClassName:`wui-text-sm text-body-secondary`,render:e=>e.messageCount},{key:`updatedDateTimeUtc`,label:h.columnLastUpdate,cellClassName:`wui-text-sm text-body-secondary text-nowrap`,render:e=>/* @__PURE__ */ V(X,{iso:e.updatedDateTimeUtc})}];return/* @__PURE__ */ H(`div`,{className:`d-flex flex-column gap-3`,children:[n&&/* @__PURE__ */ H(l,{tone:`danger`,children:[$(n,h.loadError,g.offline),` `,/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:r,children:h.retry})]}),/* @__PURE__ */ H(`div`,{className:`d-flex flex-column flex-md-row gap-2 align-items-md-center justify-content-between`,children:[s===`none`?null:s===`select`?/* @__PURE__ */ V(ee,{label:h.statusSelect,value:a,onChange:o,options:y,fieldClassName:`flex-shrink-0`}):/* @__PURE__ */ V(N,{tabs:_.map(({key:e,label:t,countKey:n})=>({key:e,label:t,count:u?.[n]})),value:a,onChange:o,ariaLabel:h.filterByStatus,overflow:`menu`,className:`flex-grow-1`}),/* @__PURE__ */ V(k,{value:d,onChange:p,placeholder:h.searchPlaceholder,ariaLabel:h.searchLabel})]}),/* @__PURE__ */ V(v,{columns:S,rows:e,loading:t,skeletonRows:4,ariaLabel:h.tableLabel,rowActionsLabel:h.actions,rowActions:e=>/* @__PURE__ */ V(c,{icon:`eye`,label:Z(h.openTicket,{subject:e.subject}),href:Tt(e.id),onClick:t=>x(t,e.id)}),stickyActions:!0,stackOnMobile:!0,sourceCount:u?.total??0,pagination:m,empty:/* @__PURE__ */ V(b,{variant:`table`,icon:`message-square`,title:h.emptyTitle,description:h.emptyText}),emptyFiltered:/* @__PURE__ */ V(b,{variant:`table`,icon:`search`,title:h.noMatchTitle,description:h.noMatchText})})]})}var At=300,jt=10,Mt={heading:`Your tickets`,newTicket:`New ticket`,configError:`We could not load the support settings.`,retry:`Try again`};function Nt({initialTicketId:e,defaultCategory:t,appVersion:n,status:i,defaultStatus:a=`all`,onStatusChange:o,statusFilter:c=`tabs`}){let u=Y(`supportCenter`,Mt),d=Y(`shared`,Q),{config:p,error:m,reload:h}=me(),[g,_]=s(a),v=i!==void 0,y=v?i:g,b=e=>{v||_(e),o?.(e)},[x,S]=s(``),C=Te(x.trim(),At),[w,T]=s(jt),E=`${y}|${C}|${w}`,[D,O]=s({key:E,page:1}),k=D.key===E?D.page:1,ee=e=>O({key:E,page:e}),A=he({status:y===`all`?void 0:y,search:C||void 0,page:k,pageSize:w}),{counts:j,reload:M}=ge(),[N,P]=s(()=>e||wt()),[F,I]=s(!1),L=A.totalPages;r(()=>{L>0&&k>L&&O({key:E,page:L})},[L,k,E]);let R=()=>{A.reload(),M()},z=e=>{P(e),Et(e)};if(N)return/* @__PURE__ */ V(St,{ticketId:N,onBack:()=>z(null),onChanged:R,onOpenTicket:z},N);let B={page:k,totalPages:Math.max(1,A.totalPages),pageSize:w,total:A.totalCount,setPage:ee,setPageSize:T};return/* @__PURE__ */ H(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-labelledby":`support-center-title`,children:[/* @__PURE__ */ H(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2`,children:[/* @__PURE__ */ V(`h2`,{id:`support-center-title`,className:`h5 mb-0`,children:u.heading}),/* @__PURE__ */ V(f,{leftIcon:`plus`,onClick:()=>I(!0),disabled:!p,children:u.newTicket})]}),m&&/* @__PURE__ */ H(l,{tone:`warning`,children:[$(m,u.configError,d.offline),` `,/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:h,children:u.retry})]}),/* @__PURE__ */ V(kt,{tickets:A.tickets,loading:A.loading,error:A.error,onRetry:R,onOpen:z,status:y,onStatusChange:b,statusFilter:c,counts:j,search:x,onSearchChange:S,pagination:B}),p&&/* @__PURE__ */ V(st,{open:F,onClose:()=>I(!1),config:p,defaultCategory:t,appVersion:n,onCreated:e=>{I(!1),R(),z(e.id)}})]})}var Pt={copyEmail:`Copy email`,emailCopied:`Email copied`,contactNamed:`Contact {name}`,contactSupport:`Contact support`},Ft=e=>typeof e==`string`&&e.trim()!==``;function It({className:e}){let t=Y(`supportContact`,Pt),{config:n}=me();if(!n)return null;let r=Ft(n.supportEmail),i=Ft(n.supportPhone),a=Ft(n.supportHours);if(!r&&!i&&!a)return null;let o=[`d-flex flex-wrap align-items-center gap-2 wui-text-sm`,e].filter(Boolean).join(` `);return/* @__PURE__ */ H(`section`,{className:o,"aria-label":Ft(n.supportName)?Z(t.contactNamed,{name:n.supportName}):t.contactSupport,children:[/* @__PURE__ */ V(`span`,{className:`fw-semibold`,children:Ft(n.supportName)?n.supportName:t.contactSupport}),r&&/* @__PURE__ */ H(`span`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ V(`a`,{href:`mailto:${n.supportEmail}`,className:`text-break`,children:n.supportEmail}),/* @__PURE__ */ V(_,{text:n.supportEmail,iconOnly:!0,label:t.copyEmail,copiedLabel:t.emailCopied})]}),i&&/* @__PURE__ */ V(`a`,{href:`tel:${n.supportPhone.replace(/[^\d+]/g,``)}`,children:n.supportPhone}),a&&/* @__PURE__ */ V(`span`,{className:`text-body-secondary`,children:n.supportHours})]})}function Lt({client:e,timeZone:n=I,renderTime:r,labels:i,children:s}){let c=o(null),l=t((t=!1)=>{let n=c.current;if(t||!n||n.client!==e){let t=e.getConfig(),n={client:e,pending:t};return c.current=n,t.catch(()=>{c.current===n&&(c.current=null)}),t}return n.pending},[e]),u=a(()=>({client:e,loadConfig:l,timeZone:n,renderTime:r,labels:i}),[e,l,n,r,i]);return/* @__PURE__ */ V(le.Provider,{value:u,children:s})}export{we as HelpArticle,je as HelpCentre,at as ReportIssue,W as SupportApiError,Nt as SupportCenter,It as SupportContact,Lt as SupportProvider,ve as createHelpCentreClient,se as createSupportClient,Ae as useHelpCentre,J as useSupportClient,me as useSupportConfig,_e as useSupportTicket,ge as useSupportTicketCounts,he as useSupportTickets};
|
|
1
|
+
import{createContext as e,useCallback as t,useContext as n,useEffect as r,useId as i,useMemo as a,useRef as o,useState as s}from"react";import{IST_TIME_ZONE as c,formatDateTime as l,formatFileSize as u,timeZoneLabel as d}from"@webority/ui-elements/helpers";import{Fragment as f,jsx as p,jsxs as m}from"react/jsx-runtime";import{AppActionIcon as h,AppAlert as g,AppAvatar as _,AppBadge as v,AppButton as y,AppCard as b,AppChip as x,AppChipGroup as S,AppChoiceChip as C,AppConfirmDialog as w,AppCopyButton as T,AppDataTable as E,AppDescriptions as D,AppEmptyState as O,AppFileAttachment as k,AppFloatingButton as A,AppFormActions as j,AppIcon as M,AppInput as N,AppLink as P,AppMarkdown as F,AppMetricStrip as I,AppModal as L,AppRadioGroup as R,AppSearch as z,AppSelect as B,AppSkeleton as ee,AppSpinner as V,AppStatusBadge as te,AppTabs as H,AppTextarea as U,warnInvalidValue as ne}from"@webority/ui-react";import{toBlob as re}from"html-to-image";var W=`Something went wrong. Please try again.`,G=class extends Error{constructor(e,t,n){super(t),this.name=`SupportApiError`,this.code=e,this.status=n}};async function ie(e){if(e&&typeof Blob<`u`&&e instanceof Blob)try{return JSON.parse(await e.text())}catch{return null}if(typeof e==`string`)try{return JSON.parse(e)}catch{return null}return e??null}async function K(e){if(e instanceof G)return e;let t=e?.response;if(!t)return new G(`network`,W);let n=await ie(t.data);return new G(typeof n?.code==`string`&&n.code?n.code:`unknown`,typeof n?.detail==`string`&&n.detail.trim()?n.detail:W,t.status)}async function q(e){try{return(await e()).data}catch(e){throw await K(e)}}function J(e,t,n){n!=null&&String(n).trim()!==``&&e.append(t,String(n))}function ae(e,t,n,r){(n??[]).forEach((n,i)=>{let a=n?.name||`${r}-${i+1}.png`;e.append(t,n,a)})}var oe=20;function se(e,t){return(e??[]).map((e,n)=>e?.name||`${t}-${n+1}.png`).join(`|`)}function ce(e){return e instanceof G&&typeof e.status==`number`&&e.status>=400&&e.status<=499&&e.status!==408&&e.status!==429}function le(e,t=`/api/support`){let n=(typeof t==`string`?t:t?.base??`/api/support`).replace(/\/+$/,``),r=e=>`${n}/tickets/${encodeURIComponent(e)}`,i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map;function o(){for(let e of i.keys()){if(i.size<=oe)return;a.has(e)||i.delete(e)}}async function s(e,t){let n=i.get(e)||crypto.randomUUID();i.delete(e),i.set(e,n),a.set(e,(a.get(e)??0)+1),o();try{let r=await t(n);return i.delete(e),r}catch(t){throw ce(t)&&i.delete(e),t}finally{let t=a.get(e)-1;t>0?a.set(e,t):a.delete(e)}}return{getConfig:()=>q(()=>e.get(`${n}/settings`)),listTickets:({status:t,search:r,page:i,pageSize:a}={})=>{let o=new URLSearchParams;J(o,`status`,t),J(o,`search`,r?.trim()),J(o,`page`,i),J(o,`pageSize`,a);let s=o.toString();return q(()=>e.get(`${n}/tickets${s?`?${s}`:``}`))},getTicketCounts:()=>q(()=>e.get(`${n}/tickets/counts`)),getTicket:t=>q(()=>e.get(r(t))),createTicket:({category:t,subject:r,body:i,pageUrl:a,userAgent:o,appVersion:c,files:l,screenshots:u})=>{let d=new FormData;return d.append(`category`,t??``),d.append(`subject`,r??``),d.append(`body`,i??``),J(d,`pageUrl`,a),J(d,`userAgent`,o),J(d,`appVersion`,c),ae(d,`files`,l,`file`),ae(d,`screenshots`,u,`screenshot`),s([`ticket`,t,r,i,se(l,`file`),se(u,`screenshot`)].join(`\0`),t=>q(()=>e.post(`${n}/tickets`,d,{headers:{"Idempotency-Key":t}})))},getSuggestions:async(t,{signal:r}={})=>{try{return await q(()=>e.get(`${n}/suggestions`,{params:{subject:t},signal:r}))}catch(e){if(e instanceof G&&e.status===404)return[];throw e}},reply:(t,{body:n,files:i,screenshots:a})=>{let o=new FormData;return o.append(`body`,n??``),ae(o,`files`,i,`file`),ae(o,`screenshots`,a,`screenshot`),s([`reply`,t,n,se(i,`file`),se(a,`screenshot`)].join(`\0`),n=>q(()=>e.post(`${r(t)}/replies`,o,{headers:{"Idempotency-Key":n}})))},reopen:t=>q(()=>e.post(`${r(t)}/reopen`)),cancel:t=>q(()=>e.post(`${r(t)}/cancel`)),rate:(t,{satisfaction:n,comment:i})=>{let a={satisfaction:n};return i!=null&&i.trim()!==``&&(a.comment=i.trim()),q(()=>e.post(`${r(t)}/rating`,a))},fetchAttachment:t=>q(()=>e.get(`${n}/attachments/${encodeURIComponent(t)}`,{responseType:`blob`})),confirmAction:t=>q(()=>e.post(`${n}/actions/confirm`,{token:t}))}}var ue=6e4;function de(e,{basePath:t=`/api/support/agent`}={}){let n=t.replace(/\/+$/,``),r=e=>`${n}/tickets/${encodeURIComponent(e)}`,i=(e,t)=>`${r(e)}/attachments/${encodeURIComponent(t)}`;return{getSettings:()=>q(()=>e.get(`${n}/settings`)),listTickets:(t={})=>{let r=new URLSearchParams;for(let[e,n]of Object.entries(t))n!=null&&String(n).trim()!==``&&r.append(e,String(n));let i=r.toString();return q(()=>e.get(`${n}/tickets${i?`?${i}`:``}`))},countTickets:()=>q(()=>e.get(`${n}/tickets/counts`)),getTicket:t=>q(()=>e.get(r(t))),reply:(t,{version:n,body:i,isInternal:a,files:o})=>{let s=new FormData;return s.append(`version`,n??``),s.append(`body`,i??``),s.append(`isInternal`,String(!!a)),ae(s,`files`,o,`file`),q(()=>e.post(`${r(t)}/replies`,s))},changeStatus:(t,{version:n,status:i})=>q(()=>e.post(`${r(t)}/status`,{version:n,status:i})),changePriority:(t,{version:n,priority:i})=>q(()=>e.post(`${r(t)}/priority`,{version:n,priority:i})),changeCategory:(t,{version:n,category:i})=>q(()=>e.post(`${r(t)}/category`,{version:n,category:i})),assign:(t,{version:n,agentUserId:i})=>q(()=>e.post(`${r(t)}/assignee`,{version:n,agentUserId:i})),listAgents:()=>q(()=>e.get(`${n}/agents`)),listRealms:()=>q(()=>e.get(`${n}/realms`)),attachmentUrl:i,openAttachment:async(t,n)=>{let r=await q(()=>e.get(i(t,n),{responseType:`blob`})),a=URL.createObjectURL(r);window.open(a,`_blank`,`noopener`),setTimeout(()=>URL.revokeObjectURL(a),ue)}}}var fe=3e4,pe=e(null);function me(){let e=n(pe);if(!e)throw Error(`Support agent components and hooks must be used inside <SupportAgentProvider>.`);return e}function he(){return me().client}function ge(){return me().timeZone}function _e(){return me().renderTime??null}function ve(e,t){let n=me().labels?.[e];return a(()=>n?{...t,...n}:t,[n,t])}function ye(e,n,i=!0){let[a,c]=s({data:null,loading:i,error:null}),[l,u]=s(0),d=o(e);d.current=e;let f=o(n);r(()=>{let e=f.current!==n;if(f.current=n,!i){c({data:null,loading:!1,error:null});return}let t=!0;return c(t=>({data:e?null:t.data,loading:!0,error:null})),d.current(l>0).then(e=>t&&c({data:e,loading:!1,error:null}),e=>t&&c(t=>({...t,loading:!1,error:e}))),()=>{t=!1}},[n,i,l]);let p=t(()=>u(e=>e+1),[]),m=t(e=>c(t=>({...t,data:typeof e==`function`?e(t.data):e})),[]);return{...a,reload:p,setData:m}}function be(e={}){let t=he(),{data:n,loading:r,error:i,reload:a}=ye(()=>t.listTickets(e),JSON.stringify(e));return{tickets:n?.items??[],totalCount:n?.totalCount??0,totalPages:n?.totalPages??0,loading:r,error:i,reload:a}}function xe(){let e=he(),{data:t,loading:n,error:r,reload:i}=ye(()=>e.countTickets(),`queue-counts`);return{counts:t,loading:n,error:r,reload:i}}function Se(e){let n=he(),{data:i,loading:a,error:s,reload:c,setData:l}=ye(()=>n.getTicket(e),e??``,!!e),u=o(0),d=o(e);d.current=e;let f=t(async e=>{u.current+=1;try{let t=await e();return l(t),t}finally{--u.current}},[l]),p=t(async()=>{if(u.current>0)return;let t=e;try{let e=await n.getTicket(t);if(d.current!==t)return;l(t=>t?Date.parse(e.updatedDateTimeUtc)>=Date.parse(t.updatedDateTimeUtc)?e:t:e)}catch{}},[n,e,l]);return r(()=>{if(!e)return;let t=null,n=()=>{t===null&&(t=setInterval(p,fe))},r=()=>{t!==null&&clearInterval(t),t=null},i=()=>{document.hidden?r():(p(),n())};return document.addEventListener(`visibilitychange`,i),document.hidden||n(),()=>{r(),document.removeEventListener(`visibilitychange`,i)}},[e,p]),{ticket:i,loading:a,error:s,reload:c,reply:t(t=>f(()=>n.reply(e,t)),[f,n,e]),changeStatus:t(t=>f(()=>n.changeStatus(e,t)),[f,n,e]),changePriority:t(t=>f(()=>n.changePriority(e,t)),[f,n,e]),changeCategory:t(t=>f(()=>n.changeCategory(e,t)),[f,n,e]),assign:t(t=>f(()=>n.assign(e,t)),[f,n,e])}}function Ce(){let{client:e,loadOnce:t}=me(),{data:n,loading:r,error:i,reload:a}=ye(n=>t(`agents`,()=>e.listAgents(),n),`agents`);return{agents:n??[],loading:r,error:i,reload:a}}function we(){let{client:e,loadOnce:t}=me(),{data:n,loading:r,error:i,reload:a}=ye(n=>t(`settings`,()=>e.getSettings(),n),`settings`);return{settings:n,loading:r,error:i,reload:a}}function Te({client:e,timeZone:n=c,renderTime:r,labels:i,children:s}){let l=o(/* @__PURE__ */ new Map),u=t((t,n,r=!1)=>{let i=l.current.get(t);if(!r&&i&&i.client===e)return i.pending;let a=n(),o={client:e,pending:a};return l.current.set(t,o),a.catch(()=>{l.current.get(t)===o&&l.current.delete(t)}),a},[e]),d=a(()=>({client:e,loadOnce:u,timeZone:n,renderTime:r,labels:i}),[e,u,n,r,i]);return/* @__PURE__ */ p(pe.Provider,{value:d,children:s})}function Y(e,t){return String(e).replace(/[{]([A-Za-z0-9_]+)[}]/g,(e,n)=>n in t?String(t[n]):e)}var X={offline:`We could not reach support. Check your connection and try again.`,attachOne:`You can attach one file.`,attachMany:`You can attach up to {count} files.`,typeNotAccepted:`{name} is a file type we cannot accept.`,tooLarge:`{name} is larger than {size}.`,thisFile:`This file`,alreadyAttached:`{name} is already attached.`};function Z(e,t,n=X.offline){if(e instanceof G){if(e.code===`network`)return n;if(e.code!==`unknown`)return e.message}return t}function Ee(e){return(e?.allowedContentTypes??[]).join(`,`)}function De(e,t){if(t.length===0)return!0;let n=(e||``).toLowerCase();return t.some(e=>{let t=e.toLowerCase();return t.endsWith(`/*`)?n.startsWith(t.slice(0,-1)):n===t})}function Oe(e,t,n=X){let r=e??[],i=t?.maxAttachmentsPerMessage??0,a=t?.maxAttachmentBytes??0,o=t?.allowedContentTypes??[];if(i>0&&r.length>i)return i===1?n.attachOne:Y(n.attachMany,{count:i});for(let e of r){let t=e.name||n.thisFile;if(!De(e.type,o))return Y(n.typeNotAccepted,{name:t});if(a>0&&e.size>a)return Y(n.tooLarge,{name:t,size:u(a)})}return null}var ke=(e,t)=>e===1?t.attachOne:Y(t.attachMany,{count:e});function Ae(e){return`${e.name}|${e.size}|${e.lastModified}`}function je(e,t,n,r=X){let i=n?.maxAttachmentsPerMessage??0,a=new Set(e.map(Ae)),o=[],s=null;for(let e of t){let t=Ae(e);a.has(t)?s??=e.name:(a.add(t),o.push(e))}let c=i>0?Math.max(0,i-e.length):o.length,l=[...e,...o.slice(0,c)];return{files:l,notice:(o.length>c?ke(i,r):null)??Oe(l,n,r)??(s?Y(r.alreadyAttached,{name:s}):``)}}function Me(e){let t=Array.from(e.clipboardData?.items??[]),n=Date.now();return t.filter(e=>e.kind===`file`&&e.type.startsWith(`image/`)).map(e=>e.getAsFile()).filter(Boolean).map((e,t)=>{let r=(e.type.split(`/`)[1]||`png`).replace(`jpeg`,`jpg`);return new File([e],`pasted-image-${n}-${t+1}.${r}`,{type:e.type})})}var Ne={Open:`info`,InProgress:`info`,WaitingOnCustomer:`warning`,Resolved:`success`,Closed:`success`,Cancelled:`neutral`};function Pe(e){return Ne[e]??`neutral`}var Fe={supportQueue:{countOpen:`Open`,countInProgress:`In progress`,countWaiting:`Waiting`,countOverdue:`Overdue`,countUnassigned:`Unassigned`,filterStatus:`Status`,filterPriority:`Priority`,filterCategory:`Category`,filterPlace:`Place`,filterAssignee:`Assignee`,filterUnassignedOnly:`Unassigned only`,filterOverdueOnly:`Overdue only`,filterSearch:`Search`,filterAny:`All`,columnNumber:`Number`,columnPlace:`Place`,columnSubject:`Subject`,columnCategory:`Category`,columnStatus:`Status`,columnPriority:`Priority`,columnAssignee:`Assignee`,columnDue:`Due`,loading:`Loading tickets...`,empty:`No tickets match these filters.`,error:`We could not load the tickets. Try again.`,retry:`Try again`,heading:`Ticket queue`,tableLabel:`Tickets in this queue`,settingsError:`We could not load the queue settings.`,overdueMark:`Overdue`,noAssignee:`Unassigned`,emptyUnfiltered:`No tickets in this queue yet.`},agentTicket:{reply:`Reply`,internalNote:`Internal note`,send:`Send`,savedReplies:`Saved replies`,attachFiles:`Attach files`,status:`Status`,priority:`Priority`,category:`Category`,assignee:`Assignee`,unassigned:`Unassigned`,internal:`Internal`,backToQueue:`Back to queue`,stale:`Someone else changed this ticket just now. Reload it and try again.`,reload:`Reload`,loading:`Loading ticket...`,empty:`No messages yet.`,error:`We could not load this ticket. Try again.`,retry:`Try again`,emptyReply:`Write a message before you send it.`,actionFailed:`The change was not saved. Please try again.`,attachmentFailed:`This file could not be opened. Try again.`,none:`None`,customer:`Customer`,supportTeam:`Support team`,overdue:`Overdue`,detailsLabel:`Ticket details`,controlsLabel:`Ticket controls`,fieldTicket:`Ticket`,fieldAccount:`Account`,fieldRealm:`Realm`,fieldReporter:`Reporter`,fieldEmail:`Email`,fieldRaised:`Raised`,fieldUpdated:`Updated`,fieldReplyDue:`Reply due`,fieldResolutionDue:`Resolution due`,mode:`Reply or internal note`,replyHint:`The customer sees this reply.`,noteHint:`Only the support team sees an internal note.`,body:`Message`,insertSaved:`Insert a saved reply`,attachedFiles:`Attached files`,removeFile:`Remove {name}`,formLabel:`Reply to this ticket`,conversation:`Conversation`}},Ie=[`InProgress`,`WaitingOnCustomer`,`Resolved`,`Closed`],Le=`support-agent-draft:`;function Re(e){try{return sessionStorage.getItem(Le+e)??``}catch{return``}}function ze(e,t){try{t?sessionStorage.setItem(Le+e,t):sessionStorage.removeItem(Le+e)}catch{}}function Be({iso:e,className:t}){let n=_e(),r=ge();return n?n(e):/* @__PURE__ */ p(`time`,{dateTime:e,className:t,children:l(e,{timeZone:r})})}function Ve({ticketId:e,onBack:t,labels:n}){let a=ve(`agentTicket`,Fe.agentTicket),o=n?{...a,...n}:a,c=i(),l=he(),{ticket:u,loading:d,error:f,reload:_,reply:C,changeStatus:w,changePriority:T,changeCategory:E,assign:O}=Se(e),{settings:k}=we(),{agents:A}=Ce(),[j,M]=s(`reply`),[N,P]=s(()=>Re(e)),[F,I]=s([]),[L,z]=s(``),[V,H]=s(``),[ne,re]=s(!1),[W,G]=s(!1);r(()=>{P(Re(e)),I([]),z(``),H(``),re(!1)},[e]);let ie=/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,leftIcon:`arrow-left`,onClick:t,className:`align-self-start`,children:o.backToQueue});if(!u)return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3`,"aria-busy":d||void 0,children:[ie,f?/* @__PURE__ */ m(g,{tone:`danger`,children:[Z(f,o.error,X.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:_,children:o.retry})]}):/* @__PURE__ */ p(ee,{height:160})]});async function K(e){H(``),re(!1),G(!0);try{return await e(),!0}catch(e){return e?.status===409?re(!0):H(Z(e,o.actionFailed,X.offline)),!1}finally{G(!1)}}let q=t=>{P(t),H(``),ze(e,t)},J=e=>{let t=je(F,e,k,X);I(t.files),z(t.notice)},ae=e=>{let t=F.filter((t,n)=>n!==e);I(t),z(Oe(t,k,X)??``)},oe=e=>{let t=Me(e);t.length>0&&J(t)};async function se(t){t.preventDefault();let n=N.trim();if(!n){H(o.emptyReply);return}let r=Oe(F,k,X);r?z(r):await K(()=>C({version:u.version,body:n,isInternal:j===`note`,files:F}))&&(P(``),I([]),z(``),ze(e,``))}let ce=t=>{H(``),l.openAttachment(e,t).catch(e=>{H(Z(e,o.attachmentFailed,X.offline))})},le=e=>{let t=(k?.savedReplies??[])[Number(e)];t&&q(N?`${N}\n${t.body}`:t.body)},ue=k?.queues??[],de=ue.find(e=>e.key===u.queue),fe=de?de.categories:ue.flatMap(e=>e.categories??[]),pe=(k?.statuses??[]).filter(e=>Ie.includes(e.value)).map(e=>({value:e.value,label:e.label})),me=(k?.priorities??[]).map(e=>({value:e.value,label:e.label})),ge=[...new Set(fe??[])].map(e=>({value:e,label:e})),_e=[{value:``,label:o.unassigned},...(A??[]).map(e=>({value:String(e.userId),label:e.name}))],ye=(e,t)=>e?/* @__PURE__ */ m(`span`,{className:`d-inline-flex flex-wrap align-items-center gap-2`,children:[/* @__PURE__ */ p(Be,{iso:e}),t&&/* @__PURE__ */ p(v,{tone:`danger`,children:o.overdue})]}):o.none,be=[{key:`ticket`,label:o.fieldTicket,value:u.number},{key:`account`,label:o.fieldAccount,value:u.accountId??o.none},{key:`realm`,label:o.fieldRealm,value:u.realm?k?.realmLabels?.[u.realm]??u.realm:o.none},{key:`reporter`,label:o.fieldReporter,value:u.reporterName||o.none},{key:`email`,label:o.fieldEmail,value:u.reporterEmail||o.none},{key:`raised`,label:o.fieldRaised,value:/* @__PURE__ */ p(Be,{iso:u.raisedDateTimeUtc??u.createdDateTimeUtc})},{key:`updated`,label:o.fieldUpdated,value:/* @__PURE__ */ p(Be,{iso:u.updatedDateTimeUtc})},{key:`replyDue`,label:o.fieldReplyDue,value:ye(u.replyDueDateTimeUtc,u.isOverdue)},{key:`resolutionDue`,label:o.fieldResolutionDue,value:ye(u.resolutionDueDateTimeUtc,u.isResolutionOverdue)}],xe=V||L;return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3`,"aria-labelledby":`${c}-subject`,children:[ie,/* @__PURE__ */ m(`div`,{className:`row g-3`,children:[/* @__PURE__ */ m(`div`,{className:`col-12 col-lg-8 d-flex flex-column gap-3`,children:[/* @__PURE__ */ m(`header`,{className:`d-flex flex-wrap align-items-center gap-2`,children:[/* @__PURE__ */ p(`h2`,{id:`${c}-subject`,className:`h5 mb-0 text-break`,children:u.subject}),/* @__PURE__ */ p(te,{label:u.statusLabel??u.status,tone:Pe(u.status)})]}),ne&&/* @__PURE__ */ m(g,{tone:`warning`,children:[o.stale,` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:_,children:o.reload})]}),/* @__PURE__ */ m(`ol`,{className:`list-unstyled d-flex flex-column gap-3 mb-0`,"aria-label":o.conversation,children:[(u.messages??[]).length===0&&/* @__PURE__ */ p(`p`,{className:`wui-text-sm text-body-secondary mb-0`,children:o.empty}),(u.messages??[]).map(e=>{if(e.authorKind===`System`)return/* @__PURE__ */ m(`li`,{className:`text-center wui-text-xs text-body-secondary`,"data-author":`system`,children:[/* @__PURE__ */ p(`span`,{className:`d-block`,children:e.body}),/* @__PURE__ */ p(Be,{iso:e.createdDateTimeUtc})]},e.id);let t=e.authorKind===`Customer`,n=e.authorName||(t?o.customer:o.supportTeam);return/* @__PURE__ */ p(`li`,{"data-author":t?`customer`:`agent`,"data-internal":e.isInternal?`true`:void 0,children:/* @__PURE__ */ m(b,{padding:`sm`,variant:e.isInternal?`accent`:`flat`,className:`border`,children:[/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2 mb-2`,children:[/* @__PURE__ */ m(`span`,{className:`d-inline-flex flex-wrap align-items-center gap-2 fw-semibold wui-text-sm text-break`,children:[n,e.isInternal&&/* @__PURE__ */ p(v,{tone:`warning`,children:o.internal})]}),/* @__PURE__ */ p(`span`,{className:`wui-text-xs text-body-secondary text-nowrap`,children:/* @__PURE__ */ p(Be,{iso:e.createdDateTimeUtc})})]}),/* @__PURE__ */ p(`div`,{className:`wui-text-sm`,style:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:e.body}),e.attachments?.length>0&&/* @__PURE__ */ p(`div`,{className:`d-flex flex-wrap gap-2 mt-2`,children:e.attachments.map(e=>/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,leftIcon:`paperclip`,onClick:()=>ce(e.id),children:e.fileName},e.id))})]})},e.id)})]}),/* @__PURE__ */ m(`form`,{onSubmit:se,noValidate:!0,className:`d-flex flex-column gap-2 min-w-0`,"aria-label":o.formLabel,children:[xe&&/* @__PURE__ */ p(g,{tone:`danger`,children:xe}),/* @__PURE__ */ p(R,{label:o.mode,options:[{value:`reply`,label:o.reply},{value:`note`,label:o.internalNote}],value:j,onChange:M,inline:!0}),/* @__PURE__ */ p(B,{label:o.savedReplies,placeholder:o.insertSaved,options:(k?.savedReplies??[]).map((e,t)=>({value:String(t),label:e.title})),value:``,onChange:le,disabled:W}),/* @__PURE__ */ p(U,{id:`${c}-body`,label:o.body,rows:3,autoGrow:!0,maxLength:k?.bodyMaxLength,value:N,onChange:e=>q(e.target.value),onPaste:oe,helperText:j===`note`?o.noteHint:o.replyHint,required:!0}),F.length>0&&/* @__PURE__ */ p(S,{label:o.attachedFiles,children:F.map((e,t)=>/* @__PURE__ */ p(x,{leadingIcon:`paperclip`,label:e.name,removeLabel:Y(o.removeFile,{name:e.name}),onRemove:()=>ae(t)},Ae(e)))}),/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2`,children:[/* @__PURE__ */ p(h,{iconVariant:`bulk`,icon:`paperclip`,label:o.attachFiles,multiple:k?.maxAttachmentsPerMessage!==1,accept:Ee(k),onFiles:J}),/* @__PURE__ */ p(y,{type:`submit`,leftIcon:`send`,loading:W,children:o.send})]})]})]}),/* @__PURE__ */ m(`aside`,{"aria-label":o.detailsLabel,className:`col-12 col-lg-4 d-flex flex-column gap-3`,children:[/* @__PURE__ */ p(b,{padding:`sm`,className:`border`,children:/* @__PURE__ */ p(D,{columns:1,items:be})}),/* @__PURE__ */ p(b,{padding:`sm`,className:`border`,"aria-label":o.controlsLabel,children:/* @__PURE__ */ m(`div`,{className:`d-flex flex-column gap-3`,children:[/* @__PURE__ */ p(B,{label:o.status,value:u.status,options:pe,disabled:W,onChange:e=>K(()=>w({version:u.version,status:e}))}),/* @__PURE__ */ p(B,{label:o.priority,value:u.priority??``,options:me,disabled:W,onChange:e=>K(()=>T({version:u.version,priority:e}))}),/* @__PURE__ */ p(B,{label:o.category,value:u.category,options:ge,disabled:W,onChange:e=>K(()=>E({version:u.version,category:e}))}),/* @__PURE__ */ p(B,{label:o.assignee,value:u.assignedAgentUserId==null?``:String(u.assignedAgentUserId),options:_e,disabled:W,onChange:e=>K(()=>O({version:u.version,agentUserId:e?Number(e):null}))})]})})]})]})]})}function He(e,t){let[n,i]=s(e);return r(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[e,t]),n}var Ue=10,We=300,Q=`all`,Ge=e=>e===Q?void 0:e,Ke=e=>[...new Set(e.flatMap(e=>e.categories??[]))];function qe({onOpenTicket:e,getTicketHref:t,status:n,onStatusChange:i,defaultStatus:a=Q,queue:o,pageSize:c=Ue}){let u=ve(`supportQueue`,Fe.supportQueue),d=_e(),f=ge(),{settings:h,error:_}=we(),{agents:b}=Ce(),{counts:x}=xe(),[S,w]=s(a),T=n!==void 0,D=T?n:S,k=e=>{T||w(e),i?.(e)},[A,j]=s(Q),[M,N]=s(Q),[F,L]=s(Q),[R,ee]=s(Q),[V,H]=s(!1),[U,ne]=s(!1),[re,W]=s(``),G=He(re.trim(),We),[ie,K]=s(c),q=JSON.stringify([o,D,A,M,F,R,V,U,G,ie]),[J,ae]=s({key:q,page:1}),oe=J.key===q?J.page:1,se=e=>ae({key:q,page:e}),ce=be({queue:o,status:Ge(D),priority:Ge(A),category:Ge(M),realm:Ge(F),assignedAgentUserId:Ge(R),unassignedOnly:V||void 0,overdueOnly:U||void 0,includeSettled:D===Q||void 0,search:G||void 0,page:oe,pageSize:ie}),le=ce.totalPages;r(()=>{le>0&&oe>le&&ae({key:q,page:le})},[le,oe,q]);let ue=h?.queues??[],de=o?ue.filter(e=>e.key===o):ue,fe=[{value:Q,label:u.filterAny},...h?.statuses??[]],pe=[{value:Q,label:u.filterAny},...h?.priorities??[]],me=[{value:Q,label:u.filterAny},...Ke(de).map(e=>({value:e,label:e}))],he=[{value:Q,label:u.filterAny},...Object.entries(h?.realmLabels??{}).map(([e,t])=>({value:e,label:t}))],ye=[{value:Q,label:u.filterAny},...b.map(e=>({value:String(e.userId),label:e.name}))],Se=h?.realmLabels??{},Te=e=>d?d(e):/* @__PURE__ */ p(`time`,{dateTime:e,children:l(e,{timeZone:f})}),Y=(t,n)=>{e&&(t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),e(n)))},X=[{key:`number`,label:u.columnNumber,nowrap:!0,render:n=>{let r=t?.(n.id);return!r&&!e?/* @__PURE__ */ p(`span`,{className:`fw-semibold text-nowrap`,children:n.number}):r?/* @__PURE__ */ p(P,{href:r,animation:`none`,className:`fw-semibold text-nowrap`,onClick:e=>Y(e,n.id),children:n.number}):/* @__PURE__ */ p(y,{variant:`link`,size:`sm`,className:`fw-semibold text-nowrap`,onClick:()=>e(n.id),children:n.number})}},{key:`place`,label:u.columnPlace,render:e=>/* @__PURE__ */ m(`div`,{className:`d-flex flex-column`,style:{minWidth:0},children:[/* @__PURE__ */ p(`span`,{className:`text-break`,children:e.accountName}),/* @__PURE__ */ p(`span`,{className:`wui-text-xs text-body-secondary`,children:Se[e.realm]??`-`})]})},{key:`subject`,label:u.columnSubject,render:e=>/* @__PURE__ */ p(`span`,{className:`text-break`,children:e.subject})},{key:`category`,label:u.columnCategory,render:e=>e.category},{key:`status`,label:u.columnStatus,render:e=>/* @__PURE__ */ p(te,{label:e.statusLabel,tone:Pe(e.status)})},{key:`priority`,label:u.columnPriority,render:e=>/* @__PURE__ */ p(v,{children:e.priorityLabel})},{key:`assignee`,label:u.columnAssignee,render:e=>e.assignedAgentName??u.noAssignee},{key:`due`,label:u.columnDue,cellClassName:`wui-text-sm text-nowrap`,render:e=>{let t=e.resolutionDueDateTimeUtc,n=e.isOverdue||e.isResolutionOverdue;return/* @__PURE__ */ m(`span`,{className:`d-inline-flex gap-2 align-items-center`,children:[t?Te(t):`-`,n&&/* @__PURE__ */ p(v,{tone:`danger`,children:u.overdueMark})]})}}],Ee=[{label:u.countOpen,value:x?.open??`-`},{label:u.countInProgress,value:x?.inProgress??`-`},{label:u.countWaiting,value:x?.waitingOnCustomer??`-`},{label:u.countOverdue,value:x?.overdue??`-`,tone:`danger`},{label:u.countUnassigned,value:x?.unassigned??`-`}],De=[D,A,M,F,R].some(e=>e!==Q)||V||U||!!G,Oe={page:oe,totalPages:Math.max(1,ce.totalPages),pageSize:ie,total:ce.totalCount,setPage:se,setPageSize:K};return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-labelledby":`support-queue-title`,children:[/* @__PURE__ */ p(`h2`,{id:`support-queue-title`,className:`h5 mb-0`,children:u.heading}),_&&/* @__PURE__ */ p(g,{tone:`warning`,children:Z(_,u.settingsError)}),/* @__PURE__ */ p(I,{items:Ee,columns:5,size:`sm`}),ce.error&&/* @__PURE__ */ m(g,{tone:`danger`,children:[Z(ce.error,u.error),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:ce.reload,children:u.retry})]}),/* @__PURE__ */ m(`div`,{className:`d-flex flex-column flex-xl-row flex-wrap gap-2 align-items-xl-end`,children:[/* @__PURE__ */ p(B,{label:u.filterStatus,value:D,onChange:k,options:fe,fieldClassName:`flex-shrink-0`}),/* @__PURE__ */ p(B,{label:u.filterPriority,value:A,onChange:j,options:pe,fieldClassName:`flex-shrink-0`}),/* @__PURE__ */ p(B,{label:u.filterCategory,value:M,onChange:N,options:me,fieldClassName:`flex-shrink-0`}),/* @__PURE__ */ p(B,{label:u.filterPlace,value:F,onChange:L,options:he,fieldClassName:`flex-shrink-0`}),/* @__PURE__ */ p(B,{label:u.filterAssignee,value:R,onChange:ee,options:ye,fieldClassName:`flex-shrink-0`}),/* @__PURE__ */ p(C,{multiple:!0,checked:V,onChange:()=>H(e=>!e),children:u.filterUnassignedOnly}),/* @__PURE__ */ p(C,{multiple:!0,checked:U,onChange:()=>ne(e=>!e),children:u.filterOverdueOnly}),/* @__PURE__ */ p(z,{value:re,onChange:W,placeholder:u.filterSearch,ariaLabel:u.filterSearch})]}),/* @__PURE__ */ p(E,{columns:X,rows:ce.tickets,loading:ce.loading,skeletonRows:4,ariaLabel:u.tableLabel,pagination:Oe,empty:/* @__PURE__ */ p(O,{variant:`table`,icon:`message-square`,title:De?u.empty:u.emptyUnfiltered})})]})}var Je=3e4,Ye=e(null);function Xe(){let e=n(Ye);if(!e)throw Error(`Support components and hooks must be used inside <SupportProvider>.`);return e}function Ze(){return Xe().client}function Qe(){return Xe().timeZone}function $e(){return Xe().renderTime??null}function $(e,t){let n=Xe().labels?.[e];return a(()=>n?{...t,...n}:t,[n,t])}function et(e,n,i=!0){let[a,c]=s({data:null,loading:i,error:null}),[l,u]=s(0),d=o(e);d.current=e;let f=o(n);r(()=>{let e=f.current!==n;if(f.current=n,!i){c({data:null,loading:!1,error:null});return}let t=!0;return c(t=>({data:e?null:t.data,loading:!0,error:null})),d.current(l>0).then(e=>t&&c({data:e,loading:!1,error:null}),e=>t&&c(t=>({...t,loading:!1,error:e}))),()=>{t=!1}},[n,i,l]);let p=t(()=>u(e=>e+1),[]),m=t(e=>c(t=>({...t,data:typeof e==`function`?e(t.data):e})),[]);return{...a,reload:p,setData:m}}function tt(){let{loadConfig:e}=Xe(),{data:t,loading:n,error:r,reload:i}=et(e,`config`);return{config:t,loading:n,error:r,reload:i}}function nt(e={}){let t=Ze(),{status:n,search:r,page:i,pageSize:a}=e,{data:o,loading:s,error:c,reload:l}=et(()=>t.listTickets({status:n,search:r,page:i,pageSize:a}),JSON.stringify([`tickets`,n??null,r??null,i??null,a??null]));return{tickets:o?.items??[],totalCount:o?.totalCount??0,totalPages:o?.totalPages??0,loading:s,error:c,reload:l}}function rt(){let e=Ze(),{data:t,loading:n,error:r,reload:i}=et(()=>e.getTicketCounts(),`ticket-counts`);return{counts:t,loading:n,error:r,reload:i}}function it(e){let n=Ze(),{data:i,loading:a,error:s,reload:c,setData:l}=et(()=>n.getTicket(e),e??``,!!e),u=o(0),d=o(e);d.current=e;let f=t(async e=>{u.current+=1;try{let t=await e();return l(t),t}finally{--u.current}},[l]),p=t(async()=>{if(u.current>0)return;let t=e;try{let e=await n.getTicket(t);if(d.current!==t)return;l(t=>t?Date.parse(e.updatedDateTimeUtc)>=Date.parse(t.updatedDateTimeUtc)?e:t:e)}catch{}},[n,e,l]);return r(()=>{if(!e)return;let t=null,n=()=>{t===null&&(t=setInterval(p,Je))},r=()=>{t!==null&&clearInterval(t),t=null},i=()=>{document.hidden?r():(p(),n())};return document.addEventListener(`visibilitychange`,i),document.hidden||n(),()=>{r(),document.removeEventListener(`visibilitychange`,i)}},[e,p]),{ticket:i,loading:a,error:s,reload:c,reply:t(t=>f(()=>n.reply(e,t)),[f,n,e]),reopen:t(()=>f(()=>n.reopen(e)),[f,n,e]),cancel:t(()=>f(()=>n.cancel(e)),[f,n,e]),rate:t(t=>f(()=>n.rate(e,t)),[f,n,e])}}function at({baseUrl:e,http:t}){if(typeof e!=`string`||e.trim()===``)throw TypeError(`createHelpCentreClient needs a baseUrl.`);if(typeof t?.get!=`function`)throw TypeError(`createHelpCentreClient needs an http client with get().`);let n=e.trim().replace(/\/+$/,``),r=async e=>{try{return(await e()).data}catch(e){throw await K(e)}};return{settings:e=>r(()=>t.get(`${n}/settings`,{signal:e?.signal})),list:({page:e,pageSize:i}={},a)=>{let o=new URLSearchParams;e!=null&&o.set(`page`,String(e)),i!=null&&o.set(`pageSize`,String(i));let s=o.toString();return r(()=>t.get(`${n}/articles${s?`?${s}`:``}`,{signal:a?.signal}))},get:(e,i)=>r(()=>t.get(`${n}/articles/${encodeURIComponent(e)}`,{signal:i?.signal})),search:(e,i)=>r(()=>t.get(`${n}/search?${new URLSearchParams({q:String(e??``)}).toString()}`,{signal:i?.signal}))}}function ot({iso:e,className:t}){let n=$e(),r=Qe();return n?n(e):/* @__PURE__ */ p(`time`,{dateTime:e,className:t,children:l(e,{timeZone:r})})}var st={heading:`Help centre`,searchPlaceholder:`Search help articles`,searchLabel:`Search help articles`,tableLabel:`Help articles`,columnArticle:`Article`,columnUpdated:`Last updated`,listError:`We could not load the help articles.`,settingsError:`We could not load the help centre.`,retry:`Try again`,emptyTitle:`No articles yet`,emptyText:`Help articles from the support team show here.`,noMatchTitle:`No articles match`,noMatchText:`Try other words.`},ct={back:`Back to help`,published:`Published {date}`,updated:`Updated {date}`,loadError:`We could not load this article.`,notFoundTitle:`This article could not be found.`,retry:`Try again`},lt=`article_not_found`,ut=`{date}`;function dt({template:e,iso:t}){let n=e.indexOf(ut);return n===-1?/* @__PURE__ */ m(f,{children:[e,` `,/* @__PURE__ */ p(ot,{iso:t})]}):/* @__PURE__ */ m(f,{children:[e.slice(0,n),/* @__PURE__ */ p(ot,{iso:t}),e.slice(n+6)]})}function ft({client:e,slug:n,onBack:i}){let a=$(`helpArticle`,ct),c=$(`shared`,X),[l,u]=s({article:null,loading:!0,error:null}),d=o(null),f=t(()=>{d.current?.abort();let t=new AbortController;d.current=t,u({article:null,loading:!0,error:null}),e.get(n,{signal:t.signal}).then(e=>{t.signal.aborted||u({article:e,loading:!1,error:null})},e=>{t.signal.aborted||u({article:null,loading:!1,error:e})})},[e,n]);r(()=>(f(),()=>d.current?.abort()),[f]);let{article:h,loading:_,error:v}=l,b=v?.code===lt;return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-busy":_||void 0,children:[i&&/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,leftIcon:`arrow-left`,onClick:i,className:`align-self-start`,children:a.back}),_&&/* @__PURE__ */ p(ee,{height:160}),b&&/* @__PURE__ */ p(O,{variant:`card`,icon:`search`,title:a.notFoundTitle}),v&&!b&&/* @__PURE__ */ m(g,{tone:`danger`,children:[Z(v,a.loadError,c.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:f,children:a.retry})]}),h&&/* @__PURE__ */ m(`article`,{className:`d-flex flex-column gap-3`,children:[/* @__PURE__ */ p(`h2`,{className:`h4 mb-0`,children:h.title}),/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap gap-3 wui-text-sm text-body-secondary`,children:[h.publishedDateTimeUtc!=null&&/* @__PURE__ */ p(`span`,{children:/* @__PURE__ */ p(dt,{template:a.published,iso:h.publishedDateTimeUtc})}),/* @__PURE__ */ p(`span`,{children:/* @__PURE__ */ p(dt,{template:a.updated,iso:h.updatedDateTimeUtc})})]}),/* @__PURE__ */ p(F,{value:h.bodyMarkdown})]})]})}var pt=10,mt=300,ht=2;function gt(){let e=o(null),n=t(()=>{e.current?.abort(),e.current=null},[]);r(()=>n,[n]);let i=t((t,n,r)=>{e.current?.abort();let i=new AbortController;e.current=i,t(i.signal).then(e=>{i.signal.aborted||n(e)},e=>{i.signal.aborted||r(e)})},[]);return a(()=>({run:i,cancel:n}),[i,n])}function _t(e){let[n,i]=s({data:null,loading:!0,error:null}),[a,o]=s({page:1,pageSize:pt}),[c,l]=s({data:null,loading:!0,error:null}),[u,d]=s(``),[f,p]=s({term:``,data:[],loading:!1,error:null}),m=He(u.trim(),mt),h=gt(),g=gt(),_=gt(),{page:v,pageSize:y}=a,b=n.data?.searchAvailable===!0,x=b&&m.length>=ht,S=c.data?.totalPages??0,C=t(()=>{i(e=>({...e,loading:!0,error:null})),h.run(t=>e.settings({signal:t}),e=>i({data:e,loading:!1,error:null}),e=>i({data:null,loading:!1,error:e}))},[e,h]),w=t(()=>{l(e=>({...e,loading:!0,error:null})),g.run(t=>e.list({page:v,pageSize:y},{signal:t}),e=>l({data:e,loading:!1,error:null}),e=>l(t=>({...t,loading:!1,error:e})))},[e,v,y,g]),T=t(()=>{p(e=>({term:m,data:e.data,loading:!0,error:null})),_.run(t=>e.search(m,{signal:t}),e=>p({term:m,data:e,loading:!1,error:null}),e=>p({term:m,data:[],loading:!1,error:e}))},[e,m,_]);r(()=>{C()},[C]),r(()=>{w()},[w]),r(()=>{x?T():_.cancel()},[T,x,_]);let E=t(e=>{d(e),e.trim()===``&&_.cancel()},[_]);r(()=>{S>0&&v>S&&o(e=>({...e,page:S}))},[v,S]);let D=t(e=>o(t=>({...t,page:e})),[]),O=t(e=>o({page:1,pageSize:e}),[]);return{settings:{data:n.data,loading:n.loading,error:n.error,reload:C},articles:{items:c.data?.items??[],page:v,pageSize:y,totalCount:c.data?.totalCount??0,totalPages:S,loading:c.loading,error:c.error,setPage:D,setPageSize:O,reload:w},search:{enabled:b,query:u,setQuery:E,active:x,results:f.data,loading:x&&(f.loading||f.term!==m),error:x?f.error:null,reload:T}}}function vt({client:e,onOpen:t,linkTo:n}){let r=$(`helpCentre`,st),i=$(`shared`,X),{settings:a,articles:o,search:s}=_t(e),c=s.active,l=c?s.results:o.items,u=c?s.loading:o.loading,d=c?s.error:o.error,f=c?s.reload:o.reload,h=(e,n)=>{t&&(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t(n)))},_=[{key:`title`,label:r.columnArticle,render:e=>/* @__PURE__ */ m(`div`,{className:`d-flex flex-column min-w-0`,children:[n?/* @__PURE__ */ p(P,{href:n(e.slug),animation:`none`,className:`fw-semibold text-break`,onClick:t=>h(t,e.slug),children:e.title}):/* @__PURE__ */ p(y,{variant:`link`,size:`sm`,className:`fw-semibold text-break text-start p-0`,onClick:()=>t?.(e.slug),children:e.title}),/* @__PURE__ */ p(`span`,{className:`wui-text-sm text-body-secondary`,children:e.summary})]})},{key:`updatedDateTimeUtc`,label:r.columnUpdated,cellClassName:`wui-text-sm text-body-secondary text-nowrap`,render:e=>/* @__PURE__ */ p(ot,{iso:e.updatedDateTimeUtc})}],v={page:o.page,totalPages:Math.max(1,o.totalPages),pageSize:o.pageSize,total:o.totalCount,setPage:o.setPage,setPageSize:o.setPageSize};return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-labelledby":`help-centre-title`,children:[/* @__PURE__ */ p(`h2`,{id:`help-centre-title`,className:`h5 mb-0`,children:r.heading}),a.error&&/* @__PURE__ */ m(g,{tone:`warning`,children:[Z(a.error,r.settingsError,i.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:a.reload,children:r.retry})]}),s.enabled&&/* @__PURE__ */ p(z,{value:s.query,onChange:s.setQuery,placeholder:r.searchPlaceholder,ariaLabel:r.searchLabel}),d&&/* @__PURE__ */ m(g,{tone:`danger`,children:[Z(d,r.listError,i.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:f,children:r.retry})]}),/* @__PURE__ */ p(E,{columns:_,rows:l,loading:u,skeletonRows:4,ariaLabel:r.tableLabel,stackOnMobile:!0,pagination:c?void 0:v,empty:c?/* @__PURE__ */ p(O,{variant:`table`,icon:`search`,title:r.noMatchTitle,description:r.noMatchText}):/* @__PURE__ */ p(O,{variant:`table`,icon:`message-square`,title:r.emptyTitle,description:r.emptyText})})]})}var yt=80;function bt(e,t){let n=Math.min(t,yt),r=(e??``).split(/\r?\n/).find(e=>e.trim()!==``);if(r===void 0)return``;let i=r.replace(/\s+/g,` `).trim();if(i.length<=n)return i;let a=i.slice(0,n+1).lastIndexOf(` `);return(a>0?i.slice(0,a):i.slice(0,n)).replace(/[ ,;:.-]+$/,``)}function xt({id:e,label:t=`Attachments`,files:n,onChange:r,config:i,error:a}){let o=i?.maxAttachmentBytes??0,s=o>0?Math.max(.1,Math.round(o/1048576*10)/10):0;return/* @__PURE__ */ p(k,{id:e,label:t,optional:!0,multiple:!0,value:n,onChange:r,accept:Ee(i),maxSizeMb:s,validate:!1,error:a||void 0})}var St={title:`These may already answer your question`};function Ct({items:e}){let t=$(`suggestedAnswers`,St);return e.length===0?null:/* @__PURE__ */ p(b,{variant:`filled`,padding:`sm`,title:t.title,children:/* @__PURE__ */ p(`ul`,{className:`list-unstyled mb-0 d-flex flex-column gap-2`,children:e.map(e=>/* @__PURE__ */ m(`li`,{children:[/* @__PURE__ */ p(`div`,{className:`fw-semibold`,children:e.title}),/* @__PURE__ */ p(`div`,{className:`small text-body-secondary`,children:e.summary})]},e.title))})})}var wt={bodyRequired:`Enter what happened.`,sendFailed:`Your ticket did not send. Please try again.`,messageLabel:`Message`,messagePlaceholder:`What happened, and what did you expect to happen?`,messageHint:`You can paste an image into the message.`,subjectLabel:`Subject`,subjectPlaceholder:`A short summary`,subjectHint:`Filled in from your message. You can change it.`,categoryLabel:`Category (optional)`,categoryPlaceholder:`Choose a category`,categoryHint:`Not sure? Leave it empty and we will sort it.`},Tt=500,Et=3,Dt=5;function Ot(e,t){return t&&e.includes(t)?t:``}function kt({id:e,config:t,defaultCategory:n,initialValues:i,onValuesChange:a,extraFiles:o=[],onSubmit:c,onBusyChange:l,children:u}){let d=$(`ticketForm`,wt),f=$(`shared`,X),h=t?.categories??[],_=t?.subjectMaxLength??1/0,[v,y]=s(()=>i?.category??Ot(h,n)),[b,x]=s(i?.body??``),[S,C]=s(()=>i?.subject||bt(i?.body??``,_)),[w,T]=s(()=>{let e=(i?.subject??``).trim();return e!==``&&e!==bt(i?.body??``,_)}),[E,D]=s(i?.files??[]),[O,k]=s({}),[A,j]=s(``),M=Ze(),[P,F]=s(``),[I,L]=s([]),R=He(S.trim(),Tt);r(()=>{a?.({category:v,subject:S,body:b,files:E})},[v,S,b,E,a]),r(()=>{F(R)},[R]),r(()=>{if(P.length<Et){L([]);return}let e=!0,t=new AbortController;return L([]),M.getSuggestions(P,{signal:t.signal}).then(t=>{e&&L(Array.isArray(t)?t.slice(0,Dt):[])},()=>{e&&L([])}),()=>{e=!1,t.abort()}},[M,P]);let z=e=>{D(e),k(n=>({...n,files:Oe([...o,...e],t,f)??void 0}))},ee=e=>{let t=Me(e);t.length>0&&z([...E,...t])},V=e=>{let t=e.target.value;x(t),w||C(bt(t,_)),O.body&&k(e=>({...e,body:t.trim()?void 0:d.bodyRequired}))},te=e=>{let t=e.target.value;C(t),T(t.trim()!==``)};function H(){let e={};b.trim()||(e.body=d.bodyRequired);let n=Oe([...o,...E],t,f);return n&&(e.files=n),k(e),Object.keys(e).length===0}async function ne(e){if(e.preventDefault(),j(``),H()){l?.(!0);try{await c({category:v,subject:S.trim()||bt(b,_),body:b.trim(),files:E})}catch(e){j(Z(e,d.sendFailed,f.offline))}finally{l?.(!1)}}}return/* @__PURE__ */ m(`form`,{id:e,onSubmit:ne,noValidate:!0,className:`d-flex flex-column gap-3`,children:[A&&/* @__PURE__ */ p(g,{tone:`danger`,children:A}),/* @__PURE__ */ p(U,{id:`${e}-body`,label:d.messageLabel,required:!0,rows:6,maxLength:t?.bodyMaxLength,showCount:!0,placeholder:d.messagePlaceholder,value:b,onChange:V,onPaste:ee,helperText:d.messageHint,error:O.body}),/* @__PURE__ */ p(N,{id:`${e}-subject`,label:d.subjectLabel,maxLength:t?.subjectMaxLength,showCount:!0,placeholder:d.subjectPlaceholder,helperText:d.subjectHint,value:S,onChange:te,onBlur:()=>F(S.trim())}),/* @__PURE__ */ p(Ct,{items:I}),/* @__PURE__ */ p(B,{id:`${e}-category`,label:d.categoryLabel,value:v,onChange:y,options:h.map(e=>({value:e,label:e})),placeholder:d.categoryPlaceholder,helperText:d.categoryHint,error:O.category}),u,/* @__PURE__ */ p(xt,{id:`${e}-files`,files:E,onChange:z,config:t,error:O.files})]})}var At={captureEmpty:`The page capture came back empty.`,retake:`Retake`,removeScreenshot:`Remove screenshot`,addScreenshot:`Add a screenshot`,screenshotNote:`Only what is on your screen now. You can remove it before sending.`,screenshotFailed:`We could not take a screenshot of this page. You can attach an image instead, or send the report without one.`,screenshotTitle:`Screenshot`,screenshotLabel:`Screenshot of the page you were on`,viewTicket:`View ticket`,close:`Close`,cancel:`Cancel`,submit:`Submit`,takingScreenshot:`Taking a screenshot`,title:`Report an issue`,subtitle:`Tell us what went wrong. You can add a screenshot of this page if it helps.`,confirmDiscard:`Discard this report?`,createdTitle:`Ticket {number} is with the support team`,createdText:`We reply by email. You can follow the ticket on your support page.`,configError:`We could not load the support settings.`,loading:`Loading the form.`},jt=`supportCapture`,Mt={zIndex:`var(--wui-z-fixed)`,bottom:0,insetInlineEnd:0},Nt={zIndex:`var(--wui-z-fixed)`},Pt={maxWidth:`20rem`},Ft=e=>e.dataset?.[jt]===`exclude`||e.matches?.(`.modal-backdrop`)?!1:!(e.matches?.(`.modal`)&&e.querySelector?.(`[data-support-capture="exclude"]`)),It=()=>new Promise(e=>requestAnimationFrame(()=>e()));async function Lt(e){let t=await re(document.body,{filter:Ft,pixelRatio:Math.min(window.devicePixelRatio||1,2),style:{overflow:`visible`,paddingRight:`0px`}});if(!t)throw Error(e);return new File([t],`screenshot.png`,{type:`image/png`})}function Rt({t:e,file:t,failed:n,disabled:i,hintId:a,controlRef:o,onAdd:c,onRemove:l}){let[u,d]=s(null);return r(()=>{if(!t)return;let e=URL.createObjectURL(t);return d(e),()=>URL.revokeObjectURL(e)},[t]),/* @__PURE__ */ m(`div`,{className:`d-flex flex-column gap-2`,children:[/* @__PURE__ */ p(`span`,{className:`wui-text-sm fw-semibold`,children:e.screenshotTitle}),t&&u&&/* @__PURE__ */ p(`img`,{src:u,alt:e.screenshotLabel,className:`d-block w-100 border rounded`,style:Pt}),/* @__PURE__ */ p(`div`,{ref:o,className:`d-flex flex-wrap gap-2`,children:t?/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ p(y,{variant:`outline`,size:`sm`,leftIcon:`refresh-cw`,onClick:c,disabled:i,"aria-describedby":a,children:e.retake}),/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,leftIcon:`x`,onClick:l,disabled:i,children:e.removeScreenshot})]}):/* @__PURE__ */ p(y,{variant:`outline`,size:`sm`,leftIcon:`camera`,onClick:c,disabled:i,"aria-describedby":a,children:e.addScreenshot})}),/* @__PURE__ */ p(`span`,{id:a,className:`wui-text-sm text-body-secondary`,children:e.screenshotNote}),n&&/* @__PURE__ */ p(g,{tone:`info`,children:e.screenshotFailed})]})}function zt({label:e=`Report an issue`,floating:t=!1,compact:n=!1,defaultCategory:a=`Bug report`,appVersion:c,getTicketHref:l,onOpenTicket:u,onCreated:d,className:h,style:_}){let v=$(`reportIssue`,At),b=$(`shared`,X),x=Ze(),{config:S,error:C}=tt(),w=`support-report-${i().replace(/[^a-zA-Z0-9-]/g,``)}`,[T,E]=s(!1),[D,O]=s(!1),[k,j]=s(null),[M,N]=s(!1),[P,F]=s(!1),[I,R]=s(null),[z,B]=s(null),ee=o(null),V=o(!1);r(()=>{!D&&V.current&&(V.current=!1,ee.current?.querySelector(`button`)?.focus())},[D]);function te(){R(null),j(null),N(!1),B(null),E(!0)}async function H(){O(!0),N(!1),await It(),await It();try{j(await Lt(v.captureEmpty))}catch{j(null),N(!0)}finally{V.current=!0,O(!1)}}let U=()=>{P||(E(!1),j(null),N(!1),R(null),B(null))};async function ne(e){let t=await x.createTicket({...e,pageUrl:window.location.href,userAgent:navigator.userAgent,appVersion:c,screenshots:k?[k]:[]});R(t),j(null),d?.(t)}let re=!I&&(!!k||!!z&&(z.subject.trim()!==``||z.body.trim()!==``||z.files.length>0)),W=I&&l?l(I.id):void 0,G=I&&(W||u)?/* @__PURE__ */ p(y,{href:W,onClick:W?void 0:()=>{E(!1),R(null),u(I)},children:v.viewTicket}):null,ie=I?/* @__PURE__ */ m(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ p(y,{variant:`soft`,onClick:U,children:v.close}),G]}):/* @__PURE__ */ m(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ p(y,{variant:`soft`,onClick:U,disabled:P,children:v.cancel}),/* @__PURE__ */ p(y,{type:`submit`,form:w,loading:P,disabled:!S,children:v.submit})]}),K=n?/* @__PURE__ */ p(A,{icon:`bug`,label:e,order:`secondary`,size:`sm`,variant:`soft`,stacked:t,className:t?h:void 0,style:t?_:void 0,disabled:D,onClick:te,"aria-haspopup":`dialog`}):/* @__PURE__ */ p(y,{leftIcon:`bug`,variant:t?`solid`:`outline`,disabled:D,onClick:te,"aria-haspopup":`dialog`,children:e});return/* @__PURE__ */ m(f,{children:[t&&n?K:/* @__PURE__ */ p(`span`,{"data-support-capture":`exclude`,className:[t?`position-fixed m-3`:`d-inline-block`,h].filter(Boolean).join(` `),style:t?{...Mt,..._}:_,children:K}),D&&/* @__PURE__ */ m(`div`,{"data-support-capture":`exclude`,role:`status`,className:`position-fixed top-0 start-50 translate-middle-x mt-3 d-flex align-items-center gap-2 px-3 py-2 bg-body border rounded-pill shadow-sm wui-text-sm`,style:Nt,children:[/* @__PURE__ */ p(`span`,{className:`spinner-border spinner-border-sm`,"aria-hidden":`true`}),v.takingScreenshot]}),/* @__PURE__ */ p(L,{open:T,size:`lg`,title:v.title,subtitle:v.subtitle,headerIcon:`bug`,confirmDiscard:v.confirmDiscard,dirty:re&&!P,onClose:U,footer:ie,"data-support-capture":`exclude`,children:I?/* @__PURE__ */ p(g,{tone:`success`,role:`status`,title:Y(v.createdTitle,{number:I.number}),children:v.createdText}):S?/* @__PURE__ */ p(kt,{id:w,config:S,defaultCategory:a,initialValues:z,onValuesChange:B,extraFiles:k?[k]:[],onSubmit:ne,onBusyChange:F,children:/* @__PURE__ */ p(Rt,{t:v,file:k,failed:M,disabled:P||D,hintId:`${w}-screenshot-hint`,controlRef:ee,onAdd:H,onRemove:()=>j(null)})}):/* @__PURE__ */ p(g,{tone:C?`danger`:`info`,children:C?Z(C,v.configError,b.offline):v.loading})})]})}var Bt={title:`New ticket`,subtitle:`Tell us what you need. We reply by email and on this page.`,confirmDiscard:`Discard this ticket?`,cancel:`Cancel`,send:`Send ticket`};function Vt({open:e,onClose:t,onCreated:n,config:r,defaultCategory:a,appVersion:o}){let c=$(`newTicketModal`,Bt),l=Ze(),u=`support-new-${i().replace(/[^a-zA-Z0-9-]/g,``)}`,[d,f]=s(!1),[h,g]=s(null),_=!!h&&(h.subject.trim()!==``||h.body.trim()!==``||h.files.length>0);async function v(e){n(await l.createTicket({...e,userAgent:typeof navigator>`u`?void 0:navigator.userAgent,appVersion:o}))}return/* @__PURE__ */ p(L,{open:e,size:`lg`,title:c.title,subtitle:c.subtitle,headerIcon:`message-square`,confirmDiscard:c.confirmDiscard,dirty:_&&!d,onClose:()=>{d||t()},footer:/* @__PURE__ */ m(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ p(y,{variant:`soft`,onClick:t,disabled:d,children:c.cancel}),/* @__PURE__ */ p(y,{type:`submit`,form:u,loading:d,children:c.send})]}),children:e&&/* @__PURE__ */ p(kt,{id:u,config:r,defaultCategory:a,onSubmit:v,onBusyChange:f,onValuesChange:g})})}var Ht={loading:`Loading {name}`,failed:`Could not load this file. Click to try again.`},Ut=6e4,Wt=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`application/pdf`];function Gt({attachment:e}){let t=$(`attachmentThumb`,Ht),n=Ze(),[r,i]=s(!1),[a,o]=s(!1);async function c(){i(!0),o(!1);let t=Wt.includes(e.contentType)?window.open(``,`_blank`):null;t&&(t.opener=null);try{let r=await n.fetchAttachment(e.id),i=URL.createObjectURL(r);if(setTimeout(()=>URL.revokeObjectURL(i),Ut),t)t.location.href=i;else{let t=document.createElement(`a`);t.href=i,t.download=e.fileName,t.click()}}catch{t?.close(),o(!0)}finally{i(!1)}}let l=Number.isFinite(e.sizeBytes)?u(e.sizeBytes):`-`;return/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ p(x,{leadingIcon:a?`x-circle`:`paperclip`,label:r?/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ p(V,{size:`sm`,label:Y(t.loading,{name:e.fileName})}),` `,e.fileName]}):e.fileName,onClick:c,disabled:r,"aria-busy":r||void 0,title:`${e.fileName}, ${l}`}),a&&/* @__PURE__ */ p(`span`,{role:`status`,className:`wui-text-xs text-danger align-self-center`,children:t.failed})]})}var Kt={conversation:`Conversation`,you:`You`,supportTeam:`Support team`,supportBadge:`Support`},qt={whiteSpace:`pre-wrap`,overflowWrap:`anywhere`};function Jt({messages:e}){let t=$(`messageThread`,Kt);return/* @__PURE__ */ p(`ol`,{className:`list-unstyled d-flex flex-column gap-3 mb-0`,"aria-label":t.conversation,children:e.map(e=>{let n=/* @__PURE__ */ p(ot,{iso:e.createdDateTimeUtc,className:`wui-text-xs text-body-secondary text-nowrap`});if(e.authorKind===`System`)return/* @__PURE__ */ m(`li`,{className:`text-center wui-text-xs text-body-secondary`,"data-author":`system`,children:[/* @__PURE__ */ p(`span`,{className:`d-block`,children:e.body}),n]},e.id);let r=e.authorKind===`Customer`,i=e.authorName||(r?t.you:t.supportTeam);return/* @__PURE__ */ m(`li`,{className:`d-flex align-items-start gap-2${r?` flex-row-reverse`:``}`,"data-author":r?`customer`:`agent`,children:[/* @__PURE__ */ p(_,{name:i,size:32,tone:r?`neutral`:`primary`}),/* @__PURE__ */ m(b,{className:`flex-grow-1 border`,padding:`sm`,variant:r?`flat`:`accent`,style:{minWidth:0},children:[/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2 mb-2`,children:[/* @__PURE__ */ m(`span`,{className:`d-inline-flex flex-wrap align-items-center gap-2 fw-semibold wui-text-sm text-break`,children:[i,!r&&/* @__PURE__ */ p(v,{tone:`primary`,children:t.supportBadge})]}),n]}),/* @__PURE__ */ p(`div`,{className:`wui-text-sm`,style:qt,children:e.body}),e.attachments?.length>0&&/* @__PURE__ */ p(`div`,{className:`d-flex flex-wrap gap-2 mt-2`,children:e.attachments.map(e=>/* @__PURE__ */ p(Gt,{attachment:e},e.id))})]})]},e.id)})})}var Yt={solved:`You told us this solved your problem.`,notSolved:`You told us this did not solve your problem.`,sendFailed:`Your rating did not send. Please try again.`,commentLabel:`Anything to add?`,commentHint:`Optional. Your comment goes to the support team.`,yes:`Yes, it is solved`,no:`No, it is not`,heading:`Did this solve your problem?`,yourComment:`Your comment:`};function Xt({satisfaction:e,comment:t,canRate:n=!1,commentMaxLength:r,onRate:a}){let o=$(`ratingPanel`,Yt),c=$(`shared`,X),l=i(),[u,d]=s(``),[f,h]=s(null),[_,v]=s(``);if(e)return/* @__PURE__ */ m(g,{tone:e===`Satisfied`?`success`:`info`,role:`status`,children:[e===`Satisfied`?o.solved:o.notSolved,t?/* @__PURE__ */ m(`span`,{className:`d-block mt-1`,children:[o.yourComment,` `,t]}):null]});if(!n)return null;async function x(e){v(``),h(e);try{await a({satisfaction:e,comment:u})}catch(e){v(Z(e,o.sendFailed,c.offline))}finally{h(null)}}return/* @__PURE__ */ p(b,{padding:`sm`,className:`border`,title:o.heading,children:/* @__PURE__ */ m(`div`,{className:`d-flex flex-column gap-2`,children:[_&&/* @__PURE__ */ p(g,{tone:`danger`,children:_}),/* @__PURE__ */ p(U,{id:`${l}-comment`,label:o.commentLabel,rows:2,maxLength:r,value:u,onChange:e=>d(e.target.value),helperText:o.commentHint}),/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap gap-2`,children:[/* @__PURE__ */ p(y,{variant:`outline`,leftIcon:`check-circle`,loading:f===`Satisfied`,disabled:f!==null,onClick:()=>x(`Satisfied`),children:o.yes}),/* @__PURE__ */ p(y,{variant:`outline`,leftIcon:`x-circle`,loading:f===`Unsatisfied`,disabled:f!==null,onClick:()=>x(`Unsatisfied`),children:o.no})]})]})})}var Zt={emptyReply:`Write a message before you send it.`,sendFailed:`Your reply did not send. Please try again.`,replyLabel:`Your reply`,hintReopens:`Sending a reply reopens this ticket. You can paste an image into the message.`,hint:`You can paste an image into the message.`,attachedFiles:`Attached files`,removeFile:`Remove {name}`,attach:`Attach a file`,send:`Send reply`,formLabel:`Reply to this ticket`};function Qt({onSend:e,config:t,reopens:n=!1}){let r=$(`replyBox`,Zt),a=$(`shared`,X),o=i(),[c,l]=s(``),[u,d]=s([]),[f,_]=s(``),[v,b]=s(``),[C,w]=s(!1),T=e=>{let n=je(u,e,t,a);d(n.files),_(n.notice)},E=e=>{let n=u.filter((t,n)=>n!==e);d(n),_(Oe(n,t,a)??``)},D=e=>{let t=Me(e);t.length>0&&T(t)};async function O(n){n.preventDefault();let i=c.trim();if(!i){b(r.emptyReply);return}let o=Oe(u,t,a);if(o)_(o);else{b(``),w(!0);try{await e({body:i,files:u}),l(``),d([]),_(``)}catch(e){b(Z(e,r.sendFailed,a.offline))}finally{w(!1)}}}let k=v||f;return/* @__PURE__ */ m(`form`,{onSubmit:O,noValidate:!0,className:`d-flex flex-column gap-2 flex-grow-1 min-w-0`,"aria-label":r.formLabel,children:[k&&/* @__PURE__ */ p(g,{tone:`danger`,children:k}),/* @__PURE__ */ p(U,{id:`${o}-body`,label:r.replyLabel,rows:2,autoGrow:!0,maxLength:t?.bodyMaxLength,value:c,onChange:e=>{l(e.target.value),b(``)},onPaste:D,helperText:n?r.hintReopens:r.hint,required:!0}),u.length>0&&/* @__PURE__ */ p(S,{label:r.attachedFiles,children:u.map((e,t)=>/* @__PURE__ */ p(x,{leadingIcon:`paperclip`,label:e.name,removeLabel:Y(r.removeFile,{name:e.name}),onRemove:()=>E(t)},Ae(e)))}),/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2`,children:[/* @__PURE__ */ p(h,{iconVariant:`bulk`,icon:`paperclip`,label:r.attach,multiple:t?.maxAttachmentsPerMessage!==1,accept:Ee(t),onFiles:T}),/* @__PURE__ */ p(y,{type:`submit`,leftIcon:`send`,loading:C,children:r.send})]})]})}var $t={reopenFailed:`The ticket did not reopen. Please try again.`,withdrawFailed:`The request was not withdrawn. Please try again.`,back:`Back to tickets`,loadError:`We could not load this ticket.`,retry:`Try again`,fieldStatus:`Status`,fieldCategory:`Category`,fieldTicket:`Ticket`,fieldOpened:`Opened`,fieldUpdated:`Last update`,openedLabel:`Opened`,summaryLabel:`Ticket summary`,detailsLabel:`Ticket details`,detailsTitle:`Ticket details`,timeZoneNote:`Times are shown in {zone}.`,mergedText:`This ticket was merged into {number}. The conversation carries on there.`,openMerged:`Open {number}`,resolvedHint:`If you still need help, reopen the ticket or send a reply.`,waitingHint:`We need your answer to carry on. Reply below and the ticket goes back to our team.`,openHint:`Our team marks this resolved once your question is answered. Replying reopens it.`,reopen:`Reopen ticket`,withdraw:`Withdraw request`,withdrawTitle:`Withdraw this request?`,withdrawMessage:`Our team will stop working on this ticket. You can open a new ticket later if you still need help.`,withdrawConfirm:`Withdraw request`,withdrawCancel:`Keep request`,merged:`Merged into this ticket`};function en({ticketId:e,onBack:t,onChanged:n,onOpenTicket:r}){let{config:i}=tt(),a=$(`ticketDetail`,$t),o=$(`shared`,X),c=Qe(),l=$e(),{ticket:u,loading:f,error:h,reload:_,reply:v,reopen:x,cancel:S,rate:C}=it(e),[T,E]=s(!1),[O,k]=s(!1),[A,N]=s(!1),[P,F]=s(``),I=async e=>{let t=await e();return n?.(),t};async function L(){F(``),E(!0);try{await I(x)}catch(e){F(Z(e,a.reopenFailed,o.offline))}finally{E(!1)}}async function R(){F(``),N(!0);try{await I(S)}catch(e){F(Z(e,a.withdrawFailed,o.offline))}finally{N(!1),k(!1)}}let z=/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,leftIcon:`arrow-left`,onClick:t,className:`align-self-start`,children:a.back});if(!u)return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3`,"aria-busy":f||void 0,children:[z,h?/* @__PURE__ */ m(g,{tone:`danger`,children:[Z(h,a.loadError,o.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:_,children:a.retry})]}):/* @__PURE__ */ p(ee,{height:160})]});let B=Pe(u.status),V=[{key:`status`,label:a.fieldStatus,value:u.statusLabel?/* @__PURE__ */ p(te,{label:u.statusLabel,tone:B}):`-`},{key:`category`,label:a.fieldCategory,value:u.category||`-`},{key:`ticket`,label:a.fieldTicket,value:u.number},{key:`opened`,label:a.fieldOpened,value:/* @__PURE__ */ p(ot,{iso:u.createdDateTimeUtc})},{key:`updated`,label:a.fieldUpdated,value:/* @__PURE__ */ p(ot,{iso:u.updatedDateTimeUtc})}];return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3`,"aria-labelledby":`support-ticket-${u.id}`,children:[z,/* @__PURE__ */ m(`div`,{className:`row g-3`,children:[/* @__PURE__ */ m(`div`,{className:`col-12 col-lg-8 d-flex flex-column gap-3`,children:[/* @__PURE__ */ m(`header`,{className:`d-flex flex-column gap-2`,children:[/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap align-items-center gap-2`,children:[/* @__PURE__ */ p(`h2`,{id:`support-ticket-${u.id}`,className:`h5 mb-0 text-break`,children:u.subject}),u.statusLabel&&/* @__PURE__ */ p(te,{label:u.statusLabel,tone:B})]}),/* @__PURE__ */ m(`ul`,{className:`list-unstyled d-flex flex-wrap gap-3 mb-0 wui-text-sm text-body-secondary`,"aria-label":a.summaryLabel,children:[u.number&&/* @__PURE__ */ m(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ p(M,{variant:`bulk`,name:`receipt-text`,size:16}),u.number]}),u.category&&/* @__PURE__ */ m(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ p(M,{variant:`bulk`,name:`folder-2`,size:16}),u.category]}),/* @__PURE__ */ m(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ p(M,{variant:`bulk`,name:`calendar-1`,size:16}),a.openedLabel,` `,/* @__PURE__ */ p(ot,{iso:u.createdDateTimeUtc})]})]}),l===null&&/* @__PURE__ */ p(`p`,{className:`wui-text-xs text-body-secondary mb-0`,children:Y(a.timeZoneNote,{zone:d(c)})})]}),P&&/* @__PURE__ */ p(g,{tone:`danger`,children:P}),u.mergedInto&&/* @__PURE__ */ m(g,{tone:`info`,role:`status`,children:[Y(a.mergedText,{number:u.mergedInto.number}),` `,r&&/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:()=>r(u.mergedInto.id),children:Y(a.openMerged,{number:u.mergedInto.number})})]}),u.canReopen&&/* @__PURE__ */ p(g,{tone:`success`,role:`status`,children:a.resolvedHint}),u.status===`WaitingOnCustomer`&&/* @__PURE__ */ p(g,{tone:`warning`,role:`status`,children:a.waitingHint}),!u.canReopen&&/* @__PURE__ */ p(`p`,{className:`wui-text-sm text-body-secondary mb-0`,children:a.openHint}),u.canReopen&&/* @__PURE__ */ p(y,{variant:`soft`,leftIcon:`history`,loading:T,onClick:L,className:`align-self-start`,children:a.reopen}),u.canCancel&&/* @__PURE__ */ p(y,{variant:`soft`,onClick:()=>k(!0),className:`align-self-start`,children:a.withdraw}),/* @__PURE__ */ p(w,{open:O,title:a.withdrawTitle,description:a.withdrawMessage,confirmLabel:a.withdrawConfirm,cancelLabel:a.withdrawCancel,tone:`danger`,loading:A,onConfirm:R,onClose:()=>k(!1)}),/* @__PURE__ */ p(Xt,{satisfaction:u.satisfaction,comment:u.satisfactionComment,canRate:u.canRate,commentMaxLength:i?.satisfactionCommentMaxLength,onRate:e=>I(()=>C(e))}),/* @__PURE__ */ p(Jt,{messages:u.messages??[]}),u.mergedTickets?.length>0&&/* @__PURE__ */ m(`section`,{"aria-labelledby":`support-merged-${u.id}`,className:`d-flex flex-column gap-1`,children:[/* @__PURE__ */ p(`h3`,{id:`support-merged-${u.id}`,className:`h6 mb-0`,children:a.merged}),/* @__PURE__ */ p(`ul`,{className:`list-unstyled d-flex flex-column gap-1 mb-0 wui-text-sm`,children:u.mergedTickets.map(e=>/* @__PURE__ */ p(`li`,{children:r?/* @__PURE__ */ m(y,{variant:`ghost`,size:`sm`,onClick:()=>r(e.id),children:[e.number,`: `,e.subject]}):`${e.number}: ${e.subject}`},e.id))})]}),!u.mergedInto&&/* @__PURE__ */ p(j,{sticky:!0,align:`start`,children:/* @__PURE__ */ p(Qt,{config:i,reopens:u.canReopen,onSend:e=>I(()=>v(e))})})]}),/* @__PURE__ */ p(`aside`,{"aria-label":a.detailsLabel,className:`col-12 col-lg-4`,children:/* @__PURE__ */ m(b,{padding:`sm`,className:`border`,children:[/* @__PURE__ */ p(`h3`,{className:`h6`,children:a.detailsTitle}),/* @__PURE__ */ p(D,{columns:1,items:V})]})})]})]})}var tn=`ticket`;function nn(){return typeof window>`u`?null:new URLSearchParams(window.location.search).get(tn)}function rn(e){if(typeof window>`u`)return e?`?${tn}=${encodeURIComponent(e)}`:`?`;let t=new URL(window.location.href);return e?t.searchParams.set(tn,e):t.searchParams.delete(tn),`${t.pathname}${t.search}${t.hash}`}function an(e){if(typeof window>`u`)return;let t=rn(e);t!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,t)}var on={tabAll:`All`,tabOpen:`Open`,tabNeedsReply:`Needs your reply`,tabResolved:`Resolved`,tabWithdrawn:`Withdrawn`,columnSubject:`Subject`,columnStatus:`Status`,columnMessages:`Messages`,columnLastUpdate:`Last update`,loadError:`We could not load your tickets.`,retry:`Try again`,statusSelect:`Status`,filterByStatus:`Filter tickets by status`,searchPlaceholder:`Search tickets`,searchLabel:`Search tickets`,tableLabel:`Support tickets`,actions:`Actions`,openTicket:`Open ticket {subject}`,emptyTitle:`No tickets yet`,emptyText:`When you raise a ticket, it shows here with its status.`,noMatchTitle:`No tickets match`,noMatchText:`Try another search or status.`},sn=[`tabs`,`select`,`none`];function cn({tickets:e,loading:t,error:n,onRetry:r,onOpen:i,status:a,onStatusChange:o,statusFilter:s=`tabs`,counts:c,search:l,onSearchChange:u,pagination:d}){let f=$(`ticketList`,on),_=$(`shared`,X);ne(`SupportCenter`,`statusFilter`,s,sn);let v=[{key:`all`,label:f.tabAll,countKey:`total`},{key:`Open`,label:f.tabOpen,countKey:`open`},{key:`NeedsReply`,label:f.tabNeedsReply,countKey:`needsReply`},{key:`Resolved`,label:f.tabResolved,countKey:`resolved`},{key:`Withdrawn`,label:f.tabWithdrawn,countKey:`withdrawn`}],b=v.map(({key:e,label:t,countKey:n})=>{let r=c?.[n];return{value:e,label:r==null?t:`${t} (${r})`}}),x=(e,t)=>{e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),i(t))},S=[{key:`subject`,label:f.columnSubject,render:e=>/* @__PURE__ */ m(`div`,{className:`d-flex flex-column`,style:{minWidth:0},children:[/* @__PURE__ */ p(P,{href:rn(e.id),animation:`none`,className:`fw-semibold text-break`,onClick:t=>x(t,e.id),children:e.subject}),/* @__PURE__ */ m(`span`,{className:`wui-text-xs text-body-secondary`,children:[e.number,`, `,e.category]})]})},{key:`status`,label:f.columnStatus,render:e=>e.statusLabel?/* @__PURE__ */ p(te,{label:e.statusLabel,tone:Pe(e.status)}):`-`},{key:`messageCount`,label:f.columnMessages,cellClassName:`wui-text-sm text-body-secondary`,render:e=>e.messageCount},{key:`updatedDateTimeUtc`,label:f.columnLastUpdate,cellClassName:`wui-text-sm text-body-secondary text-nowrap`,render:e=>/* @__PURE__ */ p(ot,{iso:e.updatedDateTimeUtc})}];return/* @__PURE__ */ m(`div`,{className:`d-flex flex-column gap-3`,children:[n&&/* @__PURE__ */ m(g,{tone:`danger`,children:[Z(n,f.loadError,_.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:r,children:f.retry})]}),/* @__PURE__ */ m(`div`,{className:`d-flex flex-column flex-md-row gap-2 align-items-md-center justify-content-between`,children:[s===`none`?null:s===`select`?/* @__PURE__ */ p(B,{label:f.statusSelect,value:a,onChange:o,options:b,fieldClassName:`flex-shrink-0`}):/* @__PURE__ */ p(H,{tabs:v.map(({key:e,label:t,countKey:n})=>({key:e,label:t,count:c?.[n]})),value:a,onChange:o,ariaLabel:f.filterByStatus,overflow:`menu`,className:`flex-grow-1`}),/* @__PURE__ */ p(z,{value:l,onChange:u,placeholder:f.searchPlaceholder,ariaLabel:f.searchLabel})]}),/* @__PURE__ */ p(E,{columns:S,rows:e,loading:t,skeletonRows:4,ariaLabel:f.tableLabel,rowActionsLabel:f.actions,rowActions:e=>/* @__PURE__ */ p(h,{icon:`eye`,label:Y(f.openTicket,{subject:e.subject}),href:rn(e.id),onClick:t=>x(t,e.id)}),stickyActions:!0,stackOnMobile:!0,sourceCount:c?.total??0,pagination:d,empty:/* @__PURE__ */ p(O,{variant:`table`,icon:`message-square`,title:f.emptyTitle,description:f.emptyText}),emptyFiltered:/* @__PURE__ */ p(O,{variant:`table`,icon:`search`,title:f.noMatchTitle,description:f.noMatchText})})]})}var ln=300,un=10,dn={heading:`Your tickets`,newTicket:`New ticket`,configError:`We could not load the support settings.`,retry:`Try again`};function fn({initialTicketId:e,defaultCategory:t,appVersion:n,status:i,defaultStatus:a=`all`,onStatusChange:o,statusFilter:c=`tabs`}){let l=$(`supportCenter`,dn),u=$(`shared`,X),{config:d,error:f,reload:h}=tt(),[_,v]=s(a),b=i!==void 0,x=b?i:_,S=e=>{b||v(e),o?.(e)},[C,w]=s(``),T=He(C.trim(),ln),[E,D]=s(un),O=`${x}|${T}|${E}`,[k,A]=s({key:O,page:1}),j=k.key===O?k.page:1,M=e=>A({key:O,page:e}),N=nt({status:x===`all`?void 0:x,search:T||void 0,page:j,pageSize:E}),{counts:P,reload:F}=rt(),[I,L]=s(()=>e||nn()),[R,z]=s(!1),B=N.totalPages;r(()=>{B>0&&j>B&&A({key:O,page:B})},[B,j,O]);let ee=()=>{N.reload(),F()},V=e=>{L(e),an(e)};if(I)return/* @__PURE__ */ p(en,{ticketId:I,onBack:()=>V(null),onChanged:ee,onOpenTicket:V},I);let te={page:j,totalPages:Math.max(1,N.totalPages),pageSize:E,total:N.totalCount,setPage:M,setPageSize:D};return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-labelledby":`support-center-title`,children:[/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2`,children:[/* @__PURE__ */ p(`h2`,{id:`support-center-title`,className:`h5 mb-0`,children:l.heading}),/* @__PURE__ */ p(y,{leftIcon:`plus`,onClick:()=>z(!0),disabled:!d,children:l.newTicket})]}),f&&/* @__PURE__ */ m(g,{tone:`warning`,children:[Z(f,l.configError,u.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:h,children:l.retry})]}),/* @__PURE__ */ p(cn,{tickets:N.tickets,loading:N.loading,error:N.error,onRetry:ee,onOpen:V,status:x,onStatusChange:S,statusFilter:c,counts:P,search:C,onSearchChange:w,pagination:te}),d&&/* @__PURE__ */ p(Vt,{open:R,onClose:()=>z(!1),config:d,defaultCategory:t,appVersion:n,onCreated:e=>{z(!1),ee(),V(e.id)}})]})}var pn={copyEmail:`Copy email`,emailCopied:`Email copied`,contactNamed:`Contact {name}`,contactSupport:`Contact support`},mn=e=>typeof e==`string`&&e.trim()!==``;function hn({className:e}){let t=$(`supportContact`,pn),{config:n}=tt();if(!n)return null;let r=mn(n.supportEmail),i=mn(n.supportPhone),a=mn(n.supportHours),o=[`d-flex flex-wrap align-items-center gap-2 wui-text-sm`,e].filter(Boolean).join(` `);return/* @__PURE__ */ m(`section`,{className:o,"aria-label":mn(n.supportName)?Y(t.contactNamed,{name:n.supportName}):t.contactSupport,children:[/* @__PURE__ */ p(`span`,{className:`fw-semibold`,children:mn(n.supportName)?n.supportName:t.contactSupport}),r&&/* @__PURE__ */ m(`span`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ p(`a`,{href:`mailto:${n.supportEmail}`,className:`text-break`,children:n.supportEmail}),/* @__PURE__ */ p(T,{text:n.supportEmail,iconOnly:!0,label:t.copyEmail,copiedLabel:t.emailCopied})]}),i&&/* @__PURE__ */ p(`a`,{href:`tel:${n.supportPhone.replace(/[^\d+]/g,``)}`,children:n.supportPhone}),a&&/* @__PURE__ */ p(`span`,{className:`text-body-secondary`,children:n.supportHours})]})}function gn({client:e,timeZone:n=c,renderTime:r,labels:i,children:s}){let l=o(null),u=t((t=!1)=>{let n=l.current;if(t||!n||n.client!==e){let t=e.getConfig(),n={client:e,pending:t};return l.current=n,t.catch(()=>{l.current===n&&(l.current=null)}),t}return n.pending},[e]),d=a(()=>({client:e,loadConfig:u,timeZone:n,renderTime:r,labels:i}),[e,u,n,r,i]);return/* @__PURE__ */ p(Ye.Provider,{value:d,children:s})}export{ft as HelpArticle,vt as HelpCentre,zt as ReportIssue,Te as SupportAgentProvider,Ve as SupportAgentTicket,G as SupportApiError,fn as SupportCenter,hn as SupportContact,gn as SupportProvider,qe as SupportQueue,at as createHelpCentreClient,de as createSupportAgentClient,le as createSupportClient,_t as useHelpCentre,he as useSupportAgentClient,ve as useSupportAgentLabels,_e as useSupportAgentRenderTime,we as useSupportAgentSettings,Se as useSupportAgentTicket,ge as useSupportAgentTimeZone,Ce as useSupportAgents,Ze as useSupportClient,tt as useSupportConfig,be as useSupportQueue,xe as useSupportQueueCounts,it as useSupportTicket,rt as useSupportTicketCounts,nt as useSupportTickets};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* How to reach support on one line: the name, the email address with a copy button, the phone
|
|
3
|
-
* number as a call link and the hours. A field the product has not set is left out;
|
|
4
|
-
*
|
|
3
|
+
* number as a call link and the hours. A field the product has not set is left out; with none
|
|
4
|
+
* set, only the heading renders.
|
|
5
5
|
*
|
|
6
6
|
* @param {object} props
|
|
7
7
|
* @param {string} [props.className]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Makes an agent support client available to the agent queue, ticket and hooks below it.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} props
|
|
5
|
+
* @param {import('./client.js').SupportAgentClient} props.client From `createSupportAgentClient(http)`.
|
|
6
|
+
* @param {string} [props.timeZone="Asia/Kolkata"] IANA zone every ticket and message time is shown in.
|
|
7
|
+
* @param {(iso: string) => import('react').ReactNode} [props.renderTime] Draws every ticket and message time instead of the built-in date and time.
|
|
8
|
+
* @param {Record<string, Record<string, string>>} [props.labels] Replaces any built-in English text. Keyed by scope (supportQueue, agentTicket), then by key. Give only the keys you change.
|
|
9
|
+
* @param {import('react').ReactNode} props.children
|
|
10
|
+
*/
|
|
11
|
+
export default function SupportAgentProvider({ client, timeZone, renderTime, labels, children }: {
|
|
12
|
+
client: import('./client.js').SupportAgentClient;
|
|
13
|
+
timeZone?: string;
|
|
14
|
+
renderTime?: (iso: string) => import('react').ReactNode;
|
|
15
|
+
labels?: Record<string, Record<string, string>>;
|
|
16
|
+
children: import('react').ReactNode;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One ticket for a support agent: its facts, the conversation with internal notes marked, a reply
|
|
3
|
+
* or internal note, and the controls to change its status, priority, category and assignee.
|
|
4
|
+
* Every write sends the ticket's current version; a 409 keeps the reply text and asks for a reload.
|
|
5
|
+
*
|
|
6
|
+
* @param {object} props
|
|
7
|
+
* @param {string} props.ticketId
|
|
8
|
+
* @param {() => void} props.onBack Return to the queue.
|
|
9
|
+
* @param {Record<string, string>} [props.labels] Overrides the built-in English for this screen.
|
|
10
|
+
*/
|
|
11
|
+
export default function SupportAgentTicket({ ticketId, onBack, labels }: {
|
|
12
|
+
ticketId: string;
|
|
13
|
+
onBack: () => void;
|
|
14
|
+
labels?: Record<string, string>;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const meta: {
|
|
2
|
+
readonly name: "SupportAgentTicket";
|
|
3
|
+
readonly marker: null;
|
|
4
|
+
readonly platforms: readonly ["web"];
|
|
5
|
+
readonly acceptsChildren: false;
|
|
6
|
+
readonly props: {
|
|
7
|
+
readonly ticketId: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly description: "The ticket to show. Its facts, conversation and controls load from the agent client.";
|
|
10
|
+
};
|
|
11
|
+
readonly onBack: {
|
|
12
|
+
readonly type: "any";
|
|
13
|
+
readonly description: "Called when the agent presses the back button to return to the queue.";
|
|
14
|
+
};
|
|
15
|
+
readonly labels: {
|
|
16
|
+
readonly type: "object";
|
|
17
|
+
readonly description: "Overrides the built-in English for this screen, keyed by string key. Give only the keys you change.";
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
readonly examples: readonly [];
|
|
21
|
+
readonly usage: {
|
|
22
|
+
readonly when: readonly ["A support agent works one ticket: reads the thread, replies or adds an internal note, and changes its status, priority, category or assignee."];
|
|
23
|
+
readonly whenNot: readonly [{
|
|
24
|
+
readonly text: "The customer reads or replies to their own ticket.";
|
|
25
|
+
readonly instead: "SupportCenter";
|
|
26
|
+
}];
|
|
27
|
+
readonly do: readonly [];
|
|
28
|
+
readonly dont: readonly [];
|
|
29
|
+
readonly a11y: readonly ["The conversation is an ordered list named Conversation, and an internal note carries an Internal badge in its text.", "A conflict or failure is shown as an alert above the reply box, and the reply text is kept."];
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The support agent's queue: a counts strip, filters, search and one page of tickets. Every
|
|
3
|
+
* filter, the search and the paging go to the server; this only shows what it is given. A plain
|
|
4
|
+
* click on a ticket number opens it in place through `onOpenTicket`; a modified click keeps the
|
|
5
|
+
* link's own behaviour, and `getTicketHref` gives each number a real address. With no
|
|
6
|
+
* `getTicketHref` the number is a button that calls `onOpenTicket`; with neither it is plain text.
|
|
7
|
+
*
|
|
8
|
+
* @param {object} props
|
|
9
|
+
* @param {(id: string) => void} [props.onOpenTicket]
|
|
10
|
+
* @param {(id: string) => string} [props.getTicketHref]
|
|
11
|
+
* @param {string} [props.status] The status filter's value, when the product drives it.
|
|
12
|
+
* @param {(status: string) => void} [props.onStatusChange] Called with the status the agent picks.
|
|
13
|
+
* @param {string} [props.defaultStatus="all"] The status to start on when `status` is not passed.
|
|
14
|
+
* @param {string} [props.queue] The queue key to list; every queue when left out.
|
|
15
|
+
* @param {number} [props.pageSize=10]
|
|
16
|
+
*/
|
|
17
|
+
export default function SupportQueue({ onOpenTicket, getTicketHref, status: statusProp, onStatusChange, defaultStatus, queue, pageSize: initialPageSize, }: {
|
|
18
|
+
onOpenTicket?: (id: string) => void;
|
|
19
|
+
getTicketHref?: (id: string) => string;
|
|
20
|
+
status?: string;
|
|
21
|
+
onStatusChange?: (status: string) => void;
|
|
22
|
+
defaultStatus?: string;
|
|
23
|
+
queue?: string;
|
|
24
|
+
pageSize?: number;
|
|
25
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export declare const meta: {
|
|
2
|
+
readonly name: "SupportQueue";
|
|
3
|
+
readonly marker: null;
|
|
4
|
+
readonly platforms: readonly ["web"];
|
|
5
|
+
readonly acceptsChildren: false;
|
|
6
|
+
readonly props: {
|
|
7
|
+
readonly onOpenTicket: {
|
|
8
|
+
readonly type: "any";
|
|
9
|
+
readonly description: "Called with a ticket's id when a row opens it in place. Left out, the ticket number is a link only.";
|
|
10
|
+
};
|
|
11
|
+
readonly getTicketHref: {
|
|
12
|
+
readonly type: "any";
|
|
13
|
+
readonly description: "Called with a ticket's id and returns the address of its page, so each ticket number is a real link.";
|
|
14
|
+
};
|
|
15
|
+
readonly status: {
|
|
16
|
+
readonly type: "string";
|
|
17
|
+
readonly description: "The status filter's value, when the product drives it. Pass onStatusChange with it.";
|
|
18
|
+
};
|
|
19
|
+
readonly onStatusChange: {
|
|
20
|
+
readonly type: "any";
|
|
21
|
+
readonly description: "Called with the status value the agent picks, for a product that drives the status filter.";
|
|
22
|
+
};
|
|
23
|
+
readonly defaultStatus: {
|
|
24
|
+
readonly type: "string";
|
|
25
|
+
readonly default: "all";
|
|
26
|
+
readonly description: "The status filter's starting value when the product does not drive it.";
|
|
27
|
+
};
|
|
28
|
+
readonly queue: {
|
|
29
|
+
readonly type: "string";
|
|
30
|
+
readonly description: "The queue key to list. Every queue the agent can see when left out.";
|
|
31
|
+
};
|
|
32
|
+
readonly pageSize: {
|
|
33
|
+
readonly type: "number";
|
|
34
|
+
readonly default: 10;
|
|
35
|
+
readonly description: "Tickets per page. The server pages the list; the table never holds more than one page.";
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
readonly omit: readonly [];
|
|
39
|
+
readonly examples: readonly [{
|
|
40
|
+
readonly id: "SupportQueue";
|
|
41
|
+
readonly title: "Default";
|
|
42
|
+
readonly props: {};
|
|
43
|
+
}, {
|
|
44
|
+
readonly id: "SupportQueue.queue";
|
|
45
|
+
readonly title: "One queue";
|
|
46
|
+
readonly props: {
|
|
47
|
+
readonly queue: "Support";
|
|
48
|
+
readonly pageSize: 20;
|
|
49
|
+
};
|
|
50
|
+
}];
|
|
51
|
+
readonly usage: {
|
|
52
|
+
readonly when: readonly ["A support agent works through the tickets in their queue.", "The agent narrows the queue by status, priority, category, place, assignee, unassigned or overdue, or searches it."];
|
|
53
|
+
readonly whenNot: readonly [];
|
|
54
|
+
readonly do: readonly [];
|
|
55
|
+
readonly dont: readonly [];
|
|
56
|
+
readonly a11y: readonly ["The queue is a section labelled by its Ticket queue heading, and the counts strip is a list of figures.", "Each ticket number is a link to the ticket, and a plain click opens it in place.", "Overdue is shown as text beside the due time, never as colour alone."];
|
|
57
|
+
};
|
|
58
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export type AgentTicketListQuery = {
|
|
2
|
+
/**
|
|
3
|
+
* Open, InProgress, WaitingOnCustomer, Resolved, Closed or Cancelled.
|
|
4
|
+
*/
|
|
5
|
+
status?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Low, Normal, High or Urgent.
|
|
8
|
+
*/
|
|
9
|
+
priority?: string;
|
|
10
|
+
category?: string;
|
|
11
|
+
realm?: string;
|
|
12
|
+
assignedAgentUserId?: number | string;
|
|
13
|
+
unassignedOnly?: boolean;
|
|
14
|
+
overdueOnly?: boolean;
|
|
15
|
+
unsettledOnly?: boolean;
|
|
16
|
+
awaitingAgentOnly?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* With no status, also lists the resolved, closed and cancelled tickets.
|
|
19
|
+
*/
|
|
20
|
+
includeSettled?: boolean;
|
|
21
|
+
queue?: string;
|
|
22
|
+
search?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Newest, Oldest, RecentlyUpdated or LeastRecentlyUpdated.
|
|
25
|
+
*/
|
|
26
|
+
order?: string;
|
|
27
|
+
page?: number;
|
|
28
|
+
pageSize?: number;
|
|
29
|
+
};
|
|
30
|
+
export type SupportAgentClient = {
|
|
31
|
+
getSettings: () => Promise<any>;
|
|
32
|
+
listTickets: (query?: AgentTicketListQuery) => Promise<any>;
|
|
33
|
+
countTickets: () => Promise<any>;
|
|
34
|
+
getTicket: (id: string) => Promise<any>;
|
|
35
|
+
reply: (id: string, input: {
|
|
36
|
+
version: string;
|
|
37
|
+
body: string;
|
|
38
|
+
isInternal?: boolean;
|
|
39
|
+
files?: Blob[];
|
|
40
|
+
}) => Promise<any>;
|
|
41
|
+
changeStatus: (id: string, input: {
|
|
42
|
+
version: string;
|
|
43
|
+
status: string;
|
|
44
|
+
}) => Promise<any>;
|
|
45
|
+
changePriority: (id: string, input: {
|
|
46
|
+
version: string;
|
|
47
|
+
priority: string;
|
|
48
|
+
}) => Promise<any>;
|
|
49
|
+
changeCategory: (id: string, input: {
|
|
50
|
+
version: string;
|
|
51
|
+
category: string;
|
|
52
|
+
}) => Promise<any>;
|
|
53
|
+
assign: (id: string, input: {
|
|
54
|
+
version: string;
|
|
55
|
+
agentUserId: number | null;
|
|
56
|
+
}) => Promise<any>;
|
|
57
|
+
listAgents: () => Promise<any>;
|
|
58
|
+
listRealms: () => Promise<any>;
|
|
59
|
+
attachmentUrl: (id: string, attachmentId: string) => string;
|
|
60
|
+
openAttachment: (id: string, attachmentId: string) => Promise<void>;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* @typedef {object} AgentTicketListQuery Every key the list endpoint accepts is passed through as given;
|
|
64
|
+
* a key left undefined, null or blank is left out.
|
|
65
|
+
* @property {string} [status] Open, InProgress, WaitingOnCustomer, Resolved, Closed or Cancelled.
|
|
66
|
+
* @property {string} [priority] Low, Normal, High or Urgent.
|
|
67
|
+
* @property {string} [category]
|
|
68
|
+
* @property {string} [realm]
|
|
69
|
+
* @property {number|string} [assignedAgentUserId]
|
|
70
|
+
* @property {boolean} [unassignedOnly]
|
|
71
|
+
* @property {boolean} [overdueOnly]
|
|
72
|
+
* @property {boolean} [unsettledOnly]
|
|
73
|
+
* @property {boolean} [awaitingAgentOnly]
|
|
74
|
+
* @property {boolean} [includeSettled] With no status, also lists the resolved, closed and cancelled tickets.
|
|
75
|
+
* @property {string} [queue]
|
|
76
|
+
* @property {string} [search]
|
|
77
|
+
* @property {string} [order] Newest, Oldest, RecentlyUpdated or LeastRecentlyUpdated.
|
|
78
|
+
* @property {number} [page]
|
|
79
|
+
* @property {number} [pageSize]
|
|
80
|
+
*/
|
|
81
|
+
/**
|
|
82
|
+
* @typedef {object} SupportAgentClient
|
|
83
|
+
* @property {() => Promise<any>} getSettings
|
|
84
|
+
* @property {(query?: AgentTicketListQuery) => Promise<any>} listTickets
|
|
85
|
+
* @property {() => Promise<any>} countTickets
|
|
86
|
+
* @property {(id: string) => Promise<any>} getTicket
|
|
87
|
+
* @property {(id: string, input: { version: string, body: string, isInternal?: boolean, files?: Blob[] }) => Promise<any>} reply
|
|
88
|
+
* @property {(id: string, input: { version: string, status: string }) => Promise<any>} changeStatus
|
|
89
|
+
* @property {(id: string, input: { version: string, priority: string }) => Promise<any>} changePriority
|
|
90
|
+
* @property {(id: string, input: { version: string, category: string }) => Promise<any>} changeCategory
|
|
91
|
+
* @property {(id: string, input: { version: string, agentUserId: number | null }) => Promise<any>} assign
|
|
92
|
+
* @property {() => Promise<any>} listAgents
|
|
93
|
+
* @property {() => Promise<any>} listRealms
|
|
94
|
+
* @property {(id: string, attachmentId: string) => string} attachmentUrl
|
|
95
|
+
* @property {(id: string, attachmentId: string) => Promise<void>} openAttachment
|
|
96
|
+
*/
|
|
97
|
+
/**
|
|
98
|
+
* Binds the agent side of the support HTTP contract to the product's authenticated client.
|
|
99
|
+
*
|
|
100
|
+
* @param {import('../client.js').SupportHttp} http The product's axios-like instance (bearer token and refresh already wired).
|
|
101
|
+
* @param {{ basePath?: string }} [options]
|
|
102
|
+
* @returns {SupportAgentClient}
|
|
103
|
+
*/
|
|
104
|
+
export declare function createSupportAgentClient(http: import('../client.js').SupportHttp, { basePath }?: {
|
|
105
|
+
basePath?: string;
|
|
106
|
+
}): SupportAgentClient;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/** @type {import('react').Context<{ client: import('./client.js').SupportAgentClient, loadOnce: (name: string, load: () => Promise<any>, fresh?: boolean) => Promise<any>, timeZone: string, renderTime?: (iso: string) => import('react').ReactNode, labels?: Record<string, Record<string, string>> } | null>} */
|
|
2
|
+
export declare const SupportAgentContext: import('react').Context<{
|
|
3
|
+
client: import('./client.js').SupportAgentClient;
|
|
4
|
+
loadOnce: (name: string, load: () => Promise<any>, fresh?: boolean) => Promise<any>;
|
|
5
|
+
timeZone: string;
|
|
6
|
+
renderTime?: (iso: string) => import('react').ReactNode;
|
|
7
|
+
labels?: Record<string, Record<string, string>>;
|
|
8
|
+
} | null>;
|
|
9
|
+
/**
|
|
10
|
+
* The agent support client the nearest SupportAgentProvider holds.
|
|
11
|
+
*
|
|
12
|
+
* @returns {import('./client.js').SupportAgentClient}
|
|
13
|
+
*/
|
|
14
|
+
export declare function useSupportAgentClient(): import('./client.js').SupportAgentClient;
|
|
15
|
+
/**
|
|
16
|
+
* The IANA time zone the nearest SupportAgentProvider shows times in.
|
|
17
|
+
*
|
|
18
|
+
* @returns {string}
|
|
19
|
+
*/
|
|
20
|
+
export declare function useSupportAgentTimeZone(): string;
|
|
21
|
+
/**
|
|
22
|
+
* The product's own time renderer the nearest SupportAgentProvider holds, or null for the built-in one.
|
|
23
|
+
*
|
|
24
|
+
* @returns {((iso: string) => import('react').ReactNode)|null}
|
|
25
|
+
*/
|
|
26
|
+
export declare function useSupportAgentRenderTime(): ((iso: string) => import('react').ReactNode) | null;
|
|
27
|
+
/**
|
|
28
|
+
* The labels for one scope, with any the provider overrides merged over the defaults.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} scope
|
|
31
|
+
* @param {Record<string, string>} defaults
|
|
32
|
+
* @returns {Record<string, string>}
|
|
33
|
+
*/
|
|
34
|
+
export declare function useSupportAgentLabels(scope: string, defaults: Record<string, string>): Record<string, string>;
|
|
35
|
+
/**
|
|
36
|
+
* One page of the tickets in the agent's queue, filtered and searched on the server. Loads again
|
|
37
|
+
* whenever any part of the query changes; an answer for a query that has since moved on is dropped.
|
|
38
|
+
*
|
|
39
|
+
* @param {import('./client.js').AgentTicketListQuery} [query]
|
|
40
|
+
* @returns {{ tickets: any[], totalCount: number, totalPages: number, loading: boolean, error: any, reload: () => void }}
|
|
41
|
+
*/
|
|
42
|
+
export declare function useSupportQueue(query?: import('./client.js').AgentTicketListQuery): {
|
|
43
|
+
tickets: any[];
|
|
44
|
+
totalCount: number;
|
|
45
|
+
totalPages: number;
|
|
46
|
+
loading: boolean;
|
|
47
|
+
error: any;
|
|
48
|
+
reload: () => void;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* How many tickets are in each queue bucket, for labelling the counts strip.
|
|
52
|
+
*
|
|
53
|
+
* @returns {{ counts: any|null, loading: boolean, error: any, reload: () => void }}
|
|
54
|
+
*/
|
|
55
|
+
export declare function useSupportQueueCounts(): {
|
|
56
|
+
counts: any | null;
|
|
57
|
+
loading: boolean;
|
|
58
|
+
error: any;
|
|
59
|
+
reload: () => void;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* One ticket with its thread, plus the changes an agent can make to it. Each change returns the
|
|
63
|
+
* updated ticket and replaces the one held here. The ticket refreshes every 30 seconds while the
|
|
64
|
+
* page is visible, and never while a change is in flight.
|
|
65
|
+
*
|
|
66
|
+
* @param {string|null|undefined} id The ticket's id; nothing loads while it is empty.
|
|
67
|
+
* @returns {{
|
|
68
|
+
* ticket: any, loading: boolean, error: any, reload: () => void,
|
|
69
|
+
* reply: (input: Parameters<import('./client.js').SupportAgentClient['reply']>[1]) => Promise<any>,
|
|
70
|
+
* changeStatus: (input: { version: string, status: string }) => Promise<any>,
|
|
71
|
+
* changePriority: (input: { version: string, priority: string }) => Promise<any>,
|
|
72
|
+
* changeCategory: (input: { version: string, category: string }) => Promise<any>,
|
|
73
|
+
* assign: (input: { version: string, agentUserId: number | null }) => Promise<any>
|
|
74
|
+
* }}
|
|
75
|
+
*/
|
|
76
|
+
export declare function useSupportAgentTicket(id: string | null | undefined): {
|
|
77
|
+
ticket: any;
|
|
78
|
+
loading: boolean;
|
|
79
|
+
error: any;
|
|
80
|
+
reload: () => void;
|
|
81
|
+
reply: (input: Parameters<import('./client.js').SupportAgentClient['reply']>[1]) => Promise<any>;
|
|
82
|
+
changeStatus: (input: {
|
|
83
|
+
version: string;
|
|
84
|
+
status: string;
|
|
85
|
+
}) => Promise<any>;
|
|
86
|
+
changePriority: (input: {
|
|
87
|
+
version: string;
|
|
88
|
+
priority: string;
|
|
89
|
+
}) => Promise<any>;
|
|
90
|
+
changeCategory: (input: {
|
|
91
|
+
version: string;
|
|
92
|
+
category: string;
|
|
93
|
+
}) => Promise<any>;
|
|
94
|
+
assign: (input: {
|
|
95
|
+
version: string;
|
|
96
|
+
agentUserId: number | null;
|
|
97
|
+
}) => Promise<any>;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* The agents a ticket can be assigned to. Loaded once per provider and shared.
|
|
101
|
+
*
|
|
102
|
+
* @returns {{ agents: any[], loading: boolean, error: any, reload: () => void }}
|
|
103
|
+
*/
|
|
104
|
+
export declare function useSupportAgents(): {
|
|
105
|
+
agents: any[];
|
|
106
|
+
loading: boolean;
|
|
107
|
+
error: any;
|
|
108
|
+
reload: () => void;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* The agent-side settings (categories, priorities, statuses). Loaded once per provider and shared.
|
|
112
|
+
*
|
|
113
|
+
* @returns {{ settings: any|null, loading: boolean, error: any, reload: () => void }}
|
|
114
|
+
*/
|
|
115
|
+
export declare function useSupportAgentSettings(): {
|
|
116
|
+
settings: any | null;
|
|
117
|
+
loading: boolean;
|
|
118
|
+
error: any;
|
|
119
|
+
reload: () => void;
|
|
120
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/** Strings the support agent queue and ticket page show. Scope names: supportQueue, agentTicket. */
|
|
2
|
+
export declare const AGENT_LABELS: {
|
|
3
|
+
supportQueue: {
|
|
4
|
+
countOpen: string;
|
|
5
|
+
countInProgress: string;
|
|
6
|
+
countWaiting: string;
|
|
7
|
+
countOverdue: string;
|
|
8
|
+
countUnassigned: string;
|
|
9
|
+
filterStatus: string;
|
|
10
|
+
filterPriority: string;
|
|
11
|
+
filterCategory: string;
|
|
12
|
+
filterPlace: string;
|
|
13
|
+
filterAssignee: string;
|
|
14
|
+
filterUnassignedOnly: string;
|
|
15
|
+
filterOverdueOnly: string;
|
|
16
|
+
filterSearch: string;
|
|
17
|
+
filterAny: string;
|
|
18
|
+
columnNumber: string;
|
|
19
|
+
columnPlace: string;
|
|
20
|
+
columnSubject: string;
|
|
21
|
+
columnCategory: string;
|
|
22
|
+
columnStatus: string;
|
|
23
|
+
columnPriority: string;
|
|
24
|
+
columnAssignee: string;
|
|
25
|
+
columnDue: string;
|
|
26
|
+
loading: string;
|
|
27
|
+
empty: string;
|
|
28
|
+
error: string;
|
|
29
|
+
retry: string;
|
|
30
|
+
heading: string;
|
|
31
|
+
tableLabel: string;
|
|
32
|
+
settingsError: string;
|
|
33
|
+
overdueMark: string;
|
|
34
|
+
noAssignee: string;
|
|
35
|
+
emptyUnfiltered: string;
|
|
36
|
+
};
|
|
37
|
+
agentTicket: {
|
|
38
|
+
reply: string;
|
|
39
|
+
internalNote: string;
|
|
40
|
+
send: string;
|
|
41
|
+
savedReplies: string;
|
|
42
|
+
attachFiles: string;
|
|
43
|
+
status: string;
|
|
44
|
+
priority: string;
|
|
45
|
+
category: string;
|
|
46
|
+
assignee: string;
|
|
47
|
+
unassigned: string;
|
|
48
|
+
internal: string;
|
|
49
|
+
backToQueue: string;
|
|
50
|
+
stale: string;
|
|
51
|
+
reload: string;
|
|
52
|
+
loading: string;
|
|
53
|
+
empty: string;
|
|
54
|
+
error: string;
|
|
55
|
+
retry: string;
|
|
56
|
+
emptyReply: string;
|
|
57
|
+
actionFailed: string;
|
|
58
|
+
attachmentFailed: string;
|
|
59
|
+
none: string;
|
|
60
|
+
customer: string;
|
|
61
|
+
supportTeam: string;
|
|
62
|
+
overdue: string;
|
|
63
|
+
detailsLabel: string;
|
|
64
|
+
controlsLabel: string;
|
|
65
|
+
fieldTicket: string;
|
|
66
|
+
fieldAccount: string;
|
|
67
|
+
fieldRealm: string;
|
|
68
|
+
fieldReporter: string;
|
|
69
|
+
fieldEmail: string;
|
|
70
|
+
fieldRaised: string;
|
|
71
|
+
fieldUpdated: string;
|
|
72
|
+
fieldReplyDue: string;
|
|
73
|
+
fieldResolutionDue: string;
|
|
74
|
+
mode: string;
|
|
75
|
+
replyHint: string;
|
|
76
|
+
noteHint: string;
|
|
77
|
+
body: string;
|
|
78
|
+
insertSaved: string;
|
|
79
|
+
attachedFiles: string;
|
|
80
|
+
removeFile: string;
|
|
81
|
+
formLabel: string;
|
|
82
|
+
conversation: string;
|
|
83
|
+
};
|
|
84
|
+
};
|
package/dist/types/client.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export declare class SupportApiError extends Error {
|
|
|
12
12
|
constructor(code: string, message: string, status?: number);
|
|
13
13
|
}
|
|
14
14
|
export declare function normaliseError(error: any): Promise<SupportApiError>;
|
|
15
|
+
export declare function call(request: any): Promise<any>;
|
|
16
|
+
export declare function appendFiles(form: any, name: any, files: any, fallbackName: any): void;
|
|
15
17
|
export type SupportHttp = {
|
|
16
18
|
get: (url: string, config?: object) => Promise<{
|
|
17
19
|
data: any;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
export { createSupportAgentClient } from "./agent/client.js";
|
|
2
|
+
export { useSupportAgentClient, useSupportAgentLabels, useSupportAgentRenderTime, useSupportAgentSettings, useSupportAgents, useSupportAgentTicket, useSupportAgentTimeZone, useSupportQueue, useSupportQueueCounts, } from "./agent/context.js";
|
|
3
|
+
export { default as SupportAgentProvider } from "./agent/SupportAgentProvider.jsx";
|
|
4
|
+
export { default as SupportAgentTicket } from "./agent/SupportAgentTicket.jsx";
|
|
5
|
+
export { default as SupportQueue } from "./agent/SupportQueue.jsx";
|
|
1
6
|
export { createSupportClient, SupportApiError } from "./client.js";
|
|
2
7
|
export { useSupportClient, useSupportConfig, useSupportTicket, useSupportTicketCounts, useSupportTickets } from "./context.js";
|
|
3
8
|
export { createHelpCentreClient } from "./helpCentre/client.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/support-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.135.0",
|
|
4
4
|
"description": "Webority customer support for React portals: ticket centre, help centre with articles and search, report-an-issue with an optional page screenshot, and support contact details, built on @webority/ui-react.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
},
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@webority/ui-elements": "0.
|
|
31
|
-
"@webority/ui-react": "0.
|
|
30
|
+
"@webority/ui-elements": "0.135.0",
|
|
31
|
+
"@webority/ui-react": "0.135.0",
|
|
32
32
|
"bootstrap": "5.3.3",
|
|
33
33
|
"react": "^19.0.0",
|
|
34
34
|
"react-bootstrap": "^2.10.0",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"@types/react": "^19.2.17",
|
|
43
43
|
"@vitejs/plugin-react": "^6.0.1",
|
|
44
44
|
"@vitest/coverage-v8": "5.0.1",
|
|
45
|
-
"@webority/canvas-kit": "0.
|
|
46
|
-
"@webority/ui-elements": "0.
|
|
47
|
-
"@webority/ui-react": "0.
|
|
45
|
+
"@webority/canvas-kit": "0.135.0",
|
|
46
|
+
"@webority/ui-elements": "0.135.0",
|
|
47
|
+
"@webority/ui-react": "0.135.0",
|
|
48
48
|
"bootstrap": "5.3.3",
|
|
49
49
|
"jsdom": "30.1.1",
|
|
50
50
|
"react": "^19.2.6",
|