@everfur/sdk 0.1.1 → 0.4.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 (219) hide show
  1. package/CHANGELOG.md +703 -4
  2. package/README.md +63 -23
  3. package/consent/package.json +8 -0
  4. package/dist/Chat-BZZ-Py5l.d.ts +128 -0
  5. package/dist/Chat-Dq4fffIO.d.cts +128 -0
  6. package/dist/DepthViews-BG3E25MD.d.ts +16 -0
  7. package/dist/DepthViews-B_hIypI6.d.cts +19 -0
  8. package/dist/DepthViews-CL75jyRA.d.cts +16 -0
  9. package/dist/DepthViews-CkYri51q.d.ts +19 -0
  10. package/dist/ErrorPolicyPort-CNf4uQZP.d.cts +22 -0
  11. package/dist/ErrorPolicyPort-CwbfmxzJ.d.ts +22 -0
  12. package/dist/{EverfurResult-D92-uL82.d.cts → EverfurResult-DN9pL2Ab.d.cts} +11 -10
  13. package/dist/{EverfurResult-D92-uL82.d.ts → EverfurResult-DN9pL2Ab.d.ts} +11 -10
  14. package/dist/{PhotoController-BItt5M7u.d.cts → PhotoController-3l7MT9jA.d.cts} +1 -1
  15. package/dist/{PhotoController-D8zMTdcW.d.ts → PhotoController-vzY5bfY_.d.ts} +1 -1
  16. package/dist/animations/index.cjs +1 -1997
  17. package/dist/animations/index.d.cts +35 -35
  18. package/dist/animations/index.d.ts +35 -35
  19. package/dist/animations/index.js +1 -1972
  20. package/dist/attachments-BorG422I.d.cts +146 -0
  21. package/dist/attachments-BrUWQYNK.d.ts +257 -0
  22. package/dist/attachments-D_SECjr1.d.cts +257 -0
  23. package/dist/attachments-DpldrvIW.d.ts +146 -0
  24. package/dist/bookingCopy-CqtDYvCR.d.ts +732 -0
  25. package/dist/bookingCopy-SREvkG19.d.cts +732 -0
  26. package/dist/branding-CsRdeNwK.d.cts +566 -0
  27. package/dist/branding-CsRdeNwK.d.ts +566 -0
  28. package/dist/callCopy-DoQKG3-L.d.cts +40 -0
  29. package/dist/callCopy-DoQKG3-L.d.ts +40 -0
  30. package/dist/casesRepository-DwtZVsbj.d.cts +51 -0
  31. package/dist/casesRepository-v6QczS9N.d.ts +51 -0
  32. package/dist/chat/index.cjs +1 -1170
  33. package/dist/chat/index.d.cts +32 -53
  34. package/dist/chat/index.d.ts +32 -53
  35. package/dist/chat/index.js +1 -1167
  36. package/dist/client/index.cjs +9 -2315
  37. package/dist/client/index.d.cts +80 -16
  38. package/dist/client/index.d.ts +80 -16
  39. package/dist/client/index.js +9 -2215
  40. package/dist/{config-CiJ0PVBB.d.ts → config--Wu1Umhd.d.cts} +64 -26
  41. package/dist/{config-BSjBdxrZ.d.cts → config-C7eb_IMD.d.ts} +64 -26
  42. package/dist/consent/index.cjs +1 -0
  43. package/dist/consent/index.d.cts +33 -0
  44. package/dist/consent/index.d.ts +33 -0
  45. package/dist/consent/index.js +1 -0
  46. package/dist/context-CL3lyuy1.d.cts +159 -0
  47. package/dist/context-CahAEha8.d.ts +159 -0
  48. package/dist/copy-DdVFDL01.d.ts +198 -0
  49. package/dist/copy-UeUJVk8X.d.cts +198 -0
  50. package/dist/core/index.cjs +13 -3178
  51. package/dist/core/index.d.cts +164 -29
  52. package/dist/core/index.d.ts +164 -29
  53. package/dist/core/index.js +13 -3166
  54. package/dist/depth-D5HwcvKC.d.cts +533 -0
  55. package/dist/depth-DvPwPuT_.d.ts +533 -0
  56. package/dist/entitlementRepository-B7egEdW6.d.ts +43 -0
  57. package/dist/entitlementRepository-BpJ7tiwl.d.cts +43 -0
  58. package/dist/{identity-Brl-lDd6.d.cts → identity-C2-08BZW.d.cts} +20 -7
  59. package/dist/{identity-DK9zORrG.d.ts → identity-CEi9GRFZ.d.ts} +20 -7
  60. package/dist/{ids-CJ1S6adf.d.cts → ids-B2GAAifq.d.cts} +1 -1
  61. package/dist/{ids-CJ1S6adf.d.ts → ids-B2GAAifq.d.ts} +1 -1
  62. package/dist/index.cjs +12 -4494
  63. package/dist/index.d.cts +30 -121
  64. package/dist/index.d.ts +30 -121
  65. package/dist/index.js +12 -4470
  66. package/dist/models-B-Uh2LTf.d.ts +214 -0
  67. package/dist/models-D2EUxPZY.d.cts +214 -0
  68. package/dist/notifications/index.cjs +2 -0
  69. package/dist/notifications/index.d.cts +17 -0
  70. package/dist/notifications/index.d.ts +17 -0
  71. package/dist/notifications/index.js +2 -0
  72. package/dist/optionalModule-DbJmsq5f.d.cts +21 -0
  73. package/dist/optionalModule-DbJmsq5f.d.ts +21 -0
  74. package/dist/pets-DJv2sj2H.d.ts +92 -0
  75. package/dist/pets-JVCXgRgR.d.cts +92 -0
  76. package/dist/petsRepository-B_gKbAzJ.d.cts +142 -0
  77. package/dist/petsRepository-Bk6GDwLs.d.ts +142 -0
  78. package/dist/photo/index.cjs +1 -2189
  79. package/dist/photo/index.d.cts +6 -6
  80. package/dist/photo/index.d.ts +6 -6
  81. package/dist/photo/index.js +1 -2186
  82. package/dist/ports-BN6RHF9W.d.cts +48 -0
  83. package/dist/ports-BN6RHF9W.d.ts +48 -0
  84. package/dist/ports-BY2ph0_y.d.cts +376 -0
  85. package/dist/ports-D7YW8qz9.d.ts +376 -0
  86. package/dist/profile-CSs1wlXT.d.cts +93 -0
  87. package/dist/profile-CSs1wlXT.d.ts +93 -0
  88. package/dist/records/depth/index.cjs +2 -0
  89. package/dist/records/depth/index.d.cts +13 -0
  90. package/dist/records/depth/index.d.ts +13 -0
  91. package/dist/records/depth/index.js +2 -0
  92. package/dist/records/index.cjs +3 -2839
  93. package/dist/records/index.d.cts +137 -203
  94. package/dist/records/index.d.ts +137 -203
  95. package/dist/records/index.js +3 -2833
  96. package/dist/requestFunnel-BjDpqqvm.d.cts +110 -0
  97. package/dist/requestFunnel-DFMGcluw.d.ts +110 -0
  98. package/dist/{resolve-Dq_4_agU.d.ts → resolve-D4Ywz5OS.d.cts} +10 -4
  99. package/dist/{resolve-Dq_4_agU.d.cts → resolve-D4Ywz5OS.d.ts} +10 -4
  100. package/dist/{runtime-Bvr8yqXm.d.cts → runtimeTypes-gZEJu-da.d.cts} +104 -132
  101. package/dist/{runtime-BIYzf9cK.d.ts → runtimeTypes-w5KqBMcs.d.ts} +104 -132
  102. package/dist/server/events/index.cjs +2 -0
  103. package/dist/server/events/index.d.cts +550 -0
  104. package/dist/server/events/index.d.ts +550 -0
  105. package/dist/server/events/index.js +2 -0
  106. package/dist/server/index.cjs +2 -533
  107. package/dist/server/index.d.cts +73 -18
  108. package/dist/server/index.d.ts +73 -18
  109. package/dist/server/index.js +2 -530
  110. package/dist/species-BXAIMh7I.d.cts +9 -0
  111. package/dist/species-BXAIMh7I.d.ts +9 -0
  112. package/dist/televet/booking/index.cjs +1 -0
  113. package/dist/televet/booking/index.d.cts +294 -0
  114. package/dist/televet/booking/index.d.ts +294 -0
  115. package/dist/televet/booking/index.js +1 -0
  116. package/dist/televet/call/index.cjs +1 -0
  117. package/dist/televet/call/index.d.cts +141 -0
  118. package/dist/televet/call/index.d.ts +141 -0
  119. package/dist/televet/call/index.js +1 -0
  120. package/dist/televet/index.cjs +1 -0
  121. package/dist/televet/index.d.cts +142 -0
  122. package/dist/televet/index.d.ts +142 -0
  123. package/dist/televet/index.js +1 -0
  124. package/dist/testing/index.cjs +5 -823
  125. package/dist/testing/index.d.cts +18 -4
  126. package/dist/testing/index.d.ts +18 -4
  127. package/dist/testing/index.js +5 -820
  128. package/dist/testing/rn/index.cjs +1 -449
  129. package/dist/testing/rn/index.d.cts +18 -29
  130. package/dist/testing/rn/index.d.ts +18 -29
  131. package/dist/testing/rn/index.js +1 -444
  132. package/dist/testing/web/index.cjs +1 -0
  133. package/dist/testing/web/index.d.cts +132 -0
  134. package/dist/testing/web/index.d.ts +132 -0
  135. package/dist/testing/web/index.js +1 -0
  136. package/dist/timelineRows-C15jxFFH.d.ts +19 -0
  137. package/dist/timelineRows-odO8g9r2.d.cts +19 -0
  138. package/dist/typeStyle-CKqVYD6L.d.cts +111 -0
  139. package/dist/typeStyle-DmoyacDG.d.ts +111 -0
  140. package/dist/uploadTransport-D0M0T4hN.d.ts +38 -0
  141. package/dist/uploadTransport-DKJHs3Yj.d.cts +38 -0
  142. package/dist/useRecordsDepth-C6rjEaLn.d.cts +237 -0
  143. package/dist/useRecordsDepth-crhBllQK.d.ts +237 -0
  144. package/dist/useVetVisit-Bc84hWUU.d.cts +187 -0
  145. package/dist/useVetVisit-CjmMa896.d.ts +187 -0
  146. package/dist/video/index.cjs +1 -1941
  147. package/dist/video/index.d.cts +4 -4
  148. package/dist/video/index.d.ts +4 -4
  149. package/dist/video/index.js +1 -1938
  150. package/dist/view-Bxwxp4xD.d.ts +310 -0
  151. package/dist/view-DyitEO0m.d.cts +310 -0
  152. package/dist/visitIntent-D7_yVp1I.d.cts +8 -0
  153. package/dist/visitIntent-D7_yVp1I.d.ts +8 -0
  154. package/dist/web/consent/index.cjs +1 -0
  155. package/dist/web/consent/index.d.cts +34 -0
  156. package/dist/web/consent/index.d.ts +34 -0
  157. package/dist/web/consent/index.js +1 -0
  158. package/dist/web/index.cjs +14 -0
  159. package/dist/web/index.d.cts +218 -0
  160. package/dist/web/index.d.ts +218 -0
  161. package/dist/web/index.js +14 -0
  162. package/dist/web/notifications/index.cjs +2 -0
  163. package/dist/web/notifications/index.d.cts +213 -0
  164. package/dist/web/notifications/index.d.ts +213 -0
  165. package/dist/web/notifications/index.js +2 -0
  166. package/dist/web/records/depth/index.cjs +2 -0
  167. package/dist/web/records/depth/index.d.cts +12 -0
  168. package/dist/web/records/depth/index.d.ts +12 -0
  169. package/dist/web/records/depth/index.js +2 -0
  170. package/dist/web/records/index.cjs +4 -0
  171. package/dist/web/records/index.d.cts +285 -0
  172. package/dist/web/records/index.d.ts +285 -0
  173. package/dist/web/records/index.js +4 -0
  174. package/dist/web/televet/booking/index.cjs +1 -0
  175. package/dist/web/televet/booking/index.d.cts +349 -0
  176. package/dist/web/televet/booking/index.d.ts +349 -0
  177. package/dist/web/televet/booking/index.js +1 -0
  178. package/dist/web/televet/call/index.cjs +1 -0
  179. package/dist/web/televet/call/index.d.cts +142 -0
  180. package/dist/web/televet/call/index.d.ts +142 -0
  181. package/dist/web/televet/call/index.js +1 -0
  182. package/dist/web/televet/index.cjs +1 -0
  183. package/dist/web/televet/index.d.cts +136 -0
  184. package/dist/web/televet/index.d.ts +136 -0
  185. package/dist/web/televet/index.js +1 -0
  186. package/notifications/package.json +8 -0
  187. package/package.json +266 -10
  188. package/records/depth/package.json +8 -0
  189. package/server/events/device-blocked.cjs +15 -0
  190. package/server/events/package.json +9 -0
  191. package/televet/booking/package.json +8 -0
  192. package/televet/call/package.json +8 -0
  193. package/televet/package.json +8 -0
  194. package/testing/web/native-blocked.cjs +12 -0
  195. package/testing/web/package.json +8 -0
  196. package/web/consent/native-blocked.cjs +12 -0
  197. package/web/consent/package.json +8 -0
  198. package/web/native-blocked.cjs +12 -0
  199. package/web/notifications/native-blocked.cjs +12 -0
  200. package/web/notifications/package.json +8 -0
  201. package/web/package.json +8 -0
  202. package/web/records/depth/native-blocked.cjs +12 -0
  203. package/web/records/depth/package.json +8 -0
  204. package/web/records/native-blocked.cjs +12 -0
  205. package/web/records/package.json +8 -0
  206. package/web/televet/booking/native-blocked.cjs +12 -0
  207. package/web/televet/booking/package.json +8 -0
  208. package/web/televet/call/native-blocked.cjs +12 -0
  209. package/web/televet/call/package.json +8 -0
  210. package/web/televet/native-blocked.cjs +12 -0
  211. package/web/televet/package.json +8 -0
  212. package/dist/ChatController-CKdBvPj2.d.ts +0 -146
  213. package/dist/ChatController-CpUMvvZf.d.cts +0 -146
  214. package/dist/FilePort-BabWrv7I.d.cts +0 -22
  215. package/dist/FilePort-BabWrv7I.d.ts +0 -22
  216. package/dist/petsRepository-BEGb97M9.d.cts +0 -326
  217. package/dist/petsRepository-Bu18r2kK.d.ts +0 -326
  218. package/dist/requestFunnel-DuUH-kAe.d.cts +0 -28
  219. package/dist/requestFunnel-dio5OmR9.d.ts +0 -28
