@webority/support-react 0.129.0 → 0.130.1

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 CHANGED
@@ -163,6 +163,40 @@ support config. A field the product has not set is left out, and nothing renders
163
163
  <SupportContact />
164
164
  ```
165
165
 
166
+ ### Help centre: `<HelpCentre />` and `<HelpArticle />`
167
+
168
+ The public help centre: the support team's published articles, one page at a time, with a search box
169
+ when the server offers search. An article opens in place through `onOpen(slug)`, or through the link
170
+ `linkTo(slug)` gives. The client is built from the portal's HTTP instance with its own prefix:
171
+
172
+ ```jsx
173
+ import { createHelpCentreClient, HelpArticle, HelpCentre } from "@webority/support-react";
174
+
175
+ const helpClient = createHelpCentreClient({ baseUrl: "/api/help", http: userClient });
176
+
177
+ <HelpCentre client={helpClient} linkTo={(slug) => `/help/${slug}`} />
178
+ <HelpArticle client={helpClient} slug={slug} onBack={() => navigate("/help")} />
179
+ ```
180
+
181
+ Both need a `SupportProvider` above them for their labels and times.
182
+
183
+ | Prop | What it does |
184
+ |---|---|
185
+ | `client` | The help centre client from `createHelpCentreClient`. Required on both. |
186
+ | `onOpen(slug)` | `HelpCentre`: opens an article in place. Without it a row is a plain button. |
187
+ | `linkTo(slug)` | `HelpCentre`: the href of an article's page, for a router link. A modified click keeps the link's own new-tab behaviour. |
188
+ | `slug` | `HelpArticle`: the article to show, as the list gives it. |
189
+ | `onBack()` | `HelpArticle`: the back action. Without it the article has none. |
190
+
191
+ Search asks the server only when the settings say search is available and the typed text, without
192
+ spaces at either end, is at least two characters long; it waits for typing to pause, and clearing the
193
+ box cancels the search in flight. A
194
+ failed list or article load shows the server's curated message with a Try again button. The Published
195
+ line is left out when an article has no publish date.
196
+
197
+ `useHelpCentre(client)` returns the settings, the article list (with its paging) and the search for a
198
+ screen that draws its own layout.
199
+
166
200
  ## Hooks
167
201
 
168
202
  `useSupportConfig()`, `useSupportTickets(query)`, `useSupportTicketCounts()` and
@@ -2,9 +2,51 @@
2
2
  "format": "webority-guidance/1",
3
3
  "package": {
4
4
  "name": "@webority/support-react",
5
- "version": "0.129.0"
5
+ "version": "0.130.1"
6
6
  },
7
7
  "components": [
8
+ {
9
+ "name": "HelpArticle",
10
+ "usage": {
11
+ "when": [
12
+ "A customer has opened one help article and needs to read it."
13
+ ],
14
+ "whenNot": [
15
+ {
16
+ "text": "The customer needs to contact support about their own account.",
17
+ "instead": "SupportCenter"
18
+ }
19
+ ],
20
+ "do": [],
21
+ "dont": [],
22
+ "a11y": [
23
+ "The article title is a heading, and its dates are read as times.",
24
+ "A missing article shows a message instead of an empty page."
25
+ ]
26
+ }
27
+ },
28
+ {
29
+ "name": "HelpCentre",
30
+ "usage": {
31
+ "when": [
32
+ "A customer or visitor needs answers from the support team's published help articles.",
33
+ "The product offers search over those articles and the customer wants to find one by words."
34
+ ],
35
+ "whenNot": [
36
+ {
37
+ "text": "The customer needs to raise or follow their own ticket.",
38
+ "instead": "SupportCenter"
39
+ }
40
+ ],
41
+ "do": [],
42
+ "dont": [],
43
+ "a11y": [
44
+ "The page is a section labelled by its Help centre heading.",
45
+ "The search box is labelled and appears only when the server offers search.",
46
+ "Each article is a button or a link named by its title."
47
+ ]
48
+ }
49
+ },
8
50
  {
9
51
  "name": "ReportIssue",
10
52
  "usage": {
@@ -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,AppModal as D,AppSearch as O,AppSelect as k,AppSkeleton as A,AppSpinner as j,AppStatusBadge as M,AppTabs as N,AppTextarea as P,warnInvalidValue as F}from"@webority/ui-react";import{toBlob as I}from"html-to-image";import{IST_TIME_ZONE as L,formatDateTime as R,formatFileSize as z,timeZoneLabel as B}from"@webority/ui-elements/helpers";import{Fragment as V,jsx as H,jsxs as U}from"react/jsx-runtime";var ee=`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 te(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 ne(e){if(e instanceof W)return e;let t=e?.response;if(!t)return new W(`network`,ee);let n=await te(t.data);return new W(typeof n?.code==`string`&&n.code?n.code:`unknown`,typeof n?.detail==`string`&&n.detail.trim()?n.detail:ee,t.status)}async function G(e){try{return(await e()).data}catch(e){throw await ne(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 re=20;function ie(e,t){return(e??[]).map((e,n)=>e?.name||`${t}-${n+1}.png`).join(`|`)}function ae(e){return e instanceof W&&typeof e.status==`number`&&e.status>=400&&e.status<=499&&e.status!==408&&e.status!==429}function oe(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<=re)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 ae(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,ie(l,`file`),ie(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,ie(i,`file`),ie(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 se=3e4,ce=e(null);function J(){let e=n(ce);if(!e)throw Error(`Support components and hooks must be used inside <SupportProvider>.`);return e}function Y(){return J().client}function le(){return J().timeZone}function ue(){return J().renderTime??null}function X(e,t){let n=J().labels?.[e];return a(()=>n?{...t,...n}:t,[n,t])}function de(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 fe(){let{loadConfig:e}=J(),{data:t,loading:n,error:r,reload:i}=de(e,`config`);return{config:t,loading:n,error:r,reload:i}}function pe(e={}){let t=Y(),{status:n,search:r,page:i,pageSize:a}=e,{data:o,loading:s,error:c,reload:l}=de(()=>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 me(){let e=Y(),{data:t,loading:n,error:r,reload:i}=de(()=>e.getTicketCounts(),`ticket-counts`);return{counts:t,loading:n,error:r,reload:i}}function he(e){let n=Y(),{data:i,loading:a,error:s,reload:c,setData:l}=de(()=>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,se))},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 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}function ge(e){return(e?.allowedContentTypes??[]).join(`,`)}function _e(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 ve(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(!_e(e.type,o))return Z(n.typeNotAccepted,{name:t});if(a>0&&e.size>a)return Z(n.tooLarge,{name:t,size:z(a)})}return null}var ye=(e,t)=>e===1?t.attachOne:Z(t.attachMany,{count:e});function be(e){return`${e.name}|${e.size}|${e.lastModified}`}function xe(e,t,n,r=Q){let i=n?.maxAttachmentsPerMessage??0,a=new Set(e.map(be)),o=[],s=null;for(let e of t){let t=be(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?ye(i,r):null)??ve(l,n,r)??(s?Z(r.alreadyAttached,{name:s}):``)}}function Se(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 Ce=80;function we(e,t){let n=Math.min(t,Ce),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 Te(e,t){let[n,i]=s(e);return r(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[e,t]),n}function Ee({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__ */ H(x,{id:e,label:t,optional:!0,multiple:!0,value:n,onChange:r,accept:ge(i),maxSizeMb:s,validate:!1,error:a||void 0})}var De={title:`These may already answer your question`};function Oe({items:e}){let t=X(`suggestedAnswers`,De);return e.length===0?null:/* @__PURE__ */ H(p,{variant:`muted`,padding:`sm`,title:t.title,children:/* @__PURE__ */ H(`ul`,{className:`list-unstyled mb-0 d-flex flex-column gap-2`,children:e.map(e=>/* @__PURE__ */ U(`li`,{children:[/* @__PURE__ */ H(`div`,{className:`fw-semibold`,children:e.title}),/* @__PURE__ */ H(`div`,{className:`small text-body-secondary`,children:e.summary})]},e.title))})})}var ke={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.`},Ae=500,je=3,Me=5;function Ne(e,t){return t&&e.includes(t)?t:``}function Pe({id:e,config:t,defaultCategory:n,initialValues:i,onValuesChange:a,extraFiles:o=[],onSubmit:c,onBusyChange:u,children:d}){let f=X(`ticketForm`,ke),p=X(`shared`,Q),m=t?.categories??[],h=t?.subjectMaxLength??1/0,[g,_]=s(()=>i?.category??Ne(m,n)),[v,y]=s(i?.body??``),[b,x]=s(()=>i?.subject||we(i?.body??``,h)),[S,C]=s(()=>{let e=(i?.subject??``).trim();return e!==``&&e!==we(i?.body??``,h)}),[w,E]=s(i?.files??[]),[D,O]=s({}),[A,j]=s(``),M=Y(),[N,F]=s(``),[I,L]=s([]),R=Te(b.trim(),Ae);r(()=>{a?.({category:g,subject:b,body:v,files:w})},[g,b,v,w,a]),r(()=>{F(R)},[R]),r(()=>{if(N.length<je){L([]);return}let e=!0,t=new AbortController;return L([]),M.getSuggestions(N,{signal:t.signal}).then(t=>{e&&L(Array.isArray(t)?t.slice(0,Me):[])},()=>{e&&L([])}),()=>{e=!1,t.abort()}},[M,N]);let z=e=>{E(e),O(n=>({...n,files:ve([...o,...e],t,p)??void 0}))},B=e=>{let t=Se(e);t.length>0&&z([...w,...t])},V=e=>{let t=e.target.value;y(t),S||x(we(t,h)),D.body&&O(e=>({...e,body:t.trim()?void 0:f.bodyRequired}))},ee=e=>{let t=e.target.value;x(t),C(t.trim()!==``)};function W(){let e={};v.trim()||(e.body=f.bodyRequired);let n=ve([...o,...w],t,p);return n&&(e.files=n),O(e),Object.keys(e).length===0}async function te(e){if(e.preventDefault(),j(``),W()){u?.(!0);try{await c({category:g,subject:b.trim()||we(v,h),body:v.trim(),files:w})}catch(e){j($(e,f.sendFailed,p.offline))}finally{u?.(!1)}}}return/* @__PURE__ */ U(`form`,{id:e,onSubmit:te,noValidate:!0,className:`d-flex flex-column gap-3`,children:[A&&/* @__PURE__ */ H(l,{tone:`danger`,children:A}),/* @__PURE__ */ H(P,{id:`${e}-body`,label:f.messageLabel,required:!0,rows:6,maxLength:t?.bodyMaxLength,showCount:!0,placeholder:f.messagePlaceholder,value:v,onChange:V,onPaste:B,hint:f.messageHint,error:D.body}),/* @__PURE__ */ H(T,{id:`${e}-subject`,label:f.subjectLabel,maxLength:t?.subjectMaxLength,showCount:!0,placeholder:f.subjectPlaceholder,hint:f.subjectHint,value:b,onChange:ee,onBlur:()=>F(b.trim())}),/* @__PURE__ */ H(Oe,{items:I}),/* @__PURE__ */ H(k,{id:`${e}-category`,label:f.categoryLabel,value:g,onChange:_,options:m.map(e=>({value:e,label:e})),placeholder:f.categoryPlaceholder,hint:f.categoryHint,error:D.category}),d,/* @__PURE__ */ H(Ee,{id:`${e}-files`,files:w,onChange:z,config:t,error:D.files})]})}var Fe={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.`},Ie=`supportCapture`,Le={zIndex:`var(--wui-z-fixed)`,bottom:0,insetInlineEnd:0},Re={zIndex:`var(--wui-z-fixed)`},ze={maxWidth:`20rem`},Be=e=>e.dataset?.[Ie]===`exclude`||e.matches?.(`.modal-backdrop`)?!1:!(e.matches?.(`.modal`)&&e.querySelector?.(`[data-support-capture="exclude"]`)),Ve=()=>new Promise(e=>requestAnimationFrame(()=>e()));async function He(e){let t=await I(document.body,{filter:Be,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 Ue({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__ */ U(`div`,{className:`d-flex flex-column gap-2`,children:[/* @__PURE__ */ H(`span`,{className:`wui-text-sm fw-semibold`,children:e.screenshotTitle}),t&&d&&/* @__PURE__ */ H(`img`,{src:d,alt:e.screenshotLabel,className:`d-block w-100 border rounded`,style:ze}),/* @__PURE__ */ H(`div`,{ref:o,className:`d-flex flex-wrap gap-2`,children:t?/* @__PURE__ */ U(V,{children:[/* @__PURE__ */ H(f,{variant:`outline`,size:`sm`,leftIcon:`refresh-cw`,onClick:c,disabled:i,"aria-describedby":a,children:e.retake}),/* @__PURE__ */ H(f,{variant:`ghost`,size:`sm`,leftIcon:`x`,onClick:u,disabled:i,children:e.removeScreenshot})]}):/* @__PURE__ */ H(f,{variant:`outline`,size:`sm`,leftIcon:`camera`,onClick:c,disabled:i,"aria-describedby":a,children:e.addScreenshot})}),/* @__PURE__ */ H(`span`,{id:a,className:`wui-text-sm text-body-secondary`,children:e.screenshotNote}),n&&/* @__PURE__ */ H(l,{tone:`info`,children:e.screenshotFailed})]})}function We({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=X(`reportIssue`,Fe),_=X(`shared`,Q),v=Y(),{config:y,error:b}=fe(),x=`support-report-${i().replace(/[^a-zA-Z0-9-]/g,``)}`,[C,w]=s(!1),[T,E]=s(!1),[O,k]=s(null),[A,j]=s(!1),[M,N]=s(!1),[P,F]=s(null),[I,L]=s(null),R=o(null),z=o(!1);r(()=>{!T&&z.current&&(z.current=!1,R.current?.querySelector(`button`)?.focus())},[T]);function B(){F(null),k(null),j(!1),L(null),w(!0)}async function ee(){E(!0),j(!1),await Ve(),await Ve();try{k(await He(g.captureEmpty))}catch{k(null),j(!0)}finally{z.current=!0,E(!1)}}let W=()=>{M||(w(!1),k(null),j(!1),F(null),L(null))};async function te(e){let t=await v.createTicket({...e,pageUrl:window.location.href,userAgent:navigator.userAgent,appVersion:c,screenshots:O?[O]:[]});F(t),k(null),p?.(t)}let ne=!P&&(!!O||!!I&&(I.subject.trim()!==``||I.body.trim()!==``||I.files.length>0)),G=P&&u?u(P.id):void 0,K=P&&(G||d)?/* @__PURE__ */ H(f,{href:G,onClick:G?void 0:()=>{w(!1),F(null),d(P)},children:g.viewTicket}):null,q=P?/* @__PURE__ */ U(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ H(f,{variant:`secondary`,onClick:W,children:g.close}),K]}):/* @__PURE__ */ U(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ H(f,{variant:`secondary`,onClick:W,disabled:M,children:g.cancel}),/* @__PURE__ */ H(f,{type:`submit`,form:x,loading:M,disabled:!y,children:g.submit})]}),re=n?/* @__PURE__ */ H(S,{icon:`bug`,label:e,order:`secondary`,size:`sm`,variant:`secondary`,stacked:t,className:t?m:void 0,style:t?h:void 0,disabled:T,onClick:B,"aria-haspopup":`dialog`}):/* @__PURE__ */ H(f,{leftIcon:`bug`,variant:t?`primary`:`outline`,disabled:T,onClick:B,"aria-haspopup":`dialog`,children:e});return/* @__PURE__ */ U(V,{children:[t&&n?re:/* @__PURE__ */ H(`span`,{"data-support-capture":`exclude`,className:[t?`position-fixed m-3`:`d-inline-block`,m].filter(Boolean).join(` `),style:t?{...Le,...h}:h,children:re}),T&&/* @__PURE__ */ U(`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:Re,children:[/* @__PURE__ */ H(`span`,{className:`spinner-border spinner-border-sm`,"aria-hidden":`true`}),g.takingScreenshot]}),/* @__PURE__ */ H(D,{open:C,size:`lg`,title:g.title,subtitle:g.subtitle,headerIcon:`bug`,confirmDiscard:g.confirmDiscard,dirty:ne&&!M,onClose:W,footer:q,"data-support-capture":`exclude`,children:P?/* @__PURE__ */ H(l,{tone:`success`,role:`status`,title:Z(g.createdTitle,{number:P.number}),children:g.createdText}):y?/* @__PURE__ */ H(Pe,{id:x,config:y,defaultCategory:a,initialValues:I,onValuesChange:L,extraFiles:O?[O]:[],onSubmit:te,onBusyChange:N,children:/* @__PURE__ */ H(Ue,{t:g,file:O,failed:A,disabled:M||T,hintId:`${x}-screenshot-hint`,controlRef:R,onAdd:ee,onRemove:()=>k(null)})}):/* @__PURE__ */ H(l,{tone:b?`danger`:`info`,children:b?$(b,g.configError,_.offline):g.loading})})]})}var Ge={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 Ke({open:e,onClose:t,onCreated:n,config:r,defaultCategory:a,appVersion:o}){let c=X(`newTicketModal`,Ge),l=Y(),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__ */ H(D,{open:e,size:`lg`,title:c.title,subtitle:c.subtitle,headerIcon:`message-square`,confirmDiscard:c.confirmDiscard,dirty:g&&!d,onClose:()=>{d||t()},footer:/* @__PURE__ */ U(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ H(f,{variant:`secondary`,onClick:t,disabled:d,children:c.cancel}),/* @__PURE__ */ H(f,{type:`submit`,form:u,loading:d,children:c.send})]}),children:e&&/* @__PURE__ */ H(Pe,{id:u,config:r,defaultCategory:a,onSubmit:_,onBusyChange:p,onValuesChange:h})})}var qe={Open:`info`,InProgress:`info`,WaitingOnCustomer:`warning`,Resolved:`success`,Closed:`success`,Cancelled:`neutral`};function Je(e){return qe[e]??`neutral`}var Ye={loading:`Loading {name}`,failed:`Could not load this file. Click to try again.`},Xe=6e4,Ze=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`application/pdf`];function Qe({attachment:e}){let t=X(`attachmentThumb`,Ye),n=Y(),[r,i]=s(!1),[a,o]=s(!1);async function c(){i(!0),o(!1);let t=Ze.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),Xe),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)?z(e.sizeBytes):`-`;return/* @__PURE__ */ U(V,{children:[/* @__PURE__ */ H(m,{leadingIcon:a?`x-circle`:`paperclip`,label:r?/* @__PURE__ */ U(V,{children:[/* @__PURE__ */ H(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__ */ H(`span`,{role:`status`,className:`wui-text-xs text-danger align-self-center`,children:t.failed})]})}function $e({iso:e,className:t}){let n=ue(),r=le();return n?n(e):/* @__PURE__ */ H(`time`,{dateTime:e,className:t,children:R(e,{timeZone:r})})}var et={conversation:`Conversation`,you:`You`,supportTeam:`Support team`,supportBadge:`Support`},tt={whiteSpace:`pre-wrap`,overflowWrap:`anywhere`};function nt({messages:e}){let t=X(`messageThread`,et);return/* @__PURE__ */ H(`ol`,{className:`list-unstyled d-flex flex-column gap-3 mb-0`,"aria-label":t.conversation,children:e.map(e=>{let n=/* @__PURE__ */ H($e,{iso:e.createdDateTimeUtc,className:`wui-text-xs text-body-secondary text-nowrap`});if(e.authorKind===`System`)return/* @__PURE__ */ U(`li`,{className:`text-center wui-text-xs text-body-secondary`,"data-author":`system`,children:[/* @__PURE__ */ H(`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__ */ U(`li`,{className:`d-flex align-items-start gap-2${r?` flex-row-reverse`:``}`,"data-author":r?`customer`:`agent`,children:[/* @__PURE__ */ H(u,{name:i,size:32,tone:r?`neutral`:`primary`}),/* @__PURE__ */ U(p,{className:`flex-grow-1 border`,padding:`sm`,variant:r?`default`:`accent`,style:{minWidth:0},children:[/* @__PURE__ */ U(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2 mb-2`,children:[/* @__PURE__ */ U(`span`,{className:`d-inline-flex flex-wrap align-items-center gap-2 fw-semibold wui-text-sm text-break`,children:[i,!r&&/* @__PURE__ */ H(d,{tone:`primary`,children:t.supportBadge})]}),n]}),/* @__PURE__ */ H(`div`,{className:`wui-text-sm`,style:tt,children:e.body}),e.attachments?.length>0&&/* @__PURE__ */ H(`div`,{className:`d-flex flex-wrap gap-2 mt-2`,children:e.attachments.map(e=>/* @__PURE__ */ H(Qe,{attachment:e},e.id))})]})]},e.id)})})}var rt={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 it({satisfaction:e,comment:t,canRate:n=!1,commentMaxLength:r,onRate:a}){let o=X(`ratingPanel`,rt),c=X(`shared`,Q),u=i(),[d,m]=s(``),[h,g]=s(null),[_,v]=s(``);if(e)return/* @__PURE__ */ U(l,{tone:e===`Satisfied`?`success`:`info`,role:`status`,children:[e===`Satisfied`?o.solved:o.notSolved,t?/* @__PURE__ */ U(`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__ */ H(p,{padding:`sm`,className:`border`,title:o.heading,children:/* @__PURE__ */ U(`div`,{className:`d-flex flex-column gap-2`,children:[_&&/* @__PURE__ */ H(l,{tone:`danger`,children:_}),/* @__PURE__ */ H(P,{id:`${u}-comment`,label:o.commentLabel,rows:2,maxLength:r,value:d,onChange:e=>m(e.target.value),hint:o.commentHint}),/* @__PURE__ */ U(`div`,{className:`d-flex flex-wrap gap-2`,children:[/* @__PURE__ */ H(f,{variant:`outline`,leftIcon:`check-circle`,loading:h===`Satisfied`,disabled:h!==null,onClick:()=>y(`Satisfied`),children:o.yes}),/* @__PURE__ */ H(f,{variant:`outline`,leftIcon:`x-circle`,loading:h===`Unsatisfied`,disabled:h!==null,onClick:()=>y(`Unsatisfied`),children:o.no})]})]})})}var at={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 ot({onSend:e,config:t,reopens:n=!1}){let r=X(`replyBox`,at),a=X(`shared`,Q),o=i(),[u,d]=s(``),[p,g]=s([]),[_,v]=s(``),[y,b]=s(``),[x,S]=s(!1),C=e=>{let n=xe(p,e,t,a);g(n.files),v(n.notice)},w=e=>{let n=p.filter((t,n)=>n!==e);g(n),v(ve(n,t,a)??``)},T=e=>{let t=Se(e);t.length>0&&C(t)};async function E(n){n.preventDefault();let i=u.trim();if(!i){b(r.emptyReply);return}let o=ve(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__ */ U(`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__ */ H(l,{tone:`danger`,children:D}),/* @__PURE__ */ H(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,hint:n?r.hintReopens:r.hint,required:!0}),p.length>0&&/* @__PURE__ */ H(h,{label:r.attachedFiles,children:p.map((e,t)=>/* @__PURE__ */ H(m,{leadingIcon:`paperclip`,label:e.name,removeLabel:Z(r.removeFile,{name:e.name}),onRemove:()=>w(t)},be(e)))}),/* @__PURE__ */ U(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2`,children:[/* @__PURE__ */ H(c,{iconVariant:`bulk`,icon:`paperclip`,label:r.attach,multiple:t?.maxAttachmentsPerMessage!==1,accept:ge(t),onFiles:C}),/* @__PURE__ */ H(f,{type:`submit`,leftIcon:`send`,loading:x,children:r.send})]})]})}var st={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 ct({ticketId:e,onBack:t,onChanged:n,onOpenTicket:r}){let{config:i}=fe(),a=X(`ticketDetail`,st),o=X(`shared`,Q),c=le(),u=ue(),{ticket:d,loading:m,error:h,reload:_,reply:v,reopen:b,cancel:x,rate:S}=he(e),[T,E]=s(!1),[D,O]=s(!1),[k,j]=s(!1),[N,P]=s(``),F=async e=>{let t=await e();return n?.(),t};async function I(){P(``),E(!0);try{await F(b)}catch(e){P($(e,a.reopenFailed,o.offline))}finally{E(!1)}}async function L(){P(``),j(!0);try{await F(x)}catch(e){P($(e,a.withdrawFailed,o.offline))}finally{j(!1),O(!1)}}let R=/* @__PURE__ */ H(f,{variant:`ghost`,size:`sm`,leftIcon:`arrow-left`,onClick:t,className:`align-self-start`,children:a.back});if(!d)return/* @__PURE__ */ U(`section`,{className:`d-flex flex-column gap-3`,"aria-busy":m||void 0,children:[R,h?/* @__PURE__ */ U(l,{tone:`danger`,children:[$(h,a.loadError,o.offline),` `,/* @__PURE__ */ H(f,{variant:`ghost`,size:`sm`,onClick:_,children:a.retry})]}):/* @__PURE__ */ H(A,{height:160})]});let z=Je(d.status),V=[{key:`status`,label:a.fieldStatus,value:d.statusLabel?/* @__PURE__ */ H(M,{label:d.statusLabel,tone:z}):`-`},{key:`category`,label:a.fieldCategory,value:d.category||`-`},{key:`ticket`,label:a.fieldTicket,value:d.number},{key:`opened`,label:a.fieldOpened,value:/* @__PURE__ */ H($e,{iso:d.createdDateTimeUtc})},{key:`updated`,label:a.fieldUpdated,value:/* @__PURE__ */ H($e,{iso:d.updatedDateTimeUtc})}];return/* @__PURE__ */ U(`section`,{className:`d-flex flex-column gap-3`,"aria-labelledby":`support-ticket-${d.id}`,children:[R,/* @__PURE__ */ U(`div`,{className:`row g-3`,children:[/* @__PURE__ */ U(`div`,{className:`col-12 col-lg-8 d-flex flex-column gap-3`,children:[/* @__PURE__ */ U(`header`,{className:`d-flex flex-column gap-2`,children:[/* @__PURE__ */ U(`div`,{className:`d-flex flex-wrap align-items-center gap-2`,children:[/* @__PURE__ */ H(`h2`,{id:`support-ticket-${d.id}`,className:`h5 mb-0 text-break`,children:d.subject}),d.statusLabel&&/* @__PURE__ */ H(M,{label:d.statusLabel,tone:z})]}),/* @__PURE__ */ U(`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__ */ U(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ H(w,{variant:`bulk`,name:`receipt-text`,size:16}),d.number]}),d.category&&/* @__PURE__ */ U(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ H(w,{variant:`bulk`,name:`folder-2`,size:16}),d.category]}),/* @__PURE__ */ U(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ H(w,{variant:`bulk`,name:`calendar-1`,size:16}),a.openedLabel,` `,/* @__PURE__ */ H($e,{iso:d.createdDateTimeUtc})]})]}),u===null&&/* @__PURE__ */ H(`p`,{className:`wui-text-xs text-body-secondary mb-0`,children:Z(a.timeZoneNote,{zone:B(c)})})]}),N&&/* @__PURE__ */ H(l,{tone:`danger`,children:N}),d.mergedInto&&/* @__PURE__ */ U(l,{tone:`info`,role:`status`,children:[Z(a.mergedText,{number:d.mergedInto.number}),` `,r&&/* @__PURE__ */ H(f,{variant:`ghost`,size:`sm`,onClick:()=>r(d.mergedInto.id),children:Z(a.openMerged,{number:d.mergedInto.number})})]}),d.canReopen&&/* @__PURE__ */ H(l,{tone:`success`,role:`status`,children:a.resolvedHint}),d.status===`WaitingOnCustomer`&&/* @__PURE__ */ H(l,{tone:`warning`,role:`status`,children:a.waitingHint}),!d.canReopen&&/* @__PURE__ */ H(`p`,{className:`wui-text-sm text-body-secondary mb-0`,children:a.openHint}),d.canReopen&&/* @__PURE__ */ H(f,{variant:`secondary`,leftIcon:`history`,loading:T,onClick:I,className:`align-self-start`,children:a.reopen}),d.canCancel&&/* @__PURE__ */ H(f,{variant:`secondary`,onClick:()=>O(!0),className:`align-self-start`,children:a.withdraw}),/* @__PURE__ */ H(g,{open:D,title:a.withdrawTitle,message:a.withdrawMessage,confirmLabel:a.withdrawConfirm,cancelLabel:a.withdrawCancel,danger:!0,loading:k,onConfirm:L,onClose:()=>O(!1)}),/* @__PURE__ */ H(it,{satisfaction:d.satisfaction,comment:d.satisfactionComment,canRate:d.canRate,commentMaxLength:i?.satisfactionCommentMaxLength,onRate:e=>F(()=>S(e))}),/* @__PURE__ */ H(nt,{messages:d.messages??[]}),d.mergedTickets?.length>0&&/* @__PURE__ */ U(`section`,{"aria-labelledby":`support-merged-${d.id}`,className:`d-flex flex-column gap-1`,children:[/* @__PURE__ */ H(`h3`,{id:`support-merged-${d.id}`,className:`h6 mb-0`,children:a.merged}),/* @__PURE__ */ H(`ul`,{className:`list-unstyled d-flex flex-column gap-1 mb-0 wui-text-sm`,children:d.mergedTickets.map(e=>/* @__PURE__ */ H(`li`,{children:r?/* @__PURE__ */ U(f,{variant:`ghost`,size:`sm`,onClick:()=>r(e.id),children:[e.number,`: `,e.subject]}):`${e.number}: ${e.subject}`},e.id))})]}),!d.mergedInto&&/* @__PURE__ */ H(C,{sticky:!0,align:`start`,children:/* @__PURE__ */ H(ot,{config:i,reopens:d.canReopen,onSend:e=>F(()=>v(e))})})]}),/* @__PURE__ */ H(`aside`,{"aria-label":a.detailsLabel,className:`col-12 col-lg-4`,children:/* @__PURE__ */ U(p,{padding:`sm`,className:`border`,children:[/* @__PURE__ */ H(`h3`,{className:`h6`,children:a.detailsTitle}),/* @__PURE__ */ H(y,{columns:1,items:V})]})})]})]})}var lt=`ticket`;function ut(){return typeof window>`u`?null:new URLSearchParams(window.location.search).get(lt)}function dt(e){if(typeof window>`u`)return e?`?${lt}=${encodeURIComponent(e)}`:`?`;let t=new URL(window.location.href);return e?t.searchParams.set(lt,e):t.searchParams.delete(lt),`${t.pathname}${t.search}${t.hash}`}function ft(e){if(typeof window>`u`)return;let t=dt(e);t!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,t)}var pt={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.`},mt=[`tabs`,`select`,`none`];function ht({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=X(`ticketList`,pt),g=X(`shared`,Q);F(`SupportCenter`,`statusFilter`,s,mt);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__ */ U(`div`,{className:`d-flex flex-column`,style:{minWidth:0},children:[/* @__PURE__ */ H(E,{href:dt(e.id),animation:`none`,className:`fw-semibold text-break`,onClick:t=>x(t,e.id),children:e.subject}),/* @__PURE__ */ U(`span`,{className:`wui-text-xs text-body-secondary`,children:[e.number,`, `,e.category]})]})},{key:`status`,label:h.columnStatus,render:e=>e.statusLabel?/* @__PURE__ */ H(M,{label:e.statusLabel,tone:Je(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__ */ H($e,{iso:e.updatedDateTimeUtc})}];return/* @__PURE__ */ U(`div`,{className:`d-flex flex-column gap-3`,children:[n&&/* @__PURE__ */ U(l,{tone:`danger`,children:[$(n,h.loadError,g.offline),` `,/* @__PURE__ */ H(f,{variant:`ghost`,size:`sm`,onClick:r,children:h.retry})]}),/* @__PURE__ */ U(`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__ */ H(k,{label:h.statusSelect,value:a,onChange:o,options:y,fieldClassName:`flex-shrink-0`}):/* @__PURE__ */ H(N,{tabs:_.map(({key:e,label:t,countKey:n})=>({key:e,label:t,count:u?.[n]})),value:a,onChange:o,ariaLabel:h.filterByStatus,className:`flex-grow-1`}),/* @__PURE__ */ H(O,{value:d,onChange:p,placeholder:h.searchPlaceholder,ariaLabel:h.searchLabel})]}),/* @__PURE__ */ H(v,{columns:S,rows:e,loading:t,skeletonRows:4,ariaLabel:h.tableLabel,rowActionsLabel:h.actions,rowActions:e=>/* @__PURE__ */ H(c,{icon:`eye`,label:Z(h.openTicket,{subject:e.subject}),href:dt(e.id),onClick:t=>x(t,e.id)}),stickyActions:!0,stackOnMobile:!0,sourceCount:u?.total??0,pagination:m,empty:/* @__PURE__ */ H(b,{variant:`table`,icon:`message-square`,title:h.emptyTitle,text:h.emptyText}),emptyFiltered:/* @__PURE__ */ H(b,{variant:`table`,icon:`search`,title:h.noMatchTitle,text:h.noMatchText})})]})}var gt=300,_t=10,vt={heading:`Your tickets`,newTicket:`New ticket`,configError:`We could not load the support settings.`,retry:`Try again`};function yt({initialTicketId:e,defaultCategory:t,appVersion:n,status:i,defaultStatus:a=`all`,onStatusChange:o,statusFilter:c=`tabs`}){let u=X(`supportCenter`,vt),d=X(`shared`,Q),{config:p,error:m,reload:h}=fe(),[g,_]=s(a),v=i!==void 0,y=v?i:g,b=e=>{v||_(e),o?.(e)},[x,S]=s(``),C=Te(x.trim(),gt),[w,T]=s(_t),E=`${y}|${C}|${w}`,[D,O]=s({key:E,page:1}),k=D.key===E?D.page:1,A=e=>O({key:E,page:e}),j=pe({status:y===`all`?void 0:y,search:C||void 0,page:k,pageSize:w}),{counts:M,reload:N}=me(),[P,F]=s(()=>e||ut()),[I,L]=s(!1),R=j.totalPages;r(()=>{R>0&&k>R&&O({key:E,page:R})},[R,k,E]);let z=()=>{j.reload(),N()},B=e=>{F(e),ft(e)};if(P)return/* @__PURE__ */ H(ct,{ticketId:P,onBack:()=>B(null),onChanged:z,onOpenTicket:B},P);let V={page:k,totalPages:Math.max(1,j.totalPages),pageSize:w,total:j.totalCount,setPage:A,setPageSize:T};return/* @__PURE__ */ U(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-labelledby":`support-center-title`,children:[/* @__PURE__ */ U(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2`,children:[/* @__PURE__ */ H(`h2`,{id:`support-center-title`,className:`h5 mb-0`,children:u.heading}),/* @__PURE__ */ H(f,{leftIcon:`plus`,onClick:()=>L(!0),disabled:!p,children:u.newTicket})]}),m&&/* @__PURE__ */ U(l,{tone:`warning`,children:[$(m,u.configError,d.offline),` `,/* @__PURE__ */ H(f,{variant:`ghost`,size:`sm`,onClick:h,children:u.retry})]}),/* @__PURE__ */ H(ht,{tickets:j.tickets,loading:j.loading,error:j.error,onRetry:z,onOpen:B,status:y,onStatusChange:b,statusFilter:c,counts:M,search:x,onSearchChange:S,pagination:V}),p&&/* @__PURE__ */ H(Ke,{open:I,onClose:()=>L(!1),config:p,defaultCategory:t,appVersion:n,onCreated:e=>{L(!1),z(),B(e.id)}})]})}var bt={copyEmail:`Copy email`,emailCopied:`Email copied`,contactNamed:`Contact {name}`,contactSupport:`Contact support`},xt=e=>typeof e==`string`&&e.trim()!==``;function St({className:e}){let t=X(`supportContact`,bt),{config:n}=fe();if(!n)return null;let r=xt(n.supportEmail),i=xt(n.supportPhone),a=xt(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__ */ U(`section`,{className:o,"aria-label":xt(n.supportName)?Z(t.contactNamed,{name:n.supportName}):t.contactSupport,children:[/* @__PURE__ */ H(`span`,{className:`fw-semibold`,children:xt(n.supportName)?n.supportName:t.contactSupport}),r&&/* @__PURE__ */ U(`span`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ H(`a`,{href:`mailto:${n.supportEmail}`,className:`text-break`,children:n.supportEmail}),/* @__PURE__ */ H(_,{text:n.supportEmail,iconOnly:!0,label:t.copyEmail,copiedLabel:t.emailCopied})]}),i&&/* @__PURE__ */ H(`a`,{href:`tel:${n.supportPhone.replace(/[^\d+]/g,``)}`,children:n.supportPhone}),a&&/* @__PURE__ */ H(`span`,{className:`text-body-secondary`,children:n.supportHours})]})}function Ct({client:e,timeZone:n=L,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__ */ H(ce.Provider,{value:u,children:s})}export{We as ReportIssue,W as SupportApiError,yt as SupportCenter,St as SupportContact,Ct as SupportProvider,oe as createSupportClient,Y as useSupportClient,fe as useSupportConfig,he as useSupportTicket,me as useSupportTicketCounts,pe 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{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,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};
@@ -11,6 +11,7 @@ export declare class SupportApiError extends Error {
11
11
  */
12
12
  constructor(code: string, message: string, status?: number);
13
13
  }
14
+ export declare function normaliseError(error: any): Promise<SupportApiError>;
14
15
  export type SupportHttp = {
15
16
  get: (url: string, config?: object) => Promise<{
16
17
  data: any;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * One published help article: its title, its dates and its Markdown body, with a back action when
3
+ * `onBack` is given. The body renders as Markdown only; HTML in it shows as text. The Published line
4
+ * is left out when the article has no publish date.
5
+ * Needs a SupportProvider above it for its labels and times.
6
+ *
7
+ * @param {object} props
8
+ * @param {import('./client.js').HelpCentreClient} props.client
9
+ * @param {string} props.slug
10
+ * @param {() => void} [props.onBack]
11
+ */
12
+ export default function HelpArticle({ client, slug, onBack }: {
13
+ client: import('./client.js').HelpCentreClient;
14
+ slug: string;
15
+ onBack?: () => void;
16
+ }): import("react").JSX.Element;
@@ -0,0 +1,34 @@
1
+ export declare const meta: {
2
+ readonly name: "HelpArticle";
3
+ readonly marker: null;
4
+ readonly platforms: readonly ["web"];
5
+ readonly acceptsChildren: false;
6
+ readonly props: {
7
+ readonly client: {
8
+ readonly type: "object";
9
+ readonly required: true;
10
+ readonly description: "The help centre client from createHelpCentreClient, bound to the product's API prefix.";
11
+ };
12
+ readonly slug: {
13
+ readonly type: "string";
14
+ readonly required: true;
15
+ readonly description: "The article's slug, as the help centre list gives it.";
16
+ };
17
+ readonly onBack: {
18
+ readonly type: "any";
19
+ readonly description: "Called by the back action. Left out, the article has no back action.";
20
+ };
21
+ };
22
+ readonly omit: readonly [];
23
+ readonly examples: readonly [];
24
+ readonly usage: {
25
+ readonly when: readonly ["A customer has opened one help article and needs to read it."];
26
+ readonly whenNot: readonly [{
27
+ readonly text: "The customer needs to contact support about their own account.";
28
+ readonly instead: "SupportCenter";
29
+ }];
30
+ readonly do: readonly [];
31
+ readonly dont: readonly [];
32
+ readonly a11y: readonly ["The article title is a heading, and its dates are read as times.", "A missing article shows a message instead of an empty page."];
33
+ };
34
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The public help centre: the published articles, one page at a time, and a search box when the
3
+ * server offers search. A row opens its article through `onOpen(slug)`, or through the href `linkTo(slug)`
4
+ * gives for a router link (a modified click then keeps the link's own new-tab behaviour).
5
+ * Needs a SupportProvider above it for its labels and times.
6
+ *
7
+ * @param {object} props
8
+ * @param {import('./client.js').HelpCentreClient} props.client
9
+ * @param {(slug: string) => void} [props.onOpen]
10
+ * @param {(slug: string) => string} [props.linkTo]
11
+ */
12
+ export default function HelpCentre({ client, onOpen, linkTo }: {
13
+ client: import('./client.js').HelpCentreClient;
14
+ onOpen?: (slug: string) => void;
15
+ linkTo?: (slug: string) => string;
16
+ }): import("react").JSX.Element;
@@ -0,0 +1,33 @@
1
+ export declare const meta: {
2
+ readonly name: "HelpCentre";
3
+ readonly marker: null;
4
+ readonly platforms: readonly ["web"];
5
+ readonly acceptsChildren: false;
6
+ readonly props: {
7
+ readonly client: {
8
+ readonly type: "object";
9
+ readonly required: true;
10
+ readonly description: "The help centre client from createHelpCentreClient, bound to the product's API prefix.";
11
+ };
12
+ readonly onOpen: {
13
+ readonly type: "any";
14
+ readonly description: "Called with an article's slug when a row opens it in place. Left out, the row is a plain button.";
15
+ };
16
+ readonly linkTo: {
17
+ readonly type: "any";
18
+ readonly description: "Called with an article's slug and returns the href of its page, for a router link that keeps new-tab clicks.";
19
+ };
20
+ };
21
+ readonly omit: readonly [];
22
+ readonly examples: readonly [];
23
+ readonly usage: {
24
+ readonly when: readonly ["A customer or visitor needs answers from the support team's published help articles.", "The product offers search over those articles and the customer wants to find one by words."];
25
+ readonly whenNot: readonly [{
26
+ readonly text: "The customer needs to raise or follow their own ticket.";
27
+ readonly instead: "SupportCenter";
28
+ }];
29
+ readonly do: readonly [];
30
+ readonly dont: readonly [];
31
+ readonly a11y: readonly ["The page is a section labelled by its Help centre heading.", "The search box is labelled and appears only when the server offers search.", "Each article is a button or a link named by its title."];
32
+ };
33
+ };
@@ -0,0 +1,98 @@
1
+ export type HelpCentreHttp = {
2
+ get: (url: string, config?: object) => Promise<{
3
+ data: any;
4
+ }>;
5
+ };
6
+ export type HelpArticleSummary = {
7
+ id: string;
8
+ slug: string;
9
+ title: string;
10
+ summary: string;
11
+ publishedDateTimeUtc: string | null;
12
+ updatedDateTimeUtc: string;
13
+ };
14
+ export type HelpArticle = HelpArticleSummary & {
15
+ bodyMarkdown: string;
16
+ };
17
+ export type HelpArticlePage = {
18
+ items: HelpArticleSummary[];
19
+ page: number;
20
+ pageSize: number;
21
+ totalCount: number;
22
+ totalPages: number;
23
+ };
24
+ export type HelpCentreSettings = {
25
+ /**
26
+ * The help centre's home page.
27
+ */
28
+ publicUrl: string;
29
+ /**
30
+ * False when the server has no search; search is then never asked.
31
+ */
32
+ searchAvailable: boolean;
33
+ };
34
+ export type HelpCentreClient = {
35
+ settings: (options?: {
36
+ signal?: AbortSignal;
37
+ }) => Promise<HelpCentreSettings>;
38
+ list: (query?: {
39
+ page?: number;
40
+ pageSize?: number;
41
+ }, options?: {
42
+ signal?: AbortSignal;
43
+ }) => Promise<HelpArticlePage>;
44
+ get: (slug: string, options?: {
45
+ signal?: AbortSignal;
46
+ }) => Promise<HelpArticle>;
47
+ search: (q: string, options?: {
48
+ signal?: AbortSignal;
49
+ }) => Promise<HelpArticleSummary[]>;
50
+ };
51
+ /**
52
+ * @typedef {object} HelpCentreHttp An axios-like HTTP client.
53
+ * @property {(url: string, config?: object) => Promise<{ data: any }>} get
54
+ */
55
+ /**
56
+ * @typedef {object} HelpArticleSummary
57
+ * @property {string} id
58
+ * @property {string} slug
59
+ * @property {string} title
60
+ * @property {string} summary
61
+ * @property {string|null} publishedDateTimeUtc
62
+ * @property {string} updatedDateTimeUtc
63
+ */
64
+ /**
65
+ * @typedef {HelpArticleSummary & { bodyMarkdown: string }} HelpArticle
66
+ */
67
+ /**
68
+ * @typedef {object} HelpArticlePage
69
+ * @property {HelpArticleSummary[]} items
70
+ * @property {number} page
71
+ * @property {number} pageSize
72
+ * @property {number} totalCount
73
+ * @property {number} totalPages
74
+ */
75
+ /**
76
+ * @typedef {object} HelpCentreSettings
77
+ * @property {string} publicUrl The help centre's home page.
78
+ * @property {boolean} searchAvailable False when the server has no search; search is then never asked.
79
+ */
80
+ /**
81
+ * @typedef {object} HelpCentreClient
82
+ * @property {(options?: { signal?: AbortSignal }) => Promise<HelpCentreSettings>} settings
83
+ * @property {(query?: { page?: number, pageSize?: number }, options?: { signal?: AbortSignal }) => Promise<HelpArticlePage>} list
84
+ * @property {(slug: string, options?: { signal?: AbortSignal }) => Promise<HelpArticle>} get
85
+ * @property {(q: string, options?: { signal?: AbortSignal }) => Promise<HelpArticleSummary[]>} search
86
+ */
87
+ /**
88
+ * Binds the help-centre HTTP contract under a prefix the host chooses.
89
+ *
90
+ * @param {object} options
91
+ * @param {string} options.baseUrl The prefix the API maps the help-centre endpoints under, such as "/api/help".
92
+ * @param {HelpCentreHttp} options.http
93
+ * @returns {HelpCentreClient}
94
+ */
95
+ export declare function createHelpCentreClient({ baseUrl, http }: {
96
+ baseUrl: string;
97
+ http: HelpCentreHttp;
98
+ }): HelpCentreClient;
@@ -0,0 +1,23 @@
1
+ export declare const HELP_CENTRE_LABELS: {
2
+ heading: string;
3
+ searchPlaceholder: string;
4
+ searchLabel: string;
5
+ tableLabel: string;
6
+ columnArticle: string;
7
+ columnUpdated: string;
8
+ listError: string;
9
+ settingsError: string;
10
+ retry: string;
11
+ emptyTitle: string;
12
+ emptyText: string;
13
+ noMatchTitle: string;
14
+ noMatchText: string;
15
+ };
16
+ export declare const HELP_ARTICLE_LABELS: {
17
+ back: string;
18
+ published: string;
19
+ updated: string;
20
+ loadError: string;
21
+ notFoundTitle: string;
22
+ retry: string;
23
+ };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The help centre's settings, its article list and its search, for one client. Search is asked only
3
+ * when the settings say the server offers it and the words are at least two characters long.
4
+ *
5
+ * @param {import('./client.js').HelpCentreClient} client
6
+ * @returns {{
7
+ * settings: { data: import('./client.js').HelpCentreSettings|null, loading: boolean, error: any, reload: () => void },
8
+ * articles: {
9
+ * items: import('./client.js').HelpArticleSummary[], page: number, pageSize: number, totalCount: number, totalPages: number,
10
+ * loading: boolean, error: any, setPage: (page: number) => void, setPageSize: (size: number) => void, reload: () => void
11
+ * },
12
+ * search: {
13
+ * enabled: boolean, query: string, setQuery: (query: string) => void, active: boolean,
14
+ * results: import('./client.js').HelpArticleSummary[], loading: boolean, error: any, reload: () => void
15
+ * }
16
+ * }}
17
+ */
18
+ export declare function useHelpCentre(client: import('./client.js').HelpCentreClient): {
19
+ settings: {
20
+ data: import('./client.js').HelpCentreSettings | null;
21
+ loading: boolean;
22
+ error: any;
23
+ reload: () => void;
24
+ };
25
+ articles: {
26
+ items: import('./client.js').HelpArticleSummary[];
27
+ page: number;
28
+ pageSize: number;
29
+ totalCount: number;
30
+ totalPages: number;
31
+ loading: boolean;
32
+ error: any;
33
+ setPage: (page: number) => void;
34
+ setPageSize: (size: number) => void;
35
+ reload: () => void;
36
+ };
37
+ search: {
38
+ enabled: boolean;
39
+ query: string;
40
+ setQuery: (query: string) => void;
41
+ active: boolean;
42
+ results: import('./client.js').HelpArticleSummary[];
43
+ loading: boolean;
44
+ error: any;
45
+ reload: () => void;
46
+ };
47
+ };
@@ -1,5 +1,9 @@
1
1
  export { createSupportClient, SupportApiError } from "./client.js";
2
2
  export { useSupportClient, useSupportConfig, useSupportTicket, useSupportTicketCounts, useSupportTickets } from "./context.js";
3
+ export { createHelpCentreClient } from "./helpCentre/client.js";
4
+ export { default as HelpArticle } from "./helpCentre/HelpArticle.jsx";
5
+ export { default as HelpCentre } from "./helpCentre/HelpCentre.jsx";
6
+ export { useHelpCentre } from "./helpCentre/useHelpCentre.js";
3
7
  export { default as ReportIssue } from "./ReportIssue.jsx";
4
8
  export { default as SupportCenter } from "./SupportCenter.jsx";
5
9
  export { default as SupportContact } from "./SupportContact.jsx";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@webority/support-react",
3
- "version": "0.129.0",
4
- "description": "Webority customer support for React portals: ticket centre, report-an-issue with an optional page screenshot, and support contact details, built on @webority/ui-react.",
3
+ "version": "0.130.1",
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",
7
7
  "publishConfig": {
@@ -27,8 +27,8 @@
27
27
  },
28
28
  "sideEffects": false,
29
29
  "peerDependencies": {
30
- "@webority/ui-elements": "0.129.0",
31
- "@webority/ui-react": "0.129.0",
30
+ "@webority/ui-elements": "0.130.1",
31
+ "@webority/ui-react": "0.130.1",
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.129.0",
46
- "@webority/ui-elements": "0.129.0",
47
- "@webority/ui-react": "0.129.0",
45
+ "@webority/canvas-kit": "0.130.1",
46
+ "@webority/ui-elements": "0.130.1",
47
+ "@webority/ui-react": "0.130.1",
48
48
  "bootstrap": "5.3.3",
49
49
  "jsdom": "30.1.1",
50
50
  "react": "^19.2.6",