@webority/mobile-chat 0.133.0 → 0.134.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/lib/commonjs/AgentByline.js +1 -1
  2. package/lib/commonjs/ChatComposer.js +1 -1
  3. package/lib/commonjs/ChatConversationActions.js +1 -1
  4. package/lib/commonjs/ChatDictationButton.js +1 -1
  5. package/lib/commonjs/ChatEmbed.js +1 -1
  6. package/lib/commonjs/ChatFooter.js +1 -1
  7. package/lib/commonjs/ChatFrame.js +1 -1
  8. package/lib/commonjs/ChatHistory.js +1 -1
  9. package/lib/commonjs/ChatLiveBar.js +1 -1
  10. package/lib/commonjs/ChatMessageActions.js +1 -1
  11. package/lib/commonjs/ChatNudge.js +1 -1
  12. package/lib/commonjs/ChatOpenTickets.js +1 -1
  13. package/lib/commonjs/ChatPastChats.js +1 -0
  14. package/lib/commonjs/ChatScreen.js +1 -1
  15. package/lib/commonjs/ChatSheet.js +1 -1
  16. package/lib/commonjs/ChatStarters.js +1 -1
  17. package/lib/commonjs/ChatThread.js +1 -1
  18. package/lib/commonjs/ReadAloudButton.js +1 -1
  19. package/lib/commonjs/features.map.json +3 -3
  20. package/lib/commonjs/index.js +1 -1
  21. package/lib/commonjs/loaders/ChatLoader.js +1 -1
  22. package/lib/commonjs/renderers/ActionPart.js +1 -1
  23. package/lib/commonjs/renderers/ChartPart.js +1 -1
  24. package/lib/commonjs/renderers/FigureText.js +1 -1
  25. package/lib/commonjs/renderers/FiguresPart.js +1 -1
  26. package/lib/commonjs/renderers/FilePart.js +1 -1
  27. package/lib/commonjs/renderers/HandoffPart.js +1 -1
  28. package/lib/commonjs/renderers/ImagePart.js +1 -1
  29. package/lib/commonjs/renderers/InputRequestPart.js +1 -1
  30. package/lib/commonjs/renderers/NoticePart.js +1 -1
  31. package/lib/commonjs/renderers/QuickRepliesPart.js +1 -1
  32. package/lib/commonjs/renderers/RecordCardPart.js +1 -1
  33. package/lib/commonjs/renderers/SourcesPart.js +1 -1
  34. package/lib/commonjs/renderers/TablePart.js +1 -1
  35. package/lib/commonjs/renderers/TicketPart.js +1 -1
  36. package/lib/commonjs/renderers/VoiceClipPart.js +1 -1
  37. package/lib/commonjs/speech/phoneSpeech.js +1 -1
  38. package/lib/commonjs/speech/speechText.js +1 -1
  39. package/lib/commonjs/useChat.js +1 -1
  40. package/lib/commonjs/useChatHaptics.js +1 -1
  41. package/lib/commonjs/useChatSound.js +1 -0
  42. package/lib/module/AgentByline.js +1 -1
  43. package/lib/module/ChatComposer.js +1 -1
  44. package/lib/module/ChatConversationActions.js +1 -1
  45. package/lib/module/ChatDictationButton.js +1 -1
  46. package/lib/module/ChatEmbed.js +1 -1
  47. package/lib/module/ChatFooter.js +1 -1
  48. package/lib/module/ChatFrame.js +1 -1
  49. package/lib/module/ChatHistory.js +1 -1
  50. package/lib/module/ChatLiveBar.js +1 -1
  51. package/lib/module/ChatMessageActions.js +1 -1
  52. package/lib/module/ChatNudge.js +1 -1
  53. package/lib/module/ChatOpenTickets.js +1 -1
  54. package/lib/module/ChatPastChats.js +1 -0
  55. package/lib/module/ChatScreen.js +1 -1
  56. package/lib/module/ChatSheet.js +1 -1
  57. package/lib/module/ChatStarters.js +1 -1
  58. package/lib/module/ChatThread.js +1 -1
  59. package/lib/module/ReadAloudButton.js +1 -1
  60. package/lib/module/features.map.json +3 -3
  61. package/lib/module/index.js +1 -1
  62. package/lib/module/loaders/ChatLoader.js +1 -1
  63. package/lib/module/renderers/ActionPart.js +1 -1
  64. package/lib/module/renderers/ChartPart.js +1 -1
  65. package/lib/module/renderers/FigureText.js +1 -1
  66. package/lib/module/renderers/FiguresPart.js +1 -1
  67. package/lib/module/renderers/FilePart.js +1 -1
  68. package/lib/module/renderers/HandoffPart.js +1 -1
  69. package/lib/module/renderers/ImagePart.js +1 -1
  70. package/lib/module/renderers/InputRequestPart.js +1 -1
  71. package/lib/module/renderers/NoticePart.js +1 -1
  72. package/lib/module/renderers/QuickRepliesPart.js +1 -1
  73. package/lib/module/renderers/RecordCardPart.js +1 -1
  74. package/lib/module/renderers/SourcesPart.js +1 -1
  75. package/lib/module/renderers/TablePart.js +1 -1
  76. package/lib/module/renderers/TicketPart.js +1 -1
  77. package/lib/module/renderers/VoiceClipPart.js +1 -1
  78. package/lib/module/speech/phoneSpeech.js +1 -1
  79. package/lib/module/speech/speechText.js +1 -1
  80. package/lib/module/useChat.js +1 -1
  81. package/lib/module/useChatHaptics.js +1 -1
  82. package/lib/module/useChatSound.js +1 -0
  83. package/lib/typescript/commonjs/ChatComposer.d.ts +2 -1
  84. package/lib/typescript/commonjs/ChatConversationActions.d.ts +1 -1
  85. package/lib/typescript/commonjs/ChatDictationButton.d.ts +3 -1
  86. package/lib/typescript/commonjs/ChatEmbed.d.ts +1 -1
  87. package/lib/typescript/commonjs/ChatFrame.d.ts +7 -1
  88. package/lib/typescript/commonjs/ChatPastChats.d.ts +21 -0
  89. package/lib/typescript/commonjs/ChatScreen.d.ts +1 -1
  90. package/lib/typescript/commonjs/ChatSheet.d.ts +1 -1
  91. package/lib/typescript/commonjs/ChatThread.d.ts +3 -1
  92. package/lib/typescript/commonjs/index.d.ts +1 -0
  93. package/lib/typescript/commonjs/renderers/ChartPart.d.ts +1 -1
  94. package/lib/typescript/commonjs/renderers/FigureText.d.ts +4 -2
  95. package/lib/typescript/commonjs/renderers/HandoffPart.d.ts +1 -1
  96. package/lib/typescript/commonjs/renderers/VoiceClipPart.d.ts +1 -1
  97. package/lib/typescript/commonjs/speech/speechText.d.ts +3 -3
  98. package/lib/typescript/commonjs/types.d.ts +9 -1
  99. package/lib/typescript/commonjs/useChat.d.ts +2 -0
  100. package/lib/typescript/commonjs/useChatSound.d.ts +35 -0
  101. package/lib/typescript/module/ChatComposer.d.ts +2 -1
  102. package/lib/typescript/module/ChatConversationActions.d.ts +1 -1
  103. package/lib/typescript/module/ChatDictationButton.d.ts +3 -1
  104. package/lib/typescript/module/ChatEmbed.d.ts +1 -1
  105. package/lib/typescript/module/ChatFrame.d.ts +7 -1
  106. package/lib/typescript/module/ChatPastChats.d.ts +21 -0
  107. package/lib/typescript/module/ChatScreen.d.ts +1 -1
  108. package/lib/typescript/module/ChatSheet.d.ts +1 -1
  109. package/lib/typescript/module/ChatThread.d.ts +3 -1
  110. package/lib/typescript/module/index.d.ts +1 -0
  111. package/lib/typescript/module/renderers/ChartPart.d.ts +1 -1
  112. package/lib/typescript/module/renderers/FigureText.d.ts +4 -2
  113. package/lib/typescript/module/renderers/HandoffPart.d.ts +1 -1
  114. package/lib/typescript/module/renderers/VoiceClipPart.d.ts +1 -1
  115. package/lib/typescript/module/speech/speechText.d.ts +3 -3
  116. package/lib/typescript/module/types.d.ts +9 -1
  117. package/lib/typescript/module/useChat.d.ts +2 -0
  118. package/lib/typescript/module/useChatSound.d.ts +35 -0
  119. package/package.json +10 -9
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AgentByline=AgentByline;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");function AgentByline({author:e,labels:i}){const t=(0,_mobileUi.useTheme)(),r=e.displayName||i.agent,a=e.avatarUrl?{uri:e.avatarUrl}:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:"row",alignItems:"center",gap:t.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Avatar,{size:"xs",name:r,source:a}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:r})]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AgentByline=AgentByline;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");function AgentByline({author:e,labels:i}){const t=(0,_mobileUi.useTheme)(),r=e.displayName||i.agent,a=e.avatarUrl?{uri:e.avatarUrl}:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:"row",alignItems:"center",gap:t.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Avatar,{size:"xs",name:r,source:a}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:r}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",children:i.agent})]})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatComposer=ChatComposer;var _permissions=require("@webority/mobile-core/permissions"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ChatDictationButton=require("./ChatDictationButton.js"),_ChatFooter=require("./ChatFooter.js"),_speechText=require("./speech/speechText.js"),_jsxRuntime=require("react/jsx-runtime");const ALLOWANCE_SHOWN_AT=10,DEFAULT_MAX_LENGTH=4e3;function ChatComposer({chat:e,labels:t,pickAttachments:s,keyboardOffset:a,keyboardAware:i,safeArea:o,testID:n="chat-composer"}){const r=(0,_mobileUi.useTheme)(),l=(0,_react.useMemo)(()=>buildStyles(r),[r]),[c,m]=(0,_react.useState)(""),[u,h]=(0,_react.useState)(null),d=e.editing;(0,_react.useEffect)(()=>{m(d?d.text:"")},[d]);const p=e.attachments,_=p.some(e=>"Uploading"===e.status),x=p.some(e=>"Ready"===e.status),g=e.messagesLeftToday,b=e.profile?.limits.maxMessageLength??DEFAULT_MAX_LENGTH,j=void 0!==s&&e.features.Attachments&&(e.profile?.limits.maxAttachments??0)>0,f=e.features.HumanHandoff&&("WaitingForAgent"===e.conversationState||"WithAgent"===e.conversationState),v=j&&!e.handoffPause?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"paperclip",accessibilityLabel:t.attach,variant:"ghost",tone:"neutral",onPress:()=>{s&&s().then(t=>e.attach(t))},testID:`${n}-attach`}):void 0,y=d?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{message:t.editing,accessibilityRole:"summary",actions:[{label:t.cancel,onPress:()=>e.cancelEdit()}],testID:`${n}-editing`}):null,R=p.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:l.tray,testID:`${n}-attachments`,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:l.row,children:p.map(s=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:l.item,children:[(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:s.fileName,variant:"soft",onRemove:()=>{e.removeAttachment(s.key)},labels:{remove:t.removeAttachment},removeTestID:`${n}-remove-${s.key}`,testID:`${n}-chip-${s.key}`}),"Uploading"===s.status?(0,_jsxRuntime.jsx)(_mobileUi.ProgressBar,{progress:s.progress??void 0,label:t.attachmentUploading,height:4,containerStyle:l.progress}):null,"Failed"===s.status?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:t.attachmentFailed}):null]},s.key))})}):null,A=null!==g&&g<=ALLOWANCE_SHOWN_AT?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:0===g?"danger":"secondary",accessibilityLiveRegion:"polite",testID:`${n}-allowance`,children:t.allowance(g)}):null,C=u?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{message:u.message,tone:"danger",dismissible:!0,onClose:()=>h(null),actions:u.openSettings?[{label:t.dictateOpenSettings,onPress:()=>{_permissions.Permissions.openSettings()}}]:void 0,testID:`${n}-voice-notice`}):null,S=y||R||A||C?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[y,R,A,C]}):void 0,T=!_&&(!!x||void 0),D=c.length>0,L=!0===e.profile?.experience.motion;return(0,_jsxRuntime.jsx)(_mobileUi.Composer,{onSend:t=>{e.submit(t)},value:c,onChangeText:t=>{m(t),f&&t.length>0&&e.notifyTyping()},loading:e.streaming,ring:L&&(D||e.streaming),sendReveal:L?"onText":"always",onStop:e.features.Stop?()=>e.stop():void 0,stopLabel:t.stop,disabled:0===g||e.handoffPause,maxLength:b,canSend:T,placeholder:e.handoffPause?t.handoffMoment:t.placeholder,accessibilityLabel:t.composer,labels:{send:t.send},leading:v,trailing:(0,_jsxRuntime.jsx)(_ChatDictationButton.ChatDictationButton,{chat:e,labels:t,disabled:0===g||e.handoffPause,onText:e=>m(t=>(0,_speechText.joinDictation)(t,e,b)),onNotice:h}),above:S,below:(0,_jsxRuntime.jsx)(_ChatFooter.ChatFooter,{chat:e,labels:t}),keyboardAware:i,keyboardOffset:a,safeArea:o,testID:n})}const buildStyles=e=>_reactNative.StyleSheet.create({tray:{gap:e.space.xs},row:{flexDirection:"row",flexWrap:"wrap",gap:e.space.xs},item:{gap:e.space.xxs,maxWidth:"100%"},progress:{minWidth:120}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatComposer=ChatComposer;var _permissions=require("@webority/mobile-core/permissions"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ChatDictationButton=require("./ChatDictationButton.js"),_ChatFooter=require("./ChatFooter.js"),_speechText=require("./speech/speechText.js"),_jsxRuntime=require("react/jsx-runtime");const ALLOWANCE_SHOWN_AT=10,COUNTER_AT=.9,DEFAULT_MAX_LENGTH=4e3,openQuestion=e=>{for(let t=e.length-1;t>=0;t-=1){const s=e[t];for(const e of[...s?.parts??[]].reverse())if("InputRequest"===e.kind&&"Open"===e.state)return e.fields[0]?.label||e.title||null}return null};function ChatComposer({chat:e,labels:t,pickAttachments:s,keyboardOffset:i,keyboardAware:a,safeArea:n,testID:o="chat-composer",focusRef:r}){const l=(0,_mobileUi.useTheme)(),c=(0,_react.useMemo)(()=>buildStyles(l),[l]),[u,m]=(0,_react.useState)(""),[h,p]=(0,_react.useState)(null),d=e.editing,_=(0,_react.useRef)(null),x=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(r)return r.current=()=>x.current?.focus(),()=>{r.current=null}},[r]),(0,_react.useEffect)(()=>{d&&_.current?.(),m(d?d.text:"")},[d]);const f=e.attachments,g=f.some(e=>"Uploading"===e.status),b=f.some(e=>"Ready"===e.status),j=e.messagesLeftToday,v=e.profile?.limits.maxMessageLength??DEFAULT_MAX_LENGTH,y=void 0!==s&&e.features.Attachments&&(e.profile?.limits.maxAttachments??0)>0,R=e.features.HumanHandoff&&("WaitingForAgent"===e.conversationState||"WithAgent"===e.conversationState),A=y&&!e.handoffPause?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"paperclip",accessibilityLabel:t.attach,variant:"ghost",tone:"neutral",onPress:()=>{s&&s().then(t=>e.attach(t))},testID:`${o}-attach`}):void 0,T=d?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{message:t.editing,accessibilityRole:"summary",actions:[{label:t.cancel,onPress:()=>e.cancelEdit()}],testID:`${o}-editing`}):null,C=f.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:c.tray,testID:`${o}-attachments`,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:c.row,children:f.map(s=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:c.item,children:[(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:s.fileName,variant:"soft",onRemove:()=>{e.removeAttachment(s.key)},labels:{remove:t.removeAttachment},removeTestID:`${o}-remove-${s.key}`,testID:`${o}-chip-${s.key}`}),"Uploading"===s.status?(0,_jsxRuntime.jsx)(_mobileUi.ProgressBar,{progress:s.progress??void 0,label:t.attachmentUploading,height:4,containerStyle:c.progress}):null,"Failed"===s.status?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:s.error??t.attachmentFailed}):null]},s.key))})}):null,S=null!==j&&j<=ALLOWANCE_SHOWN_AT?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:0===j?"danger":"secondary",accessibilityLiveRegion:"polite",testID:`${o}-allowance`,children:t.allowance(j)}):null,D=h?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{message:h.message,tone:h.tone,dismissible:!0,onClose:()=>p(null),actions:h.openSettings?[{label:t.dictateOpenSettings,onPress:()=>{_permissions.Permissions.openSettings()}}]:void 0,testID:`${o}-voice-notice`}):null,U=u.length>0,L=u.length>v*COUNTER_AT?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",testID:`${o}-counter`,children:t.counter(u.length,v)}):null,w=T||C||S||L||D?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[T,C,S,L,D]}):void 0,N=!g&&(!!b||void 0),I=!0===e.profile?.experience.motion;return(0,_jsxRuntime.jsx)(_mobileUi.Composer,{ref:x,onSend:t=>{_.current?.(),e.submit(t)},value:u,onChangeText:t=>{_.current?.(),m(t),R&&t.length>0&&e.notifyTyping()},loading:e.streaming&&e.features.Stop,ring:I&&(U||e.streaming),sendReveal:I?"onText":"always",onStop:e.features.Stop?()=>e.stop():void 0,stopLabel:t.stop,disabled:0===j||e.handoffPause,maxLength:v,canSend:N,placeholder:e.handoffPause?t.handoffMoment:openQuestion(e.messages)??t.placeholder,accessibilityLabel:t.composer,labels:{send:t.send},leading:A,trailing:(0,_jsxRuntime.jsx)(_ChatDictationButton.ChatDictationButton,{chat:e,labels:t,disabled:0===j||e.handoffPause,onText:e=>m(t=>(0,_speechText.joinDictation)(t,e,v)),onNotice:p,stopRef:_}),above:w,below:(0,_jsxRuntime.jsx)(_ChatFooter.ChatFooter,{chat:e,labels:t}),keyboardAware:a,keyboardOffset:i,safeArea:n,testID:o})}const buildStyles=e=>_reactNative.StyleSheet.create({tray:{gap:e.space.xs},row:{flexDirection:"row",flexWrap:"wrap",gap:e.space.xs},item:{gap:e.space.xxs,maxWidth:"100%"},progress:{minWidth:120}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatConversationActions=ChatConversationActions;var _mobileUi=require("@webority/mobile-ui"),_useTranscriptActions=_interopRequireDefault(require("./useTranscriptActions.js")),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ChatConversationActions({chat:e,labels:i,testID:t}){const n=(0,_useTranscriptActions.default)(e,i);return n.canShare&&e.messages.some(e=>!e.streaming)?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"share",variant:"ghost",size:"sm",accessibilityLabel:i.shareConversation,disabled:e.streaming||e.thinking,onPress:()=>{n.shareConversation()},testID:t}),null!==n.notice?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:n.notice}):null]}):null}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatConversationActions=ChatConversationActions;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_useTranscriptActions=_interopRequireDefault(require("./useTranscriptActions.js")),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const REPLY_AUTHORS=new Set(["Assistant","Agent","Script"]);function ChatConversationActions({chat:e,labels:t,testID:i}){const n=(0,_useTranscriptActions.default)(e,t),s=e.messages.some(e=>e.stored&&REPLY_AUTHORS.has(e.author.kind)&&""!==(0,_chatCore.messagePlainText)(e.parts));return e.streaming||e.thinking||e.loading||null===e.conversationId||!s||!n.canShare?null:(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"share",variant:"ghost",size:"sm",accessibilityLabel:t.shareConversation,onPress:()=>{n.shareConversation()},testID:i}),null!==n.notice?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:n.notice}):null]})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatDictationButton=ChatDictationButton;var _mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_phoneSpeech=require("./speech/phoneSpeech.js"),_useChatSpeech=require("./useChatSpeech.js"),_jsxRuntime=require("react/jsx-runtime");function ChatDictationButton({chat:e,labels:t,disabled:i=!1,onText:n,onNotice:r,testID:a="chat-dictation"}){const c=(0,_useChatSpeech.useChatSpeech)(e),[o,s]=(0,_react.useState)("idle"),u=(0,_react.useRef)(null),l=(0,_react.useRef)(!0);if((0,_react.useEffect)(()=>(l.current=!0,()=>{l.current=!1,u.current?.abort()}),[]),!e.features.Dictation||null===c)return null;const d="transcribing"===o,h="listening"===o,g=h?t.dictateStop:d?t.dictateTranscribing:t.dictate;return(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:h?"stop":"microphone",accessibilityLabel:g,variant:"ghost",tone:"neutral",active:h,loading:d,disabled:i||d,onPress:()=>{if("listening"===o)return s("transcribing"),void u.current?.abort();if("idle"!==o)return;r(null);const e=new AbortController;u.current=e,s("listening"),(0,_mobileUi.announce)(t.dictateListening);let i=!1;(async()=>{try{await c.startDictation({signal:e.signal,onText:e=>{l.current&&(i=!0,n(e))},onEnd:()=>{l.current&&s("transcribing")}}),l.current&&!i&&r({message:t.dictationNotHeard,openSettings:!1})}catch(e){if(!l.current)return;e instanceof _phoneSpeech.PhoneSpeechError?r(dictationFailure(e,t)):(_mobileCore.Logger.error("[chat] dictation failed",e),r({message:t.dictationFailed,openSettings:!1}))}finally{l.current&&(u.current=null,s("idle"))}})()},testID:a})}const dictationFailure=(e,t)=>{switch(e.phoneCode){case"MicBlocked":return{message:t.dictationBlocked,openSettings:!0};case"MicDenied":return{message:t.dictationBlocked,openSettings:!1};case"MicUnavailable":return{message:t.dictationNoMicrophone,openSettings:!1};default:return{message:t.dictationFailed,openSettings:!1}}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatDictationButton=ChatDictationButton;var _mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_phoneSpeech=require("./speech/phoneSpeech.js"),_useChatSpeech=require("./useChatSpeech.js"),_jsxRuntime=require("react/jsx-runtime");function ChatDictationButton({chat:e,labels:t,disabled:n=!1,onText:i,onNotice:r,testID:a="chat-dictation",stopRef:o}){const c=(0,_useChatSpeech.useChatSpeech)(e),[s,u]=(0,_react.useState)("idle"),l=(0,_react.useRef)(null),d=(0,_react.useRef)(!0),g=(0,_react.useRef)(!1);if((0,_react.useEffect)(()=>{if(o)return o.current=()=>{null!==l.current&&(u("transcribing"),l.current.abort())},()=>{o.current=null}},[o]),(0,_react.useEffect)(()=>(d.current=!0,()=>{d.current=!1,g.current=!0,l.current?.abort()}),[]),!e.features.Dictation||null===c)return null;const h="transcribing"===s,p="listening"===s,b=p?t.dictateStop:h?t.dictateTranscribing:t.dictate;return(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:p?"stop":"microphone",accessibilityLabel:b,variant:"ghost",tone:"neutral",active:p,loading:h,disabled:n||h,onPress:()=>{if("listening"===s)return u("transcribing"),void l.current?.abort();if("idle"!==s)return;r(null),g.current=!1;const e=new AbortController;l.current=e,u("listening"),(0,_mobileUi.announce)(t.dictateListening);let n=!1;(async()=>{try{await c.startDictation({signal:e.signal,onText:e=>{d.current&&(n=!0,i(e))},onEnd:()=>{d.current&&u("transcribing")},shouldDiscard:()=>g.current}),d.current&&!n&&r({message:t.dictationNotHeard,openSettings:!1,tone:"info"})}catch(e){if(!d.current)return;e instanceof _phoneSpeech.PhoneSpeechError?r(dictationFailure(e,t)):(_mobileCore.Logger.error("[chat] dictation failed",e),r({message:t.dictationFailed,openSettings:!1,tone:"info"}))}finally{d.current&&(l.current=null,u("idle"))}})()},testID:a})}const dictationFailure=(e,t)=>{switch(e.phoneCode){case"MicBlocked":return{message:t.dictationBlocked,openSettings:!0,tone:"danger"};case"MicDenied":return{message:t.dictationBlocked,openSettings:!1,tone:"danger"};case"MicUnavailable":return{message:t.dictationNoMicrophone,openSettings:!1,tone:"danger"};case"Unavailable":return{message:t.dictationUnavailable,openSettings:!1,tone:"info"};default:return{message:t.dictationFailed,openSettings:!1,tone:"info"}}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatEmbed=ChatEmbed;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_ChatFrame=require("./ChatFrame.js"),_jsxRuntime=require("react/jsx-runtime");function ChatEmbed({chat:e,labels:t,renderers:r,layoutParts:a,loader:o="Steps",motion:i="On",pickAttachments:s,onOpenAttachment:n,onOpenTarget:l,onNavigate:d,openTicket:h,handoffHosts:c,keyboardOffset:m,title:u,headerActions:b,height:f=520,testID:_="chat-embed"}){const p=(0,_mobileUi.useTheme)();return null===e.profile||e.features.VisitorChat?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:f,overflow:"hidden",borderRadius:(0,_mobileUi.radiusOf)(p,"lg"),borderWidth:1,borderColor:p.colors["border-subtle"],backgroundColor:p.colors.bg},testID:_,children:(0,_jsxRuntime.jsx)(_ChatFrame.ChatFrame,{chat:e,labels:(0,_chatCore.mergeLabels)(t),renderers:r,layoutParts:a,loader:o,motion:i,pickAttachments:s,onOpenAttachment:n,onOpenTarget:l,onNavigate:d,openTicket:h,handoffHosts:c,keyboardOffset:m,layout:"embedded",title:u,headerActions:b,testID:`${_}-frame`})}):null}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatEmbed=ChatEmbed;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_ChatFrame=require("./ChatFrame.js"),_jsxRuntime=require("react/jsx-runtime");function ChatEmbed({chat:e,labels:t,renderers:r,layoutParts:o,loader:a="Steps",motion:i="On",pickAttachments:s,onOpenAttachment:n,onOpenTarget:l,onNavigate:d,openTicket:h,handoffHosts:c,resolveLink:m,keyboardOffset:u,title:b,headerActions:f,onClose:C,height:_=520,testID:p="chat-embed"}){const g=(0,_mobileUi.useTheme)();return null===e.profile||e.features.VisitorChat?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:_,overflow:"hidden",borderRadius:(0,_mobileUi.radiusOf)(g,"lg"),borderWidth:1,borderColor:g.colors["border-subtle"],backgroundColor:g.colors.bg},testID:p,children:(0,_jsxRuntime.jsx)(_ChatFrame.ChatFrame,{chat:e,labels:(0,_chatCore.mergeLabels)(t),renderers:r,layoutParts:o,loader:a,motion:i,pickAttachments:s,onOpenAttachment:n,onOpenTarget:l,onNavigate:d,openTicket:h,handoffHosts:c,resolveLink:m,keyboardOffset:u,layout:"embedded",title:b,headerActions:f,onClose:C,testID:`${p}-frame`})}):null}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatFooter=ChatFooter;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const GOOGLE_PRIVACY="https://policies.google.com/privacy",GOOGLE_TERMS="https://policies.google.com/terms",openLink=e=>{_reactNative.Linking.openURL(e).catch(()=>{})};function ChatFooter({chat:e,labels:i}){const t=(0,_mobileUi.useTheme)(),o=e.profile;if(!o)return null;const r=o.footer.disclaimer??i.disclaimer,n=o.footer.privacyUrl,a=o.footer.assuranceText,c=(0,_chatCore.showsCaptchaNote)(o);return Boolean(r)||Boolean(n)||Boolean(a)||c?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:t.space.xxs,alignItems:"center"},children:[r?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:r}):null,n?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(n),children:i.footerPrivacy}):null,a?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:a}):null,c?(0,_jsxRuntime.jsxs)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:[i.captchaNote," ",(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(GOOGLE_PRIVACY),children:i.captchaPrivacy})," ",(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(GOOGLE_TERMS),children:i.captchaTerms})]}):null]}):null}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatFooter=ChatFooter;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const GOOGLE_PRIVACY="https://policies.google.com/privacy",GOOGLE_TERMS="https://policies.google.com/terms",openLink=e=>{_reactNative.Linking.openURL(e).catch(()=>{})};function ChatFooter({chat:e,labels:i}){const t=(0,_mobileUi.useTheme)(),o=e.profile;if(!o)return null;const r=o.footer.disclaimer||i.disclaimer,n=o.footer.privacyUrl,a=o.footer.assuranceText,l=o.footer.privacyText,c=(0,_chatCore.showsCaptchaNote)(o);return Boolean(r)||Boolean(l)||Boolean(n)||Boolean(a)||c?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:t.space.xxs,alignItems:"center"},children:[r?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:r}):null,l?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:l}):null,n?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(n),children:i.footerPrivacy}):null,a?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:a}):null,c?(0,_jsxRuntime.jsxs)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:[i.captchaNote," ",(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(GOOGLE_PRIVACY),children:i.captchaPrivacy})," ",(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(GOOGLE_TERMS),children:i.captchaTerms})]}):null]}):null}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatFrame=ChatFrame;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ChatComposer=require("./ChatComposer.js"),_ChatConversationActions=require("./ChatConversationActions.js"),_ChatHistory=require("./ChatHistory.js"),_ChatLiveBar=require("./ChatLiveBar.js"),_ChatStarters=require("./ChatStarters.js"),_ChatThread=require("./ChatThread.js"),_useChatHaptics=require("./useChatHaptics.js"),_jsxRuntime=require("react/jsx-runtime");function ChatFrame({chat:e,labels:t,renderers:s,layoutParts:a,loader:r="Steps",motion:i="On",pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:c,openTicket:u,handoffHosts:m,keyboardOffset:h,layout:d,title:_,headerActions:x,testID:j="chat-frame"}){const C=(0,_mobileUi.useTheme)(),[p,b]=(0,_react.useState)(!1);(0,_useChatHaptics.useChatHaptics)(e);const f="sheet"!==d,y=null!==e.profile;if(y&&!e.features.VisitorChat)return null;const v=e.messages.length>0,R=!0===e.profile?.experience.sound.muteControl&&e.features.Sounds,g=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:C.space.sm,paddingHorizontal:C.space.md,paddingVertical:C.space.sm,borderBottomWidth:1,borderBottomColor:C.colors["border-subtle"]},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1,minWidth:0},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"title",accessibilityRole:"header",numberOfLines:1,children:_??e.profile?.assistant.name??t.panelTitle}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:t.headerStatus})]}),x,p?null:(0,_jsxRuntime.jsx)(_ChatConversationActions.ChatConversationActions,{chat:e,labels:t,testID:`${j}-conversation-actions`}),R?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:e.muted?t.unmuteSounds:t.muteSounds,variant:"link",size:"sm",accessibilityState:{checked:e.muted},onPress:()=>e.session.setMuted(!e.muted),testID:`${j}-mute`}):null,e.features.History?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:p?t.backToChat:t.history,variant:"link",size:"sm",onPress:()=>b(e=>!e),testID:`${j}-history`}):null,p?null:(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:t.newChat,size:"sm",variant:"soft",leftIcon:"add",disabled:!v&&!e.loading,onPress:()=>e.newConversation(),testID:`${j}-new`})]});let I;return I=p?(0,_jsxRuntime.jsx)(_ChatHistory.ChatHistory,{chat:e,labels:t,onOpen:()=>b(!1),testID:`${j}-history-list`}):e.profileError?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"danger",message:e.profileError.message,accessibilityRole:"alert",testID:`${j}-profile-error`}):!y||e.loading?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,alignItems:"center",justifyContent:"center"},children:(0,_jsxRuntime.jsx)(_mobileUi.Spinner,{message:t.loadingConversation,testID:`${j}-loading`})}):e.loadError?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"danger",message:e.loadError.message,accessibilityRole:"alert",testID:`${j}-load-error`}):v?(0,_jsxRuntime.jsx)(_ChatThread.ChatThread,{chat:e,labels:t,renderers:s,layoutParts:a,loader:r,motion:i,pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:c,openTicket:u,handoffHosts:m,keyboardAware:f,keyboardOffset:h,style:{flex:1},testID:`${j}-thread`}):(0,_jsxRuntime.jsx)(_ChatStarters.ChatStarters,{chat:e,labels:t,openTicket:u,testID:`${j}-starters`}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1},testID:j,children:[g,p?null:(0,_jsxRuntime.jsx)(_ChatLiveBar.ChatLiveBar,{chat:e,labels:t,testID:`${j}-live`}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1},children:I}),p?null:(0,_jsxRuntime.jsx)(_ChatComposer.ChatComposer,{chat:e,labels:t,pickAttachments:n,keyboardOffset:h,keyboardAware:f,testID:`${j}-composer`})]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatFrame=ChatFrame;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ChatComposer=require("./ChatComposer.js"),_ChatConversationActions=require("./ChatConversationActions.js"),_ChatHistory=require("./ChatHistory.js"),_ChatLiveBar=require("./ChatLiveBar.js"),_ChatStarters=require("./ChatStarters.js"),_ChatThread=require("./ChatThread.js"),_useChatHaptics=require("./useChatHaptics.js"),_useChatSound=require("./useChatSound.js"),_jsxRuntime=require("react/jsx-runtime");function ChatFrame({chat:e,labels:t,renderers:s,layoutParts:a,loader:r="Steps",motion:i="On",pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:u,openTicket:c,handoffHosts:m,resolveLink:h,keyboardOffset:d,layout:_,title:x,headerActions:C,onClose:j,testID:b="chat-frame"}){const p=(0,_mobileUi.useTheme)(),[f,v]=(0,_react.useState)(!1),y=f&&!0===e.features.History;(0,_useChatHaptics.useChatHaptics)(e),(0,_useChatSound.useChatSound)(e);const R="sheet"!==_,g=null!==e.profile,k=(0,_react.useRef)(null);if(g&&!e.features.VisitorChat)return null;const I=e.messages.length>0,D=e.messages.some(e=>"Visitor"===e.author.kind||"Customer"===e.author.kind),S="screen"===_||D,T=!0===e.profile?.experience.sound.muteControl&&e.features.Sounds,H=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:p.space.sm,paddingHorizontal:p.space.md,paddingVertical:p.space.sm,borderBottomWidth:1,borderBottomColor:p.colors["border-subtle"]},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1,minWidth:0},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"title",accessibilityRole:"header",numberOfLines:1,children:x??e.profile?.assistant.name??t.panelTitle}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:t.headerStatus})]}),C,y?null:(0,_jsxRuntime.jsx)(_ChatConversationActions.ChatConversationActions,{chat:e,labels:t,testID:`${b}-conversation-actions`}),T?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:e.muted?t.unmuteSounds:t.muteSounds,variant:"link",size:"sm",onPress:()=>e.session.setMuted(!e.muted),testID:`${b}-mute`}):null,e.features.History?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:y?t.backToChat:t.history,variant:"link",size:"sm",onPress:()=>v(e=>!e),testID:`${b}-history`}):null,y||!S?null:(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:t.newChat,size:"sm",variant:"soft",leftIcon:"add",disabled:e.streaming||e.thinking,onPress:()=>e.newConversation(),testID:`${b}-new`}),j?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"x",variant:"ghost",tone:"neutral",accessibilityLabel:t.close,onPress:j,testID:`${b}-close`}):null]});let $;return $=y?(0,_jsxRuntime.jsx)(_ChatHistory.ChatHistory,{chat:e,labels:t,onOpen:()=>v(!1),testID:`${b}-history-list`}):e.profileError?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"danger",message:e.profileError.message,accessibilityRole:"alert",testID:`${b}-profile-error`}):!g||e.loading?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,alignItems:"center",justifyContent:"center"},children:(0,_jsxRuntime.jsx)(_mobileUi.Spinner,{message:t.loadingConversation,testID:`${b}-loading`})}):e.loadError?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"danger",message:e.loadError.message,accessibilityRole:"alert",testID:`${b}-load-error`}):I?(0,_jsxRuntime.jsx)(_ChatThread.ChatThread,{chat:e,labels:t,renderers:s,layoutParts:a,loader:r,motion:i,pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:u,openTicket:c,handoffHosts:m,resolveLink:h,focusComposer:()=>k.current?.(),keyboardAware:R,keyboardOffset:d,style:{flex:1},testID:`${b}-thread`}):(0,_jsxRuntime.jsx)(_ChatStarters.ChatStarters,{chat:e,labels:t,openTicket:c,testID:`${b}-starters`}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1},testID:b,children:[H,y?null:(0,_jsxRuntime.jsx)(_ChatLiveBar.ChatLiveBar,{chat:e,labels:t,testID:`${b}-live`}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1},children:$}),y?null:(0,_jsxRuntime.jsx)(_ChatComposer.ChatComposer,{chat:e,labels:t,pickAttachments:n,keyboardOffset:d,keyboardAware:R,focusRef:k,testID:`${b}-composer`})]})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatHistory=ChatHistory;var _chatCore=require("@webority/chat-core"),_mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const TITLE_MAX_LENGTH=120,EMPTY_LIST_STATE=Object.freeze({items:[],totalCount:null,loading:!1,error:null,hasMore:!1}),NO_SUBSCRIPTION=()=>()=>{};function ChatHistory({chat:e,labels:t,onOpen:i,testID:n="chat-history"}){const l=(0,_mobileUi.useTheme)(),[s,a]=(0,_react.useState)(null),r=null!==s&&s.client===e.client?s.list:null,o=(0,_react.useCallback)(e=>r?r.subscribe(e):NO_SUBSCRIPTION(),[r]),c=(0,_react.useCallback)(()=>r?r.getState():EMPTY_LIST_STATE,[r]),u=(0,_react.useSyncExternalStore)(o,c),[m,_]=(0,_react.useState)(null),[d,b]=(0,_react.useState)(""),[x,j]=(0,_react.useState)(""),[h,p]=(0,_react.useState)(null),[y,g]=(0,_react.useState)(""),[I,T]=(0,_react.useState)(!1);(0,_react.useEffect)(()=>{const t=(0,_chatCore.createConversationList)({client:e.client});return a({client:e.client,list:t}),t.load(),()=>t.dispose()},[e.client]);const saveRename=async()=>{if(!m||!r)return;const e=d.trim();if(""!==e){T(!0),j("");try{await r.rename(m.publicId,e),_(null)}catch{j(t.renameFailed)}finally{T(!1)}}},S=!u.loading&&null===u.error&&0===u.items.length;return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{contentContainerStyle:{padding:l.space.md,gap:l.space.sm,flexGrow:1},accessibilityLabel:t.history,testID:n,children:[u.error?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"danger",message:u.error.message||t.loadFailed,actions:[{label:t.retry,onPress:()=>{r?.load()}}],testID:`${n}-error`}):null,S?(0,_jsxRuntime.jsx)(_mobileUi.EmptyState,{size:"sm",title:t.historyEmptyTitle,description:t.historyEmptyText,testID:`${n}-empty`}):null,u.items.map(s=>{const a=s.title||t.untitled;return(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",padding:"sm",onPress:()=>(t=>{e.openConversation(t.publicId),i()})(s),accessibilityLabel:a,testID:`${n}-item-${s.publicId}`,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:l.space.sm},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1,minWidth:0},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",numberOfLines:1,children:a}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:(0,_mobileCore.formatDate)(s.lastActivityDateTimeUtc)})]}),e.features.Rename?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"edit",variant:"ghost",accessibilityLabel:t.rename,onPress:()=>{j(""),b(s.title??""),_(s)},testID:`${n}-rename-${s.publicId}`}):null,e.features.Delete?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"trash",tone:"danger",variant:"ghost",accessibilityLabel:t.deleteChat,onPress:()=>{g(""),p(s)},testID:`${n}-delete-${s.publicId}`}):null]})},s.publicId)}),u.loading&&0===u.items.length?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:l.space.sm},accessibilityElementsHidden:!0,children:[(0,_jsxRuntime.jsx)(_mobileUi.Skeleton,{height:56}),(0,_jsxRuntime.jsx)(_mobileUi.Skeleton,{height:56}),(0,_jsxRuntime.jsx)(_mobileUi.Skeleton,{height:56})]}):null,!u.loading&&u.hasMore?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:t.loadMore,variant:"outline",onPress:()=>{r?.loadMore()},testID:`${n}-more`}):null,(0,_jsxRuntime.jsxs)(_mobileUi.Dialog,{open:null!==m,onClose:()=>{I||_(null)},title:t.rename,dismissOnAction:!1,actions:[{label:t.cancel,tone:"neutral",disabled:I,onPress:()=>_(null)},{label:t.renameSave,disabled:""===d.trim()||I,loading:I,onPress:()=>{saveRename()}}],testID:`${n}-rename`,children:[(0,_jsxRuntime.jsx)(_mobileUi.Input,{label:t.conversationTitle,value:d,onChangeText:b,maxLength:TITLE_MAX_LENGTH,returnKeyType:"done",onSubmitEditing:()=>{saveRename()},testID:`${n}-rename-input`}),""!==x?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",testID:`${n}-rename-error`,children:x}):null]}),(0,_jsxRuntime.jsx)(_mobileUi.Dialog,{open:null!==h,onClose:()=>{I||p(null)},tone:"warning",title:t.deleteConfirmTitle,message:y||t.deleteConfirmMessage,dismissOnAction:!1,actions:[{label:t.cancel,tone:"neutral",disabled:I,onPress:()=>p(null)},{label:t.deleteConfirm,tone:"danger",loading:I,onPress:()=>{(async()=>{if(h&&r){T(!0),g("");try{await r.remove(h.publicId),h.publicId===e.conversationId&&e.newConversation(),p(null)}catch{g(t.deleteFailed)}finally{T(!1)}}})()}}],testID:`${n}-confirm`})]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatHistory=ChatHistory;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ChatPastChats=require("./ChatPastChats.js"),_jsxRuntime=require("react/jsx-runtime");const EMPTY_LIST_STATE=Object.freeze({items:[],totalCount:null,loading:!1,error:null,hasMore:!1}),NO_SUBSCRIPTION=()=>()=>{};function ChatHistory({chat:e,labels:t,onOpen:i,testID:s="chat-history"}){const l=(0,_mobileUi.useTheme)(),[r,n]=(0,_react.useState)(null),a=null!==r&&r.client===e.client?r.list:null,o=(0,_react.useCallback)(e=>a?a.subscribe(e):NO_SUBSCRIPTION(),[a]),c=(0,_react.useCallback)(()=>a?a.getState():EMPTY_LIST_STATE,[a]),u=(0,_react.useSyncExternalStore)(o,c);(0,_react.useEffect)(()=>{const t=(0,_chatCore.createConversationList)({client:e.client});return n({client:e.client,list:t}),t.load(),()=>t.dispose()},[e.client]);const open=t=>{e.openConversation(t.publicId),i()},_=!u.loading&&null===u.error&&0===u.items.length;return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{contentContainerStyle:{padding:l.space.md,gap:l.space.sm,flexGrow:1},accessibilityLabel:t.history,testID:s,children:[u.error?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"danger",message:t.loadFailed,actions:[{label:t.retry,onPress:()=>{a?.load()}}],testID:`${s}-error`}):null,_?(0,_jsxRuntime.jsx)(_mobileUi.EmptyState,{size:"sm",title:t.historyEmptyTitle,description:t.historyEmptyText,testID:`${s}-empty`}):null,u.items.map(i=>(0,_jsxRuntime.jsx)(_ChatPastChats.ConversationRow,{conversation:i,list:a,chat:e,labels:t,testID:s,onOpen:open,untitledTitle:t.untitled},i.publicId)),u.loading&&0===u.items.length?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:l.space.sm},accessibilityElementsHidden:!0,children:[(0,_jsxRuntime.jsx)(_mobileUi.Skeleton,{height:56}),(0,_jsxRuntime.jsx)(_mobileUi.Skeleton,{height:56}),(0,_jsxRuntime.jsx)(_mobileUi.Skeleton,{height:56})]}):null,!u.loading&&u.hasMore?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:t.loadMore,variant:"outline",onPress:()=>{a?.loadMore()},testID:`${s}-more`}):null]})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatLiveBar=ChatLiveBar;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const newestAgentName=(e,t)=>{for(let i=e.messages.length-1;i>=0;i-=1){const n=e.messages[i];if("Agent"===n?.author.kind)return n.author.displayName||t}return t};function ChatLiveBar({chat:e,labels:t,testID:i="chat-live-bar"}){const n=(0,_mobileUi.useTheme)();if(!e.features.HumanHandoff||null===e.conversationId)return null;const s=e.conversationState;if("Closed"===s)return null;if("Open"===s)return(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityLiveRegion:"polite",style:{paddingHorizontal:n.space.md,paddingVertical:n.space.xs},testID:i,children:(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:t.talkToPerson,variant:"soft",size:"sm",leftIcon:"user",loading:e.handoffPending,disabled:e.streaming||e.thinking,onPress:()=>{e.requestHandoff()},testID:`${i}-talk`})});const a="Lost"===e.live,r="WaitingForAgent"===s?t.handoffWaiting:t.handoffJoined(newestAgentName(e,t.agent));return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityLiveRegion:"polite",style:{gap:n.space.xs,paddingHorizontal:n.space.md,paddingVertical:n.space.xs},testID:i,children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:r}),a?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"warning",message:t.liveLost,actions:[{label:t.retry,onPress:()=>e.resumeLive()}],testID:`${i}-lost`}):null]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatLiveBar=ChatLiveBar;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const newestAgentName=(e,t)=>{for(let i=e.messages.length-1;i>=0;i-=1){const n=e.messages[i];if("Agent"===n?.author.kind)return n.author.displayName||t}return t};function ChatLiveBar({chat:e,labels:t,testID:i="chat-live-bar"}){const n=(0,_mobileUi.useTheme)();if(!e.features.HumanHandoff||null===e.conversationId)return null;const s=e.conversationState;if("Closed"===s)return null;if("Open"===s){return e.features.HumanHandoff&&e.messages.some(e=>"Visitor"===e.author.kind||"Customer"===e.author.kind)&&!e.streaming&&!e.thinking?(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityLiveRegion:"polite",style:{paddingHorizontal:n.space.md,paddingVertical:n.space.xs},testID:i,children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:t.talkToPerson,variant:"soft",size:"sm",leftIcon:"user",loading:e.handoffPending,onPress:()=>{e.requestHandoff()},testID:`${i}-talk`}),null!==e.handoffError?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:t.errorGeneric}):null]}):null}const a="Lost"===e.live,r="WaitingForAgent"===s?t.statusWaitingForAgent:t.statusWithAgent(newestAgentName(e,t.agent));return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityLiveRegion:"polite",style:{gap:n.space.xs,paddingHorizontal:n.space.md,paddingVertical:n.space.xs},testID:i,children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:r}),a?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"warning",message:t.liveLost,actions:[{label:t.retry,onPress:()=>e.resumeLive()}],testID:`${i}-lost`}):null]})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatMessageActions=ChatMessageActions;var _chatCore=require("@webority/chat-core"),_clipboard=require("@webority/mobile-core/clipboard"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ReadAloudButton=require("./ReadAloudButton.js"),_useTranscriptActions=_interopRequireDefault(require("./useTranscriptActions.js")),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const TEXT_AUTHORS=new Set(["Assistant","Agent","Script"]),RATED_AUTHORS=new Set(["Assistant","Agent"]);function ChatMessageActions({chat:e,message:t,labels:i,isLast:s,isLastVisitor:a,testID:r}){const n=(0,_mobileUi.useTheme)(),[l,o]=(0,_react.useState)(!1),[u,c]=(0,_react.useState)("idle"),d=(0,_react.useRef)(null),_=(0,_useTranscriptActions.default)(e,i),m=(0,_react.useMemo)(()=>TEXT_AUTHORS.has(t.author.kind)&&(0,_chatCore.buildTranscript)([t],{labels:i,title:null,figureText:!1}).entries.length>0,[t,i]);if((0,_react.useEffect)(()=>()=>{null!==d.current&&clearTimeout(d.current)},[]),t.streaming)return null;const x=t.parts.filter(e=>"Text"===e.kind).map(e=>e.text).join("\n\n"),h=TEXT_AUTHORS.has(t.author.kind)&&""!==x,g=t.stored&&RATED_AUTHORS.has(t.author.kind),p=("Assistant"===t.author.kind||"Agent"===t.author.kind)&&""!==(0,_chatCore.messagePlainText)(t.parts).trim(),b=s&&"Assistant"===t.author.kind&&!e.streaming&&!e.thinking&&e.features.Regenerate&&e.messages.some(e=>e.stored&&"Visitor"===e.author.kind),R=a&&t.stored&&e.features.Edit,save=async i=>{c("idle");try{await e.rate(t.id,i),c("saved")}catch{c("failed")}};return h&&e.features.Copy||m&&e.features.Share&&_.canShare||p||b||R||g&&e.features.Rating?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:n.space.xs},testID:r,children:[h&&e.features.Copy?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:l?i.copied:i.copy,variant:"link",size:"sm",onPress:()=>{(async()=>{await(0,_clipboard.copyText)(x)&&(o(!0),null!==d.current&&clearTimeout(d.current),d.current=setTimeout(()=>o(!1),2e3))})()},testID:`${r}-copy`}):null,m&&e.features.Share&&_.canShare?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.share,variant:"link",size:"sm",leftIcon:"share",disabled:e.streaming||e.thinking,onPress:()=>{_.shareReply(t)},testID:`${r}-share`}):null,p?(0,_jsxRuntime.jsx)(_ReadAloudButton.ReadAloudButton,{chat:e,message:t,labels:i}):null,b?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.regenerate,variant:"link",size:"sm",onPress:()=>{e.regenerate()},testID:`${r}-regenerate`}):null,R?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.edit,variant:"link",size:"sm",onPress:()=>e.startEdit(t.id),testID:`${r}-edit`}):null,g&&e.features.Rating?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.rateUp,size:"sm",leftIcon:"like",variant:"Up"===t.rating?"soft":"ghost",accessibilityState:{selected:"Up"===t.rating},onPress:()=>{save("Up")},testID:`${r}-rate-up`}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.rateDown,size:"sm",leftIcon:"dislike",variant:"Down"===t.rating?"soft":"ghost",accessibilityState:{selected:"Down"===t.rating},onPress:()=>{save("Down")},testID:`${r}-rate-down`}),"failed"===u?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:i.ratingFailed}):null,"saved"===u?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:i.rated}):null]}):null,null!==_.notice?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:_.notice}):null]}):null}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatMessageActions=ChatMessageActions;var _chatCore=require("@webority/chat-core"),_clipboard=require("@webority/mobile-core/clipboard"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ReadAloudButton=require("./ReadAloudButton.js"),_useTranscriptActions=_interopRequireDefault(require("./useTranscriptActions.js")),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const TEXT_AUTHORS=new Set(["Assistant","Agent","Script"]),RATED_AUTHORS=new Set(["Assistant","Agent"]);function ChatMessageActions({chat:e,message:t,labels:i,isLast:s,isLastVisitor:a,testID:r}){const n=(0,_mobileUi.useTheme)(),[l,o]=(0,_react.useState)(!1),[c,u]=(0,_react.useState)("idle"),d=(0,_react.useRef)(null),m=(0,_useTranscriptActions.default)(e,i),_=(0,_react.useMemo)(()=>TEXT_AUTHORS.has(t.author.kind)&&(0,_chatCore.buildTranscript)([t],{labels:i,title:null,figureText:!1}).entries.length>0,[t,i]);if((0,_react.useEffect)(()=>()=>{null!==d.current&&clearTimeout(d.current)},[]),t.streaming)return null;const h=(0,_chatCore.messagePlainText)(t.parts),g=TEXT_AUTHORS.has(t.author.kind)&&""!==h,x=t.stored&&RATED_AUTHORS.has(t.author.kind),b=("Assistant"===t.author.kind||"Agent"===t.author.kind||"Script"===t.author.kind)&&""!==(0,_chatCore.messagePlainText)(t.parts).trim(),p=s&&"Assistant"===t.author.kind&&!e.streaming&&!e.thinking&&e.features.Regenerate&&e.messages.some(e=>e.stored&&"Visitor"===e.author.kind),R=a&&t.stored&&e.features.Edit&&!e.streaming&&!e.thinking,save=async i=>{try{await e.rate(t.id,i),u("saved")}catch{u("failed")}};return g&&e.features.Copy||_&&e.features.Share&&m.canShare||b||p||R||x&&e.features.Rating?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:n.space.xs},testID:r,children:[g&&e.features.Copy?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:l?i.copied:i.copy,variant:"link",size:"sm",onPress:()=>{(async()=>{await(0,_clipboard.copyText)(h)&&(o(!0),null!==d.current&&clearTimeout(d.current),d.current=setTimeout(()=>o(!1),2e3))})()},testID:`${r}-copy`}):null,_&&e.features.Share&&m.canShare?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.share,variant:"link",size:"sm",leftIcon:"share",disabled:e.streaming||e.thinking,onPress:()=>{m.shareReply(t)},testID:`${r}-share`}):null,b?(0,_jsxRuntime.jsx)(_ReadAloudButton.ReadAloudButton,{chat:e,message:t,labels:i}):null,p?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.regenerate,variant:"link",size:"sm",onPress:()=>{e.regenerate()},testID:`${r}-regenerate`}):null,R?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.edit,variant:"link",size:"sm",onPress:()=>e.startEdit(t.id),testID:`${r}-edit`}):null,x&&e.features.Rating?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityRole:"summary",accessibilityLabel:i.rating,style:{flexDirection:"row",alignItems:"center",gap:n.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"like",accessibilityLabel:i.rateUp,tone:"neutral",size:"sm",variant:"Up"===t.rating?"soft":"ghost",accessibilityState:{checked:"Up"===t.rating},onPress:()=>{save("Up")},testID:`${r}-rate-up`}),(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"dislike",accessibilityLabel:i.rateDown,tone:"neutral",size:"sm",variant:"Down"===t.rating?"soft":"ghost",accessibilityState:{checked:"Down"===t.rating},onPress:()=>{save("Down")},testID:`${r}-rate-down`})]}),"failed"===c?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:i.ratingFailed}):null,"saved"===c?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:i.rated}):null]}):null,null!==m.notice?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:m.notice}):null]}):null}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatNudge=ChatNudge;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const LAUNCHER_CLEARANCE=72,EDGE_INSET=16;function ChatNudge({chat:e,labels:t,enabled:r,onActivate:i,bottomOffset:o,position:s,testID:a="chat-nudge"}){const n=e.profile,u=e.features,c=n?(0,_chatCore.resolveNudge)(n,u):null,[l,_]=(0,_react.useState)(!1),[E,b]=(0,_react.useState)(!1);if((0,_react.useEffect)(()=>{if(!r||!c||l)return void b(!1);const e=setTimeout(()=>b(!0),1e3*c.delaySeconds);return()=>clearTimeout(e)},[r,c,l]),!c||!E||l)return null;const d="start"===s?{left:EDGE_INSET}:{right:EDGE_INSET};return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:"absolute",bottom:o+LAUNCHER_CLEARANCE,...d,maxWidth:320},pointerEvents:"box-none",children:(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"info",message:c.text,dismissible:!0,onClose:()=>_(!0),actions:[{label:t.launcher,onPress:i}],testID:a})})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatNudge=ChatNudge;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const LAUNCHER_CLEARANCE=72,EDGE_INSET=16;function ChatNudge({chat:e,labels:t,enabled:r,onActivate:i,bottomOffset:s,position:o,testID:a="chat-nudge"}){const n=e.profile,u=e.features,c=n?(0,_chatCore.resolveNudge)(n,u):null,[l,_]=(0,_react.useState)(!1),[E,d]=(0,_react.useState)(!1),[m,b]=(0,_react.useState)(!1);if((0,_react.useEffect)(()=>{if(!r||!c||l)return void d(!1);if(m)return;const e=setTimeout(()=>{d(!0),b(!0)},1e3*c.delaySeconds);return()=>clearTimeout(e)},[r,c,l,m]),!c||!E||l)return null;const f="start"===o?{left:EDGE_INSET}:{right:EDGE_INSET};return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:"absolute",bottom:s+LAUNCHER_CLEARANCE,...f,maxWidth:320},pointerEvents:"box-none",children:(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"info",message:c.text,dismissible:!0,onClose:()=>_(!0),labels:{dismiss:t.nudgeDismiss},actions:[{label:t.launcher,onPress:i}],testID:a})})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatOpenTickets=ChatOpenTickets;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const SHOWN_AT_MOST=3;function ChatOpenTickets({chat:e,labels:t,onOpenTicket:i,testID:s="chat-open-tickets"}){const n=(0,_mobileUi.useTheme)();return e.features.OpenTickets&&0!==e.openTickets.length?(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityRole:"list",accessibilityLabel:t.openTickets,style:{gap:n.space.xs},testID:s,children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:t.openTickets}),e.openTickets.slice(0,SHOWN_AT_MOST).map(e=>{const n=i?()=>i({ticketId:e.ticketId,number:e.number}):void 0;return(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",padding:"sm",interactive:void 0!==n,onPress:n,testID:`${s}-${e.ticketId}`,children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:t.ticketAria(e.number)}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",numberOfLines:1,children:e.subject}),(0,_jsxRuntime.jsx)(_mobileUi.Chip,{size:"sm",variant:"soft",label:e.status})]},e.ticketId)})]}):null}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatOpenTickets=ChatOpenTickets;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const SHOWN_AT_MOST=3;function ChatOpenTickets({chat:e,labels:t,onOpenTicket:i,testID:s="chat-open-tickets"}){const n=(0,_mobileUi.useTheme)();return e.features.OpenTickets&&0!==e.openTickets.length?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityLabel:t.openTickets,style:{gap:n.space.xs},testID:s,children:e.openTickets.slice(0,SHOWN_AT_MOST).map(e=>{const n=i?()=>i({ticketId:e.ticketId,number:e.number}):void 0;return(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",padding:"sm",interactive:void 0!==n,onPress:n,testID:`${s}-${e.ticketId}`,children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:t.ticketAria(e.number)}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",numberOfLines:1,children:e.subject}),(0,_jsxRuntime.jsx)(_mobileUi.Chip,{size:"sm",variant:"soft",label:t.ticketStatus(e.status)||e.status})]},e.ticketId)})}):null}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatPastChats=ChatPastChats,exports.ConversationRow=ConversationRow;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const PAGE_SIZE=20,EMPTY_LIST_STATE=Object.freeze({items:[],totalCount:null,loading:!1,error:null,hasMore:!1}),NO_SUBSCRIPTION=()=>()=>{};function ChatPastChats({chat:e,labels:t,testID:i="chat-past-chats"}){const n=(0,_mobileUi.useTheme)(),s=!0===e.features.History,[a,l]=(0,_react.useState)(null),r=s&&null!==a&&a.client===e.client?a.list:null,o=(0,_react.useCallback)(e=>r?r.subscribe(e):NO_SUBSCRIPTION(),[r]),c=(0,_react.useCallback)(()=>r?r.getState():EMPTY_LIST_STATE,[r]),u=(0,_react.useSyncExternalStore)(o,c);if((0,_react.useEffect)(()=>{if(!s)return;const t=(0,_chatCore.createConversationList)({client:e.client});return l({client:e.client,list:t}),t.load(),()=>t.dispose()},[e.client,s]),!s||0===u.items.length)return null;const open=t=>{e.openConversation(t.publicId)};return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{gap:n.space.sm},testID:i,children:u.items.slice(0,PAGE_SIZE).map(n=>(0,_jsxRuntime.jsx)(ConversationRow,{conversation:n,list:r,chat:e,labels:t,testID:i,onOpen:open},n.publicId))})}function ConversationRow({conversation:e,list:t,chat:i,labels:n,testID:s,onOpen:a,untitledTitle:l}){const r=(0,_mobileUi.useTheme)(),[o,c]=(0,_react.useState)("idle"),[u,m]=(0,_react.useState)(""),[_,d]=(0,_react.useState)(""),[x,b]=(0,_react.useState)(!1),j=e.publicId,h=e.title||l||n.earlierChat,v=(0,_chatCore.formatChatDate)(e.lastActivityDateTimeUtc),cancel=()=>{d(""),c("idle")},saveRename=async()=>{const e=u.trim();if(!x&&t&&""!==e){b(!0),d("");try{await t.rename(j,e),c("idle")}catch{d(n.renameFailed)}finally{b(!1)}}};return(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",padding:"sm",onPress:"idle"===o?()=>a(e):void 0,accessibilityLabel:`${h}, ${v}`,testID:`${s}-item-${j}`,children:["idle"===o?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:r.space.sm},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1,minWidth:0},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",numberOfLines:1,children:h}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:v})]}),i.features.Rename?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"edit",variant:"ghost",accessibilityLabel:n.rename,onPress:()=>{d(""),m(e.title??""),c("renaming")},testID:`${s}-rename-${j}`}):null,i.features.Delete?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"trash",tone:"danger",variant:"ghost",accessibilityLabel:n.deleteChat,onPress:()=>{d(""),c("deleting")},testID:`${s}-delete-${j}`}):null]}):null,"renaming"===o?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Input,{label:n.conversationTitle,value:u,onChangeText:m,maxLength:120,returnKeyType:"done",onSubmitEditing:()=>{saveRename()},testID:`${s}-rename-input-${j}`}),""!==_?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",testID:`${s}-rename-error-${j}`,children:_}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",justifyContent:"flex-end",gap:r.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:n.cancel,variant:"ghost",disabled:x,onPress:cancel,testID:`${s}-rename-cancel-${j}`}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:n.renameSave,disabled:""===u.trim()||x,loading:x,onPress:()=>{saveRename()},testID:`${s}-rename-save-${j}`})]})]}):null,"deleting"===o?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:""!==_?"danger":"secondary",accessibilityLiveRegion:""!==_?"polite":void 0,testID:`${s}-delete-message-${j}`,children:""!==_?_:n.deleteConfirmMessage}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",justifyContent:"flex-end",gap:r.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:n.cancel,variant:"ghost",disabled:x,onPress:cancel,testID:`${s}-delete-cancel-${j}`}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:n.deleteConfirm,tone:"danger",loading:x,onPress:()=>{(async()=>{if(!x&&t){b(!0),d("");try{await t.remove(j),j===i.conversationId&&i.newConversation(),c("idle")}catch{d(n.deleteFailed)}finally{b(!1)}}})()},testID:`${s}-delete-confirm-${j}`})]})]}):null]})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatScreen=ChatScreen;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_ChatFrame=require("./ChatFrame.js"),_jsxRuntime=require("react/jsx-runtime");function ChatScreen({chat:e,labels:t,renderers:r,layoutParts:a,loader:o="Steps",motion:n="On",pickAttachments:s,onOpenAttachment:i,onOpenTarget:c,onNavigate:l,openTicket:h,handoffHosts:u,keyboardOffset:m,title:d,headerActions:f,testID:b="chat-screen"}){const p=(0,_mobileUi.useTheme)();return null===e.profile||e.features.VisitorChat?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,backgroundColor:p.colors.bg},testID:b,children:(0,_jsxRuntime.jsx)(_ChatFrame.ChatFrame,{chat:e,labels:(0,_chatCore.mergeLabels)(t),renderers:r,layoutParts:a,loader:o,motion:n,pickAttachments:s,onOpenAttachment:i,onOpenTarget:c,onNavigate:l,openTicket:h,handoffHosts:u,keyboardOffset:m,layout:"screen",title:d,headerActions:f,testID:`${b}-frame`})}):null}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatScreen=ChatScreen;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_ChatFrame=require("./ChatFrame.js"),_jsxRuntime=require("react/jsx-runtime");function ChatScreen({chat:e,labels:t,renderers:r,layoutParts:a,loader:o="Steps",motion:n="On",pickAttachments:s,onOpenAttachment:i,onOpenTarget:c,onNavigate:l,openTicket:h,handoffHosts:u,resolveLink:m,keyboardOffset:d,title:f,headerActions:b,onClose:p,testID:C="chat-screen"}){const _=(0,_mobileUi.useTheme)();return null===e.profile||e.features.VisitorChat?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,backgroundColor:_.colors.bg},testID:C,children:(0,_jsxRuntime.jsx)(_ChatFrame.ChatFrame,{chat:e,labels:(0,_chatCore.mergeLabels)(t),renderers:r,layoutParts:a,loader:o,motion:n,pickAttachments:s,onOpenAttachment:i,onOpenTarget:c,onNavigate:l,openTicket:h,handoffHosts:u,resolveLink:m,keyboardOffset:d,layout:"screen",title:f,headerActions:b,onClose:p,testID:`${C}-frame`})}):null}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatSheet=ChatSheet;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ChatFrame=require("./ChatFrame.js"),_ChatNudge=require("./ChatNudge.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_SNAP_POINTS=["92%"];function ChatSheet({chat:e,labels:t,renderers:s,layoutParts:n,loader:o="Steps",motion:a="On",pickAttachments:r,onOpenAttachment:i,onOpenTarget:c,onNavigate:l,keyboardOffset:u,open:f,defaultOpen:h=!1,onOpenChange:m,position:p="end",bottomOffset:_=16,snapPoints:b=DEFAULT_SNAP_POINTS,compact:d=!1,openTicket:g,handoffHosts:C,conversationId:x,testID:N="chat-sheet"}){const j=(0,_mobileUi.useTheme)(),y=(0,_chatCore.mergeLabels)(t),v=void 0!==f,A=v?f:e.open,O=(0,_react.useRef)(null),P=(0,_react.useRef)(null),R=(0,_react.useRef)(!1),T=(0,_react.useRef)(x??null),I=e.setChatVisible;(0,_react.useEffect)(()=>{R.current||(R.current=!0,v||!h||null===e.profile||e.open||e.session.open({trigger:"manual"}))},[v,h,e.profile,e.open,e.session]),(0,_react.useEffect)(()=>{v&&(f&&!e.open&&e.session.open({trigger:"manual"}),!f&&e.open&&e.session.close("button"))},[v,f,e.open,e.session]);const k=(0,_react.useRef)(A);if((0,_react.useEffect)(()=>{if(k.current&&!A){const e=(0,_reactNative.findNodeHandle)(O.current);null!==e&&_reactNative.AccessibilityInfo.setAccessibilityFocus(e)}k.current=A},[A]),(0,_react.useEffect)(()=>{I(A)},[I,A]),(0,_react.useEffect)(()=>{!v&&x&&x!==T.current&&null!==e.profile&&(T.current=x,e.open||(e.session.open({trigger:"manual"}),m?.(!0)))},[v,x,e.profile,e.open,e.session,m]),(0,_react.useEffect)(()=>{if(null!==P.current){if(A)for(const t of e.messages){if("Assistant"!==t.author.kind||t.streaming||P.current.has(t.id))continue;P.current.add(t.id);const e=(0,_chatCore.messagePlainText)(t.parts);""!==e&&_reactNative.AccessibilityInfo.announceForAccessibility(e)}}else P.current=new Set(e.messages.map(e=>e.id))},[e.messages,A]),null===e.profile||!e.features.VisitorChat)return null;const setOpen=t=>{t?e.session.open({trigger:"manual"}):e.session.close("button"),m?.(t)},S="start"===p?"bottomLeft":"bottomRight";return(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:N,children:[A?null:(0,_jsxRuntime.jsx)(_mobileUi.FloatingActionButton,{ref:O,icon:"messages",label:d?void 0:y.launcher,position:S,bottomOffset:_,accessibilityLabel:y.launcher,onPress:()=>setOpen(!0),testID:`${N}-launcher`}),(0,_jsxRuntime.jsx)(_ChatNudge.ChatNudge,{chat:e,labels:y,enabled:!A&&e.features.Nudges,onActivate:()=>setOpen(!0),bottomOffset:_,position:p,testID:`${N}-nudge`}),(0,_jsxRuntime.jsx)(_mobileUi.BottomSheet,{open:A,onClose:()=>setOpen(!1),snapPoints:b,keyboardBehavior:"shift",scrollable:!1,enablePanDownToClose:!0,enableBackdropPress:!0,accessibilityViewIsModal:!0,accessibilityLabel:y.panelTitle,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,backgroundColor:j.colors.bg},children:(0,_jsxRuntime.jsx)(_ChatFrame.ChatFrame,{chat:e,labels:y,renderers:s,layoutParts:n,loader:o,motion:a,pickAttachments:r,onOpenAttachment:i,onOpenTarget:c,onNavigate:l,openTicket:g,handoffHosts:C,keyboardOffset:u,layout:"sheet",testID:`${N}-frame`})})})]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatSheet=ChatSheet;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ChatFrame=require("./ChatFrame.js"),_ChatNudge=require("./ChatNudge.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_SNAP_POINTS=["92%"];function ChatSheet({chat:e,labels:t,renderers:s,layoutParts:o,loader:n="Steps",motion:r="On",pickAttachments:a,onOpenAttachment:i,onOpenTarget:l,onNavigate:c,keyboardOffset:u,open:f,defaultOpen:h=!1,onOpenChange:p,position:m="end",bottomOffset:_=16,snapPoints:b=DEFAULT_SNAP_POINTS,compact:d=!1,openTicket:g,handoffHosts:C,resolveLink:j,conversationId:v,onClose:x,testID:N="chat-sheet"}){const y=(0,_mobileUi.useTheme)(),O=(0,_chatCore.mergeLabels)(t),A=void 0!==f,P=A?f:e.open,R=(0,_react.useRef)(null),k=(0,_react.useRef)(!1),T=(0,_react.useRef)(v??null),I=e.setChatVisible;(0,_react.useEffect)(()=>{k.current||(k.current=!0,A||!h||null===e.profile||e.open||e.session.open({trigger:"manual"}))},[A,h,e.profile,e.open,e.session]),(0,_react.useEffect)(()=>{A&&(f&&!e.open&&e.session.open({trigger:"manual"}),!f&&e.open&&e.session.close("button"))},[A,f,e.open,e.session]);const S=(0,_react.useRef)(P);if((0,_react.useEffect)(()=>{if(S.current&&!P){const e=(0,_reactNative.findNodeHandle)(R.current);null!==e&&_reactNative.AccessibilityInfo.setAccessibilityFocus(e)}S.current=P},[P]),(0,_react.useEffect)(()=>{I(P)},[I,P]),(0,_react.useEffect)(()=>{!A&&v&&v!==T.current&&null!==e.profile&&(T.current=v,e.open||(e.session.open({trigger:"manual"}),p?.(!0)))},[A,v,e.profile,e.open,e.session,p]),null===e.profile||!e.features.VisitorChat)return null;const setOpen=t=>{t?e.session.open({trigger:"manual"}):e.session.close("button"),p?.(t)},closeSheet=()=>{setOpen(!1),x?.()},D="start"===m?"bottomLeft":"bottomRight";return(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:N,children:[P?null:(0,_jsxRuntime.jsx)(_mobileUi.FloatingActionButton,{ref:R,icon:"messages",label:d?void 0:O.launcher,position:D,bottomOffset:_,accessibilityLabel:O.launcher,onPress:()=>setOpen(!0),testID:`${N}-launcher`}),(0,_jsxRuntime.jsx)(_ChatNudge.ChatNudge,{chat:e,labels:O,enabled:!P&&e.features.Nudges,onActivate:()=>setOpen(!0),bottomOffset:_,position:m,testID:`${N}-nudge`}),(0,_jsxRuntime.jsx)(_mobileUi.BottomSheet,{open:P,onClose:closeSheet,snapPoints:b,keyboardBehavior:"shift",scrollable:!1,enablePanDownToClose:!0,enableBackdropPress:!0,accessibilityViewIsModal:!0,accessibilityLabel:O.panelTitle,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,backgroundColor:y.colors.bg},children:(0,_jsxRuntime.jsx)(_ChatFrame.ChatFrame,{chat:e,labels:O,renderers:s,layoutParts:o,loader:n,motion:r,pickAttachments:a,onOpenAttachment:i,onOpenTarget:l,onNavigate:c,openTicket:g,handoffHosts:C,resolveLink:j,keyboardOffset:u,onClose:closeSheet,layout:"sheet",testID:`${N}-frame`})})})]})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatStarters=ChatStarters;var _chatCore=require("@webority/chat-core"),_mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ChatOpenTickets=require("./ChatOpenTickets.js"),_jsxRuntime=require("react/jsx-runtime");function ChatStarters({chat:e,labels:t,openTicket:r,testID:i="chat-starters"}){const s=(0,_mobileUi.useTheme)(),a=e.profile,n=null!==e.lastConversation,l=(0,_react.useMemo)(()=>a?(0,_chatCore.resolveStart)(a,{pathname:a.screen??"/",returning:n}).greeting:"",[a,n]);if(!a)return null;const c=e.features.Starters&&e.features.BehaviourStarters&&e.starters.length>0,o=e.lastConversation,u=e.features.ResumeLast&&null!==o;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1,justifyContent:"center",alignItems:"center",gap:s.space.md,padding:s.space.md},testID:i,children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"h2",align:"center",children:l}),c?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"none",accessibilityLabel:t.starters,style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"center",gap:s.space.xs},children:e.starters.map(r=>(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:r.label,onPress:()=>{e.submit(r.message)},accessibilityLabel:`${t.starters}: ${r.label}`,testID:`${i}-${r.id}`},r.id))}):null,u&&o?(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",padding:"sm",onPress:()=>{e.resumeLast()},testID:`${i}-resume`,children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:t.resumeLast}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",numberOfLines:1,children:o.title||t.untitled}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:(0,_mobileCore.formatDate)(o.lastActivityDateTimeUtc)})]}):null,(0,_jsxRuntime.jsx)(_ChatOpenTickets.ChatOpenTickets,{chat:e,labels:t,onOpenTicket:r})]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatStarters=ChatStarters;var _mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_ChatEntrance=require("./ChatEntrance.js"),_ChatOpenTickets=require("./ChatOpenTickets.js"),_ChatPastChats=require("./ChatPastChats.js"),_jsxRuntime=require("react/jsx-runtime");function ChatStarters({chat:e,labels:t,openTicket:s,testID:i="chat-starters"}){const a=(0,_mobileUi.useTheme)(),r=e.profile,n=e.greeting??"";if(!r)return null;const l=e.features.Starters&&e.starters.length>0,c=e.lastConversation,o=e.features.ResumeLast&&!e.features.History&&null!==c;return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityLabel:t.emptyTitle,style:{flex:1,justifyContent:"center",alignItems:"center",gap:a.space.md,padding:a.space.md},testID:i,children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"h2",align:"center",children:n}),l?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"none",accessibilityLabel:t.starters,style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"center",gap:a.space.xs},children:e.starters.map((t,s)=>(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{index:s,children:(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:t.label,leftIcon:t.icon?t.icon:void 0,onPress:()=>{e.submit(t.message)},testID:`${i}-${t.id}`})},t.id))}):null,o&&c?(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",padding:"sm",onPress:()=>{e.resumeLast()},testID:`${i}-resume`,children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:t.resumeLast}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",numberOfLines:1,children:c.title||t.untitled}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:(0,_mobileCore.formatDate)(c.lastActivityDateTimeUtc)})]}):null,e.features.History?(0,_jsxRuntime.jsx)(_ChatPastChats.ChatPastChats,{chat:e,labels:t,testID:`${i}-past-chats`}):null,(0,_jsxRuntime.jsx)(_ChatOpenTickets.ChatOpenTickets,{chat:e,labels:t,onOpenTicket:s})]})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatThread=ChatThread;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_AgentByline=require("./AgentByline.js"),_ChatEntrance=require("./ChatEntrance.js"),_ChatMessageActions=require("./ChatMessageActions.js"),_chatShared=require("./chatShared.js"),_ChatLoader=require("./loaders/ChatLoader.js"),_TypingPill=require("./loaders/TypingPill.js"),_index=require("./renderers/index.js"),_NoticePart=require("./renderers/NoticePart.js"),_jsxRuntime=require("react/jsx-runtime");const MINE=new Set(["Visitor","Customer"]),joinedText=e=>e.filter(e=>"Text"===e.kind).map(e=>e.text).join("\n\n"),renderPart=(e,t,s,a,i,r)=>{const n=e[t.kind];if(n)return(0,_react.createElement)(n,{key:r,part:t,message:s,turn:a,pickAttachments:i});const o={kind:"Notice",code:"NeedsNewerApp",text:a.labels.needsNewerApp};return(0,_react.createElement)(_NoticePart.NoticePart,{key:r,part:o,message:s,turn:a})},sameMessage=(e,t)=>e.signature===t.signature&&e.message.id===t.message.id&&e.message.rating===t.message.rating&&e.message.stored===t.message.stored&&e.groupPosition===t.groupPosition&&e.isLast===t.isLast&&e.isLastVisitor===t.isLastVisitor&&e.thinking===t.thinking&&e.streaming===t.streaming&&e.pickAttachments===t.pickAttachments&&e.labels===t.labels&&e.all===t.all&&e.layoutParts===t.layoutParts&&e.chat.session===t.chat.session&&e.chat.features===t.chat.features&&e.chat.onNavigate===t.chat.onNavigate&&e.onNavigate===t.onNavigate&&e.onOpenAttachment===t.onOpenAttachment&&e.onOpenTarget===t.onOpenTarget&&e.openTicket===t.openTicket&&e.handoffHosts===t.handoffHosts;function ThreadMessageView({chat:e,message:t,labels:s,all:a,layoutParts:i,groupPosition:r,isLast:n,isLastVisitor:o,pickAttachments:l,onOpenAttachment:c,onOpenTarget:g,onNavigate:m,openTicket:u,handoffHosts:p,testID:h}){const d=(0,_mobileUi.useTheme)(),_=(0,_chatCore.createTurnApi)(e.session,{messageId:t.id,labels:s,openAttachment:c,openTarget:g??_chatShared.defaultOpenTarget,onNavigate:m??e.onNavigate,openTicket:u,handoffHosts:p});let x=0;const nextSlot=()=>(x+=1,x),y=(0,_jsxRuntime.jsx)(_ChatMessageActions.ChatMessageActions,{chat:e,message:t,labels:s,isLast:n,isLastVisitor:o,testID:`${h}-actions`});if(MINE.has(t.author.kind)){const e=t.parts.filter(e=>"File"===e.kind),i=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:d.space.xs},children:[e.map(e=>renderPart(a,e,t,_,l,`${t.id}-file-${nextSlot()}`)),y]});return(0,_jsxRuntime.jsx)(_mobileUi.MessageBubble,{side:"mine",text:joinedText(t.parts),labels:{you:s.you},groupPosition:r,footer:i,testID:h})}const j="Agent"===t.author.kind,T=t.author.displayName||s.agent,f=(i?i(t):t.parts).map(e=>Array.isArray(e)?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:d.space.xs},children:e.map(e=>renderPart(a,e,t,_,l,`${t.id}-part-${nextSlot()}`))},`${t.id}-group-${nextSlot()}`):renderPart(a,e,t,_,l,`${t.id}-item-${nextSlot()}`)),b=j?[(0,_jsxRuntime.jsx)(_AgentByline.AgentByline,{author:t.author,labels:s},`${t.id}-byline`),...f]:f,A=(0,_chatCore.messagePlainText)(t.parts);return(0,_jsxRuntime.jsx)(_mobileUi.MessageBubble,{side:"theirs",author:j?void 0:s.assistant,text:j?`${s.agentSays(T)} ${A}`:A,streaming:t.streaming,groupPosition:r,footer:y,testID:h,children:b})}const ThreadMessage=(0,_react.memo)(ThreadMessageView,sameMessage),TYPING_ORB_MARK=14,TYPING_ASSISTANT_MARK=8,TypingMark=({size:e})=>{const t=(0,_mobileUi.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:e,height:e,borderRadius:t.radius.pill,backgroundColor:t.colors.primary}})},TurnGap=()=>{const e=(0,_mobileUi.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:e.space.lg}})},followNew=()=>!0;function ChatThread({chat:e,labels:t,renderers:s,layoutParts:a,loader:i="Steps",motion:r="On",pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:c,openTicket:g,handoffHosts:m,keyboardAware:u,keyboardOffset:p,empty:h,style:d,testID:_="chat-thread"}){const x=(0,_mobileUi.useTheme)(),y=(0,_react.useMemo)(()=>({..._index.defaultRenderers,...s}),[s]),j=(0,_react.useMemo)(()=>e.messages.filter(e=>!(e.streaming&&0===e.parts.length)).reverse(),[e.messages]),T=e.messages[e.messages.length-1]?.id,f=(0,_react.useRef)(T);(0,_react.useEffect)(()=>{if(T===f.current)return;f.current=T;const s=e.messages[e.messages.length-1];if("Agent"!==s?.author.kind||!s.stored||s.restored||s.streaming)return;const a=s.author.displayName||t.agent;_reactNative.AccessibilityInfo.announceForAccessibility(`${t.agentSays(a)} ${(0,_chatCore.messagePlainText)(s.parts)}`)},[T,e.messages,t]);const b=(0,_react.useMemo)(()=>{for(let t=e.messages.length-1;t>=0;t-=1){const s=e.messages[t];if(s?.stored&&"Visitor"===s.author.kind)return s.id}},[e.messages]),A=e.streaming||null===e.turnError&&!e.stopped?null:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:x.space.xs},testID:`${_}-error`,children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:e.turnError?.message??t.stopped}),e.features.Retry?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row"},children:(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:t.retry,variant:"link",size:"sm",onPress:()=>{e.retry()},testID:`${_}-retry`})}):null]}),N=e.thinking&&null!==e.profile?(0,_jsxRuntime.jsx)(_ChatLoader.ChatLoader,{style:i,steps:e.steps,phrases:e.profile.experience.pacing.thinkingPhrases,intervalMs:e.profile.experience.pacing.phraseIntervalMs,announce:t.preparingAnswer(e.profile.assistant.name),motion:r}):null,k=!0===e.pending?.typing?(0,_jsxRuntime.jsx)(_TypingPill.TypingPill,{motion:r,mark:(0,_jsxRuntime.jsx)(TypingMark,{size:"Orb"===i?TYPING_ORB_MARK:TYPING_ASSISTANT_MARK})}):null,R=null!==e.agentTyping&&"WithAgent"===e.conversationState?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:x.space.xs,alignSelf:"flex-start"},children:[(0,_jsxRuntime.jsx)(_TypingPill.TypingPill,{motion:r,mark:(0,_jsxRuntime.jsx)(TypingMark,{size:TYPING_ASSISTANT_MARK})}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:t.agentTyping(e.agentTyping.displayName||t.agent)})]}):null,P=k||N||A||R?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:x.space.sm},children:[k,N,R,A]}):void 0;return(0,_jsxRuntime.jsx)(_mobileUi.MessageList,{messages:j,keyExtractor:e=>e.id,renderMessage:({item:s,groupPosition:i})=>(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{animate:!s.restored,children:(0,_jsxRuntime.jsx)(ThreadMessage,{chat:e,message:s,signature:(0,_chatShared.messageSignature)(s),labels:t,all:y,layoutParts:a,groupPosition:i,isLast:s.id===T,isLastVisitor:s.id===b,thinking:e.thinking,streaming:e.streaming,pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:c,openTicket:g,handoffHosts:m,testID:`${_}-${s.id}`})}),getAuthorKey:e=>e.author.kind,getDate:e=>e.createdDateTimeUtc,followNew:followNew,typing:P,empty:h,ItemSeparatorComponent:TurnGap,keyboardAware:u,keyboardOffset:p,accessibilityLabel:t.thread,style:d,testID:_})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatThread=ChatThread;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_AgentByline=require("./AgentByline.js"),_ChatEntrance=require("./ChatEntrance.js"),_ChatMessageActions=require("./ChatMessageActions.js"),_chatShared=require("./chatShared.js"),_ChatLoader=require("./loaders/ChatLoader.js"),_TypingPill=require("./loaders/TypingPill.js"),_index=require("./renderers/index.js"),_NoticePart=require("./renderers/NoticePart.js"),_jsxRuntime=require("react/jsx-runtime");const MINE=new Set(["Visitor","Customer"]),joinedText=e=>e.filter(e=>"Text"===e.kind).map(e=>e.text).join("\n\n"),renderPart=(e,t,s,a,i,r)=>{const n=e[t.kind];if(n)return(0,_react.createElement)(n,{key:r,part:t,message:s,turn:a,pickAttachments:i});const o={kind:"Notice",code:"NeedsNewerApp",text:a.labels.needsNewerApp};return(0,_react.createElement)(_NoticePart.NoticePart,{key:r,part:o,message:s,turn:a})},sameMessage=(e,t)=>e.signature===t.signature&&e.message.id===t.message.id&&e.message.rating===t.message.rating&&e.message.stored===t.message.stored&&e.groupPosition===t.groupPosition&&e.isLast===t.isLast&&e.handoffSettled===t.handoffSettled&&e.isLastVisitor===t.isLastVisitor&&e.thinking===t.thinking&&e.streaming===t.streaming&&e.pickAttachments===t.pickAttachments&&e.labels===t.labels&&e.all===t.all&&e.layoutParts===t.layoutParts&&e.chat.session===t.chat.session&&e.chat.features===t.chat.features&&e.chat.onNavigate===t.chat.onNavigate&&e.onNavigate===t.onNavigate&&e.onOpenAttachment===t.onOpenAttachment&&e.onOpenTarget===t.onOpenTarget&&e.openTicket===t.openTicket&&e.resolveLink===t.resolveLink&&e.focusComposer===t.focusComposer&&e.byline===t.byline&&e.handoffHosts===t.handoffHosts;function ThreadMessageView({chat:e,message:t,labels:s,all:a,layoutParts:i,groupPosition:r,isLast:n,isLastVisitor:o,pickAttachments:l,onOpenAttachment:c,onOpenTarget:u,onNavigate:d,openTicket:g,handoffHosts:m,resolveLink:h,focusComposer:p,byline:_,sourceRows:x,testID:y}){const f=(0,_mobileUi.useTheme)(),j=Object.assign((0,_chatCore.createTurnApi)(e.session,{messageId:t.id,labels:s,openAttachment:c,openTarget:u??_chatShared.defaultOpenTarget,onNavigate:d??e.onNavigate,openTicket:g,handoffHosts:m,openCitation:e=>(e=>{const t=x.current.get(e),s=t?(0,_reactNative.findNodeHandle)(t):null;null!==s&&_reactNative.AccessibilityInfo.setAccessibilityFocus(s)})(String(e))}),{resolveLink:h,focusComposer:p,registerSourceRow:(e,t)=>{t?x.current.set(e,t):x.current.delete(e)}});let T=0;const nextSlot=()=>(T+=1,T),b=(0,_jsxRuntime.jsx)(_ChatMessageActions.ChatMessageActions,{chat:e,message:t,labels:s,isLast:n,isLastVisitor:o,testID:`${y}-actions`});if(MINE.has(t.author.kind)){const e=t.parts.filter(e=>"File"===e.kind),i=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:f.space.xs},children:[e.map(e=>renderPart(a,e,t,j,l,`${t.id}-file-${nextSlot()}`)),b]});return(0,_jsxRuntime.jsx)(_mobileUi.MessageBubble,{side:"mine",text:joinedText(t.parts),labels:{you:s.you},groupPosition:r,footer:i,testID:y})}const k="Agent"===t.author.kind,N=t.author.displayName||s.agent,v=(i?i(t):t.parts).map(e=>Array.isArray(e)?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:f.space.xs},children:e.map(e=>renderPart(a,e,t,j,l,`${t.id}-part-${nextSlot()}`))},`${t.id}-group-${nextSlot()}`):renderPart(a,e,t,j,l,`${t.id}-item-${nextSlot()}`)),A=k&&_?[(0,_jsxRuntime.jsx)(_AgentByline.AgentByline,{author:t.author,labels:s},`${t.id}-byline`),...v]:v,R=(0,_chatCore.messagePlainText)(t.parts);return(0,_jsxRuntime.jsx)(_mobileUi.MessageBubble,{side:"theirs",author:k?void 0:t.author.displayName||s.assistant,text:k?`${s.agentSays(N)} ${R}`:R,streaming:t.streaming,groupPosition:r,footer:b,testID:y,children:A})}const ThreadMessage=(0,_react.memo)(ThreadMessageView,sameMessage),TYPING_ORB_MARK=14,TYPING_ASSISTANT_MARK=8,TypingMark=({size:e})=>{const t=(0,_mobileUi.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:e,height:e,borderRadius:t.radius.pill,backgroundColor:t.colors.primary}})},TYPING_DOT=6,TypingDots=()=>{const e=(0,_mobileUi.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},children:[0,1,2].map(t=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:6,height:6,borderRadius:3,backgroundColor:e.colors["text-muted"]}},t))})},TurnGap=()=>{const e=(0,_mobileUi.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:e.space.lg}})},followNew=()=>!0;function ChatThread({chat:e,labels:t,renderers:s,layoutParts:a,loader:i="Steps",motion:r="On",pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:c,openTicket:u,handoffHosts:d,resolveLink:g,focusComposer:m,keyboardAware:h,keyboardOffset:p,empty:_,style:x,testID:y="chat-thread"}){const f=(0,_mobileUi.useTheme)(),j=(0,_react.useMemo)(()=>({..._index.defaultRenderers,...s}),[s]),T=e.messages[0],b=e.greeting??"",k=(0,_react.useMemo)(()=>""!==b&&void 0!==T&&MINE.has(T.author.kind)?{...T,id:"greeting",author:{...T.author,kind:"Assistant",displayName:null,avatarUrl:null},parts:[{kind:"Text",text:b}],stored:!1,streaming:!1,restored:!1,rating:null}:null,[b,T]),N=(0,_react.useMemo)(()=>{const t=e.messages.filter(e=>!(e.streaming&&0===e.parts.length)).reverse();return k?[...t,k]:t},[e.messages,k]),v=e.messages[e.messages.length-1]?.id,A=(0,_react.useRef)(new Map),R=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(null!==R.current)for(const s of e.messages){if(MINE.has(s.author.kind)||s.streaming||s.restored||R.current.has(s.id))continue;if("Agent"===s.author.kind&&!s.stored)continue;R.current.add(s.id);const e=(0,_chatCore.messagePlainText)(s.parts);""!==e&&_reactNative.AccessibilityInfo.announceForAccessibility("Agent"===s.author.kind?`${t.agentSays(s.author.displayName||t.agent)} ${e}`:e)}else R.current=new Set(e.messages.map(e=>e.id))},[e.messages,t]);const w=(0,_react.useMemo)(()=>{for(let t=e.messages.length-1;t>=0;t-=1){const s=e.messages[t];if(s?.stored&&"Visitor"===s.author.kind)return s.id}},[e.messages]),P=(0,_react.useMemo)(()=>{const t=new Set;return e.messages.forEach((s,a)=>{if("Agent"!==s.author.kind)return;const i=e.messages[a-1];"Agent"===i?.author.kind&&(i.author.displayName||"")===(s.author.displayName||"")||t.add(s.id)}),t},[e.messages]),M=(0,_react.useMemo)(()=>(0,_chatCore.handoffSettledIds)(e.messages),[e.messages]),C=e.turnError,S="daily_limit"===C?.code,I=null!==C&&/feature_off$/.test(C.code),L=S&&C?.resetsDateTimeUtc?` ${t.dailyLimitRefresh((0,_chatCore.formatChatDateTime)(C.resetsDateTimeUtc))}`:"",$=e.streaming||null===C&&!e.stopped?null:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:f.space.xs},testID:`${y}-error`,children:[null!==C?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityRole:S?void 0:"alert",accessibilityLiveRegion:S?"polite":void 0,children:`${C.message}${L}`}):(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:t.stopped}),!e.features.Retry||S||I?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row"},children:(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:t.retry,variant:"link",size:"sm",onPress:()=>{e.retry()},testID:`${y}-retry`})})]}),D=e.thinking&&null!==e.profile?(0,_jsxRuntime.jsx)(_ChatLoader.ChatLoader,{style:i,steps:e.steps,phrases:e.profile.experience.pacing.thinkingPhrases,intervalMs:e.profile.experience.pacing.phraseIntervalMs,announce:t.preparingAnswer(e.profile.assistant.name),motion:r}):null,O=!0===e.pending?.typing?(0,_jsxRuntime.jsx)(_TypingPill.TypingPill,{motion:r,mark:(0,_jsxRuntime.jsx)(TypingMark,{size:"Orb"===i?TYPING_ORB_MARK:TYPING_ASSISTANT_MARK})}):null,V=null!==e.agentTyping&&"WithAgent"===e.conversationState?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:f.space.xs,alignSelf:"flex-start"},children:[(0,_jsxRuntime.jsx)(_TypingPill.TypingPill,{motion:r,mark:(0,_jsxRuntime.jsx)(TypingDots,{})}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:t.agentTyping(e.agentTyping.displayName||t.agent)})]}):null,U=O||D||$||V?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:f.space.sm},children:[O,D,V,$]}):void 0;return(0,_jsxRuntime.jsx)(_mobileUi.MessageList,{messages:N,keyExtractor:e=>e.id,renderMessage:({item:s,groupPosition:i})=>(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{animate:!s.restored,children:(0,_jsxRuntime.jsx)(ThreadMessage,{chat:e,message:s,signature:(0,_chatShared.messageSignature)(s),labels:t,all:j,layoutParts:a,groupPosition:i,isLast:s.id===v,isLastVisitor:s.id===w,handoffSettled:M.has(s.id),thinking:e.thinking,streaming:e.streaming,pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:c,openTicket:u,handoffHosts:d,resolveLink:g,focusComposer:m,byline:P.has(s.id),sourceRows:A,testID:`${y}-${s.id}`})}),getAuthorKey:e=>e.author.kind,getDate:e=>e.createdDateTimeUtc,followNew:followNew,typing:U,empty:_,ItemSeparatorComponent:TurnGap,keyboardAware:h,keyboardOffset:p,accessibilityLabel:t.thread,style:x,testID:y})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ReadAloudButton=ReadAloudButton;var _chatCore=require("@webority/chat-core"),_mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_phoneSpeech=require("./speech/phoneSpeech.js"),_useChatSpeech=require("./useChatSpeech.js"),_jsxRuntime=require("react/jsx-runtime");function ReadAloudButton({chat:e,message:r,labels:t,testID:a="chat-read-aloud"}){const o=(0,_useChatSpeech.useChatSpeech)(e),[i,u]=(0,_react.useState)(!1),[n,s]=(0,_react.useState)(!1),c=(0,_react.useRef)(null),l=(0,_react.useRef)(!0),h=(0,_react.useMemo)(()=>(0,_chatCore.messagePlainText)(r.parts),[r.parts]);if((0,_react.useEffect)(()=>(l.current=!0,()=>{l.current=!1,c.current?.abort()}),[]),!e.features.ReadAloud||null===o||r.streaming||""===h.trim())return null;return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:i?"stop":"volume-high",accessibilityLabel:i?t.readAloudStop:t.readAloud,variant:"ghost",tone:"neutral",size:"sm",onPress:()=>{if(i)return void c.current?.abort();s(!1);const e=new AbortController;c.current=e,u(!0);(async()=>{try{await o.speak(h,{signal:e.signal})}catch(r){if(!l.current||e.signal.aborted)return;s(!0),r instanceof _phoneSpeech.PhoneSpeechError||_mobileCore.Logger.error("[chat] read aloud failed",r)}finally{l.current&&(c.current=null,u(!1))}})()},testID:a}),n?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:t.readAloudFailed}):null]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ReadAloudButton=ReadAloudButton;var _chatCore=require("@webority/chat-core"),_mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_phoneSpeech=require("./speech/phoneSpeech.js"),_useChatSpeech=require("./useChatSpeech.js"),_jsxRuntime=require("react/jsx-runtime");function spokenText(e){return(0,_chatCore.messagePlainText)(e.filter(e=>"Text"===e.kind)).replace(/ ?\[\d+\]/g,"").replace(/\s+/g," ").trim()}function ReadAloudButton({chat:e,message:r,labels:t,testID:a="chat-read-aloud"}){const o=(0,_useChatSpeech.useChatSpeech)(e),[i,n]=(0,_react.useState)(!1),[u,s]=(0,_react.useState)(!1),c=(0,_react.useRef)(null),l=(0,_react.useRef)(!0),d=(0,_react.useMemo)(()=>spokenText(r.parts),[r.parts]);if((0,_react.useEffect)(()=>(l.current=!0,()=>{l.current=!1,c.current?.abort()}),[]),!e.features.ReadAloud||null===o||r.streaming||""===d.trim())return null;return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:i?"stop":"volume-high",accessibilityLabel:i?t.readAloudStop:t.readAloud,variant:"ghost",tone:"neutral",size:"sm",onPress:()=>{if(i)return void c.current?.abort();s(!1);const e=new AbortController;c.current=e,n(!0);(async()=>{try{await o.speak(d,{signal:e.signal})}catch(r){if(!l.current||e.signal.aborted)return;s(!0),r instanceof _phoneSpeech.PhoneSpeechError||_mobileCore.Logger.error("[chat] read aloud failed",r)}finally{l.current&&(c.current=null,n(!1))}})()},testID:a}),u?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:t.readAloudFailed}):null]})}
@@ -5,8 +5,8 @@
5
5
  "ResumeLast": "src/ChatStarters.tsx",