@@ -1,1167 +1 @@
1
- import { createContext, useState, useEffect, useCallback, useSyncExternalStore, useMemo, useContext, useRef } from 'react';
2
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
3
- import { KeyboardAvoidingView, View, Text, Platform, TextInput, Pressable, ActivityIndicator, ScrollView, StyleSheet, Animated } from 'react-native';
4
- import { jsx, jsxs } from 'react/jsx-runtime';
5
-
6
- // src/rn/chat/useChat.ts
7
- var CONTRACT_RETRYABILITY = Object.freeze([
8
- Object.freeze({ wireCode: "AccessDeniedException", envelope: "http_envelope", httpStatus: 403, retryable: false }),
9
- Object.freeze({ wireCode: "AuthorizationException", envelope: "http_envelope", httpStatus: 401, retryable: false }),
10
- Object.freeze({ wireCode: "ConflictException", envelope: "http_envelope", httpStatus: 409, retryable: true }),
11
- Object.freeze({ wireCode: "DAILY_QUOTA_EXCEEDED", envelope: "http_envelope", httpStatus: 429, retryable: true }),
12
- Object.freeze({ wireCode: "IDEMPOTENCY_KEY_IN_FLIGHT", envelope: "http_envelope", httpStatus: 409, retryable: true }),
13
- Object.freeze({ wireCode: "IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST", envelope: "http_envelope", httpStatus: 409, retryable: false }),
14
- Object.freeze({ wireCode: "InternalFailureException", envelope: "http_envelope", httpStatus: 500, retryable: true }),
15
- Object.freeze({ wireCode: "NotImplementedException", envelope: "http_envelope", httpStatus: 501, retryable: false }),
16
- Object.freeze({ wireCode: "PaymentRequiredException", envelope: "http_envelope", httpStatus: 402, retryable: false }),
17
- Object.freeze({ wireCode: "ResourceNotFoundException", envelope: "http_envelope", httpStatus: 404, retryable: false }),
18
- Object.freeze({ wireCode: "ServiceUnavailableException", envelope: "http_envelope", httpStatus: 503, retryable: true }),
19
- Object.freeze({ wireCode: "TIER_UPGRADE_REQUIRED", envelope: "http_envelope", httpStatus: 402, retryable: false }),
20
- Object.freeze({ wireCode: "ThrottlingException", envelope: "http_envelope", httpStatus: 429, retryable: true }),
21
- Object.freeze({ wireCode: "ValidationException", envelope: "http_envelope", httpStatus: 400, retryable: false }),
22
- Object.freeze({ wireCode: "accessDenied", envelope: "http_envelope", httpStatus: 403, retryable: false }),
23
- Object.freeze({ wireCode: "authExpired", envelope: "http_envelope", httpStatus: 401, retryable: true }),
24
- Object.freeze({ wireCode: "internal_error", envelope: "sse_frame", httpStatus: 200, retryable: false }),
25
- Object.freeze({ wireCode: "invalidRequest", envelope: "http_envelope", httpStatus: 400, retryable: false }),
26
- Object.freeze({ wireCode: "not_found", envelope: "sse_frame", httpStatus: 200, retryable: false }),
27
- Object.freeze({ wireCode: "session_required", envelope: "http_envelope", httpStatus: 403, retryable: false }),
28
- Object.freeze({ wireCode: "timeout", envelope: "sse_frame", httpStatus: 200, retryable: true }),
29
- Object.freeze({ wireCode: "unavailable", envelope: "http_envelope", httpStatus: 503, retryable: true })
30
- ]);
31
- Object.freeze(
32
- CONTRACT_RETRYABILITY.map((row) => row.wireCode)
33
- );
34
-
35
- // src/client/errors/contract.ts
36
- var NORMALIZED_FOLD = Object.freeze({
37
- // the default status-mapped envelope
38
- ValidationException: "validationFailed",
39
- AuthorizationException: "authRejected",
40
- PaymentRequiredException: "paymentRequired",
41
- AccessDeniedException: "accessDenied",
42
- ResourceNotFoundException: "resourceNotFound",
43
- ConflictException: "conflict",
44
- ThrottlingException: "rateLimited",
45
- InternalFailureException: "internalError",
46
- NotImplementedException: "notImplemented",
47
- ServiceUnavailableException: "serviceUnavailable",
48
- // dict-detail codes on the widget surface
49
- authExpired: "authExpired",
50
- unavailable: "serviceUnavailable",
51
- session_required: "sessionRequired",
52
- accessDenied: "accessDenied",
53
- invalidRequest: "sdkUpdateRequired",
54
- // typed codes
55
- IDEMPOTENCY_KEY_IN_FLIGHT: "idempotencyInFlight",
56
- IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST: "idempotencyConflict",
57
- DAILY_QUOTA_EXCEEDED: "quotaExceeded",
58
- TIER_UPGRADE_REQUIRED: "paymentRequired",
59
- // SSE error frames
60
- not_found: "conversationNotFound",
61
- timeout: "streamTimeout",
62
- internal_error: "internalError"
63
- });
64
- var CONTRACT_ERROR_ROWS = Object.freeze(
65
- CONTRACT_RETRYABILITY.map(
66
- (generated) => Object.freeze({
67
- wireCode: generated.wireCode,
68
- envelope: generated.envelope,
69
- retryable: generated.retryable,
70
- normalized: NORMALIZED_FOLD[generated.wireCode]
71
- })
72
- )
73
- );
74
- var BY_UPPER = new Map(
75
- CONTRACT_ERROR_ROWS.map((r) => [r.wireCode.toUpperCase(), r])
76
- );
77
- function contractErrorFor(wireCode) {
78
- if (typeof wireCode !== "string") return void 0;
79
- const key = wireCode.trim().toUpperCase();
80
- return key.length > 0 ? BY_UPPER.get(key) : void 0;
81
- }
82
- var CATEGORY_OF = Object.freeze({
83
- // the caller's sign-in state is wrong and a credential change is the remedy
84
- authExpired: "authentication",
85
- authRejected: "authentication",
86
- sessionRequired: "authentication",
87
- // signed in, correctly identified, and still not allowed
88
- accessDenied: "authorization",
89
- // a plan gate, not a permission failure: the remedy is commercial
90
- paymentRequired: "entitlement",
91
- // slow down / come back later
92
- quotaExceeded: "rateLimit",
93
- rateLimited: "rateLimit",
94
- // the request itself was wrong; retrying it unchanged can never succeed
95
- validationFailed: "invalidRequest",
96
- sdkUpdateRequired: "invalidRequest",
97
- // the target is gone, hidden, or was never visible to this caller
98
- conversationNotFound: "notFound",
99
- petNotFound: "notFound",
100
- resourceNotFound: "notFound",
101
- // something else already holds the thing
102
- conflict: "conflict",
103
- idempotencyConflict: "conflict",
104
- idempotencyInFlight: "conflict",
105
- // the pipe, not the request: timeouts, drops, a briefly unreachable dependency
106
- streamTimeout: "connection",
107
- streamIncomplete: "connection",
108
- upstreamLlmTimeout: "connection",
109
- serviceUnavailable: "connection",
110
- // the server admits fault
111
- internalError: "server",
112
- notImplemented: "server",
113
- mediaUploadFailed: "media",
114
- moderationBlocked: "policy",
115
- unknown: "unknown"
116
- });
117
- function categoryFor(code) {
118
- return CATEGORY_OF[code];
119
- }
120
-
121
- // src/client/errors/EverfurError.ts
122
- var USER_FACING_COPY = Object.freeze({
123
- authExpired: "Please sign in again to continue.",
124
- authRejected: "Please sign in again to continue.",
125
- sessionRequired: "This app needs to be updated to keep using Everfur.",
126
- accessDenied: "This feature isn't available on your account right now.",
127
- paymentRequired: "This is part of a paid plan.",
128
- quotaExceeded: "You have used today's messages. This resets tomorrow.",
129
- rateLimited: "You are sending messages quickly. Try again in a few seconds.",
130
- validationFailed: "Something in that request was not right. Check the details and try again.",
131
- sdkUpdateRequired: "This app needs to be updated to keep using Everfur.",
132
- conflict: "That is already running. Wait for it to finish, then try again.",
133
- idempotencyConflict: "That message was already delivered.",
134
- idempotencyInFlight: "That is still processing. Give it a moment.",
135
- conversationNotFound: "This conversation is no longer available.",
136
- petNotFound: "We could not find that pet. Please pick a pet and try again.",
137
- resourceNotFound: "We could not find that.",
138
- streamTimeout: "The response timed out. Tap retry to try again.",
139
- mediaUploadFailed: "We could not upload that photo. Please attach it again.",
140
- moderationBlocked: "This request cannot be answered here.",
141
- upstreamLlmTimeout: "The response timed out. Tap retry to try again.",
142
- internalError: "We hit a snag on our end. Please try again.",
143
- notImplemented: "That is not available yet.",
144
- serviceUnavailable: "That service is briefly unavailable. Try again shortly.",
145
- streamIncomplete: "The connection dropped mid-answer. Tap retry to continue.",
146
- unknown: "Something went wrong. Please try again."
147
- });
148
- function userFacingError(code) {
149
- return USER_FACING_COPY[code];
150
- }
151
- function defineHidden(target, key, value) {
152
- Object.defineProperty(target, key, {
153
- value,
154
- enumerable: false,
155
- writable: false,
156
- configurable: false
157
- });
158
- }
159
- function makeEverfurError(code, opts) {
160
- contractErrorFor(opts?.wireCode);
161
- const error = {
162
- code,
163
- category: categoryFor(code),
164
- retryable: opts?.retryable,
165
- displayMessage: userFacingError(code)
166
- };
167
- if (opts?.httpStatus !== void 0) error.httpStatus = opts.httpStatus;
168
- if (opts?.requestId) error.requestId = opts.requestId;
169
- if (opts?.wireMessage) defineHidden(error, "wireMessage", opts.wireMessage);
170
- if (opts?.raw !== void 0 && opts.raw !== null) defineHidden(error, "raw", opts.raw);
171
- return Object.freeze(error);
172
- }
173
-
174
- // src/client/errors/EverfurResult.ts
175
- function ok(value, warning) {
176
- return Object.freeze(
177
- { ok: true, value }
178
- );
179
- }
180
- function err(error) {
181
- return Object.freeze({ ok: false, error });
182
- }
183
- var EverfurConfigError = class _EverfurConfigError extends Error {
184
- constructor(kind, message) {
185
- super(message);
186
- this.name = "EverfurConfigError";
187
- this.kind = kind;
188
- Object.setPrototypeOf(this, _EverfurConfigError.prototype);
189
- }
190
- };
191
-
192
- // src/client/protocol/frames.ts
193
- function assertNever(x) {
194
- throw new Error(
195
- `assertNever: unhandled discriminated-union member ${JSON.stringify(x)}`
196
- );
197
- }
198
-
199
- // src/core/chat/ChatController.ts
200
- var MESSAGE_MAX_CHARS = 4e3;
201
-
202
- // src/client/entitlements/resolve.ts
203
- var REQUIRES = Object.freeze({
204
- chat: Object.freeze(["chat.message.create"]),
205
- records: Object.freeze(["records.upload.create", "records.record.read"]),
206
- video: Object.freeze(["video.gait.execute"]),
207
- photo: Object.freeze(["photo.checkup.execute"]),
208
- animations: Object.freeze(["animations.state.read"])
209
- });
210
- function requires(name) {
211
- return REQUIRES[name];
212
- }
213
- function decideCapability(name, decisions, opts) {
214
- if (opts?.isPending === true) {
215
- return freezeDecision({ name, enabled: false, isPending: true, limits: {} });
216
- }
217
- const keys = requires(name);
218
- const byResource = /* @__PURE__ */ new Map();
219
- for (const decision of decisions) byResource.set(decision.resource, decision);
220
- const limits = mergeLimits(keys, byResource);
221
- const missing = keys.filter((key) => byResource.get(key)?.granted !== true);
222
- if (missing.length === 0) {
223
- return freezeDecision({ name, enabled: true, isPending: false, limits });
224
- }
225
- return freezeDecision({
226
- name,
227
- enabled: false,
228
- isPending: false,
229
- limits,
230
- disabled: disabledFor(keys, byResource)
231
- });
232
- }
233
- function mergeLimits(keys, byResource) {
234
- const out = {};
235
- for (const key of keys) {
236
- const decisionLimits = byResource.get(key)?.limits;
237
- if (!decisionLimits) continue;
238
- for (const [limitKey, limitValue] of Object.entries(decisionLimits)) {
239
- const existing = out[limitKey];
240
- out[limitKey] = existing === void 0 ? limitValue : Math.min(existing, limitValue);
241
- }
242
- }
243
- return out;
244
- }
245
- function disabledFor(keys, byResource) {
246
- for (const key of keys) {
247
- const explicit = byResource.get(key)?.disabled;
248
- if (explicit) {
249
- return Object.freeze({
250
- reason: explicit.reason,
251
- level: explicit.level,
252
- recoverable: explicit.recoverable
253
- });
254
- }
255
- }
256
- return Object.freeze({
257
- reason: userFacingError("accessDenied"),
258
- level: "user_entitlement",
259
- recoverable: false
260
- });
261
- }
262
- function freezeDecision(d) {
263
- const base = {
264
- name: d.name,
265
- enabled: d.enabled,
266
- isPending: d.isPending,
267
- limits: Object.freeze({ ...d.limits })
268
- };
269
- if (d.disabled !== void 0) base.disabled = d.disabled;
270
- return Object.freeze(base);
271
- }
272
-
273
- // src/client/theme/tokens.ts
274
- function deepFreeze(value) {
275
- if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
276
- Object.freeze(value);
277
- for (const key of Object.keys(value)) {
278
- deepFreeze(value[key]);
279
- }
280
- }
281
- return value;
282
- }
283
- var SPACE = { xs: 4, sm: 8, md: 12, lg: 16, xl: 24, xxl: 32 };
284
- var RADIUS = { tile: 5, xs: 6, sm: 10, md: 14, lg: 20, xl: 28, pill: 500 };
285
- var TYPE_SIZE = {
286
- nano: 8,
287
- small: 9,
288
- micro: 10,
289
- tiny: 11,
290
- caption: 12,
291
- bodyTight: 13,
292
- body: 14,
293
- subtitle: 16,
294
- heading: 18,
295
- verdict: 24
296
- };
297
- var LINE_HEIGHT = { tight: 1.15, snug: 1.3, normal: 1.4, relaxed: 1.55 };
298
- var WEIGHT = { regular: "400", medium: "500", bold: "700" };
299
- var LETTER_SPACING = {
300
- eyebrow: 1,
301
- monoWide: 0.9,
302
- headerBrand: -0.42,
303
- tight: -0.35
304
- };
305
- function baseType() {
306
- return {
307
- family: "System",
308
- mono: "monospace",
309
- fontUrl: null,
310
- size: TYPE_SIZE,
311
- lineHeight: LINE_HEIGHT,
312
- weight: WEIGHT,
313
- letterSpacing: LETTER_SPACING
314
- };
315
- }
316
- var MOTION = {
317
- duration: { instant: 80, fast: 140, normal: 220, slow: 320 },
318
- spring: { gentle: { damping: 18, stiffness: 200 } },
319
- easing: { standard: "cubic-bezier(0.4, 0, 0.2, 1)" },
320
- reducedMotion: false
321
- };
322
- var LIGHT_COLOR = {
323
- brand: "#10462E",
324
- brandSoft: "rgba(16,70,46,0.10)",
325
- brandSofter: "rgba(16,70,46,0.15)",
326
- brandBorder: "rgba(16,70,46,0.18)",
327
- borderHairlineGreen: "rgba(16,70,46,0.25)",
328
- surface: "#FFFFFF",
329
- surfaceCream: "#FDFBF8",
330
- surfaceSubtle: "#EFE9E3",
331
- background: "#FFFFFF",
332
- borderRingCream: "#D8D2C8",
333
- text: {
334
- primary: "#111111",
335
- secondary: "#0E462E",
336
- muted: "#6E6660",
337
- placeholder: "rgba(0,0,0,0.30)",
338
- onBrand: "#FFFFFF",
339
- metaCool: "#3D3D3D"
340
- },
341
- primary: "#10462E",
342
- onPrimary: "#FFFFFF",
343
- accent: "#10462E",
344
- onAccent: "#FFFFFF",
345
- accentEdge: "#07C168",
346
- success: "#07C168",
347
- danger: "#B91C1C",
348
- errorRed: "#FF1B00",
349
- warningStrong: "#A45610",
350
- cautionAccent: "#D9821D",
351
- riskConcern: "#EFA700",
352
- badgeBgPositive: "rgba(7,193,104,0.12)",
353
- badgeBgCaution: "rgba(217,130,29,0.14)",
354
- badgeBgCritical: "rgba(185,28,28,0.12)",
355
- badgeBgNeutral: "rgba(110,102,96,0.12)",
356
- bubbleUser: "#10462E",
357
- bubbleAssistant: "#FFFFFF",
358
- skeleton: "#EFE9E3",
359
- scanButtonPink: "#FFC3BC",
360
- checkupCardLowRiskBg: "rgba(7,193,104,0.10)",
361
- checkupCardConcernBg: "rgba(239,167,0,0.10)"
362
- };
363
- var EVERFUR_LIGHT = deepFreeze({
364
- brightness: "light",
365
- meta: { displayName: "Everfur", logoUrl: null, placeholder: null, hidePoweredBy: false },
366
- color: LIGHT_COLOR,
367
- space: SPACE,
368
- radius: RADIUS,
369
- type: baseType(),
370
- motion: MOTION
371
- });
372
- var DARK_COLOR = {
373
- brand: "#6BD39A",
374
- brandSoft: "rgba(107,211,154,0.12)",
375
- brandSofter: "rgba(107,211,154,0.18)",
376
- brandBorder: "rgba(107,211,154,0.22)",
377
- borderHairlineGreen: "rgba(107,211,154,0.28)",
378
- surface: "#1C1F23",
379
- surfaceCream: "#23272C",
380
- surfaceSubtle: "#23272C",
381
- background: "#15171A",
382
- borderRingCream: "#3A3F45",
383
- text: {
384
- primary: "#F5F3F0",
385
- secondary: "#A9E4C4",
386
- muted: "#9A938C",
387
- placeholder: "rgba(255,255,255,0.35)",
388
- onBrand: "#0E1F17",
389
- metaCool: "#C9C9C9"
390
- },
391
- primary: "#6BD39A",
392
- onPrimary: "#0E1F17",
393
- accent: "#6BD39A",
394
- onAccent: "#0E1F17",
395
- accentEdge: "#34D888",
396
- success: "#07C168",
397
- danger: "#B91C1C",
398
- errorRed: "#FF1B00",
399
- warningStrong: "#A45610",
400
- cautionAccent: "#D9821D",
401
- riskConcern: "#EFA700",
402
- badgeBgPositive: "rgba(7,193,104,0.18)",
403
- badgeBgCaution: "rgba(217,130,29,0.20)",
404
- badgeBgCritical: "rgba(185,28,28,0.22)",
405
- badgeBgNeutral: "rgba(255,255,255,0.10)",
406
- bubbleUser: "#6BD39A",
407
- bubbleAssistant: "#1C1F23",
408
- skeleton: "#23272C",
409
- scanButtonPink: "#FFC3BC",
410
- checkupCardLowRiskBg: "rgba(7,193,104,0.16)",
411
- checkupCardConcernBg: "rgba(239,167,0,0.16)"
412
- };
413
- deepFreeze({
414
- brightness: "dark",
415
- meta: { displayName: "Everfur", logoUrl: null, placeholder: null, hidePoweredBy: false },
416
- color: DARK_COLOR,
417
- space: SPACE,
418
- radius: RADIUS,
419
- type: baseType(),
420
- motion: MOTION
421
- });
422
- var EVERFUR_THEME_CONTEXT_SYMBOL = /* @__PURE__ */ Symbol.for("@everfur/sdk#EverfurThemeContext@v1");
423
- var globalThemeHost = globalThis;
424
- var EverfurThemeContext = globalThemeHost[EVERFUR_THEME_CONTEXT_SYMBOL] ?? (globalThemeHost[EVERFUR_THEME_CONTEXT_SYMBOL] = createContext(EVERFUR_LIGHT));
425
- EverfurThemeContext.displayName ??= "EverfurThemeContext";
426
- function useEverfurTheme() {
427
- return useContext(EverfurThemeContext);
428
- }
429
-
430
- // src/rn/facade.ts
431
- var EVERFUR_CONTEXT_SYMBOL = /* @__PURE__ */ Symbol.for("@everfur/sdk#EverfurContext@v1");
432
- var globalContextHost = globalThis;
433
- var EverfurContext = globalContextHost[EVERFUR_CONTEXT_SYMBOL] ?? (globalContextHost[EVERFUR_CONTEXT_SYMBOL] = createContext(null));
434
- EverfurContext.displayName ??= "EverfurContext";
435
- function useEverfurContext() {
436
- const ctx = useContext(EverfurContext);
437
- if (ctx === null) {
438
- throw new EverfurConfigError(
439
- "not-initialized",
440
- "Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high."
441
- );
442
- }
443
- return ctx;
444
- }
445
-
446
- // src/rn/chat/useChat.ts
447
- var BOOTSTRAP_SNAPSHOT = Object.freeze({
448
- status: "idle",
449
- messages: Object.freeze([]),
450
- conversationId: null,
451
- error: null,
452
- isStreaming: false,
453
- isBootstrapping: true,
454
- suggestedPrompts: Object.freeze([])
455
- });
456
- function useEverfurChat(opts) {
457
- const { runtime, userRef, activePet, scopeEpoch } = useEverfurContext();
458
- const petRef = opts?.petRef ?? activePet ?? null;
459
- const conversationId = opts?.conversationId ?? null;
460
- const [controller, setController] = useState(null);
461
- useEffect(() => {
462
- const acquired = runtime.registry.acquireChat({ userRef, petRef, conversationId });
463
- setController(acquired);
464
- return () => {
465
- setController((current) => current === acquired ? null : current);
466
- runtime.registry.releaseChat(acquired);
467
- };
468
- }, [runtime, userRef, petRef, conversationId, scopeEpoch]);
469
- const subscribe = useCallback(
470
- (onChange) => controller ? controller.subscribe(onChange) : NOOP_UNSUBSCRIBE,
471
- [controller]
472
- );
473
- const getSnapshot = useCallback(
474
- () => controller ? controller.getSnapshot() : BOOTSTRAP_SNAPSHOT,
475
- [controller]
476
- );
477
- const snapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
478
- const send = useCallback(
479
- (text) => controller ? driveToResult(controller, controller.send(text)) : Promise.resolve(notReadyError()),
480
- [controller]
481
- );
482
- const retryLast = useCallback(
483
- () => controller ? driveToResult(controller, controller.retryLast()) : Promise.resolve(notReadyError()),
484
- [controller]
485
- );
486
- const stop = useCallback(() => {
487
- controller?.stop();
488
- }, [controller]);
489
- return useMemo(
490
- () => ({
491
- status: snapshot.status,
492
- messages: snapshot.messages,
493
- conversationId: snapshot.conversationId,
494
- error: snapshot.error,
495
- isStreaming: snapshot.isStreaming,
496
- isBootstrapping: snapshot.isBootstrapping,
497
- suggestedPrompts: snapshot.suggestedPrompts,
498
- send,
499
- retryLast,
500
- stop
501
- }),
502
- [snapshot, send, retryLast, stop]
503
- );
504
- }
505
- var NOOP_UNSUBSCRIBE = () => {
506
- };
507
- async function driveToResult(controller, iterable) {
508
- for await (const _frame of iterable) {
509
- }
510
- const snapshot = controller.getSnapshot();
511
- if (snapshot.status === "error" && snapshot.error !== null) return err(snapshot.error);
512
- return ok(lastAssistantResponseId(snapshot.messages));
513
- }
514
- function lastAssistantResponseId(messages) {
515
- for (let i = messages.length - 1; i >= 0; i -= 1) {
516
- const message = messages[i];
517
- if (message && message.role === "assistant" && message.responseId !== void 0) {
518
- return message.responseId;
519
- }
520
- }
521
- return null;
522
- }
523
- function notReadyError() {
524
- return err(
525
- makeEverfurError("internalError", { retryable: true })
526
- );
527
- }
528
- function useCapability(name) {
529
- const { runtime } = useEverfurContext();
530
- const store = runtime.entitlements;
531
- const snapshot = useSyncExternalStore(
532
- store.subscribe,
533
- store.getSnapshot,
534
- store.getSnapshot
535
- );
536
- return useMemo(
537
- () => decideCapability(name, snapshot.decisions, { isPending: snapshot.isPending }),
538
- [name, snapshot]
539
- );
540
- }
541
- var MIN_OFFSTATE_HEIGHT = 48;
542
- function selectView(decision) {
543
- if (decision.isPending) return "pending";
544
- return decision.enabled ? "enabled" : "disabled";
545
- }
546
- function CapabilityGate(props) {
547
- const { capability, children, renderDisabled, renderPending, style } = props;
548
- const decision = useCapability(capability);
549
- const view = useMemo(() => selectView(decision), [decision]);
550
- switch (view) {
551
- case "enabled":
552
- return children;
553
- case "pending":
554
- return renderPending ? renderPending() : /* @__PURE__ */ jsx(PendingSkeleton, { capability, style });
555
- case "disabled":
556
- return renderDisabled ? renderDisabled(decision) : /* @__PURE__ */ jsx(OffState, { decision, style });
557
- default:
558
- return assertNever(view);
559
- }
560
- }
561
- function PendingSkeleton({
562
- capability,
563
- style
564
- }) {
565
- const theme = useEverfurTheme();
566
- const styles = useMemo(() => makeStyles(theme), [theme]);
567
- return /* @__PURE__ */ jsx(
568
- View,
569
- {
570
- style: [styles.offstate, style],
571
- accessible: true,
572
- accessibilityState: { busy: true },
573
- accessibilityLabel: `Loading ${capability}`,
574
- children: /* @__PURE__ */ jsx(View, { style: styles.skeletonBar })
575
- }
576
- );
577
- }
578
- function OffState({
579
- decision,
580
- style
581
- }) {
582
- const theme = useEverfurTheme();
583
- const styles = useMemo(() => makeStyles(theme), [theme]);
584
- const message = decision.disabled?.reason ?? "";
585
- return /* @__PURE__ */ jsx(
586
- View,
587
- {
588
- style: [styles.offstate, style],
589
- accessible: true,
590
- accessibilityRole: "text",
591
- accessibilityLabel: message,
592
- children: message.length > 0 ? /* @__PURE__ */ jsx(Text, { style: styles.offstateText, children: message }) : null
593
- }
594
- );
595
- }
596
- function makeStyles(theme) {
597
- const { color, space, radius, type } = theme;
598
- return StyleSheet.create({
599
- // A deliberate cream card with a soft brand hairline, never a bare grey slab.
600
- offstate: {
601
- minHeight: MIN_OFFSTATE_HEIGHT,
602
- justifyContent: "center",
603
- paddingHorizontal: space.lg,
604
- paddingVertical: space.md,
605
- backgroundColor: color.surfaceCream,
606
- borderRadius: radius.md,
607
- borderWidth: StyleSheet.hairlineWidth,
608
- borderColor: color.brandBorder
609
- },
610
- offstateText: {
611
- fontFamily: type.family,
612
- fontSize: type.size.body,
613
- lineHeight: Math.round(type.size.body * type.lineHeight.normal),
614
- color: color.text.muted
615
- },
616
- // A soft green shimmer bar (brand wash) that stays legible on the cream card in both light and dark,
617
- // where the neutral `skeleton` token would collide with the dark cream surface.
618
- skeletonBar: {
619
- height: space.md,
620
- borderRadius: radius.xs,
621
- backgroundColor: color.brandSofter
622
- }
623
- });
624
- }
625
- var CLINICAL_DISCLAIMER = Object.freeze({
626
- title: "For educational use only",
627
- body: "Everfur is for educational purposes only. It helps you track visible changes through AI checkups. It does not diagnose, treat, prescribe, or replace veterinary care. For urgent symptoms or emergencies, contact a veterinarian immediately."
628
- });
629
- function ClinicalDisclaimer(props) {
630
- const theme = useEverfurTheme();
631
- const styles = useMemo(() => makeStyles2(theme), [theme]);
632
- return /* @__PURE__ */ jsxs(
633
- View,
634
- {
635
- style: [styles.container, props.style],
636
- accessible: true,
637
- accessibilityRole: "text",
638
- accessibilityLabel: `${CLINICAL_DISCLAIMER.title}. ${CLINICAL_DISCLAIMER.body}`,
639
- children: [
640
- /* @__PURE__ */ jsx(Text, { style: styles.title, children: CLINICAL_DISCLAIMER.title }),
641
- /* @__PURE__ */ jsx(Text, { style: styles.body, children: CLINICAL_DISCLAIMER.body })
642
- ]
643
- }
644
- );
645
- }
646
- function makeStyles2(theme) {
647
- const { color, space, type } = theme;
648
- return StyleSheet.create({
649
- container: {
650
- paddingHorizontal: space.lg,
651
- paddingVertical: space.md,
652
- borderTopWidth: StyleSheet.hairlineWidth,
653
- borderTopColor: color.borderHairlineGreen,
654
- backgroundColor: color.surfaceCream,
655
- gap: space.xs
656
- },
657
- title: {
658
- fontFamily: type.family,
659
- fontSize: type.size.caption,
660
- lineHeight: Math.round(type.size.caption * type.lineHeight.snug),
661
- color: color.text.secondary,
662
- fontWeight: type.weight.bold,
663
- letterSpacing: type.letterSpacing.eyebrow
664
- },
665
- body: {
666
- fontFamily: type.family,
667
- fontSize: type.size.caption,
668
- lineHeight: Math.round(type.size.caption * type.lineHeight.snug),
669
- color: color.text.muted,
670
- fontWeight: type.weight.regular
671
- }
672
- });
673
- }
674
- var INLINE_TOKEN = /\*\*([^*]+?)\*\*|\*([^*]+?)\*|`([^`]+?)`/g;
675
- function renderInlineMarkdown(text, styles) {
676
- if (!text.includes("*") && !text.includes("`")) return text;
677
- const nodes = [];
678
- let cursor = 0;
679
- let key = 0;
680
- INLINE_TOKEN.lastIndex = 0;
681
- for (let match = INLINE_TOKEN.exec(text); match !== null; match = INLINE_TOKEN.exec(text)) {
682
- if (match.index > cursor) nodes.push(text.slice(cursor, match.index));
683
- const bold = match[1];
684
- const italic = match[2];
685
- const code = match[3];
686
- if (bold !== void 0) {
687
- nodes.push(/* @__PURE__ */ jsx(Text, { style: styles.bold, children: bold }, key++));
688
- } else if (italic !== void 0) {
689
- nodes.push(styles.italic ? /* @__PURE__ */ jsx(Text, { style: styles.italic, children: italic }, key++) : italic);
690
- } else if (code !== void 0) {
691
- nodes.push(styles.code ? /* @__PURE__ */ jsx(Text, { style: styles.code, children: code }, key++) : code);
692
- }
693
- cursor = match.index + match[0].length;
694
- }
695
- if (cursor < text.length) nodes.push(text.slice(cursor));
696
- return nodes;
697
- }
698
- var DOT_SIZE = 6;
699
- var LOOP_MS = 520;
700
- var STAGGER_MS = Math.round(LOOP_MS * 0.18);
701
- var OPACITY_REST = 0.44;
702
- var OPACITY_STATIC = 0.5;
703
- var TRI_IN = [0, 0.5, 1];
704
- var DOT_INDICES = [0, 1, 2];
705
- function TypingIndicator() {
706
- const theme = useEverfurTheme();
707
- const styles = useMemo(() => makeStyles3(theme), [theme]);
708
- const animate = !theme.motion.reducedMotion;
709
- return /* @__PURE__ */ jsx(
710
- View,
711
- {
712
- style: styles.card,
713
- accessible: true,
714
- accessibilityRole: "text",
715
- accessibilityLabel: "Assistant is typing",
716
- accessibilityLiveRegion: "polite",
717
- accessibilityState: { busy: true },
718
- children: DOT_INDICES.map(
719
- (index) => animate ? /* @__PURE__ */ jsx(AnimatedDot, { index, style: styles.dot }, index) : /* @__PURE__ */ jsx(View, { style: [styles.dot, styles.dotStatic] }, index)
720
- )
721
- }
722
- );
723
- }
724
- function AnimatedDot({ index, style }) {
725
- const t = useRef(new Animated.Value(0)).current;
726
- useEffect(() => {
727
- const anim = Animated.sequence([
728
- Animated.delay(index * STAGGER_MS),
729
- Animated.loop(Animated.timing(t, { toValue: 1, duration: LOOP_MS, useNativeDriver: true }))
730
- ]);
731
- anim.start();
732
- return () => anim.stop();
733
- }, [t, index]);
734
- const opacity = t.interpolate({ inputRange: TRI_IN, outputRange: [OPACITY_REST, 1, OPACITY_REST] });
735
- const translateY = t.interpolate({ inputRange: TRI_IN, outputRange: [0, -3.5, 0] });
736
- return /* @__PURE__ */ jsx(Animated.View, { style: [style, { opacity, transform: [{ translateY }] }] });
737
- }
738
- function makeStyles3(theme) {
739
- const c = theme.color;
740
- const s = theme.space;
741
- const r = theme.radius;
742
- return StyleSheet.create({
743
- card: {
744
- alignSelf: "flex-start",
745
- flexDirection: "row",
746
- alignItems: "center",
747
- gap: s.xs,
748
- paddingHorizontal: s.md,
749
- paddingVertical: s.sm,
750
- backgroundColor: c.surfaceCream,
751
- borderRadius: r.md,
752
- borderWidth: StyleSheet.hairlineWidth,
753
- borderColor: c.brandBorder
754
- },
755
- dot: { width: DOT_SIZE, height: DOT_SIZE, borderRadius: r.pill, backgroundColor: c.brand },
756
- dotStatic: { opacity: OPACITY_STATIC }
757
- });
758
- }
759
- var SPINNER_DELAY_MS = 300;
760
- var DEFAULT_PLACEHOLDER = "Message";
761
- var DEFAULT_SEND_LABEL = "Send";
762
- var DEFAULT_STOP_LABEL = "Stop";
763
- var FOLLOW_UPS_LABEL = "Follow up questions";
764
- var POWERED_BY_LABEL = "powered by everfur";
765
- var MIN_SURFACE_HEIGHT = 120;
766
- var MIN_TOUCH_TARGET = 44;
767
- var INPUT_MAX_HEIGHT = 120;
768
- var EMPTY_GLYPH_SIZE = 40;
769
- var BUBBLE_MAX_WIDTH = "82%";
770
- var COMPOSER_BORDER_WIDTH = 1.25;
771
- var BUBBLE_EDGE_WIDTH = 0.5;
772
- var PENDING_OPACITY = 0.6;
773
- var COMPOSER_SHADOW_OPACITY = 0.1;
774
- var COMPOSER_SHADOW_OFFSET_Y = 2;
775
- var COMPOSER_SHADOW_ELEVATION = 2;
776
- function EverfurChat(props) {
777
- const { petRef, conversationId, style } = props;
778
- return /* @__PURE__ */ jsx(CapabilityGate, { capability: "chat", style, children: /* @__PURE__ */ jsx(ChatBody, { petRef, conversationId, style }) });
779
- }
780
- function selectView2(state) {
781
- if (state.isBootstrapping) return "loading";
782
- if (state.status === "error" && state.error) return "error";
783
- if (state.messages.length === 0) return "empty";
784
- return "populated";
785
- }
786
- function ChatBody({
787
- petRef,
788
- conversationId,
789
- style
790
- }) {
791
- const { theme, styles } = useChatTheme();
792
- const chatOpts = useMemo(
793
- () => buildChatOpts(petRef, conversationId),
794
- [petRef, conversationId]
795
- );
796
- const chat = useEverfurChat(chatOpts);
797
- const view = selectView2(chat);
798
- const insets = useSafeAreaInsets();
799
- const onSelectPrompt = useCallback(
800
- (prompt) => {
801
- void chat.send(prompt);
802
- },
803
- [chat.send]
804
- );
805
- return (
806
- // KeyboardAvoidingView so the composer + disclaimer lift above the software keyboard while the user types.
807
- /* @__PURE__ */ jsxs(
808
- KeyboardAvoidingView,
809
- {
810
- style: [styles.container, { paddingTop: insets.top }, style],
811
- behavior: Platform.OS === "ios" ? "padding" : void 0,
812
- children: [
813
- /* @__PURE__ */ jsx(View, { style: styles.body, children: renderView(view, chat, onSelectPrompt) }),
814
- /* @__PURE__ */ jsx(Composer, { send: chat.send, stop: chat.stop, isStreaming: chat.isStreaming }),
815
- /* @__PURE__ */ jsx(ClinicalDisclaimer, {}),
816
- theme.meta.hidePoweredBy ? null : /* @__PURE__ */ jsx(Text, { style: styles.poweredBy, accessibilityRole: "text", accessibilityLabel: POWERED_BY_LABEL, children: POWERED_BY_LABEL })
817
- ]
818
- }
819
- )
820
- );
821
- }
822
- function Composer({
823
- send,
824
- stop,
825
- isStreaming
826
- }) {
827
- const { theme, styles } = useChatTheme();
828
- const [draft, setDraft] = useState("");
829
- const placeholder = theme.meta.placeholder ?? DEFAULT_PLACEHOLDER;
830
- const onSend = useCallback(() => {
831
- if (draft.trim().length === 0) return;
832
- if ([...draft].length > MESSAGE_MAX_CHARS) return;
833
- void send(draft);
834
- setDraft("");
835
- }, [draft, send]);
836
- const onStop = useCallback(() => {
837
- stop();
838
- }, [stop]);
839
- const isOverLimit = useMemo(() => [...draft].length > MESSAGE_MAX_CHARS, [draft]);
840
- return /* @__PURE__ */ jsxs(View, { style: styles.composer, children: [
841
- /* @__PURE__ */ jsx(
842
- TextInput,
843
- {
844
- style: styles.input,
845
- value: draft,
846
- onChangeText: setDraft,
847
- placeholder,
848
- placeholderTextColor: theme.color.text.placeholder,
849
- accessibilityLabel: placeholder,
850
- onSubmitEditing: onSend,
851
- returnKeyType: "send",
852
- blurOnSubmit: false,
853
- multiline: true,
854
- editable: true
855
- }
856
- ),
857
- isStreaming ? /* @__PURE__ */ jsx(
858
- Pressable,
859
- {
860
- onPress: onStop,
861
- accessibilityRole: "button",
862
- accessibilityLabel: DEFAULT_STOP_LABEL,
863
- style: styles.actionButton,
864
- children: /* @__PURE__ */ jsx(Text, { style: styles.actionLabel, children: DEFAULT_STOP_LABEL })
865
- }
866
- ) : /* @__PURE__ */ jsx(
867
- Pressable,
868
- {
869
- onPress: onSend,
870
- disabled: isOverLimit,
871
- accessibilityRole: "button",
872
- accessibilityLabel: DEFAULT_SEND_LABEL,
873
- accessibilityState: { disabled: isOverLimit },
874
- style: [styles.actionButton, isOverLimit ? styles.actionButtonDisabled : null],
875
- children: /* @__PURE__ */ jsx(Text, { style: [styles.actionLabel, isOverLimit ? styles.actionLabelDisabled : null], children: DEFAULT_SEND_LABEL })
876
- }
877
- )
878
- ] });
879
- }
880
- function renderView(view, chat, onSelectPrompt) {
881
- switch (view) {
882
- case "loading":
883
- return /* @__PURE__ */ jsx(LoadingState, {});
884
- case "empty":
885
- return /* @__PURE__ */ jsx(EmptyState, { prompts: chat.suggestedPrompts, onSelectPrompt });
886
- case "error":
887
- return /* @__PURE__ */ jsx(ErrorState, { error: chat.error, onRetry: chat.retryLast });
888
- case "populated":
889
- return /* @__PURE__ */ jsx(
890
- PopulatedState,
891
- {
892
- messages: chat.messages,
893
- prompts: chat.suggestedPrompts,
894
- onSelectPrompt,
895
- isStreaming: chat.isStreaming
896
- }
897
- );
898
- default:
899
- return assertNever(view);
900
- }
901
- }
902
- function buildChatOpts(petRef, conversationId) {
903
- const opts = {};
904
- if (petRef !== void 0) opts.petRef = petRef;
905
- if (conversationId !== void 0) opts.conversationId = conversationId;
906
- return opts;
907
- }
908
- function LoadingState() {
909
- const { theme, styles } = useChatTheme();
910
- const [visible, setVisible] = useState(false);
911
- useEffect(() => {
912
- const id = setTimeout(() => setVisible(true), SPINNER_DELAY_MS);
913
- return () => clearTimeout(id);
914
- }, []);
915
- return /* @__PURE__ */ jsx(View, { style: styles.centered, accessible: true, accessibilityState: { busy: true }, accessibilityLabel: "Loading", children: visible ? /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.color.brand }) : null });
916
- }
917
- function EmptyState({
918
- prompts,
919
- onSelectPrompt
920
- }) {
921
- const { styles } = useChatTheme();
922
- return /* @__PURE__ */ jsxs(ScrollView, { contentContainerStyle: styles.emptyContent, keyboardShouldPersistTaps: "handled", children: [
923
- /* @__PURE__ */ jsx(View, { style: styles.emptyGlyphWrap, accessible: true, accessibilityRole: "summary", accessibilityLabel: "No messages yet", children: /* @__PURE__ */ jsx(View, { style: styles.emptyGlyph }) }),
924
- /* @__PURE__ */ jsx(FollowUps, { prompts, onSelectPrompt })
925
- ] });
926
- }
927
- function FollowUps({
928
- prompts,
929
- onSelectPrompt
930
- }) {
931
- const { styles } = useChatTheme();
932
- if (prompts.length === 0) return null;
933
- return /* @__PURE__ */ jsxs(View, { style: styles.followUps, children: [
934
- /* @__PURE__ */ jsx(Text, { style: styles.followUpsLabel, accessibilityRole: "header", children: FOLLOW_UPS_LABEL }),
935
- prompts.map((prompt, index) => /* @__PURE__ */ jsx(
936
- Pressable,
937
- {
938
- onPress: () => onSelectPrompt(prompt),
939
- accessibilityRole: "button",
940
- accessibilityLabel: prompt,
941
- style: [styles.followUpRow, index > 0 ? styles.followUpDivider : null],
942
- children: /* @__PURE__ */ jsx(Text, { style: styles.followUpText, children: prompt })
943
- },
944
- prompt
945
- ))
946
- ] });
947
- }
948
- function ErrorState({ error, onRetry }) {
949
- const { styles } = useChatTheme();
950
- return /* @__PURE__ */ jsxs(View, { style: styles.centered, accessible: true, accessibilityRole: "alert", children: [
951
- /* @__PURE__ */ jsx(Text, { style: styles.errorText, children: error.displayMessage }),
952
- error.retryable ? /* @__PURE__ */ jsx(
953
- Pressable,
954
- {
955
- onPress: onRetry,
956
- accessibilityRole: "button",
957
- accessibilityLabel: "Try again",
958
- style: styles.retryButton,
959
- children: /* @__PURE__ */ jsx(Text, { style: styles.retryLabel, children: "Try again" })
960
- }
961
- ) : null
962
- ] });
963
- }
964
- function PopulatedState({
965
- messages,
966
- prompts,
967
- onSelectPrompt,
968
- isStreaming
969
- }) {
970
- const { styles } = useChatTheme();
971
- const lastMessage = messages[messages.length - 1];
972
- const awaitingAssistant = isStreaming && (lastMessage === void 0 || lastMessage.role === "user");
973
- return /* @__PURE__ */ jsxs(
974
- ScrollView,
975
- {
976
- style: styles.list,
977
- contentContainerStyle: styles.listContent,
978
- accessibilityLabel: "Conversation",
979
- keyboardShouldPersistTaps: "handled",
980
- children: [
981
- messages.map((message) => /* @__PURE__ */ jsx(MessageRow, { message }, message.id)),
982
- awaitingAssistant ? /* @__PURE__ */ jsx(TypingIndicator, {}) : null,
983
- !isStreaming ? /* @__PURE__ */ jsx(FollowUps, { prompts, onSelectPrompt }) : null
984
- ]
985
- }
986
- );
987
- }
988
- function MessageRow({ message }) {
989
- const { styles } = useChatTheme();
990
- const isUser = message.role === "user";
991
- const sender = isUser ? "You" : "Assistant";
992
- return /* @__PURE__ */ jsx(
993
- View,
994
- {
995
- style: [styles.row, isUser ? styles.rowUser : styles.rowAssistant],
996
- accessible: true,
997
- accessibilityRole: "text",
998
- accessibilityLabel: `${sender}: ${message.text}`,
999
- accessibilityState: message.pending === true ? { busy: true } : void 0,
1000
- children: /* @__PURE__ */ jsx(View, { style: [styles.bubble, isUser ? styles.bubbleUser : styles.bubbleAssistant, message.pending ? styles.bubblePending : null], children: /* @__PURE__ */ jsx(Text, { style: isUser ? styles.bubbleTextUser : styles.bubbleTextAssistant, children: isUser ? message.text : renderInlineMarkdown(message.text, {
1001
- bold: styles.bubbleBold,
1002
- italic: styles.bubbleItalic,
1003
- code: styles.bubbleCode
1004
- }) }) })
1005
- }
1006
- );
1007
- }
1008
- function useChatTheme() {
1009
- const theme = useEverfurTheme();
1010
- const styles = useMemo(() => makeStyles4(theme), [theme]);
1011
- return { theme, styles };
1012
- }
1013
- function makeStyles4(theme) {
1014
- const c = theme.color;
1015
- const s = theme.space;
1016
- const r = theme.radius;
1017
- const t = theme.type;
1018
- const weightLabel = t.weight.medium;
1019
- return StyleSheet.create({
1020
- // Cream ground so the branded bubbles / bare assistant text sit on an Everfur surface (host `style` still wins).
1021
- container: { flex: 1, minHeight: MIN_SURFACE_HEIGHT, backgroundColor: c.surfaceCream },
1022
- body: { flex: 1 },
1023
- centered: { minHeight: MIN_SURFACE_HEIGHT, flexGrow: 1, alignItems: "center", justifyContent: "center", padding: s.xl },
1024
- // Deliberate empty-state placeholder: a soft brand-wash disc (never a blank region).
1025
- emptyGlyph: {
1026
- width: EMPTY_GLYPH_SIZE,
1027
- height: EMPTY_GLYPH_SIZE,
1028
- borderRadius: r.pill,
1029
- backgroundColor: c.brandSoft,
1030
- borderWidth: StyleSheet.hairlineWidth,
1031
- borderColor: c.brandBorder
1032
- },
1033
- // Empty state scrolls (glyph centered, then the follow-up list) so nothing overflows a short surface.
1034
- emptyContent: { flexGrow: 1, justifyContent: "center", padding: s.lg, gap: s.lg },
1035
- emptyGlyphWrap: { alignItems: "center", justifyContent: "center", paddingVertical: s.xl },
1036
- errorText: {
1037
- fontFamily: t.family,
1038
- fontSize: t.size.subtitle,
1039
- lineHeight: t.size.subtitle * t.lineHeight.snug,
1040
- color: c.danger,
1041
- textAlign: "center",
1042
- marginBottom: s.md
1043
- },
1044
- // Brand-green pill retry CTA with the WCAG-legible on-brand foreground.
1045
- retryButton: {
1046
- minHeight: MIN_TOUCH_TARGET,
1047
- minWidth: MIN_TOUCH_TARGET,
1048
- alignItems: "center",
1049
- justifyContent: "center",
1050
- paddingHorizontal: s.xl,
1051
- paddingVertical: s.sm,
1052
- borderRadius: r.pill,
1053
- backgroundColor: c.brand
1054
- },
1055
- retryLabel: { fontFamily: t.family, color: c.onPrimary, fontSize: t.size.body, fontWeight: weightLabel },
1056
- list: { flex: 1 },
1057
- listContent: { padding: s.lg, gap: s.md },
1058
- row: { flexDirection: "row" },
1059
- rowUser: { justifyContent: "flex-end" },
1060
- rowAssistant: { justifyContent: "flex-start" },
1061
- bubble: { maxWidth: BUBBLE_MAX_WIDTH, paddingHorizontal: s.md, paddingVertical: s.sm, borderRadius: r.lg },
1062
- // User = brand accent fill + 0.5px accent edge, tail corner tightened (the mobile asymmetry).
1063
- bubbleUser: {
1064
- backgroundColor: c.bubbleUser,
1065
- borderBottomRightRadius: r.tile,
1066
- borderWidth: BUBBLE_EDGE_WIDTH,
1067
- borderColor: c.accentEdge
1068
- },
1069
- // Assistant = bare text block (no fill, flush-left) so the reply reads as plain, on-surface prose.
1070
- bubbleAssistant: { paddingHorizontal: 0 },
1071
- bubblePending: { opacity: PENDING_OPACITY },
1072
- bubbleTextUser: {
1073
- fontFamily: t.family,
1074
- color: c.onAccent,
1075
- fontSize: t.size.body,
1076
- lineHeight: t.size.body * t.lineHeight.normal
1077
- },
1078
- bubbleTextAssistant: {
1079
- fontFamily: t.family,
1080
- color: c.text.primary,
1081
- fontSize: t.size.body,
1082
- lineHeight: t.size.body * t.lineHeight.normal
1083
- },
1084
- // Inline-markdown runs inside the assistant reply (nested <Text>): bold entities + optional italic / code.
1085
- bubbleBold: { fontWeight: t.weight.bold },
1086
- bubbleItalic: { fontStyle: "italic" },
1087
- bubbleCode: { fontFamily: t.mono },
1088
- // "Follow up questions": a labeled, list-with-dividers block of tappable, ready-to-send backend prompts.
1089
- followUps: { marginTop: s.sm, borderRadius: r.md, backgroundColor: c.brandSoft, borderWidth: StyleSheet.hairlineWidth, borderColor: c.brandBorder },
1090
- followUpsLabel: {
1091
- fontFamily: t.family,
1092
- color: c.text.secondary,
1093
- fontSize: t.size.caption,
1094
- fontWeight: weightLabel,
1095
- letterSpacing: t.letterSpacing.eyebrow,
1096
- textTransform: "uppercase",
1097
- paddingHorizontal: s.md,
1098
- paddingTop: s.md,
1099
- paddingBottom: s.sm
1100
- },
1101
- followUpRow: { minHeight: MIN_TOUCH_TARGET, justifyContent: "center", paddingHorizontal: s.md, paddingVertical: s.sm },
1102
- followUpDivider: { borderTopWidth: StyleSheet.hairlineWidth, borderTopColor: c.brandBorder },
1103
- followUpText: {
1104
- fontFamily: t.family,
1105
- color: c.text.primary,
1106
- fontSize: t.size.body,
1107
- lineHeight: t.size.body * t.lineHeight.snug
1108
- },
1109
- // Composer = inset cream pill with a brand border and a soft brand-tinted lift.
1110
- composer: {
1111
- flexDirection: "row",
1112
- alignItems: "flex-end",
1113
- gap: s.sm,
1114
- marginHorizontal: s.md,
1115
- marginTop: s.xs,
1116
- marginBottom: s.sm,
1117
- paddingHorizontal: s.md,
1118
- paddingVertical: s.sm,
1119
- backgroundColor: c.surfaceCream,
1120
- borderWidth: COMPOSER_BORDER_WIDTH,
1121
- borderColor: c.brandBorder,
1122
- borderRadius: r.pill,
1123
- shadowColor: c.brand,
1124
- shadowOpacity: COMPOSER_SHADOW_OPACITY,
1125
- shadowRadius: s.sm,
1126
- shadowOffset: { width: 0, height: COMPOSER_SHADOW_OFFSET_Y },
1127
- elevation: COMPOSER_SHADOW_ELEVATION
1128
- },
1129
- // Bare input inside the pill (the composer owns the border / fill); placeholder color set on the element.
1130
- input: {
1131
- flex: 1,
1132
- minHeight: MIN_TOUCH_TARGET,
1133
- maxHeight: INPUT_MAX_HEIGHT,
1134
- paddingHorizontal: s.md,
1135
- paddingVertical: s.sm,
1136
- fontFamily: t.family,
1137
- fontSize: t.size.body,
1138
- lineHeight: t.size.body * t.lineHeight.normal,
1139
- color: c.text.primary
1140
- },
1141
- // Brand-green pill send / stop control.
1142
- actionButton: {
1143
- minHeight: MIN_TOUCH_TARGET,
1144
- minWidth: MIN_TOUCH_TARGET,
1145
- alignItems: "center",
1146
- justifyContent: "center",
1147
- paddingHorizontal: s.lg,
1148
- borderRadius: r.pill,
1149
- backgroundColor: c.brand
1150
- },
1151
- actionLabel: { fontFamily: t.family, color: c.onPrimary, fontSize: t.size.body, fontWeight: weightLabel },
1152
- // The over-length state. Opacity alone would carry the meaning by appearance only, so the control also
1153
- // sets `disabled` and `accessibilityState.disabled`, which is what a screen reader announces.
1154
- actionButtonDisabled: { opacity: 0.45 },
1155
- actionLabelDisabled: { color: c.onPrimary },
1156
- // Everfur's own attribution: small, muted, centered under the disclaimer.
1157
- poweredBy: {
1158
- fontFamily: t.family,
1159
- color: c.text.muted,
1160
- fontSize: t.size.micro,
1161
- textAlign: "center",
1162
- paddingBottom: s.xs
1163
- }
1164
- });
1165
- }
1166
-
1167
- export { EverfurChat, useEverfurChat };
1
+ import {createContext,forwardRef,useMemo,useState,useRef,useEffect,useCallback,useSyncExternalStore,createElement,useContext,Component}from'react';import {StyleSheet,TextInput,Linking,KeyboardAvoidingView,View,Platform,Pressable,Text,Animated,UIManager,LayoutAnimation,Modal,Image,ActivityIndicator,ScrollView,useWindowDimensions,FlatList}from'react-native';import {useSafeAreaInsets}from'react-native-safe-area-context';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var Pl=Object.defineProperty;var i=(e,t)=>Pl(e,"name",{value:t,configurable:true});var Sr=Object.freeze([Object.freeze({wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false}),Object.freeze({wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true}),Object.freeze({wireCode:"DAILY_QUOTA_EXCEEDED",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"FILE_TOO_LARGE",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"IDEMPOTENCY_KEY_IN_FLIGHT",envelope:"http_envelope",httpStatus:409,retryable:true}),Object.freeze({wireCode:"IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"INVALID_CONTENT_TYPE",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"InternalFailureException",envelope:"http_envelope",httpStatus:500,retryable:true}),Object.freeze({wireCode:"MethodNotAllowedException",envelope:"http_envelope",httpStatus:405,retryable:false}),Object.freeze({wireCode:"NotImplementedException",envelope:"http_envelope",httpStatus:501,retryable:false}),Object.freeze({wireCode:"PaymentRequiredException",envelope:"http_envelope",httpStatus:402,retryable:false}),Object.freeze({wireCode:"ResourceNotFoundException",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"ServiceUnavailableException",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"TIER_UPGRADE_REQUIRED",envelope:"http_envelope",httpStatus:402,retryable:false}),Object.freeze({wireCode:"ThrottlingException",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"ValidationException",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"accessDenied",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"access_denied",envelope:"oauth_error",httpStatus:302,retryable:false}),Object.freeze({wireCode:"attachment_unreadable",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"authExpired",envelope:"http_envelope",httpStatus:401,retryable:true}),Object.freeze({wireCode:"authRejected",envelope:"http_envelope",httpStatus:401,retryable:false}),Object.freeze({wireCode:"consent_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"consent_required",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"consent_scope_wrong_route",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"device_cipher_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"email_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"event_cursor_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_payload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_type_not_available",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"event_type_unknown",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"idempotency_key_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"idempotency_key_required",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"idempotency_key_reused",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"insufficientCapability",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"insufficient_scope",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"internal_error",envelope:"sse_frame",httpStatus:200,retryable:false}),Object.freeze({wireCode:"invalidRequest",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_client",envelope:"oauth_error",httpStatus:401,retryable:false}),Object.freeze({wireCode:"invalid_client_metadata",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_grant",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_redirect_uri",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_request",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_scope",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"invalid_target",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"mcp_connection_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"mcp_request_conflict",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"mcp_request_gone",envelope:"http_envelope",httpStatus:410,retryable:false}),Object.freeze({wireCode:"mcp_request_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"not_found",envelope:"sse_frame",httpStatus:200,retryable:false}),Object.freeze({wireCode:"partner_visit_link_conflict",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"partner_visit_owner_only",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"partner_visit_pet_already_mapped",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"payload_too_large",envelope:"http_envelope",httpStatus:413,retryable:false}),Object.freeze({wireCode:"petRefInUse",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"pet_health_list_removals_unconfirmed",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"pet_health_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"pet_not_registered",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"provider_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"rateLimited",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"record_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"record_subject_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"record_upload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"records_consent_required",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"sandbox_only",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"session_required",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"share_limit_reached",envelope:"http_envelope",httpStatus:429,retryable:false}),Object.freeze({wireCode:"slow_down",envelope:"oauth_error",httpStatus:429,retryable:true}),Object.freeze({wireCode:"species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"tenant_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"tenant_has_no_capabilities",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"tenant_resource_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),Object.freeze({wireCode:"tenant_surface_not_enabled",envelope:"http_envelope",httpStatus:409,retryable:false}),Object.freeze({wireCode:"timeout",envelope:"sse_frame",httpStatus:200,retryable:true}),Object.freeze({wireCode:"token_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"unavailable",envelope:"sse_frame",httpStatus:200,retryable:true}),Object.freeze({wireCode:"unavailable",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"unsupported_grant_type",envelope:"oauth_error",httpStatus:400,retryable:false}),Object.freeze({wireCode:"unsupported_response_type",envelope:"oauth_error",httpStatus:302,retryable:false}),Object.freeze({wireCode:"verify_mint_rate_limited",envelope:"http_envelope",httpStatus:429,retryable:true}),Object.freeze({wireCode:"verify_mint_refused",envelope:"http_envelope",httpStatus:403,retryable:false}),Object.freeze({wireCode:"verify_mint_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true}),Object.freeze({wireCode:"verify_user_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),Object.freeze({wireCode:"webhook_endpoint_update_empty",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),Object.freeze({wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false})]);Object.freeze(Sr.map(e=>e.wireCode));var Tl=Object.freeze({ValidationException:"validationFailed",AuthorizationException:"authRejected",PaymentRequiredException:"paymentRequired",AccessDeniedException:"accessDenied",ResourceNotFoundException:"resourceNotFound",ConflictException:"conflict",ThrottlingException:"rateLimited",InternalFailureException:"internalError",NotImplementedException:"notImplemented",ServiceUnavailableException:"serviceUnavailable",MethodNotAllowedException:"validationFailed",authExpired:"authExpired",unavailable:"serviceUnavailable",session_required:"sessionRequired",accessDenied:"accessDenied",invalidRequest:"sdkUpdateRequired",authRejected:"authRejected",rateLimited:"rateLimited",insufficientCapability:"accessDenied",event_cursor_invalid:"validationFailed",event_filter_invalid:"validationFailed",event_payload_invalid:"validationFailed",event_type_unknown:"validationFailed",idempotency_key_invalid:"validationFailed",idempotency_key_required:"validationFailed",idempotency_key_reused:"idempotencyConflict",payload_too_large:"validationFailed",webhook_url_rejected:"validationFailed",webhook_endpoint_update_empty:"validationFailed",webhook_endpoint_update_invalid:"validationFailed",event_type_not_available:"conflict",record_subject_not_found:"resourceNotFound",records_consent_required:"conflict",record_species_unsupported:"validationFailed",record_upload_invalid:"validationFailed",FILE_TOO_LARGE:"validationFailed",INVALID_CONTENT_TYPE:"validationFailed",attachment_unreadable:"validationFailed",provider_unsupported:"validationFailed",token_invalid:"validationFailed",device_cipher_unavailable:"serviceUnavailable",email_invalid:"validationFailed",consent_required:"validationFailed",consent_invalid:"validationFailed",consent_scope_wrong_route:"validationFailed",IDEMPOTENCY_KEY_IN_FLIGHT:"idempotencyInFlight",IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST:"idempotencyConflict",DAILY_QUOTA_EXCEEDED:"quotaExceeded",TIER_UPGRADE_REQUIRED:"paymentRequired",not_found:"conversationNotFound",timeout:"streamTimeout",internal_error:"internalError",invalid_request:"validationFailed",invalid_client:"authRejected",invalid_grant:"authRejected",unsupported_grant_type:"validationFailed",invalid_scope:"validationFailed",invalid_target:"validationFailed",invalid_redirect_uri:"validationFailed",invalid_client_metadata:"validationFailed",unsupported_response_type:"validationFailed",access_denied:"accessDenied",slow_down:"rateLimited",mcp_request_not_found:"resourceNotFound",mcp_request_gone:"resourceNotFound",mcp_connection_not_found:"resourceNotFound",mcp_request_conflict:"conflict",sandbox_only:"accessDenied",tenant_has_no_capabilities:"conflict",verify_mint_refused:"accessDenied",verify_mint_rate_limited:"rateLimited",verify_mint_unavailable:"serviceUnavailable",verify_user_ref_invalid:"validationFailed",insufficient_scope:"accessDenied",tenant_filter_invalid:"validationFailed",tenant_resource_not_found:"resourceNotFound",tenant_surface_not_enabled:"conflict",pet_health_species_unsupported:"validationFailed",pet_health_list_removals_unconfirmed:"validationFailed",petRefInUse:"conflict",share_limit_reached:"conflict",pet_not_registered:"resourceNotFound",species_unsupported:"validationFailed",partner_visit_owner_only:"accessDenied",partner_visit_link_conflict:"conflict",partner_visit_pet_already_mapped:"conflict"}),Yn=Object.freeze(Sr.map(e=>Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:Tl[e.wireCode]}))),kl=new Map(Yn.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),wl=Object.freeze(["http_envelope",...[...new Set(Yn.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function At(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let n of [t??"http_envelope",...wl]){let o=kl.get(n+r);if(o)return o}}i(At,"contractErrorFor");function _l(e){return e.envelope==="sse_frame"?`/errors#sse-${e.wireCode}`:e.envelope==="oauth_error"?`/errors#oauth-${e.wireCode}`:`/errors#${e.wireCode}`}i(_l,"contractDocUrl");function Kn(e){return null}i(Kn,"publishedDocUrl");var xl=Object.freeze({authExpired:"authentication",authRejected:"authentication",sessionRequired:"authentication",accessDenied:"authorization",paymentRequired:"entitlement",quotaExceeded:"rateLimit",rateLimited:"rateLimit",validationFailed:"invalidRequest",sdkUpdateRequired:"invalidRequest",conversationNotFound:"notFound",petNotFound:"notFound",resourceNotFound:"notFound",conflict:"conflict",idempotencyConflict:"conflict",idempotencyInFlight:"conflict",streamTimeout:"connection",streamIncomplete:"connection",upstreamLlmTimeout:"connection",serviceUnavailable:"connection",internalError:"server",notImplemented:"server",mediaUploadFailed:"media",moderationBlocked:"policy",unknown:"unknown"});function $n(e){return xl[e]}i($n,"categoryFor");function Qn(e){let t=At(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),n=r.replace(/[^A-Z0-9]/g,"");if(n==="AUTHREJECTED")return "authRejected";if(r.startsWith("AUTH"))return "authExpired";switch(n){case "DAILYQUOTAEXCEEDED":case "QUOTAEXCEEDED":return "quotaExceeded";case "RATELIMITED":case "TOOMANYREQUESTS":return "rateLimited";case "IDEMPOTENCYKEYCONFLICT":case "IDEMPOTENCYCONFLICT":return "idempotencyConflict";case "ACCESSDENIED":case "FORBIDDEN":return "accessDenied";case "NOTFOUND":case "CONVERSATIONNOTFOUND":return "conversationNotFound";case "PETNOTFOUND":return "petNotFound";case "TIMEOUT":case "STREAMTIMEOUT":return "streamTimeout";case "MEDIAUPLOADFAILED":case "UNRECOGNIZEDVIDEOFORMAT":case "FILETOOSMALL":return "mediaUploadFailed";case "MODERATIONBLOCKED":return "moderationBlocked";case "UPSTREAMLLMTIMEOUT":return "upstreamLlmTimeout";case "INTERNALERROR":case "INTERNALSERVERERROR":return "internalError";case "STREAMINCOMPLETE":case "CHATSTREAMINCOMPLETE":return "streamIncomplete";case "INVALIDANALYSISTYPE":case "INVALIDUPLOADPURPOSE":return "unknown";default:return "unknown"}}i(Qn,"fromWire");var Il=new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function Pr(e){return Il.has(e)}i(Pr,"isAutoRetryable");var Al=new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function Xn(e){return Pr(e)||Al.has(e)}i(Xn,"isRetryableCode");var Ol=500,Tr=8e3,Zn=4;function Jn(e,t=Math.random){let r=Math.max(0,e),n=Math.min(Ol*2**r,Tr);return Math.floor(t()*n)}i(Jn,"backoffDelayMs");var Fl=Object.freeze({authExpired:"Please sign in again to continue.",authRejected:"Please sign in again to continue.",sessionRequired:"This app needs to be updated to keep using Everfur.",accessDenied:"This feature isn't available on your account right now.",paymentRequired:"This is part of a paid plan.",quotaExceeded:"You have used today's messages. This resets tomorrow.",rateLimited:"You are sending messages quickly. Try again in a few seconds.",validationFailed:"Something in that request was not right. Check the details and try again.",sdkUpdateRequired:"This app needs to be updated to keep using Everfur.",conflict:"That is already running. Wait for it to finish, then try again.",idempotencyConflict:"That message was already delivered.",idempotencyInFlight:"That is still processing. Give it a moment.",conversationNotFound:"This conversation is no longer available.",petNotFound:"We could not find that pet. Please pick a pet and try again.",resourceNotFound:"We could not find that.",streamTimeout:"The response timed out. Tap retry to try again.",mediaUploadFailed:"We could not upload that photo. Please attach it again.",moderationBlocked:"This request cannot be answered here.",upstreamLlmTimeout:"The response timed out. Tap retry to try again.",internalError:"We hit a snag on our end. Please try again.",notImplemented:"That is not available yet.",serviceUnavailable:"That service is briefly unavailable. Try again shortly.",streamIncomplete:"The connection dropped mid-answer. Tap retry to continue.",unknown:"Something went wrong. Please try again."});function kr(e){return Fl[e]}i(kr,"userFacingError");function eo(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false});}i(eo,"defineHidden");var Ml=/^[a-z][a-z0-9_]{0,63}$/;function Y(e,t){let r=At(t?.wireCode,t?.wireEnvelope),n={code:e,category:$n(e),retryable:t?.retryable??Xn(e),displayMessage:kr(e)};if(t?.httpStatus!==void 0&&(n.httpStatus=t.httpStatus),t?.requestId&&(n.requestId=t.requestId),typeof t?.reasonCode=="string"&&Ml.test(t.reasonCode)&&(n.reasonCode=t.reasonCode),r);return t?.wireMessage&&eo(n,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&eo(n,"raw",t.raw),Object.freeze(n)}i(Y,"makeEverfurError");function de(e,t){return Object.freeze(t===void 0?{ok:true,value:e}:{ok:true,value:e,warning:t})}i(de,"ok");function M(e){return Object.freeze({ok:false,error:e})}i(M,"err");var Ot=class Ot extends Error{constructor(t,r){super(r),this.name="EverfurConfigError",this.kind=t,Object.setPrototypeOf(this,Ot.prototype);}};i(Ot,"EverfurConfigError");var dt=Ot;var p=Object.freeze({placeholder:"Message",send:"Send",stop:"Stop",retry:"Try again",followUps:"Follow up questions",poweredBy:"powered by everfur",senderUser:"You",senderAssistant:"Assistant",typing:"Assistant is typing",loading:"Loading",empty:"No messages yet",transcript:"Conversation",emptyTitle:"What can we help {petName} with today?",emptyTitlePetFallback:"your pet",copied:"Copied",copyUserMessage:"Copy your message",copyAssistantMessage:"Copy assistant message",feedbackHelpful:"Helpful",feedbackNeutral:"Neutral",feedbackNotHelpful:"Not helpful",feedbackTitle:"What went wrong?",feedbackSubtitle:"Your feedback helps make answers more reliable.",feedbackReasonInaccurate:"Inaccurate",feedbackReasonOutdated:"Out of date",feedbackReasonUnsafe:"Unsafe advice",feedbackReasonUnclear:"Confusing or unclear",feedbackReasonOther:"Something else",feedbackNotesPlaceholder:"Add details (optional)",feedbackSubmit:"Submit feedback",feedbackSkip:"Skip",feedbackSkipA11y:"Skip feedback",feedbackThanks:"Thanks for the feedback",feedbackFailed:"Couldn't send feedback. Please try again.",turnFailedTitle:"Message failed",turnRetry:"Retry",turnUnreachableTitle:"Couldn't reach this chat",turnStartNewChat:"Start a new chat",reconnecting:"Reconnecting\u2026",turnStoppedTitle:"Response stopped",turnStoppedBody:"You stopped this response before it finished. Tap retry to try again.",sourceSingular:"source",sourcePlural:"sources",showSources:"Show",hideSources:"Hide",openSource:"Open source",urgencyGeneralReason:"Just general info about {petName}. Nothing here needs action right now.",findVet:"Find a vet",findVetA11y:"Find a vet near you",showLatestVetAlert:"Show latest vet alert",dismissBanner:"Dismiss {label} banner",openMenu:"Open menu",openMenuUnread:"Open menu, unread chats",yourPets:"Your Pets",yourPet:"Your pet",switchActivePet:"Switch active pet, {name}",petCurrentlyActive:"{name}, currently active",switchToPet:"Switch to {name}",activePrefix:"Active \xB7 ",close:"Close",addAnotherPet:"Add another pet",addPet:"Add a pet",attachmentPhoto:"Photo",attachmentCamera:"Camera",closeAttachmentPicker:"Close attachment picker",addAttachment:"Add attachment, {used} of {total} used",attachmentsFull:"Attachments full, {used} of {total} used",retryUpload:"Retry uploading {filename}",removeAttachment:"Remove {filename}",previewAttachment:"Preview {filename}",closePreview:"Close preview",attachedImage:"Attached image: {filename}, opens a full-screen preview",attachmentTooLarge:"Files must be under {max}. {filename} is {size}.",attachmentTooMany:"You can attach up to {max} files per message.",attachmentUnsupported:"{filename} isn't a supported file type yet.",attachmentNetwork:"Couldn't reach the server. Check your connection and try again.",attachmentServer:"Upload failed{status}. Please try again.",attachmentCancelled:"Upload cancelled.",attachmentRateLimited:"Slow down. Please wait a moment and try again.",attachmentQuota:"Daily image limit reached. Try again tomorrow.",attachmentConflict:"Something went wrong. Tap to retry.",attachmentUnknown:"Something went wrong. Please try again.",attachmentsFailedBlocked:"Some attachments failed to upload. Remove or retry them before sending.",dictate:"Dictate a message",stopDictation:"Stop dictation",listening:"Listening",micBlocked:"Microphone access is blocked. Allow it in your browser settings to dictate.",noSpeech:"We didn't catch that. Tap the mic and try again.",dictationUnavailable:"Voice typing isn't available right now."});function W(e,t){return e.replace(/\{(\w+)\}/g,(r,n)=>{let o=t[n];return o===void 0?r:String(o)})}i(W,"fillCopy");var wr=Object.freeze([Object.freeze({key:"inaccurate",label:p.feedbackReasonInaccurate,feedbackType:"wrong"}),Object.freeze({key:"outdated",label:p.feedbackReasonOutdated,feedbackType:"outdated"}),Object.freeze({key:"unsafe",label:p.feedbackReasonUnsafe,feedbackType:"dangerous"}),Object.freeze({key:"unclear",label:p.feedbackReasonUnclear,feedbackType:"unclear"}),Object.freeze({key:"other",label:p.feedbackReasonOther,feedbackType:"not_helpful"})]),to=Object.freeze([Object.freeze({sentiment:"up",label:p.feedbackHelpful}),Object.freeze({sentiment:"neutral",label:p.feedbackNeutral}),Object.freeze({sentiment:"down",label:p.feedbackNotHelpful})]);function Dl(e){switch(e){case "up":return "helpful";case "neutral":return "neutral";case "down":return "not_helpful"}}i(Dl,"sentimentToFeedbackType");function ro(e,t){if(e==="down"&&t!==null){let r=wr.find(n=>n.key===t);if(r!==void 0)return r.feedbackType}return Dl(e)}i(ro,"feedbackTypeFor");var no=Symbol.for("@everfur/sdk#EverfurContext@v1"),oo=globalThis,io=oo[no]??(oo[no]=createContext(null));io.displayName??="EverfurContext";function ae(){let e=useContext(io);if(e===null)throw new dt("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}i(ae,"useEverfurContext");var zl=Object.freeze({status:"idle",messages:Object.freeze([]),conversationId:null,error:null,isStreaming:false,isBootstrapping:true,suggestedPrompts:Object.freeze([]),unreadCount:null});function Ft(e){let{runtime:t,userRef:r,activePet:n,scopeEpoch:o}=ae(),a=e?.petRef??n??null,s=e?.conversationId??null,d=useMemo(()=>({runtime:t,userRef:r,petRef:a,conversationId:s,scopeEpoch:o}),[t,r,a,s,o]),[l,c]=useState(null),u=l?.scope===d?l.controller:t.registry.peekChat({userRef:r,petRef:a,conversationId:s}),f=useRef(null);useEffect(()=>{let P=t.registry.acquireChat({userRef:r,petRef:a,conversationId:s});return f.current=P,c({scope:d,controller:P}),()=>{f.current=null,c(S=>S?.controller===P?null:S),t.registry.releaseChat(P);}},[t,r,a,s,o,d]);let y=useCallback(P=>u?u.subscribe(P):Bl,[u]),g=useCallback(()=>u?u.getSnapshot():zl,[u]),h=useSyncExternalStore(y,g,g),_=useCallback((P,S)=>u&&f.current===u&&!u.getSnapshot().isBootstrapping?xr(u,u.send(P,S?.imageS3Keys===void 0?{}:{imageS3Keys:S.imageS3Keys}),()=>f.current===u):Promise.resolve(Ir()),[u]),m=useCallback(P=>u&&f.current===u&&!u.getSnapshot().isBootstrapping?xr(u,u.askEverfur(P),()=>f.current===u):Promise.resolve(Ir()),[u]),T=useCallback(()=>u&&f.current===u?xr(u,u.retryLast(),()=>f.current===u):Promise.resolve(Ir()),[u]),A=useCallback(()=>{u&&f.current===u&&u.stop();},[u]),O=useCallback(()=>{u&&f.current===u&&u.adoptConversation(null);},[u]),[F,C]=useState({controller:null,byMessage:{}}),E=F.controller===u?F.byMessage:jl,R=useCallback(async(P,S,x,U)=>{if(!u||f.current!==u)return M(Y("accessDenied"));let j=String(P),z=F.controller===u?F.byMessage[j]:void 0;if(z===S&&x==null)return C(ie=>{let B={...ie.controller===u?ie.byMessage:{}};return delete B[j],{controller:u,byMessage:B}}),de(Object.freeze({feedbackId:""}));C(ie=>({controller:u,byMessage:{...ie.controller===u?ie.byMessage:{},[j]:S}}));let re=await u.submitFeedback(P,ro(S,x??null),U??null);return f.current!==u?M(Y("accessDenied")):(re.ok||C(ie=>{let B={...ie.controller===u?ie.byMessage:{}};return z===void 0?delete B[j]:B[j]=z,{controller:u,byMessage:B}}),re)},[u,F]),L=useMemo(()=>{let P=i(async S=>{if(!u||f.current!==u)return M(Y("accessDenied"));let x=await S(u);return f.current===u?x:M(Y("accessDenied"))},"run");return {listConversations:i(S=>P(x=>x.listConversations({...a?{petRef:a}:{},...S})),"listConversations"),getMessages:i((S,x)=>P(U=>U.getMessages(S,x)),"getMessages"),resumeConversation:i(S=>P(x=>x.resumeConversation(S)),"resumeConversation"),loadOlderMessages:i(()=>P(S=>S.loadOlderMessages()),"loadOlderMessages"),markRead:i(()=>P(S=>S.markRead()),"markRead"),refreshActiveThread:i(()=>P(S=>S.refreshActiveThread()),"refreshActiveThread"),answerCheckin:i((S,x)=>P(U=>U.answerCheckin(S,x)),"answerCheckin"),openCheckin:i(S=>P(x=>x.openCheckin(S)),"openCheckin")}},[u,a]);return useMemo(()=>({status:h.status,messages:h.messages,conversationId:h.conversationId,petRef:a,error:h.error,isStreaming:h.isStreaming,isBootstrapping:h.isBootstrapping,historyCursor:h.historyCursor??null,isLoadingHistory:h.isLoadingHistory??false,stopped:h.stopped??false,reconnecting:h.reconnecting??false,...L,suggestedPrompts:h.suggestedPrompts,unreadCount:h.unreadCount,hasUnreadThreads:h.hasUnreadThreads??false,newConversation:O,sentimentByMessage:E,feedback:R,send:_,askEverfur:m,retryLast:T,stop:A}),[h,a,_,m,T,A,L,O,E,R])}i(Ft,"useEverfurChat");var Bl=i(()=>{},"NOOP_UNSUBSCRIBE"),jl=Object.freeze({});async function xr(e,t,r){for await(let o of t);if(!r())return M(Y("accessDenied"));let n=e.getSnapshot();return n.status==="error"&&n.error!==null?M(n.error):de(Wl(n.messages))}i(xr,"driveToResult");function Wl(e){for(let t=e.length-1;t>=0;t-=1){let r=e[t];if(r&&r.role==="assistant"&&r.responseId!==void 0)return r.responseId}return null}i(Wl,"lastAssistantResponseId");function Ir(){return M(Y("internalError",{retryable:true}))}i(Ir,"notReadyError");function Ar(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.keys(e))Ar(e[t]);}return e}i(Ar,"deepFreeze");var Gl=Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3}),lo={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},co={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},so={nano:8,small:9,micro:10,tiny:11,caption:12,bodyTight:13,body:14,subtitle:16,heading:18,verdict:24},ql={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},Yl={regular:"400",medium:"500",bold:"700"},Kl={eyebrow:1,monoWide:.9,headerBrand:-0.42,tight:-0.35},$l=0,Mt="System",Dt="monospace",Ql=["content","heading","control","compact","badge"];function Xl(e){let t={};for(let r of Ql)t[r]=e;return t}i(Xl,"authoredTierSizes");function uo(){return {family:Mt,mono:Dt,fontUrl:null,families:{regular:Mt,medium:Mt,bold:Mt,mono:Dt,monoMedium:Dt,monoBold:Dt},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:so,tierSizes:Xl(so),lineHeight:ql,weight:Yl,letterSpacing:Kl,scale:1,maxScale:$l,scaleCaps:Gl}}i(uo,"baseType");var po={},De=Object.freeze({standard:Object.freeze([.2,0,0,1]),emphasized:Object.freeze([.2,.8,.2,1]),exit:Object.freeze([.4,0,1,1])});function Vt(e){return `cubic-bezier(${e.join(", ")})`}i(Vt,"cssCubicBezier");var fo={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:Vt(De.standard),emphasized:Vt(De.emphasized),exit:Vt(De.exit)},reducedMotion:false},Zl={brand:"#10462E",brandSoft:"rgba(16,70,46,0.10)",brandSofter:"rgba(16,70,46,0.15)",brandBorder:"rgba(16,70,46,0.18)",borderHairlineGreen:"rgba(16,70,46,0.25)",brandBorderStrong:"rgba(16,70,46,0.55)",brandInk:"#10462E",linkInk:"#10462E",surface:"#FFFFFF",surfaceCream:"#FDFBF8",surfaceSubtle:"#EFE9E3",background:"#FFFFFF",borderRingCream:"#D8D2C8",chatGround:"#FFFFFF",composerFill:"#FDFBF8",composerBorder:"rgba(16,70,46,0.75)",shadow:"#0B3421",text:{primary:"#111111",secondary:"#0E462E",muted:"#6E6660",placeholder:"rgba(61,61,61,0.75)",onBrand:"#FFFFFF",metaCool:"#3D3D3D",timestamp:"rgba(61,61,61,0.75)"},primary:"#10462E",onPrimary:"#FFFFFF",accent:"#10462E",onAccent:"#FFFFFF",accentEdge:"#07C168",success:"#07C168",danger:"#B91C1C",errorRed:"#FF1B00",warningStrong:"#A45610",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.12)",badgeBgCaution:"rgba(217,130,29,0.14)",badgeBgCritical:"rgba(185,28,28,0.12)",badgeBgNeutral:"rgba(110,102,96,0.12)",bubbleUser:"#10462E",bubbleAssistant:"#FFFFFF",skeleton:"#EFE9E3",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)"},yo=Ar({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:Zl,space:lo,radius:co,type:uo(),motion:fo,slots:po}),Jl={brand:"#6BD39A",brandSoft:"rgba(107,211,154,0.12)",brandSofter:"rgba(107,211,154,0.18)",brandBorder:"rgba(107,211,154,0.22)",borderHairlineGreen:"rgba(107,211,154,0.28)",brandBorderStrong:"rgba(107,211,154,0.55)",brandInk:"#6BD39A",linkInk:"#6BD39A",surface:"#1C1F23",surfaceCream:"#23272C",surfaceSubtle:"#23272C",background:"#15171A",borderRingCream:"#3A3F45",chatGround:"#1C1F23",composerFill:"#23272C",composerBorder:"rgba(107,211,154,0.75)",shadow:"#000000",text:{primary:"#F5F3F0",secondary:"#A9E4C4",muted:"#9A938C",placeholder:"rgba(255,255,255,0.55)",onBrand:"#0E1F17",metaCool:"#C9C9C9",timestamp:"rgba(245,243,240,0.7)"},primary:"#6BD39A",onPrimary:"#0E1F17",accent:"#6BD39A",onAccent:"#0E1F17",accentEdge:"#34D888",success:"#07C168",danger:"#F87171",errorRed:"#FF6B5B",warningStrong:"#F0A35E",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.18)",badgeBgCaution:"rgba(217,130,29,0.20)",badgeBgCritical:"rgba(185,28,28,0.22)",badgeBgNeutral:"rgba(255,255,255,0.10)",bubbleUser:"#6BD39A",bubbleAssistant:"#1C1F23",skeleton:"#23272C",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)"};Ar({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:Jl,space:lo,radius:co,type:uo(),motion:fo,slots:po});var mo=Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),ho=globalThis,Or=ho[mo]??(ho[mo]=createContext(yo));Or.displayName??="EverfurThemeContext";function w(){return useContext(Or)}i(w,"useEverfurTheme");function id(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}i(id,"tierMultiplier");function b({tier:e="content",...t}){let{type:r}=w(),n=id(r,e);return createElement(Text,n===void 0?t:{maxFontSizeMultiplier:n,...t})}i(b,"Text");var Xe=forwardRef(i(function(t,r){return createElement(TextInput,{...t,...r===null?{}:{ref:r}})},"TextInput"));function Lt(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}i(Lt,"assertNever");function bo(e){return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryable,wireMessage:e.wireMessage,synthesized:e.synthesized,lastEventId:e.lastEventId,serverRequestId:e.serverRequestId??null})}i(bo,"errorFrame");function ld(e){let t={};return e.mode==="personalized"?t.authorization=`Bearer ${e.token}`:t["x-everfur-partner-key"]=e.publishableKey,e.userRef&&(t["x-everfur-user-ref"]=e.userRef),e.sessionId&&(t["x-everfur-session-id"]=e.sessionId),t}i(ld,"authHeaders");function ct(e,t){return {...e,headers:{...dd(e.headers),...ld(t)}}}i(ct,"withAuthHeaders");function dd(e){if(!e)return {};let t={};for(let[r,n]of Object.entries(e)){let o=r.toLowerCase();o==="authorization"||o==="x-everfur-partner-key"||(t[r]=n);}return t}i(dd,"stripAuthHeaders");async function vo(e,t){if(t.mode==="anonymous")return t.transport.request(ct(e,{mode:"anonymous",publishableKey:t.publishableKey,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));let r;try{r=await t.identity.currentToken();}catch{return M(Fr())}let n=await t.transport.request(ct(e,{mode:"personalized",token:r,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(n.ok||n.error.httpStatus!==401)return n;let o;try{o=await t.identity.currentToken({forceRefresh:!0});}catch{return M(Fr())}let a=await t.transport.request(ct(e,{mode:"personalized",token:o,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return !a.ok&&a.error.httpStatus===401?M(Fr(a.error.httpStatus)):a}i(vo,"authedSend");function Fr(e){return Y("authRejected",{retryable:false,...e!==void 0?{httpStatus:e}:{}})}i(Fr,"authRejectedError");function Co(e){return Y("internalError",{retryable:true,wireMessage:cd(e)})}i(Co,"networkError");function cd(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}i(cd,"describeCause");var ud=3e4,pd=Tr*2,fd="idempotency-key",yd=new Set(["POST","PUT","PATCH","DELETE"]),md=Object.freeze({onEvent(){}}),hd=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function gd(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}i(gd,"seededIdempotencyKey");function Ve(e){let t=e.observer??md,r=e.timers??hd,n=e.rng??Math.random,o=e.sleep??((y,g)=>Id(y,r,g)),a=e.maxAttempts??Zn,s=e.unaryTimeoutMs??ud,d=e.newIdempotencyKey??vd(),l=i(y=>{try{t.onEvent(y);}catch{}},"emit");async function c(y,g,h){let _=h?.maxAttempts,m=Math.max(1,_??a),T=h?.idempotent??yd.has(g.method),A=h?.idempotencyKey===void 0?null:gd(h.idempotencyKey),O=T?A??d():null,F=bd(g,O),C=0;for(;;){let E=i(j=>Object.freeze({call:y,method:g.method,path:g.path,attempt:C,...O?{idempotencyKey:O}:{},...j}),"stamp");l(E({phase:"attempt"}));let R=_d(s,r),L=xd(R.signal,g.signal),P;try{P=await vo({...F,signal:L.signal},e.auth);}catch(j){P=M(Co(j));}finally{L.dispose(),R.cancel();}if(P.ok)return l(E({phase:"settled",ok:true,reason:"ok"})),P;let S=P.error,x=Ed(S,C,{maxAttempts:m,rng:n,now:r.now(),aborted:g.signal?.aborted===true,..._!==void 0?{perCallMaxAttempts:_}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),U={ok:false,code:S.code,reason:x.reason,...S.httpStatus!==void 0?{httpStatus:S.httpStatus}:{},...S.requestId!==void 0?{requestId:S.requestId}:{}};if(!x.retry)return l(E({phase:"settled",...U})),M(S);if(l(E({phase:"retry",...U,delayMs:x.delayMs})),await o(x.delayMs,g.signal),g.signal?.aborted===true)return l(E({phase:"settled",...U,reason:"aborted"})),M(S);C+=1;}}i(c,"send");async function u(y){return ct(y,await wd(e.auth))}i(u,"authorize");async function*f(y,g,h){l(Object.freeze({call:y,phase:"stream.open",method:g.method,path:g.path,attempt:0}));try{yield*e.auth.transport.stream(g,h);}catch{yield bo({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:null});}}return i(f,"stream"),Object.freeze({send:c,authorize:u,stream:f})}i(Ve,"createRequestFunnel");function bd(e,t){let r={};for(let[n,o]of Object.entries(e.headers??{}))n.toLowerCase()!==fd&&(r[n]=o);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}i(bd,"assembleHeaders");function vd(){let e=0;return ()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}i(vd,"defaultIdempotencyKeyFactory");var Cd=10;function Ed(e,t,r){if(r.aborted)return {retry:false,reason:"aborted"};let n=Rd(e);if(n==="quota")return {retry:false,reason:"daily-quota-exhausted"};if(n!=="burst"&&!Pr(e.code))return {retry:false,reason:"terminal-code"};let o=n==="burst"?"burst-throttle":"retryable-code";if(i(()=>{if(r.policy===void 0)return false;try{return !r.policy.shouldRetry(e.code,t)}catch{return false}},"policyVetoedRetry")())return {retry:false,reason:"terminal-code"};let s=i(()=>{if(r.policy===void 0)return null;let c;try{c=r.policy.maxAttempts(e.code);}catch{return null}return typeof c!="number"||!Number.isFinite(c)?null:Math.max(1,Math.min(Cd,Math.floor(c)))},"policyCeiling"),d=r.perCallMaxAttempts??s()??r.maxAttempts;if(t+1>=d)return {retry:false,reason:"attempts-exhausted"};let l=Sd(e,r.now);return l!==null?l>pd?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:o,delayMs:l}:{retry:true,reason:o,delayMs:Jn(t,r.rng)}}i(Ed,"decideRetry");function Rd(e){let t=e.code==="unknown"?Qn(kd(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}i(Rd,"throttleKind");function Sd(e,t){let r=Pd(e.raw);if(r===null)return null;let n=r-t;return n>0?n:0}i(Sd,"retryOverrideMs");function Pd(e){for(let t of Ro(e)){let r=t.resets_at,n=Td(r);if(n!==null)return n}return null}i(Pd,"findResetsAt");function Ro(e){if(!Eo(e))return [];let t=[e];for(let r of ["error","detail"]){let n=e[r];Eo(n)&&t.push(n);}return t}i(Ro,"candidateScopes");function Td(e){if(typeof e=="number"&&Number.isFinite(e))return e<1e11?Math.round(e*1e3):Math.round(e);if(typeof e=="string"&&e.trim().length>0){let t=Date.parse(e);return Number.isFinite(t)?t:null}return null}i(Td,"parseInstantMs");function kd(e){for(let t of Ro(e)){let r=t.code;if(typeof r=="string"&&r.length>0)return r}return null}i(kd,"rawWireCode");function Eo(e){return typeof e=="object"&&e!==null}i(Eo,"isRecord");async function wd(e){return e.mode==="anonymous"?{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{}}:{mode:"personalized",token:await e.identity.currentToken(),userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{}}}i(wd,"resolveDeviceAuth");function _d(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return {signal:r.signal,cancel:i(()=>t.clearTimeout(n),"cancel")}}i(_d,"boundedSignal");function xd(e,t){let r=i(()=>{},"noop");if(!t)return {signal:e,dispose:r};let n=new AbortController;if(e.aborted||t.aborted)return n.abort(),{signal:n.signal,dispose:r};let o=i(()=>n.abort(),"onAbort");return e.addEventListener("abort",o,{once:true}),t.addEventListener("abort",o,{once:true}),{signal:n.signal,dispose:i(()=>{e.removeEventListener("abort",o),t.removeEventListener("abort",o);},"dispose")}}i(xd,"mergeSignals");function Id(e,t,r){return e<=0||r?.aborted===true?Promise.resolve():new Promise(n=>{let o=t.setTimeout(()=>{r?.removeEventListener("abort",a),n();},e),a=i(()=>{t.clearTimeout(o),n();},"onAbort");r?.addEventListener("abort",a,{once:true});})}i(Id,"delayAbortable");function Nt(e){for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let n=e.charCodeAt(t+1);if(!(n>=56320&&n<=57343))return true;t+=1;}else if(r>=56320&&r<=57343)return true}return false}i(Nt,"hasLoneSurrogate");function Ht(e){return [...e].length}i(Ht,"serverLength");var So=Object.freeze(["better","same","worse"]);var Po=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function To(e,t,r){return new Promise(n=>{if(t.aborted){n();return}let o={handle:void 0},a=i(()=>{r.clearTimeout(o.handle),t.removeEventListener("abort",a),n();},"done");o.handle=r.setTimeout(a,e),t.addEventListener("abort",a,{once:true});})}i(To,"delayAbortable");var Ad="watching";function ko(e){return e.status!=null&&e.status!==Ad}i(ko,"isCheckinSettled");var Ut=4e3;var zt=4e3;var Md=Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function wo(e){return e!==Md}i(wo,"isUploadTransportAvailable");var Dd=Object.freeze(["image/jpeg","image/jpg","image/png","image/heic","image/heif","image/webp"]);var Bt=10*1024*1024,jt=5,ut=120,Vd="/widget/v1/uploads/initiate";function Ld(e){return typeof e=="string"&&Dd.includes(e.trim().toLowerCase())}i(Ld,"isAttachmentMime");function Mr(e){if(!e)return "attachment";let t=e.replace(/[\\/]+/g," ").replace(/[\x00-\x1f\x7f"]/g,"").replace(/\s+/g," ").trim();if(!t)return "attachment";if(t.length<=ut)return t;let r=t.lastIndexOf(".");if(r===-1||r===t.length-1)return t.slice(0,ut);let n=t.slice(r);return n.length>=ut?t.slice(0,ut):`${t.slice(0,r).slice(0,ut-n.length)}${n}`}i(Mr,"sanitizeFilename");function Dr(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}i(Dr,"formatBytes");var pt=i(e=>Object.freeze({ok:true,value:e}),"ok"),fe=i(e=>Object.freeze({ok:false,error:e}),"err");function J(e,t,r,n){return Object.freeze({code:e,retryable:t,filename:r,...n??{}})}i(J,"failure");function Nd(e){if(typeof e.sizeBytes=="number"&&Number.isFinite(e.sizeBytes)&&e.sizeBytes>=0)return e.sizeBytes;let t=e.blob;return t!==void 0&&typeof t.size=="number"&&Number.isFinite(t.size)?t.size:null}i(Nd,"attachmentSize");function Hd(e){let t=Mr(e.name),r=typeof e.mimeType=="string"?e.mimeType.trim().toLowerCase():"";if(!Ld(r))return fe(J("unsupported_type",false,t));let n=Nd(e);return n===null?fe(J("unknown",false,t)):n>Bt?fe(J("too_large",false,t,{sizeBytes:n})):pt(Object.freeze({file:e,filename:t,contentType:r,sizeBytes:n}))}i(Hd,"validateAttachment");function Ud(e){if(typeof e!="object"||e===null)return null;let t=e,r=i(c=>typeof c=="string"&&c.length>0?c:null,"str"),n=i(c=>typeof c=="number"&&Number.isFinite(c)?c:null,"num"),o=r(t.upload_id),a=r(t.upload_url),s=r(t.s3_key);if(o===null||a===null||s===null)return null;let d={},l=t.upload_fields;if(typeof l=="object"&&l!==null)for(let[c,u]of Object.entries(l))typeof u=="string"&&(d[c]=u);return Object.freeze({upload_id:o,upload_url:a,upload_fields:Object.freeze(d),expires_in_seconds:n(t.expires_in_seconds)??0,max_content_length:n(t.max_content_length)??Bt,s3_key:s,purpose:r(t.purpose)})}i(Ud,"parsePolicy");function zd(e,t){let r=e.httpStatus;switch(e.code){case "quotaExceeded":return J("quota_exceeded",false,t,{cause:e});case "rateLimited":return J("rate_limited",true,t,{cause:e});case "idempotencyConflict":case "idempotencyInFlight":return J("idempotency_conflict",true,t,{cause:e});case "validationFailed":return J("unsupported_type",false,t,{cause:e});case "serviceUnavailable":case "streamTimeout":return J("network",true,t,{cause:e});default:return r===429?J("rate_limited",true,t,{cause:e}):r===503?J("network",true,t,{cause:e}):r===void 0?J("network",true,t,{cause:e}):J("server",e.retryable,t,{httpStatus:r,cause:e})}}i(zd,"initiateFailure");async function Bd(e,t,r){let n=await e.send("chat.attachments.initiate",{method:"POST",path:Vd,body:{filename:t.filename,content_type:t.contentType,file_size:t.sizeBytes},...r?.signal?{signal:r.signal}:{}});if(!n.ok)return fe(zd(n.error,t.filename));let o=Ud(n.value);return o===null?fe(J("server",false,t.filename)):pt(o)}i(Bd,"initiateAttachmentUpload");async function jd(e,t,r,n){let o=i(()=>n?.signal?.aborted===true,"cancelled");if(o())return fe(J("cancelled",true,r.filename));try{return await e.postMultipart(t,r.file,{...n?.signal?{signal:n.signal}:{},...n?.onProgress?{onProgress:n.onProgress}:{}}),pt(void 0)}catch{return o()?fe(J("cancelled",true,r.filename)):fe(J("server",true,r.filename))}}i(jd,"uploadAttachmentBytes");var Wd=2,Gd=3,qd=Object.freeze([1e3,2e3,4e3]),_o=0;function Yd(){return _o+=1,`attachment-${_o}`}i(Yd,"defaultNewId");function xo(e){let t=Math.max(1,e.concurrency??Wd),r=Math.max(1,e.maxAttempts??Gd),n=e.backoffMs??qd,o=Math.max(1,e.maxPerMessage??jt),a=e.timers??Po,s=e.newId??Yd,d=wo(e.transport),l=new Map,c=[],u=[],f=new Set,y=new Set,g=Object.freeze({attachments:Object.freeze([])}),h=false,_=i(()=>{g=Object.freeze({attachments:Object.freeze(c.flatMap(C=>{let E=l.get(C);return E===void 0?[]:[E.state]}))});for(let C of y)C();},"publish"),m=i((C,E)=>{C.state=Object.freeze({...C.state,...E}),_();},"patch"),T=i(()=>{for(;!h&&f.size<t&&u.length>0;){let C=u.shift(),E=l.get(C);E!==void 0&&(f.add(C),A(E).finally(()=>{f.delete(C),T();}));}},"pump"),A=i(async C=>{let{attachment:E}=C;for(;C.attempts<r;){if(h||C.controller.signal.aborted)return;C.attempts+=1;let R=C.controller.signal;m(C,{status:"uploading",error:null,progress:0});let L=await Bd(e.funnel,E,{signal:R});if(h||R.aborted)return;let P;if(!L.ok)P=fe(L.error);else {let j=await jd(e.transport,L.value,E,{signal:R,onProgress:i(z=>{!R.aborted&&C.state.status==="uploading"&&m(C,{progress:Kd(z)});},"onProgress")});if(h||R.aborted)return;P=j.ok?pt(L.value.s3_key):fe(j.error);}if(P.ok){m(C,{status:"uploaded",s3Key:P.value,error:null,progress:1});return}let S=P.error,x=S.retryable&&C.attempts<r;if(m(C,{status:x?"uploading":"failed",error:S,progress:0}),!x)return;let U=n[Math.min(C.attempts-1,n.length-1)]??0;await To(U,R,a);}},"run"),O=i(C=>{u.push(C.state.id),T();},"enqueue"),F={available:d,subscribe(C){return y.add(C),()=>{y.delete(C);}},getSnapshot:i(()=>g,"getSnapshot"),get uploading(){return g.attachments.some(C=>C.status==="uploading")},get s3Keys(){return g.attachments.flatMap(C=>C.status==="uploaded"&&C.s3Key!==null?[C.s3Key]:[])},add(C){let E=Hd(C);if(!E.ok)return E;if(h||c.length>=o)return fe(J("too_many",false,E.value.filename));let R=s(),L={attachment:E.value,controller:new AbortController,attempts:0,state:Object.freeze({id:R,filename:E.value.filename,previewUri:C.uri,contentType:E.value.contentType,sizeBytes:E.value.sizeBytes,status:"uploading",s3Key:null,error:null,progress:0})};return l.set(R,L),c.push(R),_(),O(L),pt(L.state)},retry(C){let E=l.get(C);E===void 0||h||E.state.status!=="failed"||(E.controller=new AbortController,E.attempts=0,m(E,{status:"uploading",error:null,progress:0,s3Key:null}),O(E));},remove(C){let E=l.get(C);if(E===void 0)return;E.controller.abort(),l.delete(C);let R=c.indexOf(C);R>=0&&c.splice(R,1);let L=u.indexOf(C);L>=0&&u.splice(L,1),_();},clear(){for(let C of [...c])F.remove(C);},dispose(){h=true;for(let C of l.values())C.controller.abort();l.clear(),c.length=0,u.length=0,y.clear(),g=Object.freeze({attachments:Object.freeze([])});}};return F}i(xo,"createAttachmentQueue");function Kd(e){return Number.isNaN(e)||e<0?0:e>1?1:e}i(Kd,"clamp");function Ao(e){switch(e.code){case "too_large":return W(p.attachmentTooLarge,{max:Dr(Bt),filename:e.filename,size:Dr(e.sizeBytes??0)});case "too_many":return W(p.attachmentTooMany,{max:jt});case "unsupported_type":return W(p.attachmentUnsupported,{filename:e.filename});case "network":return p.attachmentNetwork;case "server":return W(p.attachmentServer,{status:e.httpStatus?` (${e.httpStatus})`:""});case "cancelled":return p.attachmentCancelled;case "rate_limited":return p.attachmentRateLimited;case "quota_exceeded":return p.attachmentQuota;case "idempotency_conflict":return p.attachmentConflict;case "unknown":return p.attachmentUnknown}}i(Ao,"attachmentErrorMessage");function Oo(e,t){return W(e>=t?p.attachmentsFull:p.addAttachment,{used:e,total:t})}i(Oo,"attachControlLabel");var Zd=Object.freeze({attachments:Object.freeze([])});function Vr(e={}){let{runtime:t,userRef:r,scopeEpoch:n}=ae(),o=e.maxPerMessage??jt,a=useMemo(()=>{if(e.queue)return e.queue;let{services:m}=t.registry;return xo({funnel:Ve({auth:m.authFor(r),...m.errorPolicy?{errorPolicy:m.errorPolicy}:{}}),transport:e.transport??m.uploadTransport,maxPerMessage:o})},[t,r,n,o,e.queue,e.transport]);useEffect(()=>()=>{a!==e.queue&&a.dispose();},[a,e.queue]);let s=useSyncExternalStore(a.subscribe,a.getSnapshot,()=>Zd),[d,l]=useState(null),c=useCallback(m=>{let A=(Array.isArray(m)?m:[m]).map(F=>a.add(F)),O=A.find(F=>!F.ok);return O!==void 0&&!O.ok&&l(O.error),A},[a,l]),u=useCallback(m=>a.retry(m),[a]),f=useCallback(m=>a.remove(m),[a]),y=useCallback(()=>a.clear(),[a]),g=useCallback(()=>l(null),[l]),h=s.attachments.some(m=>m.status==="uploading"),_=s.attachments.some(m=>m.status==="failed");return useMemo(()=>({available:a.available,attachments:s.attachments,maxPerMessage:o,uploading:h,failed:_,blocked:h||_,s3Keys:s.attachments.flatMap(m=>m.status==="uploaded"&&m.s3Key!==null?[m.s3Key]:[]),rejected:d,add:c,retry:u,remove:f,clear:y,dismissRejected:g}),[a.available,s,o,h,_,d,c,u,f,y,g])}i(Vr,"useChatAttachments");var Fo=Object.freeze({dog:"dog",canine:"dog",k9:"dog",puppy:"dog",cat:"cat",feline:"cat",kitten:"cat"});function Wt(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.prototype.hasOwnProperty.call(Fo,t)?Fo[t]:null}i(Wt,"canonicalPetSpecies");var Mo=50,Jd=128,Lr=120,Do=120,ec=2e3,Vo=120,tc=80,Ho=new Set(["male","female","unknown"]),Uo=new Set(["day","month","year"]),zo=new Set(["low","medium","high","athletic"]),Bo=new Set(["indoor","outdoor","both"]),jo=new Set(["mild","moderate","severe"]),rc=/^(\d{4})-(\d{2})-(\d{2})$/,Wo=[["sex","sex"],["spayedNeutered","spayed_neutered"],["birthDate","birth_date"],["birthDatePrecision","birth_date_precision"],["activityLevel","activity_level"],["indoorOutdoor","indoor_outdoor"],["foodBrand","food_brand"],["foodType","food_type"],["microchipId","microchip_id"]],Go=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];Object.freeze([...Wo,...Go].map(([e])=>e));function nc(e){let t=rc.exec(e);if(t===null)return false;let[r,n,o]=[Number(t[1]),Number(t[2]),Number(t[3])],a=new Date(Date.UTC(r,n-1,o));return a.getUTCFullYear()===r&&a.getUTCMonth()===n-1&&a.getUTCDate()===o}i(nc,"isRealDate");var mt=i(e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,"oneOf"),oc=i((e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,"boolean"),qt=i((e,t)=>typeof t=="string"&&nc(t)?null:`${e} must be a real date written YYYY-MM-DD`,"date"),be=i((e,t={})=>(r,n)=>{if(typeof n!="string")return `${r} must be a string`;if(Nt(n))return `${r} contains an unpaired surrogate and cannot be encoded`;let o=t.trimmed?n.trim():n;if(t.required&&o.length===0)return `${r} is required and must not be blank`;let a=Ht(o);return a<=e?null:`${r} is ${a} characters; the server accepts at most ${e}`},"text"),ic={sex:mt(Ho),spayedNeutered:oc,birthDate:qt,birthDatePrecision:mt(Uo),activityLevel:mt(zo),indoorOutdoor:mt(Bo),foodBrand:be(Vo),foodType:be(Vo),microchipId:be(tc)},Nr=["ref","ref",false,be(Jd,{required:true,trimmed:true})],Hr=["notes","notes",false,be(ec,{trimmed:true})],Lo=[Nr,["name","name",true,be(Lr,{required:true,trimmed:true})],["dose","dose",false,be(Do,{trimmed:true})],["frequency","frequency",false,be(Do,{trimmed:true})],["startDate","start_date",false,qt],["endDate","end_date",false,qt],Hr],ac={allergies:[Nr,["allergen","allergen",true,be(Lr,{required:true,trimmed:true})],["severity","severity",false,mt(jo)],Hr],medications:Lo,supplements:Lo,conditions:[Nr,["conditionName","condition_name",true,be(Lr,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,qt],Hr]};function sc(e,t,r){let n=`${e}[${t}]`;if(typeof r!="object"||r===null||Array.isArray(r))return {error:`${n} must be an object`};let o=r,a={};for(let[l,c,u,f]of ac[e]){let y=o[l];if(y==null){if(u)return {error:`${n}.${l} is required`};y===null&&(a[c]=null);continue}let g=f(`${n}.${l}`,y);if(g!==null)return {error:g};a[c]=y;}let s=a.start_date,d=a.end_date;return typeof s=="string"&&typeof d=="string"&&d<s?{error:`${n}.endDate must not be before startDate`}:{item:a}}i(sc,"itemToWire");function lc(e,t){if(!Array.isArray(t))return {error:`${e} must be an array (send [] to clear it)`};if(t.length>Mo)return {error:`${e} has ${t.length} items; the server accepts at most ${Mo}`};let r=[],n=new Set;for(let o=0;o<t.length;o+=1){let a=sc(e,o,t[o]);if("error"in a)return a;let s=a.item.ref;if(typeof s=="string"){let d=s.trim();if(n.has(d))return {error:`${e}: ref ${JSON.stringify(d)} is used twice; a ref names one item`};n.add(d);}r.push(a.item);}return {items:r}}i(lc,"listToWire");function qo(e,t){let r=e,n={};for(let[s,d]of Wo){let l=r[s];if(l!==void 0){if(l!==null){let c=ic[s](s,l);if(c!==null)return {error:c}}n[d]=l;}}let o=r.birthDate!==void 0,a=r.birthDatePrecision!==void 0;if(o!==a||o&&r.birthDate===null!=(r.birthDatePrecision===null))return {error:"birthDate and birthDatePrecision must be sent together, both set or both null"};for(let[s,d]of Go){let l=r[s];if(l===void 0)continue;let c=lc(s,l);if("error"in c)return c;n[d]=c.items;}return Object.keys(n).length>0&&t!==void 0&&Wt(t)===null?{error:"health fields need a pet Everfur reads as a dog or a cat (dog, canine, k9, puppy, cat, feline, kitten)"}:{body:n}}i(qo,"petHealthToWire");var Q=i(e=>typeof e=="string"?e:null,"str"),yt=i((e,t)=>typeof t=="string"&&e.has(t)?t:null,"pick"),dc=i(e=>typeof e=="boolean"?e:null,"bool");function Gt(e,t){return Array.isArray(e)?Object.freeze(e.flatMap(r=>{if(typeof r!="object"||r===null||Array.isArray(r))return [];let n=t(r);return n===null?[]:[n]})):Object.freeze([])}i(Gt,"itemsFromWire");function No(e){let t=Q(e.name);return t===null||t.length===0?null:Object.freeze({ref:Q(e.ref),name:t,dose:Q(e.dose),frequency:Q(e.frequency),startDate:Q(e.start_date),endDate:Q(e.end_date),notes:Q(e.notes)})}i(No,"medicationFromWire");function Yo(e){let t=e.profile_version;return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:yt(Ho,e.sex),spayedNeutered:dc(e.spayed_neutered),birthDate:Q(e.birth_date),birthDatePrecision:yt(Uo,e.birth_date_precision),activityLevel:yt(zo,e.activity_level),indoorOutdoor:yt(Bo,e.indoor_outdoor),foodBrand:Q(e.food_brand),foodType:Q(e.food_type),microchipId:Q(e.microchip_id),allergies:Gt(e.allergies,r=>{let n=Q(r.allergen);return n===null||n.length===0?null:Object.freeze({ref:Q(r.ref),allergen:n,severity:yt(jo,r.severity),notes:Q(r.notes)})}),medications:Gt(e.medications,No),supplements:Gt(e.supplements,No),conditions:Gt(e.conditions,r=>{let n=Q(r.condition_name);return n===null||n.length===0?null:Object.freeze({ref:Q(r.ref),conditionName:n,diagnosedDate:Q(r.diagnosed_date),notes:Q(r.notes)})})})}i(Yo,"petHealthFromWire");var Qo=100,Xo=50,Zo=100,Jo=50,ei=500,cc=128,uc=6e4;function Ce(e){return Y("validationFailed",{retryable:false,wireMessage:e})}i(Ce,"invalid");function Le(e,t,r){if(typeof t!="string")return Ce(`${e} must be a string`);let n=Ht(t);return n<=r?null:Ce(`${e} is ${n} characters; the server accepts at most ${r}`)}i(Le,"checkString");function Yt(e,t,r){return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=r?null:Ce(`${e} must be a finite number between 0 and ${r}`)}i(Yt,"outOfRange");function Ko(e,t){if(typeof e!="string")return Ce("pet_ref must be a string");if(e.trim().length===0)return Ce("pet_ref must not be blank");if(Nt(e))return Ce("pet_ref contains an unpaired surrogate and cannot be encoded");if(t!=null&&typeof t!="object")return Ce("profile must be an object");let r=[Le("pet_ref",e,cc)];return t?.name!==void 0&&r.push(Le("name",t.name,Qo)),t?.species!==void 0&&r.push(Le("species",t.species,Xo)),t?.breed!==void 0&&r.push(Le("breed",t.breed,Zo)),t?.ageYears!==void 0&&r.push(Yt("age_years",t.ageYears,Jo)),t?.weightKg!==void 0&&r.push(Yt("weight_kg",t.weightKg,ei)),r.find(n=>n!==null)??null}i(Ko,"validate");function ti(e,t){let r=qo(e,t);return "error"in r?{error:Ce(r.error)}:r}i(ti,"healthToWire");function pc(e){if(typeof e!="object"||e===null)return {error:Ce("patch must be an object")};let t=e,r=[["name","name",a=>Le("name",a,Qo)],["species","species",a=>Le("species",a,Xo)],["breed","breed",a=>Le("breed",a,Zo)],["ageYears","age_years",a=>Yt("age_years",a,Jo)],["weightKg","weight_kg",a=>Yt("weight_kg",a,ei)]],n={};for(let[a,s,d]of r){let l=t[a];if(l!==void 0){if(l!==null){let c=d(l);if(c!==null)return {error:c}}n[s]=l;}}let o=ti(t,t.species);return "error"in o?o:(Object.assign(n,o.body),Object.keys(n).length===0?{error:Ce("patch must change at least one field")}:{body:n})}i(pc,"patchToWire");function fc(e){if(e==null)return {body:{}};let t=ti(e,e.species);return "error"in t?t:{body:{...e.name!==void 0?{name:e.name}:{},...e.species!==void 0?{species:e.species}:{},...e.breed!==void 0?{breed:e.breed}:{},...e.ageYears!==void 0?{age_years:e.ageYears}:{},...e.weightKg!==void 0?{weight_kg:e.weightKg}:{},...t.body}}}i(fc,"toWire");var ve=i(e=>typeof e=="string"?e:null,"str"),Kt=i(e=>typeof e=="number"&&Number.isFinite(e)?e:null,"num");function $o(e,t){let r=typeof e=="object"&&e!==null?e:{};return Object.freeze({petRef:ve(r.pet_ref)??t,name:ve(r.name),species:ve(r.species),breed:ve(r.breed),ageYears:Kt(r.age_years),weightKg:Kt(r.weight_kg)})}i($o,"fromWire");function ri(e){if(typeof e!="object"||e===null)return null;let t=e,r=ve(t.pet_ref);return r===null||r.length===0?null:Object.freeze({petId:ve(t.pet_id),petRef:r,name:ve(t.name),species:ve(t.species),breed:ve(t.breed),ageYears:Kt(t.age_years),weightKg:Kt(t.weight_kg),updatedAt:ve(t.updated_at)})}i(ri,"widgetPetFromWire");function yc(e){let t=ri(e);return t===null?null:Object.freeze({...t,...Yo(e)})}i(yc,"widgetPetProfileFromWire");function mc(e){let t=Array.isArray(e)?e:typeof e=="object"&&e!==null&&Array.isArray(e.pets)?e.pets:[];return Object.freeze(t.flatMap(r=>{let n=ri(r);return n===null?[]:[n]}))}i(mc,"petListFromWire");function $t(e){return hc(Ve({auth:e}),Ve({auth:e,unaryTimeoutMs:uc}))}i($t,"createPetsRepository");function hc(e,t=e){let r=i((o,a)=>a?{...o,signal:a}:o,"withSignal"),n=i(o=>Ko(o,void 0)??`/widget/v1/pets/${encodeURIComponent(o)}`,"petPath");return {async list(o){let a=await e.send("pets.list",r({method:"GET",path:"/widget/v1/pets"},o?.signal));return a.ok?de(mc(a.value)):M(a.error)},async registerPet(o,a,s){let d=Ko(o,a);if(d!==null)return M(d);let l=fc(a);if("error"in l)return M(l.error);let u={method:"POST",path:`/widget/v1/pets/${encodeURIComponent(o)}`,body:l.body},f=await e.send("pets.registerPet",s?.signal?{...u,signal:s.signal}:u);return f.ok?de($o(f.value,o)):M(f.error)},async updatePet(o,a,s){let d=n(o);if(typeof d!="string")return M(d);let l=pc(a);if("error"in l)return M(l.error);let c=await e.send("pets.updatePet",r({method:"PATCH",path:d,body:l.body},s?.signal));return c.ok?de($o(c.value,o)):M(c.error)},async getPetProfile(o,a){let s=n(o);if(typeof s!="string")return M(s);let d=await e.send("pets.getPetProfile",r({method:"GET",path:`${s}/profile`},a?.signal));if(!d.ok)return M(d.error);let l=yc(d.value);return l===null?M(Y("internalError",{retryable:false,httpStatus:502,wireMessage:"the pet profile response carried no pet_ref"})):de(l)},async deletePet(o,a){let s=n(o);if(typeof s!="string")return M(s);let d=await e.send("pets.deletePet",r({method:"DELETE",path:s},a?.signal));return d.ok?de(void 0):M(d.error)},async eraseUserData(o){let a=await t.send("pets.eraseUserData",r({method:"DELETE",path:"/widget/v1/me"},o?.signal),{maxAttempts:1});return a.ok?de(void 0):M(a.error)}}}i(hc,"createPetsRepositoryOver");var vc="pet_not_registered";function ii(e){return e!=null&&e.reasonCode===vc}i(ii,"isPetNotRegistered");var Cc=Object.freeze({status:"idle",error:null,registered:null,retry:i(()=>{},"retry")});function ai(e,t,r){let{runtime:n,userRef:o,scopeEpoch:a}=ae(),s=useCallback(()=>$t(n.registry.services.authFor(o)),[n,o,a]),d=useMemo(()=>t===void 0?null:zr(t),[t]),[l,c]=useState({key:null,status:"idle",error:null,registered:null}),u=useRef(0),f=useRef(r);f.current=r;let y=e===null||d===null?null:`${String(o)}|${a}|${e}|${d}`,g=useCallback(()=>{if(e===null||t===void 0||y===null)return;let _=++u.current;c({key:y,status:"registering",error:null,registered:null}),s().registerPet(e,t).then(m=>{_===u.current&&(m.ok?(c({key:y,status:"registered",error:null,registered:m.value}),f.current?.()):c({key:y,status:"failed",error:m.error,registered:null}));});},[s,e,y]);useEffect(()=>{if(y===null){u.current+=1;return}return g(),()=>{u.current+=1;}},[y,g]);let h=useCallback(()=>{l.status==="failed"&&g();},[l.status,g]);return useMemo(()=>y===null?Cc:l.key!==y?{status:"registering",error:null,registered:null,retry:h}:{status:l.status,error:l.error,registered:l.registered,retry:h},[y,l,h])}i(ai,"useChatPetRegistration");function zr(e){return e===null||typeof e!="object"?JSON.stringify(e)??"undefined":Array.isArray(e)?`[${e.map(zr).join(",")}]`:`{${Object.entries(e).filter(([,r])=>r!==void 0).sort(([r],[n])=>r<n?-1:r>n?1:0).map(([r,n])=>`${JSON.stringify(r)}:${zr(n)}`).join(",")}}`}i(zr,"stableKey");var Br=Object.freeze({});function li(e){let[t,r]=useState(Br),n=useRef(null),o=useRef([]);o.current=e.map(s=>s.id),useEffect(()=>{if(e.length===0){n.current=null,r(l=>l===Br?l:Br);return}let s=n.current;if(s===null)return;let d=e.find(l=>l.role==="user"&&!s.known.has(l.id));d!==void 0&&(n.current=null,r(l=>({...l,[d.id]:s.images})));},[e]);let a=useCallback(s=>{n.current=s.length===0?null:{images:s,known:new Set(o.current)};},[]);return useMemo(()=>({byMessage:t,stage:a}),[t,a])}i(li,"useSentImages");var kc=500;function jr(e){if(!e)return null;let t=e.replace(/[\u0000-\u001F\u007F-\u009F\u200E\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g," ").replace(/\s+/g," ").trim();return t?t.slice(0,kc):null}i(jr,"sanitizeSeedPrompt");function ci(e,t,r){let n=jr(r),o=useRef(e);o.current=e;let a=useRef(null);useEffect(()=>{if(n===null||t||a.current===n)return;let s=o.current;s!==void 0&&(a.current=n,Promise.resolve(s(n)).catch(()=>{}));},[n,t]);}i(ci,"useInitialAsk");function wc(e,t,r){if(e==="announced")return false;let n=r.lastRefresh;return n===null||n.conversationId!==t?false:r.now-n.at<15e3}i(wc,"isCoalesced");function ui(e,t){let r=t.activeConversationId;return r===null||r.length===0?{action:"skip",reason:"no_thread"}:t.isTurnInFlight?{action:"defer",reason:"turn_in_flight"}:t.isOffline?{action:"defer",reason:"offline"}:wc(e,r,t)?{action:"skip",reason:"coalesced"}:{action:"refresh",conversationId:r}}i(ui,"decideChatRefresh");function Wr(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e);}catch{}}i(Wr,"reportHostFailure");function _c(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(_c,"isThenable");function G(e,...t){if(typeof e=="function")try{let r=e(...t);return _c(r)&&Promise.resolve(r).then(void 0,Wr),r}catch(r){Wr(r);return}}i(G,"callHost");var pi=new WeakMap;function fi(e){if(typeof e!="function")return;let t=pi.get(e);if(t!==void 0)return t;let r=i((...n)=>{G(e,...n);},"guarded");return pi.set(e,r),r}i(fi,"guardHost");function Ze(e,...t){let r;try{r=e(...t);}catch(n){return Wr(n),Promise.resolve({ok:false,error:n})}return Promise.resolve(r).then(n=>({ok:true,value:n}),n=>({ok:false,error:n}))}i(Ze,"callHostAsync");function mi(e,t){let r=useRef(t);r.current=t;let n=useRef(null),o=useRef(null),a=e?.isOffline===void 0?false:G(()=>e.isOffline?.()===!0)===true,s=useRef(()=>{});s.current=d=>{let{conversationId:l,isTurnInFlight:c,refresh:u}=r.current,f=ui(d,{activeConversationId:l,isTurnInFlight:c,isOffline:a,lastRefresh:n.current,now:Date.now()});if(f.action!=="skip"){if(f.action==="defer"){o.current!=="announced"&&(o.current=d);return}o.current=null,n.current={conversationId:f.conversationId,at:Date.now()},u!==void 0&&Promise.resolve(u()).catch(()=>{});}},useEffect(()=>{if(t.isTurnInFlight||a)return;let d=o.current;d!==null&&s.current(d);},[t.isTurnInFlight,a]),useEffect(()=>{if(e===void 0)return;let d=[],l=i((c,u)=>{if(c===void 0)return;let f=G(()=>c(()=>{s.current(u);}));typeof f=="function"&&d.push(f);},"subscribe");return l(e.onForeground?.bind(e),"foreground"),l(e.onOnline?.bind(e),"foreground"),l(e.onAnnounced?.bind(e),"announced"),()=>{for(let c of d)G(c);}},[e]);}i(mi,"useChatLifecycle");function Ic(e){if(e===void 0)return null;let t=e.conversationId??"",r=e.petRef??"";return t===""&&r===""?null:`${String(t)}|${String(r)}`}i(Ic,"targetKey");function gi(e,t){let r=Ic(t),n=useRef({openCheckin:e,target:t});n.current={openCheckin:e,target:t};let o=useRef(null);useEffect(()=>{if(r===null||o.current===r)return;o.current=r;let{openCheckin:a,target:s}=n.current;a===void 0||s===void 0||Promise.resolve(a(s)).catch(()=>{});},[r]);}i(gi,"useCheckinTarget");function Ci(e,t,r){let[n,o]=useState({send:e,conversationId:t,text:r??"",seeded:r??null}),a=n.send===e&&(n.conversationId===null||n.conversationId===t);useEffect(()=>{o(d=>{let l=d.send===e&&(d.conversationId===null||d.conversationId===t),c=l?d.text:"",u=l?d.seeded:null,f=r!=null&&r!==u&&c.length===0;return {send:e,conversationId:t,text:f?r:c,seeded:f?r:u}});},[e,t,r]);let s=useCallback(d=>o(l=>({send:e,conversationId:t,text:d,seeded:l.seeded})),[e,t]);return [a?n.text:"",s]}i(Ci,"useChatDraft");function Ei(e,t,r,n){let o=useRef({draft:r,setDraft:n});o.current={draft:r,setDraft:n};let a=useRef(null),[s,d]=useState(null);useEffect(()=>{if(e===void 0)return;let l=`${t??""}`;if(a.current===l)return;a.current=l;let c=true;return (async()=>{let u=await Ze(()=>e.read(t));if(!c)return;let f=u.ok&&typeof u.value=="string"?u.value:"";f.length>0&&o.current.draft.length===0&&o.current.setDraft(f),d(l);})(),()=>{c=false;}},[e,t]),useEffect(()=>{e===void 0||s!==`${t??""}`||G(()=>e.write(t,r));},[e,t,r,s]);}i(Ei,"usePersistedDraft");var K=Object.freeze({heading:"Chat History",empty:"No chats yet",emptyBody:"Start a new conversation to see it here.",noMatch:"No matching chats",noMatchBody:"Try a different title or start a new conversation.",loading:"Loading your chats\u2026",loadFailed:"Couldn\u2019t load your chats",loadingMore:"Loading more\u2026",untitled:"New conversation",newConversation:"New conversation",search:"Search",retry:"Try again",retryA11y:"Retry loading chats",close:"Close",closeA11y:"Close history",more:"Load more",earlier:"Load earlier messages",loadingEarlier:"Loading earlier messages\u2026",openConversation:"Open conversation",unreadPrefix:"Unread. "});function Xt(e){let t=e?.replace(/\s+/g," ").trim();return t||K.untitled}i(Xt,"conversationTitle");function Si(e){return `${e.unreadCount!==null&&e.unreadCount>0?K.unreadPrefix:""}${K.openConversation} ${Xt(e.title)}`}i(Si,"openConversationLabel");function Ri(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').toLowerCase().trim().replace(/\s+/g," ")}i(Ri,"normalizeForSearch");function Vc(e,t){let r=Ri(t);if(r.length===0)return e;let n=[[],[],[]];for(let o of e){let a=Ri(Xt(o.title)),s=a.indexOf(r);if(s<0)continue;let d=s===0?0:a.charAt(s-1)===" "?1:2;n[d]?.push(o);}return n.flat()}i(Vc,"filterConversations");function Yr(e){return {scope:e,rows:[],cursor:null,loading:false,loadingMore:false,error:null}}i(Yr,"fresh");function Pi(e){let[t,r]=useState(false),[n,o]=useState(""),a=e.listConversations,s=useRef(0),[d,l]=useState(()=>Yr(a)),c=d.scope===a?d:Yr(a);useEffect(()=>(s.current+=1,r(false),o(""),l(Yr(a)),()=>{s.current+=1;}),[a]);let u=useCallback(async O=>{let F=++s.current,C=O!==void 0;l(R=>({...R,scope:a,loading:!C,loadingMore:C,error:null}));let E=await e.listConversations(O?{cursor:O}:void 0);if(F===s.current){if(!E.ok){l(R=>({...R,loading:false,loadingMore:false,error:E.error.displayMessage}));return}l(R=>{let L=O&&R.scope===a?R.rows:[],P=new Set(L.map(S=>S.id));return {scope:a,loading:false,loadingMore:false,error:null,rows:[...L,...E.value.conversations.filter(S=>!P.has(S.id))],cursor:E.value.nextCursor===O?null:E.value.nextCursor}});}},[e.listConversations,a]),f=i(()=>{r(true),o(""),u();},"show"),y=i(()=>{s.current+=1,r(false);},"close"),g=i(async O=>{let F=++s.current;l(E=>({...E,loading:true,error:null}));let C=await e.resumeConversation(O);F===s.current&&(l(E=>({...E,loading:false,error:C.ok?null:C.error.displayMessage})),C.ok&&r(false));},"resume"),h=i(async()=>{let O=s.current,F=await e.loadOlderMessages();O===s.current&&!F.ok&&l(C=>({...C,error:F.error.displayMessage}));},"earlier"),_=i(()=>{e.newConversation(),s.current+=1,r(false);},"newConversation"),m=i(()=>{c.cursor===null||c.loading||c.loadingMore||n.trim().length>0||u(c.cursor);},"loadMore"),T=useMemo(()=>Vc(c.rows,n),[c.rows,n]),A=n.trim().length>0;return {...c,open:t,show:f,close:y,load:u,resume:g,earlier:h,newConversation:_,loadMore:m,query:n,setQuery:o,searching:A,filtered:T,emptyKind:c.rows.length===0?"empty":"noMatch"}}i(Pi,"useHistoryPanel");var Zt="#111111",Jt="#FFFFFF",Hc=Object.freeze({emergency:Object.freeze({level:"emergency",label:"Vet care now",borderColor:"#FCA5A5",backgroundColor:"#FEF2F2",textColor:"#991B1B",reasonColor:Zt,pillColor:Jt,showsVetAction:true}),schedule_soon:Object.freeze({level:"schedule_soon",label:"Vet care suggested soon",borderColor:"#FCD34D",backgroundColor:"#FFFBEB",textColor:"#92400E",reasonColor:Zt,pillColor:Jt,showsVetAction:true}),home_care:Object.freeze({level:"home_care",label:"Monitor at home",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:Zt,pillColor:Jt,showsVetAction:false}),general:Object.freeze({level:"general",label:"Good to know",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:Zt,pillColor:Jt,showsVetAction:false})});function Uc(e){return `${e.messageId}:${e.level}:${e.reason??""}`}i(Uc,"urgencySignature");function zc(e){return W(p.urgencyGeneralReason,{petName:e?.trim()||p.emptyTitlePetFallback})}i(zc,"generalUrgencyReason");function wi(e,t){for(let r=e.length-1;r>=0;r-=1){let n=e[r];if(n?.role!=="assistant"||n.responseId===void 0)continue;let o=n.urgencyLevel;return o?{messageId:n.id,level:o,reason:n.urgencyReason??null}:n.urgencyProvided===true?{messageId:n.id,level:"general",reason:zc(t)}:null}return null}i(wi,"latestUrgencySource");function _i(e){let t=e===null?null:Uc(e),[r,n]=useState(null),[o,a]=useState(false);useEffect(()=>a(false),[t]);let d=e!==null&&(o||!(r!==null&&r===t)),l=e===null?null:Hc[e.level],c=e!==null&&!d&&e.level!=="general",u=useCallback(()=>{t!==null&&n(t),a(false);},[t]),f=useCallback(()=>a(true),[]);return useMemo(()=>({source:e,tier:l,signature:t,showBanner:d,showCompactIcon:c,showVetAction:d&&l!==null&&l.showsVetAction,dismissLabel:l===null?null:W(p.dismissBanner,{label:l.label}),dismiss:u,expand:f}),[e,l,t,d,c,u,f])}i(_i,"useUrgencySurface");function xi(e){return e.isBootstrapping?"loading":e.status==="error"&&e.error&&e.messages.length===0?"error":e.messages.length===0?"empty":"populated"}i(xi,"selectView");function Bc(e){return e.code==="accessDenied"||e.code==="conversationNotFound"}i(Bc,"needsNewConversation");function Ii(e){if(e.messages.length===0)return null;let t=e.status==="error"?e.error:null;if(t!==null){let r=Bc(t);return {tone:"error",title:r?p.turnUnreachableTitle:p.turnFailedTitle,body:t.displayMessage,actionLabel:r?p.turnStartNewChat:p.turnRetry,action:r?"startNew":"retry"}}return e.stopped===true?{tone:"neutral",title:p.turnStoppedTitle,body:p.turnStoppedBody,actionLabel:p.turnRetry,action:"retry"}:null}i(Ii,"turnNotice");function Ai(e,t){let r=e[e.length-1];return t&&(r===void 0||r.role==="user")}i(Ai,"awaitingAssistant");function Oi(e,t){let r={};return e!==void 0&&(r.petRef=e),t!==void 0&&(r.conversationId=t),r}i(Oi,"buildChatOpts");var jc=Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function v(e,t){let r=e.type,n=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:n}:{fontFamily:n,fontWeight:r.weight[jc[t]]}}i(v,"face");var $r=class $r extends Component{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey};}static getDerivedStateFromError(){return {failed:true}}static getDerivedStateFromProps(r,n){return Object.is(r.resetKey,n.key)?null:{failed:false,key:r.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};i($r,"HostRenderBoundary");var Kr=$r;function Gc({render:e}){return e()}i(Gc,"RenderHost");function Ne({render:e,fallback:t,resetKey:r}){return createElement(Kr,{fallback:t,resetKey:r,children:createElement(Gc,{render:e})})}i(Ne,"HostRender");var qc=Object.freeze({chat:Object.freeze(["chat.message.create"]),records:Object.freeze(["records.upload.create","records.record.read"]),recordsClinic:Object.freeze(["records.clinic.create"]),video:Object.freeze(["video.gait.execute"]),photo:Object.freeze(["photo.checkup.execute"]),animations:Object.freeze(["animations.state.read"]),televet:Object.freeze(["televet.visit.create"])});function Yc(e){return qc[e]}i(Yc,"requires");function Mi(e,t,r){let n=Yc(e),o=new Map;for(let d of t)o.set(d.resource,d);if(r?.isPending===true&&n.some(d=>!o.has(d)))return Qr({name:e,enabled:false,isPending:true,limits:{}});let a=Kc(n,o);return n.filter(d=>o.get(d)?.granted!==true).length===0?Qr({name:e,enabled:true,isPending:false,limits:a}):Qr({name:e,enabled:false,isPending:false,limits:a,disabled:$c(n,o)})}i(Mi,"decideCapability");function Kc(e,t){let r={};for(let n of e){let o=t.get(n)?.limits;if(o)for(let[a,s]of Object.entries(o)){let d=r[a];r[a]=d===void 0?s:Math.min(d,s);}}return r}i(Kc,"mergeLimits");function $c(e,t){for(let r of e){let n=t.get(r)?.disabled;if(n)return Object.freeze({reason:n.reason,level:n.level,recoverable:n.recoverable})}return Object.freeze({reason:kr("accessDenied"),level:"user_entitlement",recoverable:false})}i($c,"disabledFor");function Qr(e){let t={name:e.name,enabled:e.enabled,isPending:e.isPending,limits:Object.freeze({...e.limits})};return e.disabled!==void 0&&(t.disabled=e.disabled),Object.freeze(t)}i(Qr,"freezeDecision");function ht(e){let{runtime:t}=ae(),r=t.entitlements,n=useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot);return useMemo(()=>Mi(e,n.decisions,{isPending:n.isPending}),[e,n])}i(ht,"useCapability");var Zc=48;function Jc(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}i(Jc,"selectView");function Ni(e){let{capability:t,children:r,renderDisabled:n,renderPending:o,style:a}=e,s=ht(t),d=useMemo(()=>Jc(s),[s]);switch(d){case "enabled":return r;case "pending":return o?jsx(Ne,{render:o,fallback:jsx(Vi,{capability:t,style:a})}):jsx(Vi,{capability:t,style:a});case "disabled":return n?jsx(Ne,{render:()=>n(s),fallback:jsx(Li,{decision:s,style:a}),resetKey:s}):jsx(Li,{decision:s,style:a});default:return Lt(d)}}i(Ni,"CapabilityGate");function Vi({capability:e,style:t}){let r=w(),n=useMemo(()=>Hi(r),[r]);return jsx(View,{style:[n.offstate,t],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${e}`,children:jsx(View,{style:n.skeletonBar})})}i(Vi,"PendingSkeleton");function Li({decision:e,style:t}){let r=w(),n=useMemo(()=>Hi(r),[r]),o=e.disabled?.reason??"";return jsx(View,{style:[n.offstate,t],accessible:true,accessibilityRole:"text",accessibilityLabel:o,children:o.length>0?jsx(b,{style:n.offstateText,children:o}):null})}i(Li,"OffState");function Hi(e){let{color:t,space:r,radius:n,type:o}=e;return StyleSheet.create({offstate:{minHeight:Zc,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:StyleSheet.hairlineWidth,borderColor:t.brandBorder},offstateText:{...v(e,"regular"),fontSize:o.size.body,lineHeight:Math.round(o.size.body*o.lineHeight.normal),color:t.text.muted},skeletonBar:{height:r.md,borderRadius:n.xs,backgroundColor:t.brandSofter}})}i(Hi,"makeStyles");var gt=Object.freeze({title:"For educational use only",body:"Everfur is for educational purposes only. It helps you track visible changes through AI checkups. It does not diagnose, treat, prescribe, or replace veterinary care. For urgent symptoms or emergencies, contact a veterinarian immediately."});function Bi(e){let t=w(),r=useMemo(()=>ru(t),[t]);return jsxs(View,{style:[r.container,e.style],accessible:true,accessibilityRole:"text",accessibilityLabel:`${gt.title}. ${gt.body}`,children:[jsx(b,{style:r.title,children:gt.title}),jsx(b,{style:r.body,children:gt.body})]})}i(Bi,"ClinicalDisclaimer");function ru(e){let{color:t,space:r,type:n}=e;return StyleSheet.create({container:{paddingHorizontal:r.lg,paddingVertical:r.md,borderTopWidth:StyleSheet.hairlineWidth,borderTopColor:t.borderHairlineGreen,backgroundColor:t.surfaceCream,gap:r.xs},title:{...v(e,"bold"),fontSize:n.size.caption,lineHeight:Math.round(n.size.caption*n.lineHeight.snug),color:t.text.secondary,letterSpacing:n.letterSpacing.eyebrow},body:{...v(e,"regular"),fontSize:n.size.caption,lineHeight:Math.round(n.size.caption*n.lineHeight.snug),color:t.text.muted}})}i(ru,"makeStyles");var ee={pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"};function X(e){return {width:e,height:e,alignItems:"center",justifyContent:"center"}}i(X,"box");function ne(e,t){return t??Math.max(1.5,Math.round(e/11*10)/10)}i(ne,"stroke");function ji({size:e,color:t,strokeWidth:r}){let n=ne(e,r),o={width:e*.82,height:n,borderRadius:n,backgroundColor:t};return jsxs(View,{style:[X(e),{gap:e*.22}],...ee,children:[jsx(View,{style:o}),jsx(View,{style:o}),jsx(View,{style:o})]})}i(ji,"MenuGlyph");function Wi({size:e,color:t,strokeWidth:r,rotate:n}){let o=ne(e,r),a=e*.78;return jsxs(View,{style:[X(e),{transform:[{rotate:n}]}],...ee,children:[jsx(View,{style:{position:"absolute",width:a,height:o,borderRadius:o,backgroundColor:t}}),jsx(View,{style:{position:"absolute",width:o,height:a,borderRadius:o,backgroundColor:t}})]})}i(Wi,"Cross");function Gi(e){return jsx(Wi,{...e,rotate:"0deg"})}i(Gi,"PlusGlyph");function He(e){return jsx(Wi,{...e,rotate:"45deg"})}i(He,"CloseGlyph");function xe({size:e,color:t,strokeWidth:r}){let n=ne(e,r);return jsx(View,{style:X(e),...ee,children:jsx(View,{style:{width:e*.36,height:e*.66,marginTop:-e*.14,borderBottomWidth:n,borderRightWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})})}i(xe,"CheckGlyph");function qi({size:e,color:t,strokeWidth:r,direction:n}){let o=ne(e,r),a=e*.46;return jsx(View,{style:X(e),...ee,children:jsx(View,{style:{width:a,height:a,borderRightWidth:o,borderBottomWidth:o,borderColor:t,marginTop:n==="down"?-a*.4:a*.4,transform:[{rotate:n==="down"?"45deg":"225deg"}]}})})}i(qi,"ChevronGlyph");function Yi({size:e,color:t,strokeWidth:r}){let n=ne(e,r),o={width:e*.42,height:e*.7,borderWidth:n,borderColor:t,borderRadius:n};return jsxs(View,{style:[X(e),{flexDirection:"row",gap:1}],...ee,children:[jsx(View,{style:[o,{borderTopLeftRadius:e*.2}]}),jsx(View,{style:[o,{borderTopRightRadius:e*.2}]})]})}i(Yi,"BookGlyph");function Ki({size:e,color:t,strokeWidth:r}){let n=ne(e,r),o=e*.5;return jsxs(View,{style:X(e),...ee,children:[jsx(View,{style:{position:"absolute",width:e*.78,height:n,borderRadius:n,backgroundColor:t,transform:[{rotate:"-45deg"}]}}),jsx(View,{style:{position:"absolute",top:e*.16,right:e*.16,width:o,height:o,borderTopWidth:n,borderRightWidth:n,borderColor:t}})]})}i(Ki,"ArrowUpRightGlyph");function $i({size:e,color:t,strokeWidth:r}){let n=ne(e,r),o=e*.6,a={position:"absolute",width:o,height:o,borderWidth:n,borderColor:t,borderRadius:e*.14};return jsxs(View,{style:X(e),...ee,children:[jsx(View,{style:[a,{top:0,left:0}]}),jsx(View,{style:[a,{bottom:0,right:0}]})]})}i($i,"CopyGlyph");function er({size:e,color:t,strokeWidth:r,active:n,rotate:o}){let a=ne(e,r),s=n?t:"transparent";return jsxs(View,{style:[X(e),{transform:[{rotate:o}]}],...ee,children:[jsx(View,{style:{position:"absolute",bottom:e*.08,left:e*.12,width:e*.62,height:e*.5,borderWidth:a,borderColor:t,backgroundColor:s,borderRadius:e*.12,borderTopLeftRadius:e*.04}}),jsx(View,{style:{position:"absolute",top:e*.04,left:e*.4,width:e*.3,height:e*.5,borderWidth:a,borderColor:t,backgroundColor:s,borderRadius:e*.15,transform:[{rotate:"-20deg"}]}}),jsx(View,{style:{position:"absolute",bottom:e*.08,left:0,width:e*.2,height:e*.5,borderWidth:a,borderColor:t,backgroundColor:s,borderRadius:e*.05}})]})}i(er,"ThumbGlyph");function Qi({size:e,color:t,strokeWidth:r}){let n=ne(e,r);return jsxs(View,{style:[X(e),{borderRadius:e/2,borderWidth:n,borderColor:t}],...ee,children:[jsx(View,{style:{width:n,height:n,borderRadius:n,backgroundColor:t,marginBottom:e*.1}}),jsx(View,{style:{width:n,height:e*.34,borderRadius:n,backgroundColor:t}})]})}i(Qi,"InfoGlyph");function Xi({size:e,color:t,strokeWidth:r}){let n=ne(e,r),o=e*.34;return jsxs(View,{style:X(e),...ee,children:[jsx(View,{style:{position:"absolute",top:e*.06,width:o,height:o,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}}),jsx(View,{style:{position:"absolute",top:e*.1,width:n,height:e*.56,borderRadius:n,backgroundColor:t}}),jsx(View,{style:{position:"absolute",bottom:0,width:e*.84,height:e*.3,borderBottomWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderBottomLeftRadius:n,borderBottomRightRadius:n}})]})}i(Xi,"UploadGlyph");function Zi({size:e,color:t,strokeWidth:r}){let n=ne(e,r);return jsxs(View,{style:[X(e),{borderWidth:n,borderColor:t,borderRadius:e*.14,overflow:"hidden"}],...ee,children:[jsx(View,{style:{position:"absolute",top:e*.16,left:e*.18,width:e*.16,height:e*.16,borderRadius:e,backgroundColor:t}}),jsx(View,{style:{position:"absolute",bottom:-e*.3,right:-e*.1,width:e*.7,height:e*.7,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}i(Zi,"PhotoGlyph");function Ji({size:e,color:t,strokeWidth:r}){let n=ne(e,r);return jsxs(View,{style:X(e),...ee,children:[jsx(View,{style:{position:"absolute",top:e*.08,width:e*.34,height:e*.2,borderTopWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderTopLeftRadius:n,borderTopRightRadius:n}}),jsx(View,{style:{position:"absolute",top:e*.22,width:e*.92,height:e*.66,borderWidth:n,borderColor:t,borderRadius:e*.16,alignItems:"center",justifyContent:"center"},children:jsx(View,{style:{width:e*.3,height:e*.3,borderRadius:e,borderWidth:n,borderColor:t}})})]})}i(Ji,"CameraGlyph");function ea({size:e,color:t,strokeWidth:r}){let n=ne(e,r),o=e*.66;return jsxs(View,{style:X(e),...ee,children:[jsx(View,{style:{position:"absolute",top:0,left:0,width:o,height:o,borderRadius:o,borderWidth:n,borderColor:t}}),jsx(View,{style:{position:"absolute",bottom:e*.02,right:e*.02,width:n,height:e*.4,borderRadius:n,backgroundColor:t,transform:[{rotate:"-45deg"}]}})]})}i(ea,"SearchGlyph");function ta({size:e,color:t,strokeWidth:r}){let n=ne(e,r);return jsxs(View,{style:X(e),...ee,children:[jsx(View,{style:{position:"absolute",width:e*.3,height:e*.82,borderWidth:n,borderColor:t,borderRadius:n,transform:[{rotate:"45deg"}]}}),jsx(View,{style:{position:"absolute",bottom:0,left:0,width:e*.4,height:n,borderRadius:n,backgroundColor:t}})]})}i(ta,"EditGlyph");function ra({size:e,color:t,strokeWidth:r}){let n=ne(e,r),o=e*.62;return jsxs(View,{style:X(e),...ee,children:[jsx(View,{style:{position:"absolute",top:0,width:o,height:o,borderRadius:o,borderWidth:n,borderColor:t,alignItems:"center",justifyContent:"center"},children:jsx(View,{style:{width:n*1.4,height:n*1.4,borderRadius:n,backgroundColor:t}})}),jsx(View,{style:{position:"absolute",bottom:e*.04,width:o*.5,height:o*.5,borderRightWidth:n,borderBottomWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}i(ra,"MapPinGlyph");function na({size:e,color:t,testID:r}){let n=e*.36;return jsx(View,{style:X(e),testID:r,...ee,children:jsx(View,{style:{width:0,height:0,marginLeft:e*.12,borderLeftWidth:e*.78,borderTopWidth:n,borderBottomWidth:n,borderLeftColor:t,borderTopColor:"transparent",borderBottomColor:"transparent",transform:[{rotate:"-45deg"}]}})})}i(na,"SendGlyph");function oa({size:e,color:t,testID:r}){return jsx(View,{style:X(e),testID:r,...ee,children:jsx(View,{style:{width:e*.5,height:e*.5,backgroundColor:t}})})}i(oa,"StopGlyph");function tr({size:e,strokeWidth:t,color:r,children:n}){return jsx(View,{style:[X(e),{borderRadius:e/2,borderWidth:t??StyleSheet.hairlineWidth,borderColor:r}],children:n})}i(tr,"Ring");var bt=Object.freeze({standard:De.standard,emphasized:De.emphasized,exit:De.exit,outQuad:Object.freeze([.25,.46,.45,.94])});var ia=Object.freeze({layoutMs:220,messageInMs:200,bannerInMs:220,bannerOutMs:160,iconInMs:180,iconOutMs:120,followUpInMs:180,followUpStaggerMs:70,citationsInMs:220,citationsRisePx:6,drawerMs:220,pressScale:.97,pressMs:140,revealTickMs:24,revealDivisor:12,dotsCycleMs:520,dotsMinOpacity:.44,dotsLiftPx:3.5,dotsStagger:Object.freeze([0,.18,.36]),copiedMs:1500,uploadFlashMs:600,reduced:false}),iu=Object.freeze({...ia,layoutMs:0,messageInMs:0,bannerInMs:0,bannerOutMs:0,iconInMs:0,iconOutMs:0,followUpInMs:0,followUpStaggerMs:0,citationsInMs:0,citationsRisePx:0,drawerMs:0,pressScale:1,pressMs:0,revealTickMs:0,dotsCycleMs:0,dotsMinOpacity:1,dotsLiftPx:0,reduced:true});function aa(e){return e.motion.reducedMotion?iu:ia}i(aa,"chatMotion");function rr(e,t){return Math.max(0,t)*e.followUpStaggerMs}i(rr,"followUpDelayMs");function sa(e,t,r){if(e.reduced||t>=r)return r;let n=Math.max(1,Math.ceil((r-t)/e.revealDivisor));return Math.min(r,t+n)}i(sa,"nextRevealLength");function q(){let e=w();return aa(e)}i(q,"useChatMotion");var uu=8;function da(e,t,r){return ((1-3*r+3*t)*e+(3*r-6*t))*e*e+3*t*e}i(da,"bezierComponent");function pu(e,t,r){return 3*(1-3*r+3*t)*e*e+2*(3*r-6*t)*e+3*t}i(pu,"bezierSlope");function nr(e){let[t,r,n,o]=e;return a=>{if(a<=0)return 0;if(a>=1)return 1;let s=a;for(let d=0;d<uu;d+=1){let l=pu(s,t,n);if(l===0)break;s-=(da(s,t,n)-a)/l;}return da(Math.min(1,Math.max(0,s)),r,o)}}i(nr,"bezierEasing");var Jr=nr(bt.standard),fu=nr(bt.outQuad);function nn(e){let t=useRef(null);return t.current===null&&(t.current=new Animated.Value(e)),t.current}i(nn,"useAnimatedValue");function Ue(e,t={}){let r=t.risePx??0,n=t.delayMs??0,o=nn(e>0?0:1);return useEffect(()=>{if(e<=0)return;let a=Animated.timing(o,{toValue:1,duration:e,easing:fu,useNativeDriver:true}),s=n>0?Animated.sequence([Animated.delay(n),a]):a;return s.start(),()=>s.stop()},[o,e,n]),useMemo(()=>({opacity:o,transform:[{translateY:o.interpolate({inputRange:[0,1],outputRange:[r,0]})}]}),[o,r])}i(Ue,"useFadeIn");function on({visible:e,inMs:t,outMs:r,style:n,children:o}){let[a,s]=useState(e),d=nn(e&&t<=0?1:0);return useEffect(()=>{if(e){s(true);let c=Animated.timing(d,{toValue:1,duration:Math.max(0,t),easing:Jr,useNativeDriver:true});return c.start(),()=>c.stop()}if(!a)return;if(r<=0){s(false);return}let l=Animated.timing(d,{toValue:0,duration:r,easing:Jr,useNativeDriver:true});return l.start(({finished:c})=>{c&&s(false);}),()=>l.stop()},[e,a,t,r,d]),!a&&!e?null:jsx(Animated.View,{style:[n,{opacity:d}],children:o})}i(on,"FadePresence");function V({style:e,containerStyle:t,children:r,onPressIn:n,onPressOut:o,...a}){let s=q(),d=nn(1),l=useCallback(c=>{s.pressMs<=0||s.pressScale===1||Animated.timing(d,{toValue:c,duration:s.pressMs,easing:Jr,useNativeDriver:true}).start();},[d,s.pressMs,s.pressScale]);return jsx(Pressable,{...a,style:t,onPressIn:c=>{l(s.pressScale),n?.(c);},onPressOut:c=>{l(1),o?.(c);},children:jsx(Animated.View,{style:[e,{transform:[{scale:d}]}],children:r})})}i(V,"PressScale");function pa(e,t,r){let n=t&&r.revealTickMs>0,[o,a]=useState(0),s=useRef(e);return s.current=e,useEffect(()=>{if(!n)return;let d=setInterval(()=>{a(l=>sa(r,l,s.current.length));},r.revealTickMs);return ()=>clearInterval(d)},[n,r]),n?e.slice(0,Math.min(o,e.length)):e}i(pa,"useRevealedText");var ca=false;function yu(e){e.layoutMs<=0||(ca||(ca=true,Platform.OS==="android"&&typeof UIManager.setLayoutAnimationEnabledExperimental=="function"&&UIManager.setLayoutAnimationEnabledExperimental(true)),LayoutAnimation.configureNext({duration:e.layoutMs,create:{type:"easeInEaseOut",property:"opacity"},update:{type:"easeInEaseOut"},delete:{type:"easeInEaseOut",property:"opacity"}}));}i(yu,"animateLayout");function vt(e,t){let r=useRef(e);r.current!==e&&(r.current=e,yu(t));}i(vt,"useAnimateLayoutOn");var an=36,Eu=22,Ru=12,Su=12,Pu=16,Tu="#000",ku="rgba(0,0,0,0.45)";function fa({uri:e,label:t,onClose:r}){let n=w(),o=useSafeAreaInsets();return e===null?null:jsxs(Modal,{visible:true,animationType:n.motion.reducedMotion?"none":"fade",transparent:false,statusBarTranslucent:true,onRequestClose:r,children:[jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:p.closePreview,style:or.backdrop,onPress:r,children:jsx(Image,{source:{uri:e},style:or.image,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,accessibilityIgnoresInvertColors:true})}),jsx(View,{pointerEvents:"box-none",style:[or.closeWrap,{top:o.top+Su}],children:jsx(V,{accessibilityRole:"button",accessibilityLabel:p.closePreview,hitSlop:Ru,style:or.closeButton,onPress:r,children:jsx(He,{size:Eu,color:n.color.surface,strokeWidth:2})})})]})}i(fa,"AttachmentImageLightbox");var or=StyleSheet.create({backdrop:{flex:1,backgroundColor:Tu,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"},closeWrap:{position:"absolute",right:Pu},closeButton:{width:an,height:an,borderRadius:an/2,backgroundColor:ku,alignItems:"center",justifyContent:"center"}});var ir=12,Au=80,sn=44,ya=22,Ou=.14,Fu=18,Mu=8,ma=Object.freeze({photo:p.attachmentPhoto,camera:p.attachmentCamera});function ha({sources:e,full:t,onPick:r,onClose:n}){let o=w(),a=useMemo(()=>Du(o),[o]);return jsxs(View,{style:a.anchor,pointerEvents:"box-none",children:[jsx(Pressable,{style:a.dismissLayer,accessibilityRole:"button",accessibilityLabel:p.closeAttachmentPicker,onPress:n}),jsxs(View,{style:a.bubble,children:[jsx(View,{style:a.tilesRow,children:e.map(s=>jsxs(V,{accessibilityRole:"button",accessibilityLabel:ma[s],accessibilityState:{disabled:t},disabled:t,containerStyle:a.tile,style:a.tileInner,onPress:()=>r(s),children:[jsx(View,{style:a.tileIconWrap,children:s==="photo"?jsx(Zi,{size:ya,color:o.color.brandInk,strokeWidth:1.5}):jsx(Ji,{size:ya,color:o.color.brandInk,strokeWidth:1.5})}),jsx(b,{tier:"control",style:a.tileLabel,children:ma[s]})]},s))}),jsx(View,{style:a.tail}),jsx(View,{style:a.tailFill})]})]})}i(ha,"AttachmentPickerPopover");function Du(e){let t=e.color,r=e.radius;return StyleSheet.create({anchor:{position:"absolute",left:0,right:0,bottom:"100%",paddingHorizontal:8,paddingBottom:10,alignItems:"flex-start"},dismissLayer:{position:"absolute",left:-1e3,right:-1e3,top:-2e3,bottom:0},bubble:{backgroundColor:t.surfaceCream,borderRadius:r.lg,borderWidth:1,borderColor:t.brandBorderStrong,paddingHorizontal:6,paddingVertical:8,shadowColor:t.shadow,shadowOpacity:Ou,shadowRadius:Fu,shadowOffset:{width:0,height:Mu},elevation:8},tilesRow:{flexDirection:"row",alignItems:"stretch"},tile:{minWidth:Au,borderRadius:r.md},tileInner:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:10,paddingVertical:8,gap:6},tileIconWrap:{width:sn,height:sn,borderRadius:sn/2,backgroundColor:t.brandSoft,alignItems:"center",justifyContent:"center"},tileLabel:{...v(e,"medium"),fontSize:12,lineHeight:14,color:t.text.primary},tail:{position:"absolute",left:24,bottom:-ir/2,width:ir,height:ir,backgroundColor:t.surfaceCream,borderRightWidth:1,borderBottomWidth:1,borderColor:t.brandBorderStrong,transform:[{rotate:"45deg"}]},tailFill:{position:"absolute",left:22,bottom:0,width:ir+4,height:2,backgroundColor:t.surfaceCream}})}i(Du,"makeStyles");var ga=56,ba=12,Nu=14,Hu=10,Uu="rgba(16,70,46,0.45)",zu="rgba(7,193,104,0.55)",Bu="rgba(185,28,28,0.55)",ju=200,Wu=300,ka=20,dn=22,Gu=12,qu="rgba(0,0,0,0.78)",va=220,Ca=100,Ea="rgba(255,255,255,0.15)";function wa({attachments:e,rejected:t,uploadFailed:r=false,onRetry:n,onRemove:o,onPreview:a}){let s=w(),d=useMemo(()=>xa(s),[s]);return e.length===0&&t===null?null:jsxs(View,{style:d.strip,children:[e.length>0?jsx(View,{style:d.cards,children:e.map(l=>jsx(Yu,{row:l,styles:d,onRetry:n,onRemove:o,onPreview:a},l.id))}):null,r?jsx(b,{style:d.rejected,accessibilityRole:"alert",children:p.attachmentsFailedBlocked}):null,t!==null?jsx(b,{style:d.rejected,accessibilityRole:"alert",children:Ao(t)}):null]})}i(wa,"AttachmentStrip");function Yu({row:e,styles:t,onRetry:r,onRemove:n,onPreview:o}){let a=w(),s=e.status==="uploading",d=e.status==="failed",l=e.status==="uploaded",c=useRef(e.status),[u,f]=useState(false);return useEffect(()=>{let y=c.current;c.current=e.status,e.status==="uploaded"&&y==="uploading"&&f(true);},[e.status]),jsxs(View,{style:t.card,children:[jsx(Pressable,{accessibilityRole:l?"button":"image",accessibilityLabel:l?W(p.previewAttachment,{filename:e.filename}):e.filename,accessibilityState:{busy:s,disabled:!l},disabled:!l,style:t.thumbHit,onPress:()=>o(e),children:jsxs(View,{style:t.thumb,children:[jsx(Image,{source:{uri:e.previewUri},style:t.thumbImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true}),s?jsx(View,{style:t.uploadingOverlay,children:jsx(ActivityIndicator,{size:"small",color:a.color.surface})}):null,u?jsx(Ku,{styles:t,onDone:()=>f(false)}):null]})}),d?jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:W(p.retryUpload,{filename:e.filename}),style:t.failedOverlay,onPress:()=>r(e.id),children:jsx(View,{style:t.failedInner,children:jsx(He,{size:ka,color:a.color.surface,strokeWidth:2})})}):null,jsx(V,{accessibilityRole:"button",accessibilityLabel:W(p.removeAttachment,{filename:e.filename}),hitSlop:6,containerStyle:t.removeSlot,style:t.removeButton,onPress:()=>n(e.id),children:jsx(He,{size:Gu,color:a.color.surface,strokeWidth:1.5})})]})}i(Yu,"PreviewCard");function Ku({styles:e,onDone:t}){let r=w(),n=q(),o=useRef(null);o.current===null&&(o.current=new Animated.Value(0));let a=o.current;return useEffect(()=>{let s=Animated.sequence([Animated.timing(a,{toValue:1,duration:ju,useNativeDriver:true}),Animated.delay(n.uploadFlashMs),Animated.timing(a,{toValue:0,duration:Wu,useNativeDriver:true})]);return s.start(({finished:d})=>{d&&t();}),()=>s.stop()},[a,n.uploadFlashMs,t]),jsx(Animated.View,{pointerEvents:"none",style:[e.successOverlay,{opacity:a}],children:jsx(xe,{size:ka,color:r.color.surface,strokeWidth:2})})}i(Ku,"SuccessFlash");function _a({images:e,onPreview:t}){let r=w(),n=useMemo(()=>xa(r),[r]);if(e.length===0)return null;let o=e.length===1;return jsx(View,{style:o?n.sentSingle:n.sentGrid,children:e.map((a,s)=>jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:W(p.attachedImage,{filename:a.filename}),onPress:()=>t(a),children:jsx(Image,{source:{uri:a.uri},style:o?n.singleImage:n.gridImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true})},`${a.uri}-${s}`))})}i(_a,"SentImages");function xa(e){let t=e.color,r=e.type;return StyleSheet.create({strip:{gap:6,paddingBottom:8},cards:{flexDirection:"row",flexWrap:"wrap",gap:8},card:{width:ga,height:ga,overflow:"visible"},thumbHit:{width:"100%",height:"100%"},thumb:{width:"100%",height:"100%",borderRadius:ba,overflow:"hidden",backgroundColor:t.composerFill,borderWidth:StyleSheet.hairlineWidth,borderColor:t.brandBorder},thumbImage:{width:"100%",height:"100%"},uploadingOverlay:{...StyleSheet.absoluteFillObject,alignItems:"center",justifyContent:"center",backgroundColor:Uu},successOverlay:{...StyleSheet.absoluteFillObject,alignItems:"center",justifyContent:"center",backgroundColor:zu},failedOverlay:{...StyleSheet.absoluteFillObject,borderRadius:ba,overflow:"hidden"},failedInner:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:Bu},removeSlot:{position:"absolute",top:4,right:4},removeButton:{width:dn,height:dn,borderRadius:dn/2,backgroundColor:qu,borderWidth:1.5,borderColor:t.surface,alignItems:"center",justifyContent:"center"},rejected:{...v(e,"regular"),fontSize:r.size.caption,lineHeight:r.size.caption*r.lineHeight.normal,color:t.danger},sentSingle:{marginBottom:6},sentGrid:{flexDirection:"row",flexWrap:"wrap",gap:6,marginBottom:6},singleImage:{width:va,height:va,borderRadius:Nu,backgroundColor:Ea},gridImage:{width:Ca,height:Ca,borderRadius:Hu,backgroundColor:Ea}})}i(xa,"makeStyles");var $u="file",Qu="chat attachment upload: the file handle has no uri",Xu="chat attachment upload failed";function Zu(e){return {uri:e.uri,name:Mr(e.name),type:e.mimeType}}i(Zu,"filePartOf");function pn(e={}){return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(Qu));let{signal:o,onProgress:a}=n,s=i(()=>Promise.reject(new Error(Xu)),"failed");if(o?.aborted===true)return s();let d=new FormData;for(let[c,u]of Object.entries(t.upload_fields))d.append(c,u);d.append($u,Zu(r));let l=e.fetch??fetch;return Promise.resolve().then(()=>l(t.upload_url,{method:"POST",body:d,credentials:"omit",...o?{signal:o}:{}})).then(c=>{if(!c.ok)return s();a?.(1);},s)}})}i(pn,"createRnChatAttachmentTransport");function yn(){let{runtime:e,userRef:t,activePet:r,scopeEpoch:n}=ae(),o=useMemo(()=>$t(e.registry.services.authFor(t)),[e,t,n]),[a,s]=useState({repository:o,pets:[],loading:true,error:null}),d=a.repository===o?a:{pets:[],loading:true,error:null},l=useRef(0),c=useCallback(async()=>{let f=++l.current;s(g=>({...g,repository:o,loading:true,error:null,pets:g.repository===o?g.pets:[]}));let y=await o.list();f===l.current&&s(y.ok?{repository:o,pets:y.value,loading:false,error:null}:g=>({repository:o,pets:g.repository===o?g.pets:[],loading:false,error:y.error}));},[o]);useEffect(()=>(c(),()=>{l.current+=1;}),[c]);let u=useMemo(()=>r===null?null:d.pets.find(f=>f.petRef===r)??null,[r,d.pets]);return useMemo(()=>({pets:d.pets,activePet:u,loading:d.loading,error:d.error,refresh:c}),[d.pets,d.loading,d.error,u,c])}i(yn,"useEverfurPets");function Ia(e,t){if(t!==null){let r=e.find(n=>n.petRef===t);if(r!==void 0)return r}return e[0]??null}i(Ia,"headerPetOf");function oe(e,t){if(e===void 0)return {};let r={};return e.backgroundColor!==void 0&&(r.backgroundColor=e.backgroundColor),e.borderColor!==void 0&&(r.borderColor=e.borderColor,r.borderWidth=t??1),e.borderRadius!==void 0&&(r.borderRadius=e.borderRadius),r}i(oe,"slotBox");function mn(e){return e===void 0||e.backgroundColor!==void 0?e:e.borderRadius===void 0?void 0:{borderRadius:e.borderRadius}}i(mn,"ownGroundSlot");function ye(e){return e?.textColor===void 0?{}:{color:e.textColor}}i(ye,"slotText");var Aa=Object.freeze({visitButton:"Talk to a vet"});var Oa=null;function Fa(){return Oa!==null}i(Fa,"hasEverfurTelevetFlow");function Ma(e){return false;}i(Ma,"presentEverfurTelevetFlow");var hn=Object.freeze(["visit","join","summary","messages"]);function gn(e){return typeof e=="string"&&hn.includes(e)}i(gn,"isVetVisitIntent");var np="/widget/v1/televet/handoffs",op="/widget/v1/televet/availability",ip="/widget/v1/televet/chat-entry",ap=/^[a-z0-9][a-z0-9_-]{0,39}$/,sp=/^[A-Za-z0-9_-]{22}$/;var Da=32,Va=128,La=64;function vn(e){let t=e.httpStatus;switch(e.code){case "sessionRequired":return "sessionRequired";case "authExpired":case "authRejected":return "authRejected";case "sdkUpdateRequired":return "sdkUpdateRequired";case "validationFailed":return "invalidRequest";case "rateLimited":case "quotaExceeded":return "rateLimited";}return t===void 0?e.code==="internalError"?"network":"unknown":t===429?"rateLimited":t===404?"unavailable":t===403?"accessDenied":t===401?"authRejected":t===400||t===422?"invalidRequest":t>=500?"serverError":"unknown"}i(vn,"vetVisitErrorReasonOf");function Na(e){return M(Y("validationFailed",{retryable:false,wireMessage:e}))}i(Na,"invalid");function bn(e){return M(Y("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}i(bn,"unusable");function lp(e,t){let r={};e!==void 0&&(r.pet_ref=e);let n=t?.returnTo;if(n!=null){if(typeof n!="string"||!ap.test(n))return {ok:false,message:"returnTo must be a registered return destination key"};r.return_to=n;}let o=t?.entry;if(o!=null){if(o!=="chat"||e===void 0)return {ok:false,message:"entry 'chat' needs the pet the chat is about"};r.entry=o;}let a=t?.visitRef,s=t?.intent,d=a!=null;if(d){let l=typeof a=="string"?a.trim():"";if(l.length<1||[...l].length>La)return {ok:false,message:`visitRef must be 1..${La} characters`};r.visit_ref=l;}if(s!=null){if(!d)return {ok:false,message:"intent needs the visitRef it opens"};if(!gn(s))return {ok:false,message:`intent must be one of ${hn.join(", ")}`};r.intent=s;}return {ok:true,body:r}}i(lp,"handoffBody");function dp(e){if(typeof e!="object"||e===null)return null;let{visit_ref:t,intent:r}=e;return typeof t!="string"||t.length===0||!gn(r)?null:Object.freeze({visitRef:t,intent:r})}i(dp,"parseVisitEcho");function Ua(e){let t=e.funnel??Ve({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e.telemetry,n=i(o=>(Ha(r,"televet.visit.handoff_failed",{reason:vn(o)}),M(o)),"failed");return {async createHandoff(o,a){let s;if(o!=null){let m=typeof o=="string"?[...o].length:0;if(m<1||m>Va)return n(Y("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${Va} characters`}));s=o;}let d=lp(s,a);if(!d.ok){let m=Na(d.message);return m.ok?m:n(m.error)}let l=d.body,c=await t.send("televet.visit.handoff",{method:"POST",path:np,body:l},{idempotent:false,maxAttempts:1});if(!c.ok)return n(c.error);let u=cp(c.value),f=l.return_to!==void 0,y=f?c.value?.flow_id:void 0;if(f&&(typeof y!="string"||!sp.test(y))){let m=bn("the handoff response carried no usable return flow id");return m.ok?m:n(m.error)}let g=l.visit_ref!==void 0,h=g?dp(c.value?.visit):null;if(g&&h===null){let m=bn("the handoff response did not confirm the visit it opens");return m.ok?m:n(m.error)}let _=u===null?null:Object.freeze({...u,...f?{flowId:y}:{},...h!==null?{visit:h}:{}});return _===null?n(Y("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(Ha(r,"televet.visit.handoff_created",{pet_scoped:l.pet_ref!==void 0}),de(_))},async checkAvailability(o){if(typeof o!="string"||o.length>Da)return Na(`state must be at most ${Da} characters`);let a=await t.send("televet.visit.availability",{method:"POST",path:op,body:{state:o}},{idempotent:false,maxAttempts:1});if(!a.ok)return M(a.error);let s=a.value?.available;return typeof s!="boolean"?bn("the availability response carried no usable answer"):de(Object.freeze({available:s}))},async chatEntryOpen(){try{let o=await t.send("televet.visit.chat_entry",{method:"GET",path:ip},{maxAttempts:1});return o.ok&&o.value?.open===!0}catch{return false}}}}i(Ua,"createVetVisitController");function cp(e){if(typeof e!="object"||e===null)return null;let{url:t,expires_at:r}=e;return typeof t!="string"||typeof r!="string"||r.length===0||!yp(t)?null:Object.freeze({url:t,expiresAt:r})}i(cp,"parseHandoff");var up=new Set(["localhost","127.0.0.1","[::1]"]),pp=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,fp=/[\s\u0000-\u001f\u007f]/;function yp(e){if(fp.test(e))return false;let t=pp.exec(e);if(t===null)return false;let r=(t[1]??"").toLowerCase(),n=t[2]??"";if(n.length===0||n.includes("@"))return false;let o=n.replace(/:\d+$/,"").toLowerCase(),a=r==="https",s=r==="http"&&up.has(o);if(!a&&!s)return false;let d=e.indexOf("#");if(d<0)return false;let l=e.slice(d);return l.startsWith("#h=")&&l.length>3}i(yp,"isOpenableVisitUrl");function Ha(e,t,r){if(e)try{e.track(t,r);}catch{}}i(Ha,"safeTrack");var Ba=Object.freeze({status:"idle",error:null,errorReason:null});function hp(e,t,r){let{usState:n,chat:o,scope:a}=r,s=t&&(n!==null||o),d=`${n??""}|${o?"chat":""}`,[l,c]=useState(null);if(useEffect(()=>{if(!s)return;let f=true,y=e.current;return c(null),i(async()=>{try{if(o&&!(y.chatEntryOpen&&await y.chatEntryOpen()))return !1;if(n===null)return !0;if(!y.checkAvailability)return !1;let h=await y.checkAvailability(n);return h.ok&&h.value.available}catch{return false}},"ask")().then(h=>{f&&c({key:d,open:h});}),()=>{f=false;}},[s,d,n,o,a,e]),!s)return null;let u=l!==null&&l.key===d;return {open:u&&l.open,pending:!u}}i(hp,"usePreflight");var gp=Object.freeze({status:"opening",error:null,errorReason:null});function Wa(e,t={}){let{runtime:r,userRef:n,scopeEpoch:o}=ae(),a=ht("televet"),s=a.enabled&&n!==null,d=t.usState??null,l=t.entry==="chat",c=t.petRef??null,u=useMemo(()=>{if(t.controller)return t.controller;let{services:P}=r.registry;return Ua({auth:P.authFor(n),telemetry:P.telemetry,...P.errorPolicy?{errorPolicy:P.errorPolicy}:{}})},[r,n,o,t.controller]),f=useRef(u);f.current=u;let y=useMemo(()=>({runtime:r,userRef:n,scopeEpoch:o}),[r,n,o]),g=hp(f,s,{usState:d,chat:l,scope:y}),h=s&&(g===null||g.open)&&(!l||c!==null),_=t.returnTo??null,[m,T]=useState(Ba),A=useRef(null),O=useRef({runtime:r,userRef:n,scopeEpoch:o});O.current={runtime:r,userRef:n,scopeEpoch:o};let F=useRef(u);F.current=u;let C=useRef(h);C.current=h;let E=useCallback((P,S)=>{if(A.current)return A.current;let x=i((B,Me)=>(T({status:B==="cancelled"?"idle":"error",error:Me,errorReason:B==="cancelled"?null:B}),Object.freeze({opened:false,reason:B,error:Me})),"fail");if(!C.current)return Promise.resolve(x("unavailable",null));let U=e.prepare();if(!U.ok)return Promise.resolve(x(U.reason,null));let j=O.current,z=F.current;T(gp);let ie=(async()=>{let B,Me={..._!==null?{returnTo:_}:{},...l?{entry:"chat"}:{},...S!==null?{visitRef:S.visitRef}:{},...S!==null&&S.intent!==null&&S.intent!==void 0?{intent:S.intent}:{}},xt=Object.keys(Me).length===0?void 0:Me,at=P===void 0?c:P;try{B=await(xt===void 0?z.createHandoff(at):z.createHandoff(at,xt));}catch{return e.abandon(U.value),x("unknown",null)}let Ke=O.current;if(Ke.runtime!==j.runtime||Ke.userRef!==j.userRef||Ke.scopeEpoch!==j.scopeEpoch)return e.abandon(U.value),x("cancelled",null);if(!B.ok)return e.abandon(U.value),x(vn(B.error),B.error);let $e=await e.finish(U.value,B.value);return $e!==null?x($e,null):(T(Ba),Object.freeze(B.value.flowId===void 0?{opened:true}:{opened:true,flowId:B.value.flowId}))})().finally(()=>{A.current===ie&&(A.current=null);});return A.current=ie,ie},[e,c,_,l]),R=useCallback(P=>E(P,null),[E]),L=useCallback((P,S)=>E(void 0,{visitRef:P,intent:S??null}),[E]);return {available:h,isPending:a.isPending||(g?.pending??false),status:m.status,error:m.error,errorReason:m.errorReason,open:R,openVisit:L}}i(Wa,"useVetVisitWith");var Cp=i(e=>Linking.openURL(e),"defaultOpenUrl");function ar(e={}){let{openUrl:t,...r}=e,n=useMemo(()=>{let o=t??Cp;return {prepare:i(()=>({ok:true,value:null}),"prepare"),async finish(a,s){try{return await o(s.url),null}catch{return "openFailed"}},abandon:i(()=>{},"abandon")}},[t]);return Wa(n,r)}i(ar,"useVetVisit");var Ga=44,Tp=.6;function tt(e){let{petRef:t,label:r,openUrl:n,onOpened:o,onError:a,style:s,labelStyle:d,controller:l,returnTo:c,usState:u,entry:f,visitRef:y,intent:g,onStartInApp:h,prefer:_}=e,m=ar({...c!==void 0?{returnTo:c}:{},...u!==void 0?{usState:u}:{},...f!==void 0?{entry:f}:{},...t!==void 0?{petRef:t}:{},...n!==void 0?{openUrl:n}:{},...l!==void 0?{controller:l}:{}}),T=w(),A=useMemo(()=>kp(T),[T]),O=useRef(false);if(!m.available)return null;let F=m.status==="opening",C=r??Aa.visitButton,E=y!=null,R=_==="redirect"||E,L=!R&&h!==void 0;return jsx(Pressable,{onPress:i(()=>{if(!(F||O.current)){if(L){G(h);return}(O.current=true,(y==null?m.open():m.openVisit(y,g??null)).then(x=>{x.opened?G(o,x.flowId??null):x.reason!=="cancelled"&&G(a,x.reason,x.error);}).finally(()=>{O.current=false;}));}},"onPress"),accessibilityRole:"button",accessibilityLabel:C,accessibilityState:{busy:F,disabled:F},style:[A.button,F?A.busy:null,s],children:jsx(b,{style:[A.label,d],children:C})})}i(tt,"VetVisitButton");function kp(e){let{color:t,space:r,radius:n,type:o,slots:a}=e;return StyleSheet.create({button:{minHeight:Ga,minWidth:Ga,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.primary,...oe(a.vetVisitButton)},busy:{opacity:Tp},label:{...v(e,"medium"),color:t.onPrimary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.snug,...ye(a.vetVisitButton)}})}i(kp,"makeStyles");function En(e){return Wt(e)==="cat"?"cat":"dog"}i(En,"speciesOf");function Rn(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:Math.floor(e)}i(Rn,"petAgeYears");function Ka(e){let t=Rn(e.ageYears),r=En(e.species)==="cat"?"Cat":"Dog";if(t==null)return r;let n=t===1?"1 yr":`${t} yrs`;return `${r} \xB7 ${n}`}i(Ka,"formatPetMeta");var Ya=Object.freeze([Object.freeze({background:"#ffbdbd",foreground:"#6d1d14"}),Object.freeze({background:"#a0c4f6",foreground:"#0b3a73"}),Object.freeze({background:"#fbc558",foreground:"#10462e"}),Object.freeze({background:"#bde7c5",foreground:"#0e3b22"}),Object.freeze({background:"#dcc7f4",foreground:"#3a1d6a"}),Object.freeze({background:"#ffd8a8",foreground:"#5a2a04"})]);function wp(e){let t=0;for(let r=0;r<e.length;r+=1)t=t*31+e.charCodeAt(r)>>>0;return Ya[t%Ya.length]}i(wp,"pickInitialsPalette");function Sn(e){let t=(e??"").trim();return (Array.from(t)[0]??"?").toUpperCase()}i(Sn,"getInitial");function $a(e){return {...wp(e.petRef),initial:Sn(e.name)}}i($a,"petInitials");function Ap(e){return Math.max(12,Math.round(e*.42))}i(Ap,"letterSize");function St({pet:e,size:t,ringStroke:r}){let n=w(),o=useMemo(()=>Op(n),[n]),a=t-r*2,s=e===null?null:$a(e),d=Ap(a);return jsx(tr,{size:t,strokeWidth:r,color:n.color.success,children:jsx(View,{style:[o.disc,{width:a,height:a,borderRadius:a/2},s===null?o.discEmpty:{backgroundColor:s.background}],children:jsx(b,{tier:"badge",style:[o.letter,{fontSize:d,lineHeight:Math.round(d*1.2),color:s===null?n.color.text.muted:s.foreground}],children:s===null?Sn(null):s.initial})})})}i(St,"PetDisc");function Op(e){return StyleSheet.create({disc:{alignItems:"center",justifyContent:"center",overflow:"hidden"},discEmpty:{backgroundColor:e.color.brandSoft},letter:{...v(e,"bold"),textAlign:"center",includeFontPadding:false}})}i(Op,"makeStyles");var Tn=48,Ja=2,Lp=320,Np="80%",Hp="rgba(17,17,17,0.45)",Up=18,Qa=22,zp=12,Xa=.4,Bp=44;function kn(e){return e?.name?.trim()||p.yourPet}i(kn,"petDisplayName");function es({visible:e,pets:t,activePetRef:r,onSelect:n,onAddPet:o=null,onClose:a}){let s=w(),d=useMemo(()=>jp(s),[s]);return e?jsx(Modal,{visible:true,transparent:true,animationType:s.motion.reducedMotion?"none":"fade",onRequestClose:a,children:jsxs(View,{style:d.root,children:[jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:a,accessibilityRole:"button",accessibilityLabel:p.close,children:jsx(View,{style:d.backdrop})}),jsxs(View,{style:d.panel,accessibilityViewIsModal:true,children:[jsx(b,{tier:"heading",style:d.title,accessibilityRole:"header",children:p.yourPets}),jsx(ScrollView,{style:d.list,contentContainerStyle:d.listContent,showsVerticalScrollIndicator:true,children:t.map(l=>{let c=l.petRef===r,u=kn(l),f=Ka(l);return jsxs(V,{accessibilityRole:"button",accessibilityLabel:W(c?p.petCurrentlyActive:p.switchToPet,{name:u}),accessibilityState:{selected:c},style:[d.row,c?d.rowActive:null],onPress:()=>n(l.petRef),children:[jsx(St,{pet:l,size:Tn,ringStroke:Ja}),jsxs(View,{style:d.copy,children:[jsx(b,{style:d.name,numberOfLines:1,children:u}),jsx(b,{tier:"compact",style:d.meta,numberOfLines:1,children:c?`${p.activePrefix}${f}`:f})]}),c?jsx(xe,{size:Up,color:s.color.brandInk}):null]},l.petRef)})}),o!==null?jsxs(V,{accessibilityRole:"button",accessibilityLabel:p.addAnotherPet,style:d.addRow,onPress:o,children:[jsx(View,{style:d.addDisc,children:jsx(b,{tier:"control",style:d.addPlus,children:"+"})}),jsx(b,{style:d.addLabel,children:p.addAnotherPet})]}):null,jsx(V,{accessibilityRole:"button",accessibilityLabel:p.close,containerStyle:d.closeSlot,style:d.closeButton,onPress:a,children:jsx(b,{tier:"control",style:d.closeText,children:p.close})})]})]})}):null}i(es,"PetSwitcherSheet");function jp(e){let t=e.color,r=e.radius;return StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{flex:1,backgroundColor:Hp},panel:{backgroundColor:t.surface,paddingHorizontal:20,paddingTop:20,paddingBottom:32,borderTopLeftRadius:Qa,borderTopRightRadius:Qa,gap:14,maxHeight:Np},title:{...v(e,"bold"),fontSize:18,lineHeight:22,color:t.brandInk},list:{maxHeight:Lp,flexShrink:1},listContent:{gap:10},addRow:{flexDirection:"row",alignItems:"center",gap:12,minHeight:Bp,paddingHorizontal:8},addDisc:{width:Tn,height:Tn,borderRadius:r.pill,alignItems:"center",justifyContent:"center",borderWidth:Ja,borderStyle:"dashed",borderColor:t.brandBorder,backgroundColor:t.surfaceCream},addPlus:{...v(e,"bold"),fontSize:20,lineHeight:22,color:t.brandInk},addLabel:{...v(e,"bold"),fontSize:15,lineHeight:20,color:t.text.primary},row:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:r.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface},rowActive:{borderColor:t.brandInk,backgroundColor:t.brandSoft},copy:{flex:1,gap:2},name:{...v(e,"bold"),fontSize:15,lineHeight:18,color:t.text.primary},meta:{...v(e,"monoBold"),fontSize:11,lineHeight:13,color:t.text.muted,textTransform:"uppercase",letterSpacing:Xa},closeSlot:{alignSelf:"flex-end"},closeButton:{paddingHorizontal:18,paddingVertical:10,borderRadius:zp,backgroundColor:t.brandSoft},closeText:{...v(e,"bold"),color:t.brandInk,fontSize:13,lineHeight:16,letterSpacing:Xa}})}i(jp,"makeStyles");var qp=44,sr=36,Yp=22,_n=9,Kp=1.5,ts=6,Be=35,lr=1.75,xn=12.4,$p=.5,Qp=8,Xp=28,Zp=160;function An(e,t){return Ia(e,t)}i(An,"headerPet");function ns({pets:e,petRef:t,historyUnread:r,onOpenHistory:n,onPetChange:o,onAddPet:a,vet:s}){let d=w(),l=useMemo(()=>ef(d),[d]),[c,u]=useState(false),f=An(e.pets,t),y=e.pets.length>=2,g=t??f?.petRef??null,h=kn(f),_=i(T=>{u(false),e.setActivePet(T),G(o,T);},"select"),m=a===void 0?null:()=>{u(false),G(a);};return jsxs(View,{style:l.row,children:[jsxs(V,{accessibilityRole:"button",accessibilityLabel:r?p.openMenuUnread:p.openMenu,containerStyle:l.iconSlot,style:l.iconButton,onPress:n,children:[jsx(ji,{size:Yp,color:d.color.text.primary,strokeWidth:2}),r?jsx(View,{style:l.unreadDot,pointerEvents:"none"}):null]}),jsx(View,{style:l.center,pointerEvents:"box-none",children:jsx(Jp,{logoUrl:d.meta.logoUrl,name:d.meta.displayName,styles:l})}),g===null?null:jsx(tt,{entry:"chat",petRef:g,...s?.returnTo!==void 0?{returnTo:s.returnTo}:{},...s?.usState!==void 0?{usState:s.usState}:{},style:l.vetEntry,labelStyle:l.vetEntryLabel}),jsx(View,{style:l.right,children:y?jsxs(V,{accessibilityRole:"button",accessibilityLabel:W(p.switchActivePet,{name:h}),containerStyle:l.avatarSlot,style:l.avatarWrap,onPress:()=>u(true),children:[jsx(St,{pet:f,size:Be,ringStroke:lr}),jsx(View,{style:l.addBadge,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:jsx(Gi,{size:Qp,color:d.color.brandInk,strokeWidth:2})})]}):e.loading&&f===null?jsx(View,{style:l.avatarWrap,accessible:true,accessibilityLabel:p.yourPet,children:jsx(tr,{size:Be,strokeWidth:lr,color:d.color.success,children:jsx(View,{style:l.placeholderDisc})})}):jsx(View,{style:l.avatarWrap,accessible:true,accessibilityRole:"image",accessibilityLabel:f===null?p.yourPet:h,children:jsx(St,{pet:f,size:Be,ringStroke:lr})})}),jsx(es,{visible:c,pets:e.pets,activePetRef:f?.petRef??null,onSelect:_,onAddPet:m,onClose:()=>u(false)})]})}i(ns,"ChatHeader");function Jp({logoUrl:e,name:t,styles:r}){let[n,o]=useState(null);return e===null||n===e?null:jsx(View,{style:r.logoBar,children:jsx(Image,{source:{uri:e},style:r.logo,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,onError:()=>o(e)})})}i(Jp,"BrandLogo");function ef(e){let t=e.color,r=Be-lr*2;return StyleSheet.create({vetEntry:{minHeight:qp,justifyContent:"center",paddingHorizontal:12,borderRadius:e.radius.pill,backgroundColor:t.surfaceCream,borderWidth:StyleSheet.hairlineWidth,borderColor:t.brandBorder},vetEntryLabel:{...v(e,"bold"),color:t.brandInk,fontSize:e.type.size.caption},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingVertical:10,backgroundColor:t.surface},iconSlot:{borderRadius:sr/2},iconButton:{width:sr,height:sr,borderRadius:sr/2,alignItems:"center",justifyContent:"center"},unreadDot:{position:"absolute",top:ts,right:ts,width:_n,height:_n,borderRadius:_n,backgroundColor:t.danger,borderWidth:Kp,borderColor:t.surface},center:{...StyleSheet.absoluteFillObject,alignItems:"center",justifyContent:"center"},logoBar:{alignItems:"center",paddingHorizontal:e.space.lg},logo:{height:Xp,width:Zp},right:{alignItems:"flex-end"},avatarSlot:{borderRadius:Be/2},avatarWrap:{width:Be,height:Be,position:"relative"},placeholderDisc:{width:r,height:r,borderRadius:r/2,backgroundColor:t.brandSoft},addBadge:{position:"absolute",bottom:0,right:0,width:xn,height:xn,borderRadius:xn/2,borderWidth:$p,borderColor:t.success,backgroundColor:t.surface,alignItems:"center",justifyContent:"center"}})}i(ef,"makeStyles");var is=44,af="rgba(17,17,17,0.55)",as=26,sf=36,ss=4,On=20,Fn=38,lf=18,df=12;function ls({visible:e,onSubmit:t,onSkip:r}){let n=w(),o=useMemo(()=>cf(n),[n]),[a,s]=useState(null),[d,l]=useState(""),[c,u]=useState(false),[f,y]=useState(false),g=i(()=>{s(null),l(""),u(false),y(false);},"reset"),h=i(()=>{c||(g(),r());},"skip"),_=i(async()=>{if(c)return;u(true),y(false);let T=d.trim();await t(a,T.length>0?T:null)?g():(u(false),y(true));},"submit");if(!e)return null;let m=[...d].length>Ut;return jsx(Modal,{visible:true,transparent:true,animationType:n.motion.reducedMotion?"none":"slide",onRequestClose:h,children:jsxs(KeyboardAvoidingView,{behavior:Platform.OS==="ios"?"padding":void 0,style:o.root,children:[jsx(Pressable,{style:o.scrim,onPress:h,accessibilityRole:"button",accessibilityLabel:p.feedbackSkipA11y}),jsxs(View,{style:o.sheet,accessibilityViewIsModal:true,accessibilityLiveRegion:"polite",children:[jsx(View,{style:o.handle}),jsxs(View,{style:o.header,children:[jsx(View,{style:o.iconBadge,children:jsx(er,{size:lf,color:n.color.brandInk,active:false,rotate:"180deg"})}),jsxs(View,{style:o.headerText,children:[jsx(b,{tier:"heading",style:o.title,accessibilityRole:"header",children:p.feedbackTitle}),jsx(b,{style:o.subtitle,children:p.feedbackSubtitle})]})]}),jsx(View,{style:o.options,children:wr.map(T=>{let A=a===T.key;return jsxs(V,{accessibilityRole:"button",accessibilityLabel:T.label,accessibilityState:{selected:A},style:[o.option,A?o.optionSelected:null],onPress:()=>s(O=>O===T.key?null:T.key),children:[jsx(b,{style:[o.optionLabel,A?o.optionLabelSelected:null],children:T.label}),jsx(View,{style:[o.radio,A?o.radioSelected:null],children:A?jsx(xe,{size:df,color:n.color.surface,strokeWidth:2}):null})]},T.key)})}),jsxs(View,{style:o.inputWrap,children:[jsx(Xe,{style:o.input,placeholder:p.feedbackNotesPlaceholder,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:p.feedbackNotesPlaceholder,value:d,onChangeText:l,multiline:true,editable:!c}),d.length>0?jsx(b,{tier:"compact",style:[o.counter,m?o.counterOver:null],children:`${[...d].length}/${Ut}`}):null]}),f?jsx(b,{style:o.failed,accessibilityRole:"alert",children:p.feedbackFailed}):null,jsxs(View,{style:o.actions,children:[jsx(V,{accessibilityRole:"button",accessibilityLabel:p.feedbackSubmit,accessibilityState:{busy:c,disabled:c||m},disabled:c||m,style:[o.submit,c||m?o.submitDisabled:null],onPress:()=>{_();},children:jsx(b,{tier:"control",style:o.submitLabel,children:p.feedbackSubmit})}),jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:p.feedbackSkipA11y,hitSlop:8,onPress:h,style:o.skip,children:jsx(b,{tier:"control",style:o.skipLabel,children:p.feedbackSkip})})]})]})]})})}i(ls,"FeedbackReasons");function cf(e){let t=e.color,r=e.type,n=e.radius,o=e.slots;return StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},scrim:{...StyleSheet.absoluteFillObject,backgroundColor:af},sheet:{backgroundColor:t.surface,borderTopLeftRadius:as,borderTopRightRadius:as,paddingHorizontal:22,paddingTop:12,paddingBottom:34,gap:14},handle:{alignSelf:"center",width:sf,height:ss,borderRadius:ss/2,backgroundColor:t.brandBorder,marginBottom:2},header:{flexDirection:"row",alignItems:"center",gap:12},iconBadge:{width:Fn,height:Fn,borderRadius:Fn/2,alignItems:"center",justifyContent:"center",backgroundColor:t.brandSoft},headerText:{flex:1,gap:2},title:{...v(e,"bold"),fontSize:20,lineHeight:28,color:t.text.primary,letterSpacing:r.letterSpacing.tight},subtitle:{...v(e,"regular"),fontSize:r.size.body,lineHeight:r.size.body*r.lineHeight.relaxed,color:t.text.muted},options:{gap:8},option:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:14,paddingVertical:13,borderRadius:n.md,borderWidth:StyleSheet.hairlineWidth,borderColor:t.brandBorder,backgroundColor:t.surface},optionSelected:{borderColor:t.brandInk,backgroundColor:t.brandSoft},optionLabel:{...v(e,"medium"),fontSize:r.size.body,color:t.text.primary},optionLabelSelected:{color:t.brandInk},radio:{width:On,height:On,borderRadius:On/2,borderWidth:2,borderColor:t.brandBorder,alignItems:"center",justifyContent:"center"},radioSelected:{borderColor:t.brandInk,backgroundColor:t.brandInk},inputWrap:{gap:4},input:{minHeight:72,maxHeight:132,borderRadius:n.md,borderWidth:StyleSheet.hairlineWidth,borderColor:t.brandBorder,paddingHorizontal:14,paddingTop:12,paddingBottom:12,...v(e,"regular"),fontSize:r.size.body,color:t.text.primary,textAlignVertical:"top"},counter:{...v(e,"mono"),alignSelf:"flex-end",fontSize:r.size.caption,letterSpacing:.3,color:t.text.placeholder},counterOver:{color:t.danger},failed:{...v(e,"regular"),fontSize:r.size.caption,lineHeight:r.size.caption*r.lineHeight.normal,color:t.danger},actions:{gap:10,alignItems:"center"},submit:{alignSelf:"stretch",minHeight:is,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.xl,borderRadius:n.pill,backgroundColor:t.brand,...oe(o.primaryButton)},submitDisabled:{opacity:.6},submitLabel:{...v(e,"medium"),fontSize:r.size.body,color:t.onPrimary,...ye(o.primaryButton)},skip:{minHeight:is,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},skipLabel:{...v(e,"medium"),fontSize:r.size.body,color:t.text.muted}})}i(cf,"makeStyles");var Pf=.88,Tf=420,kf=58,wf="rgba(17,17,17,0.28)",_f=.08,xf=.1,If=.08,Af=.18,Of=.78,Ff=.7,Mn=36,Mf=10,Df=14,Vf=12,Lf=16,Nf=14,Dn=8,Hf=1.5,Uf=.5,zf=nr(bt.standard);function Bf(e){return Math.min(Math.round(e*Pf),Tf)}i(Bf,"drawerPanelWidth");function cs({chat:e,history:t}){let[r,n]=useState(t.open),o=useCallback(()=>n(false),[]);return t.open&&!r&&n(true),r?jsx(jf,{chat:e,history:t,onHidden:o}):null}i(cs,"HistoryDrawer");function jf({chat:e,history:t,onHidden:r}){let n=w(),o=useMemo(()=>Gf(n),[n]),a=q(),s=useSafeAreaInsets(),{width:d}=useWindowDimensions(),l=Bf(d),c=t.open,u=useRef(null);u.current===null&&(u.current=new Animated.Value(a.drawerMs<=0&&c?1:0));let f=u.current;useEffect(()=>{if(!c&&a.drawerMs<=0){r();return}let T=Animated.timing(f,{toValue:c?1:0,duration:a.drawerMs,easing:zf,useNativeDriver:true});return T.start(({finished:A})=>{A&&!c&&r();}),()=>T.stop()},[c,f,a.drawerMs,r]);let y=f.interpolate({inputRange:[0,1],outputRange:[-l,0]}),g=t.filtered,h=t.rows.length===0,_=h&&t.loading?jsxs(View,{style:o.emptyCard,accessibilityLabel:K.loading,accessibilityState:{busy:true},children:[jsx(ActivityIndicator,{color:n.color.onPrimary}),jsx(b,{style:o.emptyBody,children:K.loading})]}):h&&t.error!==null?jsxs(View,{style:o.emptyCard,children:[jsx(b,{style:o.emptyTitle,accessibilityRole:"alert",children:K.loadFailed}),jsx(b,{style:o.emptyBody,children:t.error}),jsx(V,{accessibilityRole:"button",accessibilityLabel:K.retryA11y,containerStyle:o.retrySlot,style:o.retryButton,onPress:()=>{t.load();},children:jsx(b,{tier:"control",style:o.retryText,children:K.retry})})]}):jsxs(View,{style:o.emptyCard,children:[jsx(b,{style:o.emptyTitle,children:t.emptyKind==="empty"?K.empty:K.noMatch}),jsx(b,{style:o.emptyBody,children:t.emptyKind==="empty"?K.emptyBody:K.noMatchBody})]}),m=!t.searching&&t.loadingMore?jsx(View,{style:o.loadMoreFooter,children:jsx(b,{style:o.loadMoreLabel,children:K.loadingMore})}):null;return jsx(Modal,{visible:true,transparent:true,animationType:"none",onRequestClose:t.close,children:jsxs(View,{style:o.root,children:[jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:t.close,accessibilityRole:"button",accessibilityLabel:K.closeA11y,children:jsx(Animated.View,{style:[o.backdrop,{opacity:f}]})}),jsx(Animated.View,{style:[o.panel,{width:l,paddingTop:Math.max(kf,s.top+n.space.md),transform:[{translateX:y}]}],accessibilityViewIsModal:true,children:jsxs(KeyboardAvoidingView,{style:o.keyboardAvoider,behavior:Platform.OS==="ios"?"padding":"height",children:[jsxs(View,{style:o.searchRow,children:[jsxs(View,{style:o.searchPill,children:[jsx(ea,{size:Nf,color:n.color.text.muted,strokeWidth:1.5}),jsx(Xe,{value:t.query,onChangeText:T=>t.setQuery(T.replace(/^\s+/,"")),style:o.searchInput,placeholder:K.search,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:K.search,autoCorrect:false,autoCapitalize:"none",returnKeyType:"search"})]}),jsx(V,{accessibilityRole:"button",accessibilityLabel:K.newConversation,style:o.newButton,onPress:t.newConversation,children:jsx(ta,{size:Lf,color:n.color.text.primary,strokeWidth:1.5})})]}),jsx(b,{tier:"heading",style:o.heading,accessibilityRole:"header",children:K.heading}),t.error!==null&&!h?jsx(View,{style:o.errorCard,children:jsx(b,{style:o.errorText,accessibilityRole:"alert",children:t.error})}):null,jsx(FlatList,{data:g,keyExtractor:T=>T.id,renderItem:({item:T})=>jsx(Wf,{row:T,active:T.id===e.conversationId,disabled:t.loading,styles:o,onPress:()=>{t.resume(T.id);}}),contentContainerStyle:g.length===0?o.listEmpty:o.list,keyboardShouldPersistTaps:"handled",ListEmptyComponent:_,ListFooterComponent:m,onEndReached:t.loadMore,onEndReachedThreshold:Uf})]})})]})})}i(jf,"DrawerModal");function Wf({row:e,active:t,disabled:r,styles:n,onPress:o}){let a=e.unreadCount!==null&&e.unreadCount>0;return jsx(V,{accessibilityRole:"button",accessibilityLabel:Si(e),accessibilityState:{selected:t,disabled:r},disabled:r,style:[n.item,t?n.itemActive:null],onPress:o,children:jsxs(View,{style:n.itemRow,children:[jsx(b,{style:[n.itemTitle,a?n.itemTitleUnread:null],numberOfLines:1,children:Xt(e.title)}),a?jsx(View,{style:n.unreadDot}):null]})})}i(Wf,"Row");function pr(e,t){if(!/^#[0-9a-f]{6}$/i.test(e))return "transparent";let r=Math.round(Math.min(1,Math.max(0,t))*255);return `${e}${r.toString(16).padStart(2,"0").toUpperCase()}`}i(pr,"inkWash");function Gf(e){let t=e.color,r=e.slots,n=t.onPrimary;return StyleSheet.create({root:{flex:1},backdrop:{flex:1,backgroundColor:wf},panel:{position:"absolute",left:0,top:0,bottom:0,backgroundColor:t.brand,paddingHorizontal:16,borderRightWidth:.5,borderRightColor:t.brandBorder,gap:12},keyboardAvoider:{flex:1,gap:12},searchRow:{flexDirection:"row",alignItems:"center",gap:10},searchPill:{flex:1,flexDirection:"row",alignItems:"center",gap:8,borderRadius:e.radius.pill,backgroundColor:t.surface,paddingHorizontal:14,paddingVertical:10,borderWidth:1,borderColor:pr(n,xf)},searchInput:{...v(e,"regular"),flex:1,fontSize:13,lineHeight:16,color:t.text.primary,padding:0},newButton:{width:Mn,height:Mn,borderRadius:Mn/2,alignItems:"center",justifyContent:"center",backgroundColor:t.surface},heading:{...v(e,"bold"),fontSize:14,lineHeight:17,color:n,marginTop:4},list:{gap:10,paddingBottom:28},listEmpty:{flexGrow:1},item:{paddingVertical:12,paddingHorizontal:4,borderRadius:Mf},itemActive:{backgroundColor:pr(n,_f)},itemRow:{flexDirection:"row",alignItems:"center",gap:8},itemTitle:{...v(e,"regular"),flex:1,fontSize:14,lineHeight:18,color:n},itemTitleUnread:v(e,"bold"),unreadDot:{width:Dn,height:Dn,borderRadius:Dn/2,backgroundColor:t.danger,borderWidth:Hf,borderColor:n},errorCard:{borderRadius:Vf,borderWidth:.5,borderColor:t.danger,backgroundColor:t.surface,padding:12},errorText:{...v(e,"regular"),fontSize:11,lineHeight:16,color:t.danger},emptyCard:{borderRadius:Df,padding:14,gap:6,backgroundColor:pr(n,If),borderWidth:.5,borderColor:pr(n,Af)},emptyTitle:{...v(e,"bold"),fontSize:12,lineHeight:15,color:n},emptyBody:{...v(e,"regular"),fontSize:11,lineHeight:17,color:n,opacity:Of},retrySlot:{marginTop:8,alignSelf:"flex-start"},retryButton:{borderRadius:e.radius.pill,paddingHorizontal:14,paddingVertical:7,borderWidth:1,borderColor:n,...oe(r.primaryButton)},retryText:{...v(e,"bold"),fontSize:12,lineHeight:15,color:n,...ye(r.primaryButton)},loadMoreFooter:{paddingVertical:14,alignItems:"center"},loadMoreLabel:{...v(e,"regular"),fontSize:11,lineHeight:14,color:n,opacity:Ff}})}i(Gf,"makeStyles");function us(e,t){let r={entry:"chat",petRef:e};return t?.returnTo!==void 0&&(r.returnTo=t.returnTo),t?.usState!==void 0&&(r.usState=t.usState),r}i(us,"chatVetVisitOptions");var $f=16,Qf=.75,Vn=12,ps=15,Xf=18,fr=22,Zf=14,Jf=8,ey=20,ty=10,ry=13;function ys({surface:e,petRef:t,renderVetAction:r,onFindVet:n,vet:o}){let a=w(),s=useMemo(()=>ny(a),[a]),d=q(),l=e.tier,c=e.source;return jsxs(Fragment,{children:[jsx(on,{visible:e.showBanner&&l!==null,inMs:d.bannerInMs,outMs:d.bannerOutMs,style:s.pinned,children:l!==null&&c!==null?jsxs(View,{accessibilityRole:"alert",style:[s.card,{borderColor:l.borderColor,backgroundColor:l.backgroundColor}],children:[jsx(b,{tier:"compact",style:[s.label,{color:l.textColor}],children:l.label}),c.reason!==null?jsx(b,{style:[s.reason,{color:l.reasonColor}],children:c.reason}):null,e.showVetAction?r!==void 0?jsx(Ne,{render:()=>r(l.level),fallback:jsx(fs,{tier:l,petRef:t,onFindVet:n,vet:o,styles:s}),resetKey:l.level}):jsx(fs,{tier:l,petRef:t,onFindVet:n,vet:o,styles:s}):null,e.dismissLabel!==null?jsx(V,{accessibilityRole:"button",accessibilityLabel:e.dismissLabel,hitSlop:Jf,containerStyle:s.closeSlot,style:s.closeButton,onPress:e.dismiss,children:jsx(He,{size:Zf,color:l.textColor,strokeWidth:1.5})}):null]}):null}),jsx(on,{visible:e.showCompactIcon,inMs:d.iconInMs,outMs:d.iconOutMs,style:s.indicatorRow,children:jsx(V,{accessibilityRole:"button",accessibilityLabel:p.showLatestVetAlert,hitSlop:ty,onPress:e.expand,children:jsx(Qi,{size:ey,color:a.color.text.muted,strokeWidth:2})})})]})}i(ys,"UrgencyBanner");function fs({tier:e,petRef:t,onFindVet:r,vet:n,styles:o}){let a=w(),s=ar(us(t,n)),d=s.status==="opening",l=s.available?()=>{s.open();}:r!==void 0?()=>{G(r,e.level);}:null;if(l===null)return null;let c=mn(a.slots.vetVisitButton)?.textColor??e.textColor;return jsxs(V,{accessibilityRole:"button",accessibilityLabel:p.findVetA11y,accessibilityState:{busy:d},containerStyle:o.findVetSlot,style:[o.findVetButton,{borderColor:e.borderColor,backgroundColor:e.pillColor},o.findVetSlotBox,d?o.findVetBusy:null],onPress:l,children:[jsx(ra,{size:ry,color:c,strokeWidth:1.5}),jsx(b,{tier:"control",style:[o.findVetLabel,{color:c}],children:p.findVet})]})}i(fs,"VetAction");function ny(e){let t=mn(e.slots.vetVisitButton);return StyleSheet.create({pinned:{marginTop:0,marginBottom:4,paddingHorizontal:e.space.lg},card:{borderRadius:$f,borderWidth:Qf,paddingHorizontal:14,paddingVertical:8,gap:2},label:{...v(e,"monoBold"),fontSize:Vn,lineHeight:ps},reason:{...v(e,"regular"),fontSize:Vn,lineHeight:Xf,paddingRight:fr},findVetSlot:{alignSelf:"flex-start",marginTop:6},findVetButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:e.radius.pill,borderWidth:1},findVetSlotBox:{...oe(t,1)},findVetBusy:{opacity:.6},findVetLabel:{...v(e,"monoBold"),fontSize:Vn,lineHeight:ps},closeSlot:{position:"absolute",top:6,right:6},closeButton:{width:fr,height:fr,borderRadius:fr/2,alignItems:"center",justifyContent:"center"},indicatorRow:{alignItems:"flex-end",paddingHorizontal:16,paddingTop:2,paddingBottom:4}})}i(ny,"makeStyles");function ms(){let e=yn(),{handle:t}=ae(),r=useCallback(n=>t.setActivePet(n),[t]);return useMemo(()=>({...e,setActivePet:r}),[e,r])}i(ms,"useChatPets");var Es=300,Rs=3e3,hs=120,We=44,ly=120,dy="86%",gs=15,bs=22,mr=.5,cy=.04,uy=8,py=2,fy=1,yy=.6,my=22,hy=48,vs=1.25,gy=14,by=18,vy=6,Cy=14,Ey=.04,Ry=12,Sy=2,Py=2,Cs=36,Ty=20,rt=36,nt=(We-rt)/2,Ss=24,Ps=22,ky=.4,hr=30,Ts=20,wy=.4,_y=480,xy="12%";function pe(){let e=w(),t=useMemo(()=>Iy(e),[e]);return {theme:e,styles:t}}i(pe,"useChatTheme");function Iy(e){let t=e.color,r=e.space,n=e.radius,o=e.type,a=e.slots;return StyleSheet.create({container:{flex:1,minHeight:hs,backgroundColor:t.chatGround},body:{flex:1},centered:{minHeight:hs,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl},emptyContent:{flexGrow:1,alignItems:"center",justifyContent:"flex-start",paddingTop:xy,paddingHorizontal:r.lg,paddingBottom:r.lg,minHeight:_y,gap:18},errorText:{...v(e,"regular"),fontSize:o.size.subtitle,lineHeight:o.size.subtitle*o.lineHeight.snug,color:t.danger,textAlign:"center",marginBottom:r.md},retryButton:{minHeight:We,minWidth:We,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.brand,...oe(a.primaryButton)},retryLabel:{...v(e,"medium"),color:t.onPrimary,fontSize:o.size.body,...ye(a.primaryButton)},setupNotice:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm,paddingHorizontal:r.lg,paddingVertical:r.sm,backgroundColor:t.surfaceCream},setupNoticeText:{...v(e,"regular"),color:t.danger,fontSize:o.size.caption,flexShrink:1},turnNotice:{gap:r.xs,padding:r.md,borderRadius:n.lg,backgroundColor:t.surfaceCream,borderWidth:StyleSheet.hairlineWidth,borderColor:t.brandBorder,alignItems:"flex-start"},turnNoticeError:{borderColor:t.danger},turnNoticeTitle:{...v(e,"bold"),color:t.text.primary,fontSize:o.size.body},turnNoticeTitleError:{color:t.danger},turnNoticeBody:{...v(e,"regular"),color:t.text.secondary,fontSize:o.size.caption,lineHeight:o.size.caption*o.lineHeight.normal},turnNoticeAction:{minHeight:We,justifyContent:"center"},turnNoticeActionLabel:{...v(e,"medium"),color:t.brandInk,fontSize:o.size.body},setupNoticeAction:{...v(e,"medium"),color:t.brandInk,fontSize:o.size.caption},reconnectingCaption:{...v(e,"medium"),color:t.text.secondary,fontSize:o.size.caption,lineHeight:o.size.caption*o.lineHeight.normal,textTransform:"uppercase",letterSpacing:.5},list:{flex:1},listContent:{padding:r.lg,gap:r.md},rowBlock:{gap:r.sm},rowBlockUser:{},rowBlockAssistant:{paddingRight:r.xl},row:{flexDirection:"row"},rowUser:{justifyContent:"flex-end"},rowAssistant:{justifyContent:"flex-start"},bubble:{maxWidth:dy},bubbleUser:{padding:gs,backgroundColor:t.bubbleUser,borderRadius:n.xl,borderBottomRightRadius:n.sm,borderWidth:mr,borderColor:t.accentEdge,shadowColor:t.brand,shadowOpacity:cy,shadowRadius:uy,shadowOffset:{width:0,height:py},elevation:fy,...oe(a.userBubble,mr)},bubbleAssistant:a.assistantBubble?.backgroundColor===void 0?{...oe(a.assistantBubble,mr)}:{padding:gs,borderRadius:n.xl,...oe(a.assistantBubble,mr)},bubblePending:{opacity:yy},bubbleTextUser:{...v(e,"medium"),color:t.onPrimary,fontSize:o.size.body,lineHeight:bs,...ye(a.userBubble)},bubbleTextAssistant:{...v(e,"medium"),color:t.text.primary,fontSize:o.size.body,lineHeight:bs,...ye(a.assistantBubble)},bubbleBold:v(e,"bold"),bubbleItalic:{fontStyle:"italic"},bubbleCode:v(e,"mono"),followUps:{alignSelf:"stretch",marginTop:r.sm,borderRadius:n.md,backgroundColor:t.brandSoft,borderWidth:StyleSheet.hairlineWidth,borderColor:t.brandBorder},followUpsLabel:{...v(e,"medium"),color:t.text.secondary,fontSize:o.size.caption,letterSpacing:o.letterSpacing.eyebrow,textTransform:"uppercase",paddingHorizontal:r.md,paddingTop:r.md,paddingBottom:r.sm},followUpRow:{minHeight:We,justifyContent:"center",paddingHorizontal:r.md,paddingVertical:r.sm},followUpDivider:{borderTopWidth:StyleSheet.hairlineWidth,borderTopColor:t.brandBorder},followUpText:{...v(e,"regular"),color:t.text.primary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.snug},composerOuter:{position:"relative"},composer:{marginHorizontal:r.md,marginTop:r.xs,marginBottom:r.sm,minHeight:hy,justifyContent:"center",paddingLeft:gy,paddingRight:by,paddingVertical:vy,backgroundColor:t.composerFill,borderWidth:vs,borderColor:t.composerBorder,borderRadius:my,shadowColor:t.shadow,shadowOpacity:Ey,shadowRadius:Ry,shadowOffset:{width:0,height:Sy},elevation:Py,...oe(a.composerInput,vs)},composerRow:{flexDirection:"row",alignItems:"center",gap:Cy,minHeight:Cs},attachControl:{width:hr,height:hr,alignItems:"center",justifyContent:"center"},attachControlDisabled:{opacity:wy},input:{flex:1,minHeight:Cs,maxHeight:ly,paddingHorizontal:0,paddingVertical:0,...v(e,"regular"),fontSize:o.size.body,lineHeight:Ty,color:t.text.primary,...ye(a.composerInput)},sendControl:{minHeight:rt,minWidth:rt,alignItems:"center",justifyContent:"center"},sendDisc:{width:rt,height:rt,borderRadius:rt/2,alignItems:"center",justifyContent:"center",...oe(a.sendButton)},sendControlDisabled:{opacity:ky},poweredBy:{...v(e,"regular"),color:t.text.muted,fontSize:o.size.micro,textAlign:"center",paddingBottom:r.xs}})}i(Iy,"makeStyles");var Oe=Object.freeze({eyebrow:"Checking in",logged:"Logged",findVet:"Find a vet now",answers:Object.freeze({better:"Better",same:"Same",worse:"Worse"})}),ks=Object.freeze(So.map(e=>Object.freeze({answer:e,label:Oe.answers[e]})));function ws(e,t){let[r,n]=useState(null),[o,a]=useState(null),[s,d]=useState(null),l=useCallback(u=>{t!==null&&(n(u),a(null),t(e.caseId,u).then(f=>{n(null),f.ok?d(u):a(f.error);}));},[t,e.caseId]),c=s??e.answer;return {answer:c,answerable:!ko(e),escalated:c==="worse",pending:r,error:o,choose:l}}i(ws,"useCheckinCard");var As=44,Fy=.6;function Os({message:e,checkin:t,onAnswer:r,petRef:n,onFindVet:o,vet:a}){let s=w(),d=useMemo(()=>My(s),[s]),l=ws(t,r),c=l.answer!==null||l.pending!==null,u=r!==null&&l.answerable;return jsxs(View,{style:d.card,accessibilityLabel:Oe.eyebrow,children:[jsx(b,{tier:"compact",style:d.eyebrow,children:Oe.eyebrow}),jsx(b,{style:d.question,accessibilityRole:"text",children:e.text}),u?jsx(View,{style:[d.row,l.pending?d.rowPending:null],children:ks.map(({answer:f,label:y})=>{let g=(l.pending??l.answer)===f;return jsx(Pressable,{onPress:()=>l.choose(f),disabled:c,accessibilityRole:"button",accessibilityLabel:y,accessibilityState:{selected:g,disabled:c,busy:l.pending===f},style:[d.pill,g?d.pillSelected:null],children:jsx(b,{tier:"control",style:[d.pillLabel,g?d.pillLabelSelected:null],children:y})},f)})}):null,l.answer!==null?jsx(b,{style:d.logged,children:Oe.logged}):null,l.escalated?o!==void 0?jsx(Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:Oe.findVet,style:d.findVet,children:jsx(b,{tier:"control",style:d.findVetLabel,children:Oe.findVet})}):n?jsx(tt,{entry:"chat",petRef:n,label:Oe.findVet,...a?.returnTo!==void 0?{returnTo:a.returnTo}:{},...a?.usState!==void 0?{usState:a.usState}:{},style:d.findVet,labelStyle:d.findVetLabel}):null:null,t.resolutionText?jsx(b,{style:d.resolution,children:t.resolutionText}):null,l.error?jsx(b,{style:d.error,accessibilityRole:"alert",children:l.error.displayMessage}):null]})}i(Os,"CheckinCard");function My(e){let t=e.color,r=e.space,n=e.radius,o=e.type;return StyleSheet.create({card:{maxWidth:"92%",padding:r.md,gap:r.sm,borderRadius:n.lg,backgroundColor:t.surface,borderWidth:StyleSheet.hairlineWidth,borderColor:t.brandBorder},eyebrow:{...v(e,"regular"),color:t.text.secondary,fontSize:o.size.caption,letterSpacing:o.letterSpacing.eyebrow,textTransform:"uppercase"},question:{...v(e,"regular"),color:t.text.primary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.normal},row:{flexDirection:"row",gap:r.sm,marginTop:r.xs},rowPending:{opacity:Fy},pill:{flex:1,minHeight:As,alignItems:"center",justifyContent:"center",paddingHorizontal:r.md,borderRadius:n.pill,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surfaceCream},pillSelected:{backgroundColor:t.brand,borderColor:t.brand},pillLabel:{...v(e,"regular"),color:t.text.primary,fontSize:o.size.body},pillLabelSelected:{color:t.onPrimary},logged:{...v(e,"regular"),color:t.text.secondary,fontSize:o.size.caption},resolution:{...v(e,"regular"),color:t.text.primary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.normal},error:{...v(e,"regular"),color:t.danger,fontSize:o.size.caption},findVet:{alignSelf:"stretch",minHeight:As,alignItems:"center",justifyContent:"center",borderRadius:n.pill,borderWidth:1.5,borderColor:t.brandBorder,backgroundColor:t.surface},findVetLabel:{...v(e,"bold"),color:t.brandInk,fontSize:o.size.body}})}i(My,"makeStyles");var Vy=Object.freeze({TIER_1:"#07C168",TIER_2:"#27A9FF",TIER_3:"#FBC558"}),Fs="#C8BEB4";function Ly(e){return e?Vy[e.toUpperCase()]??Fs:Fs}i(Ly,"tierColor");function Ny(e){if(!e)return null;let t=/^tier[_\s-]?(\d+)$/i.exec(e.trim());return t?`Tier ${t[1]}`:e}i(Ny,"tierLabel");function Se(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}i(Se,"text");function Hy(e){let t=Se(e);return t!==null&&/^https:\/\/\S+$/i.test(t)?t:null}i(Hy,"httpsUrl");function Uy(e,t){let r=Se(e.source_name)??Se(e.sourceName),n=Se(e.section),o=Se(e.authority_tier)??Se(e.authorityTier),a=Ny(o),s=r??Se(e.title)??`Source ${t+1}`,d=Se(e.monograph_chunk_id)??Se(e.chunkId),l=[n,a].filter(c=>c!==null).join(" \xB7 ");return Object.freeze({title:s,sourceName:r,section:n,authorityTier:o,tierLabel:a,meta:l.length===0?null:l,url:Hy(e.url),excerpt:Se(e.excerpt),tierColor:Ly(o),key:`${s}-${d??"none"}-${t}`})}i(Uy,"toCitationCard");function Ms(e){return e===void 0||e.length===0?zy:Object.freeze(e.map((t,r)=>Uy(t,r)))}i(Ms,"toCitationCards");var zy=Object.freeze([]);function Hn(e){return e===1?`1 ${p.sourceSingular}`:`${e} ${p.sourcePlural}`}i(Hn,"sourcesLabel");function Ds(e,t){return `${t?p.hideSources:p.showSources} ${Hn(e)}`}i(Ds,"sourcesToggleLabel");function Vs(e){return [e.url!==null?`${p.openSource}: ${e.title}`:e.title,e.meta,e.excerpt].filter(t=>t!==null&&t.length>0).join(". ")}i(Vs,"citationA11yLabel");var Yy=244,Ns=8,Hs=13,Ky=14,$y=.3,Qy=-0.24,Xy=22,Zy=10,Jy=15;function Us({citations:e}){let t=w(),r=useMemo(()=>rm(t),[t]),n=useMemo(()=>Ms(e),[e]),[o,a]=useState(false);if(n.length===0)return null;let s=n.length;return jsxs(View,{style:r.block,children:[jsxs(V,{accessibilityRole:"button",accessibilityLabel:Ds(s,o),accessibilityState:{expanded:o},containerStyle:r.toggleSlot,style:r.togglePill,onPress:()=>a(d=>!d),children:[jsx(Yi,{size:Hs,color:t.color.brandInk,strokeWidth:1.5}),jsx(b,{tier:"compact",style:r.toggleLabel,children:Hn(s)}),jsx(qi,{size:Hs,color:t.color.brandInk,strokeWidth:1.5,direction:o?"up":"down"})]}),o?jsx(em,{cards:n,styles:r}):null]})}i(Us,"CitationCards");function em({cards:e,styles:t}){let r=q(),n=Ue(r.citationsInMs,{risePx:r.citationsRisePx});return jsx(Animated.View,{style:n,children:jsx(ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,contentContainerStyle:t.row,children:e.map(o=>jsx(tm,{card:o,styles:t},o.key))})})}i(em,"Deck");function tm({card:e,styles:t}){let r=w(),n=Vs(e),o=e.url!==null,a=jsxs(Fragment,{children:[jsxs(View,{style:t.cardHeader,children:[jsx(View,{style:[t.tierDot,{backgroundColor:e.tierColor}]}),jsx(b,{style:[t.cardTitle,o?t.cardTitleLink:null],numberOfLines:2,children:e.title}),o?jsx(Ki,{size:Ky,color:r.color.linkInk,strokeWidth:1.5}):null]}),e.meta!==null?jsx(b,{tier:"compact",style:t.cardMeta,numberOfLines:1,children:e.meta}):null,e.excerpt!==null?jsx(b,{style:t.cardExcerpt,numberOfLines:3,children:e.excerpt}):null]});if(e.url!==null){let s=e.url;return jsx(V,{accessibilityRole:"link",accessibilityLabel:n,style:t.card,onPress:()=>{Linking.openURL(s);},children:a})}return jsx(View,{accessible:true,accessibilityRole:"text",accessibilityLabel:n,style:t.card,children:a})}i(tm,"Card");function rm(e){let t=e.color,r=e.space,n=e.radius,o=e.type.size;return StyleSheet.create({block:{gap:r.sm},toggleSlot:{alignSelf:"flex-start",borderRadius:n.pill},togglePill:{flexDirection:"row",alignItems:"center",gap:r.xs+2,paddingHorizontal:r.md,paddingVertical:r.xs+2,borderRadius:n.pill,backgroundColor:t.brandSoft},toggleLabel:{...v(e,"monoBold"),fontSize:o.micro,lineHeight:o.micro,letterSpacing:$y,color:t.brandInk,textTransform:"uppercase"},row:{gap:r.sm,paddingRight:r.xl,paddingTop:r.xs},card:{width:Yy,borderRadius:n.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,padding:r.md,gap:r.xs+2},cardHeader:{flexDirection:"row",alignItems:"center",gap:r.sm},tierDot:{width:Ns,height:Ns,borderRadius:n.pill},cardTitle:{...v(e,"bold"),flex:1,fontSize:o.bodyTight,lineHeight:Xy,color:t.text.primary,letterSpacing:Qy},cardTitleLink:{color:t.linkInk},cardMeta:{...v(e,"monoMedium"),fontSize:o.nano,lineHeight:Zy,letterSpacing:e.type.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase"},cardExcerpt:{...v(e,"regular"),fontSize:o.tiny,lineHeight:Jy,color:t.text.muted}})}i(rm,"makeStyles");function zs(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}i(zs,"formatMessageTime");var kt=15,lm=15,dm=6,cm=Object.freeze({up:"0deg",neutral:"270deg",down:"180deg"});function qs({message:e,onCopy:t,sentiment:r=null,onSentiment:n,thanks:o=false}){let a=w(),s=useMemo(()=>um(a),[a]),d=q(),l=e.role==="user",c=useMemo(()=>zs(e.createdAt),[e.createdAt]),u=t!==void 0&&e.text.length>0,f=!l&&n!==void 0&&e.responseId!==void 0,[y,g]=useState(false),h=useRef(null);useEffect(()=>()=>{h.current&&clearTimeout(h.current);},[]);let _=i(()=>{t!==void 0&&(Ze(t,e.text),g(true),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{g(false),h.current=null;},d.copiedMs));},"copy");return c===null&&!u&&!f?null:jsxs(View,{style:s.wrap,children:[jsxs(View,{style:[s.row,l?s.rowUser:s.rowAssistant],children:[c!==null?jsx(b,{tier:"compact",style:s.timestamp,children:c}):null,u?jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:y?p.copied:l?p.copyUserMessage:p.copyAssistantMessage,hitSlop:lm,onPress:_,style:s.iconHit,children:y?jsx(xe,{size:kt,color:a.color.success,strokeWidth:2}):jsx($i,{size:kt,color:a.color.text.timestamp,strokeWidth:1.5})}):null,f?to.map(({sentiment:m,label:T})=>jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:T,accessibilityState:{selected:r===m},hitSlop:dm,onPress:()=>n?.(m),style:s.iconHit,children:jsx(er,{size:kt,color:a.color.sentiment[m],active:r===m,rotate:cm[m],strokeWidth:1.5})},m)):null]}),o?jsx(b,{style:s.thanks,accessibilityLiveRegion:"polite",children:p.feedbackThanks}):null]})}i(qs,"MessageFooter");function um(e){let t=e.type;return StyleSheet.create({wrap:{gap:4},row:{flexDirection:"row",alignItems:"center",gap:10,paddingTop:6},rowAssistant:{alignSelf:"flex-start"},rowUser:{alignSelf:"flex-end"},timestamp:{...v(e,"monoMedium"),fontSize:t.size.nano,lineHeight:t.size.nano+2,color:e.color.text.timestamp,textAlign:"center"},iconHit:{width:kt,height:kt,alignItems:"center",justifyContent:"center"},thanks:{...v(e,"regular"),fontSize:t.size.caption,lineHeight:t.size.caption*t.lineHeight.normal,color:e.color.text.secondary}})}i(um,"makeStyles");var Ys="#000000",pm="#83E0B4",fm=Object.freeze([Object.freeze({id:"breed-health-miss",intent:"send",label:"What {breed} health issue do owners miss most?",fallbackLabel:"What {species} health issue do owners miss most?",background:"#A0C4F6",borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),Object.freeze({id:"attention-at-age",intent:"send",label:"What changes should I expect at {ageYears} years old?",fallbackLabel:"What changes should I expect as my {species} ages?",background:pm,borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),Object.freeze({id:"early-pain-signs",intent:"send",label:"What are early signs of pain?",background:"#FBC558",borderColor:"#10462E",borderWidth:1}),Object.freeze({id:"vet-prep",intent:"vet_report",label:"Help me prep for {petName}\u2019s vet visit.",background:"#FFBDBD",borderColor:"#6D1D14",borderWidth:1.25})]),ym=/\s*-\s*(?:small|medium|large|giant|toy)\s*$/i;function mm(e){return e==null?e:e.replace(ym,"").trim()}i(mm,"formatBreedForPrompt");var hm=new Set(["","?","-","--",".","n/a","na","none","null","nil","unknown","unspecified","unsure","not sure","not specified","not applicable","no idea","dunno","idk","tbd","other","i dont know","i don't know","dont know","don't know","do not know","i do not know","not known","no clue"]);function gm(e){let t=String(e??"").replace(/\s+/gu," ").trim().toLowerCase().replace(/\u2019/g,"'");return hm.has(t)}i(gm,"isUninformativeBreed");function bm(e){return e==="cat"?"Domestic Short Hair Mix":"Mixed Breed"}i(bm,"unspecifiedBreedLabel");function vm(e,t){return gm(e)?bm(t):String(e).replace(/\s+/gu," ").trim()}i(vm,"resolveBreedLabel");function Ks(e){let t=e?.name?.trim()||p.emptyTitlePetFallback;return W(p.emptyTitle,{petName:t})}i(Ks,"emptyStateTitle");function $s(e){let t=En(e?.species),r=t==="cat"?"my cat":"my dog",n=e?.name?.trim()||null,o=n||r,a=vm(mm(e?.breed),t)||null,s=Rn(e?.ageYears),d=s===null?null:String(s);return Object.freeze(fm.map(l=>{let c=l.label.includes("{breed}"),u=l.label.includes("{ageYears}"),y=l.fallbackLabel!==void 0&&(c&&!a||u&&!d)&&l.fallbackLabel?l.fallbackLabel:l.label,g=W(y,{petName:o,breed:a??r,species:t,ageYears:d??""}),h=!n&&y.startsWith("{petName}")?g.charAt(0).toUpperCase()+g.slice(1):g;return Object.freeze({id:l.id,intent:l.intent,label:h,background:l.background,borderColor:l.borderColor,borderWidth:l.borderWidth})}))}i($s,"resolveQuickPrompts");var Em=36,Zs=4,Rm=340;function Js({pet:e,petRef:t,onSend:r,onVetPrep:n,vet:o}){let a=w(),s=useMemo(()=>Pm(a),[a]),d=useMemo(()=>$s(e),[e]),l=Ks(e);return jsxs(View,{style:s.block,children:[jsx(b,{tier:"heading",style:s.title,accessibilityRole:"header",children:l}),jsx(View,{style:s.list,children:d.map((c,u)=>jsx(Sm,{prompt:c,index:u,petRef:t,onSend:r,onVetPrep:n,vet:o,pet:e,styles:s},c.id))})]})}i(Js,"QuickPrompts");function Sm({prompt:e,index:t,pet:r,petRef:n,onSend:o,onVetPrep:a,vet:s,styles:d}){let l=q(),c=Ue(l.followUpInMs,{delayMs:rr(l,t)}),u={backgroundColor:e.background,borderColor:e.borderColor,borderWidth:e.borderWidth};return e.intent==="vet_report"?a!==void 0?jsx(Animated.View,{style:c,children:jsx(V,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:Zs,style:[d.chip,u],onPress:()=>{G(a,r);},children:jsx(b,{tier:"compact",style:d.chipLabel,children:e.label})})}):n===null?null:jsx(Animated.View,{style:c,children:jsx(tt,{entry:"chat",petRef:n,label:e.label,...s?.returnTo!==void 0?{returnTo:s.returnTo}:{},...s?.usState!==void 0?{usState:s.usState}:{},style:[d.chip,u],labelStyle:d.chipLabel})}):jsx(Animated.View,{style:c,children:jsx(V,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:Zs,style:[d.chip,u],onPress:()=>o(e.label),children:jsx(b,{tier:"compact",style:d.chipLabel,children:e.label})})})}i(Sm,"Chip");function Pm(e){let t=e.color;return StyleSheet.create({block:{gap:18,alignItems:"center",width:"100%"},title:{...v(e,"bold"),fontSize:28,lineHeight:34,color:t.text.primary,letterSpacing:-0.8,textAlign:"center",maxWidth:Rm},list:{width:"100%",gap:12,alignItems:"center"},chip:{borderRadius:e.radius.pill,paddingHorizontal:14,paddingVertical:9,minHeight:Em,minWidth:0,alignItems:"center",justifyContent:"center",maxWidth:"100%"},chipLabel:{...v(e,"bold"),fontSize:12,lineHeight:14,color:Ys,textAlign:"center"}})}i(Pm,"makeStyles");var zn=/\*\*([^*]+?)\*\*|\*([^*]+?)\*|`([^`]+?)`/g;function el(e){return e.includes("*")||e.includes("`")}i(el,"hasInlineMarkup");function tl(e){let t=[],r=0;zn.lastIndex=0;for(let n=zn.exec(e);n!==null;n=zn.exec(e)){n.index>r&&t.push({kind:"text",text:e.slice(r,n.index)});let o=n[1],a=n[2],s=n[3];o!==void 0?t.push({kind:"bold",text:o}):a!==void 0?t.push({kind:"italic",text:a}):s!==void 0&&t.push({kind:"code",text:s}),r=n.index+n[0].length;}return r<e.length&&t.push({kind:"text",text:e.slice(r)}),t}i(tl,"tokenizeInlineMarkdown");function rl(e,t){return el(e)?tl(e).map((r,n)=>{switch(r.kind){case "bold":return jsx(b,{style:t.bold,children:r.text},n);case "italic":return t.italic?jsx(b,{style:t.italic,children:r.text},n):r.text;case "code":return t.code?jsx(b,{style:t.code,children:r.text},n):r.text;default:return r.text}}):e}i(rl,"renderInlineMarkdown");var il=6,ll=520,Im=Math.round(ll*.18),al=.44,Am=.5,sl=[0,.5,1],Om=[0,1,2];function dl(){let e=w(),t=useMemo(()=>Mm(e),[e]),r=!e.motion.reducedMotion;return jsx(View,{style:t.card,accessible:true,accessibilityRole:"text",accessibilityLabel:p.typing,accessibilityLiveRegion:"polite",accessibilityState:{busy:true},children:Om.map(n=>r?jsx(Fm,{index:n,style:t.dot},n):jsx(View,{style:[t.dot,t.dotStatic]},n))})}i(dl,"TypingIndicator");function Fm({index:e,style:t}){let r=useRef(new Animated.Value(0)).current;useEffect(()=>{let a=Animated.sequence([Animated.delay(e*Im),Animated.loop(Animated.timing(r,{toValue:1,duration:ll,useNativeDriver:true}))]);return a.start(),()=>a.stop()},[r,e]);let n=r.interpolate({inputRange:sl,outputRange:[al,1,al]}),o=r.interpolate({inputRange:sl,outputRange:[0,-3.5,0]});return jsx(Animated.View,{style:[t,{opacity:n,transform:[{translateY:o}]}]})}i(Fm,"AnimatedDot");function Mm(e){let t=e.color,r=e.space,n=e.radius;return StyleSheet.create({card:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:r.xs,paddingHorizontal:r.md,paddingVertical:r.sm,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:StyleSheet.hairlineWidth,borderColor:t.brandBorder},dot:{width:il,height:il,borderRadius:n.pill,backgroundColor:t.brand},dotStatic:{opacity:Am}})}i(Mm,"makeStyles");function fl(e,t,r){switch(e){case "loading":return r.renderPending?jsx(Ne,{render:r.renderPending,fallback:jsx(cl,{})}):jsx(cl,{});case "empty":return jsx(Hm,{pet:r.shownPet,petRef:t.petRef,prompts:t.suggestedPrompts,onSelectPrompt:r.onSelectPrompt,onVetPrep:r.onVetPrep,vet:r.vet});case "error":return jsx(zm,{error:t.error,onRetry:t.retryLast,onAddPet:r.onAddPet});case "populated":return jsx(Bm,{messages:t.messages,prompts:t.suggestedPrompts,onSelectPrompt:r.onSelectPrompt,isStreaming:t.isStreaming,onAnswerCheckin:t.petRef?t.answerCheckin:null,onCopy:r.onCopy,sentimentByMessage:t.sentimentByMessage,onSentiment:r.onSentiment,thanksFor:r.thanksFor,imagesByMessage:r.imagesByMessage,onPreview:r.onPreview,notice:r.notice,reconnecting:t.reconnecting===true,onRetry:t.retryLast,onStartNew:t.newConversation,petRef:t.petRef,onFindVet:r.onCheckinFindVet,vet:r.vet});default:return Lt(e)}}i(fl,"renderView");function cl(){let{theme:e,styles:t}=pe(),[r,n]=useState(false);return useEffect(()=>{let o=setTimeout(()=>n(true),Es);return ()=>clearTimeout(o)},[]),jsx(View,{style:t.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:p.loading,children:r?jsx(ActivityIndicator,{color:e.color.brandInk}):null})}i(cl,"LoadingState");function Hm({pet:e,petRef:t,prompts:r,onSelectPrompt:n,onVetPrep:o,vet:a}){let{styles:s}=pe();return jsxs(ScrollView,{contentContainerStyle:s.emptyContent,keyboardShouldPersistTaps:"handled",accessibilityLabel:p.empty,children:[jsx(Js,{pet:e,petRef:t,onSend:n,onVetPrep:o,vet:a}),jsx(yl,{prompts:r,onSelectPrompt:n})]})}i(Hm,"EmptyState");function yl({prompts:e,onSelectPrompt:t}){let{styles:r}=pe();return e.length===0?null:jsxs(View,{style:r.followUps,children:[jsx(b,{tier:"compact",style:r.followUpsLabel,accessibilityRole:"header",children:p.followUps}),e.map((n,o)=>jsx(Um,{prompt:n,index:o,onSelectPrompt:t},n))]})}i(yl,"FollowUps");function Um({prompt:e,index:t,onSelectPrompt:r}){let{styles:n}=pe(),o=q(),a=Ue(o.followUpInMs,{delayMs:rr(o,t)});return jsx(Animated.View,{style:a,children:jsx(Pressable,{onPress:()=>r(e),accessibilityRole:"button",accessibilityLabel:e,style:[n.followUpRow,t>0?n.followUpDivider:null],children:jsx(b,{style:n.followUpText,children:e})})})}i(Um,"FollowUpRow");function zm({error:e,onRetry:t,onAddPet:r}){let{styles:n}=pe(),o=ii(e)?fi(r):void 0;return jsxs(View,{style:n.centered,accessible:true,accessibilityRole:"alert",children:[jsx(b,{style:n.errorText,children:e.displayMessage}),o!==void 0?jsx(Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:p.addPet,style:n.retryButton,children:jsx(b,{tier:"control",style:n.retryLabel,children:p.addPet})}):null,e.retryable?jsx(Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:p.retry,style:n.retryButton,children:jsx(b,{tier:"control",style:n.retryLabel,children:p.retry})}):null]})}i(zm,"ErrorState");function Bm({messages:e,prompts:t,onSelectPrompt:r,isStreaming:n,onAnswerCheckin:o,onCopy:a,sentimentByMessage:s,onSentiment:d,thanksFor:l,imagesByMessage:c,onPreview:u,notice:f,reconnecting:y,onRetry:g,onStartNew:h,petRef:_,onFindVet:m,vet:T}){let{styles:A}=pe(),O=q();vt(e.length,O);let F=Ai(e,n),C=e[e.length-1];return jsxs(ScrollView,{style:A.list,contentContainerStyle:A.listContent,accessibilityLabel:p.transcript,keyboardShouldPersistTaps:"handled",children:[e.map(E=>E.checkin?jsx(Os,{message:E,checkin:E.checkin,onAnswer:o,petRef:_,onFindVet:m,vet:T},E.id):jsx(Gm,{message:E,revealing:n&&E===C&&E.role==="assistant",onCopy:a,sentiment:E.responseId===void 0?null:s[String(E.responseId)]??null,onSentiment:d,thanks:l!==null&&E.responseId!==void 0&&String(E.responseId)===l,images:c[E.id]??Wm,onPreview:u},E.id)),y?jsx(b,{tier:"compact",style:A.reconnectingCaption,accessibilityRole:"text",children:p.reconnecting}):null,F?jsx(dl,{}):null,f!==null?jsx(jm,{notice:f,onRetry:g,onStartNew:h}):null,n?null:jsx(yl,{prompts:t,onSelectPrompt:r})]})}i(Bm,"PopulatedState");function jm({notice:e,onRetry:t,onStartNew:r}){let{styles:n}=pe(),o=e.tone==="error";return jsxs(View,{style:[n.turnNotice,o?n.turnNoticeError:null],accessible:true,accessibilityRole:"alert",children:[jsx(b,{tier:"control",style:[n.turnNoticeTitle,o?n.turnNoticeTitleError:null],children:e.title}),jsx(b,{tier:"compact",style:n.turnNoticeBody,children:e.body}),jsx(Pressable,{onPress:e.action==="startNew"?r:t,accessibilityRole:"button",accessibilityLabel:e.actionLabel,hitSlop:nt,style:n.turnNoticeAction,children:jsx(b,{tier:"control",style:n.turnNoticeActionLabel,children:e.actionLabel})})]})}i(jm,"TurnNoticeCard");var Wm=Object.freeze([]);function Gm({message:e,revealing:t,onCopy:r,sentiment:n,onSentiment:o,thanks:a,images:s,onPreview:d}){let{styles:l}=pe(),c=q(),u=Ue(c.messageInMs),f=pa(e.text,t,c),y=e.role==="user",g=y?p.senderUser:p.senderAssistant,h=useCallback(m=>o(e,m),[o,e]),_=e.pending!==true;return jsxs(Animated.View,{style:[l.rowBlock,y?l.rowBlockUser:l.rowBlockAssistant,u],children:[jsx(View,{style:[l.row,y?l.rowUser:l.rowAssistant],accessible:true,accessibilityRole:"text",accessibilityLabel:`${g}: ${e.text}`,accessibilityState:e.pending===true?{busy:true}:void 0,children:jsxs(View,{style:[l.bubble,y?l.bubbleUser:l.bubbleAssistant,e.pending?l.bubblePending:null],children:[y&&s.length>0?jsx(_a,{images:s,onPreview:m=>d({uri:m.uri,label:m.filename})}):null,jsx(b,{style:y?l.bubbleTextUser:l.bubbleTextAssistant,children:y?e.text:rl(f,{bold:l.bubbleBold,italic:l.bubbleItalic,code:l.bubbleCode})})]})}),!y&&!t?jsx(Us,{citations:e.citations}):null,_?jsx(qs,{message:e,onCopy:r,sentiment:n,onSentiment:e.responseId===void 0?void 0:h,thanks:a}):null]})}i(Gm,"MessageRow");var Qm=Object.freeze(["photo"]),Xm=1;function Zm(e){let{style:t,renderPending:r}=e;return jsx(Ni,{capability:"chat",style:t,...r?{renderPending:r}:{},children:jsx(Jm,{...e})})}i(Zm,"EverfurChat");function Jm({petRef:e,conversationId:t,style:r,renderPending:n,onCopy:o,onPetChange:a,onVetPrep:s,onFindVet:d,renderVetAction:l,attachments:c,pet:u,onAddPet:f,checkinTarget:y,initialAsk:g,composerSeed:h,lifecycle:_,draftStore:m,vetReturnTo:T,vetUsState:A}){let{theme:O,styles:F}=pe(),C=q(),E=useMemo(()=>Oi(e,t),[e,t]),R=Ft(E),L=xi(R),P=ms(),S=Pi(R),x=useSafeAreaInsets(),U=Ii(R),j=useMemo(()=>d===void 0?void 0:()=>{G(d,"emergency");},[d]),z=useMemo(()=>T===void 0&&A===void 0?void 0:{returnTo:T,usState:A},[T,A]),re=An(P.pets,R.petRef),ie=useMemo(()=>wi(R.messages,re?.name??null),[R.messages,re?.name]),B=_i(ie);vt(B.showBanner,C),gi(R.openCheckin,y),ci(R.askEverfur,R.isBootstrapping,g);let Me=useMemo(()=>jr(h),[h]);mi(_,{conversationId:R.conversationId===null?null:String(R.conversationId),isTurnInFlight:R.isStreaming,refresh:R.refreshActiveThread});let xt=(R.hasUnreadThreads??false)||S.rows.some(ge=>ge.unreadCount!==null&&ge.unreadCount>0)||(R.unreadCount??0)>0,at=li(R.messages),[Ke,$e]=useState(null),gl=useCallback(()=>$e(null),[]),[st,Rr]=useState(null),[bl,jn]=useState(null),Qe=useRef(null);useEffect(()=>()=>{Qe.current&&clearTimeout(Qe.current);},[]);let Wn=useCallback(ge=>{jn(String(ge)),Qe.current&&clearTimeout(Qe.current),Qe.current=setTimeout(()=>{jn(null),Qe.current=null;},Rs);},[]),vl=useCallback((ge,It)=>{let lt=ge.responseId;if(lt===void 0)return;let Sl=R.sentimentByMessage[String(lt)];R.feedback(lt,It),It==="down"&&Sl!=="down"&&Rr(lt);},[R]),Cl=useCallback(async(ge,It)=>st===null||!(await R.feedback(st,"down",ge??"other",It)).ok?false:(Rr(null),Wn(st),true),[R,st,Wn]),El=useCallback(()=>Rr(null),[]),Rl=useCallback(ge=>{R.send(ge);},[R.send]),Gn={send:R.send,stop:R.stop,isStreaming:R.isStreaming,conversationId:R.conversationId,seed:Me,draftStore:m,onStage:at.stage,onPreview:$e};return jsxs(KeyboardAvoidingView,{style:[F.container,{paddingTop:x.top},r],behavior:Platform.OS==="ios"?"padding":void 0,children:[jsx(ns,{pets:P,petRef:R.petRef,historyUnread:xt,onOpenHistory:S.show,onPetChange:a,onAddPet:f,vet:z}),u!==void 0?jsx(eh,{petRef:e??null,pet:u,onRegistered:P.refresh}):null,jsx(ys,{surface:B,petRef:R.petRef,renderVetAction:l,onFindVet:d,vet:z}),jsx(View,{style:F.body,children:fl(L,R,{notice:U,vet:z,onCheckinFindVet:j,onSelectPrompt:Rl,renderPending:n,shownPet:re,onVetPrep:s,onCopy:o,onSentiment:vl,thanksFor:bl,imagesByMessage:at.byMessage,onPreview:$e,onAddPet:f})}),c!==void 0?jsx(th,{...Gn,attachments:c}):jsx(hl,{...Gn,attachments:null}),jsx(Bi,{}),O.meta.hidePoweredBy?null:jsx(b,{tier:"compact",style:F.poweredBy,accessibilityRole:"text",accessibilityLabel:p.poweredBy,children:p.poweredBy}),jsx(cs,{chat:R,history:S}),jsx(ls,{visible:st!==null,onSubmit:Cl,onSkip:El}),jsx(fa,{uri:Ke?.uri??null,label:Ke?.label??"",onClose:gl})]})}i(Jm,"ChatBody");function eh({petRef:e,pet:t,onRegistered:r}){let{styles:n}=pe(),o=ai(e,t,r);return o.status!=="failed"||o.error===null?null:jsxs(View,{style:n.setupNotice,accessible:true,accessibilityRole:"alert",children:[jsx(b,{tier:"compact",style:n.setupNoticeText,children:o.error.displayMessage}),jsx(Pressable,{onPress:o.retry,accessibilityRole:"button",accessibilityLabel:p.retry,hitSlop:nt,children:jsx(b,{tier:"control",style:n.setupNoticeAction,children:p.retry})})]})}i(eh,"PetSetupNotice");function th({attachments:e,...t}){let r=useMemo(()=>pn(),[]),n=Vr({maxPerMessage:e.maxPerMessage??Xm,transport:r}),o=useMemo(()=>({state:n,sources:e.sources??Qm,pick:e.pick}),[n,e.sources,e.pick]);return jsx(hl,{...t,attachments:o})}i(th,"ComposerWithAttachments");function hl({send:e,stop:t,isStreaming:r,conversationId:n,attachments:o,seed:a,draftStore:s,onStage:d,onPreview:l}){let{theme:c,styles:u}=pe(),f=q(),[y,g]=Ci(e,n,a);Ei(s,n===null?null:String(n),y,g);let[h,_]=useState(false),[m,T]=useState(false);useEffect(()=>{T(false);},[n]);let A=c.meta.placeholder??p.placeholder,O=o?.state.uploading??false,F=o?.state.failed??false,C=O||F,E=o?.state.attachments??rh;vt(E.length,f);let R=useCallback(()=>{if(y.trim().length===0||C||[...y].length>zt)return;let z=o?.state.s3Keys??nh;o!==null&&z.length>0?(d(o.state.attachments.filter(re=>re.status==="uploaded").map(re=>({uri:re.previewUri,filename:re.filename}))),e(y,{imageS3Keys:z}),o.state.clear()):e(y),g(""),T(false);},[y,e,C,o,d]),L=useCallback(()=>{t();},[t]),P=useCallback(z=>{_(false),o!==null&&(T(false),o.state.dismissRejected(),Ze(o.pick,z).then(re=>{if(!re.ok){T(true);return}re.value!==null&&o.state.add(re.value);}));},[o]),x=useMemo(()=>[...y].length>zt,[y])||C,U=o!==null&&E.length>=o.state.maxPerMessage,j=c.slots.sendButton?.textColor??c.color.brandInk;return jsxs(View,{style:u.composerOuter,children:[o!==null&&h?jsx(ha,{sources:o.sources,full:U,onPick:P,onClose:()=>_(false)}):null,jsxs(View,{style:u.composer,children:[o!==null?jsx(wa,{attachments:E,rejected:m?oh:o.state.rejected,uploadFailed:F,onRetry:o.state.retry,onRemove:o.state.remove,onPreview:z=>l({uri:z.previewUri,label:z.filename})}):null,jsxs(View,{style:u.composerRow,children:[o!==null?jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:Oo(E.length,o.state.maxPerMessage),accessibilityState:{disabled:U,expanded:h},disabled:U,hitSlop:(We-hr)/2,style:[u.attachControl,U?u.attachControlDisabled:null],onPress:()=>_(z=>!z),children:jsx(Xi,{size:Ts,color:U?c.color.text.muted:c.color.brandInk,strokeWidth:1.75})}):null,jsx(Xe,{style:u.input,value:y,onChangeText:g,placeholder:A,placeholderTextColor:c.slots.composerInput?.textColor??c.color.text.placeholder,accessibilityLabel:A,onSubmitEditing:R,returnKeyType:"send",blurOnSubmit:false,multiline:true,editable:true}),r?jsx(Pressable,{onPress:L,accessibilityRole:"button",accessibilityLabel:p.stop,hitSlop:nt,style:u.sendControl,children:jsx(View,{style:u.sendDisc,testID:"everfur-stop-disc",children:jsx(oa,{size:Ps,color:j,testID:"everfur-stop-glyph"})})}):jsx(Pressable,{onPress:R,disabled:x,accessibilityRole:"button",accessibilityLabel:p.send,accessibilityState:{disabled:x,busy:O},hitSlop:nt,style:[u.sendControl,x?u.sendControlDisabled:null],children:jsx(View,{style:u.sendDisc,testID:"everfur-send-disc",children:jsx(na,{size:Ss,color:j,testID:"everfur-send-glyph"})})})]})]})]})}i(hl,"Composer");var rh=Object.freeze([]),nh=Object.freeze([]),oh=Object.freeze({code:"unknown",retryable:true,filename:""});export{Zm as EverfurChat,pn as createRnChatAttachmentTransport,Vr as useChatAttachments,Ft as useEverfurChat,yn as useEverfurPets};