6
6
  "OpenTickets": "src/ChatOpenTickets.tsx",
7
7
  "History": "src/ChatFrame.tsx",
8
- "Rename": "src/ChatHistory.tsx",
9
- "Delete": "src/ChatHistory.tsx",
8
+ "Rename": "src/ChatPastChats.tsx",
9
+ "Delete": "src/ChatPastChats.tsx",
10
10
  "SuggestedReplies": "src/renderers/QuickRepliesPart.tsx",
11
11
  "Stop": "src/ChatComposer.tsx",
12
12
  "Retry": "src/ChatThread.tsx",
@@ -30,7 +30,7 @@
30
30
  "VoiceClips": "src/renderers/VoiceClipPart.tsx",
31
31
  "Sounds": "src/useChatHaptics.ts",
32
32
  "AutoOpen": null,
33
- "BehaviourStarters": "src/ChatStarters.tsx",
33
+ "BehaviourStarters": "../chat-core/src/session.ts",
34
34
  "LeadShortcuts": "src/renderers/InputRequestPart.tsx",
35
35
  "LeadRecap": "src/renderers/ActionPart.tsx",
36
36
  "FigureText": "src/renderers/TextPart.tsx",
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"AgentByline",{enumerable:!0,get:function(){return _AgentByline.AgentByline}}),Object.defineProperty(exports,"CHAT_PUSH_TYPE",{enumerable:!0,get:function(){return _pushOpen.CHAT_PUSH_TYPE}}),Object.defineProperty(exports,"ChatComposer",{enumerable:!0,get:function(){return _ChatComposer.ChatComposer}}),Object.defineProperty(exports,"ChatConversationActions",{enumerable:!0,get:function(){return _ChatConversationActions.ChatConversationActions}}),Object.defineProperty(exports,"ChatDictationButton",{enumerable:!0,get:function(){return _ChatDictationButton.ChatDictationButton}}),Object.defineProperty(exports,"ChatEmbed",{enumerable:!0,get:function(){return _ChatEmbed.ChatEmbed}}),Object.defineProperty(exports,"ChatFooter",{enumerable:!0,get:function(){return _ChatFooter.ChatFooter}}),Object.defineProperty(exports,"ChatHistory",{enumerable:!0,get:function(){return _ChatHistory.ChatHistory}}),Object.defineProperty(exports,"ChatLiveBar",{enumerable:!0,get:function(){return _ChatLiveBar.ChatLiveBar}}),Object.defineProperty(exports,"ChatLoader",{enumerable:!0,get:function(){return _ChatLoader.ChatLoader}}),Object.defineProperty(exports,"ChatMessageActions",{enumerable:!0,get:function(){return _ChatMessageActions.ChatMessageActions}}),Object.defineProperty(exports,"ChatNudge",{enumerable:!0,get:function(){return _ChatNudge.ChatNudge}}),Object.defineProperty(exports,"ChatOpenTickets",{enumerable:!0,get:function(){return _ChatOpenTickets.ChatOpenTickets}}),Object.defineProperty(exports,"ChatScreen",{enumerable:!0,get:function(){return _ChatScreen.ChatScreen}}),Object.defineProperty(exports,"ChatSheet",{enumerable:!0,get:function(){return _ChatSheet.ChatSheet}}),Object.defineProperty(exports,"ChatStarters",{enumerable:!0,get:function(){return _ChatStarters.ChatStarters}}),Object.defineProperty(exports,"ChatThread",{enumerable:!0,get:function(){return _ChatThread.ChatThread}}),Object.defineProperty(exports,"ReadAloudButton",{enumerable:!0,get:function(){return _ReadAloudButton.ReadAloudButton}}),Object.defineProperty(exports,"TypingPill",{enumerable:!0,get:function(){return _TypingPill.TypingPill}}),Object.defineProperty(exports,"chatConversationIdFromPush",{enumerable:!0,get:function(){return _pushOpen.chatConversationIdFromPush}}),Object.defineProperty(exports,"defaultOpenTarget",{enumerable:!0,get:function(){return _chatShared.defaultOpenTarget}}),Object.defineProperty(exports,"defaultRenderers",{enumerable:!0,get:function(){return _index.defaultRenderers}}),Object.defineProperty(exports,"messageSignature",{enumerable:!0,get:function(){return _chatShared.messageSignature}}),Object.defineProperty(exports,"useChat",{enumerable:!0,get:function(){return _useChat.useChat}}),Object.defineProperty(exports,"useChatSpeech",{enumerable:!0,get:function(){return _useChatSpeech.useChatSpeech}});var _AgentByline=require("./AgentByline.js"),_ChatComposer=require("./ChatComposer.js"),_ChatConversationActions=require("./ChatConversationActions.js"),_ChatDictationButton=require("./ChatDictationButton.js"),_ChatEmbed=require("./ChatEmbed.js"),_ChatFooter=require("./ChatFooter.js"),_ChatHistory=require("./ChatHistory.js"),_ChatLiveBar=require("./ChatLiveBar.js"),_ChatMessageActions=require("./ChatMessageActions.js"),_ChatNudge=require("./ChatNudge.js"),_ChatOpenTickets=require("./ChatOpenTickets.js"),_ChatScreen=require("./ChatScreen.js"),_ChatSheet=require("./ChatSheet.js"),_ChatStarters=require("./ChatStarters.js"),_ChatThread=require("./ChatThread.js"),_chatShared=require("./chatShared.js"),_ChatLoader=require("./loaders/ChatLoader.js"),_TypingPill=require("./loaders/TypingPill.js"),_pushOpen=require("./pushOpen.js"),_ReadAloudButton=require("./ReadAloudButton.js"),_index=require("./renderers/index.js"),_useChat=require("./useChat.js"),_useChatSpeech=require("./useChatSpeech.js");
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"AgentByline",{enumerable:!0,get:function(){return _AgentByline.AgentByline}}),Object.defineProperty(exports,"CHAT_PUSH_TYPE",{enumerable:!0,get:function(){return _pushOpen.CHAT_PUSH_TYPE}}),Object.defineProperty(exports,"ChatComposer",{enumerable:!0,get:function(){return _ChatComposer.ChatComposer}}),Object.defineProperty(exports,"ChatConversationActions",{enumerable:!0,get:function(){return _ChatConversationActions.ChatConversationActions}}),Object.defineProperty(exports,"ChatDictationButton",{enumerable:!0,get:function(){return _ChatDictationButton.ChatDictationButton}}),Object.defineProperty(exports,"ChatEmbed",{enumerable:!0,get:function(){return _ChatEmbed.ChatEmbed}}),Object.defineProperty(exports,"ChatFooter",{enumerable:!0,get:function(){return _ChatFooter.ChatFooter}}),Object.defineProperty(exports,"ChatHistory",{enumerable:!0,get:function(){return _ChatHistory.ChatHistory}}),Object.defineProperty(exports,"ChatLiveBar",{enumerable:!0,get:function(){return _ChatLiveBar.ChatLiveBar}}),Object.defineProperty(exports,"ChatLoader",{enumerable:!0,get:function(){return _ChatLoader.ChatLoader}}),Object.defineProperty(exports,"ChatMessageActions",{enumerable:!0,get:function(){return _ChatMessageActions.ChatMessageActions}}),Object.defineProperty(exports,"ChatNudge",{enumerable:!0,get:function(){return _ChatNudge.ChatNudge}}),Object.defineProperty(exports,"ChatOpenTickets",{enumerable:!0,get:function(){return _ChatOpenTickets.ChatOpenTickets}}),Object.defineProperty(exports,"ChatPastChats",{enumerable:!0,get:function(){return _ChatPastChats.ChatPastChats}}),Object.defineProperty(exports,"ChatScreen",{enumerable:!0,get:function(){return _ChatScreen.ChatScreen}}),Object.defineProperty(exports,"ChatSheet",{enumerable:!0,get:function(){return _ChatSheet.ChatSheet}}),Object.defineProperty(exports,"ChatStarters",{enumerable:!0,get:function(){return _ChatStarters.ChatStarters}}),Object.defineProperty(exports,"ChatThread",{enumerable:!0,get:function(){return _ChatThread.ChatThread}}),Object.defineProperty(exports,"ReadAloudButton",{enumerable:!0,get:function(){return _ReadAloudButton.ReadAloudButton}}),Object.defineProperty(exports,"TypingPill",{enumerable:!0,get:function(){return _TypingPill.TypingPill}}),Object.defineProperty(exports,"chatConversationIdFromPush",{enumerable:!0,get:function(){return _pushOpen.chatConversationIdFromPush}}),Object.defineProperty(exports,"defaultOpenTarget",{enumerable:!0,get:function(){return _chatShared.defaultOpenTarget}}),Object.defineProperty(exports,"defaultRenderers",{enumerable:!0,get:function(){return _index.defaultRenderers}}),Object.defineProperty(exports,"messageSignature",{enumerable:!0,get:function(){return _chatShared.messageSignature}}),Object.defineProperty(exports,"useChat",{enumerable:!0,get:function(){return _useChat.useChat}}),Object.defineProperty(exports,"useChatSpeech",{enumerable:!0,get:function(){return _useChatSpeech.useChatSpeech}});var _AgentByline=require("./AgentByline.js"),_ChatComposer=require("./ChatComposer.js"),_ChatConversationActions=require("./ChatConversationActions.js"),_ChatDictationButton=require("./ChatDictationButton.js"),_ChatEmbed=require("./ChatEmbed.js"),_ChatFooter=require("./ChatFooter.js"),_ChatHistory=require("./ChatHistory.js"),_ChatLiveBar=require("./ChatLiveBar.js"),_ChatMessageActions=require("./ChatMessageActions.js"),_ChatNudge=require("./ChatNudge.js"),_ChatOpenTickets=require("./ChatOpenTickets.js"),_ChatPastChats=require("./ChatPastChats.js"),_ChatScreen=require("./ChatScreen.js"),_ChatSheet=require("./ChatSheet.js"),_ChatStarters=require("./ChatStarters.js"),_ChatThread=require("./ChatThread.js"),_chatShared=require("./chatShared.js"),_ChatLoader=require("./loaders/ChatLoader.js"),_TypingPill=require("./loaders/TypingPill.js"),_pushOpen=require("./pushOpen.js"),_ReadAloudButton=require("./ReadAloudButton.js"),_index=require("./renderers/index.js"),_useChat=require("./useChat.js"),_useChatSpeech=require("./useChatSpeech.js");
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatLoader=ChatLoader;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_OrbLoader=require("./OrbLoader.js"),_PhrasesLoader=require("./PhrasesLoader.js"),_SkeletonLoader=require("./SkeletonLoader.js"),_StepsLoader=require("./StepsLoader.js"),_jsxRuntime=require("react/jsx-runtime");const ANNOUNCE_DELAY_MS=500;function ChatLoader({style:e="Steps",steps:t=[],phrases:r,intervalMs:s,motion:o="On",announce:a,testID:i="chat-loader"}){if(!_chatCore.LOADER_STYLES.includes(e))throw new Error(`ChatLoader style must be one of ${_chatCore.LOADER_STYLES.join(", ")}; got "${e}".`);const c=(0,_mobileUi.useReducedMotion)(),n="Reduced"===o||c,[u,d]=(0,_react.useState)({style:e,count:0});(0,_react.useEffect)(()=>{d({style:e,count:0})},[e]),(0,_react.useEffect)(()=>{if(n)return;const t=setInterval(()=>{d(t=>({style:e,count:(t.style===e?t.count:0)+1}))},s);return()=>clearInterval(t)},[e,s,n]);const l=(0,_react.useRef)(a),[_,L]=(0,_react.useState)("");(0,_react.useEffect)(()=>{const e=setTimeout(()=>L(l.current),ANNOUNCE_DELAY_MS);return()=>clearTimeout(e)},[]);const h=n||u.style!==e?0:u.count,b=(0,_chatCore.loaderView)(e,t,r,h);return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityRole:"progressbar",accessibilityLabel:b.label,accessibilityLiveRegion:"polite",testID:i,children:[loaderBody(e,b,n),(0,_jsxRuntime.jsx)(_mobileUi.Text,{accessibilityLiveRegion:"polite",style:styles.announce,children:_})]})}const loaderBody=(e,t,r)=>{switch(e){case"Steps":return(0,_jsxRuntime.jsx)(_StepsLoader.StepsLoader,{view:t,reduced:r});case"Phrases":return(0,_jsxRuntime.jsx)(_PhrasesLoader.PhrasesLoader,{view:t,reduced:r});case"Orb":return(0,_jsxRuntime.jsx)(_OrbLoader.OrbLoader,{view:t,reduced:r});case"Skeleton":return(0,_jsxRuntime.jsx)(_SkeletonLoader.SkeletonLoader,{view:t,reduced:r})}},styles=_reactNative.StyleSheet.create({announce:{position:"absolute",width:1,height:1,opacity:0,overflow:"hidden"}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatLoader=ChatLoader;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_OrbLoader=require("./OrbLoader.js"),_PhrasesLoader=require("./PhrasesLoader.js"),_SkeletonLoader=require("./SkeletonLoader.js"),_StepsLoader=require("./StepsLoader.js"),_jsxRuntime=require("react/jsx-runtime");const ANNOUNCE_DELAY_MS=500;function ChatLoader({style:e="Steps",steps:t=[],phrases:r,intervalMs:s,motion:o="On",announce:a,testID:i="chat-loader"}){if(!_chatCore.LOADER_STYLES.includes(e))throw new Error(`ChatLoader style must be one of ${_chatCore.LOADER_STYLES.join(", ")}; got "${e}".`);const c=(0,_mobileUi.useReducedMotion)(),n="Reduced"===o||c,[u,d]=(0,_react.useState)({style:e,count:0});(0,_react.useEffect)(()=>{d({style:e,count:0})},[e]),(0,_react.useEffect)(()=>{if(n)return;const t=setInterval(()=>{d(t=>({style:e,count:(t.style===e?t.count:0)+1}))},s);return()=>clearInterval(t)},[e,s,n]);const l=(0,_react.useRef)(a),[_,L]=(0,_react.useState)("");(0,_react.useEffect)(()=>{const e=setTimeout(()=>L(l.current),ANNOUNCE_DELAY_MS);return()=>clearTimeout(e)},[]);const h=n||u.style!==e?0:u.count,S=(0,_chatCore.loaderView)(e,t,r,h);return(0,_jsxRuntime.jsxs)(_reactNative.View,{role:"status",accessibilityLabel:S.label,accessibilityLiveRegion:"polite",testID:i,children:[loaderBody(e,S,n),(0,_jsxRuntime.jsx)(_mobileUi.Text,{accessibilityLiveRegion:"polite",style:styles.announce,children:_})]})}const loaderBody=(e,t,r)=>{switch(e){case"Steps":return(0,_jsxRuntime.jsx)(_StepsLoader.StepsLoader,{view:t,reduced:r});case"Phrases":return(0,_jsxRuntime.jsx)(_PhrasesLoader.PhrasesLoader,{view:t,reduced:r});case"Orb":return(0,_jsxRuntime.jsx)(_OrbLoader.OrbLoader,{view:t,reduced:r});case"Skeleton":return(0,_jsxRuntime.jsx)(_SkeletonLoader.SkeletonLoader,{view:t,reduced:r})}},styles=_reactNative.StyleSheet.create({announce:{position:"absolute",width:1,height:1,opacity:0,overflow:"hidden"}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ActionPart=ActionPart;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_NoticePart=require("./NoticePart.js"),_jsxRuntime=require("react/jsx-runtime");const statusLine=(e,t)=>{switch(e.state){case"Confirmed":return t.actionConfirmed;case"Done":return t.actionDone;case"Rejected":return t.actionRejected;case"Expired":return t.actionExpired;case"Failed":return t.actionFailed;case"Repeat":return e.decidedDateTimeUtc?t.actionRepeat((0,_chatCore.formatChatDate)(e.decidedDateTimeUtc)):t.actionDone;case"Pending":return""}};function ActionBody({part:e,turn:t}){const i=(0,_mobileUi.useTheme)(),{labels:n,features:a}=t,[r,o]=(0,_react.useState)(null),[s,c]=(0,_react.useState)(""),[l,u]=(0,_react.useState)(!1),run=async(e,t)=>{o(e),c("");try{await t()}catch(e){const t=e?.message;c("string"==typeof t&&""!==t?t:n.actionFailed),o(null)}},d=(e.editFields??[]).map(e=>({label:e.label,value:e.id})),m=a.LeadRecap&&d.length>0,x=null!==r;return(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",padding:"sm",children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:e.title}),e.lines.map(e=>(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:e},e)),e.consentText?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:e.consentText}):null,"Pending"===e.state?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[""!==s?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:s}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:i.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:"confirm"===r?n.actionWorking:e.confirmLabel??n.actionConfirm,loading:"confirm"===r,disabled:x,onPress:()=>{run("confirm",()=>t.confirmAction(e.actionId))}}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:e.rejectLabel??n.actionDismiss,variant:"ghost",disabled:x,onPress:()=>{run("reject",()=>t.rejectAction(e.actionId))}}),m?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:n.editSomething,variant:"ghost",disabled:x,onPress:()=>u(!0)}):null]})]}):(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:statusLine(e,n)}),e.note?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:e.note}):null]}),m?(0,_jsxRuntime.jsx)(_mobileUi.OptionSheet,{open:l,onClose:()=>u(!1),title:n.editSomething,options:d,onChange:(e,i)=>{u(!1),t.chooseQuickReply({id:`lead.edit:${String(i.value)}`,label:i.label,action:"Send",target:null,navigateAfterMs:null,icon:null,variant:null})}}):null]})}function ActionPart(e){const{part:t,message:i,turn:n}=e;if("Action"!==t.kind){const e={kind:"Notice",code:"NeedsNewerApp",text:n.labels.needsNewerApp};return(0,_jsxRuntime.jsx)(_NoticePart.NoticePart,{part:e,message:i,turn:n})}return(0,_jsxRuntime.jsx)(ActionBody,{part:t,turn:n},t.actionId)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ActionPart=ActionPart;var _chatCore=require("@webority/chat-core"),_markdownCore=require("@webority/markdown-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_NoticePart=require("./NoticePart.js"),_jsxRuntime=require("react/jsx-runtime");const LEAD_CAPTURE="ChatLeadCapture",SAFE_LINK=/^https?:/,inlineNodes=(e,t)=>e.map(e=>{if("text"===e.type||"code"===e.type||"citation"===e.type)return e.text;if("link"===e.type){const i=inlineNodes(e.children,t);return SAFE_LINK.test(e.href)?(0,_jsxRuntime.jsx)(_reactNative.Text,{accessibilityRole:"link",style:{color:t.colors.link,textDecorationLine:"underline"},onPress:()=>{_reactNative.Linking.openURL(e.href).catch(()=>{})},children:i},e.key):(0,_jsxRuntime.jsx)(_reactNative.Text,{children:i},e.key)}if("image"===e.type)return null;const i="strong"===e.type?{fontWeight:t.weight.bold}:"em"===e.type?{fontStyle:"italic"}:{textDecorationLine:"line-through"};return(0,_jsxRuntime.jsx)(_reactNative.Text,{style:i,children:inlineNodes(e.children,t)},e.key)}),splitLine=e=>{const t=e.indexOf(": ");return t<0?{term:e,detail:null}:{term:e.slice(0,t),detail:e.slice(t+2)}},statusLine=(e,t)=>{switch(e.state){case"Confirmed":return t.actionConfirmed;case"Done":return e.decidedDateTimeUtc?`${t.actionDone} ${(0,_chatCore.formatChatDate)(e.decidedDateTimeUtc)}`:t.actionDone;case"Rejected":return t.actionRejected;case"Expired":return t.actionExpired;case"Failed":return t.actionFailed;case"Repeat":return e.decidedDateTimeUtc?t.actionRepeat((0,_chatCore.formatChatDate)(e.decidedDateTimeUtc)):t.actionDone;case"Pending":return""}};function ActionBody({part:e,turn:t}){const i=(0,_mobileUi.useTheme)(),{labels:n,features:a}=t,[r,o]=(0,_react.useState)(null),[s,l]=(0,_react.useState)(""),[c,d]=(0,_react.useState)(!1),run=async(e,t)=>{o(e),l("");try{await t()}catch(e){const t=e?.message;l("string"==typeof t&&""!==t?t:n.actionFailed),o(null)}},u=(e.editFields??[]).map(e=>({label:e.label,value:e.id})),m=a.LeadRecap&&e.actionKind===LEAD_CAPTURE,x=m&&u.length>0,_=m&&e.confirmLabel||n.actionConfirm,j=m&&e.rejectLabel||n.actionDismiss,p=null!==r;return(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",padding:"sm",children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:e.title}),e.lines.map(e=>{if(!m)return(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:e},e);const{term:t,detail:n}=splitLine(e);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:i.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:t}),null!==n?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:n}):null]},e)}),m&&e.consentText?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:inlineNodes((0,_markdownCore.parseInline)(e.consentText),i)}):null,"Pending"===e.state?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[""!==s?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:s}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:i.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:"confirm"===r?n.actionWorking:_,loading:"confirm"===r,disabled:p,onPress:()=>{run("confirm",()=>t.confirmAction(e.actionId))}}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:j,variant:"ghost",disabled:p,onPress:()=>{run("reject",()=>t.rejectAction(e.actionId))}})]})]}):(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"Done"===e.state||"Confirmed"===e.state||"Repeat"===e.state?"success":"secondary",children:statusLine(e,n)}),x?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:n.editSomething,variant:"ghost",disabled:p||"Pending"!==e.state,onPress:()=>d(!0)}):null,e.note?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:e.note}):null]}),x?(0,_jsxRuntime.jsx)(_mobileUi.OptionSheet,{open:c,onClose:()=>d(!1),title:n.editSomething,options:u,onChange:(e,i)=>{d(!1),t.chooseQuickReply({id:`lead.edit:${String(i.value)}`,label:i.label,action:"Send",target:null,navigateAfterMs:null,icon:null,variant:null})}}):null]})}function ActionPart(e){const{part:t,message:i,turn:n}=e;if("Action"!==t.kind){const e={kind:"Notice",code:"NeedsNewerApp",text:n.labels.needsNewerApp};return(0,_jsxRuntime.jsx)(_NoticePart.NoticePart,{part:e,message:i,turn:n})}return(0,_jsxRuntime.jsx)(ActionBody,{part:t,turn:n},t.actionId)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChartPart=ChartPart;var _chatCore=require("@webority/chat-core"),_mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_FigureText=require("./FigureText.js"),_jsxRuntime=require("react/jsx-runtime");const TONES=["primary","info","success","warning","danger","neutral"],toneAt=e=>TONES[e%TONES.length]??"primary",withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),writeValue=(e,t)=>{const i=0!==e&&Math.abs(e)<.001?(0,_FigureText.runsToText)((0,_chatCore.formatFigure)(e)):(0,_mobileCore.formatNumber)(e,{maximumFractionDigits:2});return t?`${i} ${t}`:i};function ChartPart({part:e,turn:t}){const i=(0,_mobileUi.useTheme)();if(e.series.every(e=>0===e.points.length))return null;const{unit:r}=e,a=e.title?(0,_chatCore.toFigureText)(e.title):t.labels.chart,l=e.series.length>1;return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityLabel:a,style:{gap:i.space.sm},children:[e.title?(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:e.title,variant:"label",color:"primary",strong:!0}):null,withPositions(e.series).map(({key:o,item:s})=>{const n=toneAt(o),u=(0,_chatCore.toFigureText)(s.name)||a,c=s.points;if(0===c.length)return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.xs},children:[l?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:(0,_chatCore.toFigureText)(s.name)}):null,(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:t.labels.chartEmpty})]},o);const m=c.map(e=>e.value),x=m.reduce((e,t)=>Math.min(e,t)),_=m.reduce((e,t)=>Math.max(e,t)),h=c[0],b=c[c.length-1];let g;if("Bar"===e.chartType)g=(0,_jsxRuntime.jsx)(_mobileUi.BarChart,{data:c.map(e=>({label:(0,_chatCore.toFigureText)(e.label),value:e.value})),height:c.length>4?300:240,label:u,formatValue:e=>writeValue(e,r),formatTick:e=>r?`${(0,_mobileCore.formatCompactNumber)(e)} ${r}`:(0,_mobileCore.formatCompactNumber)(e),tone:n});else if("Line"===e.chartType)g=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Sparkline,{data:m,height:160,fill:!0,tone:n,label:u,formatLabel:e=>writeValue(e,r)}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",justifyContent:"space-between"},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",children:(0,_chatCore.toFigureText)(h.label)}),c.length>1?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",children:(0,_chatCore.toFigureText)(b.label)}):null]}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:`${t.labels.chartLow(writeValue(x,r))} ${t.labels.chartHigh(writeValue(_,r))}`})]});else{const e=m.reduce((e,t)=>e+(Number.isFinite(t)&&t>0?t:0),0);g=(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"list",style:{gap:i.space.sm},children:withPositions(c).map(({key:t,item:i})=>{const a=e>0&&Number.isFinite(i.value)&&i.value>0?i.value/e:0;return(0,_jsxRuntime.jsx)(_mobileUi.ProgressBar,{progress:a,height:8,tone:toneAt(t),label:(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:i.label,variant:"bodySmall"}),valueLabel:`${writeValue(i.value,r)} (${(0,_mobileCore.formatPercent)(a,{maximumFractionDigits:0})})`},t)})})}return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.xs},children:[l?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:(0,_chatCore.toFigureText)(s.name)}):null,g]},o)})]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChartPart=ChartPart;var _chatCore=require("@webority/chat-core"),_mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_FigureText=require("./FigureText.js"),_jsxRuntime=require("react/jsx-runtime");const TONES=["primary","info","success","warning","danger","neutral"],toneAt=e=>TONES[e%TONES.length]??"primary",MAX_SERIES=8,withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),writeValue=(e,t)=>{const i=0!==e&&Math.abs(e)<.001?(0,_FigureText.runsToText)((0,_chatCore.formatFigure)(e)):(0,_mobileCore.formatNumber)(e,{maximumFractionDigits:2});return t?`${i} ${t}`:i};function ChartPart({part:e,turn:t}){const i=(0,_mobileUi.useTheme)(),[r,a]=(0,_react.useState)(!1),l="Donut"===e.chartType?e.series.slice(0,1):e.series.slice(0,MAX_SERIES);if(l.every(e=>0===e.points.length))return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.sm},children:[e.title?(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:e.title,variant:"label",color:"primary",strong:!0}):null,(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:t.labels.chartEmpty})]});const{unit:s}=e,o=e.title?(0,_chatCore.toFigureText)(e.title):t.labels.chart,n=l.length>1;return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityLabel:o,style:{gap:i.space.sm},children:[e.title?(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:e.title,variant:"label",color:"primary",strong:!0}):null,(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:r?t.labels.chartShowChart:t.labels.chartShowTable,variant:"link",size:"sm",onPress:()=>a(e=>!e)}),withPositions(l).map(({key:a,item:l})=>{const c=toneAt(a),u=(0,_chatCore.toFigureText)(l.name)||o,m=l.points;if(0===m.length)return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.xs},children:[n?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:(0,_chatCore.toFigureText)(l.name)}):null,(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:t.labels.chartEmpty})]},a);const x=m.map(e=>e.value),_=x.reduce((e,t)=>Math.min(e,t)),h=x.reduce((e,t)=>Math.max(e,t)),b=m[0],j=m[m.length-1];let p;if(r)p=(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"summary",style:{gap:i.space.xs},children:withPositions(m).map(({key:e,item:t})=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",justifyContent:"space-between",gap:i.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"primary",children:(0,_chatCore.toFigureText)(t.label)}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"primary",children:writeValue(t.value,s)})]},e))});else if("Bar"===e.chartType)p=(0,_jsxRuntime.jsx)(_mobileUi.BarChart,{data:m.map(e=>({label:(0,_chatCore.toFigureText)(e.label),value:e.value})),height:m.length>4?300:240,label:u,formatValue:e=>writeValue(e,s),formatTick:e=>s?`${(0,_mobileCore.formatCompactNumber)(e)} ${s}`:(0,_mobileCore.formatCompactNumber)(e),tone:c});else if("Line"===e.chartType)p=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Sparkline,{data:x,height:160,fill:!0,tone:c,label:u,formatLabel:e=>writeValue(e,s)}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",justifyContent:"space-between"},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",children:(0,_chatCore.toFigureText)(b.label)}),m.length>1?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",children:(0,_chatCore.toFigureText)(j.label)}):null]}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:`${t.labels.chartLow(writeValue(_,s))} ${t.labels.chartHigh(writeValue(h,s))}`})]});else{const e=x.reduce((e,t)=>e+(Number.isFinite(t)&&t>0?t:0),0);p=(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"list",style:{gap:i.space.sm},children:withPositions(m).map(({key:t,item:i})=>{const r=e>0&&Number.isFinite(i.value)&&i.value>0?i.value/e:0;return(0,_jsxRuntime.jsx)(_mobileUi.ProgressBar,{progress:r,height:8,tone:toneAt(t),label:(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:i.label,variant:"bodySmall"}),valueLabel:`${writeValue(i.value,s)} (${(0,_mobileCore.formatPercent)(r,{maximumFractionDigits:0})})`},t)})})}return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.xs},children:[n?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:(0,_chatCore.toFigureText)(l.name)}):null,p]},a)})]})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FigureRuns=FigureRuns,exports.FigureText=FigureText,exports.runsToText=runsToText;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const sizeStepOf=e=>"caption"===e?"xs":"bodySmall"===e||"label"===e?"sm":"title"===e?"lg":"base",inkFor=(e,t)=>"secondary"===t?e.colors["text-muted"]:"tertiary"===t?e.colors["text-subtle"]:"success"===t||"warning"===t||"danger"===t||"info"===t?e.colors[`${t}-text`]:e.colors["text-body"];function runsToText(e){return e.map(e=>e.text).join("")}const withOffsets=e=>e.reduce((e,t)=>{const r=e[e.length-1],n=r?r.offset+r.run.text.length:0;return e.push({offset:n,run:t}),e},[]);function runNode(e,t,r){if("text"===e.kind)return e.text;const n="sub"===e.kind?Math.round(.4*t):-Math.round(.45*t),i=Math.round(.75*t);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{transform:[{translateY:n}]},children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{fontSize:i,lineHeight:i,includeFontPadding:!1,color:r},children:e.text})})}function FigureRuns({runs:e,variant:t="bodySmall",color:r,strong:n=!1,numberOfLines:i,accessibilityLabel:s,testID:o}){const u=(0,_mobileUi.useTheme)(),a=u.text[sizeStepOf(t)].size,c=inkFor(u,r);return(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:t,color:r,weight:n?"semibold":void 0,numberOfLines:i,testID:o,accessibilityLabel:s??runsToText(e),children:withOffsets(e).map(({offset:e,run:t})=>(0,_jsxRuntime.jsx)(_react.Fragment,{children:runNode(t,a,c)},e))})}function FigureText({text:e,variant:t="bodySmall",...r}){const n=(0,_react.useMemo)(()=>(0,_chatCore.toFigureRuns)(e),[e]);return(0,_jsxRuntime.jsx)(FigureRuns,{runs:n,variant:t,...r})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FigureRuns=FigureRuns,exports.FigureText=FigureText,exports.runsToText=runsToText;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const sizeStepOf=e=>"caption"===e?"xs":"bodySmall"===e||"label"===e?"sm":"title"===e?"lg":"base",inkFor=(e,t)=>"secondary"===t?e.colors["text-muted"]:"tertiary"===t?e.colors["text-subtle"]:"success"===t||"warning"===t||"danger"===t||"info"===t?e.colors[`${t}-text`]:e.colors["text-body"];function runsToText(e){return e.map(e=>e.text).join("")}const withOffsets=e=>e.reduce((e,t)=>{const r=e[e.length-1],i=r?r.offset+r.run.text.length:0;return e.push({offset:i,run:t}),e},[]);function runNode(e,t,r){if("text"===e.kind)return e.text;const i="sub"===e.kind?Math.round(.4*t):-Math.round(.45*t),n=Math.round(.75*t);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{transform:[{translateY:i}]},children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{fontSize:n,lineHeight:n,includeFontPadding:!1,color:r},children:e.text})})}function FigureRuns({runs:e,variant:t="bodySmall",color:r,strong:i=!1,numberOfLines:n,accessibilityLabel:s,testID:o,heading:u}){const a=(0,_mobileUi.useTheme)(),c=a.text[sizeStepOf(t)].size,l=inkFor(a,r);return(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:t,color:r,weight:i?"semibold":void 0,numberOfLines:n,testID:o,accessibilityRole:u?"header":void 0,accessibilityLabel:s??runsToText(e),children:withOffsets(e).map(({offset:e,run:t})=>(0,_jsxRuntime.jsx)(_react.Fragment,{children:runNode(t,c,l)},e))})}function FigureText({text:e,variant:t="bodySmall",enabled:r=!0,...i}){const n=(0,_react.useMemo)(()=>r?(0,_chatCore.toFigureRuns)(e):[{kind:"text",text:e}],[e,r]);return(0,_jsxRuntime.jsx)(FigureRuns,{runs:n,variant:t,...i})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FiguresPart=FiguresPart;var _chatCore=require("@webority/chat-core"),_mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_FigureText=require("./FigureText.js"),_jsxRuntime=require("react/jsx-runtime");const TONE={Neutral:"neutral",Positive:"success",Caution:"warning",Negative:"danger"},withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),valueRunsOf=e=>{const t=0!==e.value&&Math.abs(e.value)<.001?(0,_chatCore.formatFigure)(e.value):[{kind:"text",text:(0,_mobileCore.formatNumber)(e.value,{maximumFractionDigits:2})}];return e.unit?[...t,{kind:"text",text:` ${e.unit}`}]:t};function FiguresPart({part:e,turn:t}){const i=(0,_mobileUi.useTheme)();return 0===e.figures.length?null:(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"list",accessibilityLabel:t.labels.figures,style:{flexDirection:"row",flexWrap:"wrap",gap:i.space.sm},children:withPositions(e.figures).map(({key:e,item:i})=>{const r=valueRunsOf(i),s=t.labels.figureStatus(i.status),u=(0,_chatCore.toFigureText)(i.label);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexBasis:"48%",flexGrow:1,minWidth:140},children:(0,_jsxRuntime.jsx)(_mobileUi.StatTile,{label:u,value:(0,_jsxRuntime.jsx)(_FigureText.FigureRuns,{runs:r,variant:"title",color:"primary",strong:!0}),tone:TONE[i.status],caption:s||void 0,accessibilityLabel:`${u}: ${(0,_FigureText.runsToText)(r)}${s?`, ${s}`:""}`})},e)})})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FiguresPart=FiguresPart;var _chatCore=require("@webority/chat-core"),_mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_FigureText=require("./FigureText.js"),_jsxRuntime=require("react/jsx-runtime");const TONE={Neutral:"neutral",Positive:"success",Caution:"warning",Negative:"danger"},withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),valueRunsOf=e=>{if(0!==e.value&&Math.abs(e.value)<.001)return(0,_chatCore.formatFigure)(e.value);const t=(0,_mobileCore.formatNumber)(e.value,{maximumFractionDigits:2});return[{kind:"text",text:e.value<0?t.replace("-","−"):t}]};function FiguresPart({part:e,turn:t}){const i=(0,_mobileUi.useTheme)();return 0===e.figures.length?null:(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"summary",accessibilityLabel:t.labels.figures,style:{flexDirection:"row",flexWrap:"wrap",gap:i.space.sm},children:withPositions(e.figures).map(({key:e,item:i})=>{const r=valueRunsOf(i),u=t.labels.figureStatus(i.status),a=(0,_chatCore.toFigureText)(i.label);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexGrow:1,minWidth:110},children:(0,_jsxRuntime.jsx)(_mobileUi.StatTile,{label:a,value:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"flex-end",flexWrap:"wrap"},children:[(0,_jsxRuntime.jsx)(_FigureText.FigureRuns,{runs:r,variant:"title",color:"primary",strong:!0}),i.unit?(0,_jsxRuntime.jsx)(_FigureText.FigureRuns,{runs:[{kind:"text",text:" "},...(0,_chatCore.toFigureRuns)(i.unit)],variant:"bodySmall",color:"secondary"}):null]}),tone:TONE[i.status],caption:u||void 0,accessibilityLabel:`${a}: ${(0,_FigureText.runsToText)(r)}${i.unit?` ${i.unit}`:""}${u?`, ${u}`:""}`})},e)})})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FilePart=FilePart;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_NoticePart=require("./NoticePart.js"),_jsxRuntime=require("react/jsx-runtime");function FilePart(e){const{part:t,message:i,turn:r}=e;if("File"!==t.kind){const e={kind:"Notice",code:"NeedsNewerApp",text:r.labels.needsNewerApp};return(0,_jsxRuntime.jsx)(_NoticePart.NoticePart,{part:e,message:i,turn:r})}const{openAttachment:s}=r;return(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:`${t.fileName} (${(0,_chatCore.formatFileSize)(t.length)})`,leftIcon:"paperclip",variant:"soft",size:"sm",accessibilityLabel:r.labels.fileOpen(t.fileName),onPress:s?()=>s(t):void 0})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FilePart=FilePart;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_NoticePart=require("./NoticePart.js"),_jsxRuntime=require("react/jsx-runtime");function FilePart(e){const{part:t,message:i,turn:r}=e;if("File"!==t.kind){const e={kind:"Notice",code:"NeedsNewerApp",text:r.labels.needsNewerApp};return(0,_jsxRuntime.jsx)(_NoticePart.NoticePart,{part:e,message:i,turn:r})}const{openAttachment:s}=r;return(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:`${t.fileName} (${(0,_chatCore.formatFileSize)(t.length)})`,leftIcon:"document-text",variant:"soft",size:"sm",accessibilityLabel:r.labels.fileOpen(t.fileName),onPress:s?()=>s(t):void 0})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HandoffPart=HandoffPart;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");function HandoffPart({part:e,turn:i}){const t=(0,_mobileUi.useTheme)(),{labels:a}=i,n=!i.isLast&&("Requested"===e.state||"Waiting"===e.state),s=e.agent?.displayName||a.agent,r=e.agent?.avatarUrl;let o;switch(e.state){case"Requested":o=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:t.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Spinner,{size:"sm"}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:a.handoffRequested})]});break;case"Waiting":o=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:t.space.xs},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:t.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Spinner,{size:"sm"}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:a.handoffWaiting})]}),"number"==typeof e.queuePosition?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:a.handoffQueued(e.queuePosition)}):null,(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:a.handoffQueuedText})]});break;case"Joined":o=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:t.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Avatar,{size:"sm",name:s,source:r?{uri:r}:void 0}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:a.handoffJoined(s)})]});break;case"Left":o=(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:a.handoffLeft(s)});break;case"Ended":o=(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:a.handoffEnded})}return(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",padding:"sm",accessibilityLiveRegion:n?void 0:"polite",children:o})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HandoffPart=HandoffPart;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");function HandoffPart({part:e,turn:i}){const t=(0,_mobileUi.useTheme)(),{labels:s}=i;if(!0===i.handoffSettled&&("Requested"===e.state||"Waiting"===e.state))return null;const a=i.isLast&&("Requested"===e.state||"Waiting"===e.state||"Joined"===e.state),n=e.agent?.displayName||s.handoffAgentFallback,r=e.agent?.avatarUrl;let o;switch(e.state){case"Requested":o=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:t.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Spinner,{size:"sm"}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:s.handoffRequested})]});break;case"Waiting":o=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:t.space.xs},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:t.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Spinner,{size:"sm"}),"number"==typeof e.queuePosition?null:(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:s.handoffWaiting})]}),"number"==typeof e.queuePosition?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.handoffQueued(e.queuePosition)}):null,(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.handoffQueuedText})]});break;case"Joined":o=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:t.space.xs},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:t.space.sm},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{position:"relative"},children:[(0,_jsxRuntime.jsx)(_mobileUi.Avatar,{size:"sm",name:n,source:r?{uri:r}:void 0}),(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:"absolute",right:0,bottom:0,width:8,height:8,borderRadius:t.radius.pill,backgroundColor:t.colors["success-text"]}})]}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:s.handoffJoined(n)})]}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.handoffJoinedText(n)})]});break;case"Left":o=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:t.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:s.handoffLeft(n)}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.handoffLeftText})]});break;case"Ended":o=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:t.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:s.handoffEnded}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.handoffEndedText})]})}return void 0===o?null:(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",padding:"sm",accessibilityLiveRegion:a?"polite":void 0,children:o})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ImagePart=ImagePart;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_RATIO=4/3;function ImagePart({part:e,turn:t}){const i=(0,_mobileUi.useTheme)(),a=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[s,l]=(0,_react.useState)(!1),r=t.attachmentUrl?t.attachmentUrl(e.attachmentId):void 0;if(void 0===r)return(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:e.alt});const n=null!==e.width&&null!==e.height&&e.width>0&&e.height>0?e.width/e.height:DEFAULT_RATIO,o=(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:e.alt});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"imagebutton",accessibilityLabel:t.labels.imageOpen(e.alt),onPress:()=>l(!0),children:(0,_jsxRuntime.jsx)(_mobileUi.AuthedImage,{uri:r,contentFit:"cover",accessible:!0,accessibilityLabel:e.alt,style:{width:"100%",aspectRatio:n,maxHeight:320,borderRadius:i.radius.md},fallback:o})}),(0,_jsxRuntime.jsx)(_mobileUi.Modal,{open:s,onClose:()=>l(!1),backdropPressClose:!1,presentation:"fullScreen",accessibilityLabel:e.alt,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1,backgroundColor:i.colors.bg},children:[(0,_jsxRuntime.jsx)(_mobileUi.ZoomableImage,{style:{flex:1},accessibilityLabel:e.alt,children:(0,_jsxRuntime.jsx)(_mobileUi.AuthedImage,{uri:r,contentFit:"contain",style:{flex:1},accessibilityLabel:e.alt})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:"absolute",top:a.top+i.space.sm,right:i.space.sm},children:(0,_jsxRuntime.jsx)(_mobileUi.Button,{variant:"soft",size:"sm",label:t.labels.close,onPress:()=>l(!1)})})]})})]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ImagePart=ImagePart;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_jsxRuntime=require("react/jsx-runtime");function ImagePart({part:e,turn:t}){const a=(0,_mobileUi.useTheme)(),i=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[s,l]=(0,_react.useState)(!1),[r,n]=(0,_react.useState)(null),[c,o]=(0,_react.useState)(!1),u=(0,_react.useRef)(t.loadAttachmentUrl);u.current=t.loadAttachmentUrl;const m=(0,_react.useRef)(0),b=(0,_react.useCallback)(e=>{const t=++m.current;n(null),o(!1),u.current(e).then(e=>{m.current===t&&n(e)},()=>{m.current===t&&o(!0)})},[]);if((0,_react.useEffect)(()=>(b(e.attachmentId),()=>{m.current++}),[e.attachmentId,b]),c)return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:a.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:e.alt}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{variant:"soft",size:"sm",label:t.labels.retry,onPress:()=>b(e.attachmentId),testID:`image-retry-${e.attachmentId}`})]});if(null===r)return(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:e.alt});const x=null!==e.width&&null!==e.height&&e.width>0&&e.height>0?e.width/e.height:null,_=(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:e.alt});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"imagebutton",accessibilityLabel:t.labels.imageOpen(e.alt),onPress:()=>l(!0),children:(0,_jsxRuntime.jsx)(_mobileUi.AuthedImage,{uri:r,contentFit:"contain",accessible:!0,accessibilityLabel:e.alt,labels:{loading:t.labels.imageLoading},style:{width:"100%",...null===x?{minHeight:160}:{aspectRatio:x},maxHeight:320,borderRadius:a.radius.md},fallback:_})}),(0,_jsxRuntime.jsx)(_mobileUi.Modal,{open:s,onClose:()=>l(!1),backdropPressClose:!1,presentation:"fullScreen",accessibilityLabel:e.alt,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1,backgroundColor:a.colors.bg},children:[(0,_jsxRuntime.jsx)(_mobileUi.ZoomableImage,{style:{flex:1},accessibilityLabel:e.alt,children:(0,_jsxRuntime.jsx)(_mobileUi.AuthedImage,{uri:r,contentFit:"contain",style:{flex:1},accessibilityLabel:e.alt})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:"absolute",top:i.top+a.space.sm,right:a.space.sm},children:(0,_jsxRuntime.jsx)(_mobileUi.Button,{variant:"soft",size:"sm",label:t.labels.close,onPress:()=>l(!1)})})]})})]})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.InputRequestPart=InputRequestPart;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_NoticePart=require("./NoticePart.js"),_jsxRuntime=require("react/jsx-runtime");const FIELD_TYPES=new Set(["Email","Phone","Name","Company","Text","LongText","Choice","MultiChoice","TimeSlot","File","Consent"]),isUndrawnField=(e,t)=>!FIELD_TYPES.has(e.type)||"File"===e.type&&!t,fileNameOf=(e,t)=>{const i=e.name;return"string"==typeof i&&""!==i?i:t},slotFormat=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short",hour:"numeric",minute:"2-digit"}),selectedIds=e=>""===e?[]:JSON.parse(e),KEYBOARD_TYPES={Email:"email-address",Phone:"phone-pad"},AUTO_COMPLETE={Email:"email",Phone:"tel",Name:"name",Company:"organization"},optionalSuffix=(e,t)=>e.required?"":` (${t.inputOptional})`;function OpenRequest({part:e,turn:t,pickAttachments:i}){const a=(0,_mobileUi.useTheme)(),{labels:s,features:l}=t,[n,r]=(0,_react.useState)({}),[o,u]=(0,_react.useState)({}),[c,d]=(0,_react.useState)(""),[p,m]=(0,_react.useState)(!1),[x,y]=(0,_react.useState)({}),setValue=(e,t)=>r(i=>({...i,[e]:t})),patchUpload=(e,t)=>y(i=>{const a=i[e];return a?{...i,[e]:{...a,...t}}:i}),b=Object.values(x).some(e=>"Ready"!==e.status),leave=async e=>{m(!0),d("");try{await e()}catch{d(s.errorGeneric),m(!1)}},_=l.LeadShortcuts,j=_&&1===e.fields.length&&!e.fields[0].required,h=_&&e.cancellable;return(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",padding:"sm",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:a.space.sm},children:[e.title?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:e.title}):null,_&&e.allowTyped?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.typeAnswer}):null,e.fields.map(e=>{const l=n[e.key]??"",r=o[e.key];if("File"===e.type){const l=x[e.key];return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:a.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:`${e.label}${optionalSuffix(e,s)}`}),l?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:a.space.xxs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:l.fileName,variant:"soft",onRemove:"Uploading"===l.status?void 0:()=>{return t=e.key,y(e=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))),void setValue(t,"");var t},labels:{remove:s.inputRemoveFile}}),"Uploading"===l.status?(0,_jsxRuntime.jsx)(_mobileUi.ProgressBar,{progress:l.progress??void 0,label:s.attachmentUploading,height:4}):null,"Failed"===l.status?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:s.attachmentFailed}):null]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row"},children:(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.inputChooseFile,variant:"soft",size:"sm",leftIcon:"paperclip",disabled:p,onPress:()=>{(async e=>{if(!i)return;let a;try{a=await i()}catch{return void d(s.errorGeneric)}const l=a[0];if(l){y(t=>({...t,[e.key]:{fileName:fileNameOf(l,e.label),status:"Uploading",progress:null}}));try{const i=await t.uploadInputFile(l,t=>patchUpload(e.key,{progress:t}));setValue(e.key,i),patchUpload(e.key,{status:"Ready",progress:null})}catch{setValue(e.key,""),patchUpload(e.key,{status:"Failed",progress:null})}}})(e)}})}),r?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:r}):null]},e.key)}if("MultiChoice"===e.type){const t=(e.options??[]).map(e=>({label:e.label,value:e.id}));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:a.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:`${e.label}${optionalSuffix(e,s)}`}),(0,_jsxRuntime.jsx)(_mobileUi.ChoiceGroup,{selectionMode:"multiple",options:t,value:selectedIds(l),onChange:i=>setValue(e.key,JSON.stringify(t.filter(e=>i.includes(e.value)).map(e=>e.value))),accessibilityLabel:e.label,error:r,disabled:p})]},e.key)}if("Choice"===e.type||"TimeSlot"===e.type){const t="TimeSlot"===e.type?(e.slots??[]).map(e=>({label:slotFormat.format(new Date(e.startDateTimeUtc)),value:e.id})):(e.options??[]).map(e=>({label:e.label,value:e.id}));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:a.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:`${e.label}${optionalSuffix(e,s)}`}),(0,_jsxRuntime.jsx)(_mobileUi.ChoiceGroup,{options:t,value:""===l?void 0:l,onChange:t=>setValue(e.key,String(t)),accessibilityLabel:e.label,error:r,disabled:p})]},e.key)}return"Consent"===e.type?(0,_jsxRuntime.jsx)(_mobileUi.Checkbox,{checked:"true"===l,onChange:t=>setValue(e.key,t?"true":"false"),label:`${e.consentText??e.label}${optionalSuffix(e,s)}`,error:r,disabled:p},e.key):(0,_jsxRuntime.jsx)(_mobileUi.Input,{label:e.label,placeholder:e.placeholder??void 0,value:l,onChangeText:t=>setValue(e.key,t),maxLength:e.maxLength??void 0,required:e.required,error:r,help:e.required?void 0:s.inputOptional,labelMode:"top",disabled:p,type:"LongText"===e.type?"textarea":e.secret?"password":"input",keyboardType:KEYBOARD_TYPES[e.type]??"default",autoCapitalize:"Email"===e.type?"none":void 0,autoComplete:AUTO_COMPLETE[e.type]},e.key)}),""!==c?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:c}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:a.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:p?s.inputSubmitting:e.submitLabel,loading:p,disabled:p||b,onPress:()=>{(async()=>{if(b)return;const i={},a={};for(const t of e.fields){const e=n[t.key]??"";if("Consent"===t.type){const l="true"===e;t.required&&!l&&(i[t.key]=s.inputConsentRequired),a[t.key]=l?"true":"false"}else if("Choice"===t.type||"TimeSlot"===t.type)t.required&&""===e&&(i[t.key]=s.inputRequired),a[t.key]=e;else if("MultiChoice"===t.type){const l=selectedIds(e);t.required&&0===l.length&&(i[t.key]=s.inputRequired),a[t.key]=JSON.stringify(l)}else if("File"===t.type)t.required&&""===e&&(i[t.key]=s.inputRequired),a[t.key]=e;else{const l=e.trim();t.required&&""===l&&(i[t.key]=s.inputRequired),a[t.key]=l}}if(u(i),!(Object.keys(i).length>0)){m(!0),d("");try{const i=await t.answerInput(e.requestId,a);if(i.ok)return;u(i.errors),d(i.message??"")}catch{d(s.errorGeneric)}m(!1)}})()}}),j?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.skip,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.skipInput(e.requestId))}}):null,h?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.cancel,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.cancelLead())}}):null]})]})})}function InputRequestPart(e){const{part:t,message:i,turn:a,pickAttachments:s}=e,l=void 0!==s;if("InputRequest"!==t.kind||t.fields.some(e=>isUndrawnField(e,l))){const e={kind:"Notice",code:"NeedsNewerApp",text:a.labels.needsNewerApp};return(0,_jsxRuntime.jsx)(_NoticePart.NoticePart,{part:e,message:i,turn:a})}return"Answered"===t.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:t.answeredSummary??a.labels.inputAnswered}):"Skipped"===t.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:a.labels.inputSkipped}):"Expired"===t.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:a.labels.inputExpired}):(0,_jsxRuntime.jsx)(OpenRequest,{part:t,turn:a,pickAttachments:s},t.requestId)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.InputRequestPart=InputRequestPart;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_NoticePart=require("./NoticePart.js"),_jsxRuntime=require("react/jsx-runtime");const FIELD_TYPES=new Set(["Email","Phone","Name","Company","Text","LongText","Choice","MultiChoice","TimeSlot","File","Consent"]),isUndrawnField=e=>!FIELD_TYPES.has(e.type),fileNameOf=(e,t)=>{const i=e.name;return"string"==typeof i&&""!==i?i:t},slotFormat=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short",hour:"numeric",minute:"2-digit"}),selectedIds=e=>""===e?[]:JSON.parse(e),KEYBOARD_TYPES={Email:"email-address",Phone:"phone-pad"},AUTO_COMPLETE={Email:"email",Phone:"tel",Name:"name",Company:"organization"},optionalSuffix=(e,t)=>e.required?"":` (${t.inputOptional})`,firstErrorKey=(e,t)=>e.find(e=>void 0!==t[e.key])?.key;function OpenRequest({part:e,turn:t,pickAttachments:i}){const r=(0,_mobileUi.useTheme)(),{labels:s,features:n}=t,[a,l]=(0,_react.useState)({}),[o,c]=(0,_react.useState)({}),[u,d]=(0,_react.useState)(""),[p,m]=(0,_react.useState)(!1),[y,x]=(0,_react.useState)({}),[_,b]=(0,_react.useState)({}),[f,j]=(0,_react.useState)({}),h=(0,_react.useRef)({}),v=(0,_react.useRef)({}),k=(0,_react.useRef)(y),R=(0,_react.useRef)(0),g=(0,_react.useRef)(!1),T=(0,_react.useCallback)(e=>{const t=h.current[e];if(t)return void t.focus();const i=v.current[e];if(!i)return;const r=(0,_reactNative.findNodeHandle)(i);null!==r&&_reactNative.AccessibilityInfo.setAccessibilityFocus(r)},[]);(0,_react.useEffect)(()=>{if(p||!g.current)return;g.current=!1;const t=firstErrorKey(e.fields,o);void 0!==t&&T(t)},[p,o,e.fields,T]);const setValue=(e,t)=>l(i=>({...i,[e]:t})),commitUploads=e=>{k.current=e,x(e)},patchUpload=(e,t)=>{const i=k.current[e];i&&commitUploads({...k.current,[e]:{...i,...t}})},isLiveUpload=(e,t)=>k.current[e]?.token===t,U=Object.values(y).some(e=>"Ready"!==e.status),leave=async e=>{m(!0),d("");try{await e()}catch{d(s.errorGeneric),m(!1)}},w=n.LeadShortcuts,S=w&&1===e.fields.length&&!e.fields[0].required,C=w&&e.cancellable;return(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",padding:"sm",accessibilityLabel:e.title||void 0,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.sm},children:[e.title?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",accessibilityRole:"header",children:e.title}):null,e.allowTyped?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.typeAnswer}):null,e.fields.map(n=>{const l=a[n.key]??"",c=o[n.key];if("File"===n.type){const e=y[n.key];return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:`${n.label}${optionalSuffix(n,s)}`}),e?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xxs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:e.fileName,variant:"soft",onRemove:()=>{return e=n.key,commitUploads(Object.fromEntries(Object.entries(k.current).filter(([t])=>t!==e))),void setValue(e,"");var e},labels:{remove:s.inputRemoveFile}}),"Uploading"===e.status?(0,_jsxRuntime.jsx)(_mobileUi.ProgressBar,{progress:e.progress??void 0,label:s.attachmentUploading,height:4}):null,"Failed"===e.status?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:s.attachmentFailed}):null]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row"},children:(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.inputChooseFile,variant:"soft",size:"sm",leftIcon:"paperclip",disabled:p||void 0===i,onPress:()=>{(async e=>{if(!i)return;let r;try{r=await i()}catch{return void d(s.errorGeneric)}const n=r[0];if(!n)return;R.current+=1;const a=R.current;commitUploads({...k.current,[e.key]:{fileName:fileNameOf(n,e.label),status:"Uploading",progress:null,token:a}});try{const i=await t.uploadInputFile(n,t=>{isLiveUpload(e.key,a)&&patchUpload(e.key,{progress:t})});isLiveUpload(e.key,a)&&(setValue(e.key,i),patchUpload(e.key,{status:"Ready",progress:null}))}catch{isLiveUpload(e.key,a)&&(setValue(e.key,""),patchUpload(e.key,{status:"Failed",progress:null}))}})(n)}})}),c?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:c}):null]},n.key)}if("MultiChoice"===n.type){const e=(n.options??[]).map(e=>({label:e.label,value:e.id}));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:`${n.label}${optionalSuffix(n,s)}`}),(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e=>{v.current[n.key]=e},children:(0,_jsxRuntime.jsx)(_mobileUi.ChoiceGroup,{selectionMode:"multiple",options:e,value:selectedIds(l),onChange:t=>setValue(n.key,JSON.stringify(e.filter(e=>t.includes(e.value)).map(e=>e.value))),accessibilityLabel:n.label,error:c,disabled:p})})]},n.key)}if("Choice"===n.type||"TimeSlot"===n.type){const e="TimeSlot"===n.type?(n.slots??[]).map(e=>({label:slotFormat.format(new Date(e.startDateTimeUtc)),value:e.id})):(n.options??[]).map(e=>({label:e.label,value:e.id}));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:`${n.label}${optionalSuffix(n,s)}`}),(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e=>{v.current[n.key]=e},children:(0,_jsxRuntime.jsx)(_mobileUi.ChoiceGroup,{options:e,value:""===l?void 0:l,onChange:e=>setValue(n.key,String(e)),accessibilityLabel:n.label,error:c,disabled:p})})]},n.key)}if("Consent"===n.type)return(0,_jsxRuntime.jsx)(_mobileUi.Checkbox,{checked:"true"===l,onChange:e=>setValue(n.key,e?"true":"false"),label:n.consentText??n.label,error:c,disabled:p},n.key);const u=(0,_jsxRuntime.jsx)(_mobileUi.Input,{ref:e=>{h.current[n.key]=e},label:n.label,placeholder:n.placeholder??void 0,value:l,onChangeText:e=>setValue(n.key,e),maxLength:n.maxLength??void 0,required:n.required,error:c,help:n.required?void 0:s.inputOptional,labelMode:"top",disabled:p,type:n.secret?"password":"LongText"===n.type?"textarea":"input",keyboardType:KEYBOARD_TYPES[n.type]??"default",autoCapitalize:"Email"===n.type?"none":void 0,autoComplete:AUTO_COMPLETE[n.type]},n.key);if(!("Otp"===n.verify&&("Email"===n.type||"Phone"===n.type)))return u;const m=f[n.key];return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[u,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.inputSendCode,variant:"soft",size:"sm",disabled:p,onPress:()=>{(async i=>{if("Otp"===i.verify)try{await t.sendOtp(e.requestId,{fieldKey:i.key,value:(a[i.key]??"").trim()}),j(e=>({...e,[i.key]:"sent"}))}catch{j(e=>({...e,[i.key]:"failed"}))}})(n)},testID:`otp-send-${n.key}`}),(0,_jsxRuntime.jsx)(_mobileUi.Input,{label:s.inputEnterCode,value:_[n.key]??"",onChangeText:e=>b(t=>({...t,[n.key]:e})),keyboardType:"number-pad",autoComplete:"one-time-code",disabled:p}),m?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"failed"===m?"danger":"secondary",accessibilityLiveRegion:"polite",children:"failed"===m?s.inputCodeFailed:s.inputCodeSent}):null]})]},n.key)}),""!==u?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:u}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:r.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:p?s.inputSubmitting:e.submitLabel,loading:p,disabled:p||U,onPress:()=>{(async()=>{if(U)return;const i={},r={};for(const t of e.fields){const e=a[t.key]??"";if("Consent"===t.type){const n="true"===e;t.required&&!n&&(i[t.key]=s.inputConsentRequired),r[t.key]=n?"true":"false"}else if("Choice"===t.type||"TimeSlot"===t.type)t.required&&""===e&&(i[t.key]=s.inputRequired),r[t.key]=e;else if("MultiChoice"===t.type){const n=selectedIds(e);t.required&&0===n.length&&(i[t.key]=s.inputRequired),r[t.key]=JSON.stringify(n)}else if("File"===t.type)t.required&&""===e&&(i[t.key]=s.inputRequired),r[t.key]=e;else{const n=t.secret?e:e.trim();t.required&&""===n&&(i[t.key]=s.inputRequired),r[t.key]=n}}const n={};for(const t of e.fields){if("Otp"!==t.verify)continue;const e=(_[t.key]??"").trim();""===e&&(i[t.key]=s.inputRequired),n[t.key]=e}if(c(i),Object.keys(i).length>0){const t=firstErrorKey(e.fields,i);return void(void 0!==t&&T(t))}m(!0),d("");try{const i=await t.answerInput(e.requestId,r,Object.keys(n).length>0?n:null);if(i.ok)return;c(i.errors),g.current=!0,d(i.message??"")}catch{d(s.errorGeneric)}m(!1)})()}}),U?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.attachmentUploading}):null,S?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.skip,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.skipInput(e.requestId))}}):null,C?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.cancel,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.cancelLead())}}):null]})]})})}function InputRequestPart(e){const{part:t,message:i,turn:r,pickAttachments:s}=e;if("InputRequest"!==t.kind||t.fields.some(isUndrawnField)){const e={kind:"Notice",code:"NeedsNewerApp",text:r.labels.needsNewerApp};return(0,_jsxRuntime.jsx)(_NoticePart.NoticePart,{part:e,message:i,turn:r})}return"Answered"===t.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:t.answeredSummary||r.labels.inputAnswered}):"Skipped"===t.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:r.labels.inputSkipped}):"Expired"===t.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:r.labels.inputExpired}):(0,_jsxRuntime.jsx)(OpenRequest,{part:t,turn:r,pickAttachments:s},t.requestId)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NoticePart=NoticePart;var _mobileUi=require("@webority/mobile-ui"),_jsxRuntime=require("react/jsx-runtime");function NoticePart({part:e}){const t="ActionLimitReached"===e.code||"AssistantUnavailable"===e.code?"warning":"info";return(0,_jsxRuntime.jsx)(_mobileUi.Banner,{message:e.text,tone:t,accessibilityRole:"summary"})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NoticePart=NoticePart;var _mobileUi=require("@webority/mobile-ui"),_jsxRuntime=require("react/jsx-runtime");function NoticePart({part:e}){const t="AssistantUnavailable"===e.code?"danger":"ActionLimitReached"===e.code||"ConversationTooLong"===e.code?"warning":"info";return(0,_jsxRuntime.jsx)(_mobileUi.Banner,{message:e.text,tone:t,accessibilityRole:"alert"})}