@everfur/sdk 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/CHANGELOG.md +213 -0
  2. package/dist/{BookedScreen-BJPbXLCG.d.ts → BookedScreen-DFJcgf1e.d.ts} +12 -2
  3. package/dist/{BookedScreen-Cnld-jB_.d.cts → BookedScreen-R5X_Zrlh.d.cts} +12 -2
  4. package/dist/{Chat-CHqcgMyw.d.ts → Chat-DZpYH8Uh.d.ts} +4 -4
  5. package/dist/{Chat-BoAvCWhI.d.cts → Chat-bATY4atj.d.cts} +4 -4
  6. package/dist/{DepthViews-7Y8Ur058.d.ts → DepthViews-BpHUbjSY.d.cts} +1 -1
  7. package/dist/{DepthViews-B0g83e_N.d.cts → DepthViews-C4DC4Kom.d.cts} +1 -1
  8. package/dist/{DepthViews-Dg2bIon_.d.ts → DepthViews-dLTizxjr.d.ts} +1 -1
  9. package/dist/{DepthViews-CT5mQld9.d.cts → DepthViews-qBIoA48w.d.ts} +1 -1
  10. package/dist/animations/index.cjs +1 -1
  11. package/dist/animations/index.d.cts +3 -3
  12. package/dist/animations/index.d.ts +3 -3
  13. package/dist/animations/index.js +1 -1
  14. package/dist/{attachments-CfxsVg7W.d.ts → attachments-CPRFfoHT.d.ts} +2 -2
  15. package/dist/{attachments-rkox0ewd.d.cts → attachments-CUOGILir.d.cts} +5 -5
  16. package/dist/{attachments-CThFsH4b.d.ts → attachments-CXAnZcEg.d.ts} +5 -5
  17. package/dist/{attachments-C3HJNYQ7.d.cts → attachments-Ce06TWqe.d.cts} +2 -2
  18. package/dist/{bookingCopy-Do3zMeXb.d.cts → bookingCopy-BwVopcoV.d.cts} +451 -50
  19. package/dist/{bookingCopy-Y3OGdoMT.d.ts → bookingCopy-DFTv9w6J.d.ts} +451 -50
  20. package/dist/{bookingTypes-DCs8mmBb.d.cts → bookingTypes-D4pD3tHs.d.cts} +13 -1
  21. package/dist/{bookingTypes-DCs8mmBb.d.ts → bookingTypes-D4pD3tHs.d.ts} +13 -1
  22. package/dist/{branding-DYWma2il.d.ts → branding-Bio5MM6g.d.cts} +3 -3
  23. package/dist/{branding-ChXm8gxI.d.cts → branding-ytH4jJq1.d.ts} +3 -3
  24. package/dist/{callCopy-CPe9mbwG.d.cts → callCopy-DHjem0R-.d.cts} +12 -1
  25. package/dist/{callCopy-CPe9mbwG.d.ts → callCopy-DHjem0R-.d.ts} +12 -1
  26. package/dist/{casesRepository-Jj6t60AY.d.cts → casesRepository-CJchNp3x.d.cts} +1 -1
  27. package/dist/{casesRepository-BbgXYPxa.d.ts → casesRepository-DAVcY3jC.d.ts} +1 -1
  28. package/dist/chat/index.cjs +1 -1
  29. package/dist/chat/index.d.cts +9 -9
  30. package/dist/chat/index.d.ts +9 -9
  31. package/dist/chat/index.js +1 -1
  32. package/dist/client/index.cjs +2 -2
  33. package/dist/client/index.d.cts +10 -10
  34. package/dist/client/index.d.ts +10 -10
  35. package/dist/client/index.js +2 -2
  36. package/dist/{config-Dfbj5mlx.d.ts → config-ZxwCylac.d.ts} +1 -1
  37. package/dist/{config-BZX97FmW.d.cts → config-h5h6TsHL.d.cts} +1 -1
  38. package/dist/consent/index.cjs +1 -1
  39. package/dist/consent/index.d.cts +5 -5
  40. package/dist/consent/index.d.ts +5 -5
  41. package/dist/consent/index.js +1 -1
  42. package/dist/{context-DJXnZ1Mx.d.cts → context-CtsAgJnc.d.cts} +7 -7
  43. package/dist/{context-Cbe0zYym.d.ts → context-DtPIshVA.d.ts} +7 -7
  44. package/dist/{copy-dKK5KoAQ.d.cts → copy-CaWaplQc.d.cts} +2 -2
  45. package/dist/{copy-DHekqSKE.d.ts → copy-Cg89Qoal.d.ts} +2 -2
  46. package/dist/core/index.cjs +7 -7
  47. package/dist/core/index.d.cts +21 -21
  48. package/dist/core/index.d.ts +21 -21
  49. package/dist/core/index.js +7 -7
  50. package/dist/{depth-CrpRjWGB.d.ts → depth-Bo4bAwcn.d.ts} +132 -38
  51. package/dist/{depth-NmWSbvfi.d.cts → depth-EXZYEO70.d.cts} +132 -38
  52. package/dist/{entitlementRepository-iL-9vS1i.d.cts → entitlementRepository-BYtVb1oU.d.cts} +3 -3
  53. package/dist/{entitlementRepository-tVNazi8R.d.ts → entitlementRepository-DcbIx8yV.d.ts} +3 -3
  54. package/dist/{identity-B8rp0L9G.d.ts → identity-EC5-apbY.d.ts} +1 -1
  55. package/dist/{identity-D7PO5s9m.d.cts → identity-b5Vp32Vp.d.cts} +1 -1
  56. package/dist/index.cjs +6 -6
  57. package/dist/index.d.cts +17 -17
  58. package/dist/index.d.ts +17 -17
  59. package/dist/index.js +6 -6
  60. package/dist/notifications/index.d.cts +2 -2
  61. package/dist/notifications/index.d.ts +2 -2
  62. package/dist/{pets-BQbXmICf.d.ts → pets-B_27_agU.d.ts} +1 -1
  63. package/dist/{pets-BWx9BKea.d.cts → pets-DM8QvKLo.d.cts} +1 -1
  64. package/dist/{petsRepository-SqIvEMiT.d.cts → petsRepository-BJsJ4cju.d.cts} +1 -1
  65. package/dist/{petsRepository-0oBVydl6.d.ts → petsRepository-CuYZZaI5.d.ts} +1 -1
  66. package/dist/photo/index.cjs +1 -1
  67. package/dist/photo/index.js +1 -1
  68. package/dist/{ports-ChnzSy4E.d.cts → ports-ZmJYgd5I.d.cts} +10 -9
  69. package/dist/{ports-iXPWd7Vt.d.ts → ports-nXHf50_X.d.ts} +10 -9
  70. package/dist/records/depth/index.cjs +2 -2
  71. package/dist/records/depth/index.d.cts +7 -7
  72. package/dist/records/depth/index.d.ts +7 -7
  73. package/dist/records/depth/index.js +2 -2
  74. package/dist/records/index.cjs +3 -3
  75. package/dist/records/index.d.cts +19 -10
  76. package/dist/records/index.d.ts +19 -10
  77. package/dist/records/index.js +3 -3
  78. package/dist/{requestFunnel-DAwb7haa.d.cts → requestFunnel-C_cZXhIA.d.cts} +2 -2
  79. package/dist/{requestFunnel-CQzz2DIW.d.ts → requestFunnel-Ve9BshTB.d.ts} +2 -2
  80. package/dist/{runtimeTypes-BNOxfmfg.d.ts → runtimeTypes-ByKsp8hm.d.ts} +5 -5
  81. package/dist/{runtimeTypes-DB9-kigO.d.cts → runtimeTypes-D155OlBW.d.cts} +5 -5
  82. package/dist/server/events/index.cjs +1 -1
  83. package/dist/server/events/index.d.cts +2 -2
  84. package/dist/server/events/index.d.ts +2 -2
  85. package/dist/server/events/index.js +1 -1
  86. package/dist/server/index.cjs +1 -1
  87. package/dist/server/index.d.cts +3 -3
  88. package/dist/server/index.d.ts +3 -3
  89. package/dist/server/index.js +1 -1
  90. package/dist/televet/booking/index.cjs +4 -1
  91. package/dist/televet/booking/index.d.cts +116 -29
  92. package/dist/televet/booking/index.d.ts +116 -29
  93. package/dist/televet/booking/index.js +4 -1
  94. package/dist/televet/call/index.cjs +1 -1
  95. package/dist/televet/call/index.d.cts +1 -1
  96. package/dist/televet/call/index.d.ts +1 -1
  97. package/dist/televet/call/index.js +1 -1
  98. package/dist/televet/index.cjs +1 -1
  99. package/dist/televet/index.js +1 -1
  100. package/dist/testing/index.cjs +3 -3
  101. package/dist/testing/index.d.cts +1 -1
  102. package/dist/testing/index.d.ts +1 -1
  103. package/dist/testing/index.js +3 -3
  104. package/dist/testing/rn/index.cjs +1 -1
  105. package/dist/testing/rn/index.d.cts +14 -12
  106. package/dist/testing/rn/index.d.ts +14 -12
  107. package/dist/testing/rn/index.js +1 -1
  108. package/dist/testing/web/index.d.cts +9 -9
  109. package/dist/testing/web/index.d.ts +9 -9
  110. package/dist/{timelineRows-BuNhzDbH.d.cts → timelineRows-BNF43SXK.d.cts} +1 -1
  111. package/dist/{timelineRows-Dll2IGFg.d.ts → timelineRows-DXpjECfA.d.ts} +1 -1
  112. package/dist/{tokens-ARWZtMOU.d.cts → tokens-BYtbKwFh.d.cts} +6 -3
  113. package/dist/{tokens-ARWZtMOU.d.ts → tokens-BYtbKwFh.d.ts} +6 -3
  114. package/dist/{typeStyle-YCS8dt19.d.cts → typeStyle-BqfwxZH4.d.cts} +2 -2
  115. package/dist/{typeStyle-8iEqQmP_.d.ts → typeStyle-DKz02DGU.d.ts} +2 -2
  116. package/dist/{uploadTransport-C1p8FuG8.d.cts → uploadTransport-BM_pnEWj.d.cts} +5 -0
  117. package/dist/{uploadTransport-bZIKBTyK.d.ts → uploadTransport-C6kGP1Kd.d.ts} +5 -0
  118. package/dist/{useRecordsDepth-CNEHZJtj.d.cts → useRecordsDepth-CARTuHKh.d.cts} +1 -1
  119. package/dist/{useRecordsDepth-CuNdne6E.d.ts → useRecordsDepth-fPSv-GXU.d.ts} +1 -1
  120. package/dist/video/index.cjs +1 -1
  121. package/dist/video/index.js +1 -1
  122. package/dist/{view-BhqWlYrZ.d.cts → view-DGPaVno8.d.cts} +47 -5
  123. package/dist/{view-DFy8EDwf.d.ts → view-Dc-JlFkf.d.ts} +47 -5
  124. package/dist/web/consent/index.cjs +1 -1
  125. package/dist/web/consent/index.d.cts +5 -5
  126. package/dist/web/consent/index.d.ts +5 -5
  127. package/dist/web/consent/index.js +1 -1
  128. package/dist/web/index.cjs +7 -7
  129. package/dist/web/index.d.cts +23 -22
  130. package/dist/web/index.d.ts +23 -22
  131. package/dist/web/index.js +7 -7
  132. package/dist/web/notifications/index.d.cts +3 -3
  133. package/dist/web/notifications/index.d.ts +3 -3
  134. package/dist/web/records/depth/index.cjs +2 -2
  135. package/dist/web/records/depth/index.d.cts +7 -7
  136. package/dist/web/records/depth/index.d.ts +7 -7
  137. package/dist/web/records/depth/index.js +2 -2
  138. package/dist/web/records/index.cjs +3 -3
  139. package/dist/web/records/index.d.cts +28 -17
  140. package/dist/web/records/index.d.ts +28 -17
  141. package/dist/web/records/index.js +3 -3
  142. package/dist/web/televet/booking/index.cjs +4 -2
  143. package/dist/web/televet/booking/index.d.cts +228 -90
  144. package/dist/web/televet/booking/index.d.ts +228 -90
  145. package/dist/web/televet/booking/index.js +4 -2
  146. package/dist/web/televet/call/index.cjs +1 -1
  147. package/dist/web/televet/call/index.d.cts +1 -1
  148. package/dist/web/televet/call/index.d.ts +1 -1
  149. package/dist/web/televet/call/index.js +1 -1
  150. package/dist/web/televet/index.cjs +3 -3
  151. package/dist/web/televet/index.d.cts +2 -2
  152. package/dist/web/televet/index.d.ts +2 -2
  153. package/dist/web/televet/index.js +3 -3
  154. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import {createContext,forwardRef,useRef,useMemo,useState,useCallback,useEffect,useReducer,createElement,useContext,useSyncExternalStore,Component}from'react';import {z}from'zod';import {TextInput,View,Pressable,ScrollView,ActivityIndicator,StyleSheet,PanResponder,KeyboardAvoidingView,Image,BackHandler,Text,Modal,AccessibilityInfo,Linking,Share,Platform,RefreshControl}from'react-native';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var uu=Object.defineProperty;var i=(e,t)=>uu(e,"name",{value:t,configurable:true});var Jo=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(Jo.map(e=>e.wireCode));var pu=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"}),oa=Object.freeze(Jo.map(e=>Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:pu[e.wireCode]}))),mu=new Map(oa.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),yu=Object.freeze(["http_envelope",...[...new Set(oa.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function Mn(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let o of [t??"http_envelope",...yu]){let n=mu.get(o+r);if(n)return n}}i(Mn,"contractErrorFor");function fu(e){return e.envelope==="sse_frame"?`/errors#sse-${e.wireCode}`:e.envelope==="oauth_error"?`/errors#oauth-${e.wireCode}`:`/errors#${e.wireCode}`}i(fu,"contractDocUrl");function ia(e){return null}i(ia,"publishedDocUrl");var gu=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 sa(e){return gu[e]}i(sa,"categoryFor");function aa(e){let t=Mn(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),o=r.replace(/[^A-Z0-9]/g,"");if(o==="AUTHREJECTED")return "authRejected";if(r.startsWith("AUTH"))return "authExpired";switch(o){case "DAILYQUOTAEXCEEDED":case "QUOTAEXCEEDED":return "quotaExceeded";case "RATELIMITED":case "TOOMANYREQUESTS":case "TELEVETRATELIMITED":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(aa,"fromWire");var bu=new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function Zo(e){return bu.has(e)}i(Zo,"isAutoRetryable");var hu=new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function la(e){return Zo(e)||hu.has(e)}i(la,"isRetryableCode");var Ru=500,ei=8e3,ca=4;function da(e,t=Math.random){let r=Math.max(0,e),o=Math.min(Ru*2**r,ei);return Math.floor(t()*o)}i(da,"backoffDelayMs");var vu=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 ti(e){return vu[e]}i(ti,"userFacingError");function ua(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false});}i(ua,"defineHidden");var wu=/^[a-z][a-z0-9_]{0,63}$/;function N(e,t){let r=Mn(t?.wireCode,t?.wireEnvelope),o={code:e,category:sa(e),retryable:t?.retryable??la(e),displayMessage:ti(e)};if(t?.httpStatus!==void 0&&(o.httpStatus=t.httpStatus),t?.requestId&&(o.requestId=t.requestId),typeof t?.reasonCode=="string"&&wu.test(t.reasonCode)&&(o.reasonCode=t.reasonCode),r);return t?.wireMessage&&ua(o,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&ua(o,"raw",t.raw),Object.freeze(o)}i(N,"makeEverfurError");function Ie(e,t){return Object.freeze(t===void 0?{ok:true,value:e}:{ok:true,value:e,warning:t})}i(Ie,"ok");function W(e){return Object.freeze({ok:false,error:e})}i(W,"err");var Bn=class Bn extends Error{constructor(t,r){super(r),this.name="EverfurConfigError",this.kind=t,Object.setPrototypeOf(this,Bn.prototype);}};i(Bn,"EverfurConfigError");var cn=Bn;var ga=new Set(["requested","awaiting_clinic","awaiting_upload","received","parsing","in_review","published","failed","revoked"]),pa=Object.freeze({submitted:"requested",sent:"requested",dispatching:"requested",awaiting_response:"awaiting_clinic",clinic_responded_no_records:"awaiting_clinic",records_received:"received",parsing_failed:"in_review",review_email_failed:"in_review",clinic_declined:"failed"});function xu(e){let t=Object.prototype.hasOwnProperty.call(pa,e)?pa[e]:void 0;if(t!==void 0)return t;let r=e;return ga.has(r)?r:"parsing"}i(xu,"normalizeStatus");function ba(e){return e==="owner_reported"||e==="clinic_document"?e:null}i(ba,"normalizeOrigin");var Cu=z.object({request_id:z.string().min(1),pet_ref:z.string().min(1),status:z.string(),simple_status:z.string().nullish(),simple_status_detail:z.string().nullish(),status_label:z.string().optional(),dispatch_status:z.string().nullish(),can_retry_send:z.boolean().optional(),can_revoke:z.boolean().optional(),can_convert_to_upload:z.boolean().optional(),can_update_clinic_email:z.boolean().optional(),reminder_count:z.number().int().nonnegative().optional(),last_reminder_at:z.string().nullish(),waiting_expectation:z.string().nullish(),document_count:z.number().optional(),held_item_count:z.number().optional(),received_at:z.string().nullish(),parsing_started_at:z.string().nullish(),review_started_at:z.string().nullish(),created_at:z.string().optional(),updated_at:z.string().optional(),source:z.string().nullish().catch(null),action_needed_label:z.string().nullish().catch(null),failure_reason:z.string().nullish().catch(null),failure_code:z.string().nullish().catch(null),recovery_stage:z.string().nullish().catch(null),show_clinic_phone:z.boolean().optional().catch(void 0),clinic_name:z.string().nullish().catch(null),clinic_email:z.string().nullish().catch(null),clinic_phone:z.string().nullish().catch(null),converted_to_upload_at:z.string().nullish().catch(null),request_group_id:z.string().nullish().catch(null)}).passthrough();function gr(e){let t=Cu.safeParse(e);if(!t.success)return null;let r=t.data,o=Su(r.simple_status),n=o==="requested"&&(r.status==="awaiting_upload"||r.simple_status_detail==="awaiting_owner_upload")?"awaiting_upload":o==="parsing"&&(r.simple_status_detail==="in_review"||r.simple_status_detail==="review_email_failed")?"in_review":o??xu(r.status);return Object.freeze({id:r.request_id,petRef:r.pet_ref,status:n,simpleStatus:o,simpleStatusDetail:r.simple_status_detail??null,statusLabel:r.status_label??"",dispatchStatus:r.dispatch_status??null,canRetrySend:r.can_retry_send===true,canRevoke:r.can_revoke===true,canConvertToUpload:r.can_convert_to_upload===true,canUpdateClinicEmail:r.can_update_clinic_email===true,reminderCount:r.reminder_count??0,lastReminderAt:r.last_reminder_at??null,waitingExpectation:r.waiting_expectation??null,documentCount:ya(r.document_count,0),heldItemCount:ya(r.held_item_count,0),receivedAt:r.received_at??null,parsingStartedAt:r.parsing_started_at??null,reviewStartedAt:r.review_started_at??null,createdAt:r.created_at??"",updatedAt:r.updated_at??"",wireStatus:r.status,source:r.source??null,actionNeededLabel:r.action_needed_label??null,failureReason:r.failure_reason??null,failureCode:r.failure_code??null,recoveryStage:r.recovery_stage??null,showClinicPhone:r.show_clinic_phone===true,clinicName:r.clinic_name??null,clinicEmail:r.clinic_email??null,clinicPhone:r.clinic_phone??null,convertedToUploadAt:r.converted_to_upload_at??null,requestGroupId:r.request_group_id??null})}i(gr,"mapRequestView");var Eu=z.object({request_group_id:z.string().min(1),pet_ref:z.string().min(1),total:z.number().int().nonnegative(),responded:z.number().int().nonnegative(),pending:z.number().int().nonnegative(),members:z.array(z.unknown())});function ha(e){let t=Eu.safeParse(e);if(!t.success)return null;let r=t.data,o=ri(r.members);return o.some(n=>n.petRef!==r.pet_ref)?null:Object.freeze({requestGroupId:r.request_group_id,petRef:r.pet_ref,total:r.total,responded:r.responded,pending:r.pending,members:o})}i(ha,"mapRequestGroup");function Su(e){return !e||e==="awaiting_upload"||e==="in_review"?null:ga.has(e)?e:null}i(Su,"normalizeSimpleStatus");function ri(e){let t=Array.isArray(e)?e:[],r=[];for(let o of t){let n=gr(o);n!==null&&r.push(n);}return Object.freeze(r)}i(ri,"mapRequestList");var ku=z.object({source_doc_id:z.string().min(1),request_id:z.string().min(1)});function Ra(e){let t=ku.safeParse(e);return t.success?Object.freeze({documentId:t.data.source_doc_id,requestId:t.data.request_id,status:"received"}):null}i(Ra,"mapUploadedDocument");var Tu=z.object({label:z.string(),value:z.string()}),ni=z.object({key:z.string(),category:z.string().optional(),label:z.string().optional(),value:z.string().nullish(),unit:z.string().nullish(),observed_at:z.string().nullish(),status:z.string().nullish(),origin:z.string().nullish(),canonical_key:z.string().nullish()}),_u=z.object({at:z.string(),value:z.number().nullish(),display:z.string().nullish(),origin:z.string().nullish()}),Pu=z.object({key:z.string(),label:z.string().optional(),points:z.array(_u).optional()}),Iu=z.object({title:z.string(),detail:z.string().nullish(),due_at:z.string().nullish()}),oi=z.object({doc_id:z.string(),title:z.string().nullish(),page_count:z.number().nullish(),received_at:z.string().nullish()});function ii(e){return Object.freeze({key:e.key,category:e.category??"",label:e.label??e.key,value:e.value??null,unit:e.unit??null,observedAt:e.observed_at??null,status:e.status??null,origin:ba(e.origin),canonicalKey:e.canonical_key??null})}i(ii,"mapEntityRow");function si(e){return Object.freeze({docId:e.doc_id,title:e.title??null,pageCount:e.page_count??null,receivedAt:e.received_at??null})}i(si,"mapDocumentRow");var Du=z.object({identity:z.array(Tu).optional(),entities:z.array(ni).optional(),entity_series:z.array(Pu).optional(),forward_looking:z.array(Iu).optional(),documents:z.array(oi).optional()});function va(e,t){let r=Ou(t)?t:{},o=fa(r.schema_version,"epdf/1.0"),n=fa(r.disclaimer,""),a=typeof r.pet_ref=="string"&&r.pet_ref.length>0?r.pet_ref:e;if(r.withheld===true)return ma(a,o,n);let l=Du.safeParse(r);if(!l.success)return ma(a,o,n);let c=l.data,s=(c.identity??[]).map(R=>Object.freeze({label:R.label,value:R.value})),d=(c.entities??[]).map(ii),u=(c.entity_series??[]).map(R=>Object.freeze({key:R.key,label:R.label??R.key,points:Object.freeze((R.points??[]).map(v=>Object.freeze({at:v.at,value:v.value??null,display:v.display??null,origin:ba(v.origin)})))})),p=(c.forward_looking??[]).map(R=>Object.freeze({title:R.title,detail:R.detail??null,dueAt:R.due_at??null})),f={};for(let R of c.documents??[])f[R.doc_id]=si(R);let b=r.is_empty===true||s.length===0&&d.length===0&&u.length===0&&p.length===0&&Object.keys(f).length===0;return Object.freeze({petRef:a,schemaVersion:o,isEmpty:b,withheld:false,generatedAt:Lu(r.generated_at),identity:Object.freeze(s),entities:Object.freeze(d),entitySeries:Object.freeze(u),forwardLooking:Object.freeze(p),documents:Object.freeze(f),disclaimer:n})}i(va,"mapRecordView");function ma(e,t,r){return Object.freeze({petRef:e,schemaVersion:t,isEmpty:false,withheld:true,generatedAt:null,identity:Object.freeze([]),entities:Object.freeze([]),entitySeries:Object.freeze([]),forwardLooking:Object.freeze([]),documents:Object.freeze({}),disclaimer:r})}i(ma,"withheldView");var Au=z.object({pet_ref:z.string().optional(),granted:z.boolean().optional(),version:z.string().nullish(),granted_at:z.string().nullish()});function Hn(e,t){let r=Au.safeParse(t),o=r.success?r.data:{};return Object.freeze({petRef:typeof o.pet_ref=="string"&&o.pet_ref.length>0?o.pet_ref:e,granted:o.granted===true,version:o.version??null,grantedAt:o.granted_at??null})}i(Hn,"mapConsent");function Ou(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(Ou,"isObject");function ya(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}i(ya,"numberOr");function fa(e,t){return typeof e=="string"&&e.length>0?e:t}i(fa,"strOr");function Lu(e){return typeof e=="string"&&e.length>0?e:null}i(Lu,"strOrNull");var wa=Object.freeze(["published","failed","revoked"]);function br(e){return wa.includes(e)}i(br,"isTerminalStatus");function hr(e){if(e===null)return null;let t=e.recordsReason;return t==="consent_required"||t==="session_required"||t==="entitlement"||t==="pet_not_found"?t:null}i(hr,"recordsDenialReasonOf");var Vu="records_consent_required";function qu(e){let t=e.raw;if(t===null||typeof t!="object")return null;let r=t,o=typeof r.error=="object"&&r.error!==null?r.error.code:r.code;return typeof o=="string"&&o.length>0?o:null}i(qu,"recordsWireCodeOf");function ar(e){return e===null||e.httpStatus!==409?false:qu(e)===Vu}i(ar,"isRecordsConsentRequired");var zu=Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function Un(e){return e!==zu}i(Un,"isUploadTransportAvailable");var xa=Object.freeze({record(){}}),Rr=25*1024*1024,Ca=64,dn=128,bt=128,un="application/pdf",Ea=9e4;function ka(e){return new ai(e)}i(ka,"createRecordsController");var li=class li{constructor(t){this.recordCache=new Map;this.consentEpoch=new Map;this.reportedGaps=new Set;this.repository=t.repository,this.uploads=t.uploads,this.telemetry=t.telemetry??xa,this.newIdempotencyKey=t.newIdempotencyKey??Hu(),this.timers=t.timers??Mu,this.uploadDeadlineMs=t.uploadDeadlineMs??Ea;}async createUploadRequest(t){let r=await this.repository.createRequest({pet_ref:t.petRef,idempotency_key:t.idempotencyKey});if(!r.ok)return this.onRequestError(r.error);let o=gr(r.value);return o===null?W(jn()):(this.observeRequest(o),Ie(o))}async getRequest(t){let r=await this.repository.getRequest(t);if(!r.ok)return this.onRequestError(r.error);let o=gr(r.value);return o===null?W(jn()):(this.observeRequest(o),Ie(o))}async listRequests(){let t=await this.repository.listRequests();if(!t.ok)return this.onRequestError(t.error);let r=ri(t.value);for(let o of r)this.observeRequest(o);return Ie(r)}async uploadDocument(t){let{requestId:r,file:o}=t,n=Fu(o);if(n!==null)return this.telemetry.record("records.upload.rejected",{reason:n}),W(Sa(`upload rejected: ${n}`));let a=await this.repository.initiateUpload(r,{content_type:un,file_size:o.sizeBytes});if(!a.ok)return this.onRequestError(a.error);let l=await this.postToS3(a.value,o,t);if(!l.ok)return this.telemetry.record("records.upload.failed",{reason:l.reason}),W(Sa(l.reason));let c=await this.repository.completeUpload(r,{upload_id:a.value.upload_id});if(!c.ok)return c.error.code==="mediaUploadFailed"&&this.telemetry.record("records.upload.rejected",{reason:Nu(c.error)??"corrupt"}),this.onRequestError(c.error);let s=Ra(c.value);return s===null?W(jn()):Ie(s)}async postToS3(t,r,o){let n=new AbortController,a=Bu(n.signal,o.signal),l=this.timers.setTimeout(()=>n.abort(),this.uploadDeadlineMs);try{let c={signal:a};return o.onProgress&&(c.onProgress=o.onProgress),await this.uploads.postMultipart(t,r,c),{ok:!0}}catch{return {ok:false,reason:n.signal.aborted&&o.signal?.aborted!==true?"timeout":"upload_error"}}finally{this.timers.clearTimeout(l);}}async getRecord(t){let r=this.consentEpoch.get(t)??0,o=await this.repository.getRecord(t);if(r!==(this.consentEpoch.get(t)??0))return W(Object.freeze({...N("accessDenied",{retryable:false}),recordsReason:"consent_required"}));if(!o.ok){let a=hr(o.error);return a==="consent_required"?(this.recordCache.delete(t),this.telemetry.record("records.consent.denied",{pet_ref:t})):a==="entitlement"&&this.telemetry.record("records.capability.denied",{pet_ref:t}),W(o.error)}let n=va(t,o.value);return n.petRef!==t?W(jn()):n.withheld?(this.telemetry.record("records.redaction.withheld",{pet_ref:t}),this.recordCache.delete(t),Ie(n)):(this.recordCache.set(t,n),Ie(n))}peekCachedRecord(t){return this.recordCache.get(t)??null}async getConsent(t){let r=await this.repository.getConsent(t);return r.ok?Ie(Hn(t,r.value)):W(r.error)}async grantConsent(t){let r=await this.repository.putConsent(t.petRef,{consent_version:t.consentVersion,idempotency_key:t.idempotencyKey});return r.ok?Ie(Hn(t.petRef,r.value)):(hr(r.error)==="entitlement"&&this.telemetry.record("records.capability.denied",{pet_ref:t.petRef}),W(r.error))}async revokeConsent(t){let r=await this.repository.deleteConsent(t);return r.ok?(this.consentEpoch.set(t,(this.consentEpoch.get(t)??0)+1),this.recordCache.delete(t),Ie(Hn(t,r.value))):W(r.error)}reportCapabilityDenied(t){this.telemetry.record("records.capability.denied",t?{pet_ref:t}:{});}observeRequest(t){t.reviewStartedAt!==null&&!this.reportedGaps.has(t.id)&&(this.reportedGaps.add(t.id),this.telemetry.record("records.parse.gap",{request_id:t.id}));}onRequestError(t){return hr(t)==="entitlement"&&this.telemetry.record("records.capability.denied",{}),W(t)}};i(li,"RecordsControllerImpl");var ai=li;function Fu(e){if(e.mimeType!==un)return "unsupported_format";let t=e.sizeBytes;return typeof t!="number"||!Number.isFinite(t)||t<=0||t>Rr?"oversize":null}i(Fu,"validateFile");function Nu(e){let t=e.wireMessage;return t==="unsupported_format"||t==="oversize"||t==="corrupt"?t:null}i(Nu,"reasonFromWire");function Sa(e){return N("mediaUploadFailed",{retryable:false,wireMessage:e})}i(Sa,"uploadFailed");function jn(){return N("internalError",{retryable:true})}i(jn,"internal");var Mu={setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout")};function Bu(e,t){if(!t)return e;let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),r.signal;let o=i(()=>r.abort(),"onAbort");return e.addEventListener("abort",o,{once:true}),t.addEventListener("abort",o,{once:true}),r.signal}i(Bu,"mergeSignals");function Hu(){let e=0;return ()=>`records-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,10)}`}i(Hu,"defaultIdempotencyFactory");function vr(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}i(vr,"assertNever");function Ta(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(Ta,"errorFrame");function $u(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($u,"authHeaders");function pn(e,t){return {...e,headers:{...Wu(e.headers),...$u(t)}}}i(pn,"withAuthHeaders");function Wu(e){if(!e)return {};let t={};for(let[r,o]of Object.entries(e)){let n=r.toLowerCase();n==="authorization"||n==="x-everfur-partner-key"||(t[r]=o);}return t}i(Wu,"stripAuthHeaders");async function _a(e,t){if(t.mode==="anonymous")return t.transport.request(pn(e,{mode:"anonymous",publishableKey:t.publishableKey,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));let r;try{r=await t.identity.currentToken();}catch{return W(ci())}let o=await t.transport.request(pn(e,{mode:"personalized",token:r,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(o.ok||o.error.httpStatus!==401)return o;let n;try{n=await t.identity.currentToken({forceRefresh:!0});}catch{return W(ci())}let a=await t.transport.request(pn(e,{mode:"personalized",token:n,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return !a.ok&&a.error.httpStatus===401?W(ci(a.error.httpStatus)):a}i(_a,"authedSend");function ci(e){return N("authRejected",{retryable:false,...e!==void 0?{httpStatus:e}:{}})}i(ci,"authRejectedError");function Pa(e){return N("internalError",{retryable:true,wireMessage:Gu(e)})}i(Pa,"networkError");function Gu(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}i(Gu,"describeCause");var Yu=3e4,Ku=ei*2,Qu="idempotency-key",Xu=new Set(["POST","PUT","PATCH","DELETE"]),Ju=Object.freeze({onEvent(){}}),Zu=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function ep(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}i(ep,"seededIdempotencyKey");function wr(e){let t=e.observer??Ju,r=e.timers??Zu,o=e.rng??Math.random,n=e.sleep??((f,b)=>mp(f,r,b)),a=e.maxAttempts??ca,l=e.unaryTimeoutMs??Yu,c=e.newIdempotencyKey??lr(),s=i(f=>{try{t.onEvent(f);}catch{}},"emit");async function d(f,b,R){let v=R?.maxAttempts,w=Math.max(1,v??a),g=R?.idempotent??Xu.has(b.method),y=R?.idempotencyKey===void 0?null:ep(R.idempotencyKey),x=g?y??c():null,h=tp(b,x),P=0;for(;;){let S=i($=>Object.freeze({call:f,method:b.method,path:b.path,attempt:P,...x?{idempotencyKey:x}:{},...$}),"stamp");s(S({phase:"attempt"}));let E=up(l,r),C=pp(E.signal,b.signal),I;try{I=await _a({...h,signal:C.signal},e.auth);}catch($){I=W(Pa($));}finally{C.dispose(),E.cancel();}if(I.ok)return s(S({phase:"settled",ok:true,reason:"ok"})),I;let F=I.error,q=np(F,P,{maxAttempts:w,rng:o,now:r.now(),aborted:b.signal?.aborted===true,...v!==void 0?{perCallMaxAttempts:v}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),j={ok:false,code:F.code,reason:q.reason,...F.httpStatus!==void 0?{httpStatus:F.httpStatus}:{},...F.requestId!==void 0?{requestId:F.requestId}:{}};if(!q.retry)return s(S({phase:"settled",...j})),W(F);if(s(S({phase:"retry",...j,delayMs:q.delayMs})),await n(q.delayMs,b.signal),b.signal?.aborted===true)return s(S({phase:"settled",...j,reason:"aborted"})),W(F);P+=1;}}i(d,"send");async function u(f){return pn(f,await dp(e.auth))}i(u,"authorize");async function*p(f,b,R){s(Object.freeze({call:f,phase:"stream.open",method:b.method,path:b.path,attempt:0}));try{yield*e.auth.transport.stream(b,R);}catch{yield Ta({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:null});}}return i(p,"stream"),Object.freeze({send:d,authorize:u,stream:p})}i(wr,"createRequestFunnel");function tp(e,t){let r={};for(let[o,n]of Object.entries(e.headers??{}))o.toLowerCase()!==Qu&&(r[o]=n);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}i(tp,"assembleHeaders");function lr(){let e=0;return ()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}i(lr,"defaultIdempotencyKeyFactory");var rp=10;function np(e,t,r){if(r.aborted)return {retry:false,reason:"aborted"};let o=op(e);if(o==="quota")return {retry:false,reason:"daily-quota-exhausted"};if(o!=="burst"&&!Zo(e.code))return {retry:false,reason:"terminal-code"};let n=o==="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 l=i(()=>{if(r.policy===void 0)return null;let d;try{d=r.policy.maxAttempts(e.code);}catch{return null}return typeof d!="number"||!Number.isFinite(d)?null:Math.max(1,Math.min(rp,Math.floor(d)))},"policyCeiling"),c=r.perCallMaxAttempts??l()??r.maxAttempts;if(t+1>=c)return {retry:false,reason:"attempts-exhausted"};let s=ip(e,r.now);return s!==null?s>Ku?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:n,delayMs:s}:{retry:true,reason:n,delayMs:da(t,r.rng)}}i(np,"decideRetry");function op(e){let t=e.code==="unknown"?aa(cp(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}i(op,"throttleKind");function ip(e,t){let r=ap(e.raw);if(r!==null){let n=r-t;return n>0?n:0}let o=sp(e.raw);return o===null?null:Math.round(o*1e3)}i(ip,"retryOverrideMs");function sp(e){for(let t of di(e)){let r=t.retry_after_seconds;if(typeof r=="number"&&Number.isFinite(r)&&r>=0)return r}return null}i(sp,"findRetryAfterSeconds");function ap(e){for(let t of di(e)){let r=t.resets_at,o=lp(r);if(o!==null)return o}return null}i(ap,"findResetsAt");function di(e){if(!Ia(e))return [];let t=[e];for(let r of ["error","detail"]){let o=e[r];Ia(o)&&t.push(o);}return t}i(di,"candidateScopes");function lp(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(lp,"parseInstantMs");function cp(e){for(let t of di(e)){let r=t.code;if(typeof r=="string"&&r.length>0)return r}return null}i(cp,"rawWireCode");function Ia(e){return typeof e=="object"&&e!==null}i(Ia,"isRecord");async function dp(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(dp,"resolveDeviceAuth");function up(e,t){let r=new AbortController,o=t.setTimeout(()=>r.abort(),e);return {signal:r.signal,cancel:i(()=>t.clearTimeout(o),"cancel")}}i(up,"boundedSignal");function pp(e,t){let r=i(()=>{},"noop");if(!t)return {signal:e,dispose:r};let o=new AbortController;if(e.aborted||t.aborted)return o.abort(),{signal:o.signal,dispose:r};let n=i(()=>o.abort(),"onAbort");return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),{signal:o.signal,dispose:i(()=>{e.removeEventListener("abort",n),t.removeEventListener("abort",n);},"dispose")}}i(pp,"mergeSignals");function mp(e,t,r){return e<=0||r?.aborted===true?Promise.resolve():new Promise(o=>{let n=t.setTimeout(()=>{r?.removeEventListener("abort",a),o();},e),a=i(()=>{t.clearTimeout(n),o();},"onAbort");r?.addEventListener("abort",a,{once:true});})}i(mp,"delayAbortable");function xr(e){for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let o=e.charCodeAt(t+1);if(!(o>=56320&&o<=57343))return true;t+=1;}else if(r>=56320&&r<=57343)return true}return false}i(xr,"hasLoneSurrogate");var cr="/widget/v1/records";function Aa(e){let{auth:t}=e,r=t.mode,o=e.funnel??wr({auth:t,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),n=i(async(s,d,u)=>{let p=await o.send(s,d);return p.ok?p:W(gp(p.error,r,u))},"send"),a=i((s,d)=>typeof d!="string"||d.length===0?N("validationFailed",{retryable:false,wireMessage:`${s} is required and must be a non-empty string`}):xr(d)?N("validationFailed",{retryable:false,wireMessage:`${s} contains an unpaired surrogate and cannot be encoded`}):null,"segmentError"),l=i((s,d,u)=>{let p=a(s,d);if(p!==null)return p;let b=[...d].length;return b>u?N("validationFailed",{retryable:false,wireMessage:`${s} is ${b} characters; the server accepts at most ${u}`}):null},"boundsError"),c=i((...s)=>s.find(d=>d!==null)??null,"firstError");return {createRequest:i(s=>{let d=c(l("idempotency_key",s.idempotency_key,dn),l("pet_ref",s.pet_ref,bt));return d?Promise.resolve(W(d)):n("records.createRequest",ui(`${cr}/requests`,s),"request")},"createRequest"),initiateUpload:i((s,d)=>{let u=a("request_id",s);return u?Promise.resolve(W(u)):n("records.initiateUpload",ui(`${cr}/requests/${encodeURIComponent(s)}/uploads/initiate`,d),"request")},"initiateUpload"),completeUpload:i((s,d)=>{let u=a("request_id",s);return u?Promise.resolve(W(u)):n("records.completeUpload",ui(`${cr}/requests/${encodeURIComponent(s)}/uploads/complete`,d),"request")},"completeUpload"),getRequest:i(s=>{let d=a("request_id",s);return d?Promise.resolve(W(d)):n("records.getRequest",$n(`${cr}/requests/${encodeURIComponent(s)}`),"request")},"getRequest"),listRequests:i(async()=>{let s=await n("records.listRequests",$n(`${cr}/requests`),"request");if(!s.ok)return s;let d=s.value;return {ok:true,value:Array.isArray(d)?d:d.items??[]}},"listRequests"),getRecord:i(s=>{let d=l("pet_ref",s,bt);return d?Promise.resolve(W(d)):n("records.getRecord",$n(`${cr}/pets/${encodeURIComponent(s)}/record`),"content")},"getRecord"),getConsent:i(s=>{let d=l("pet_ref",s,bt);return d?Promise.resolve(W(d)):n("records.getConsent",$n(`${cr}/pets/${encodeURIComponent(s)}/consent`),"consent")},"getConsent"),putConsent:i((s,d)=>{let u=c(l("consent_version",d.consent_version,Ca),l("idempotency_key",d.idempotency_key,dn),l("pet_ref",s,bt));return u?Promise.resolve(W(u)):n("records.putConsent",bp(`${cr}/pets/${encodeURIComponent(s)}/consent`,d),"consent")},"putConsent"),deleteConsent:i(s=>{let d=l("pet_ref",s,bt);return d?Promise.resolve(W(d)):n("records.deleteConsent",hp(`${cr}/pets/${encodeURIComponent(s)}/consent`),"consent")},"deleteConsent")}}i(Aa,"createHttpRecordsRepository");function Da(e,t){let r={...e,recordsReason:t};for(let o of ["wireMessage","raw"]){let n=Object.getOwnPropertyDescriptor(e,o);n!==void 0&&Object.defineProperty(r,o,n);}return Object.freeze(r)}i(Da,"withReason");var yp="pet_not_registered";function fp(e){return e.httpStatus!==404?null:e.reasonCode===yp?"pet_not_found":"entitlement"}i(fp,"recordsErrorReasonFor");function gp(e,t,r){let o=fp(e);return o!==null?Da(e,o):e.code!=="accessDenied"?e:Da(e,t==="anonymous"?"session_required":r==="content"?"consent_required":"entitlement")}i(gp,"tagReason");function $n(e){return {method:"GET",path:e}}i($n,"get");function ui(e,t){return {method:"POST",path:e,body:t}}i(ui,"post");function bp(e,t){return {method:"PUT",path:e,body:t}}i(bp,"put");function hp(e){return {method:"DELETE",path:e}}i(hp,"del");var Oa=Symbol.for("@everfur/sdk#EverfurContext@v1"),La=globalThis,Va=La[Oa]??(La[Oa]=createContext(null));Va.displayName??="EverfurContext";function Te(){let e=useContext(Va);if(e===null)throw new cn("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}i(Te,"useEverfurContext");var pi=new Map,mi=new Set;function qa(e){pi.set(e,(pi.get(e)??0)+1);for(let t of [...mi])t();}i(qa,"notifyRecordsConsentWithdrawn");function Cp(e){return pi.get(e)??0}i(Cp,"recordsConsentEpochOf");function Ep(e){return mi.add(e),()=>{mi.delete(e);}}i(Ep,"subscribe");function Wn(e){let t=useCallback(()=>Cp(e),[e]);return useSyncExternalStore(Ep,t,t)}i(Wn,"useRecordsConsentEpoch");var fi={record:null,requests:[],consent:null,error:null,denialReason:null,withheld:false,loading:true,isUploading:false,uploadProgress:null,uploadQueue:[]},Fa=4e3,kp=30;function st(e){let{petRef:t}=e,r=useRef(e.uploadTransport);r.current=e.uploadTransport;let o=e.uploadTransport!==void 0,{runtime:n,userRef:a,scopeEpoch:l}=Te(),c=useMemo(()=>({}),[n,a,t,l,e.controller]),s=useRef(c),[d,u]=useState({scope:c,controller:e.controller??null}),p=e.controller??(d.scope===c?d.controller:null),[f,b]=useState({scope:c,value:fi}),R=f.scope===c?f.value:fi,v=useCallback(T=>{b(D=>D.scope===c?{scope:c,value:T(D.value)}:D);},[c]),w=useRef(0);useEffect(()=>(s.current=c,b({scope:c,value:fi}),()=>{s.current=null,w.current+=1;}),[c]),useEffect(()=>{if(e.controller)return;let{services:T}=n.registry,D={record:i((B,H)=>T.telemetry.track(B,H),"record")},L=n.registry.acquire("records",`${a??""}|${t}${o?"|own-upload":""}`,()=>ka({repository:Aa({auth:T.authFor(a),...T.errorPolicy?{errorPolicy:T.errorPolicy}:{}}),uploads:o?{postMultipart:i((B,H,O)=>(r.current??T.uploadTransport).postMultipart(B,H,O),"postMultipart")}:T.uploadTransport,telemetry:D}),()=>{});return u({scope:c,controller:L}),()=>{n.registry.release(L);}},[n,a,t,e.controller,l,c,o]);let g=useCallback(T=>{v(D=>({...D,...T}));},[v]),y=useCallback(async()=>{if(!p||s.current!==c)return;let T=w.current+=1;S.current=0,I(),g({loading:true,error:null,denialReason:null,withheld:false});let[D,L]=await Promise.all([p.getConsent(t),p.listRequests()]);if(T!==w.current)return;let B=D.ok?D.value:null,H=L.ok?L.value.filter(se=>se.petRef===t):[],O=L.ok?null:L.error;if(B&&B.granted){let se=await p.getRecord(t);if(T!==w.current)return;if(se.ok){g({consent:B,requests:H,record:se.value,withheld:se.value.withheld,error:se.value.withheld?Ip():O,denialReason:null,loading:false});return}g({consent:B,requests:H,record:null,error:se.error,denialReason:hr(se.error),withheld:false,loading:false});return}g({consent:B,requests:H,record:null,error:D.ok?O:D.error,denialReason:B?"consent_required":Pp(D),withheld:false,loading:false});},[p,t,g,c]);useEffect(()=>(y(),()=>{w.current+=1;}),[y]);let x=useMemo(()=>_p(R.requests),[R.requests]),h=x?.id??null,P=x?.status??null,S=useRef(0),E=useRef(null),[C,I]=useReducer(T=>T+1,0);useEffect(()=>{if(!p||h===null||P===null||br(P)||P==="in_review")return;E.current!==String(h)&&(E.current=String(h),S.current=0);let T=false,D=i(async()=>{if(T||S.current>=kp)return;S.current+=1;let B=await p.getRequest(h);if(!T){if(B.ok&&B.value.petRef===t){if(v(H=>({...H,requests:Yn(H.requests,B.value)})),br(B.value.status)){B.value.status==="published"&&y();return}if(B.value.status==="in_review")return}L=setTimeout(()=>{D();},Fa);}},"tick"),L=setTimeout(()=>{D();},Fa);return ()=>{T=true,clearTimeout(L);}},[p,h,P,y,C,t,v]);let F=useCallback(async T=>{if(!p||s.current!==c)return Kn();let D=await p.createUploadRequest({petRef:t,idempotencyKey:T});return s.current===c&&D.ok&&D.value.petRef===t&&v(L=>({...L,requests:Yn(L.requests,D.value)})),D},[p,t,c,v]),q=useCallback((T,D)=>{v(L=>({...L,uploadQueue:L.uploadQueue.map(B=>B.key===T?D(B):B)}));},[v]),j=useCallback(async(T,D)=>{let L=Date.now().toString(36),B=D.map((O,se)=>{let re=Na(O);return {key:`${L}-${se}`,name:O.name??null,status:re===null?"queued":"skipped",progress:0,skipReason:re,error:null}}),H=[...B];if(!p||s.current!==c)return Object.freeze(H);v(O=>({...O,uploadQueue:B,isUploading:true,uploadProgress:0}));for(let[O,se]of D.entries()){let re=B[O];if(re.status==="skipped")continue;if(s.current!==c)break;q(re.key,rt=>({...rt,status:"uploading",progress:0})),g({uploadProgress:0});let Ee=await p.uploadDocument({requestId:T,file:se,onProgress:i(rt=>{if(s.current!==c)return;let Nt=Math.min(1,Math.max(0,rt));q(re.key,Mt=>({...Mt,progress:Math.max(Mt.progress,Nt)})),g({uploadProgress:Nt});},"onProgress")});if(s.current!==c)break;let Ct=Ee.ok?{...re,status:"done",progress:1}:{...re,status:"failed",error:Ee.error};if(H[O]=Ct,q(re.key,()=>Ct),Ee.ok){let rt=await p.getRequest(T);s.current===c&&rt.ok&&rt.value.petRef===t&&v(Nt=>({...Nt,requests:Yn(Nt.requests,rt.value)}));}}return s.current===c&&g({isUploading:false,uploadProgress:null}),Object.freeze(H)},[p,g,q,t,c,v]),$=useCallback(async(T,D)=>{if(!p||s.current!==c)return Kn();let L=`${Date.now().toString(36)}-0`;v(H=>({...H,isUploading:true,uploadProgress:0,uploadQueue:[{key:L,name:D.name??null,status:"uploading",progress:0,skipReason:null,error:null}]}));let B=await p.uploadDocument({requestId:T,file:D,onProgress:i(H=>{s.current===c&&(g({uploadProgress:H}),q(L,O=>({...O,progress:Math.max(O.progress,Math.min(1,H))})));},"onProgress")});if(s.current!==c)return B;if(g({isUploading:false,uploadProgress:null}),q(L,H=>B.ok?{...H,status:"done",progress:1}:{...H,status:"failed",error:B.error}),B.ok){let H=await p.getRequest(T);s.current===c&&H.ok&&H.value.petRef===t&&v(O=>({...O,requests:Yn(O.requests,H.value)}));}return B},[p,g,q,t,c,v]),ce=useCallback(async(T,D)=>{if(!p||s.current!==c)return Kn();let L=await p.grantConsent({petRef:t,consentVersion:T,idempotencyKey:D});return L.ok&&s.current===c&&y(),L},[p,t,y,c]),oe=useCallback(async()=>{if(!p||s.current!==c)return Kn();let T=await p.revokeConsent(t);return T.ok&&qa(t),T.ok&&s.current===c&&(w.current+=1,g({record:null,withheld:false,loading:false,denialReason:"consent_required",consent:T.value})),T},[p,t,g,c]),ve=useCallback(()=>y(),[y]),ie=Tp(R,p!==null);return useMemo(()=>({status:ie,record:R.record,requests:R.requests,activeRequest:x,consent:R.consent,error:R.error,denialReason:R.denialReason,withheld:R.withheld,isUploading:R.isUploading,uploadProgress:R.uploadProgress,uploadQueue:R.uploadQueue,createRequest:F,uploadDocument:$,uploadDocuments:j,grantConsent:ce,revokeConsent:oe,refresh:ve}),[ie,R,x,F,$,j,ce,oe,ve])}i(st,"useEverfurRecords");function Na(e){if(e.mimeType!==un)return "unsupported";let t=e.sizeBytes;return typeof t!="number"||!Number.isFinite(t)||t<=0||t>Rr?"too_large":null}i(Na,"skipReasonFor");function Ma(e){let t=[],r=[];for(let o of e){let n=Na(o);n===null?t.push(o):r.push({name:o.name??null,reason:n});}return {uploadable:t,skipped:r}}i(Ma,"classifyPick");function Tp(e,t){return e.loading||!t?"loading":e.withheld||e.denialReason!==null||e.error!==null?"error":e.record!==null&&!e.record.isEmpty||e.requests.length>0?"populated":"empty"}i(Tp,"selectStatus");function _p(e){if(e.length===0)return null;let t=e[0];for(let r of e)r.updatedAt>t.updatedAt&&(t=r);return t}i(_p,"newestRequest");function Yn(e,t){let r=e.filter(o=>o.id!==t.id);return [t,...r]}i(Yn,"replaceRequest");function Pp(e){return e.ok?"consent_required":hr(e.error)??"consent_required"}i(Pp,"consentDenial");function Ip(){return N("internalError",{retryable:false})}i(Ip,"withheldSentinel");function Kn(){return {ok:false,error:N("internalError",{retryable:true})}}i(Kn,"notReady");function gi(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e);}catch{}}i(gi,"reportHostFailure");function Dp(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(Dp,"isThenable");function Qn(e,...t){if(typeof e=="function")try{let r=e(...t);return Dp(r)&&Promise.resolve(r).then(void 0,gi),r}catch(r){gi(r);return}}i(Qn,"callHost");var Ba=new WeakMap;function yn(e){if(typeof e!="function")return;let t=Ba.get(e);if(t!==void 0)return t;let r=i((...o)=>{Qn(e,...o);},"guarded");return Ba.set(e,r),r}i(yn,"guardHost");function Le(e,t){let r=null;for(let o of t){let n=e[o];typeof n=="function"&&(r??={...e},r[o]=yn(n));}return r??e}i(Le,"guardHostProps");function Lr(e,...t){let r;try{r=e(...t);}catch(o){return gi(o),Promise.resolve({ok:false,error:o})}return Promise.resolve(r).then(o=>({ok:true,value:o}),o=>({ok:false,error:o}))}i(Lr,"callHostAsync");var Ha=Object.freeze({name:"dashboard"});function Xn(e=Ha){return Object.freeze({stack:Object.freeze([e])})}i(Xn,"initialRecordsNav");function Jn(e){return e.stack[e.stack.length-1]??Ha}i(Jn,"currentRecordsScreen");function bi(e,t){return Object.freeze({stack:Object.freeze([...e.stack,t])})}i(bi,"pushRecordsNav");function hi(e,t){return Object.freeze({stack:Object.freeze([...e.stack.slice(0,-1),t])})}i(hi,"replaceRecordsNav");function Ri(e){return Xn(e)}i(Ri,"resetRecordsNav");function Zn(e){return e.stack.length<=1?{state:e,handled:false}:{state:Object.freeze({stack:Object.freeze(e.stack.slice(0,-1))}),handled:true}}i(Zn,"popRecordsNav");function Ua(e,t){return t.name==="dashboard"?Ri(t):Jn(e).name==="upload"&&t.name==="request"?hi(e,t):bi(e,t)}i(Ua,"transitionRecordsNav");function vi(e,t){switch(t.type){case "push":return bi(e,t.screen);case "pop":return Zn(e).state;case "replace":return hi(e,t.screen);case "reset":return Ri(t.screen);case "navigate":return Ua(e,t.screen);default:return e}}i(vi,"recordsNavReducer");function Ci(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.keys(e))Ci(e[t]);}return e}i(Ci,"deepFreeze");var Ap=Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3}),$a={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},Wa={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},ja={nano:8,small:9,micro:10,tiny:11,caption:12,bodyTight:13,body:14,subtitle:16,heading:18,verdict:24},Op={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},Lp={regular:"400",medium:"500",bold:"700"},Vp={eyebrow:1,monoWide:.9,headerBrand:-0.42,tight:-0.35},qp=0,eo="System",to="monospace",zp=["content","heading","control","compact","badge"];function Fp(e){let t={};for(let r of zp)t[r]=e;return t}i(Fp,"authoredTierSizes");function Ga(){return {family:eo,mono:to,fontUrl:null,families:{regular:eo,medium:eo,bold:eo,mono:to,monoMedium:to,monoBold:to},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:ja,tierSizes:Fp(ja),lineHeight:Op,weight:Lp,letterSpacing:Vp,scale:1,maxScale:qp,scaleCaps:Ap}}i(Ga,"baseType");var Ya={},wi=Object.freeze({standard:Object.freeze([.2,0,0,1]),emphasized:Object.freeze([.2,.8,.2,1]),exit:Object.freeze([.4,0,1,1])});function xi(e){return `cubic-bezier(${e.join(", ")})`}i(xi,"cssCubicBezier");var Ka={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:xi(wi.standard),emphasized:xi(wi.emphasized),exit:xi(wi.exit)},reducedMotion:false},Np={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",onDanger:"#FFFFFF",errorRed:"#CC1600",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",bubbleVet:"#FFC3BC",onBubbleVet:"#111111",skeleton:"#EFE9E3",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)"},Qa=Ci({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:Np,space:$a,radius:Wa,type:Ga(),motion:Ka,slots:Ya}),Mp={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",onDanger:"#0E1F17",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",bubbleVet:"#FFC3BC",onBubbleVet:"#111111",skeleton:"#23272C",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)"};Ci({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:Mp,space:$a,radius:Wa,type:Ga(),motion:Ka,slots:Ya});var Xa=Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),Ja=globalThis,Ei=Ja[Xa]??(Ja[Xa]=createContext(Qa));Ei.displayName??="EverfurThemeContext";function V(){return useContext(Ei)}i(V,"useEverfurTheme");function Wp(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}i(Wp,"tierMultiplier");function m({tier:e="content",...t}){let{type:r}=V(),o=Wp(r,e);return createElement(Text,o===void 0?t:{maxFontSizeMultiplier:o,...t})}i(m,"Text");var He=forwardRef(i(function(t,r){return createElement(TextInput,{...t,...r===null?{}:{ref:r}})},"TextInput"));var Gp=Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function k(e,t){let r=e.type,o=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:o}:{fontFamily:o,fontWeight:r.weight[Gp[t]]}}i(k,"face");var K=Object.freeze({title:"Request records",clinic:"Clinic",search:"Search clinics by name or location",placeholder:"Clinic name, city, or ZIP",email:"Clinic email",emailPlaceholder:"records@clinic.com",ownerName:"Your full name",scopeHeading:"What you\u2019re authorizing",send:"Send request",sending:"Sending\u2026",cancel:"Cancel",sign:"Signature",draw:"Draw your signature",type:"Type your name to sign",toType:"Can\u2019t draw? Type your name instead",toDraw:"Draw your signature instead",clear:"Clear",drawHint:"Draw your signature in the box above.",clearA11y:"Clear signature",typedSignatureA11y:i(e=>`Typed signature: ${e}`,"typedSignatureA11y"),missingSignature:"Please add your signature before submitting.",recentlyUsed:"Recently used"});var Ce=Object.freeze({title:K.title,placeholder:K.placeholder,searchA11y:K.search,clearSearch:"Clear search",loading:"Loading clinics",uploadOwn:"I already have the records",uploadOwnStarting:"Setting up your upload\u2026",uploadOwnA11y:"Upload records you already have",noPet:"Add a pet first, then come back to request their records.",recentlyUsed:K.recentlyUsed,noMatch:i(e=>`No clinics match \u201C${e}\u201D. You can still request records using the option above.`,"noMatch"),loadingMore:"Loading more\u2026",loadMoreFailed:"Couldn\u2019t load more. Tap to retry.",loadMoreRetryA11y:"Retry loading more clinics",selectA11y:i(e=>`Request records from ${e}`,"selectA11y"),fallback:Object.freeze({title:"Can\u2019t find your clinic?",subtitle:"Add it by email and we\u2019ll request your records.",expandA11y:"Can't find your clinic? Add it by email to request records.",collapseA11y:"Hide the request-by-email form",nameLabel:"Clinic name",namePlaceholder:"Your clinic\u2019s name",emailLabel:"Clinic email",emailPlaceholder:"records@clinic.com",reviewNote:"We review every request by hand before reaching out to the clinic.",submit:"Continue",submitA11y:"Request records by email"})});function el(e){switch(e){case "verified":return {label:"Email on file",a11y:"verified email on file, we can request records directly",tone:"positive"};case "unverified":return {label:"Email unconfirmed",a11y:"email on file but unconfirmed, we will try and let you know",tone:"caution"};default:return {label:"We may need your help",a11y:"no email on file, we may ask you to confirm how to reach this clinic",tone:"neutral"}}}i(el,"clinicEmailStatusBadge");function tl(e){return e===null||!Number.isFinite(e)?"":`${e.toFixed(1)} km`}i(tl,"formatClinicDistanceLabel");function rl(e){return e===null||!Number.isFinite(e)?"":`${e.toFixed(1)} ${e===1?"kilometer":"kilometers"} away`}i(rl,"formatClinicDistanceForA11y");var nl=300,Si=2;var ye=Object.freeze({loading:"Loading",empty:"No records yet",upload:"Upload records",consentRequired:"Consent required",allow:"Allow",sessionRequired:"Sign in required",recordUnavailable:"Record unavailable",retry:"Try again",records:"Records",beingReviewed:"being reviewed"});function ol(e){return !br(e.status)}i(ol,"isRecordsInProgress");function ro(e,t){if(t===null)return null;let r=e.filter(a=>a.petRef===t);if(r.length===0)return null;let o=r.find(a=>a.status==="published");return o!==void 0?o:r.filter(ol).sort((a,l)=>l.updatedAt.localeCompare(a.updatedAt))[0]??null}i(ro,"pickPetRecordsRequest");function ki(e){if(e.hasMarkers)return "published";let t=ro(e.requests,e.petRef);return t===null?"none":t.status==="published"||ol(t)?"in_progress":"none"}i(ki,"deriveRecordsDashboardState");function Yp(e){return e.recordLoading?true:e.hasFullRecord?false:e.markersLoading||!e.hasMarkers&&e.requestsLoading}i(Yp,"selectDashboardLoading");function Ti(e){return Yp(e)?"loading":e.hasFullRecord?"record":e.markersError||e.recordError&&!e.hasMarkers?"error":e.dashboardState==="in_progress"&&e.drivingRequest!==null?"in_progress":e.dashboardState==="none"?"none":"labs_only"}i(Ti,"selectDashboardView");function mt(e){return e?.httpStatus===429?"rate_limited":e?.httpStatus===502?"service_unavailable":"error"}i(mt,"recordsEmptyVariantForError");var he=Object.freeze({loading:"Loading record request",timelineA11y:"Request timeline",awaitingNote:"Clinics usually reply within a week. We follow up automatically and will let you know if there\u2019s no reply by day 14.",waitingBanner:i(e=>`It\u2019s been ${e} ${e===1?"day":"days"}. Some clinics take a little longer; we\u2019ve been following up automatically and are still on it. If there\u2019s no reply by day 14, we\u2019ll let you know.`,"waitingBanner"),viewRecords:"View health records",nextStep:"You can try a different clinic or upload records you already have.",tryAnotherClinic:"Request from a different clinic",tryAnotherClinicA11y:"Request records from a different clinic",convert:"Upload my own records instead",converting:"Switching\u2026",convertHint:"We\u2019ll stop waiting on the clinic so you can add the records you already have. If the clinic does reply, we\u2019ll still add their records too.",freshUpload:"Upload your own records",freshUploadStarting:"Starting\u2026",cancel:"Cancel request",cancelling:"Cancelling\u2026",cancelA11y:"Cancel this records request",cancellingA11y:"Cancelling, please wait",resend:"Resend email",resending:"Resending\u2026",resendA11y:"Resend the authorization email to the clinic",resendingA11y:"Resending the email, please wait",errors:Object.freeze({cancel:"We couldn\u2019t cancel this request. Please try again.",retry:"We couldn\u2019t retry this request. Please try again.",email:"We couldn\u2019t update the clinic email. Please try again.",convert:"We couldn\u2019t switch this to an upload. Please try again.",start:"We couldn\u2019t start that. Please try again.",invalidEmail:"Enter a valid clinic email."})});function Kp(e){if(e.wireStatus==="clinic_declined")return "The clinic declined to release the records.";if(e.wireStatus==="clinic_responded_no_records")return "The clinic replied but didn\u2019t include your records.";switch(e.failureCode){case "no_response":return "The clinic didn\u2019t reply after several reminders over 14 days.";case "parse_timeout":case "parse_error":return "We received the records but couldn\u2019t read them. Uploading a clean copy usually fixes this.";case "hard_bounce":case "dispatch_failed":return "We couldn\u2019t deliver the email to the clinic.";default:return "This request didn\u2019t go through."}}i(Kp,"fallbackFailureTitle");function il(e){let t=e.failureReason?.trim()??"";return t.length>0?t:Kp(e)}i(il,"failureTitle");var Qp=1440*60*1e3;function _i(e,t){if(!e.createdAt)return 0;let r=Date.parse(e.createdAt);if(Number.isNaN(r))return 0;let o=t-r;return o<=0?0:Math.floor(o/Qp)}i(_i,"requestElapsedDays");var Xp=7;function sl(e,t){return e.wireStatus!=="awaiting_response"?false:_i(e,t)>=Xp}i(sl,"requestWaitingTooLong");function Pi(e){return e.status==="failed"}i(Pi,"isTerminalFailure");function al(e){return Pi(e)||e.canUpdateClinicEmail===true||e.canRetrySend===true}i(al,"shouldOfferRecovery");function dl(e,t){let[r,o]=useState(""),[n,a]=useState(""),[l,c]=useState([]),[s,d]=useState(null),[u,p]=useState([]),[f,b]=useState(true),[R,v]=useState(false),[w,g]=useState(false),[y,x]=useState(null),[h,P]=useState(null),[S,E]=useState(0),C=useRef(0),I=useRef(true),F=t?.latitude,q=t?.longitude,j=useMemo(()=>F!==void 0&&q!==void 0?{latitude:F,longitude:q}:void 0,[F,q]);useEffect(()=>(I.current=true,()=>{I.current=false,C.current+=1;}),[e]),useEffect(()=>{let ie=true;return b(true),e.recentClinics({limit:5}).then(T=>{ie&&(T.ok&&p(T.value.clinics),b(false));}).catch(()=>{ie&&b(false);}),()=>{ie=false;}},[e]),useEffect(()=>{let ie=r.trim();if(ie.length<Si){a("");return}let T=setTimeout(()=>a(ie),nl);return ()=>clearTimeout(T)},[r]);let $=n.length>=Si;useEffect(()=>{let ie=C.current+=1;if(c([]),d(null),x(null),P(null),!$){v(false);return}v(true),e.searchClinics({query:n,limit:25,...j?{location:j}:{}}).then(T=>{!I.current||ie!==C.current||(T.ok?(c(T.value.clinics),d(T.value.nextCursor)):x(T.error),v(false));}).catch(()=>{I.current&&ie===C.current&&v(false);});},[e,n,$,j,S]);let ce=useCallback(()=>{if(!$||s===null||w)return;let ie=C.current;g(true),P(null),e.searchClinics({query:n,limit:25,cursor:s,...j?{location:j}:{}}).then(T=>{!I.current||ie!==C.current||(T.ok?(c(D=>[...D,...T.value.clinics]),d(T.value.nextCursor)):P(T.error),g(false));}).catch(()=>{I.current&&ie===C.current&&g(false);});},[e,s,n,$,w,j]),oe=useCallback(ie=>o(ie),[]),ve=useCallback(()=>E(ie=>ie+1),[]);return useMemo(()=>({query:r,debouncedQuery:n,isSearchActive:$,clinics:l,recent:u,recentLoading:f,initialLoading:R,loadingMore:w,hasNextPage:s!==null,error:y,pageError:h,setQuery:oe,loadMore:ce,retry:ve}),[r,n,$,l,u,f,R,w,s,y,h,oe,ce,ve])}i(dl,"useClinicPicker");function Di(e,t,r,o){return Object.freeze({key:e?.id??`free:${t??""}`,clinic:e,freeText:t,email:r,idempotencyKey:o})}i(Di,"clinicDraftFor");var Gr=10,oo=z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),fn=i((e,t=1)=>z.string().refine(r=>!xr(r)&&[...r].length>=t&&[...r].length<=e),"text"),pl=i(e=>[...e].some(t=>t.charCodeAt(0)<32||t.charCodeAt(0)===127),"hasControl"),Jp=z.object({clinicId:oo.optional(),clinicFreeText:fn(200).refine(e=>e.trim().length>0).optional(),clinicEmail:fn(320,3).refine(e=>!pl(e)&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e.trim())).optional(),signatureId:oo.optional(),signaturePngBase64:z.string().min(1).max(2*1024*1024).optional(),idempotencyKey:z.string().regex(/^[A-Za-z0-9._-]{8,128}$/)}).strict().refine(e=>e.clinicId===void 0!=(e.clinicFreeText===void 0)).refine(e=>e.signatureId===void 0!=(e.signaturePngBase64===void 0)),Zp=z.object({petRef:fn(128),ownerName:fn(200).refine(e=>e.trim().length>0&&!pl(e)),authorizationVersion:fn(64),clinics:z.array(Jp).min(1).max(Gr)}).strict(),em=z.object({request_group_id:oo,pet_ref:z.string(),created_count:z.number().int().nonnegative(),failed_count:z.number().int().nonnegative(),results:z.array(z.object({idempotency_key:z.string(),clinic_id:oo.nullable().optional(),clinic_free_text:z.string().nullable().optional(),created:z.boolean(),request:z.unknown().optional(),failure_code:z.string().nullable().optional(),failure_reason:z.string().nullable().optional()}))});function ml(e){let t=e.funnel??wr({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}});return {async createClinicRequestBatch(r){if(!Zp.safeParse(r).success)return W(N("validationFailed",{retryable:false}));let o=await t.send("records.clinic.createBatch",{method:"POST",path:"/widget/v1/records/clinic-requests/batch",body:{pet_ref:r.petRef,owner_name:r.ownerName,authorization_version:r.authorizationVersion,clinics:r.clinics.map(l=>({...l.clinicId!==void 0?{clinic_id:l.clinicId}:{clinic_free_text:l.clinicFreeText},...l.clinicEmail!==void 0?{clinic_email:l.clinicEmail}:{},...l.signatureId!==void 0?{signature_id:l.signatureId}:{signature_png_base64:l.signaturePngBase64},idempotency_key:l.idempotencyKey}))}});if(!o.ok)return o;let n=em.safeParse(o.value);if(!n.success||n.data.pet_ref!==r.petRef)return ul();let a=[];for(let l of n.data.results){let c=l.request===void 0||l.request===null?null:gr(l.request);if(l.created!==(c!==null))return ul();a.push(Object.freeze({idempotencyKey:l.idempotency_key,clinicId:l.clinic_id??null,clinicFreeText:l.clinic_free_text??null,created:l.created,request:c,failureCode:l.failure_code??null,failureReason:l.failure_reason??null}));}return Ie(Object.freeze({requestGroupId:n.data.request_group_id,petRef:n.data.pet_ref,results:Object.freeze(a),createdCount:n.data.created_count,failedCount:n.data.failed_count}))}}}i(ml,"createRecordsClinicBatchClient");function ul(){return W(N("internalError",{retryable:false}))}i(ul,"malformed");var yl=z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),tm=z.object({clinics:z.array(z.object({clinic_id:yl,name:z.string().min(1),address:z.string().nullable(),phone:z.string().nullable(),email_status:z.string(),distance_km:z.number().finite().nonnegative().nullable()})),next_cursor:z.string().nullable().optional()}),rm=z.object({authorization_version:z.string().min(1),scope_template:z.string().min(1),authorization_template:z.string().min(1)}),nm=z.object({upload_id:z.string().min(1),upload_url:z.string().url().refine(e=>e.startsWith("https://")),upload_fields:z.record(z.string())});function fl(e){let{repository:t}=e,r=i(async n=>{let a=await n;if(!a.ok)return a;let l=gr(a.value);return l===null?Vr():Ie(l)},"request"),o=i(async n=>{let a=await n;if(!a.ok)return a;let l=tm.safeParse(a.value);return l.success?Ie(Object.freeze({clinics:Object.freeze(l.data.clinics.map(c=>Object.freeze({id:c.clinic_id,name:c.name,address:c.address,phone:c.phone,emailStatus:c.email_status,distanceKm:c.distance_km}))),nextCursor:l.data.next_cursor??null})):Vr()},"page");return {searchClinics:i((n={})=>o(t.searchClinics(n)),"searchClinics"),recentClinics:i((n={})=>o(t.recentClinics(n)),"recentClinics"),async getRequestGroup(n){let a=await t.getRequestGroup(n);if(!a.ok)return a;let l=ha(a.value);return l===null?Vr():Ie(l)},async getAuthorizationCopy(){let n=await t.getAuthorizationCopy();if(!n.ok)return n;let a=rm.safeParse(n.value);return a.success?Ie(Object.freeze({authorizationVersion:a.data.authorization_version,scopeTemplate:a.data.scope_template,authorizationTemplate:a.data.authorization_template})):Vr()},async createClinicRequest(n){let a=await r(t.createClinicRequest(n));return a.ok&&a.value.petRef!==n.petRef?Vr():a},retryRequest:i(n=>r(t.retryRequest(n)),"retryRequest"),revokeRequest:i(n=>r(t.revokeRequest(n)),"revokeRequest"),updateClinicEmail:i((n,a)=>r(t.updateClinicEmail(n,a)),"updateClinicEmail"),convertToUpload:i(n=>r(t.convertToUpload(n)),"convertToUpload"),async initiateSignatureUpload(n){let a=await t.initiateSignatureUpload(n);if(!a.ok)return a;let l=nm.safeParse(a.value);return l.success?Ie(Object.freeze({uploadId:l.data.upload_id,uploadUrl:l.data.upload_url,uploadFields:Object.freeze(l.data.upload_fields)})):Vr()},async completeSignatureUpload(n){let a=await t.completeSignatureUpload(n);if(!a.ok)return a;let l=z.object({signature_id:yl}).safeParse(a.value);return l.success?Ie(l.data.signature_id):Vr()}}}i(fl,"createRecordsClinicController");function Vr(){return W(N("internalError",{retryable:false}))}i(Vr,"malformed");var Cr="/widget/v1/records",gl=z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),Sr=i((e,t=1)=>z.string().refine(r=>!xr(r)&&[...r].length>=t&&[...r].length<=e),"text"),hl=i(e=>[...e].some(t=>t.charCodeAt(0)<32||t.charCodeAt(0)===127),"hasControl"),Rl=Sr(320,3).refine(e=>!hl(e)&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e.trim())),bl=Sr(64),om=z.object({limit:z.number().int().min(1).max(25).optional()}).strict(),im=z.object({query:Sr(200,0).optional(),location:z.object({latitude:z.number().finite().min(-90).max(90),longitude:z.number().finite().min(-180).max(180)}).strict().optional(),limit:z.number().int().min(1).max(100).optional(),cursor:Sr(512,0).optional()}).strict(),sm=z.object({petRef:Sr(128),ownerName:Sr(200).refine(e=>e.trim().length>0&&!hl(e)),authorizationVersion:Sr(64),clinicId:gl.optional(),clinicFreeText:Sr(200).refine(e=>e.trim().length>0).optional(),clinicEmail:Rl.optional(),signatureId:gl.optional(),signaturePngBase64:z.string().min(1).max(2*1024*1024).optional(),idempotencyKey:z.string().regex(/^[A-Za-z0-9._-]{8,128}$/)}).strict().refine(e=>e.clinicId===void 0!=(e.clinicFreeText===void 0)).refine(e=>e.signatureId===void 0!=(e.signaturePngBase64===void 0));function vl(e){let t=e.funnel??wr({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=i((n,a,l=false)=>t.send(`records.clinic.${n}`,a,a.method==="GET"||l?void 0:{idempotent:false,maxAttempts:1}),"send"),o=i((n,a,l)=>bl.safeParse(n).success?r(a,{method:"POST",path:`${Cr}/requests/${encodeURIComponent(n)}/${a}`,...l?{body:l}:{}}):Er(),"recover");return {searchClinics(n){return im.safeParse(n).success?r("search",{method:"GET",path:`${Cr}/clinics/search`,query:{q:n.query??"",lat:n.location?.latitude,lng:n.location?.longitude,limit:n.limit,cursor:n.cursor}}):Er()},recentClinics(n){return om.safeParse(n).success?r("recent",{method:"GET",path:`${Cr}/clinics/recent`,query:{limit:n.limit}}):Er()},getRequestGroup(n){return bl.safeParse(n).success?r("requestGroup",{method:"GET",path:`${Cr}/request-groups/${encodeURIComponent(n)}`}):Er()},getAuthorizationCopy:i(()=>r("authorizationCopy",{method:"GET",path:`${Cr}/authorization-copy`}),"getAuthorizationCopy"),createClinicRequest(n){return sm.safeParse(n).success?r("create",{method:"POST",path:`${Cr}/clinic-requests`,body:{pet_ref:n.petRef,owner_name:n.ownerName,authorization_version:n.authorizationVersion,idempotency_key:n.idempotencyKey,...n.clinicId!==void 0?{clinic_id:n.clinicId}:{clinic_free_text:n.clinicFreeText},...n.clinicEmail!==void 0?{clinic_email:n.clinicEmail}:{},...n.signatureId!==void 0?{signature_id:n.signatureId}:{signature_png_base64:n.signaturePngBase64}}},true):Er()},retryRequest:i(n=>o(n,"retry"),"retryRequest"),revokeRequest:i(n=>o(n,"revoke"),"revokeRequest"),convertToUpload:i(n=>o(n,"convert-to-upload"),"convertToUpload"),updateClinicEmail(n,a){return Rl.safeParse(a).success?o(n,"clinic-email",{clinic_email:a}):Er()},initiateSignatureUpload(n){return !Number.isInteger(n)||n<=0||n>2*1024*1024?Er():r("signatureInitiate",{method:"POST",path:`${Cr}/signatures/initiate`,body:{content_type:"image/png",file_size:n}})},completeSignatureUpload(n){return /^sig-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n)?r("signatureComplete",{method:"POST",path:`${Cr}/signatures/complete`,body:{upload_id:n}}):Er()}}}i(vl,"createHttpRecordsClinicRepository");function Er(){return Promise.resolve(W(N("validationFailed",{retryable:false})))}i(Er,"invalid");function Ut(){let{runtime:e,userRef:t,scopeEpoch:r}=Te(),o=useMemo(()=>{let{services:a}=e.registry;return fl({repository:vl({auth:a.authFor(t),...a.errorPolicy?{errorPolicy:a.errorPolicy}:{}})})},[e,t,r]),n=useRef(o);return useEffect(()=>(n.current=o,()=>{n.current=null;}),[o]),useMemo(()=>{let a=i(async l=>{if(t===null||n.current!==o)return W(N("accessDenied"));let c=await l();return n.current===o?c:W(N("accessDenied"))},"run");return {searchClinics:i(l=>a(()=>o.searchClinics(l)),"searchClinics"),recentClinics:i(l=>a(()=>o.recentClinics(l)),"recentClinics"),getRequestGroup:i(l=>a(()=>o.getRequestGroup(l)),"getRequestGroup"),getAuthorizationCopy:i(()=>a(()=>o.getAuthorizationCopy()),"getAuthorizationCopy"),createClinicRequest:i(l=>a(()=>o.createClinicRequest(l)),"createClinicRequest"),retryRequest:i(l=>a(()=>o.retryRequest(l)),"retryRequest"),revokeRequest:i(l=>a(()=>o.revokeRequest(l)),"revokeRequest"),updateClinicEmail:i((l,c)=>a(()=>o.updateClinicEmail(l,c)),"updateClinicEmail"),convertToUpload:i(l=>a(()=>o.convertToUpload(l)),"convertToUpload"),initiateSignatureUpload:i(l=>a(()=>o.initiateSignatureUpload(l)),"initiateSignatureUpload"),completeSignatureUpload:i(l=>a(()=>o.completeSignatureUpload(l)),"completeSignatureUpload")}},[o,t])}i(Ut,"useEverfurRecordsClinic");function Ai(){let{runtime:e,userRef:t,scopeEpoch:r}=Te(),o=useMemo(()=>{let{services:a}=e.registry;return ml({auth:a.authFor(t),...a.errorPolicy?{errorPolicy:a.errorPolicy}:{}})},[e,t,r]),n=useRef(o);return useEffect(()=>(n.current=o,()=>{n.current=null;}),[o]),useMemo(()=>({async createClinicRequestBatch(a){if(t===null||n.current!==o)return W(N("accessDenied"));let l=await o.createClinicRequestBatch(a);return n.current===o?l:W(N("accessDenied"))}}),[o,t])}i(Ai,"useEverfurRecordsClinicBatch");var Vi=class Vi extends Component{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey};}static getDerivedStateFromError(){return {failed:true}}static getDerivedStateFromProps(r,o){return Object.is(r.resetKey,o.key)?null:{failed:false,key:r.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};i(Vi,"HostRenderBoundary");var Oi=Vi;function lm({render:e}){return e()}i(lm,"RenderHost");function Li({render:e,fallback:t,resetKey:r}){return createElement(Oi,{fallback:t,resetKey:r,children:createElement(lm,{render:e})})}i(Li,"HostRender");var cm=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 dm(e){return cm[e]}i(dm,"requires");function El(e,t,r){let o=dm(e),n=new Map;for(let c of t)n.set(c.resource,c);if(r?.isPending===true&&o.some(c=>!n.has(c)))return qi({name:e,enabled:false,isPending:true,limits:{}});let a=um(o,n);return o.filter(c=>n.get(c)?.granted!==true).length===0?qi({name:e,enabled:true,isPending:false,limits:a}):qi({name:e,enabled:false,isPending:false,limits:a,disabled:pm(o,n)})}i(El,"decideCapability");function um(e,t){let r={};for(let o of e){let n=t.get(o)?.limits;if(n)for(let[a,l]of Object.entries(n)){let c=r[a];r[a]=c===void 0?l:Math.min(c,l);}}return r}i(um,"mergeLimits");function pm(e,t){for(let r of e){let o=t.get(r)?.disabled;if(o)return Object.freeze({reason:o.reason,level:o.level,recoverable:o.recoverable})}return Object.freeze({reason:ti("accessDenied"),level:"user_entitlement",recoverable:false})}i(pm,"disabledFor");function qi(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(qi,"freezeDecision");function gn(e){let{runtime:t}=Te(),r=t.entitlements,o=useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot);return useMemo(()=>El(e,o.decisions,{isPending:o.isPending}),[e,o])}i(gn,"useCapability");var fm=48;function gm(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}i(gm,"selectView");function Ve(e){let{capability:t,children:r,renderDisabled:o,renderPending:n,style:a}=e,l=gn(t),c=useMemo(()=>gm(l),[l]);switch(c){case "enabled":return r;case "pending":return n?jsx(Li,{render:n,fallback:jsx(kl,{capability:t,style:a})}):jsx(kl,{capability:t,style:a});case "disabled":return o?jsx(Li,{render:()=>o(l),fallback:jsx(Tl,{decision:l,style:a}),resetKey:l}):jsx(Tl,{decision:l,style:a});default:return vr(c)}}i(Ve,"CapabilityGate");function kl({capability:e,style:t}){let r=V(),o=useMemo(()=>_l(r),[r]);return jsx(View,{style:[o.offstate,t],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${e}`,children:jsx(View,{style:o.skeletonBar})})}i(kl,"PendingSkeleton");function Tl({decision:e,style:t}){let r=V(),o=useMemo(()=>_l(r),[r]),n=e.disabled?.reason??"";return jsx(View,{style:[o.offstate,t],accessible:true,accessibilityRole:"text",accessibilityLabel:n,children:n.length>0?jsx(m,{style:o.offstateText,children:n}):null})}i(Tl,"OffState");function _l(e){let{color:t,space:r,radius:o,type:n}=e;return StyleSheet.create({offstate:{minHeight:fm,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:o.md,borderWidth:StyleSheet.hairlineWidth,borderColor:t.brandBorder},offstateText:{...k(e,"regular"),fontSize:n.size.body,lineHeight:Math.round(n.size.body*n.lineHeight.normal),color:t.text.muted},skeletonBar:{height:r.md,borderRadius:o.xs,backgroundColor:t.brandSofter}})}i(_l,"makeStyles");var bn=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 qe(e){let t=V(),r=useMemo(()=>Rm(t),[t]);return jsxs(View,{style:[r.container,e.style],accessible:true,accessibilityRole:"text",accessibilityLabel:`${bn.title}. ${bn.body}`,children:[jsx(m,{style:r.title,children:bn.title}),jsx(m,{style:r.body,children:bn.body})]})}i(qe,"ClinicalDisclaimer");function Rm(e){let{color:t,space:r,type:o}=e;return StyleSheet.create({container:{paddingHorizontal:r.lg,paddingVertical:r.md,borderTopWidth:StyleSheet.hairlineWidth,borderTopColor:t.borderHairlineGreen,backgroundColor:t.surfaceCream,gap:r.xs},title:{...k(e,"bold"),fontSize:o.size.caption,lineHeight:Math.round(o.size.caption*o.lineHeight.snug),color:t.text.secondary,letterSpacing:o.letterSpacing.eyebrow},body:{...k(e,"regular"),fontSize:o.size.caption,lineHeight:Math.round(o.size.caption*o.lineHeight.snug),color:t.text.muted}})}i(Rm,"makeStyles");function nt(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(nt,"slotBox");function at(e){return e?.textColor===void 0?{}:{color:e.textColor}}i(at,"slotText");var Dl=Object.freeze({idle:Object.freeze({title:"Find your pet\u2019s clinic",body:"Search for the clinic that holds your pet\u2019s records. We\u2019ll request them on your behalf once you sign the authorization.",action:null}),no_requests:Object.freeze({title:"No record requests yet",body:"When you request records from a clinic, you\u2019ll be able to track every step here.",action:null}),no_records:Object.freeze({title:"Nothing to show just yet",body:"Once your pet\u2019s records arrive and our team reviews them, lab trends and visits will appear here.",action:null}),rate_limited:Object.freeze({title:"Slow down a moment",body:"You\u2019ve made a lot of requests just now. You can try again shortly.",action:"Try again"}),service_unavailable:Object.freeze({title:"Records search is temporarily down",body:"We\u2019re working on it. Please try again in a few minutes.",action:"Try again"}),error:Object.freeze({title:"Couldn\u2019t reach Everfur",body:"Check your connection and try again.",action:"Try again"})}),Ni=60;function Al(e){return `Try again in ${e}s`}i(Al,"coolingActionLabel");var Ol="Try again, available shortly";function Ue({variant:e,onAction:t,message:r,testID:o}){let n=Em(),a=Dl[e],[l,c]=useState(e==="rate_limited"?Ni:0);useEffect(()=>{e==="rate_limited"&&c(Ni);},[e]),useEffect(()=>{if(l<=0)return;let u=setTimeout(()=>c(p=>Math.max(0,p-1)),1e3);return ()=>clearTimeout(u)},[l]);let s=e==="rate_limited"&&l>0,d=s?Al(l):a.action;return jsxs(View,{style:n.container,accessibilityRole:"summary",testID:o,children:[jsx(View,{style:n.glyph,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsx(m,{style:n.title,children:a.title}),jsx(m,{style:n.body,children:r??a.body}),d!==null&&t?jsx(Pressable,{onPress:t,disabled:s,accessibilityRole:"button",accessibilityLabel:s?Ol:d,accessibilityState:{disabled:s},style:[n.action,s?n.actionDisabled:null],testID:o?`${o}-action`:`records-empty-${e}-action`,children:jsx(m,{style:n.actionLabel,children:d})}):null]})}i(Ue,"RecordsEmptyState");function Em(){let e=V();return useMemo(()=>Sm(e),[e])}i(Em,"useStyles");function Sm(e){let{color:t,space:r,radius:o,type:n,slots:a}=e,l=r.lg+r.xs+r.xs/2;return StyleSheet.create({container:{paddingVertical:r.xxl,paddingHorizontal:r.xl,alignItems:"center",gap:r.sm+r.xs/2},glyph:{width:l,height:l,borderRadius:l/2,backgroundColor:t.brandSoft,borderWidth:StyleSheet.hairlineWidth,borderColor:t.brandBorder,marginBottom:r.xs},title:{...k(e,"bold"),fontSize:n.size.subtitle,lineHeight:Math.round(n.size.subtitle*n.lineHeight.snug)-1,color:t.brandInk,textAlign:"center"},body:{...k(e,"regular"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*n.lineHeight.normal),color:t.text.muted,textAlign:"center",maxWidth:320},action:{marginTop:r.sm,minHeight:r.xxl+r.sm,borderRadius:o.pill,paddingHorizontal:r.lg+r.xs/2,backgroundColor:t.brand,alignItems:"center",justifyContent:"center",...nt(a.primaryButton)},actionDisabled:{opacity:.5},actionLabel:{...k(e,"bold"),color:t.onPrimary,fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*n.lineHeight.snug)-1,...at(a.primaryButton)}})}i(Sm,"makeStyles");var Ye="Back";function Ke({title:e,onBack:t,right:r,testID:o,variant:n="brand"}){let a=Rn();return jsxs(View,{style:a.row,testID:o,children:[t?jsx(Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:Ye,hitSlop:12,style:a.back,testID:o?`${o}-back`:void 0,children:jsx(View,{style:a.chevron,accessibilityElementsHidden:true,importantForAccessibility:"no"})}):jsx(View,{style:a.back}),jsx(m,{style:n==="document"?a.documentTitle:a.title,accessibilityRole:"header",numberOfLines:1,children:e}),jsx(View,{style:a.right,children:r??jsx(View,{style:a.back})})]})}i(Ke,"ScreenHeader");function zl(){let e=Rn();return jsxs(View,{style:e.listGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:[jsx(View,{style:e.listBar}),jsx(View,{style:e.listBar}),jsx(View,{style:e.listBar})]})}i(zl,"ListGlyph");function Fl(){let e=Rn();return jsxs(View,{style:e.shareGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:[jsx(View,{style:[e.shareDot,e.shareDotTop]}),jsx(View,{style:[e.shareDot,e.shareDotLeft]}),jsx(View,{style:[e.shareDot,e.shareDotBottom]}),jsx(View,{style:[e.shareStroke,e.shareStrokeUp]}),jsx(View,{style:[e.shareStroke,e.shareStrokeDown]})]})}i(Fl,"ShareGlyph");function Nl(){let e=Rn();return jsxs(View,{style:e.sendGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:[jsx(View,{style:e.sendBody}),jsx(View,{style:e.sendFold})]})}i(Nl,"SendGlyph");function Ml(){let e=Rn();return jsxs(View,{style:e.downloadGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:[jsx(View,{style:e.downloadStem}),jsx(View,{style:e.downloadHead}),jsx(View,{style:e.downloadTray})]})}i(Ml,"DownloadGlyph");function Rn(){let e=V();return useMemo(()=>Im(e),[e])}i(Rn,"useStyles");function Im(e){let{color:t,space:r,type:o}=e,n=r.xxl+r.md,a=r.md,l=r.xs/2,c=r.lg+r.xs+r.xs/2;return StyleSheet.create({row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:r.lg,paddingTop:r.xs,paddingBottom:r.md,gap:r.sm},back:{width:n,height:n,alignItems:"center",justifyContent:"center"},chevron:{width:a,height:a,borderLeftWidth:l,borderBottomWidth:l,borderColor:t.brandInk,transform:[{rotate:"45deg"}],marginLeft:r.xs},title:{flex:1,...k(e,"bold"),fontSize:o.size.heading,lineHeight:Math.round(o.size.heading*o.lineHeight.tight)+1,color:t.brandInk},documentTitle:{flex:1,textAlign:"center",...k(e,"bold"),fontSize:o.size.subtitle,lineHeight:Math.round(o.size.subtitle*o.lineHeight.snug),color:t.text.primary},right:{flexDirection:"row",alignItems:"center",gap:r.sm+r.xs/2},listGlyph:{width:c,height:c,justifyContent:"space-evenly"},listBar:{height:l,borderRadius:l,backgroundColor:t.brandInk},shareGlyph:{width:c-r.xs,height:c-r.xs},shareDot:{position:"absolute",width:r.xs+r.xs/2,height:r.xs+r.xs/2,borderRadius:r.xs,borderWidth:l,borderColor:t.brandInk},shareDotTop:{right:0,top:0},shareDotLeft:{left:0,top:r.xs+r.xs/2},shareDotBottom:{right:0,bottom:0},shareStroke:{position:"absolute",left:r.xs,top:r.sm,width:r.sm+r.xs/2,height:l,backgroundColor:t.brandInk},shareStrokeUp:{transform:[{rotate:"-30deg"}]},shareStrokeDown:{transform:[{rotate:"30deg"}]},sendGlyph:{width:c-r.xs,height:c-r.xs},sendBody:{position:"absolute",left:0,top:0,right:0,bottom:0,borderWidth:l,borderColor:t.brandInk,transform:[{rotate:"45deg"}],borderRadius:l},sendFold:{position:"absolute",left:0,right:0,top:"50%",height:l,backgroundColor:t.brandInk},downloadGlyph:{width:c-r.xs,height:c-r.xs,alignItems:"center"},downloadStem:{width:l,height:r.sm+r.xs/2,backgroundColor:t.brandInk},downloadHead:{width:r.sm,height:r.sm,borderRightWidth:l,borderBottomWidth:l,borderColor:t.brandInk,transform:[{rotate:"45deg"}],marginTop:-r.sm},downloadTray:{position:"absolute",bottom:0,left:0,right:0,height:r.xs+r.xs/2,borderLeftWidth:l,borderRightWidth:l,borderBottomWidth:l,borderColor:t.brandInk}})}i(Im,"makeStyles");var Om=120,Lm=44;function Vm({reason:e,onExit:t,exitLabel:r,style:o}){let{color:n,space:a,radius:l,type:c}=V();return jsxs(View,{testID:"records-gate-off",style:[{minHeight:Om,justifyContent:"center",gap:a.md,padding:a.lg,borderRadius:l.md,borderWidth:1,borderColor:n.brandBorder,backgroundColor:n.surfaceCream},o],children:[e.length>0?jsx(m,{style:{fontSize:c.size.bodyTight,color:n.text.muted},children:e}):null,jsx(Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:r,testID:"records-gate-off-exit",style:{minHeight:Lm,alignSelf:"flex-start",justifyContent:"center",paddingHorizontal:a.lg,borderRadius:l.pill,borderWidth:1.5,borderColor:n.brandInk},children:jsx(m,{style:{fontSize:c.size.body,color:n.brandInk},children:r})})]})}i(Vm,"RecordsGateOffState");function Fe(e,t){return e===void 0?{}:{renderDisabled:i(r=>jsx(Vm,{reason:r.disabled?.reason??"",onExit:e,exitLabel:t}),"renderDisabled")}}i(Fe,"recordsGateExit");var zm="your pet";function Ne(e){let t=e?.trim()??"";return t.length>0?t:zm}i(Ne,"petNameOr");var yt=Object.freeze({title:"Health records",openTimeline:"Open timeline",loading:"Loading health records",lead:i(e=>`${Ne(e)}\u2019s lab trends`,"lead"),retryMarkers:"Retry loading lab trends",viewFullRecord:"View full medical record",viewTimeline:"View full timeline",important:i(e=>`Important: ${e}`,"important")}),jt=Object.freeze({title:"Marker Summary",marker:"Marker",markers:"Markers",outOfRange:"OUT OF RANGE",inRange:"IN RANGE",noRange:"NO RANGE",subtitle:"Summary of your pet\u2019s biomarkers",ask:"Ask about these markers",askA11y:"Ask Everfur about these markers",a11y:i((e,t,r,o)=>`Marker summary: ${e} ${e===1?"marker":"markers"}, ${t} in range, ${r} out of range${o>0?`, ${o} without a range`:""}.`,"a11y")}),Mi=Object.freeze({counter:i((e,t)=>`${e+1} of ${t}`,"counter"),a11y:i((e,t,r)=>e!==null?`${e}, marker ${t+1} of ${r}. Swipe left or right to see more markers.`:`Marker ${t+1} of ${r}`,"a11y")}),dr=Object.freeze({tapHint:"Tap a point to see where it came from.",singleHint:"One reading so far: we\u2019ll plot a trend as more come in.",empty:"No readings for this marker yet.",ask:"Ask about this marker",askA11y:i(e=>`Ask Everfur about ${e}`,"askA11y"),status:i(e=>`Status: ${e}`,"status"),latestA11y:i((e,t,r)=>`Latest reading ${e}, ${t}, collected ${r}`,"latestA11y"),readingsA11y:i(e=>`${e} readings, oldest to newest`,"readingsA11y")}),St=Object.freeze({title:"Where this reading came from",close:"Close reading details",collected:"Collected",clinic:"Clinic",referenceRange:"Reference range",noRange:"Not on file for this reading",sourceDocument:"Source document",unverified:"Our team hasn\u2019t verified this reading against the original document yet.",reviewed:"Reviewed by our team",ask:"Ask about this reading",askA11y:"Ask Everfur about this reading"}),kr=Object.freeze({title:i(e=>`${Ne(e)}\u2019s records request`,"title"),body:i(e=>`We\u2019re requesting ${Ne(e)}\u2019s records from your vet. This usually takes a few days; we\u2019ll show lab trends here as soon as they arrive.`,"body"),a11y:i(e=>`Records request in progress for ${Ne(e)}.`,"a11y"),openA11y:i((e,t)=>`Open ${Ne(e)}\u2019s records request. ${t}`,"openA11y"),ask:"Ask about this request",askA11y:"Ask Everfur about this records request"}),$t=Object.freeze({title:i(e=>`Add ${Ne(e)}\u2019s records`,"title"),body:"Records can come from more than one clinic over a lifetime.",requestFromClinic:"Request from a clinic",requestFromClinicA11y:i(e=>`Request ${Ne(e)}\u2019s records from a clinic`,"requestFromClinicA11y"),uploadDocument:"Upload a document",uploadDocumentA11y:i(e=>`Upload one of ${Ne(e)}\u2019s records`,"uploadDocumentA11y")});var ao="rgba(0,0,0,0.4)";function me(){let e=V();return useMemo(()=>Bm(e),[e])}i(me,"useScreenStyles");function Tr({disclaimer:e,style:t}){let r=me();return e.trim().length===0?null:jsxs(View,{style:[r.band,t],accessible:true,accessibilityRole:"text",accessibilityLabel:yt.important(e),testID:"records-disclaimer-band",children:[jsx(View,{style:r.infoGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsx(m,{style:r.infoGlyphText,children:"i"})}),jsx(m,{style:r.bandText,children:e})]})}i(Tr,"DisclaimerBand");function X({label:e,onPress:t,kind:r="primary",disabled:o=false,busy:n=false,accessibilityLabel:a,testID:l,style:c}){let s=me(),d=V(),u=r==="primary"?s.pillPrimary:r==="outline"?s.pillOutline:r==="danger"?s.pillDanger:r==="ask"?s.pillAsk:s.pillLink,p=r==="primary"?s.pillPrimaryLabel:r==="danger"?s.pillDangerLabel:r==="ask"?s.pillAskLabel:r==="link"?s.pillLinkLabel:s.pillOutlineLabel;return jsxs(Pressable,{onPress:t,disabled:o||n,accessibilityRole:"button",accessibilityLabel:a??e,accessibilityState:{disabled:o||n,busy:n},style:[s.pill,u,o?s.pillDisabled:null,c],testID:l,children:[n?jsx(ActivityIndicator,{size:"small",color:r==="primary"?d.color.onPrimary:d.color.brandInk}):null,jsx(m,{style:p,children:e})]})}i(X,"Pill");function kt({label:e,tone:t="neutral",testID:r}){let o=me(),{bg:n,fg:a}=o.chipTones[t];return jsx(View,{style:[o.chip,n],testID:r,children:jsx(m,{style:[o.chipText,a],children:e})})}i(kt,"Chip");function At({title:e,count:t}){let r=me();return jsxs(View,{style:r.sectionHeader,children:[jsx(m,{style:r.sectionTitle,accessibilityRole:"header",children:e}),t!==void 0?jsx(m,{style:r.sectionCount,children:t}):null]})}i(At,"SectionHeader");function rr({direction:e="right"}){let t=me(),r=e==="right"?"45deg":e==="down"?"135deg":"-45deg";return jsx(View,{style:[t.chevron,{transform:[{rotate:r}]}],accessibilityElementsHidden:true,importantForAccessibility:"no"})}i(rr,"Chevron");function Bm(e){let{color:t,space:r,radius:o,type:n,slots:a}=e,{size:l,lineHeight:c}=n,s=i((v,w)=>Math.round(v*w),"lh"),d=StyleSheet.hairlineWidth,u=r.xxl+r.md,p=i((v,w,g,y="regular")=>({...k(e,y),fontSize:v,lineHeight:s(v,w),color:g}),"text"),f=at(a.recordCard),b=e.brightness==="dark"?t.errorRed:t.danger,R=i((v,w)=>({bg:{backgroundColor:v},fg:{color:w}}),"tone");return {chipTones:{neutral:R(t.badgeBgNeutral,t.text.secondary),info:R(t.brandSoft,t.brandInk),warning:R(t.badgeBgCaution,t.warningStrong),critical:R(t.badgeBgCritical,t.danger),positive:R(t.badgeBgPositive,t.success)},...StyleSheet.create({root:{flex:1,backgroundColor:t.background},body:{flex:1},content:{paddingHorizontal:r.lg,paddingBottom:r.xxl,gap:r.lg},contentTight:{paddingHorizontal:r.sm,paddingBottom:r.xxl,gap:r.lg},inset:{paddingHorizontal:r.sm},section:{gap:r.sm+r.xs/2},sectionHeader:{flexDirection:"row",alignItems:"center",gap:r.sm,paddingHorizontal:r.xs},sectionTitle:{...p(l.body+1,c.snug,t.text.primary,"bold")},sectionCount:{...p(l.bodyTight,c.snug,t.text.muted,"medium")},card:{borderRadius:o.lg-r.xs,borderWidth:d,borderColor:t.brandBorder,backgroundColor:t.surface,paddingHorizontal:r.lg,paddingVertical:r.xs,...nt(a.recordCard,d)},creamCard:{borderRadius:o.lg-r.xs/2,borderWidth:d,borderColor:t.brandBorder,backgroundColor:t.surfaceCream,padding:r.lg,gap:r.md,...nt(a.recordCard,d)},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.md,paddingVertical:r.md},rowDivider:{borderTopWidth:d,borderTopColor:t.borderHairlineGreen},rowMain:{flex:1},rowRight:{alignItems:"flex-end",gap:r.xs+r.xs/2},rowTitle:{...p(l.body,c.snug,t.text.primary,"medium"),...f},rowDetail:{...p(l.caption,c.normal,t.text.secondary),marginTop:r.xs/2,...f},rowValue:{...p(l.body+1,c.snug,t.text.primary,"bold"),marginTop:r.xs/2,...f},rowMuted:{...p(l.caption,c.normal,t.text.muted),...f},chip:{borderRadius:o.pill,paddingHorizontal:r.sm,paddingVertical:r.xs-1,alignSelf:"flex-start"},chipText:{...p(l.tiny,c.snug,t.text.primary,"medium")},pill:{minHeight:u,borderRadius:o.pill,paddingHorizontal:r.lg+r.xs/2,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:r.sm},pillPrimary:{backgroundColor:t.brand,...nt(a.primaryButton)},pillPrimaryLabel:{...p(l.body,c.snug,t.onPrimary,"bold"),...at(a.primaryButton)},pillOutline:{borderWidth:1.5,borderColor:t.brandInk,backgroundColor:"transparent"},pillOutlineLabel:{...p(l.body,c.snug,t.brandInk,"bold")},pillDanger:{borderWidth:1.4,borderColor:t.danger,backgroundColor:t.surface},pillDangerLabel:{...p(l.bodyTight,c.snug,t.danger,"bold")},pillAsk:{borderWidth:d,borderColor:t.borderRingCream,backgroundColor:t.surface},pillAskLabel:{...p(l.body,c.snug,t.text.primary,"bold")},pillLink:{backgroundColor:"transparent",paddingHorizontal:r.sm},pillLinkLabel:{...p(l.body,c.snug,t.linkInk,"bold")},pillDisabled:{opacity:.5},infoNote:{flexDirection:"row",alignItems:"flex-start",gap:r.sm,borderRadius:o.md-r.xs/2,backgroundColor:t.brandSoft,paddingHorizontal:r.md,paddingVertical:r.sm+r.xs/2},infoNoteText:{flex:1,...p(l.bodyTight,c.normal,t.text.primary)},cautionNote:{flexDirection:"row",alignItems:"flex-start",gap:r.sm,borderRadius:o.md-r.xs/2,backgroundColor:t.badgeBgCaution,paddingHorizontal:r.md,paddingVertical:r.sm+r.xs/2},cautionNoteText:{flex:1,...p(l.bodyTight,c.normal,t.warningStrong)},statusCard:{borderRadius:o.md,backgroundColor:t.brandSoft,padding:r.md+r.xs/2},statusText:p(l.bodyTight,c.relaxed,t.text.primary),errorBanner:{flexDirection:"row",alignItems:"flex-start",gap:r.sm,borderRadius:o.md-r.xs/2,backgroundColor:t.badgeBgCritical,padding:r.md},errorText:{flex:1,...p(l.bodyTight,c.normal,b)},band:{flexDirection:"row",alignItems:"flex-start",gap:r.sm,borderRadius:o.md-r.xs/2,padding:r.md,backgroundColor:t.brandSoft},bandText:{flex:1,...p(l.caption,c.normal,t.text.secondary)},infoGlyph:{width:r.md+r.xs/2,height:r.md+r.xs/2,borderRadius:o.pill,borderWidth:1,borderColor:t.text.secondary,alignItems:"center",justifyContent:"center"},infoGlyphText:{...p(l.small,c.tight,t.text.secondary,"bold")},chevron:{width:r.sm,height:r.sm,borderTopWidth:r.xs/2,borderRightWidth:r.xs/2,borderColor:t.text.muted},lead:{paddingHorizontal:r.sm,...p(l.body+1,c.snug,t.text.primary,"bold")},field:{minHeight:u,paddingHorizontal:r.md,paddingVertical:r.sm,borderWidth:1,borderColor:t.borderHairlineGreen,borderRadius:o.sm,color:t.text.primary,backgroundColor:t.surface,...k(e,"regular"),fontSize:l.body},fieldLabel:{...p(l.bodyTight,c.normal,t.text.secondary,"medium")},muted:p(l.caption,c.normal,t.text.muted),bodyText:p(l.body,c.normal,t.text.primary)})}}i(Bm,"makeScreenStyles");function Yr(e,t){return e===null?"":t?`${e} ${t}`:e}i(Yr,"formatEntityValue");var Hl=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function J(e){if(!e)return "-";let t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(t!==null){let n=Hl[Number(t[2])-1];return n===void 0?"-":`${n} ${Number(t[3])}, ${t[1]}`}let r=Date.parse(e);if(Number.isNaN(r))return "-";let o=new Date(r);return `${Hl[o.getUTCMonth()]} ${o.getUTCDate()}, ${o.getUTCFullYear()}`}i(J,"formatRecordsDate");var be=Object.freeze({timeline:"Timeline",loadingTimeline:"Loading timeline",labResults:"Blood & lab work",visits:"Visits",physicalExams:"Physical exams",visitNotes:"Visit notes",visit:"Visit",exam:"Exam",visitNote:"Visit note",notRecorded:"Not recorded",abnormal:"Abnormal",notExamined:"Not examined",normal:"Normal",measured:i(e=>`Measured ${e}`,"measured"),uploadedDocument:"Uploaded document",kind:Object.freeze({visit:"Visit",vaccine:"Vaccine",weight:"Weight",medication:"Medication"}),clinicVisit:"Clinic visit",doctor:i(e=>`Dr. ${e}`,"doctor"),lot:i(e=>`Lot ${e}`,"lot"),expires:i(e=>`Expires ${e}`,"expires")});function nr(e){switch(e){case "above":return {label:"Above range",outOfRange:true};case "below":return {label:"Below range",outOfRange:true};case "in_range":return {label:"In range",outOfRange:false};default:return {label:"No range on file",outOfRange:false}}}i(nr,"markerStatusLabel");function Kr(e,t){return t<2?null:`${e==="flat"?"Holding steady":`Trending ${e==="down"?"down":e==="up"?"up":"steady"}`} over ${t} visits`}i(Kr,"trajectoryLabel");function ur(e){let t=e.replace(/_/g," ").trim();return t.length===0?e:t.charAt(0).toUpperCase()+t.slice(1)}i(ur,"humanize");var Ul=Object.freeze({general:"General / attitude",eent:"Eyes, ears, nose & throat",oral_dental:"Oral & dental",cardiovascular:"Cardiovascular",respiratory:"Respiratory",gastrointestinal:"GI / abdomen",urogenital:"Urogenital",musculoskeletal:"Musculoskeletal",neurologic:"Neurologic",integument:"Skin & coat",lymphatic:"Lymph nodes"});function qr(e){return Object.prototype.hasOwnProperty.call(Ul,e)?Ul[e]:ur(e)}i(qr,"bodySystemLabel");var jl=Object.freeze({reason_for_visit:"Reason for visit",subjective:"Subjective",objective:"Objective",assessment:"Assessment",plan:"Plan",discharge_instructions:"Discharge instructions",follow_up:"Follow-up",remarks:"Notes"});function Qr(e){return Object.prototype.hasOwnProperty.call(jl,e)?jl[e]:ur(e)}i(Qr,"soapSectionLabel");function $l(e){return e===null||!Number.isFinite(e)?"-":`${e.toFixed(3).replace(/\.?0+$/,"")} kg`}i($l,"formatWeightKg");function Tt(e,t,r){if((e===null||!Number.isFinite(e))&&r)return r;if(e===null||!Number.isFinite(e))return "-";let o=e.toFixed(3).replace(/\.?0+$/,"");return t?`${o} ${t}`:o}i(Tt,"formatMarkerReading");function Hi(e,t,r){let o=Kr(t,r);return e?`${be.measured(J(e))}${o?` \xB7 ${o}`:""}`:o}i(Hi,"labDetailLine");var ae=Object.freeze({openA11y:"Share medical record",title:"Share medical record",helper:"Anyone with an active link can view this record until it expires. You can turn a link off anytime.",close:"Close",closeSheetA11y:"Close share sheet",viewDocument:"View document",createLink:"Create link and share",creatingLink:"Creating link...",downloadPdf:"Download PDF",preparingPdf:"Preparing PDF...",activeLinks:"Active links",loadingLinks:"Loading your share links",errorTitle:"Couldn\u2019t load your links",errorBody:"Check your connection and try again. You can still create a new link above.",retry:"Try again",retrying:"Retrying...",emptyTitle:"No active links yet",emptyBody:"Create a link above to let your vet or a sitter view this record. It expires on its own, and you can turn it off anytime.",copyLink:"Copy link",copyLinkA11y:i(e=>`Copy share link, ${e}`,"copyLinkA11y"),turnOff:"Turn off",turnOffA11y:i(e=>`Turn off share link, ${e}`,"turnOffA11y"),turningOff:"Turning off...",keep:"Keep",confirmTurnOff:"Turn off this link? Anyone who has it will lose access.",shareMessage:i(e=>`View this medical record: ${e}`,"shareMessage"),consentOffTitle:"Records access is off",consentOffBody:"Allow records for this pet again to create a link or download the PDF. Any links that were live have been turned off. You can still turn off a link from this list.",toasts:Object.freeze({noAddress:"Link created, but no address came back. It is listed under Active links.",shareSheet:"Could not open the share sheet. The link is saved below.",pdfShareSheet:"Could not open the share sheet for this PDF.",copied:"Link copied.",copyFailed:"Could not copy the link.",turnedOff:"Link turned off."})});function Hm(e,t){if(!e)return false;let r=Date.parse(e);return Number.isNaN(r)?false:r<=t}i(Hm,"isShareExpired");function Um(e,t){let r=J(e);return r==="-"?t?"Expired":"No expiry date":t?`Expired ${r}`:`Expires ${r}`}i(Um,"formatShareExpiry");function Wl(e,t,r){let o=e.map(n=>{let a=Hm(n.expiresAt,r),l=Um(n.expiresAt,a),c=J(n.createdAt),s=a?"Expired":"Active",d=l.replace(/^Expires /,"expiring ").replace(/^Expired /,"expired ").replace(/^Expired$/,"expired").replace(/^No expiry date$/,"with no expiry date");return {shareId:n.shareId,shareUrl:t[n.shareId]??null,active:!a,statusLabel:s,expiryLabel:l,createdLabel:c==="-"?null:`Created ${c}`,a11yLabel:`Share link. ${s}. ${l}.`,actionContext:d}});return Object.freeze([...o.filter(n=>n.active),...o.filter(n=>!n.active)])}i(Wl,"buildShareRows");function lo(e,t){let r=e?.httpStatus;if(ar(e)){if(t==="create")return "Records access for this pet is off, so a new link cannot be created.";if(t==="download")return "Records access for this pet is off, so the PDF cannot be downloaded."}if(r===429)return "You are creating links a little too fast. Wait a moment, then try again.";if(t==="revoke"&&(r===404||r===409||r===410))return "That link was already turned off.";if(r===401||r===403)return "You need to be signed in as this pet's owner to do that.";switch(t){case "create":return "Could not create a share link. Please try again.";case "revoke":return "Could not turn off that link. Please try again.";default:return "Could not download the record PDF. Please try again."}}i(lo,"shareErrorMessage");function xe({width:e,height:t,radius:r,style:o}){let{color:n,radius:a}=V();return jsx(View,{style:[{width:e,height:t,borderRadius:r??a.xs,backgroundColor:n.skeleton},o],accessibilityElementsHidden:true,importantForAccessibility:"no"})}i(xe,"SkeletonBlock");var Ui=180,Yl=70,co=22,$m=300,Kl=44,uo=24,ji=34,Wm=6,Gm=5;function po({testID:e}){let t=xn(),r=i(o=>jsxs(View,{style:t.actionRow,children:[jsxs(View,{style:t.actionLeft,children:[jsx(xe,{width:18,height:18,radius:9}),jsx(xe,{width:"55%",height:14,radius:7})]}),jsx(xe,{width:18,height:18,radius:9})]},o),"action");return jsxs(View,{style:t.dashboard,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:yt.loading,testID:e,children:[jsx(View,{style:t.inset,children:jsxs(View,{style:t.summaryCard,children:[jsx(xe,{width:Ui,height:Ui,radius:Ui/2}),jsxs(View,{style:t.badges,children:[jsx(xe,{width:Yl,height:co,radius:co/2}),jsx(xe,{width:Yl,height:co,radius:co/2})]})]})}),jsx(xe,{width:150,height:16,radius:8,style:t.inset}),jsx(View,{style:t.carouselCard,children:jsx(xe,{width:"100%",height:$m,radius:14})}),jsxs(View,{style:t.dots,children:[jsx(xe,{width:6,height:6,radius:3}),jsx(xe,{width:18,height:6,radius:3}),jsx(xe,{width:6,height:6,radius:3})]}),jsx(xe,{width:46,height:12,radius:6,style:t.centered}),jsx(View,{style:t.inset,children:jsx(xe,{width:"100%",height:Kl,radius:12})}),jsxs(View,{style:[t.inset,t.actions],children:[r("a"),r("b")]})]})}i(po,"DashboardSkeleton");function mo({testID:e}){let t=xn();return jsxs(View,{style:t.request,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:he.loading,testID:e,children:[jsx(View,{children:[0,1,2,3].map(r=>jsxs(View,{style:t.railRow,children:[jsxs(View,{style:t.railColumn,children:[jsx(xe,{width:uo,height:uo,radius:uo/2}),r<3?jsx(xe,{width:2,height:20,radius:1,style:t.connector}):null]}),jsxs(View,{style:t.railBody,children:[jsx(xe,{width:"55%",height:14,radius:7}),jsx(xe,{width:"75%",height:11,radius:6})]})]},r))}),jsxs(View,{style:t.statusCard,children:[jsx(xe,{width:"90%",height:13,radius:6}),jsx(xe,{width:"60%",height:13,radius:6})]}),jsx(xe,{width:"100%",height:50,radius:25})]})}i(mo,"RequestSkeleton");function Ql({testID:e}){let t=xn();return jsxs(View,{style:t.timeline,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:be.loadingTimeline,testID:e,children:[jsx(View,{style:t.timelineDisclaimer,children:jsx(xe,{width:"100%",height:Kl,radius:12})}),Array.from({length:Wm},(r,o)=>jsxs(View,{children:[o>0?jsx(View,{style:t.timelineSeparator}):null,jsxs(View,{style:t.timelineRow,children:[jsx(xe,{width:ji,height:ji,radius:ji/2}),jsxs(View,{style:t.timelineBody,children:[jsxs(View,{style:t.timelineTop,children:[jsx(xe,{width:44,height:10,radius:5}),jsx(xe,{width:56,height:12,radius:6})]}),jsx(xe,{width:"70%",height:14,radius:7}),o%2===0?jsx(xe,{width:"45%",height:12,radius:6}):null]})]})]},o))]})}i(Ql,"TimelineSkeleton");function Xl({testID:e}){let t=xn();return jsx(View,{style:t.clinics,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:Ce.loading,testID:e,children:Array.from({length:Gm},(r,o)=>jsxs(View,{style:t.clinicRow,children:[jsx(xe,{width:"65%",height:14,radius:7}),jsx(xe,{width:"40%",height:11,radius:6})]},o))})}i(Xl,"ClinicsSkeleton");function Jl({testID:e}){let t=xn();return jsx(View,{style:t.shares,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:ae.loadingLinks,testID:e,children:[0,1].map(r=>jsxs(View,{style:t.shareRow,children:[jsx(xe,{width:"55%",height:13}),jsx(xe,{width:"40%",height:11})]},r))})}i(Jl,"SharesSkeleton");var $i=62;function xn(){let e=V();return useMemo(()=>Ym(e),[e])}i(xn,"useStyles");function Ym(e){let{color:t,space:r,radius:o}=e,n=StyleSheet.hairlineWidth;return StyleSheet.create({dashboard:{flex:1,paddingHorizontal:r.sm,paddingTop:r.xs,gap:r.lg,backgroundColor:t.background},inset:{paddingHorizontal:r.sm},summaryCard:{alignItems:"center",borderRadius:o.lg-r.xs,borderWidth:n,borderColor:t.brandBorder,backgroundColor:t.surface,paddingHorizontal:r.lg,paddingVertical:r.lg+r.xs,gap:r.md+r.xs/2},badges:{flexDirection:"row",gap:r.md},carouselCard:{borderRadius:o.lg-r.xs,borderWidth:n,borderColor:t.brandBorder,backgroundColor:t.surface,padding:r.lg},dots:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:r.xs+r.xs/2},centered:{alignSelf:"center"},actions:{gap:r.sm+r.xs/2},actionRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",borderRadius:o.md,borderWidth:n,borderColor:t.brandBorder,backgroundColor:t.surface,paddingHorizontal:r.lg,paddingVertical:r.lg},actionLeft:{flex:1,flexDirection:"row",alignItems:"center",gap:r.md},request:{paddingHorizontal:r.lg,paddingTop:r.xs,gap:r.lg+r.xs/2,backgroundColor:t.background},railRow:{flexDirection:"row",alignItems:"flex-start",gap:r.md},railColumn:{alignItems:"center",width:uo},connector:{marginVertical:r.xs/2},railBody:{flex:1,paddingBottom:r.lg+r.xs/2,gap:r.xs+r.xs/2},statusCard:{borderRadius:o.md,backgroundColor:t.brandSoft,padding:r.md+r.xs/2,gap:r.sm},timeline:{flex:1,backgroundColor:t.background},timelineDisclaimer:{paddingHorizontal:r.lg,paddingTop:r.xs,paddingBottom:r.md},timelineRow:{flexDirection:"row",gap:r.md,paddingHorizontal:r.lg,paddingVertical:r.md+r.xs/2},timelineBody:{flex:1,gap:r.xs-1},timelineTop:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},timelineSeparator:{height:n,backgroundColor:t.brandBorder,marginLeft:$i},clinics:{gap:r.md},clinicRow:{borderRadius:o.lg-r.xs/2,borderWidth:n,borderColor:t.brandBorder,backgroundColor:t.surface,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md+r.xs/2,gap:r.sm},shares:{gap:r.md,padding:r.md,borderRadius:o.md,backgroundColor:t.surfaceCream,borderWidth:n,borderColor:t.brandBorder},shareRow:{gap:r.xs+r.xs/2}})}i(Ym,"makeStyles");var ey=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function Wi(e){let{userRef:t,scopeEpoch:r}=Te();return jsx(Ve,{capability:"recordsClinic",style:e.style,...Fe(e.onBack,Ye),children:t===null?jsx(m,{accessibilityRole:"alert",children:ye.sessionRequired}):jsx(ty,{...Le(e,["onNavigate","onBack"])},JSON.stringify([t,r,e.petRef]))})}i(Wi,"EverfurClinicPicker");function ty({petRef:e,controller:t,recordsController:r,location:o,onNavigate:n,onBack:a,style:l}){let c=me(),s=ny(),d=V(),u=Ut(),p=dl(t??u,o),f=st(r?{petRef:e,controller:r}:{petRef:e}),b=useRef(lr()),[R,v]=useState(false),[w,g]=useState(null),[y,x]=useState(false),[h,P]=useState(""),[S,E]=useState(false),[C,I]=useState(""),[F,q]=useState(false),j=useCallback(L=>{n?.({name:"consent",clinic:Di(L,null,"",b.current())});},[n]),$=i(()=>{R||(v(true),g(null),f.createRequest(`records-upload-${Date.now().toString(36)}`).then(L=>{if(v(false),!L.ok){g(he.errors.start);return}n?.({name:"request",requestId:L.value.id});}));},"startUpload"),ce=S?h:p.query,oe=ey.test(C.trim()),ve=ce.trim().length>0&&oe,ie=i(L=>{let{layoutMeasurement:B,contentOffset:H,contentSize:O}=L.nativeEvent;B.height+H.y>=O.height-B.height*.6&&p.loadMore();},"onEndReached"),T=p.isSearchActive?p.clinics:p.recent,D=p.isSearchActive?p.error?mt(p.error):!p.initialLoading&&p.clinics.length===0?"idle":null:p.recent.length>0||p.recentLoading?null:"idle";return jsxs(View,{style:[c.root,l],children:[jsx(Ke,{title:Ce.title,onBack:a,testID:"records-clinic-header"}),jsxs(View,{style:s.searchBar,children:[jsx(View,{style:s.searchGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsx(He,{value:p.query,onChangeText:p.setQuery,placeholder:Ce.placeholder,placeholderTextColor:d.color.text.muted,autoCorrect:false,autoCapitalize:"words",returnKeyType:"search",maxLength:200,accessibilityLabel:Ce.searchA11y,style:s.searchInput,testID:"records-clinic-search-input"}),p.query.length>0?jsx(Pressable,{onPress:()=>p.setQuery(""),accessibilityRole:"button",accessibilityLabel:Ce.clearSearch,hitSlop:8,testID:"records-clinic-search-clear",children:jsx(m,{style:s.clearGlyph,children:"\xD7"})}):null]}),n?jsxs(View,{style:s.uploadWrap,children:[w?jsx(View,{style:c.errorBanner,accessibilityRole:"alert",children:jsx(m,{style:c.errorText,children:w})}):null,jsx(X,{label:R?Ce.uploadOwnStarting:Ce.uploadOwn,kind:"outline",accessibilityLabel:Ce.uploadOwnA11y,busy:R,onPress:$,testID:"records-clinic-upload-own"})]}):null,jsxs(ScrollView,{contentContainerStyle:s.list,keyboardShouldPersistTaps:"handled",onScroll:p.isSearchActive?ie:void 0,scrollEventThrottle:200,testID:"records-clinic-results",children:[p.isSearchActive?jsxs(View,{style:s.fallbackCard,testID:"records-clinic-fallback-card",children:[jsxs(Pressable,{onPress:()=>x(L=>!L),accessibilityRole:"button",accessibilityLabel:y?Ce.fallback.collapseA11y:Ce.fallback.expandA11y,style:s.fallbackHeader,testID:"records-clinic-fallback",children:[jsxs(View,{style:s.fallbackCopy,children:[jsx(m,{style:s.fallbackTitle,numberOfLines:1,children:Ce.fallback.title}),jsx(m,{style:s.fallbackSubtitle,numberOfLines:2,children:Ce.fallback.subtitle})]}),jsx(rr,{direction:y?"up":"down"})]}),y?jsxs(View,{style:s.fallbackForm,children:[jsx(m,{style:c.fieldLabel,children:Ce.fallback.nameLabel}),jsx(He,{accessibilityLabel:Ce.fallback.nameLabel,style:c.field,value:ce,onChangeText:L=>{P(L),E(true);},placeholder:Ce.fallback.namePlaceholder,placeholderTextColor:d.color.text.placeholder,autoCapitalize:"words",autoCorrect:false,maxLength:200,testID:"records-clinic-fallback-name"}),jsx(m,{style:c.fieldLabel,children:Ce.fallback.emailLabel}),jsx(He,{accessibilityLabel:Ce.fallback.emailLabel,style:c.field,value:C,onChangeText:L=>{I(L),q(false);},onBlur:()=>q(true),placeholder:Ce.fallback.emailPlaceholder,placeholderTextColor:d.color.text.placeholder,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,maxLength:320,testID:"records-clinic-fallback-email"}),F&&C.trim().length>0&&!oe?jsx(m,{style:c.errorText,accessibilityRole:"alert",children:he.errors.invalidEmail}):null,jsx(m,{style:c.muted,children:Ce.fallback.reviewNote}),jsx(X,{label:Ce.fallback.submit,accessibilityLabel:Ce.fallback.submitA11y,disabled:!ve||!n,onPress:()=>n?.({name:"consent",clinic:Di(null,ce.trim(),C.trim().toLowerCase(),b.current())}),testID:"records-clinic-fallback-submit"})]}):null]}):p.recent.length>0?jsx(m,{style:s.sectionLabel,accessibilityRole:"header",testID:"records-clinic-recent-label",children:Ce.recentlyUsed}):null,p.isSearchActive&&p.initialLoading?jsx(Xl,{testID:"records-clinic-page-loading"}):null,T.map(L=>jsx(ry,{clinic:L,onSelect:j,styles:s},L.id)),D&&!p.initialLoading?jsx(Ue,{variant:D,message:p.isSearchActive&&D==="idle"?Ce.noMatch(p.debouncedQuery):p.error?.displayMessage,onAction:p.error?.retryable===true?p.retry:void 0,testID:"records-clinic-empty"}):null,jsxs(View,{style:s.footer,children:[p.loadingMore?jsxs(View,{style:s.footerLoading,testID:"records-clinic-loading-more",children:[jsx(ActivityIndicator,{color:d.color.brandInk,size:"small"}),jsx(m,{style:c.muted,children:Ce.loadingMore})]}):null,p.pageError?jsx(Pressable,{onPress:p.loadMore,accessibilityRole:"button",accessibilityLabel:Ce.loadMoreRetryA11y,style:s.footerRetry,testID:"records-clinic-page-error-retry",children:jsx(m,{style:s.footerRetryLabel,children:Ce.loadMoreFailed})}):null]})]}),jsx(qe,{})]})}i(ty,"PickerBody");function ry({clinic:e,onSelect:t,styles:r}){let o=el(e.emailStatus),n=tl(e.distanceKm),a=[e.name,e.address,e.phone?`phone ${e.phone}`:null,n?rl(e.distanceKm):null,o.a11y].filter(Boolean).join(", ");return jsxs(Pressable,{onPress:()=>t(e),accessibilityRole:"button",accessibilityLabel:Ce.selectA11y(a),hitSlop:8,style:r.item,testID:`records-clinic-${e.id}`,children:[jsxs(View,{style:r.itemHeader,children:[jsx(m,{style:r.itemName,numberOfLines:1,children:e.name}),n?jsx(m,{style:r.itemDistance,accessibilityElementsHidden:true,importantForAccessibility:"no",children:n}):null]}),e.address?jsx(m,{style:r.itemAddress,numberOfLines:2,children:e.address}):null,e.phone?jsx(m,{style:r.itemPhone,numberOfLines:1,accessibilityElementsHidden:true,importantForAccessibility:"no",children:e.phone}):null,jsx(View,{style:[r.badge,o.tone==="positive"?r.badgePositive:o.tone==="caution"?r.badgeCaution:r.badgeNeutral],accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsx(m,{style:[r.badgeLabel,o.tone==="positive"?r.badgePositiveText:o.tone==="caution"?r.badgeCautionText:r.badgeNeutralText],children:o.label})})]})}i(ry,"ClinicRow");function ny(){let e=V();return useMemo(()=>oy(e),[e])}i(ny,"useLocalStyles");function oy(e){let{color:t,space:r,radius:o,type:n}=e,a=StyleSheet.hairlineWidth,l=i((c,s,d,u="regular")=>({...k(e,u),fontSize:c,lineHeight:Math.round(c*s),color:d}),"text");return StyleSheet.create({searchBar:{flexDirection:"row",alignItems:"center",gap:r.sm,paddingHorizontal:r.md+r.xs/2,height:r.xxl+r.md,marginHorizontal:r.lg,marginBottom:r.sm,borderRadius:o.lg+r.xs/2,backgroundColor:t.surfaceSubtle,borderWidth:a,borderColor:t.borderHairlineGreen},searchGlyph:{width:r.md,height:r.md,borderRadius:o.pill,borderWidth:2,borderColor:t.text.muted},searchInput:{flex:1,...l(n.size.body,n.lineHeight.snug,t.text.primary),paddingVertical:0},clearGlyph:l(n.size.heading,n.lineHeight.tight,t.text.muted),uploadWrap:{paddingHorizontal:r.lg,paddingBottom:r.md,gap:r.sm},list:{paddingHorizontal:r.lg,paddingBottom:r.xxl,gap:r.md},sectionLabel:{...l(n.size.caption,n.lineHeight.normal,t.text.secondary,"bold"),textTransform:"uppercase",letterSpacing:n.letterSpacing.eyebrow/2},fallbackCard:{borderRadius:o.lg-r.xs/2,borderWidth:1,borderStyle:"dashed",borderColor:t.brandBorder,backgroundColor:t.surfaceCream,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md,gap:r.md},fallbackHeader:{flexDirection:"row",alignItems:"center",gap:r.md,minHeight:r.xxl+r.md},fallbackCopy:{flex:1,gap:r.xs/2},fallbackTitle:{...l(n.size.body,n.lineHeight.snug,t.text.primary,"bold")},fallbackSubtitle:l(n.size.caption,n.lineHeight.normal,t.text.muted),fallbackForm:{gap:r.sm},item:{borderRadius:o.lg-r.xs/2,borderWidth:a,borderColor:t.brandBorder,backgroundColor:t.surface,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md,gap:r.sm},itemHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},itemName:{flex:1,...l(n.size.body,n.lineHeight.snug,t.brandInk,"bold")},itemDistance:{...k(e,"mono"),fontSize:n.size.tiny,lineHeight:n.size.body,color:t.text.muted},itemAddress:l(n.size.caption,n.lineHeight.normal,t.text.primary),itemPhone:l(n.size.caption,n.lineHeight.normal,t.text.muted),badge:{alignSelf:"flex-start",borderRadius:o.pill,paddingHorizontal:r.sm+1,paddingVertical:r.xs},badgePositive:{backgroundColor:t.badgeBgPositive},badgeCaution:{backgroundColor:t.badgeBgCaution},badgeNeutral:{backgroundColor:t.badgeBgNeutral},badgeLabel:{...l(n.size.micro,n.lineHeight.snug,t.text.muted,"bold")},badgePositiveText:{color:t.success},badgeCautionText:{color:t.cautionAccent},badgeNeutralText:{color:t.text.muted},footer:{gap:r.sm,paddingTop:r.sm},footerLoading:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:r.sm,minHeight:r.xxl+r.md},footerRetry:{minHeight:r.xxl+r.md,alignItems:"center",justifyContent:"center"},footerRetryLabel:{...l(n.size.bodyTight,n.lineHeight.snug,t.brandInk,"bold")}})}i(oy,"makeLocalStyles");var Me=Object.freeze({title:"Request records",resultTitle:"Request status",addClinic:"Add a clinic",atCap:`Up to ${Gr} clinics`,sendA11y:i(e=>e===1?"Send 1 records request":`Send ${e} records requests`,"sendA11y"),send:i(e=>`Send ${e} ${e===1?"request":"requests"}`,"send"),sending:"Sending\u2026",addToContinue:"Add a clinic to continue",tryAgain:"Try again",remove:i(e=>`Remove ${e}`,"remove"),emailToAdd:"Email to add",perClinic:"Per-clinic result",sent:"Sent",notSent:"Not sent",allFailed:"We couldn\u2019t send any of these requests. See the details below and try again.",partial:i((e,t,r)=>`${e} of ${t} requests sent. ${r} couldn\u2019t be sent.`,"partial"),allSent:i(e=>`${e} ${e===1?"request":"requests"} sent.`,"allSent"),responded:i((e,t)=>`${e} of ${t} ${t===1?"clinic":"clinics"} responded`,"responded")});function Cn(e,t,r,o){let n={owner_name:t,pet_name:r,clinic_name:o},a=false,l=e.scopeTemplate.replace(/\{([^{}]+)\}/g,(c,s)=>Object.prototype.hasOwnProperty.call(n,s)?n[s]??"":(a=true,""));return a||/[{}]/.test(l)?null:l}i(Cn,"renderClinicScope");function En(e){return e===null||e.emailStatus!=="verified"&&e.emailStatus!=="unverified"}i(En,"clinicNeedsEmail");function ec(e,t,r){let[o,n]=useState(e.ownerName),[a,l]=useState(""),[c,s]=useState(null),[d,u]=useState(""),[p,f]=useState([]),[b,R]=useState([]),[v,w]=useState(null),[g,y]=useState(null),[x,h]=useState(false),[P,S]=useState(false),[E,C]=useState(null),[I,F]=useState(0),q=useRef(false),j=useRef(false),$=useRef(0),ce=useRef(lr()),oe=useRef(null),ve=useRef(null),ie=useRef(0);useEffect(()=>(q.current=true,j.current=false,h(false),()=>{q.current=false,ie.current+=1,$.current+=1,oe.current=null,ve.current?.abort();}),[t]),useEffect(()=>{let re=true;return w(null),oe.current=null,t.getAuthorizationCopy().then(Ee=>{re&&(Ee.ok?(w(Ee.value),y(null)):y(Ee.error));}).catch(()=>{re&&y(N("internalError"));}),()=>{re=false;}},[t,I]),useEffect(()=>{let re=true;return R([]),t.recentClinics({limit:5}).then(Ee=>{re&&Ee.ok&&R(Ee.value.clinics);}).catch(()=>{}),()=>{re=false;}},[t]);let T=i(()=>{oe.current=null,y(null);},"invalidate"),D=c?.name??a.trim(),L=v?Cn(v,o.trim(),e.petName,D):null,B=En(c),H=!!(v&&L&&o.trim()&&e.petName.trim()&&D&&(!B||/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(d.trim()))&&r),O=i(async()=>{if(j.current)return;let re=++$.current;S(true);try{let Ee=await t.searchClinics({query:a.trim(),limit:100});if(!q.current||re!==$.current)return;Ee.ok?(f(Ee.value.clinics),y(null)):y(Ee.error);}catch{q.current&&re===$.current&&y(N("internalError"));}finally{q.current&&re===$.current&&S(false);}},"search"),se=i(async()=>{if(j.current||E||!H||!v||!L||!r)return;j.current=true;let re=ie.current,Ee=i(()=>q.current&&ie.current===re,"current");h(true),y(null);try{if(!oe.current){ve.current=new AbortController;let rt=await r({petRef:e.petRef,petName:e.petName,ownerName:o.trim(),clinicName:D,authorizationVersion:v.authorizationVersion,scopeText:L,signal:ve.current.signal});if(!Ee()||rt===null)return;let Nt=c&&(!B||c.emailStatus==="none")?{clinicId:c.id}:{clinicFreeText:D};oe.current={petRef:e.petRef,ownerName:o.trim(),authorizationVersion:v.authorizationVersion,...Nt,...B?{clinicEmail:d.trim().toLowerCase()}:{},...rt.signatureId!==void 0?{signatureId:rt.signatureId}:{signaturePngBase64:rt.signaturePngBase64},idempotencyKey:ce.current()};}if(!Ee())return;let Ct=await t.createClinicRequest(oe.current);if(!Ee())return;if(!Ct.ok){y(Ct.error);return}if(Ct.value.petRef!==e.petRef){y(N("internalError"));return}C(Ct.value),oe.current=null,e.onCreated?.(Ct.value);}catch{Ee()&&y(N("internalError"));}finally{j.current=false,Ee()&&h(false);}},"submit");return {ownerName:o,query:a,clinic:c,email:d,clinics:p,copy:v,scope:L,error:g,busy:x,searching:P,created:E,ready:H,needsEmail:B,recent:p.length===0&&c===null?b:[],setOwnerName(re){j.current||(T(),n(re));},setQuery(re){j.current||(T(),$.current+=1,S(false),f([]),s(null),u(""),l(re));},setEmail(re){j.current||(T(),u(re));},selectClinic(re){j.current||(T(),$.current+=1,S(false),f([]),s(re),l(re.name),u(""));},invalidate:T,search:O,submit:se,retryCopy(){y(null),F(re=>re+1);}}}i(ec,"useClinicRequestForm");var iy=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function kn(e){return e.clinic?.name??e.freeText??""}i(kn,"draftName");function Sn(e){return En(e.clinic)}i(Sn,"draftNeedsEmail");function tc(e,t,r,o,n){let[a,l]=useState(e.ownerName),[c,s]=useState(""),[d,u]=useState([]),[p,f]=useState([]),[b,R]=useState([]),[v,w]=useState(null),[g,y]=useState(null),[x,h]=useState(false),[P,S]=useState(false),[E,C]=useState(null),[I,F]=useState(null),[q,j]=useState(0),$=useRef(false),ce=useRef(false),oe=useRef(0),ve=useRef(0),ie=useRef(lr()),T=useRef(null),D=useRef(null);useEffect(()=>($.current=true,ce.current=false,h(false),()=>{$.current=false,ve.current+=1,oe.current+=1,T.current=null,D.current?.abort();}),[t,r]),useEffect(()=>{let M=true;return w(null),T.current=null,t.getAuthorizationCopy().then(we=>{M&&(we.ok?(w(we.value),y(null)):y(we.error));}).catch(()=>{M&&y(N("internalError"));}),()=>{M=false;}},[t,q]),useEffect(()=>{let M=true;return f([]),t.recentClinics({limit:5}).then(we=>{M&&we.ok&&f(we.value.clinics);}).catch(()=>{}),()=>{M=false;}},[t]);let L=i(()=>{T.current=null,y(null);},"invalidate"),B=b.map(kn),H=v?B.map(M=>Cn(v,a.trim(),e.petName,M)):[],O=H.every(M=>M!==null)?H.join(`
1
+ import {createContext,forwardRef,useRef,useMemo,useState,useCallback,useEffect,useReducer,createElement,useContext,useSyncExternalStore,Component}from'react';import {z}from'zod';import {TextInput,View,Pressable,ScrollView,ActivityIndicator,StyleSheet,PanResponder,KeyboardAvoidingView,Image,BackHandler,Text,Modal,AccessibilityInfo,Linking,Share,Platform,RefreshControl}from'react-native';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var Mu=Object.defineProperty;var i=(e,t)=>Mu(e,"name",{value:t,configurable:true});var gi=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(gi.map(e=>e.wireCode));var Hu=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"}),Ta=Object.freeze(gi.map(e=>Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:Hu[e.wireCode]}))),Bu=new Map(Ta.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),Uu=Object.freeze(["http_envelope",...[...new Set(Ta.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function Kn(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let o of [t??"http_envelope",...Uu]){let n=Bu.get(o+r);if(n)return n}}i(Kn,"contractErrorFor");function ju(e){return e.envelope==="sse_frame"?`/errors#sse-${e.wireCode}`:e.envelope==="oauth_error"?`/errors#oauth-${e.wireCode}`:`/errors#${e.wireCode}`}i(ju,"contractDocUrl");function ka(e){return null}i(ka,"publishedDocUrl");var $u=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 _a(e){return $u[e]}i(_a,"categoryFor");function Pa(e){let t=Kn(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),o=r.replace(/[^A-Z0-9]/g,"");if(o==="AUTHREJECTED")return "authRejected";if(r.startsWith("AUTH"))return "authExpired";switch(o){case "DAILYQUOTAEXCEEDED":case "QUOTAEXCEEDED":return "quotaExceeded";case "RATELIMITED":case "TOOMANYREQUESTS":case "TELEVETRATELIMITED":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(Pa,"fromWire");var Wu=new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function bi(e){return Wu.has(e)}i(bi,"isAutoRetryable");var Gu=new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function Ia(e){return bi(e)||Gu.has(e)}i(Ia,"isRetryableCode");var Yu=500,hi=8e3,Da=4;function Aa(e,t=Math.random){let r=Math.max(0,e),o=Math.min(Yu*2**r,hi);return Math.floor(t()*o)}i(Aa,"backoffDelayMs");var Ku=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 Ri(e){return Ku[e]}i(Ri,"userFacingError");function Oa(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false});}i(Oa,"defineHidden");var Qu=/^[a-z][a-z0-9_]{0,63}$/;function W(e,t){let r=Kn(t?.wireCode,t?.wireEnvelope),o={code:e,category:_a(e),retryable:t?.retryable??Ia(e),displayMessage:Ri(e)};if(t?.httpStatus!==void 0&&(o.httpStatus=t.httpStatus),t?.requestId&&(o.requestId=t.requestId),typeof t?.reasonCode=="string"&&Qu.test(t.reasonCode)&&(o.reasonCode=t.reasonCode),r);return t?.wireMessage&&Oa(o,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&Oa(o,"raw",t.raw),Object.freeze(o)}i(W,"makeEverfurError");function Ve(e,t){return Object.freeze(t===void 0?{ok:true,value:e}:{ok:true,value:e,warning:t})}i(Ve,"ok");function te(e){return Object.freeze({ok:false,error:e})}i(te,"err");var Qn=class Qn extends Error{constructor(t,r){super(r),this.name="EverfurConfigError",this.kind=t,Object.setPrototypeOf(this,Qn.prototype);}};i(Qn,"EverfurConfigError");var bn=Qn;var Zr=Object.freeze(["vet","groomer","boarding"]),Xu=z.string().min(1).refine(e=>e.startsWith("https://")),Jr=z.string().nullish(),vi=z.unknown().optional(),Ju=z.object({share_id:z.string().min(1),share_url:z.string().min(1),expires_at:Jr,audience:vi}),Zu=z.object({shares:z.array(z.object({share_id:z.string().min(1),expires_at:Jr,created_at:Jr,view_count:z.number().int().nonnegative().nullish(),last_viewed_at:Jr,audience:vi})).optional()}),ep=z.object({download_url:Xu,expires_at:Jr}),tp=z.object({share_id:z.string().min(1),expires_at:Jr,audience:vi}),rp=z.object({audience:z.string().min(1),sections:z.array(z.string()),entity_types:z.array(z.string()).nullable()}),wi=254;function Xn(e){let t=e.trim();return t.length>0&&t.length<=wi&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(t)}i(Xn,"isShareRecipientEmail");var La=i(e=>typeof e=="string"&&Zr.includes(e),"isAudience");function xi(e){return La(e)?e:null}i(xi,"audienceOf");function Va(e){let t=z.array(rp).safeParse(e);if(!t.success)return Object.freeze([]);let r=new Set,o=[];for(let n of t.data)!La(n.audience)||r.has(n.audience)||(r.add(n.audience),o.push(Object.freeze({audience:n.audience,sections:Object.freeze([...n.sections]),entityTypes:n.entity_types===null?null:Object.freeze([...n.entity_types])})));return Object.freeze(o)}i(Va,"mapShareAudiences");function np(e,t){let r=e.trim();if(r.length===0)return null;try{let o=/^[a-z][a-z0-9+.-]*:/i.test(r)?new URL(r):t!==void 0?new URL(r,t):null;return o===null||o.protocol!=="https:"?null:o.toString()}catch{return null}}i(np,"resolveShareUrl");function Fa(e,t){let r=Ju.safeParse(e);if(!r.success)return null;let o=np(r.data.share_url,t);return o===null?null:Object.freeze({shareId:r.data.share_id,shareUrl:o,expiresAt:r.data.expires_at??null,audience:xi(r.data.audience)})}i(Fa,"mapRecordShareLink");function qa(e){let t=Zu.safeParse(e);return t.success?Object.freeze((t.data.shares??[]).map(r=>Object.freeze({shareId:r.share_id,expiresAt:r.expires_at??null,createdAt:r.created_at??null,viewCount:r.view_count??0,lastViewedAt:r.last_viewed_at??null,audience:xi(r.audience)}))):null}i(qa,"mapRecordShareList");function za(e){let t=tp.safeParse(e);return t.success?Object.freeze({shareId:t.data.share_id,expiresAt:t.data.expires_at??null,audience:xi(t.data.audience)}):null}i(za,"mapRecordShareEmailReceipt");function Na(e){let t=ep.safeParse(e);return t.success?Object.freeze({downloadUrl:t.data.download_url,expiresAt:t.data.expires_at??null}):null}i(Na,"mapRecordPdfLink");var Ci="application/pdf",Ma=Object.freeze(["image/jpeg","image/png","image/heic","image/heif"]),Mt=Object.freeze({features:Object.freeze({}),uploadContentTypes:Object.freeze([Ci]),shareAudiences:Object.freeze([])}),op=z.object({features:z.record(z.boolean()),upload_content_types:z.array(z.string()).nullish(),share_audiences:z.unknown().optional()}),Ha=i(e=>Ma.includes(e),"isPhotoType");function Jn(e){let t=op.safeParse(e);if(!t.success)return Mt;let r=t.data.upload_content_types??[],o=Ma.filter(n=>r.includes(n));return Object.freeze({features:Object.freeze({...t.data.features}),uploadContentTypes:Object.freeze([Ci,...o]),shareAudiences:Va(t.data.share_audiences)})}i(Jn,"mapRecordsFeatures");function hn(e){return e!==void 0&&e.some(Ha)}i(hn,"acceptsPhotos");function Zn(e,t){return e===Ci||t!==void 0&&Ha(e)&&t.includes(e)}i(Zn,"isAcceptedUploadType");var Wa=new Set(["requested","awaiting_clinic","awaiting_upload","received","parsing","in_review","published","failed","revoked"]),Ba=Object.freeze({submitted:"requested",sent:"requested",dispatching:"requested",awaiting_response:"awaiting_clinic",clinic_responded_no_records:"awaiting_clinic",records_received:"received",parsing_failed:"in_review",review_email_failed:"in_review",clinic_declined:"failed"});function ip(e){let t=Object.prototype.hasOwnProperty.call(Ba,e)?Ba[e]:void 0;if(t!==void 0)return t;let r=e;return Wa.has(r)?r:"parsing"}i(ip,"normalizeStatus");function Ga(e){return e==="owner_reported"||e==="clinic_document"?e:null}i(Ga,"normalizeOrigin");var sp=z.object({request_id:z.string().min(1),pet_ref:z.string().min(1),status:z.string(),simple_status:z.string().nullish(),simple_status_detail:z.string().nullish(),status_label:z.string().optional(),dispatch_status:z.string().nullish(),can_retry_send:z.boolean().optional(),can_revoke:z.boolean().optional(),can_convert_to_upload:z.boolean().optional(),can_update_clinic_email:z.boolean().optional(),reminder_count:z.number().int().nonnegative().optional(),last_reminder_at:z.string().nullish(),waiting_expectation:z.string().nullish(),document_count:z.number().optional(),held_item_count:z.number().optional(),received_at:z.string().nullish(),parsing_started_at:z.string().nullish(),review_started_at:z.string().nullish(),created_at:z.string().optional(),updated_at:z.string().optional(),source:z.string().nullish().catch(null),action_needed_label:z.string().nullish().catch(null),failure_reason:z.string().nullish().catch(null),failure_code:z.string().nullish().catch(null),recovery_stage:z.string().nullish().catch(null),show_clinic_phone:z.boolean().optional().catch(void 0),clinic_name:z.string().nullish().catch(null),clinic_email:z.string().nullish().catch(null),clinic_phone:z.string().nullish().catch(null),converted_to_upload_at:z.string().nullish().catch(null),request_group_id:z.string().nullish().catch(null)}).passthrough();function Tr(e){let t=sp.safeParse(e);if(!t.success)return null;let r=t.data,o=lp(r.simple_status),n=o==="requested"&&(r.status==="awaiting_upload"||r.simple_status_detail==="awaiting_owner_upload")?"awaiting_upload":o==="parsing"&&(r.simple_status_detail==="in_review"||r.simple_status_detail==="review_email_failed")?"in_review":o??ip(r.status);return Object.freeze({id:r.request_id,petRef:r.pet_ref,status:n,simpleStatus:o,simpleStatusDetail:r.simple_status_detail??null,statusLabel:r.status_label??"",dispatchStatus:r.dispatch_status??null,canRetrySend:r.can_retry_send===true,canRevoke:r.can_revoke===true,canConvertToUpload:r.can_convert_to_upload===true,canUpdateClinicEmail:r.can_update_clinic_email===true,reminderCount:r.reminder_count??0,lastReminderAt:r.last_reminder_at??null,waitingExpectation:r.waiting_expectation??null,documentCount:ja(r.document_count,0),heldItemCount:ja(r.held_item_count,0),receivedAt:r.received_at??null,parsingStartedAt:r.parsing_started_at??null,reviewStartedAt:r.review_started_at??null,createdAt:r.created_at??"",updatedAt:r.updated_at??"",wireStatus:r.status,source:r.source??null,actionNeededLabel:r.action_needed_label??null,failureReason:r.failure_reason??null,failureCode:r.failure_code??null,recoveryStage:r.recovery_stage??null,showClinicPhone:r.show_clinic_phone===true,clinicName:r.clinic_name??null,clinicEmail:r.clinic_email??null,clinicPhone:r.clinic_phone??null,convertedToUploadAt:r.converted_to_upload_at??null,requestGroupId:r.request_group_id??null})}i(Tr,"mapRequestView");var ap=z.object({request_group_id:z.string().min(1),pet_ref:z.string().min(1),total:z.number().int().nonnegative(),responded:z.number().int().nonnegative(),pending:z.number().int().nonnegative(),members:z.array(z.unknown())});function Ya(e){let t=ap.safeParse(e);if(!t.success)return null;let r=t.data,o=Ei(r.members);return o.some(n=>n.petRef!==r.pet_ref)?null:Object.freeze({requestGroupId:r.request_group_id,petRef:r.pet_ref,total:r.total,responded:r.responded,pending:r.pending,members:o})}i(Ya,"mapRequestGroup");function lp(e){return !e||e==="awaiting_upload"||e==="in_review"?null:Wa.has(e)?e:null}i(lp,"normalizeSimpleStatus");function Ei(e){let t=Array.isArray(e)?e:[],r=[];for(let o of t){let n=Tr(o);n!==null&&r.push(n);}return Object.freeze(r)}i(Ei,"mapRequestList");var cp=z.object({source_doc_id:z.string().min(1),request_id:z.string().min(1)});function Ka(e){let t=cp.safeParse(e);return t.success?Object.freeze({documentId:t.data.source_doc_id,requestId:t.data.request_id,status:"received"}):null}i(Ka,"mapUploadedDocument");var dp=z.object({label:z.string(),value:z.string()}),Si=z.object({key:z.string(),category:z.string().optional(),label:z.string().optional(),value:z.string().nullish(),unit:z.string().nullish(),observed_at:z.string().nullish(),status:z.string().nullish(),origin:z.string().nullish(),canonical_key:z.string().nullish()}),up=z.object({at:z.string(),value:z.number().nullish(),display:z.string().nullish(),origin:z.string().nullish()}),pp=z.object({key:z.string(),label:z.string().optional(),points:z.array(up).optional()}),mp=z.object({title:z.string(),detail:z.string().nullish(),due_at:z.string().nullish()}),Ti=z.object({doc_id:z.string(),title:z.string().nullish(),page_count:z.number().nullish(),received_at:z.string().nullish()});function ki(e){return Object.freeze({key:e.key,category:e.category??"",label:e.label??e.key,value:e.value??null,unit:e.unit??null,observedAt:e.observed_at??null,status:e.status??null,origin:Ga(e.origin),canonicalKey:e.canonical_key??null})}i(ki,"mapEntityRow");function _i(e){return Object.freeze({docId:e.doc_id,title:e.title??null,pageCount:e.page_count??null,receivedAt:e.received_at??null})}i(_i,"mapDocumentRow");var yp=z.object({identity:z.array(dp).optional(),entities:z.array(Si).optional(),entity_series:z.array(pp).optional(),forward_looking:z.array(mp).optional(),documents:z.array(Ti).optional()});function Qa(e,t){let r=gp(t)?t:{},o=$a(r.schema_version,"epdf/1.0"),n=$a(r.disclaimer,""),l=typeof r.pet_ref=="string"&&r.pet_ref.length>0?r.pet_ref:e;if(r.withheld===true)return Ua(l,o,n);let a=yp.safeParse(r);if(!a.success)return Ua(l,o,n);let c=a.data,s=(c.identity??[]).map(w=>Object.freeze({label:w.label,value:w.value})),d=(c.entities??[]).map(ki),u=(c.entity_series??[]).map(w=>Object.freeze({key:w.key,label:w.label??w.key,points:Object.freeze((w.points??[]).map(R=>Object.freeze({at:R.at,value:R.value??null,display:R.display??null,origin:Ga(R.origin)})))})),m=(c.forward_looking??[]).map(w=>Object.freeze({title:w.title,detail:w.detail??null,dueAt:w.due_at??null})),y={};for(let w of c.documents??[])y[w.doc_id]=_i(w);let g=r.is_empty===true||s.length===0&&d.length===0&&u.length===0&&m.length===0&&Object.keys(y).length===0;return Object.freeze({petRef:l,schemaVersion:o,isEmpty:g,withheld:false,generatedAt:bp(r.generated_at),identity:Object.freeze(s),entities:Object.freeze(d),entitySeries:Object.freeze(u),forwardLooking:Object.freeze(m),documents:Object.freeze(y),disclaimer:n})}i(Qa,"mapRecordView");function Ua(e,t,r){return Object.freeze({petRef:e,schemaVersion:t,isEmpty:false,withheld:true,generatedAt:null,identity:Object.freeze([]),entities:Object.freeze([]),entitySeries:Object.freeze([]),forwardLooking:Object.freeze([]),documents:Object.freeze({}),disclaimer:r})}i(Ua,"withheldView");var fp=z.object({pet_ref:z.string().optional(),granted:z.boolean().optional(),version:z.string().nullish(),granted_at:z.string().nullish()});function eo(e,t){let r=fp.safeParse(t),o=r.success?r.data:{};return Object.freeze({petRef:typeof o.pet_ref=="string"&&o.pet_ref.length>0?o.pet_ref:e,granted:o.granted===true,version:o.version??null,grantedAt:o.granted_at??null})}i(eo,"mapConsent");function gp(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(gp,"isObject");function ja(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}i(ja,"numberOr");function $a(e,t){return typeof e=="string"&&e.length>0?e:t}i($a,"strOr");function bp(e){return typeof e=="string"&&e.length>0?e:null}i(bp,"strOrNull");var Xa=Object.freeze(["published","failed","revoked"]);function kr(e){return Xa.includes(e)}i(kr,"isTerminalStatus");function _r(e){if(e===null)return null;let t=e.recordsReason;return t==="consent_required"||t==="session_required"||t==="entitlement"||t==="pet_not_found"?t:null}i(_r,"recordsDenialReasonOf");var hp="records_consent_required";function Rp(e){let t=e.raw;if(t===null||typeof t!="object")return null;let r=t,o=typeof r.error=="object"&&r.error!==null?r.error.code:r.code;return typeof o=="string"&&o.length>0?o:null}i(Rp,"recordsWireCodeOf");function ar(e){return e===null||e.httpStatus!==409?false:Rp(e)===hp}i(ar,"isRecordsConsentRequired");var vp=Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function to(e){return e!==vp}i(to,"isUploadTransportAvailable");var Ja=Object.freeze({record(){}}),Pr=25*1024*1024,Za=64,Rn=128,Rt=128;var el=9e4;function rl(e){return new Pi(e)}i(rl,"createRecordsController");var Ii=class Ii{constructor(t){this.recordCache=new Map;this.consentEpoch=new Map;this.reportedGaps=new Set;this.features=Mt;this.repository=t.repository,this.uploads=t.uploads,this.telemetry=t.telemetry??Ja,this.newIdempotencyKey=t.newIdempotencyKey??Sp(),this.timers=t.timers??Cp,this.uploadDeadlineMs=t.uploadDeadlineMs??el;}async createUploadRequest(t){let r=await this.repository.createRequest({pet_ref:t.petRef,idempotency_key:t.idempotencyKey});if(!r.ok)return this.onRequestError(r.error);let o=Tr(r.value);return o===null?te(ro()):(this.observeRequest(o),Ve(o))}async getRequest(t){let r=await this.repository.getRequest(t);if(!r.ok)return this.onRequestError(r.error);let o=Tr(r.value);return o===null?te(ro()):(this.observeRequest(o),Ve(o))}async listRequests(){let t=await this.repository.listRequests();if(!t.ok)return this.onRequestError(t.error);let r=Ei(t.value);for(let o of r)this.observeRequest(o);return Ve(r)}async readFeatures(){let t=this.repository.getFeatures;if(t===void 0)return this.features=Mt;let r=Mt;try{let o=await t.call(this.repository);o.ok&&(r=Jn(o.value));}catch{}return this.features=r,r}async uploadDocument(t){let{requestId:r,file:o}=t,n=wp(o,this.features.uploadContentTypes);if(n!==null)return this.telemetry.record("records.upload.rejected",{reason:n}),te(tl(`upload rejected: ${n}`));let l=await this.repository.initiateUpload(r,{content_type:o.mimeType,file_size:o.sizeBytes});if(!l.ok)return this.onRequestError(l.error);let a=await this.postToS3(l.value,o,t);if(!a.ok)return this.telemetry.record("records.upload.failed",{reason:a.reason}),te(tl(a.reason));let c=await this.repository.completeUpload(r,{upload_id:l.value.upload_id});if(!c.ok)return c.error.code==="mediaUploadFailed"&&this.telemetry.record("records.upload.rejected",{reason:xp(c.error)??"corrupt"}),this.onRequestError(c.error);let s=Ka(c.value);return s===null?te(ro()):Ve(s)}async postToS3(t,r,o){let n=new AbortController,l=Ep(n.signal,o.signal),a=this.timers.setTimeout(()=>n.abort(),this.uploadDeadlineMs);try{let c={signal:l};return o.onProgress&&(c.onProgress=o.onProgress),await this.uploads.postMultipart(t,r,c),{ok:!0}}catch{return {ok:false,reason:n.signal.aborted&&o.signal?.aborted!==true?"timeout":"upload_error"}}finally{this.timers.clearTimeout(a);}}async getRecord(t){let r=this.consentEpoch.get(t)??0,o=await this.repository.getRecord(t);if(r!==(this.consentEpoch.get(t)??0))return te(Object.freeze({...W("accessDenied",{retryable:false}),recordsReason:"consent_required"}));if(!o.ok){let l=_r(o.error);return l==="consent_required"?(this.recordCache.delete(t),this.telemetry.record("records.consent.denied",{pet_ref:t})):l==="entitlement"&&this.telemetry.record("records.capability.denied",{pet_ref:t}),te(o.error)}let n=Qa(t,o.value);return n.petRef!==t?te(ro()):n.withheld?(this.telemetry.record("records.redaction.withheld",{pet_ref:t}),this.recordCache.delete(t),Ve(n)):(this.recordCache.set(t,n),Ve(n))}peekCachedRecord(t){return this.recordCache.get(t)??null}async getConsent(t){let r=await this.repository.getConsent(t);return r.ok?Ve(eo(t,r.value)):te(r.error)}async grantConsent(t){let r=await this.repository.putConsent(t.petRef,{consent_version:t.consentVersion,idempotency_key:t.idempotencyKey});return r.ok?Ve(eo(t.petRef,r.value)):(_r(r.error)==="entitlement"&&this.telemetry.record("records.capability.denied",{pet_ref:t.petRef}),te(r.error))}async revokeConsent(t){let r=await this.repository.deleteConsent(t);return r.ok?(this.consentEpoch.set(t,(this.consentEpoch.get(t)??0)+1),this.recordCache.delete(t),Ve(eo(t,r.value))):te(r.error)}reportCapabilityDenied(t){this.telemetry.record("records.capability.denied",t?{pet_ref:t}:{});}observeRequest(t){t.reviewStartedAt!==null&&!this.reportedGaps.has(t.id)&&(this.reportedGaps.add(t.id),this.telemetry.record("records.parse.gap",{request_id:t.id}));}onRequestError(t){return _r(t)==="entitlement"&&this.telemetry.record("records.capability.denied",{}),te(t)}};i(Ii,"RecordsControllerImpl");var Pi=Ii;function wp(e,t){if(!Zn(e.mimeType,t))return "unsupported_format";let r=e.sizeBytes;return typeof r!="number"||!Number.isFinite(r)||r<=0||r>Pr?"oversize":null}i(wp,"validateFile");function xp(e){let t=e.wireMessage;return t==="unsupported_format"||t==="oversize"||t==="corrupt"?t:null}i(xp,"reasonFromWire");function tl(e){return W("mediaUploadFailed",{retryable:false,wireMessage:e})}i(tl,"uploadFailed");function ro(){return W("internalError",{retryable:true})}i(ro,"internal");var Cp={setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout")};function Ep(e,t){if(!t)return e;let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),r.signal;let o=i(()=>r.abort(),"onAbort");return e.addEventListener("abort",o,{once:true}),t.addEventListener("abort",o,{once:true}),r.signal}i(Ep,"mergeSignals");function Sp(){let e=0;return ()=>`records-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,10)}`}i(Sp,"defaultIdempotencyFactory");function Ir(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}i(Ir,"assertNever");function nl(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(nl,"errorFrame");function _p(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(_p,"authHeaders");function vn(e,t){return {...e,headers:{...Pp(e.headers),..._p(t)}}}i(vn,"withAuthHeaders");function Pp(e){if(!e)return {};let t={};for(let[r,o]of Object.entries(e)){let n=r.toLowerCase();n==="authorization"||n==="x-everfur-partner-key"||(t[r]=o);}return t}i(Pp,"stripAuthHeaders");async function ol(e,t){if(t.mode==="anonymous")return t.transport.request(vn(e,{mode:"anonymous",publishableKey:t.publishableKey,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));let r;try{r=await t.identity.currentToken();}catch{return te(Di())}let o=await t.transport.request(vn(e,{mode:"personalized",token:r,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(o.ok||o.error.httpStatus!==401)return o;let n;try{n=await t.identity.currentToken({forceRefresh:!0});}catch{return te(Di())}let l=await t.transport.request(vn(e,{mode:"personalized",token:n,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return !l.ok&&l.error.httpStatus===401?te(Di(l.error.httpStatus)):l}i(ol,"authedSend");function Di(e){return W("authRejected",{retryable:false,...e!==void 0?{httpStatus:e}:{}})}i(Di,"authRejectedError");function il(e){return W("internalError",{retryable:true,wireMessage:Ip(e)})}i(il,"networkError");function Ip(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}i(Ip,"describeCause");var Dp=3e4,Ap=hi*2,Op="idempotency-key",Lp=new Set(["POST","PUT","PATCH","DELETE"]),Vp=Object.freeze({onEvent(){}}),Fp=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function qp(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}i(qp,"seededIdempotencyKey");function Dr(e){let t=e.observer??Vp,r=e.timers??Fp,o=e.rng??Math.random,n=e.sleep??((y,g)=>Qp(y,r,g)),l=e.maxAttempts??Da,a=e.unaryTimeoutMs??Dp,c=e.newIdempotencyKey??gr(),s=i(y=>{try{t.onEvent(y);}catch{}},"emit");async function d(y,g,w){let R=w?.maxAttempts,v=Math.max(1,R??l),f=w?.idempotent??Lp.has(g.method),b=w?.idempotencyKey===void 0?null:qp(w.idempotencyKey),C=f?b??c():null,h=zp(g,C),I=0;for(;;){let T=i(z=>Object.freeze({call:y,method:g.method,path:g.path,attempt:I,...C?{idempotencyKey:C}:{},...z}),"stamp");s(T({phase:"attempt"}));let k=Yp(a,r),_=Kp(k.signal,g.signal),E;try{E=await ol({...h,signal:_.signal},e.auth);}catch(z){E=te(il(z));}finally{_.dispose(),k.cancel();}if(E.ok)return s(T({phase:"settled",ok:true,reason:"ok"})),E;let B=E.error,x=Mp(B,I,{maxAttempts:v,rng:o,now:r.now(),aborted:g.signal?.aborted===true,...R!==void 0?{perCallMaxAttempts:R}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),A={ok:false,code:B.code,reason:x.reason,...B.httpStatus!==void 0?{httpStatus:B.httpStatus}:{},...B.requestId!==void 0?{requestId:B.requestId}:{}};if(!x.retry)return s(T({phase:"settled",...A})),te(B);if(s(T({phase:"retry",...A,delayMs:x.delayMs})),await n(x.delayMs,g.signal),g.signal?.aborted===true)return s(T({phase:"settled",...A,reason:"aborted"})),te(B);I+=1;}}i(d,"send");async function u(y){return vn(y,await Gp(e.auth))}i(u,"authorize");async function*m(y,g,w){s(Object.freeze({call:y,phase:"stream.open",method:g.method,path:g.path,attempt:0}));try{yield*e.auth.transport.stream(g,w);}catch{yield nl({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:null});}}return i(m,"stream"),Object.freeze({send:d,authorize:u,stream:m})}i(Dr,"createRequestFunnel");function zp(e,t){let r={};for(let[o,n]of Object.entries(e.headers??{}))o.toLowerCase()!==Op&&(r[o]=n);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}i(zp,"assembleHeaders");function gr(){let e=0;return ()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}i(gr,"defaultIdempotencyKeyFactory");var Np=10;function Mp(e,t,r){if(r.aborted)return {retry:false,reason:"aborted"};let o=Hp(e);if(o==="quota")return {retry:false,reason:"daily-quota-exhausted"};if(o!=="burst"&&!bi(e.code))return {retry:false,reason:"terminal-code"};let n=o==="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 a=i(()=>{if(r.policy===void 0)return null;let d;try{d=r.policy.maxAttempts(e.code);}catch{return null}return typeof d!="number"||!Number.isFinite(d)?null:Math.max(1,Math.min(Np,Math.floor(d)))},"policyCeiling"),c=r.perCallMaxAttempts??a()??r.maxAttempts;if(t+1>=c)return {retry:false,reason:"attempts-exhausted"};let s=Bp(e,r.now);return s!==null?s>Ap?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:n,delayMs:s}:{retry:true,reason:n,delayMs:Aa(t,r.rng)}}i(Mp,"decideRetry");function Hp(e){let t=e.code==="unknown"?Pa(Wp(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}i(Hp,"throttleKind");function Bp(e,t){let r=jp(e.raw);if(r!==null){let n=r-t;return n>0?n:0}let o=Up(e.raw);return o===null?null:Math.round(o*1e3)}i(Bp,"retryOverrideMs");function Up(e){for(let t of Ai(e)){let r=t.retry_after_seconds;if(typeof r=="number"&&Number.isFinite(r)&&r>=0)return r}return null}i(Up,"findRetryAfterSeconds");function jp(e){for(let t of Ai(e)){let r=t.resets_at,o=$p(r);if(o!==null)return o}return null}i(jp,"findResetsAt");function Ai(e){if(!sl(e))return [];let t=[e];for(let r of ["error","detail"]){let o=e[r];sl(o)&&t.push(o);}return t}i(Ai,"candidateScopes");function $p(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($p,"parseInstantMs");function Wp(e){for(let t of Ai(e)){let r=t.code;if(typeof r=="string"&&r.length>0)return r}return null}i(Wp,"rawWireCode");function sl(e){return typeof e=="object"&&e!==null}i(sl,"isRecord");async function Gp(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(Gp,"resolveDeviceAuth");function Yp(e,t){let r=new AbortController,o=t.setTimeout(()=>r.abort(),e);return {signal:r.signal,cancel:i(()=>t.clearTimeout(o),"cancel")}}i(Yp,"boundedSignal");function Kp(e,t){let r=i(()=>{},"noop");if(!t)return {signal:e,dispose:r};let o=new AbortController;if(e.aborted||t.aborted)return o.abort(),{signal:o.signal,dispose:r};let n=i(()=>o.abort(),"onAbort");return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),{signal:o.signal,dispose:i(()=>{e.removeEventListener("abort",n),t.removeEventListener("abort",n);},"dispose")}}i(Kp,"mergeSignals");function Qp(e,t,r){return e<=0||r?.aborted===true?Promise.resolve():new Promise(o=>{let n=t.setTimeout(()=>{r?.removeEventListener("abort",l),o();},e),l=i(()=>{t.clearTimeout(n),o();},"onAbort");r?.addEventListener("abort",l,{once:true});})}i(Qp,"delayAbortable");function br(e){for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let o=e.charCodeAt(t+1);if(!(o>=56320&&o<=57343))return true;t+=1;}else if(r>=56320&&r<=57343)return true}return false}i(br,"hasLoneSurrogate");var lr="/widget/v1/records";function ll(e){let{auth:t}=e,r=t.mode,o=e.funnel??Dr({auth:t,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),n=i(async(s,d,u)=>{let m=await o.send(s,d);return m.ok?m:te(Zp(m.error,r,u))},"send"),l=i((s,d)=>typeof d!="string"||d.length===0?W("validationFailed",{retryable:false,wireMessage:`${s} is required and must be a non-empty string`}):br(d)?W("validationFailed",{retryable:false,wireMessage:`${s} contains an unpaired surrogate and cannot be encoded`}):null,"segmentError"),a=i((s,d,u)=>{let m=l(s,d);if(m!==null)return m;let g=[...d].length;return g>u?W("validationFailed",{retryable:false,wireMessage:`${s} is ${g} characters; the server accepts at most ${u}`}):null},"boundsError"),c=i((...s)=>s.find(d=>d!==null)??null,"firstError");return {createRequest:i(s=>{let d=c(a("idempotency_key",s.idempotency_key,Rn),a("pet_ref",s.pet_ref,Rt));return d?Promise.resolve(te(d)):n("records.createRequest",Oi(`${lr}/requests`,s),"request")},"createRequest"),initiateUpload:i((s,d)=>{let u=l("request_id",s);return u?Promise.resolve(te(u)):n("records.initiateUpload",Oi(`${lr}/requests/${encodeURIComponent(s)}/uploads/initiate`,d),"request")},"initiateUpload"),completeUpload:i((s,d)=>{let u=l("request_id",s);return u?Promise.resolve(te(u)):n("records.completeUpload",Oi(`${lr}/requests/${encodeURIComponent(s)}/uploads/complete`,d),"request")},"completeUpload"),getRequest:i(s=>{let d=l("request_id",s);return d?Promise.resolve(te(d)):n("records.getRequest",wn(`${lr}/requests/${encodeURIComponent(s)}`),"request")},"getRequest"),listRequests:i(async()=>{let s=await n("records.listRequests",wn(`${lr}/requests`),"request");if(!s.ok)return s;let d=s.value;return {ok:true,value:Array.isArray(d)?d:d.items??[]}},"listRequests"),getRecord:i(s=>{let d=a("pet_ref",s,Rt);return d?Promise.resolve(te(d)):n("records.getRecord",wn(`${lr}/pets/${encodeURIComponent(s)}/record`),"content")},"getRecord"),getConsent:i(s=>{let d=a("pet_ref",s,Rt);return d?Promise.resolve(te(d)):n("records.getConsent",wn(`${lr}/pets/${encodeURIComponent(s)}/consent`),"consent")},"getConsent"),putConsent:i((s,d)=>{let u=c(a("consent_version",d.consent_version,Za),a("idempotency_key",d.idempotency_key,Rn),a("pet_ref",s,Rt));return u?Promise.resolve(te(u)):n("records.putConsent",em(`${lr}/pets/${encodeURIComponent(s)}/consent`,d),"consent")},"putConsent"),getFeatures:i(()=>n("records.getFeatures",wn(`${lr}/features`),"request"),"getFeatures"),deleteConsent:i(s=>{let d=a("pet_ref",s,Rt);return d?Promise.resolve(te(d)):n("records.deleteConsent",tm(`${lr}/pets/${encodeURIComponent(s)}/consent`),"consent")},"deleteConsent")}}i(ll,"createHttpRecordsRepository");function al(e,t){let r={...e,recordsReason:t};for(let o of ["wireMessage","raw"]){let n=Object.getOwnPropertyDescriptor(e,o);n!==void 0&&Object.defineProperty(r,o,n);}return Object.freeze(r)}i(al,"withReason");var Xp="pet_not_registered";function Jp(e){return e.httpStatus!==404?null:e.reasonCode===Xp?"pet_not_found":"entitlement"}i(Jp,"recordsErrorReasonFor");function Zp(e,t,r){let o=Jp(e);return o!==null?al(e,o):e.code!=="accessDenied"?e:al(e,t==="anonymous"?"session_required":r==="content"?"consent_required":"entitlement")}i(Zp,"tagReason");function wn(e){return {method:"GET",path:e}}i(wn,"get");function Oi(e,t){return {method:"POST",path:e,body:t}}i(Oi,"post");function em(e,t){return {method:"PUT",path:e,body:t}}i(em,"put");function tm(e){return {method:"DELETE",path:e}}i(tm,"del");var cl=Symbol.for("@everfur/sdk#EverfurContext@v1"),dl=globalThis,ul=dl[cl]??(dl[cl]=createContext(null));ul.displayName??="EverfurContext";function Te(){let e=useContext(ul);if(e===null)throw new bn("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}i(Te,"useEverfurContext");var Li=new Map,Vi=new Set;function pl(e){Li.set(e,(Li.get(e)??0)+1);for(let t of [...Vi])t();}i(pl,"notifyRecordsConsentWithdrawn");function sm(e){return Li.get(e)??0}i(sm,"recordsConsentEpochOf");function am(e){return Vi.add(e),()=>{Vi.delete(e);}}i(am,"subscribe");function no(e){let t=useCallback(()=>sm(e),[e]);return useSyncExternalStore(am,t,t)}i(no,"useRecordsConsentEpoch");var qi={record:null,requests:[],consent:null,error:null,denialReason:null,withheld:false,loading:true,isUploading:false,uploadProgress:null,uploadQueue:[],uploadContentTypes:Mt.uploadContentTypes},yl=4e3,cm=30;function mt(e){let{petRef:t}=e,r=useRef(e.uploadTransport);r.current=e.uploadTransport;let o=e.uploadTransport!==void 0,{runtime:n,userRef:l,scopeEpoch:a}=Te(),c=useMemo(()=>({}),[n,l,t,a,e.controller]),s=useRef(c),[d,u]=useState({scope:c,controller:e.controller??null}),m=e.controller??(d.scope===c?d.controller:null),[y,g]=useState({scope:c,value:qi}),w=y.scope===c?y.value:qi,R=useCallback(O=>{g(U=>U.scope===c?{scope:c,value:O(U.value)}:U);},[c]),v=useRef(0);useEffect(()=>(s.current=c,g({scope:c,value:qi}),()=>{s.current=null,v.current+=1;}),[c]),useEffect(()=>{if(e.controller)return;let{services:O}=n.registry,U={record:i((q,ee)=>O.telemetry.track(q,ee),"record")},D=n.registry.acquire("records",`${l??""}|${t}${o?"|own-upload":""}`,()=>rl({repository:ll({auth:O.authFor(l),...O.errorPolicy?{errorPolicy:O.errorPolicy}:{}}),uploads:o?{postMultipart:i((q,ee,J)=>(r.current??O.uploadTransport).postMultipart(q,ee,J),"postMultipart")}:O.uploadTransport,telemetry:U}),()=>{});return u({scope:c,controller:D}),()=>{n.registry.release(D);}},[n,l,t,e.controller,a,c,o]);let f=useCallback(O=>{R(U=>({...U,...O}));},[R]),b=useCallback(async()=>{if(!m||s.current!==c)return;let O=v.current+=1;k.current=0,B(),f({loading:true,error:null,denialReason:null,withheld:false});let[U,D]=await Promise.all([m.getConsent(t),m.listRequests()]);if(O!==v.current)return;let q=U.ok?U.value:null,ee=D.ok?D.value.filter(H=>H.petRef===t):[],J=D.ok?null:D.error;if(q&&q.granted){let H=await m.getRecord(t);if(O!==v.current)return;if(H.ok){f({consent:q,requests:ee,record:H.value,withheld:H.value.withheld,error:H.value.withheld?mm():J,denialReason:null,loading:false});return}f({consent:q,requests:ee,record:null,error:H.error,denialReason:_r(H.error),withheld:false,loading:false});return}f({consent:q,requests:ee,record:null,error:U.ok?J:U.error,denialReason:q?"consent_required":pm(U),withheld:false,loading:false});},[m,t,f,c]);useEffect(()=>(b(),()=>{v.current+=1;}),[b]);let C=e.readUploadFeatures===true;useEffect(()=>{if(!C||!m?.readFeatures)return;let O=true;return m.readFeatures().then(U=>{O&&s.current===c&&f({uploadContentTypes:U.uploadContentTypes});}),()=>{O=false;}},[m,C,f,c]);let h=useMemo(()=>um(w.requests),[w.requests]),I=h?.id??null,T=h?.status??null,k=useRef(0),_=useRef(null),[E,B]=useReducer(O=>O+1,0);useEffect(()=>{if(!m||I===null||T===null||kr(T)||T==="in_review")return;_.current!==String(I)&&(_.current=String(I),k.current=0);let O=false,U=i(async()=>{if(O||k.current>=cm)return;k.current+=1;let q=await m.getRequest(I);if(!O){if(q.ok&&q.value.petRef===t){if(R(ee=>({...ee,requests:oo(ee.requests,q.value)})),kr(q.value.status)){q.value.status==="published"&&b();return}if(q.value.status==="in_review")return}D=setTimeout(()=>{U();},yl);}},"tick"),D=setTimeout(()=>{U();},yl);return ()=>{O=true,clearTimeout(D);}},[m,I,T,b,E,t,R]);let x=useCallback(async O=>{if(!m||s.current!==c)return io();let U=await m.createUploadRequest({petRef:t,idempotencyKey:O});return s.current===c&&U.ok&&U.value.petRef===t&&R(D=>({...D,requests:oo(D.requests,U.value)})),U},[m,t,c,R]),A=useCallback((O,U)=>{R(D=>({...D,uploadQueue:D.uploadQueue.map(q=>q.key===O?U(q):q)}));},[R]),z=useCallback(async(O,U)=>{let D=Date.now().toString(36),q=U.map((J,H)=>{let N=fl(J,w.uploadContentTypes);return {key:`${D}-${H}`,name:J.name??null,status:N===null?"queued":"skipped",progress:0,skipReason:N,error:null}}),ee=[...q];if(!m||s.current!==c)return Object.freeze(ee);R(J=>({...J,uploadQueue:q,isUploading:true,uploadProgress:0}));for(let[J,H]of U.entries()){let N=q[J];if(N.status==="skipped")continue;if(s.current!==c)break;A(N.key,Le=>({...Le,status:"uploading",progress:0})),f({uploadProgress:0});let ie=await m.uploadDocument({requestId:O,file:H,onProgress:i(Le=>{if(s.current!==c)return;let rt=Math.min(1,Math.max(0,Le));A(N.key,Ee=>({...Ee,progress:Math.max(Ee.progress,rt)})),f({uploadProgress:rt});},"onProgress")});if(s.current!==c)break;let Ce=ie.ok?{...N,status:"done",progress:1}:{...N,status:"failed",error:ie.error};if(ee[J]=Ce,A(N.key,()=>Ce),ie.ok){let Le=await m.getRequest(O);s.current===c&&Le.ok&&Le.value.petRef===t&&R(rt=>({...rt,requests:oo(rt.requests,Le.value)}));}}return s.current===c&&f({isUploading:false,uploadProgress:null}),Object.freeze(ee)},[m,f,A,t,c,R,w.uploadContentTypes]),de=useCallback(async(O,U)=>{if(!m||s.current!==c)return io();let D=`${Date.now().toString(36)}-0`;R(ee=>({...ee,isUploading:true,uploadProgress:0,uploadQueue:[{key:D,name:U.name??null,status:"uploading",progress:0,skipReason:null,error:null}]}));let q=await m.uploadDocument({requestId:O,file:U,onProgress:i(ee=>{s.current===c&&(f({uploadProgress:ee}),A(D,J=>({...J,progress:Math.max(J.progress,Math.min(1,ee))})));},"onProgress")});if(s.current!==c)return q;if(f({isUploading:false,uploadProgress:null}),A(D,ee=>q.ok?{...ee,status:"done",progress:1}:{...ee,status:"failed",error:q.error}),q.ok){let ee=await m.getRequest(O);s.current===c&&ee.ok&&ee.value.petRef===t&&R(J=>({...J,requests:oo(J.requests,ee.value)}));}return q},[m,f,A,t,c,R]),G=useCallback(async(O,U)=>{if(!m||s.current!==c)return io();let D=await m.grantConsent({petRef:t,consentVersion:O,idempotencyKey:U});return D.ok&&s.current===c&&b(),D},[m,t,b,c]),ae=useCallback(async()=>{if(!m||s.current!==c)return io();let O=await m.revokeConsent(t);return O.ok&&pl(t),O.ok&&s.current===c&&(v.current+=1,f({record:null,withheld:false,loading:false,denialReason:"consent_required",consent:O.value})),O},[m,t,f,c]),M=useCallback(()=>b(),[b]),$=dm(w,m!==null);return useMemo(()=>({status:$,record:w.record,requests:w.requests,activeRequest:h,consent:w.consent,error:w.error,denialReason:w.denialReason,withheld:w.withheld,isUploading:w.isUploading,uploadProgress:w.uploadProgress,uploadQueue:w.uploadQueue,uploadContentTypes:w.uploadContentTypes,createRequest:x,uploadDocument:de,uploadDocuments:z,grantConsent:G,revokeConsent:ae,refresh:M}),[$,w,h,x,de,z,G,ae,M])}i(mt,"useEverfurRecords");function fl(e,t){if(!Zn(e.mimeType,t))return "unsupported";let r=e.sizeBytes;return typeof r!="number"||!Number.isFinite(r)||r<=0||r>Pr?"too_large":null}i(fl,"skipReasonFor");function gl(e,t){let r=[],o=[];for(let n of e){let l=fl(n,t);l===null?r.push(n):o.push({name:n.name??null,reason:l});}return {uploadable:r,skipped:o}}i(gl,"classifyPick");function dm(e,t){return e.loading||!t?"loading":e.withheld||e.denialReason!==null||e.error!==null?"error":e.record!==null&&!e.record.isEmpty||e.requests.length>0?"populated":"empty"}i(dm,"selectStatus");function um(e){if(e.length===0)return null;let t=e[0];for(let r of e)r.updatedAt>t.updatedAt&&(t=r);return t}i(um,"newestRequest");function oo(e,t){let r=e.filter(o=>o.id!==t.id);return [t,...r]}i(oo,"replaceRequest");function pm(e){return e.ok?"consent_required":_r(e.error)??"consent_required"}i(pm,"consentDenial");function mm(){return W("internalError",{retryable:false})}i(mm,"withheldSentinel");function io(){return {ok:false,error:W("internalError",{retryable:true})}}i(io,"notReady");function zi(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e);}catch{}}i(zi,"reportHostFailure");function ym(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(ym,"isThenable");function so(e,...t){if(typeof e=="function")try{let r=e(...t);return ym(r)&&Promise.resolve(r).then(void 0,zi),r}catch(r){zi(r);return}}i(so,"callHost");var bl=new WeakMap;function En(e){if(typeof e!="function")return;let t=bl.get(e);if(t!==void 0)return t;let r=i((...o)=>{so(e,...o);},"guarded");return bl.set(e,r),r}i(En,"guardHost");function Be(e,t){let r=null;for(let o of t){let n=e[o];typeof n=="function"&&(r??={...e},r[o]=En(n));}return r??e}i(Be,"guardHostProps");function Ar(e,...t){let r;try{r=e(...t);}catch(o){return zi(o),Promise.resolve({ok:false,error:o})}return Promise.resolve(r).then(o=>({ok:true,value:o}),o=>({ok:false,error:o}))}i(Ar,"callHostAsync");var hl=Object.freeze({name:"dashboard"});function ao(e=hl){return Object.freeze({stack:Object.freeze([e])})}i(ao,"initialRecordsNav");function lo(e){return e.stack[e.stack.length-1]??hl}i(lo,"currentRecordsScreen");function Ni(e,t){return Object.freeze({stack:Object.freeze([...e.stack,t])})}i(Ni,"pushRecordsNav");function Mi(e,t){return Object.freeze({stack:Object.freeze([...e.stack.slice(0,-1),t])})}i(Mi,"replaceRecordsNav");function Hi(e){return ao(e)}i(Hi,"resetRecordsNav");function co(e){return e.stack.length<=1?{state:e,handled:false}:{state:Object.freeze({stack:Object.freeze(e.stack.slice(0,-1))}),handled:true}}i(co,"popRecordsNav");function Rl(e,t){return t.name==="dashboard"?Hi(t):lo(e).name==="upload"&&t.name==="request"?Mi(e,t):Ni(e,t)}i(Rl,"transitionRecordsNav");function Bi(e,t){switch(t.type){case "push":return Ni(e,t.screen);case "pop":return co(e).state;case "replace":return Mi(e,t.screen);case "reset":return Hi(t.screen);case "navigate":return Rl(e,t.screen);default:return e}}i(Bi,"recordsNavReducer");function $i(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.keys(e))$i(e[t]);}return e}i($i,"deepFreeze");var fm=Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3}),wl={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},xl={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},vl={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},gm={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},bm={regular:"400",medium:"500",bold:"700"},hm={eyebrow:1,monoWide:.9,headerBrand:-0.42,tight:-0.35},Rm=0,uo="System",po="monospace",vm=["content","heading","control","compact","badge"];function wm(e){let t={};for(let r of vm)t[r]=e;return t}i(wm,"authoredTierSizes");function Cl(){return {family:uo,mono:po,fontUrl:null,families:{regular:uo,medium:uo,bold:uo,mono:po,monoMedium:po,monoBold:po},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:vl,tierSizes:wm(vl),lineHeight:gm,weight:bm,letterSpacing:hm,scale:1,maxScale:Rm,scaleCaps:fm}}i(Cl,"baseType");var El={},Ui=Object.freeze({standard:Object.freeze([.2,0,0,1]),emphasized:Object.freeze([.2,.8,.2,1]),exit:Object.freeze([.4,0,1,1])});function ji(e){return `cubic-bezier(${e.join(", ")})`}i(ji,"cssCubicBezier");var Sl={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:ji(Ui.standard),emphasized:ji(Ui.emphasized),exit:ji(Ui.exit)},reducedMotion:false},xm={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:"#FFFFFF",surfaceSubtle:"#F1F5F2",background:"#FFFFFF",borderRingCream:"#E4E4E4",chatGround:"#FFFFFF",composerFill:"#FFFFFF",composerBorder:"rgba(16,70,46,0.75)",shadow:"#0B3421",text:{primary:"#000000",secondary:"#0E462E",muted:"#6B6B6B",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:"#C03410",onDanger:"#FFFFFF",errorRed:"#C03410",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(192,52,16,0.06)",badgeBgNeutral:"rgba(107,107,107,0.12)",bubbleUser:"#10462E",bubbleAssistant:"#FFFFFF",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#E9F1E9",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)"},Tl=$i({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:xm,space:wl,radius:xl,type:Cl(),motion:Sl,slots:El}),Cm={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:"#9A9A9A",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",onDanger:"#0E1F17",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",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#23272C",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)"};$i({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:Cm,space:wl,radius:xl,type:Cl(),motion:Sl,slots:El});var kl=Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),_l=globalThis,Wi=_l[kl]??(_l[kl]=createContext(Tl));Wi.displayName??="EverfurThemeContext";function V(){return useContext(Wi)}i(V,"useEverfurTheme");function Pm(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}i(Pm,"tierMultiplier");function p({tier:e="content",...t}){let{type:r}=V(),o=Pm(r,e);return createElement(Text,o===void 0?t:{maxFontSizeMultiplier:o,...t})}i(p,"Text");var Qe=forwardRef(i(function(t,r){return createElement(TextInput,{...t,...r===null?{}:{ref:r}})},"TextInput"));var Im=Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function S(e,t){let r=e.type,o=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:o}:{fontFamily:o,fontWeight:r.weight[Im[t]]}}i(S,"face");var Z=Object.freeze({title:"Request records",clinic:"Clinic",search:"Search clinics by name or location",placeholder:"Clinic name, city, or ZIP",email:"Clinic email",emailPlaceholder:"records@clinic.com",ownerName:"Your full name",scopeHeading:"What you\u2019re authorizing",send:"Send request",sending:"Sending\u2026",cancel:"Cancel",sign:"Signature",draw:"Draw your signature",type:"Type your name to sign",toType:"Can\u2019t draw? Type your name instead",toDraw:"Draw your signature instead",clear:"Clear",drawHint:"Draw your signature in the box above.",clearA11y:"Clear signature",typedSignatureA11y:i(e=>`Typed signature: ${e}`,"typedSignatureA11y"),missingSignature:"Please add your signature before submitting.",recentlyUsed:"Recently used",moreClinics:"Load more"});var xe=Object.freeze({title:Z.title,titleFor:i(e=>{let t=e?.trim()??"";return t.length>0?`Request ${t}\u2019s records`:Z.title},"titleFor"),leadWeb:"Find the clinic that has them. We send a secure request and read every page they send back.",leadNative:"Find the clinic that has them.",searchLabelWeb:"Find the clinic",howItWorks:"How it works",howSteps:i(e=>[{title:"We send a secure request",body:"With your permission, straight to the clinic\u2019s records team."},{title:"The clinic sends the file",body:"Most clinics respond within 3 to 5 business days. We follow up for you."},{title:"Everfur reads every page",body:`Visits, vaccines, labs and prescriptions land in ${e}\u2019s records.`}],"howSteps"),placeholder:Z.placeholder,searchA11y:Z.search,clearSearch:"Clear search",loading:"Loading clinics",uploadOwn:"I already have the records",uploadOwnStarting:"Setting up your upload\u2026",uploadOwnA11y:"Upload records you already have",noPet:"Add a pet first, then come back to request their records.",recentlyUsed:Z.recentlyUsed,noMatch:i(e=>`No clinics match \u201C${e}\u201D. You can still request records using the option above.`,"noMatch"),loadingMore:"Loading more\u2026",loadMoreFailed:"Couldn\u2019t load more. Tap to retry.",loadMoreRetryA11y:"Retry loading more clinics",selectA11y:i(e=>`Request records from ${e}`,"selectA11y"),fallback:Object.freeze({title:"Can\u2019t find your clinic?",subtitle:"Add it by email and we\u2019ll request your records.",expandA11y:"Can't find your clinic? Add it by email to request records.",collapseA11y:"Hide the request-by-email form",nameLabel:"Clinic name",namePlaceholder:"Your clinic\u2019s name",emailLabel:"Clinic email",emailPlaceholder:"records@clinic.com",reviewNote:"We review every request by hand before reaching out to the clinic.",submit:"Continue",submitA11y:"Request records by email"})});function Il(e){switch(e){case "verified":return {label:"Email on file",a11y:"verified email on file, we can request records directly",tone:"positive"};case "unverified":return {label:"Email unconfirmed",a11y:"email on file but unconfirmed, we will try and let you know",tone:"caution"};default:return {label:"We may need your help",a11y:"no email on file, we may ask you to confirm how to reach this clinic",tone:"neutral"}}}i(Il,"clinicEmailStatusBadge");var Dm=1.609344;function Dl(e){return e===null||!Number.isFinite(e)?null:(e/Dm).toFixed(1)}i(Dl,"milesLabel");function Al(e){let t=Dl(e);return t===null?"":`${t} mi`}i(Al,"formatClinicDistanceLabel");function Ol(e){let t=Dl(e);return t===null?"":`${t} ${t==="1.0"?"mile":"miles"} away`}i(Ol,"formatClinicDistanceForA11y");var Ll=300,Gi=2;var ve=Object.freeze({loading:"Loading",empty:"No records yet",upload:"Upload records",consentRequired:"Consent required",allow:"Allow",sessionRequired:"Sign in required",recordUnavailable:"Record unavailable",retry:"Try again",records:"Records",beingReviewed:"being reviewed"}),Vl="Everfur summarizes what your vet recorded. It is informational, not diagnostic.";var Am="your pet";function ke(e){let t=e?.trim()??"";return t.length>0?t:Am}i(ke,"petNameOr");var vt=Object.freeze({title:"Health records",titleWeb:i(e=>{let t=e?.trim()??"";return t.length>0?`${t}\u2019s Records`:"Health records"},"titleWeb"),titleNative:i(e=>{let t=e?.trim()??"";return t.length>0?t:"Health records"},"titleNative"),openTimeline:"Open timeline",loading:"Loading health records",lead:i(e=>`${ke(e)}\u2019s lab trends`,"lead"),retryMarkers:"Retry loading lab trends",viewFullRecord:"View full medical record",viewTimeline:"View full timeline",important:i(e=>`Important: ${e}`,"important")}),Qt=Object.freeze({title:"At a glance",marker:"Marker",markers:"Markers",outOfRange:"out of range",inRange:"in range",noRange:"NO RANGE",subtitle:"Summary of your pet\u2019s biomarkers",ask:"Ask about these markers",askA11y:"Ask Everfur about these markers",a11y:i((e,t,r,o)=>`Marker summary: ${e} ${e===1?"marker":"markers"}, ${t} in range, ${r} out of range${o>0?`, ${o} without a range`:""}.`,"a11y")}),Yi=Object.freeze({counter:i((e,t)=>`${e+1} of ${t}`,"counter"),a11y:i((e,t,r)=>e!==null?`${e}, marker ${t+1} of ${r}. Swipe left or right to see more markers.`:`Marker ${t+1} of ${r}`,"a11y")}),hr=Object.freeze({tapHint:"Tap a point to see where it came from.",singleHint:"One reading so far: we\u2019ll plot a trend as more come in.",empty:"No readings for this marker yet.",ask:"Ask about this marker",askNamed:i(e=>{let t=e?.trim()??"";return t.length>0?`Ask about ${t}`:"Ask about this marker"},"askNamed"),askA11y:i(e=>`Ask Everfur about ${e}`,"askA11y"),status:i(e=>`Status: ${e}`,"status"),latestA11y:i((e,t,r)=>`Latest reading ${e}, ${t}, collected ${r}`,"latestA11y"),readingsA11y:i(e=>`${e} readings, oldest to newest`,"readingsA11y")}),At=Object.freeze({title:"Where this comes from",close:"Close reading details",collected:"Collected",clinic:"Clinic",referenceRange:"Reference range",noRange:"Not on file for this reading",sourceDocument:"Source document",unverified:"Our team hasn\u2019t verified this reading against the original document yet.",reviewed:"Reviewed by our team",ask:"Ask about this reading",askA11y:"Ask Everfur about this reading"}),Xt=Object.freeze({title:i(e=>`${ke(e)}\u2019s records are on the way`,"title"),anotherClinic:"Another clinic",anotherClinicSub:"Seen more than one vet? We ask each one.",uploadDocumentPhotoSub:"A PDF, or a photo of a paper record.",body:i(e=>`We\u2019re requesting ${ke(e)}\u2019s records from your vet. This usually takes a few days; we\u2019ll show lab trends here as soon as they arrive.`,"body"),a11y:i(e=>`Records request in progress for ${ke(e)}.`,"a11y"),openA11y:i((e,t)=>`Open ${ke(e)}\u2019s records request. ${t}`,"openA11y"),ask:"Ask about this request",askA11y:"Ask Everfur about this records request"}),Ot=Object.freeze({title:i(e=>`Add ${ke(e)}\u2019s records`,"title"),firstRecordTitle:i(e=>`Add ${ke(e)}\u2019s first record`,"firstRecordTitle"),body:"Records can come from more than one clinic over a lifetime.",requestFromClinic:"Request from a clinic",requestFromClinicSub:"We send a secure request and read every page they send back.",requestFromClinicA11y:i(e=>`Request ${ke(e)}\u2019s records from a clinic`,"requestFromClinicA11y"),uploadDocument:"Upload a document",uploadDocumentA11y:i(e=>`Upload one of ${ke(e)}\u2019s records`,"uploadDocumentA11y")});function Fl(e){return !kr(e.status)}i(Fl,"isRecordsInProgress");function mo(e,t){if(t===null)return null;let r=e.filter(l=>l.petRef===t);if(r.length===0)return null;let o=r.find(l=>l.status==="published");return o!==void 0?o:r.filter(Fl).sort((l,a)=>a.updatedAt.localeCompare(l.updatedAt))[0]??null}i(mo,"pickPetRecordsRequest");function Ki(e){if(e.hasMarkers)return "published";let t=mo(e.requests,e.petRef);return t===null?"none":t.status==="published"||Fl(t)?"in_progress":"none"}i(Ki,"deriveRecordsDashboardState");function Om(e){return e.recordLoading?true:e.hasFullRecord?false:e.markersLoading||!e.hasMarkers&&e.requestsLoading}i(Om,"selectDashboardLoading");function Qi(e){return Om(e)?"loading":e.hasFullRecord?"record":e.markersError||e.recordError&&!e.hasMarkers?"error":e.dashboardState==="in_progress"&&e.drivingRequest!==null?"in_progress":e.dashboardState==="none"?"none":"labs_only"}i(Qi,"selectDashboardView");function wt(e){return e?.httpStatus===429?"rate_limited":e?.httpStatus===502?"service_unavailable":"error"}i(wt,"recordsEmptyVariantForError");var fe=Object.freeze({loading:"Loading record request",sentTitle:"Request sent",sentLeadWeb:i((e,t)=>`${e} has the request. We\u2019ll let you know when ${t}\u2019s file arrives.`,"sentLeadWeb"),sentLeadNative:i(e=>`We\u2019ll let you know when ${e}\u2019s file arrives.`,"sentLeadNative"),whereItStands:"Where it stands",details:"Request details",detailsClinic:"Clinic",detailsSent:"Sent",timelineA11y:"Request timeline",awaitingNote:"Clinics usually reply within a week. We follow up automatically and will let you know if there\u2019s no reply by day 14.",waitingBanner:i(e=>`It\u2019s been ${e} ${e===1?"day":"days"}. Some clinics take a little longer; we\u2019ve been following up automatically and are still on it. If there\u2019s no reply by day 14, we\u2019ll let you know.`,"waitingBanner"),viewRecords:"View health records",nextStep:"You can try a different clinic or upload records you already have.",tryAnotherClinic:"Request from a different clinic",tryAnotherClinicA11y:"Request records from a different clinic",convert:"Upload my own records instead",converting:"Switching\u2026",convertHint:"We\u2019ll stop waiting on the clinic so you can add the records you already have. If the clinic does reply, we\u2019ll still add their records too.",freshUpload:"Upload your own records",freshUploadStarting:"Starting\u2026",cancel:"Cancel request",cancelling:"Cancelling\u2026",cancelA11y:"Cancel this records request",cancellingA11y:"Cancelling, please wait",resend:"Resend email",resending:"Resending\u2026",resendA11y:"Resend the authorization email to the clinic",resendingA11y:"Resending the email, please wait",errors:Object.freeze({cancel:"We couldn\u2019t cancel this request. Please try again.",retry:"We couldn\u2019t retry this request. Please try again.",email:"We couldn\u2019t update the clinic email. Please try again.",convert:"We couldn\u2019t switch this to an upload. Please try again.",start:"We couldn\u2019t start that. Please try again.",invalidEmail:"Enter a valid clinic email."})});function Lm(e){if(e.wireStatus==="clinic_declined")return "The clinic declined to release the records.";if(e.wireStatus==="clinic_responded_no_records")return "The clinic replied but didn\u2019t include your records.";switch(e.failureCode){case "no_response":return "The clinic didn\u2019t reply after several reminders over 14 days.";case "parse_timeout":case "parse_error":return "We received the records but couldn\u2019t read them. Uploading a clean copy usually fixes this.";case "hard_bounce":case "dispatch_failed":return "We couldn\u2019t deliver the email to the clinic.";default:return "This request didn\u2019t go through."}}i(Lm,"fallbackFailureTitle");function ql(e){let t=e.failureReason?.trim()??"";return t.length>0?t:Lm(e)}i(ql,"failureTitle");var Vm=1440*60*1e3;function Xi(e,t){if(!e.createdAt)return 0;let r=Date.parse(e.createdAt);if(Number.isNaN(r))return 0;let o=t-r;return o<=0?0:Math.floor(o/Vm)}i(Xi,"requestElapsedDays");var Fm=7;function zl(e,t){return e.wireStatus!=="awaiting_response"?false:Xi(e,t)>=Fm}i(zl,"requestWaitingTooLong");function Ji(e){return e.status==="failed"}i(Ji,"isTerminalFailure");function Nl(e){return Ji(e)||e.canUpdateClinicEmail===true||e.canRetrySend===true}i(Nl,"shouldOfferRecovery");function Bl(e,t){let[r,o]=useState(""),[n,l]=useState(""),[a,c]=useState([]),[s,d]=useState(null),[u,m]=useState([]),[y,g]=useState(true),[w,R]=useState(false),[v,f]=useState(false),[b,C]=useState(null),[h,I]=useState(null),[T,k]=useState(0),_=useRef(0),E=useRef(true),B=t?.latitude,x=t?.longitude,A=useMemo(()=>B!==void 0&&x!==void 0?{latitude:B,longitude:x}:void 0,[B,x]);useEffect(()=>(E.current=true,()=>{E.current=false,_.current+=1;}),[e]),useEffect(()=>{let M=true;return g(true),e.recentClinics({limit:5}).then($=>{M&&($.ok&&m($.value.clinics),g(false));}).catch(()=>{M&&g(false);}),()=>{M=false;}},[e]),useEffect(()=>{let M=r.trim();if(M.length<Gi){l("");return}let $=setTimeout(()=>l(M),Ll);return ()=>clearTimeout($)},[r]);let z=n.length>=Gi;useEffect(()=>{let M=_.current+=1;if(c([]),d(null),C(null),I(null),!z){R(false);return}R(true),e.searchClinics({query:n,limit:25,...A?{location:A}:{}}).then($=>{!E.current||M!==_.current||($.ok?(c($.value.clinics),d($.value.nextCursor)):C($.error),R(false));}).catch(()=>{E.current&&M===_.current&&R(false);});},[e,n,z,A,T]);let de=useCallback(()=>{if(!z||s===null||v)return;let M=_.current;f(true),I(null),e.searchClinics({query:n,limit:25,cursor:s,...A?{location:A}:{}}).then($=>{!E.current||M!==_.current||($.ok?(c(O=>[...O,...$.value.clinics]),d($.value.nextCursor)):I($.error),f(false));}).catch(()=>{E.current&&M===_.current&&f(false);});},[e,s,n,z,v,A]),G=useCallback(M=>o(M),[]),ae=useCallback(()=>k(M=>M+1),[]);return useMemo(()=>({query:r,debouncedQuery:n,isSearchActive:z,clinics:a,recent:u,recentLoading:y,initialLoading:w,loadingMore:v,hasNextPage:s!==null,error:b,pageError:h,setQuery:G,loadMore:de,retry:ae}),[r,n,z,a,u,y,w,v,s,b,h,G,de,ae])}i(Bl,"useClinicPicker");function es(e,t,r,o){return Object.freeze({key:e?.id??`free:${t??""}`,clinic:e,freeText:t,email:r,idempotencyKey:o})}i(es,"clinicDraftFor");var tn=10,fo=z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),Sn=i((e,t=1)=>z.string().refine(r=>!br(r)&&[...r].length>=t&&[...r].length<=e),"text"),jl=i(e=>[...e].some(t=>t.charCodeAt(0)<32||t.charCodeAt(0)===127),"hasControl"),qm=z.object({clinicId:fo.optional(),clinicFreeText:Sn(200).refine(e=>e.trim().length>0).optional(),clinicEmail:Sn(320,3).refine(e=>!jl(e)&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e.trim())).optional(),signatureId:fo.optional(),signaturePngBase64:z.string().min(1).max(2*1024*1024).optional(),idempotencyKey:z.string().regex(/^[A-Za-z0-9._-]{8,128}$/)}).strict().refine(e=>e.clinicId===void 0!=(e.clinicFreeText===void 0)).refine(e=>e.signatureId===void 0!=(e.signaturePngBase64===void 0)),zm=z.object({petRef:Sn(128),ownerName:Sn(200).refine(e=>e.trim().length>0&&!jl(e)),authorizationVersion:Sn(64),clinics:z.array(qm).min(1).max(tn)}).strict(),Nm=z.object({request_group_id:fo,pet_ref:z.string(),created_count:z.number().int().nonnegative(),failed_count:z.number().int().nonnegative(),results:z.array(z.object({idempotency_key:z.string(),clinic_id:fo.nullable().optional(),clinic_free_text:z.string().nullable().optional(),created:z.boolean(),request:z.unknown().optional(),failure_code:z.string().nullable().optional(),failure_reason:z.string().nullable().optional()}))});function $l(e){let t=e.funnel??Dr({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}});return {async createClinicRequestBatch(r){if(!zm.safeParse(r).success)return te(W("validationFailed",{retryable:false}));let o=await t.send("records.clinic.createBatch",{method:"POST",path:"/widget/v1/records/clinic-requests/batch",body:{pet_ref:r.petRef,owner_name:r.ownerName,authorization_version:r.authorizationVersion,clinics:r.clinics.map(a=>({...a.clinicId!==void 0?{clinic_id:a.clinicId}:{clinic_free_text:a.clinicFreeText},...a.clinicEmail!==void 0?{clinic_email:a.clinicEmail}:{},...a.signatureId!==void 0?{signature_id:a.signatureId}:{signature_png_base64:a.signaturePngBase64},idempotency_key:a.idempotencyKey}))}});if(!o.ok)return o;let n=Nm.safeParse(o.value);if(!n.success||n.data.pet_ref!==r.petRef)return Ul();let l=[];for(let a of n.data.results){let c=a.request===void 0||a.request===null?null:Tr(a.request);if(a.created!==(c!==null))return Ul();l.push(Object.freeze({idempotencyKey:a.idempotency_key,clinicId:a.clinic_id??null,clinicFreeText:a.clinic_free_text??null,created:a.created,request:c,failureCode:a.failure_code??null,failureReason:a.failure_reason??null}));}return Ve(Object.freeze({requestGroupId:n.data.request_group_id,petRef:n.data.pet_ref,results:Object.freeze(l),createdCount:n.data.created_count,failedCount:n.data.failed_count}))}}}i($l,"createRecordsClinicBatchClient");function Ul(){return te(W("internalError",{retryable:false}))}i(Ul,"malformed");var Wl=z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),Mm=z.object({clinics:z.array(z.object({clinic_id:Wl,name:z.string().min(1),address:z.string().nullable(),phone:z.string().nullable(),email_status:z.string(),distance_km:z.number().finite().nonnegative().nullable()})),next_cursor:z.string().nullable().optional()}),Hm=z.object({authorization_version:z.string().min(1),scope_template:z.string().min(1),authorization_template:z.string().min(1)}),Bm=z.object({upload_id:z.string().min(1),upload_url:z.string().url().refine(e=>e.startsWith("https://")),upload_fields:z.record(z.string())});function Gl(e){let{repository:t}=e,r=i(async n=>{let l=await n;if(!l.ok)return l;let a=Tr(l.value);return a===null?Mr():Ve(a)},"request"),o=i(async n=>{let l=await n;if(!l.ok)return l;let a=Mm.safeParse(l.value);return a.success?Ve(Object.freeze({clinics:Object.freeze(a.data.clinics.map(c=>Object.freeze({id:c.clinic_id,name:c.name,address:c.address,phone:c.phone,emailStatus:c.email_status,distanceKm:c.distance_km}))),nextCursor:a.data.next_cursor??null})):Mr()},"page");return {searchClinics:i((n={})=>o(t.searchClinics(n)),"searchClinics"),recentClinics:i((n={})=>o(t.recentClinics(n)),"recentClinics"),async getRequestGroup(n){let l=await t.getRequestGroup(n);if(!l.ok)return l;let a=Ya(l.value);return a===null?Mr():Ve(a)},async getAuthorizationCopy(){let n=await t.getAuthorizationCopy();if(!n.ok)return n;let l=Hm.safeParse(n.value);return l.success?Ve(Object.freeze({authorizationVersion:l.data.authorization_version,scopeTemplate:l.data.scope_template,authorizationTemplate:l.data.authorization_template})):Mr()},async createClinicRequest(n){let l=await r(t.createClinicRequest(n));return l.ok&&l.value.petRef!==n.petRef?Mr():l},retryRequest:i(n=>r(t.retryRequest(n)),"retryRequest"),revokeRequest:i(n=>r(t.revokeRequest(n)),"revokeRequest"),updateClinicEmail:i((n,l)=>r(t.updateClinicEmail(n,l)),"updateClinicEmail"),convertToUpload:i(n=>r(t.convertToUpload(n)),"convertToUpload"),async initiateSignatureUpload(n){let l=await t.initiateSignatureUpload(n);if(!l.ok)return l;let a=Bm.safeParse(l.value);return a.success?Ve(Object.freeze({uploadId:a.data.upload_id,uploadUrl:a.data.upload_url,uploadFields:Object.freeze(a.data.upload_fields)})):Mr()},async completeSignatureUpload(n){let l=await t.completeSignatureUpload(n);if(!l.ok)return l;let a=z.object({signature_id:Wl}).safeParse(l.value);return a.success?Ve(a.data.signature_id):Mr()}}}i(Gl,"createRecordsClinicController");function Mr(){return te(W("internalError",{retryable:false}))}i(Mr,"malformed");var Or="/widget/v1/records",Yl=z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),Vr=i((e,t=1)=>z.string().refine(r=>!br(r)&&[...r].length>=t&&[...r].length<=e),"text"),Ql=i(e=>[...e].some(t=>t.charCodeAt(0)<32||t.charCodeAt(0)===127),"hasControl"),Xl=Vr(320,3).refine(e=>!Ql(e)&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e.trim())),Kl=Vr(64),Um=z.object({limit:z.number().int().min(1).max(25).optional()}).strict(),jm=z.object({query:Vr(200,0).optional(),location:z.object({latitude:z.number().finite().min(-90).max(90),longitude:z.number().finite().min(-180).max(180)}).strict().optional(),limit:z.number().int().min(1).max(100).optional(),cursor:Vr(512,0).optional()}).strict(),$m=z.object({petRef:Vr(128),ownerName:Vr(200).refine(e=>e.trim().length>0&&!Ql(e)),authorizationVersion:Vr(64),clinicId:Yl.optional(),clinicFreeText:Vr(200).refine(e=>e.trim().length>0).optional(),clinicEmail:Xl.optional(),signatureId:Yl.optional(),signaturePngBase64:z.string().min(1).max(2*1024*1024).optional(),idempotencyKey:z.string().regex(/^[A-Za-z0-9._-]{8,128}$/)}).strict().refine(e=>e.clinicId===void 0!=(e.clinicFreeText===void 0)).refine(e=>e.signatureId===void 0!=(e.signaturePngBase64===void 0));function Jl(e){let t=e.funnel??Dr({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=i((n,l,a=false)=>t.send(`records.clinic.${n}`,l,l.method==="GET"||a?void 0:{idempotent:false,maxAttempts:1}),"send"),o=i((n,l,a)=>Kl.safeParse(n).success?r(l,{method:"POST",path:`${Or}/requests/${encodeURIComponent(n)}/${l}`,...a?{body:a}:{}}):Lr(),"recover");return {searchClinics(n){return jm.safeParse(n).success?r("search",{method:"GET",path:`${Or}/clinics/search`,query:{q:n.query??"",lat:n.location?.latitude,lng:n.location?.longitude,limit:n.limit,cursor:n.cursor}}):Lr()},recentClinics(n){return Um.safeParse(n).success?r("recent",{method:"GET",path:`${Or}/clinics/recent`,query:{limit:n.limit}}):Lr()},getRequestGroup(n){return Kl.safeParse(n).success?r("requestGroup",{method:"GET",path:`${Or}/request-groups/${encodeURIComponent(n)}`}):Lr()},getAuthorizationCopy:i(()=>r("authorizationCopy",{method:"GET",path:`${Or}/authorization-copy`}),"getAuthorizationCopy"),createClinicRequest(n){return $m.safeParse(n).success?r("create",{method:"POST",path:`${Or}/clinic-requests`,body:{pet_ref:n.petRef,owner_name:n.ownerName,authorization_version:n.authorizationVersion,idempotency_key:n.idempotencyKey,...n.clinicId!==void 0?{clinic_id:n.clinicId}:{clinic_free_text:n.clinicFreeText},...n.clinicEmail!==void 0?{clinic_email:n.clinicEmail}:{},...n.signatureId!==void 0?{signature_id:n.signatureId}:{signature_png_base64:n.signaturePngBase64}}},true):Lr()},retryRequest:i(n=>o(n,"retry"),"retryRequest"),revokeRequest:i(n=>o(n,"revoke"),"revokeRequest"),convertToUpload:i(n=>o(n,"convert-to-upload"),"convertToUpload"),updateClinicEmail(n,l){return Xl.safeParse(l).success?o(n,"clinic-email",{clinic_email:l}):Lr()},initiateSignatureUpload(n){return !Number.isInteger(n)||n<=0||n>2*1024*1024?Lr():r("signatureInitiate",{method:"POST",path:`${Or}/signatures/initiate`,body:{content_type:"image/png",file_size:n}})},completeSignatureUpload(n){return /^sig-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n)?r("signatureComplete",{method:"POST",path:`${Or}/signatures/complete`,body:{upload_id:n}}):Lr()}}}i(Jl,"createHttpRecordsClinicRepository");function Lr(){return Promise.resolve(te(W("validationFailed",{retryable:false})))}i(Lr,"invalid");function Zt(){let{runtime:e,userRef:t,scopeEpoch:r}=Te(),o=useMemo(()=>{let{services:l}=e.registry;return Gl({repository:Jl({auth:l.authFor(t),...l.errorPolicy?{errorPolicy:l.errorPolicy}:{}})})},[e,t,r]),n=useRef(o);return useEffect(()=>(n.current=o,()=>{n.current=null;}),[o]),useMemo(()=>{let l=i(async a=>{if(t===null||n.current!==o)return te(W("accessDenied"));let c=await a();return n.current===o?c:te(W("accessDenied"))},"run");return {searchClinics:i(a=>l(()=>o.searchClinics(a)),"searchClinics"),recentClinics:i(a=>l(()=>o.recentClinics(a)),"recentClinics"),getRequestGroup:i(a=>l(()=>o.getRequestGroup(a)),"getRequestGroup"),getAuthorizationCopy:i(()=>l(()=>o.getAuthorizationCopy()),"getAuthorizationCopy"),createClinicRequest:i(a=>l(()=>o.createClinicRequest(a)),"createClinicRequest"),retryRequest:i(a=>l(()=>o.retryRequest(a)),"retryRequest"),revokeRequest:i(a=>l(()=>o.revokeRequest(a)),"revokeRequest"),updateClinicEmail:i((a,c)=>l(()=>o.updateClinicEmail(a,c)),"updateClinicEmail"),convertToUpload:i(a=>l(()=>o.convertToUpload(a)),"convertToUpload"),initiateSignatureUpload:i(a=>l(()=>o.initiateSignatureUpload(a)),"initiateSignatureUpload"),completeSignatureUpload:i(a=>l(()=>o.completeSignatureUpload(a)),"completeSignatureUpload")}},[o,t])}i(Zt,"useEverfurRecordsClinic");function ts(){let{runtime:e,userRef:t,scopeEpoch:r}=Te(),o=useMemo(()=>{let{services:l}=e.registry;return $l({auth:l.authFor(t),...l.errorPolicy?{errorPolicy:l.errorPolicy}:{}})},[e,t,r]),n=useRef(o);return useEffect(()=>(n.current=o,()=>{n.current=null;}),[o]),useMemo(()=>({async createClinicRequestBatch(l){if(t===null||n.current!==o)return te(W("accessDenied"));let a=await o.createClinicRequestBatch(l);return n.current===o?a:te(W("accessDenied"))}}),[o,t])}i(ts,"useEverfurRecordsClinicBatch");var os=class os extends Component{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey};}static getDerivedStateFromError(){return {failed:true}}static getDerivedStateFromProps(r,o){return Object.is(r.resetKey,o.key)?null:{failed:false,key:r.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};i(os,"HostRenderBoundary");var rs=os;function Gm({render:e}){return e()}i(Gm,"RenderHost");function ns({render:e,fallback:t,resetKey:r}){return createElement(rs,{fallback:t,resetKey:r,children:createElement(Gm,{render:e})})}i(ns,"HostRender");var Ym=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 Km(e){return Ym[e]}i(Km,"requires");function rc(e,t,r){let o=Km(e),n=new Map;for(let c of t)n.set(c.resource,c);if(r?.isPending===true&&o.some(c=>!n.has(c)))return is({name:e,enabled:false,isPending:true,limits:{}});let l=Qm(o,n);return o.filter(c=>n.get(c)?.granted!==true).length===0?is({name:e,enabled:true,isPending:false,limits:l}):is({name:e,enabled:false,isPending:false,limits:l,disabled:Xm(o,n)})}i(rc,"decideCapability");function Qm(e,t){let r={};for(let o of e){let n=t.get(o)?.limits;if(n)for(let[l,a]of Object.entries(n)){let c=r[l];r[l]=c===void 0?a:Math.min(c,a);}}return r}i(Qm,"mergeLimits");function Xm(e,t){for(let r of e){let o=t.get(r)?.disabled;if(o)return Object.freeze({reason:o.reason,level:o.level,recoverable:o.recoverable})}return Object.freeze({reason:Ri("accessDenied"),level:"user_entitlement",recoverable:false})}i(Xm,"disabledFor");function is(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(is,"freezeDecision");function Tn(e){let{runtime:t}=Te(),r=t.entitlements,o=useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot);return useMemo(()=>rc(e,o.decisions,{isPending:o.isPending}),[e,o])}i(Tn,"useCapability");var ey=48;function ty(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}i(ty,"selectView");function Ue(e){let{capability:t,children:r,renderDisabled:o,renderPending:n,style:l}=e,a=Tn(t),c=useMemo(()=>ty(a),[a]);switch(c){case "enabled":return r;case "pending":return n?jsx(ns,{render:n,fallback:jsx(oc,{capability:t,style:l})}):jsx(oc,{capability:t,style:l});case "disabled":return o?jsx(ns,{render:()=>o(a),fallback:jsx(ic,{decision:a,style:l}),resetKey:a}):jsx(ic,{decision:a,style:l});default:return Ir(c)}}i(Ue,"CapabilityGate");function oc({capability:e,style:t}){let r=V(),o=useMemo(()=>sc(r),[r]);return jsx(View,{style:[o.offstate,t],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${e}`,children:jsx(View,{style:o.skeletonBar})})}i(oc,"PendingSkeleton");function ic({decision:e,style:t}){let r=V(),o=useMemo(()=>sc(r),[r]),n=e.disabled?.reason??"";return jsx(View,{style:[o.offstate,t],accessible:true,accessibilityRole:"text",accessibilityLabel:n,children:n.length>0?jsx(p,{style:o.offstateText,children:n}):null})}i(ic,"OffState");function sc(e){let{color:t,space:r,radius:o,type:n}=e;return StyleSheet.create({offstate:{minHeight:ey,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:o.md,borderWidth:StyleSheet.hairlineWidth,borderColor:t.brandBorder},offstateText:{...S(e,"regular"),fontSize:n.size.body,lineHeight:Math.round(n.size.body*n.lineHeight.normal),color:t.text.muted},skeletonBar:{height:r.md,borderRadius:o.xs,backgroundColor:t.brandSofter}})}i(sc,"makeStyles");function je(e){let t=V(),r=useMemo(()=>oy(t),[t]);return jsx(p,{style:[r.footnote,e.style],accessibilityRole:"text",testID:"records-footnote",children:Vl})}i(je,"RecordsFootnote");function oy(e){let{color:t,space:r,type:o}=e;return StyleSheet.create({footnote:{...S(e,"regular"),paddingHorizontal:r.lg,paddingTop:r.md,paddingBottom:r.lg,textAlign:"center",fontSize:o.size.caption,lineHeight:Math.round(o.size.caption*o.lineHeight.normal),color:t.text.muted,backgroundColor:t.background}})}i(oy,"makeStyles");function dt(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(dt,"slotBox");function yt(e){return e?.textColor===void 0?{}:{color:e.textColor}}i(yt,"slotText");var ac=Object.freeze({idle:Object.freeze({title:"Find your pet\u2019s clinic",body:"Search for the clinic that holds your pet\u2019s records. We\u2019ll request them on your behalf once you sign the authorization.",action:null}),no_requests:Object.freeze({title:"No record requests yet",body:"When you request records from a clinic, you\u2019ll be able to track every step here.",action:null}),no_records:Object.freeze({title:"Nothing to show just yet",body:"Once your pet\u2019s records arrive and our team reviews them, lab trends and visits will appear here.",action:null}),rate_limited:Object.freeze({title:"Slow down a moment",body:"You\u2019ve made a lot of requests just now. You can try again shortly.",action:"Try again"}),service_unavailable:Object.freeze({title:"Records search is temporarily down",body:"We\u2019re working on it. Please try again in a few minutes.",action:"Try again"}),error:Object.freeze({title:"Couldn\u2019t reach Everfur",body:"Check your connection and try again.",action:"Try again"})}),ls=60;function lc(e){return `Try again in ${e}s`}i(lc,"coolingActionLabel");var cc="Try again, available shortly";function Xe({variant:e,onAction:t,message:r,testID:o}){let n=cy(),l=ac[e],[a,c]=useState(e==="rate_limited"?ls:0);useEffect(()=>{e==="rate_limited"&&c(ls);},[e]),useEffect(()=>{if(a<=0)return;let u=setTimeout(()=>c(m=>Math.max(0,m-1)),1e3);return ()=>clearTimeout(u)},[a]);let s=e==="rate_limited"&&a>0,d=s?lc(a):l.action;return jsxs(View,{style:n.container,accessibilityRole:"summary",testID:o,children:[jsx(View,{style:n.glyph,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsx(p,{style:n.title,children:l.title}),jsx(p,{style:n.body,children:r??l.body}),d!==null&&t?jsx(Pressable,{onPress:t,disabled:s,accessibilityRole:"button",accessibilityLabel:s?cc:d,accessibilityState:{disabled:s},style:[n.action,s?n.actionDisabled:null],testID:o?`${o}-action`:`records-empty-${e}-action`,children:jsx(p,{style:n.actionLabel,children:d})}):null]})}i(Xe,"RecordsEmptyState");function cy(){let e=V();return useMemo(()=>dy(e),[e])}i(cy,"useStyles");function dy(e){let{color:t,space:r,radius:o,type:n,slots:l}=e,a=r.lg+r.xs+r.xs/2;return StyleSheet.create({container:{paddingVertical:r.xxl,paddingHorizontal:r.xl,alignItems:"center",gap:r.sm+r.xs/2},glyph:{width:a,height:a,borderRadius:a/2,backgroundColor:t.brandSoft,borderWidth:StyleSheet.hairlineWidth,borderColor:t.brandBorder,marginBottom:r.xs},title:{...S(e,"bold"),fontSize:n.size.subtitle,lineHeight:Math.round(n.size.subtitle*n.lineHeight.snug)-1,color:t.brandInk,textAlign:"center"},body:{...S(e,"regular"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*n.lineHeight.normal),color:t.text.muted,textAlign:"center",maxWidth:320},action:{marginTop:r.sm,minHeight:r.xxl+r.sm,borderRadius:o.pill,paddingHorizontal:r.lg+r.xs/2,backgroundColor:t.brand,alignItems:"center",justifyContent:"center",...dt(l.primaryButton)},actionDisabled:{opacity:.5},actionLabel:{...S(e,"bold"),color:t.onPrimary,fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*n.lineHeight.snug)-1,...yt(l.primaryButton)}})}i(dy,"makeStyles");var ot="Back";function it({title:e,onBack:t,right:r,testID:o,variant:n="brand"}){let l=_n();return jsxs(View,{style:l.row,testID:o,children:[t?jsx(Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:ot,hitSlop:12,style:l.back,testID:o?`${o}-back`:void 0,children:jsx(View,{style:l.chevron,accessibilityElementsHidden:true,importantForAccessibility:"no"})}):jsx(View,{style:l.back}),e.trim().length>0?jsx(p,{style:n==="document"?l.documentTitle:l.title,accessibilityRole:"header",numberOfLines:1,children:e}):jsx(View,{style:l.spacer,accessibilityElementsHidden:true,importantForAccessibility:"no",testID:o?`${o}-spacer`:void 0}),jsx(View,{style:l.right,children:r??jsx(View,{style:l.back})})]})}i(it,"ScreenHeader");function mc(){let e=_n();return jsxs(View,{style:e.listGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:[jsx(View,{style:e.listBar}),jsx(View,{style:e.listBar}),jsx(View,{style:e.listBar})]})}i(mc,"ListGlyph");function yc(){let e=_n();return jsxs(View,{style:e.shareGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:[jsx(View,{style:[e.shareDot,e.shareDotTop]}),jsx(View,{style:[e.shareDot,e.shareDotLeft]}),jsx(View,{style:[e.shareDot,e.shareDotBottom]}),jsx(View,{style:[e.shareStroke,e.shareStrokeUp]}),jsx(View,{style:[e.shareStroke,e.shareStrokeDown]})]})}i(yc,"ShareGlyph");function fc(){let e=_n();return jsxs(View,{style:e.sendGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:[jsx(View,{style:e.sendBody}),jsx(View,{style:e.sendFold})]})}i(fc,"SendGlyph");function gc(){let e=_n();return jsxs(View,{style:e.downloadGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:[jsx(View,{style:e.downloadStem}),jsx(View,{style:e.downloadHead}),jsx(View,{style:e.downloadTray})]})}i(gc,"DownloadGlyph");function _n(){let e=V();return useMemo(()=>fy(e),[e])}i(_n,"useStyles");function fy(e){let{color:t,space:r,type:o}=e,n=r.xxl+r.md,l=r.md,a=r.xs/2,c=r.lg+r.xs+r.xs/2;return StyleSheet.create({row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:r.lg,paddingTop:r.xs,paddingBottom:r.md,gap:r.sm},back:{width:n,height:n,alignItems:"center",justifyContent:"center"},chevron:{width:l,height:l,borderLeftWidth:a,borderBottomWidth:a,borderColor:t.brandInk,transform:[{rotate:"45deg"}],marginLeft:r.xs},title:{flex:1,...S(e,"bold"),fontSize:o.size.heading,lineHeight:Math.round(o.size.heading*o.lineHeight.tight)+1,color:t.brandInk},spacer:{flex:1},documentTitle:{flex:1,textAlign:"center",...S(e,"bold"),fontSize:o.size.subtitle,lineHeight:Math.round(o.size.subtitle*o.lineHeight.snug),color:t.text.primary},right:{flexDirection:"row",alignItems:"center",gap:r.sm+r.xs/2},listGlyph:{width:c,height:c,justifyContent:"space-evenly"},listBar:{height:a,borderRadius:a,backgroundColor:t.brandInk},shareGlyph:{width:c-r.xs,height:c-r.xs},shareDot:{position:"absolute",width:r.xs+r.xs/2,height:r.xs+r.xs/2,borderRadius:r.xs,borderWidth:a,borderColor:t.brandInk},shareDotTop:{right:0,top:0},shareDotLeft:{left:0,top:r.xs+r.xs/2},shareDotBottom:{right:0,bottom:0},shareStroke:{position:"absolute",left:r.xs,top:r.sm,width:r.sm+r.xs/2,height:a,backgroundColor:t.brandInk},shareStrokeUp:{transform:[{rotate:"-30deg"}]},shareStrokeDown:{transform:[{rotate:"30deg"}]},sendGlyph:{width:c-r.xs,height:c-r.xs},sendBody:{position:"absolute",left:0,top:0,right:0,bottom:0,borderWidth:a,borderColor:t.brandInk,transform:[{rotate:"45deg"}],borderRadius:a},sendFold:{position:"absolute",left:0,right:0,top:"50%",height:a,backgroundColor:t.brandInk},downloadGlyph:{width:c-r.xs,height:c-r.xs,alignItems:"center"},downloadStem:{width:a,height:r.sm+r.xs/2,backgroundColor:t.brandInk},downloadHead:{width:r.sm,height:r.sm,borderRightWidth:a,borderBottomWidth:a,borderColor:t.brandInk,transform:[{rotate:"45deg"}],marginTop:-r.sm},downloadTray:{position:"absolute",bottom:0,left:0,right:0,height:r.xs+r.xs/2,borderLeftWidth:a,borderRightWidth:a,borderBottomWidth:a,borderColor:t.brandInk}})}i(fy,"makeStyles");var hy=120,Ry=44;function vy({reason:e,onExit:t,exitLabel:r,style:o}){let{color:n,space:l,radius:a,type:c}=V();return jsxs(View,{testID:"records-gate-off",style:[{minHeight:hy,justifyContent:"center",gap:l.md,padding:l.lg,borderRadius:a.md,borderWidth:1,borderColor:n.brandBorder,backgroundColor:n.surfaceCream},o],children:[e.length>0?jsx(p,{style:{fontSize:c.size.bodyTight,color:n.text.muted},children:e}):null,jsx(Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:r,testID:"records-gate-off-exit",style:{minHeight:Ry,alignSelf:"flex-start",justifyContent:"center",paddingHorizontal:l.lg,borderRadius:a.pill,borderWidth:1.5,borderColor:n.brandInk},children:jsx(p,{style:{fontSize:c.size.body,color:n.brandInk},children:r})})]})}i(vy,"RecordsGateOffState");function $e(e,t){return e===void 0?{}:{renderDisabled:i(r=>jsx(vy,{reason:r.disabled?.reason??"",onExit:e,exitLabel:t}),"renderDisabled")}}i($e,"recordsGateExit");var ho=Object.freeze({pressScale:.97,pressMs:160,riseWebPx:16,riseNativePx:14,fadeMs:320,moveMs:480,staggerMs:55,maxSteps:8});var Sy=52,Ro="rgba(0,0,0,0.4)";function Re(){let e=V();return useMemo(()=>ky(e),[e])}i(Re,"useScreenStyles");function Fr({disclaimer:e,style:t}){let r=Re();return e.trim().length===0?null:jsxs(View,{style:[r.band,t],accessible:true,accessibilityRole:"text",accessibilityLabel:vt.important(e),testID:"records-disclaimer-band",children:[jsx(View,{style:r.infoGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsx(p,{style:r.infoGlyphText,children:"i"})}),jsx(p,{style:r.bandText,children:e})]})}i(Fr,"DisclaimerBand");function X({label:e,onPress:t,kind:r="primary",disabled:o=false,busy:n=false,accessibilityLabel:l,testID:a,style:c}){let s=Re(),d=V(),u=d.motion.reducedMotion,m=r==="primary"?s.pillPrimary:r==="outline"?s.pillOutline:r==="danger"?s.pillDanger:r==="ask"?s.pillAsk:s.pillLink,y=r==="primary"?s.pillPrimaryLabel:r==="danger"?s.pillDangerLabel:r==="ask"?s.pillAskLabel:r==="link"?s.pillLinkLabel:s.pillOutlineLabel;return jsxs(Pressable,{onPress:t,disabled:o||n,accessibilityRole:"button",accessibilityLabel:l??e,accessibilityState:{disabled:o||n,busy:n},style:({pressed:g})=>[s.pill,m,o?s.pillDisabled:null,g&&!u?s.pressed:null,c],testID:a,children:[n?jsx(ActivityIndicator,{size:"small",color:r==="primary"?d.color.onPrimary:d.color.brandInk}):null,jsx(p,{style:y,children:e})]})}i(X,"Pill");function Lt({label:e,tone:t="neutral",testID:r}){let o=Re(),{bg:n,fg:l}=o.chipTones[t],a=e.length>Ty;return jsx(View,{style:[o.chip,a?o.chipSentence:null,n],testID:r,children:jsx(p,{style:[o.chipText,a?o.chipSentenceText:null,l],children:e})})}i(Lt,"Chip");var Ty=24;function Bt({title:e,count:t}){let r=Re();return jsxs(View,{style:r.sectionHeader,children:[jsx(p,{style:r.sectionTitle,accessibilityRole:"header",children:e}),t!==void 0?jsx(p,{style:r.sectionCount,children:t}):null]})}i(Bt,"SectionHeader");function er({direction:e="right"}){let t=Re(),r=e==="right"?"45deg":e==="down"?"135deg":"-45deg";return jsx(View,{style:[t.chevron,{transform:[{rotate:r}]}],accessibilityElementsHidden:true,importantForAccessibility:"no"})}i(er,"Chevron");function ky(e){let{color:t,space:r,radius:o,type:n,slots:l}=e,{size:a,lineHeight:c}=n,s=i((v,f)=>Math.round(v*f),"lh"),d=StyleSheet.hairlineWidth,u=r.xxl+r.md,m=i((v,f,b,C="regular")=>({...S(e,C),fontSize:v,lineHeight:s(v,f),color:b}),"text"),y=yt(l.recordCard),g=e.brightness==="dark"?t.errorRed:t.danger,w=i((v,f)=>({bg:{backgroundColor:v,borderColor:"transparent"},fg:{color:f}}),"tone"),R=i((v,f)=>({bg:{backgroundColor:t.surface,borderColor:v},fg:{color:f}}),"edge");return {chipTones:{neutral:R(t.brandBorderStrong,t.text.primary),info:w(t.brandSoft,t.brandInk),warning:R(t.cautionAccent,t.text.primary),critical:R(t.danger,t.danger),positive:R(t.success,t.brandInk)},...StyleSheet.create({root:{flex:1,backgroundColor:t.background},body:{flex:1},content:{paddingHorizontal:r.lg,paddingBottom:r.xxl,gap:r.lg},contentTight:{paddingHorizontal:r.sm,paddingBottom:r.xxl,gap:r.lg},inset:{paddingHorizontal:r.sm},section:{gap:r.sm+r.xs/2},sectionHeader:{flexDirection:"row",alignItems:"center",gap:r.sm,paddingHorizontal:r.xs},sectionTitle:{...m(a.subtitle,c.snug,t.text.primary,"bold"),letterSpacing:-0.4},sectionCount:{...m(a.bodyTight,c.snug,t.text.muted,"medium")},card:{borderRadius:o.lg,borderWidth:1,borderColor:t.borderRingCream,backgroundColor:t.surface,paddingHorizontal:r.lg,paddingVertical:r.xs,...dt(l.recordCard,d)},creamCard:{borderRadius:o.lg,borderWidth:1,borderColor:t.borderRingCream,backgroundColor:t.surfaceCream,padding:r.lg,gap:r.md,...dt(l.recordCard,d)},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.md,paddingVertical:r.md},rowDivider:{borderTopWidth:d,borderTopColor:t.borderHairlineGreen},rowMain:{flex:1},rowRight:{alignItems:"flex-end",gap:r.xs+r.xs/2},rowTitle:{...m(a.body,c.snug,t.text.primary,"medium"),...y},rowDetail:{...m(a.caption,c.normal,t.text.secondary),marginTop:r.xs/2,...y},rowValue:{...m(a.body+1,c.snug,t.text.primary,"bold"),marginTop:r.xs/2,...y},rowMuted:{...m(a.caption,c.normal,t.text.muted),...y},chip:{minHeight:24,justifyContent:"center",borderRadius:o.pill,borderWidth:1.5,paddingHorizontal:r.sm+r.xs/2,alignSelf:"flex-start"},chipText:{...m(a.tiny+1,c.snug,t.text.primary,"monoBold"),letterSpacing:.7,textTransform:"uppercase"},chipSentence:{borderRadius:o.md,paddingVertical:r.xs,alignSelf:"stretch"},chipSentenceText:{...m(a.caption,c.normal,t.text.primary,"medium"),letterSpacing:0,textTransform:"none"},pill:{minHeight:Sy,borderRadius:o.pill,paddingHorizontal:r.lg+r.xs/2,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:r.sm},pillPrimary:{backgroundColor:t.brand,...dt(l.primaryButton)},pillPrimaryLabel:{...m(a.body,c.snug,t.onPrimary,"bold"),...yt(l.primaryButton)},pillOutline:{borderWidth:1.5,borderColor:t.brandInk,backgroundColor:"transparent"},pillOutlineLabel:{...m(a.body,c.snug,t.brandInk,"bold")},pillDanger:{borderWidth:1.4,borderColor:t.danger,backgroundColor:t.surface},pillDangerLabel:{...m(a.bodyTight,c.snug,t.danger,"bold")},pillAsk:{borderWidth:d,borderColor:t.borderRingCream,backgroundColor:t.surface},pillAskLabel:{...m(a.body,c.snug,t.text.primary,"bold")},pillLink:{minHeight:u,backgroundColor:"transparent",paddingHorizontal:r.sm},pillLinkLabel:{...m(a.body,c.snug,t.linkInk,"bold")},pillDisabled:{opacity:.5},pressed:{transform:[{scale:ho.pressScale}]},infoNote:{flexDirection:"row",alignItems:"flex-start",gap:r.sm,borderRadius:o.md-r.xs/2,backgroundColor:t.brandSoft,paddingHorizontal:r.md,paddingVertical:r.sm+r.xs/2},infoNoteText:{flex:1,...m(a.bodyTight,c.normal,t.text.primary)},cautionNote:{flexDirection:"row",alignItems:"flex-start",gap:r.sm,borderRadius:o.md-r.xs/2,backgroundColor:t.badgeBgCaution,paddingHorizontal:r.md,paddingVertical:r.sm+r.xs/2},cautionNoteText:{flex:1,...m(a.bodyTight,c.normal,t.warningStrong)},statusCard:{borderRadius:o.md,backgroundColor:t.brandSoft,padding:r.md+r.xs/2},statusText:m(a.bodyTight,c.relaxed,t.text.primary),errorBanner:{flexDirection:"row",alignItems:"flex-start",gap:r.sm,borderRadius:o.md-r.xs/2,backgroundColor:t.badgeBgCritical,padding:r.md},errorText:{flex:1,...m(a.bodyTight,c.normal,g)},band:{flexDirection:"row",alignItems:"flex-start",gap:r.sm,borderRadius:o.md-r.xs/2,padding:r.md,backgroundColor:t.brandSoft},bandText:{flex:1,...m(a.caption,c.normal,t.text.secondary)},infoGlyph:{width:r.md+r.xs/2,height:r.md+r.xs/2,borderRadius:o.pill,borderWidth:1,borderColor:t.text.secondary,alignItems:"center",justifyContent:"center"},infoGlyphText:{...m(a.small,c.tight,t.text.secondary,"bold")},chevron:{width:r.sm,height:r.sm,borderTopWidth:r.xs/2,borderRightWidth:r.xs/2,borderColor:t.text.muted},lead:{paddingHorizontal:r.sm,...m(a.body+1,c.snug,t.text.primary,"bold")},field:{minHeight:u,paddingHorizontal:r.md,paddingVertical:r.sm,borderWidth:1,borderColor:t.borderHairlineGreen,borderRadius:o.sm,color:t.text.primary,backgroundColor:t.surface,...S(e,"regular"),fontSize:a.body},fieldLabel:{...m(a.bodyTight,c.normal,t.text.secondary,"medium")},muted:m(a.caption,c.normal,t.text.muted),bodyText:m(a.body,c.normal,t.text.primary)})}}i(ky,"makeScreenStyles");function rn(e,t){return e===null?"":t?`${e} ${t}`:e}i(rn,"formatEntityValue");var hc=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function re(e){if(!e)return "-";let t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(t!==null){let n=hc[Number(t[2])-1];return n===void 0?"-":`${n} ${Number(t[3])}, ${t[1]}`}let r=Date.parse(e);if(Number.isNaN(r))return "-";let o=new Date(r);return `${hc[o.getUTCMonth()]} ${o.getUTCDate()}, ${o.getUTCFullYear()}`}i(re,"formatRecordsDate");function Rc(e){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return e;let t=re(e),r=Number(e.slice(8,10));return t==="-"||r<1||r>31?e:t}i(Rc,"formatIdentityValue");var be=Object.freeze({timeline:"Timeline",loadingTimeline:"Loading timeline",labResults:"Blood & lab work",visits:"Visits",physicalExams:"Physical exams",visitNotes:"Visit notes",visit:"Visit",exam:"Exam",visitNote:"Visit note",notRecorded:"Not recorded",abnormal:"Abnormal",notExamined:"Not examined",normal:"Normal",measured:i(e=>`Measured ${e}`,"measured"),uploadedDocument:"Uploaded document",kind:Object.freeze({visit:"Visit",vaccine:"Vaccine",weight:"Weight",medication:"Medication"}),clinicVisit:"Clinic visit",doctor:i(e=>`Dr. ${e}`,"doctor"),lot:i(e=>`Lot ${e}`,"lot"),expires:i(e=>`Expires ${e}`,"expires")});function pr(e){switch(e){case "above":return {label:"Above range",outOfRange:true};case "below":return {label:"Below range",outOfRange:true};case "in_range":return {label:"In range",outOfRange:false};default:return {label:"No range on file",outOfRange:false}}}i(pr,"markerStatusLabel");function nn(e,t){return t<2?null:`${e==="flat"?"Holding steady":`Trending ${e==="down"?"down":e==="up"?"up":"steady"}`} over ${t} visits`}i(nn,"trajectoryLabel");function Rr(e){let t=e.replace(/_/g," ").trim();return t.length===0?e:t.charAt(0).toUpperCase()+t.slice(1)}i(Rr,"humanize");var vc=Object.freeze({general:"General / attitude",eent:"Eyes, ears, nose & throat",oral_dental:"Oral & dental",cardiovascular:"Cardiovascular",respiratory:"Respiratory",gastrointestinal:"GI / abdomen",urogenital:"Urogenital",musculoskeletal:"Musculoskeletal",neurologic:"Neurologic",integument:"Skin & coat",lymphatic:"Lymph nodes"});function Hr(e){return Object.prototype.hasOwnProperty.call(vc,e)?vc[e]:Rr(e)}i(Hr,"bodySystemLabel");var wc=Object.freeze({reason_for_visit:"Reason for visit",subjective:"Subjective",objective:"Objective",assessment:"Assessment",plan:"Plan",discharge_instructions:"Discharge instructions",follow_up:"Follow-up",remarks:"Notes"});function on(e){return Object.prototype.hasOwnProperty.call(wc,e)?wc[e]:Rr(e)}i(on,"soapSectionLabel");function xc(e){return e===null||!Number.isFinite(e)?"-":`${e.toFixed(3).replace(/\.?0+$/,"")} kg`}i(xc,"formatWeightKg");function Vt(e,t,r){if((e===null||!Number.isFinite(e))&&r)return r;if(e===null||!Number.isFinite(e))return "-";let o=e.toFixed(3).replace(/\.?0+$/,"");return t?`${o} ${t}`:o}i(Vt,"formatMarkerReading");function ds(e,t,r){let o=nn(t,r);return e?`${be.measured(re(e))}${o?` \xB7 ${o}`:""}`:o}i(ds,"labDetailLine");var ne=Object.freeze({title:"Visits & records",shareA11y:"Share medical record",requestClinicsA11y:"Request records from clinics",inReview:i(e=>`${e} ${e===1?"document":"documents"} from your vet ${e===1?"is":"are"} being reviewed. Your full record will appear here once review is complete.`,"inReview"),needsAttention:"Needs attention",conflictSub:"Two documents list different values. Your vet can confirm which is correct.",askConflict:"Ask Everfur about this",whatsOnFile:"What's on file",coverage:Object.freeze({labs:"Labs",vaccines:"Vaccines",weight:"Weight",vitals:"Vitals",exams:"Exams",procedures:"Procedures",genetics:"Genetics",parasite:"Parasite prevention",reproductive:"Reproductive"}),onFile:"on file",noneOnFile:"none on file",documentsOnFile:i(e=>`${e} ${e===1?"document":"documents"} on file`,"documentsOnFile"),inReviewChip:i(e=>`${e} in review`,"inReviewChip"),beingVerified:i(e=>`${e} being verified`,"beingVerified"),beingVerifiedA11y:i(e=>`${e} ${e===1?"fact is":"facts are"} being verified`,"beingVerifiedA11y"),pendingReview:"Pending review: ",dateRange:i((e,t)=>`${re(e)} to ${re(t)}`,"dateRange"),documents:"Sources on file",uploadedDocument:be.uploadedDocument,documentRowA11y:i(e=>`View what ${e} contributed to this record`,"documentRowA11y"),documentMeta:i((e,t)=>{let r=t?re(t):null,n=[e!==null&&Number.isInteger(e)&&e>0?`${e} ${e===1?"page":"pages"}`:null,r].filter(l=>l!==null);return n.length>0?n.join(" \xB7 "):null},"documentMeta"),identity:"Identity",needsReview:"Needs review",upcomingCare:"Upcoming care",careTimeline:"Care timeline",careTimelineSub:"Related records grouped over time, newest first.",lastDone:i(e=>`Last done ${e}`,"lastDone"),overdue:"Overdue",due:i(e=>`Due ${e}`,"due"),askUpcomingCare:"Ask Everfur about upcoming care",askEverfur:"Ask Everfur",askExam:"Ask Everfur about this exam",askVisit:"Ask Everfur about this visit",labResults:be.labResults,visits:be.visits,physicalExams:be.physicalExams,visitNotes:be.visitNotes,document:Object.freeze({title:"Health Record",titleFor:i(e=>{let t=e?.trim()??"";return t.length>0?`${t}\u2019s health record`:"Health Record"},"titleFor"),download:"Download PDF",empty:"This record is empty for now.",docTitle:"Medical Record",namelessPet:"Your pet",generated:i(e=>`Generated ${re(e)}`,"generated"),identity:"Identity",labs:"Blood & Lab Work",ref:i(e=>`Ref ${e}`,"ref"),noRange:"No reference range",upcomingCare:"Upcoming Care",physicalExams:"Physical Exams",clinicianNotes:"Clinician Notes"})}),Cc=Object.freeze({vaccination:"Vaccinations",medication:"Medications",problem:"Problems & diagnoses",procedure:"Procedures & surgery",allergy:"Allergies",parasite_prevention:"Parasite prevention",reproductive:"Reproductive history",vital:"Vitals",body_weight:"Weight",lab_result:"Lab results",imaging:"Imaging & radiology",genetic_result:"Genetic testing",document_note:"Other notes"});function vr(e){return Object.prototype.hasOwnProperty.call(Cc,e)?Cc[e]:Rr(e)}i(vr,"entityTypeLabel");var Ec=Object.freeze(["vaccination","medication","problem","procedure","allergy","parasite_prevention","reproductive","vital","body_weight"]);function vo(e){let t=Ec.filter(o=>e.includes(o)),r=e.filter(o=>!Ec.includes(o));return [...t,...r]}i(vo,"orderEntityTypes");function wo(e){switch(e){case "identity_risk":return {label:"Identity mismatch",rank:0,tone:"critical"};case "benign":return {label:"Minor difference",rank:2,tone:"neutral"};default:return {label:"Needs review",rank:1,tone:"warning"}}}i(wo,"conflictSeverityMeta");function Dn(e,t){if(!e)return null;let r=Date.parse(e);if(Number.isNaN(r))return null;let o=r<t-1440*60*1e3;return {label:o?ne.overdue:ne.due(re(e)),overdue:o}}i(Dn,"dueBadge");function Sc(e){return e===null?null:e.refLow!==null&&e.refHigh!==null?`${e.refLow}-${e.refHigh}`:e.refLow!==null?`\u2265 ${e.refLow}`:e.refHigh!==null?`\u2264 ${e.refHigh}`:null}i(Sc,"formatReferenceBand");var j=Object.freeze({openA11y:"Share medical record",openA11yFor:i(e=>{let t=e?.trim()??"";return t.length>0?`Share ${t}\u2019s record`:"Share medical record"},"openA11yFor"),title:"Share medical record",titleFor:i(e=>{let t=e?.trim()??"";return t.length>0?`Send ${t}\u2019s record`:"Share medical record"},"titleFor"),helper:"Anyone with an active link can view this record until it expires. You can turn a link off anytime.",leadNative:"Pick who it\u2019s for; we include the right pages.",leadWebFor:i(e=>{let t=e?.trim()??"";return t.length>0?`Share a snapshot of what ${t}\u2019s vets recorded. Pick who it\u2019s for and we include the right pages.`:"Pick who it\u2019s for; we include the right pages."},"leadWebFor"),audienceLabel:"Who it\u2019s for",audiences:Object.freeze({vet:"Vet",groomer:"Groomer",boarding:"Boarding"}),included:"What\u2019s included",sendTo:"Send to",sendToPlaceholder:"vet@example.com\u2026",send:"Send",sending:"Sending\u2026",addEmailFor:i(e=>{let t=e?.trim()??"";return t.length>0?`Add an email to send ${t}\u2019s record.`:"Add an email to send the record."},"addEmailFor"),emailInvalid:"That email doesn\u2019t look right. Check it and try again.",emailFailed:"Could not send the email. Please try again.",close:"Close",closeSheetA11y:"Close share sheet",viewDocument:"View document",previewNative:"Preview what they get",createLink:"Create link and share",shareLinkNative:"Share link",linkTerms:"Sent as a secure link that works for 7 days. You can stop sharing it any time.",creatingLink:"Creating link...",downloadPdf:"Download PDF",preparingPdf:"Preparing PDF...",activeLinks:"Active links",loadingLinks:"Loading your share links",errorTitle:"Couldn\u2019t load your links",errorBody:"Check your connection and try again. You can still create a new link above.",retry:"Try again",retrying:"Retrying...",emptyTitle:"No active links yet",emptyBody:"Create a link above to let your vet or a sitter view this record. It expires on its own, and you can turn it off anytime.",copyLink:"Copy link",copyLinkA11y:i(e=>`Copy share link, ${e}`,"copyLinkA11y"),turnOff:"Turn off",turnOffA11y:i(e=>`Turn off share link, ${e}`,"turnOffA11y"),turningOff:"Turning off...",keep:"Keep",confirmTurnOff:"Turn off this link? Anyone who has it will lose access.",shareMessage:i(e=>`View this medical record: ${e}`,"shareMessage"),consentOffTitle:"Records access is off",consentOffBody:"Allow records for this pet again to create a link or download the PDF. Any links that were live have been turned off. You can still turn off a link from this list.",toasts:Object.freeze({noAddress:"Link created, but no address came back. It is listed under Active links.",shareSheet:"Could not open the share sheet. The link is saved below.",pdfShareSheet:"Could not open the share sheet for this PDF.",copied:"Link copied.",copyFailed:"Could not copy the link.",copiedNative:"Link copied. It works for 7 days.",copyFailedNative:i(e=>`Couldn\u2019t copy. The link is ${e}`,"copyFailedNative"),turnedOff:"Link turned off.",sentTo:i(e=>`Sent to ${e}. The link works for 7 days.`,"sentTo")})}),_y=Object.freeze(["Vaccines, medications and allergies","Conditions and procedures, with dates"]),Py=Object.freeze([["encounters","encounters",be.visits],["lab_results","markers",be.labResults],["physical_exams","physical_exams",be.physicalExams]]);function Tc(e,t){let r=[];e.sections.includes("entities")&&(e.entityTypes===null?r.push(..._y):r.push(...vo(e.entityTypes).map(vr)));for(let[o,n,l]of Py)e.sections.includes(o)&&t[n]===true&&r.push(l);return e.sections.includes("forward_looking")&&r.push(ne.upcomingCare),Object.freeze(r)}i(Tc,"shareIncludedLines");function Iy(e,t){if(!e)return false;let r=Date.parse(e);return Number.isNaN(r)?false:r<=t}i(Iy,"isShareExpired");function Dy(e,t){let r=re(e);return r==="-"?t?"Expired":"No expiry date":t?`Expired ${r}`:`Expires ${r}`}i(Dy,"formatShareExpiry");function kc(e,t,r){let o=e.map(n=>{let l=Iy(n.expiresAt,r),a=Dy(n.expiresAt,l),c=re(n.createdAt),s=l?"Expired":"Active",d=a.replace(/^Expires /,"expiring ").replace(/^Expired /,"expired ").replace(/^Expired$/,"expired").replace(/^No expiry date$/,"with no expiry date");return {shareId:n.shareId,shareUrl:t[n.shareId]??null,active:!l,statusLabel:s,expiryLabel:a,createdLabel:c==="-"?null:`Created ${c}`,a11yLabel:`Share link. ${s}. ${a}.`,actionContext:d}});return Object.freeze([...o.filter(n=>n.active),...o.filter(n=>!n.active)])}i(kc,"buildShareRows");function An(e,t){let r=e?.httpStatus;if(ar(e)){if(t==="create"||t==="email")return "Records access for this pet is off, so a new link cannot be created.";if(t==="download")return "Records access for this pet is off, so the PDF cannot be downloaded."}if(r===429)return "You are creating links a little too fast. Wait a moment, then try again.";if(t==="revoke"&&(r===404||r===409||r===410))return "That link was already turned off.";if(r===401||r===403)return "You need to be signed in as this pet's owner to do that.";if(t==="email"&&(r===400||r===422||e?.code==="validationFailed"))return j.emailInvalid;switch(t){case "create":return "Could not create a share link. Please try again.";case "revoke":return "Could not turn off that link. Please try again.";case "email":return j.emailFailed;default:return "Could not download the record PDF. Please try again."}}i(An,"shareErrorMessage");function _e({width:e,height:t,radius:r,style:o}){let{color:n,radius:l}=V();return jsx(View,{style:[{width:e,height:t,borderRadius:r??l.xs,backgroundColor:n.skeleton},o],accessibilityElementsHidden:true,importantForAccessibility:"no"})}i(_e,"SkeletonBlock");var us=180,Pc=70,xo=22,Oy=300,Ic=44,Co=24,ps=34,Ly=6,Vy=5;function Eo({testID:e}){let t=On(),r=i(o=>jsxs(View,{style:t.actionRow,children:[jsxs(View,{style:t.actionLeft,children:[jsx(_e,{width:18,height:18,radius:9}),jsx(_e,{width:"55%",height:14,radius:7})]}),jsx(_e,{width:18,height:18,radius:9})]},o),"action");return jsxs(View,{style:t.dashboard,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:vt.loading,testID:e,children:[jsx(View,{style:t.inset,children:jsxs(View,{style:t.summaryCard,children:[jsx(_e,{width:us,height:us,radius:us/2}),jsxs(View,{style:t.badges,children:[jsx(_e,{width:Pc,height:xo,radius:xo/2}),jsx(_e,{width:Pc,height:xo,radius:xo/2})]})]})}),jsx(_e,{width:150,height:16,radius:8,style:t.inset}),jsx(View,{style:t.carouselCard,children:jsx(_e,{width:"100%",height:Oy,radius:14})}),jsxs(View,{style:t.dots,children:[jsx(_e,{width:6,height:6,radius:3}),jsx(_e,{width:18,height:6,radius:3}),jsx(_e,{width:6,height:6,radius:3})]}),jsx(_e,{width:46,height:12,radius:6,style:t.centered}),jsx(View,{style:t.inset,children:jsx(_e,{width:"100%",height:Ic,radius:12})}),jsxs(View,{style:[t.inset,t.actions],children:[r("a"),r("b")]})]})}i(Eo,"DashboardSkeleton");function So({testID:e}){let t=On();return jsxs(View,{style:t.request,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:fe.loading,testID:e,children:[jsx(View,{children:[0,1,2,3].map(r=>jsxs(View,{style:t.railRow,children:[jsxs(View,{style:t.railColumn,children:[jsx(_e,{width:Co,height:Co,radius:Co/2}),r<3?jsx(_e,{width:2,height:20,radius:1,style:t.connector}):null]}),jsxs(View,{style:t.railBody,children:[jsx(_e,{width:"55%",height:14,radius:7}),jsx(_e,{width:"75%",height:11,radius:6})]})]},r))}),jsxs(View,{style:t.statusCard,children:[jsx(_e,{width:"90%",height:13,radius:6}),jsx(_e,{width:"60%",height:13,radius:6})]}),jsx(_e,{width:"100%",height:50,radius:25})]})}i(So,"RequestSkeleton");function Dc({testID:e}){let t=On();return jsxs(View,{style:t.timeline,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:be.loadingTimeline,testID:e,children:[jsx(View,{style:t.timelineDisclaimer,children:jsx(_e,{width:"100%",height:Ic,radius:12})}),Array.from({length:Ly},(r,o)=>jsxs(View,{children:[o>0?jsx(View,{style:t.timelineSeparator}):null,jsxs(View,{style:t.timelineRow,children:[jsx(_e,{width:ps,height:ps,radius:ps/2}),jsxs(View,{style:t.timelineBody,children:[jsxs(View,{style:t.timelineTop,children:[jsx(_e,{width:44,height:10,radius:5}),jsx(_e,{width:56,height:12,radius:6})]}),jsx(_e,{width:"70%",height:14,radius:7}),o%2===0?jsx(_e,{width:"45%",height:12,radius:6}):null]})]})]},o))]})}i(Dc,"TimelineSkeleton");function Ac({testID:e}){let t=On();return jsx(View,{style:t.clinics,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:xe.loading,testID:e,children:Array.from({length:Vy},(r,o)=>jsxs(View,{style:t.clinicRow,children:[jsx(_e,{width:"65%",height:14,radius:7}),jsx(_e,{width:"40%",height:11,radius:6})]},o))})}i(Ac,"ClinicsSkeleton");function Oc({testID:e}){let t=On();return jsx(View,{style:t.shares,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:j.loadingLinks,testID:e,children:[0,1].map(r=>jsxs(View,{style:t.shareRow,children:[jsx(_e,{width:"55%",height:13}),jsx(_e,{width:"40%",height:11})]},r))})}i(Oc,"SharesSkeleton");var ms=62;function On(){let e=V();return useMemo(()=>Fy(e),[e])}i(On,"useStyles");function Fy(e){let{color:t,space:r,radius:o}=e,n=StyleSheet.hairlineWidth;return StyleSheet.create({dashboard:{flex:1,paddingHorizontal:r.sm,paddingTop:r.xs,gap:r.lg,backgroundColor:t.background},inset:{paddingHorizontal:r.sm},summaryCard:{alignItems:"center",borderRadius:o.lg-r.xs,borderWidth:n,borderColor:t.brandBorder,backgroundColor:t.surface,paddingHorizontal:r.lg,paddingVertical:r.lg+r.xs,gap:r.md+r.xs/2},badges:{flexDirection:"row",gap:r.md},carouselCard:{borderRadius:o.lg-r.xs,borderWidth:n,borderColor:t.brandBorder,backgroundColor:t.surface,padding:r.lg},dots:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:r.xs+r.xs/2},centered:{alignSelf:"center"},actions:{gap:r.sm+r.xs/2},actionRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",borderRadius:o.md,borderWidth:n,borderColor:t.brandBorder,backgroundColor:t.surface,paddingHorizontal:r.lg,paddingVertical:r.lg},actionLeft:{flex:1,flexDirection:"row",alignItems:"center",gap:r.md},request:{paddingHorizontal:r.lg,paddingTop:r.xs,gap:r.lg+r.xs/2,backgroundColor:t.background},railRow:{flexDirection:"row",alignItems:"flex-start",gap:r.md},railColumn:{alignItems:"center",width:Co},connector:{marginVertical:r.xs/2},railBody:{flex:1,paddingBottom:r.lg+r.xs/2,gap:r.xs+r.xs/2},statusCard:{borderRadius:o.md,backgroundColor:t.brandSoft,padding:r.md+r.xs/2,gap:r.sm},timeline:{flex:1,backgroundColor:t.background},timelineDisclaimer:{paddingHorizontal:r.lg,paddingTop:r.xs,paddingBottom:r.md},timelineRow:{flexDirection:"row",gap:r.md,paddingHorizontal:r.lg,paddingVertical:r.md+r.xs/2},timelineBody:{flex:1,gap:r.xs-1},timelineTop:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},timelineSeparator:{height:n,backgroundColor:t.brandBorder,marginLeft:ms},clinics:{gap:r.md},clinicRow:{borderRadius:o.lg-r.xs/2,borderWidth:n,borderColor:t.brandBorder,backgroundColor:t.surface,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md+r.xs/2,gap:r.sm},shares:{gap:r.md,padding:r.md,borderRadius:o.md,backgroundColor:t.surfaceCream,borderWidth:n,borderColor:t.brandBorder},shareRow:{gap:r.xs+r.xs/2}})}i(Fy,"makeStyles");var By=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function ys(e){let{userRef:t,scopeEpoch:r}=Te();return jsx(Ue,{capability:"recordsClinic",style:e.style,...$e(e.onBack,ot),children:t===null?jsx(p,{accessibilityRole:"alert",children:ve.sessionRequired}):jsx(Uy,{...Be(e,["onNavigate","onBack"])},JSON.stringify([t,r,e.petRef]))})}i(ys,"EverfurClinicPicker");function Uy({petRef:e,petName:t,controller:r,recordsController:o,location:n,onNavigate:l,onBack:a,style:c}){let s=Re(),d=$y(),u=V(),m=Zt(),y=Bl(r??m,n),g=mt(o?{petRef:e,controller:o}:{petRef:e}),w=useRef(gr()),[R,v]=useState(false),[f,b]=useState(null),[C,h]=useState(false),[I,T]=useState(""),[k,_]=useState(false),[E,B]=useState(""),[x,A]=useState(false),z=useCallback(D=>{l?.({name:"consent",clinic:es(D,null,"",w.current())});},[l]),de=i(()=>{R||(v(true),b(null),g.createRequest(`records-upload-${Date.now().toString(36)}`).then(D=>{if(v(false),!D.ok){b(fe.errors.start);return}l?.({name:"request",requestId:D.value.id});}));},"startUpload"),G=k?I:y.query,ae=By.test(E.trim()),M=G.trim().length>0&&ae,$=i(D=>{let{layoutMeasurement:q,contentOffset:ee,contentSize:J}=D.nativeEvent;q.height+ee.y>=J.height-q.height*.6&&y.loadMore();},"onEndReached"),O=y.isSearchActive?y.clinics:y.recent,U=y.isSearchActive?y.error?wt(y.error):!y.initialLoading&&y.clinics.length===0?"idle":null:y.recent.length>0||y.recentLoading?null:"idle";return jsxs(View,{style:[s.root,c],children:[jsx(it,{title:xe.titleFor(t),onBack:a,testID:"records-clinic-header"}),jsx(p,{style:d.lead,testID:"records-clinic-lead",children:xe.leadNative}),jsxs(View,{style:d.searchBar,children:[jsx(View,{style:d.searchGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsx(Qe,{value:y.query,onChangeText:y.setQuery,placeholder:xe.placeholder,placeholderTextColor:u.color.text.muted,autoCorrect:false,autoCapitalize:"words",returnKeyType:"search",maxLength:200,accessibilityLabel:xe.searchA11y,style:d.searchInput,testID:"records-clinic-search-input"}),y.query.length>0?jsx(Pressable,{onPress:()=>y.setQuery(""),accessibilityRole:"button",accessibilityLabel:xe.clearSearch,hitSlop:8,testID:"records-clinic-search-clear",children:jsx(p,{style:d.clearGlyph,children:"\xD7"})}):null]}),l?jsxs(View,{style:d.uploadWrap,children:[f?jsx(View,{style:s.errorBanner,accessibilityRole:"alert",children:jsx(p,{style:s.errorText,children:f})}):null,jsx(X,{label:R?xe.uploadOwnStarting:xe.uploadOwn,kind:"outline",accessibilityLabel:xe.uploadOwnA11y,busy:R,onPress:de,testID:"records-clinic-upload-own"})]}):null,jsxs(ScrollView,{contentContainerStyle:d.list,keyboardShouldPersistTaps:"handled",onScroll:y.isSearchActive?$:void 0,scrollEventThrottle:200,testID:"records-clinic-results",children:[y.isSearchActive?jsxs(View,{style:d.fallbackCard,testID:"records-clinic-fallback-card",children:[jsxs(Pressable,{onPress:()=>h(D=>!D),accessibilityRole:"button",accessibilityLabel:C?xe.fallback.collapseA11y:xe.fallback.expandA11y,style:d.fallbackHeader,testID:"records-clinic-fallback",children:[jsxs(View,{style:d.fallbackCopy,children:[jsx(p,{style:d.fallbackTitle,numberOfLines:1,children:xe.fallback.title}),jsx(p,{style:d.fallbackSubtitle,numberOfLines:2,children:xe.fallback.subtitle})]}),jsx(er,{direction:C?"up":"down"})]}),C?jsxs(View,{style:d.fallbackForm,children:[jsx(p,{style:s.fieldLabel,children:xe.fallback.nameLabel}),jsx(Qe,{accessibilityLabel:xe.fallback.nameLabel,style:s.field,value:G,onChangeText:D=>{T(D),_(true);},placeholder:xe.fallback.namePlaceholder,placeholderTextColor:u.color.text.placeholder,autoCapitalize:"words",autoCorrect:false,maxLength:200,testID:"records-clinic-fallback-name"}),jsx(p,{style:s.fieldLabel,children:xe.fallback.emailLabel}),jsx(Qe,{accessibilityLabel:xe.fallback.emailLabel,style:s.field,value:E,onChangeText:D=>{B(D),A(false);},onBlur:()=>A(true),placeholder:xe.fallback.emailPlaceholder,placeholderTextColor:u.color.text.placeholder,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,maxLength:320,testID:"records-clinic-fallback-email"}),x&&E.trim().length>0&&!ae?jsx(p,{style:s.errorText,accessibilityRole:"alert",children:fe.errors.invalidEmail}):null,jsx(p,{style:s.muted,children:xe.fallback.reviewNote}),jsx(X,{label:xe.fallback.submit,accessibilityLabel:xe.fallback.submitA11y,disabled:!M||!l,onPress:()=>l?.({name:"consent",clinic:es(null,G.trim(),E.trim().toLowerCase(),w.current())}),testID:"records-clinic-fallback-submit"})]}):null]}):y.recent.length>0?jsx(p,{style:d.sectionLabel,accessibilityRole:"header",testID:"records-clinic-recent-label",children:xe.recentlyUsed}):null,y.isSearchActive&&y.initialLoading?jsx(Ac,{testID:"records-clinic-page-loading"}):null,O.map(D=>jsx(jy,{clinic:D,onSelect:z,styles:d},D.id)),U&&!y.initialLoading?jsx(Xe,{variant:U,message:y.isSearchActive&&U==="idle"?xe.noMatch(y.debouncedQuery):y.error?.displayMessage,onAction:y.error?.retryable===true?y.retry:void 0,testID:"records-clinic-empty"}):null,jsxs(View,{style:d.footer,children:[y.loadingMore?jsxs(View,{style:d.footerLoading,testID:"records-clinic-loading-more",children:[jsx(ActivityIndicator,{color:u.color.brandInk,size:"small"}),jsx(p,{style:s.muted,children:xe.loadingMore})]}):null,y.pageError?jsx(Pressable,{onPress:y.loadMore,accessibilityRole:"button",accessibilityLabel:xe.loadMoreRetryA11y,style:d.footerRetry,testID:"records-clinic-page-error-retry",children:jsx(p,{style:d.footerRetryLabel,children:xe.loadMoreFailed})}):null]}),jsxs(View,{style:d.howCard,accessibilityRole:"summary",testID:"records-clinic-how",children:[jsx(p,{style:d.howTitle,accessibilityRole:"header",children:xe.howItWorks}),xe.howSteps(ke(t)).map((D,q)=>jsxs(View,{style:d.howRow,children:[jsx(p,{style:d.howNumber,accessibilityElementsHidden:true,importantForAccessibility:"no",children:String(q+1).padStart(2,"0")}),jsxs(View,{style:d.howText,children:[jsx(p,{style:d.howStepTitle,children:D.title}),jsx(p,{style:d.howStepBody,children:D.body})]})]},D.title))]})]}),jsx(je,{})]})}i(Uy,"PickerBody");function jy({clinic:e,onSelect:t,styles:r}){let o=Il(e.emailStatus),n=Al(e.distanceKm),l=[e.name,e.address,e.phone?`phone ${e.phone}`:null,n?Ol(e.distanceKm):null,o.a11y].filter(Boolean).join(", ");return jsxs(Pressable,{onPress:()=>t(e),accessibilityRole:"button",accessibilityLabel:xe.selectA11y(l),hitSlop:8,style:r.item,testID:`records-clinic-${e.id}`,children:[jsxs(View,{style:r.itemHeader,children:[jsx(p,{style:r.itemName,numberOfLines:1,children:e.name}),n?jsx(p,{style:r.itemDistance,accessibilityElementsHidden:true,importantForAccessibility:"no",children:n}):null]}),e.address?jsx(p,{style:r.itemAddress,numberOfLines:2,children:e.address}):null,e.phone?jsx(p,{style:r.itemPhone,numberOfLines:1,accessibilityElementsHidden:true,importantForAccessibility:"no",children:e.phone}):null,jsx(View,{style:[r.badge,o.tone==="positive"?r.badgePositive:o.tone==="caution"?r.badgeCaution:r.badgeNeutral],accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsx(p,{style:[r.badgeLabel,o.tone==="positive"?r.badgePositiveText:o.tone==="caution"?r.badgeCautionText:r.badgeNeutralText],children:o.label})})]})}i(jy,"ClinicRow");function $y(){let e=V();return useMemo(()=>Wy(e),[e])}i($y,"useLocalStyles");function Wy(e){let{color:t,space:r,radius:o,type:n}=e,l=StyleSheet.hairlineWidth,a=i((c,s,d,u="regular")=>({...S(e,u),fontSize:c,lineHeight:Math.round(c*s),color:d}),"text");return StyleSheet.create({lead:{...a(n.size.body,n.lineHeight.normal,t.text.muted),paddingHorizontal:r.lg,paddingBottom:r.md},howCard:{borderRadius:o.lg,backgroundColor:t.surfaceSubtle,padding:r.lg,gap:r.md,marginTop:r.sm},howTitle:{...a(n.size.subtitle,n.lineHeight.snug,t.text.primary,"bold"),letterSpacing:-0.4},howRow:{flexDirection:"row",gap:r.md},howNumber:{...S(e,"monoBold"),fontSize:n.size.caption,lineHeight:Math.round(n.size.body*n.lineHeight.snug),color:t.brandInk,minWidth:r.xl},howText:{flex:1,gap:r.xs/2},howStepTitle:a(n.size.body,n.lineHeight.snug,t.text.primary,"bold"),howStepBody:a(n.size.caption,n.lineHeight.normal,t.text.secondary),searchBar:{flexDirection:"row",alignItems:"center",gap:r.sm,paddingHorizontal:r.md+r.xs/2,height:r.xxl+r.md,marginHorizontal:r.lg,marginBottom:r.sm,borderRadius:o.lg+r.xs/2,backgroundColor:t.surfaceSubtle,borderWidth:l,borderColor:t.borderHairlineGreen},searchGlyph:{width:r.md,height:r.md,borderRadius:o.pill,borderWidth:2,borderColor:t.text.muted},searchInput:{flex:1,...a(n.size.body,n.lineHeight.snug,t.text.primary),paddingVertical:0},clearGlyph:a(n.size.heading,n.lineHeight.tight,t.text.muted),uploadWrap:{paddingHorizontal:r.lg,paddingBottom:r.md,gap:r.sm},list:{paddingHorizontal:r.lg,paddingBottom:r.xxl,gap:r.md},sectionLabel:{...a(n.size.caption,n.lineHeight.normal,t.text.secondary,"bold"),textTransform:"uppercase",letterSpacing:n.letterSpacing.eyebrow/2},fallbackCard:{borderRadius:o.lg-r.xs/2,borderWidth:1,borderStyle:"dashed",borderColor:t.brandBorder,backgroundColor:t.surfaceCream,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md,gap:r.md},fallbackHeader:{flexDirection:"row",alignItems:"center",gap:r.md,minHeight:r.xxl+r.md},fallbackCopy:{flex:1,gap:r.xs/2},fallbackTitle:{...a(n.size.body,n.lineHeight.snug,t.text.primary,"bold")},fallbackSubtitle:a(n.size.caption,n.lineHeight.normal,t.text.muted),fallbackForm:{gap:r.sm},item:{borderRadius:o.lg,borderWidth:1,borderColor:t.borderRingCream,backgroundColor:t.surface,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md,gap:r.sm},itemHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},itemName:{flex:1,...a(n.size.body,n.lineHeight.snug,t.brandInk,"bold")},itemDistance:{...S(e,"mono"),fontSize:n.size.tiny,lineHeight:n.size.body,color:t.text.muted},itemAddress:a(n.size.caption,n.lineHeight.normal,t.text.primary),itemPhone:a(n.size.caption,n.lineHeight.normal,t.text.muted),badge:{alignSelf:"flex-start",borderRadius:o.pill,paddingHorizontal:r.sm+1,paddingVertical:r.xs},badgePositive:{backgroundColor:t.badgeBgPositive},badgeCaution:{backgroundColor:t.badgeBgCaution},badgeNeutral:{backgroundColor:t.badgeBgNeutral},badgeLabel:{...a(n.size.micro,n.lineHeight.snug,t.text.muted,"bold")},badgePositiveText:{color:t.success},badgeCautionText:{color:t.cautionAccent},badgeNeutralText:{color:t.text.muted},footer:{gap:r.sm,paddingTop:r.sm},footerLoading:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:r.sm,minHeight:r.xxl+r.md},footerRetry:{minHeight:r.xxl+r.md,alignItems:"center",justifyContent:"center"},footerRetryLabel:{...a(n.size.bodyTight,n.lineHeight.snug,t.brandInk,"bold")}})}i(Wy,"makeLocalStyles");var We=Object.freeze({title:"Request records",resultTitle:"Request status",addClinic:"Add a clinic",atCap:`Up to ${tn} clinics`,sendA11y:i(e=>e===1?"Send 1 records request":`Send ${e} records requests`,"sendA11y"),send:i(e=>`Send ${e} ${e===1?"request":"requests"}`,"send"),sending:"Sending\u2026",addToContinue:"Add a clinic to continue",tryAgain:"Try again",remove:i(e=>`Remove ${e}`,"remove"),emailToAdd:"Email to add",perClinic:"Per-clinic result",sent:"Sent",notSent:"Not sent",allFailed:"We couldn\u2019t send any of these requests. See the details below and try again.",partial:i((e,t,r)=>`${e} of ${t} requests sent. ${r} couldn\u2019t be sent.`,"partial"),allSent:i(e=>`${e} ${e===1?"request":"requests"} sent.`,"allSent"),responded:i((e,t)=>`${e} of ${t} ${t===1?"clinic":"clinics"} responded`,"responded")});var _o=25,ko=5;function Po(e){let[t,r]=useState({list:e,shown:ko}),o=t.list===e?t.shown:ko,n=useCallback(()=>{r(l=>({list:e,shown:(l.list===e?l.shown:ko)+ko}));},[e]);return {visible:e.slice(0,o),hasMore:e.length>o,showMore:n}}i(Po,"useVisibleClinics");function Ln(e,t,r,o){let n={owner_name:t,pet_name:r,clinic_name:o},l=false,a=e.scopeTemplate.replace(/\{([^{}]+)\}/g,(c,s)=>Object.prototype.hasOwnProperty.call(n,s)?n[s]??"":(l=true,""));return l||/[{}]/.test(a)?null:a}i(Ln,"renderClinicScope");function Vn(e){return e===null||e.emailStatus!=="verified"&&e.emailStatus!=="unverified"}i(Vn,"clinicNeedsEmail");function Vc(e,t,r){let[o,n]=useState(e.ownerName),[l,a]=useState(""),[c,s]=useState(null),[d,u]=useState(""),[m,y]=useState([]),[g,w]=useState([]),[R,v]=useState(null),[f,b]=useState(null),[C,h]=useState(false),[I,T]=useState(false),[k,_]=useState(null),[E,B]=useState(0),x=useRef(false),A=useRef(false),z=useRef(0),de=useRef(gr()),G=useRef(null),ae=useRef(null),M=useRef(0);useEffect(()=>(x.current=true,A.current=false,h(false),()=>{x.current=false,M.current+=1,z.current+=1,G.current=null,ae.current?.abort();}),[t]),useEffect(()=>{let N=true;return v(null),G.current=null,t.getAuthorizationCopy().then(ie=>{N&&(ie.ok?(v(ie.value),b(null)):b(ie.error));}).catch(()=>{N&&b(W("internalError"));}),()=>{N=false;}},[t,E]),useEffect(()=>{let N=true;return w([]),t.recentClinics({limit:5}).then(ie=>{N&&ie.ok&&w(ie.value.clinics);}).catch(()=>{}),()=>{N=false;}},[t]);let $=i(()=>{G.current=null,b(null);},"invalidate"),O=c?.name??l.trim(),U=R?Ln(R,o.trim(),e.petName,O):null,D=Vn(c),q=Po(m),ee=!!(R&&U&&o.trim()&&e.petName.trim()&&O&&(!D||/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(d.trim()))&&r),J=i(async()=>{if(A.current)return;let N=++z.current;T(true);try{let ie=await t.searchClinics({query:l.trim(),limit:_o});if(!x.current||N!==z.current)return;ie.ok?(y(ie.value.clinics),b(null)):b(ie.error);}catch{x.current&&N===z.current&&b(W("internalError"));}finally{x.current&&N===z.current&&T(false);}},"search"),H=i(async()=>{if(A.current||k||!ee||!R||!U||!r)return;A.current=true;let N=M.current,ie=i(()=>x.current&&M.current===N,"current");h(true),b(null);try{if(!G.current){ae.current=new AbortController;let Le=await r({petRef:e.petRef,petName:e.petName,ownerName:o.trim(),clinicName:O,authorizationVersion:R.authorizationVersion,scopeText:U,signal:ae.current.signal});if(!ie()||Le===null)return;let rt=c&&(!D||c.emailStatus==="none")?{clinicId:c.id}:{clinicFreeText:O};G.current={petRef:e.petRef,ownerName:o.trim(),authorizationVersion:R.authorizationVersion,...rt,...D?{clinicEmail:d.trim().toLowerCase()}:{},...Le.signatureId!==void 0?{signatureId:Le.signatureId}:{signaturePngBase64:Le.signaturePngBase64},idempotencyKey:de.current()};}if(!ie())return;let Ce=await t.createClinicRequest(G.current);if(!ie())return;if(!Ce.ok){b(Ce.error);return}if(Ce.value.petRef!==e.petRef){b(W("internalError"));return}_(Ce.value),G.current=null,e.onCreated?.(Ce.value);}catch{ie()&&b(W("internalError"));}finally{A.current=false,ie()&&h(false);}},"submit");return {ownerName:o,query:l,clinic:c,email:d,clinics:m,copy:R,scope:U,error:f,busy:C,searching:I,created:k,ready:ee,needsEmail:D,visibleClinics:q.visible,hasMoreClinics:q.hasMore,showMoreClinics:q.showMore,recent:m.length===0&&c===null?g:[],setOwnerName(N){A.current||($(),n(N));},setQuery(N){A.current||($(),z.current+=1,T(false),y([]),s(null),u(""),a(N));},setEmail(N){A.current||($(),u(N));},selectClinic(N){A.current||($(),z.current+=1,T(false),y([]),s(N),a(N.name),u(""));},invalidate:$,search:J,submit:H,retryCopy(){b(null),B(N=>N+1);}}}i(Vc,"useClinicRequestForm");var Ky=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function qn(e){return e.clinic?.name??e.freeText??""}i(qn,"draftName");function Fn(e){return Vn(e.clinic)}i(Fn,"draftNeedsEmail");function Fc(e,t,r,o,n){let[l,a]=useState(e.ownerName),[c,s]=useState(""),[d,u]=useState([]),[m,y]=useState([]),[g,w]=useState([]),[R,v]=useState(null),[f,b]=useState(null),[C,h]=useState(false),[I,T]=useState(false),[k,_]=useState(null),[E,B]=useState(null),[x,A]=useState(0),z=useRef(false),de=useRef(false),G=useRef(0),ae=useRef(0),M=useRef(gr()),$=useRef(null),O=useRef(null);useEffect(()=>(z.current=true,de.current=false,h(false),()=>{z.current=false,ae.current+=1,G.current+=1,$.current=null,O.current?.abort();}),[t,r]),useEffect(()=>{let le=true;return v(null),$.current=null,t.getAuthorizationCopy().then(Pe=>{le&&(Pe.ok?(v(Pe.value),b(null)):b(Pe.error));}).catch(()=>{le&&b(W("internalError"));}),()=>{le=false;}},[t,x]),useEffect(()=>{let le=true;return y([]),t.recentClinics({limit:5}).then(Pe=>{le&&Pe.ok&&y(Pe.value.clinics);}).catch(()=>{}),()=>{le=false;}},[t]);let U=Po(d),D=i(()=>{$.current=null,b(null);},"invalidate"),q=g.map(qn),ee=R?q.map(le=>Ln(R,l.trim(),e.petName,le)):[],J=ee.every(le=>le!==null)?ee.join(`
2
2
 
3
- `):null,se=b.length>0&&b.every(M=>!Sn(M)||iy.test(M.email.trim())),re=b.length>=Gr,Ee=!!(v&&O&&a.trim()&&e.petName.trim()&&se&&o)&&E===null,Ct=i(async()=>{if(ce.current)return;let M=++oe.current;S(true);try{let we=await t.searchClinics({query:c.trim(),limit:100});if(!$.current||M!==oe.current)return;we.ok?(u(we.value.clinics),y(null)):y(we.error);}catch{$.current&&M===oe.current&&y(N("internalError"));}finally{$.current&&M===oe.current&&S(false);}},"search"),rt=i(M=>{ce.current||re||E!==null||M.clinic!==null&&b.some(we=>we.clinic?.id===M.clinic?.id)||(L(),R(we=>[...we,{...M,key:ie.current(),idempotencyKey:ie.current()}]),u([]),s(""));},"add"),Nt=i(async()=>{if(ce.current||E!==null||!Ee||!v||!O||!o)return;ce.current=true;let M=ve.current,we=i(()=>$.current&&ve.current===M,"current");h(true),y(null);try{if(T.current===null){D.current=new AbortController;let Et=await o({petRef:e.petRef,petName:e.petName,ownerName:a.trim(),clinicName:B.join(", "),authorizationVersion:v.authorizationVersion,scopeText:O,signal:D.current.signal});if(!we()||Et===null)return;if(T.current=Et,Et.signaturePngBase64!==void 0&&n!==void 0){let du=await n(Et.signaturePngBase64,D.current.signal);if(!we())return;T.current={signatureId:du.signatureId};}}let Bt=T.current,an=b.map(Et=>({...Et.clinic!==null&&(!Sn(Et)||Et.clinic.emailStatus==="none")?{clinicId:Et.clinic.id}:{clinicFreeText:kn(Et)},...Sn(Et)?{clinicEmail:Et.email.trim().toLowerCase()}:{},...Bt.signatureId!==void 0?{signatureId:Bt.signatureId}:{signaturePngBase64:Bt.signaturePngBase64},idempotencyKey:Et.idempotencyKey})),ln=await r.createClinicRequestBatch({petRef:e.petRef,ownerName:a.trim(),authorizationVersion:v.authorizationVersion,clinics:an});if(!we())return;if(!ln.ok){y(ln.error);return}C(ln.value),e.onCreated?.(ln.value),Mt(ln.value.requestGroupId,M);}catch{we()&&y(N("internalError"));}finally{ce.current=false,we()&&h(false);}},"submit"),Mt=i(async(M,we)=>{try{let Bt=await t.getRequestGroup(M);if(!$.current||ve.current!==we)return;Bt.ok&&Bt.value.petRef===e.petRef&&F(Bt.value);}catch{}},"loadGroup"),ke=i(async()=>{E===null||ce.current||await Mt(E.requestGroupId,ve.current);},"refreshGroup");return {ownerName:a,query:c,clinics:d,copy:v,scopeText:O,error:g,busy:x,searching:P,drafts:b,outcome:E,group:I,ready:Ee,atCap:re,recent:d.length===0?p.filter(M=>!b.some(we=>we.clinic?.id===M.id)):[],setOwnerName(M){ce.current||(L(),l(M));},setQuery(M){ce.current||(oe.current+=1,S(false),u([]),s(M));},search:Ct,addClinic(M){rt({clinic:M,freeText:null,email:""});},addFreeText(){let M=c.trim();M.length!==0&&rt({clinic:null,freeText:M,email:""});},setDraftEmail(M,we){ce.current||(L(),R(Bt=>Bt.map(an=>an.key===M?{...an,email:we}:an)));},removeDraft(M){ce.current||E!==null||(L(),R(we=>we.filter(Bt=>Bt.key!==M)));},submit:Nt,refreshGroup:ke,retryCopy(){y(null),j(M=>M+1);}}}i(tc,"useClinicBatchForm");function rc(e){try{let t=new URL(e);if(t.protocol!=="https:"||t.username||t.password||t.port&&t.port!=="443")return !1;let r=t.hostname.toLowerCase();return r==="s3.amazonaws.com"||r.endsWith(".s3.amazonaws.com")||/^(?:[a-z0-9][a-z0-9.-]*\.)?s3[.-][a-z0-9-]+\.amazonaws\.com$/.test(r)||/^(?:[a-z0-9][a-z0-9.-]*\.)?s3\.dualstack\.[a-z0-9-]+\.amazonaws\.com$/.test(r)||r==="s3-accelerate.amazonaws.com"||r.endsWith(".s3-accelerate.amazonaws.com")||r==="s3-accelerate.dualstack.amazonaws.com"||r.endsWith(".s3-accelerate.dualstack.amazonaws.com")}catch{return false}}i(rc,"trustedSignatureUploadUrl");var sy="Signature upload failed",ay=3e4;function ly(e){let t=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-t}i(ly,"base64ByteLength");async function Ki(e,t,r,o){let n=i(()=>new Error(sy),"fail"),a=ly(e);if(a<=0||r.aborted)throw n();let l=await t.initiateSignatureUpload(a);if(!l.ok||r.aborted||!rc(l.value.uploadUrl))throw n();let c=new FormData;for(let[f,b]of Object.entries(l.value.uploadFields))c.append(f,b);c.append("file",{uri:`data:image/png;base64,${e}`,name:"signature.png",type:"image/png"});let s=new AbortController,d=i(()=>s.abort(),"onAbort");r.addEventListener("abort",d,{once:true});let u=setTimeout(d,ay);try{if(!(await(o??fetch)(l.value.uploadUrl,{method:"POST",body:c,credentials:"omit",signal:s.signal})).ok||r.aborted)throw n()}catch{throw n()}finally{clearTimeout(u),r.removeEventListener("abort",d);}let p=await t.completeSignatureUpload(l.value.uploadId);if(!p.ok||r.aborted)throw n();return {signatureId:p.value}}i(Ki,"registerRnSignature");var Xr=Object.freeze({width:360,height:120});function sc(e,t){return {width:e,height:t,pixels:new Uint8Array(e*t)}}i(sc,"blank");function ac(e,t,r,o){for(let n=-o;n<=o;n+=1)for(let a=-o;a<=o;a+=1){if(a*a+n*n>o*o+o)continue;let l=t+a,c=r+n;l<0||c<0||l>=e.width||c>=e.height||(e.pixels[c*e.width+l]=1);}}i(ac,"stamp");var cy=16384;function dy(e,t){let[r,o]=e;if(!Number.isFinite(r)||!Number.isFinite(o))return null;let n=Math.min(2*t.width,Math.max(-t.width,Math.round(r))),a=Math.min(2*t.height,Math.max(-t.height,Math.round(o)));return [n,a]}i(dy,"padPoint");function uy(e,t,r,o,n){let[a,l]=t,[c,s]=r,d=Math.abs(c-a),u=-Math.abs(s-l),p=a<c?1:-1,f=l<s?1:-1,b=d+u,R=0;for(;R<n&&(ac(e,a,l,o),R+=1,!(a===c&&l===s));){let v=2*b;v>=u&&(b+=u,a+=p),v<=d&&(b+=d,l+=f);}return R}i(uy,"line");function lc(e,t=1){let r=sc(Xr.width,Xr.height);for(let o of e){let n=[];for(let l of o){let c=dy(l,r);c!==null&&n.push(c);}if(n.length===0)continue;if(n.length===1){let[l,c]=n[0];ac(r,l,c,t);continue}let a=cy;for(let l=1;l<n.length&&a>0;l+=1)a-=uy(r,n[l-1],n[l],t,a);}return r}i(lc,"rasterizeStrokes");var py="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,'-",my="ehhvhhhuhhuhhufgggggfuhhhhhuvgguggvvggugggfggnhhfhhhvhhhv44444v72222ichikokihggggggvhrllhhhhpljhhhehhhhheuhhugggehhhliduhhukihfgge11uv444444hhhhhhehhhhha4hhhllrhhha4ahhhha4444v1248gv00e1fhfgguhhhu00fgggf11fhhhf00ehvgf698s8880fhhf1egguhhhh40c444e20622icggikokic44444e00qllhh00uhhhh00ehhhe0uhhugg0fhhf1100mpggg00fge1u88s889600hhhjd00hhha400hhlla00ha4ah00hhf1e00v248vehjlphe4c4444eeh1248vv2421he26aiv22vgu11he68guhhev124888ehhehheehhf12c00000cc0000c48c480000000v000",yy="0123456789abcdefghijklmnopqrstuv",ts=5,rs=7,Qi=ts+1;function fy(e,t){let r=py.indexOf(e);return r<0?0:yy.indexOf(my.charAt(r*rs+t))}i(fy,"glyphRow");function cc(e){let t=sc(Xr.width,Xr.height),r=e.trim();if(r.length===0)return t;let o=[...r],n=4;for(;n>1&&(o.length*Qi-1)*n>t.width-8;)n-=1;let a=(o.length*Qi-1)*n,l=Math.max(0,Math.floor((t.width-a)/2)),c=Math.floor((t.height-rs*n)/2);return o.forEach((s,d)=>{let u=l+d*Qi*n;for(let p=0;p<rs;p+=1){let f=fy(s,p);for(let b=0;b<ts;b+=1)if((f>>ts-1-b&1)!==0)for(let R=0;R<n;R+=1)for(let v=0;v<n;v+=1){let w=u+b*n+v,g=c+p*n+R;w<t.width&&g<t.height&&(t.pixels[g*t.width+w]=1);}}}),t}i(cc,"rasterizeTypedName");var ss=class ss{constructor(){this.bytes=[];this.acc=0;this.count=0;}writeBits(t,r){for(this.acc|=t<<this.count,this.count+=r;this.count>=8;)this.bytes.push(this.acc&255),this.acc>>>=8,this.count-=8;}writeCode(t,r){let o=0;for(let n=0;n<r;n+=1)o=o<<1|t>>n&1;this.writeBits(o,r);}finish(){return this.count>0&&this.bytes.push(this.acc&255),Uint8Array.from(this.bytes)}};i(ss,"BitWriter");var ns=ss;function os(e,t){t<144?e.writeCode(48+t,8):t<256?e.writeCode(400+(t-144),9):t<280?e.writeCode(t-256,7):e.writeCode(192+(t-280),8);}i(os,"writeLiteral");var Xi=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],nc=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Ji=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],oc=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];function gy(e,t,r){let o=Xi.length-1;for(;Xi[o]>t;)o-=1;os(e,257+o),nc[o]>0&&e.writeBits(t-Xi[o],nc[o]);let n=Ji.length-1;for(;Ji[n]>r;)n-=1;e.writeCode(n,5),oc[n]>0&&e.writeBits(r-Ji[n],oc[n]);}i(gy,"writeMatch");var by=32768,Zi=3,hy=258,ic=15,Ry=64;function vy(e){let t=new ns;t.writeBits(1,1),t.writeBits(1,2);let r=new Int32Array(1<<ic).fill(-1),o=new Int32Array(e.length).fill(-1),n=i(c=>(e[c]<<10^e[c+1]<<5^e[c+2])&(1<<ic)-1,"hashAt"),a=i(c=>{if(c+Zi>e.length)return;let s=n(c);o[c]=r[s],r[s]=c;},"insert"),l=0;for(;l<e.length;){let c=0,s=0;if(l+Zi<=e.length){let d=r[n(l)],u=0,p=Math.min(hy,e.length-l);for(;d>=0&&u<Ry&&l-d<=by;){let f=0;for(;f<p&&e[d+f]===e[l+f];)f+=1;if(f>c&&(c=f,s=l-d,f===p))break;d=o[d],u+=1;}}if(c>=Zi){gy(t,c,s);for(let d=0;d<c;d+=1)a(l+d);l+=c;}else os(t,e[l]),a(l),l+=1;}return os(t,256),t.finish()}i(vy,"deflate");function wy(e){let t=1,r=0;for(let o of e)t=(t+o)%65521,r=(r+t)%65521;return (r<<16|t)>>>0}i(wy,"adler32");var fo=null;function xy(e){if(fo===null){fo=new Uint32Array(256);for(let r=0;r<256;r+=1){let o=r;for(let n=0;n<8;n+=1)o=o&1?3988292384^o>>>1:o>>>1;fo[r]=o>>>0;}}let t=4294967295;for(let r of e)t=fo[(t^r)&255]^t>>>8;return (t^4294967295)>>>0}i(xy,"crc32");function Tn(e){return [e>>>24&255,e>>>16&255,e>>>8&255,e&255]}i(Tn,"u32");function es(e,t){let r=Uint8Array.from([...e].map(n=>n.charCodeAt(0))),o=new Uint8Array(r.length+t.length);return o.set(r,0),o.set(t,r.length),[...Tn(t.length),...o,...Tn(xy(o))]}i(es,"chunk");var go="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Cy(e){let t="";for(let r=0;r<e.length;r+=3){let o=e[r],n=r+1<e.length?e[r+1]:0,a=r+2<e.length?e[r+2]:0,l=o<<16|n<<8|a;t+=go.charAt(l>>18&63)+go.charAt(l>>12&63),t+=r+1<e.length?go.charAt(l>>6&63):"=",t+=r+2<e.length?go.charAt(l&63):"=";}return t}i(Cy,"toBase64");function is(e){let{width:t,height:r,pixels:o}=e,n=Math.ceil(t/8)+1,a=new Uint8Array(n*r);for(let u=0;u<r;u+=1){let p=u*n;a[p]=0,a.fill(255,p+1,p+n);for(let f=0;f<t;f+=1)if(o[u*t+f]===1){let b=p+1+(f>>3);a[b]=a[b]&~(128>>(f&7));}}let l=vy(a),c=new Uint8Array(2+l.length+4);c[0]=120,c[1]=1,c.set(l,2),c.set(Tn(wy(a)),2+l.length);let s=Uint8Array.from([...Tn(t),...Tn(r),1,0,0,0,0]),d=Uint8Array.from([137,80,78,71,13,10,26,10,...es("IHDR",s),...es("IDAT",c),...es("IEND",new Uint8Array(0))]);return Cy(d)}i(is,"encodeSignaturePng");var vo=2.6,pc="#111111";function Ty(e,t){let r=[];return e.forEach((o,n)=>{let a=i(l=>{let c=o[l];return [c[0]/t,c[1]/t]},"at");if(o.length===1){let[l,c]=a(0);r.push({key:`${n}-0`,cx:l,cy:c,length:0,angle:0});return}for(let l=1;l<o.length;l+=1){let[c,s]=a(l-1),[d,u]=a(l);r.push({key:`${n}-${l}`,cx:(c+d)/2,cy:(s+u)/2,length:Math.hypot(d-c,u-s),angle:Math.atan2(u-s,d-c)});}}),r}i(Ty,"strokeSegments");var _y=8,mc=2;function Mr({onChange:e,disabled:t=false}){let r=Py(),[o,n]=useState("draw"),[a,l]=useState(""),[c,s]=useState([]),[d,u]=useState(0),p=useRef([]),f=useRef(null),b=d>0?Xr.width/d:1,R=useRef(b);R.current=b;let v=useRef(t);v.current=t,useEffect(()=>{if(o==="type"){Qn(e,a.trim().length>0?is(cc(a)):null);return}let S=c.reduce((E,C)=>E+C.length,0);Qn(e,S>=_y?is(lc(c)):null);},[o,a,c,e]);let w=i(S=>{let{locationX:E,locationY:C}=S.nativeEvent;return [E*R.current,C*R.current]},"point"),g=i(()=>{let S=p.current,E=f.current;p.current=[],f.current=null,s(C=>[...C.filter(I=>I!==E),S]);},"commitStroke"),y=useMemo(()=>PanResponder.create({onStartShouldSetPanResponder:i(()=>!v.current,"onStartShouldSetPanResponder"),onMoveShouldSetPanResponder:i(()=>!v.current,"onMoveShouldSetPanResponder"),onPanResponderTerminationRequest:i(()=>false,"onPanResponderTerminationRequest"),onPanResponderGrant:i(S=>{p.current=[w(S)];},"onPanResponderGrant"),onPanResponderMove:i(S=>{let E=w(S),C=p.current[p.current.length-1];if(C!==void 0&&Math.abs(C[0]-E[0])<mc&&Math.abs(C[1]-E[1])<mc)return;p.current=[...p.current,E];let I=f.current,F=p.current;f.current=F,s(q=>[...q.filter(j=>j!==I),F]);},"onPanResponderMove"),onPanResponderRelease:i(()=>g(),"onPanResponderRelease"),onPanResponderTerminate:i(()=>g(),"onPanResponderTerminate")}),[]),x=useCallback(()=>{v.current||(p.current=[],f.current=null,s([]),l(""));},[]),h=useCallback(()=>{x(),n(S=>S==="draw"?"type":"draw");},[x]),P=i(S=>u(S.nativeEvent.layout.width),"onLayout");return jsxs(View,{style:r.container,testID:"records-signature-pad",children:[jsx(m,{style:r.label,children:o==="draw"?K.draw:K.type}),o==="type"?jsx(He,{accessibilityLabel:K.type,style:r.input,value:a,maxLength:100,editable:!t,autoComplete:"off",autoCorrect:false,onChangeText:S=>{v.current||l(S);}}):null,jsx(View,{onLayout:P,style:[r.canvas,{height:d>0?d/3:120}],accessible:true,accessibilityLabel:K.sign,accessibilityRole:"image",testID:"records-signature-canvas",...o==="draw"?y.panHandlers:{},children:o==="type"?jsx(m,{style:r.typedPreview,numberOfLines:1,adjustsFontSizeToFit:true,children:a.trim()}):Ty(c,b).map(S=>{let E=S.length+vo;return jsx(View,{pointerEvents:"none",style:[r.segment,{width:E,left:S.cx-E/2,top:S.cy-vo/2,transform:[{rotate:`${S.angle}rad`}]}]},S.key)})}),jsxs(View,{style:r.actions,children:[jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:K.clear,accessibilityState:{disabled:t},disabled:t,onPress:x,style:r.button,children:jsx(m,{style:r.buttonLabel,children:K.clear})}),jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:o==="draw"?K.toType:K.toDraw,accessibilityState:{disabled:t},disabled:t,onPress:h,style:r.button,children:jsx(m,{style:r.buttonLabel,children:o==="draw"?K.toType:K.toDraw})})]})]})}i(Mr,"SignaturePad");function Py(){let e=V();return useMemo(()=>Iy(e),[e])}i(Py,"useStyles");function Iy(e){let{color:t,space:r,radius:o,type:n}=e;return StyleSheet.create({container:{gap:r.sm},label:{...k(e,"regular"),fontSize:n.size.body,color:t.text.primary},input:{minHeight:44,padding:r.sm,borderWidth:1,borderColor:t.borderHairlineGreen,borderRadius:o.sm,color:t.text.primary,backgroundColor:t.surface,...k(e,"regular"),fontSize:n.size.body},canvas:{width:"100%",backgroundColor:"#ffffff",borderWidth:1,borderColor:t.borderHairlineGreen,borderRadius:o.sm,overflow:"hidden",justifyContent:"center"},segment:{position:"absolute",height:vo,borderRadius:vo/2,backgroundColor:pc},typedPreview:{textAlign:"center",fontSize:32,fontStyle:"italic",fontWeight:"700",color:pc,paddingHorizontal:r.md},actions:{flexDirection:"row",flexWrap:"wrap",gap:r.sm},button:{minHeight:44,paddingHorizontal:r.md,justifyContent:"center",borderWidth:1,borderColor:t.borderHairlineGreen,borderRadius:o.sm,backgroundColor:t.surface},buttonLabel:{...k(e,"regular"),fontSize:n.size.body,color:t.text.primary}})}i(Iy,"makeStyles");function ls(e){let{userRef:t,scopeEpoch:r}=Te();return jsx(Ve,{capability:"recordsClinic",...Fe(e.onClose,K.cancel),children:t===null?jsx(m,{accessibilityRole:"alert",children:ye.sessionRequired}):jsx(Oy,{...Le(e,["onClose","onCreated"])},JSON.stringify([t,r,e.petRef,e.petName]))})}i(ls,"EverfurClinicRequestBatch");function Oy(e){let t=Ut(),r=Ai(),o=e.controller??t,[n,a]=useState(null),l=useCallback(async()=>n===null?null:{signaturePngBase64:n},[n]),c=useCallback((w,g)=>Ki(w,o,g),[o]),s=tc(e,o,e.batchClient??r,e.onCaptureSignature??l,e.onCaptureSignature?void 0:c),d=e.onCaptureSignature!==void 0||n!==null,u=V(),p={minHeight:44,padding:u.space.sm,borderWidth:1,borderColor:u.color.borderHairlineGreen,borderRadius:u.radius.sm,color:u.color.text.primary,backgroundColor:u.color.surface},f={color:u.color.text.primary,fontSize:u.type.size.body},b={color:u.color.text.muted,fontSize:u.type.size.bodyTight},R=i((w,g,y=false,x=w)=>jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:x,accessibilityState:{disabled:y},disabled:y,onPress:g,style:[p,{justifyContent:"center",opacity:y?.5:1}],children:jsx(m,{style:f,children:w})}),"button"),v=s.busy?Me.sending:s.drafts.length===0?Me.addToContinue:s.error?Me.tryAgain:Me.send(s.drafts.length);return jsxs(View,{accessibilityLabel:s.outcome?Me.resultTitle:Me.title,style:[{backgroundColor:u.color.surface,padding:u.space.lg,gap:u.space.md,borderRadius:u.radius.lg,minHeight:120},e.style],children:[jsx(m,{accessibilityRole:"header",style:[f,{...k(u,"bold"),fontSize:u.type.size.heading}],children:s.outcome?Me.resultTitle:Me.title}),jsx(m,{style:f,children:e.petName}),s.outcome?jsxs(View,{style:{gap:u.space.sm},testID:"records-batch-result",children:[jsx(m,{accessibilityRole:"summary",accessibilityLiveRegion:"polite",style:f,children:s.outcome.createdCount===0?Me.allFailed:s.outcome.failedCount>0?Me.partial(s.outcome.createdCount,s.outcome.results.length,s.outcome.failedCount):Me.allSent(s.outcome.createdCount)}),jsx(m,{accessibilityRole:"header",style:f,children:Me.perClinic}),s.outcome.results.map((w,g)=>{let y=w.request?.clinicName??s.drafts[g]?.clinic?.name??w.clinicFreeText??"",x=w.created?Me.sent:Me.notSent;return jsxs(View,{accessible:true,accessibilityRole:"text",accessibilityLabel:[`${y}. ${x}.`,w.created?w.request?.statusLabel:w.failureReason].filter(Boolean).join(" "),testID:`records-batch-row-${w.created?"created":"failed"}`,children:[jsx(m,{style:f,children:y}),jsx(m,{style:b,children:x}),w.created&&w.request?.statusLabel?jsx(m,{style:b,children:w.request.statusLabel}):null,!w.created&&w.failureReason?jsx(m,{style:b,children:w.failureReason}):null]},w.idempotencyKey)}),s.group?jsx(m,{accessibilityLiveRegion:"polite",style:f,children:Me.responded(s.group.responded,s.group.total)}):null,s.group?.members.map(w=>w.statusLabel?jsx(m,{style:b,children:[w.clinicName,w.statusLabel].filter(Boolean).join(": ")},w.id):null)]}):jsxs(Fragment,{children:[jsx(m,{style:f,children:K.ownerName}),jsx(He,{accessibilityLabel:K.ownerName,style:p,value:s.ownerName,maxLength:200,editable:!s.busy,autoComplete:"name",onChangeText:s.setOwnerName}),s.drafts.map(w=>jsxs(View,{style:{gap:u.space.xs},testID:`records-batch-draft-${w.key}`,children:[jsx(m,{style:f,children:kn(w)}),Sn(w)?jsxs(Fragment,{children:[jsx(m,{style:b,children:w.email.trim()?w.email:Me.emailToAdd}),jsx(He,{accessibilityLabel:K.email,style:p,value:w.email,placeholder:K.emailPlaceholder,placeholderTextColor:u.color.text.placeholder,maxLength:320,editable:!s.busy,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,onChangeText:g=>s.setDraftEmail(w.key,g)})]}):null,R(Me.remove(kn(w)),()=>s.removeDraft(w.key),s.busy)]},w.key)),jsx(m,{style:f,children:s.atCap?Me.atCap:Me.addClinic}),!s.atCap&&jsxs(Fragment,{children:[jsx(He,{accessibilityLabel:K.clinic,style:p,value:s.query,placeholder:K.placeholder,placeholderTextColor:u.color.text.placeholder,maxLength:200,editable:!s.busy,onChangeText:s.setQuery}),R(K.search,()=>{s.search();},s.busy||s.searching||s.query.trim().length<2),s.query.trim().length>0&&s.clinics.length===0&&!s.searching&&R(Me.addClinic,s.addFreeText,s.busy),s.searching&&jsx(m,{accessibilityLiveRegion:"polite",style:f,children:ye.loading}),s.recent.length>0&&jsx(m,{accessibilityRole:"header",style:f,children:K.recentlyUsed}),s.recent.map(w=>jsx(View,{children:R([w.name,w.address,w.phone].filter(Boolean).join(", "),()=>s.addClinic(w),s.busy)},`recent-${w.id}`)),s.clinics.map(w=>jsx(View,{children:R([w.name,w.address,w.phone].filter(Boolean).join(", "),()=>s.addClinic(w),s.busy)},w.id))]}),jsx(m,{accessibilityRole:"header",style:f,children:K.scopeHeading}),s.copy?jsx(m,{style:f,children:s.drafts.length>0&&s.ownerName.trim()?s.scopeText??N("internalError").displayMessage:ye.consentRequired}):!s.error&&jsx(m,{accessibilityLiveRegion:"polite",style:f,children:ye.loading}),!e.onCaptureSignature&&jsx(Mr,{onChange:a,disabled:s.busy}),!d&&jsx(m,{accessibilityRole:"alert",style:f,children:K.missingSignature}),s.error&&jsx(m,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:f,children:s.error.displayMessage}),!s.copy&&s.error&&R(ye.retry,s.retryCopy),R(v,()=>{s.submit();},s.busy||!s.ready||!d,Me.sendA11y(s.drafts.length))]}),e.onClose&&R(K.cancel,e.onClose,s.busy),jsx(qe,{})]})}i(Oy,"BatchBody");var ue=Object.freeze({scopeHeading:"What you\u2019re authorizing",scopeBody:"You\u2019re asking your pet\u2019s clinic to release their medical records to Everfur, on your behalf, so we can organize them for you.",whatWeDo:Object.freeze(["We email the clinic a signed copy of this authorization.","When records arrive, our team reviews them before they appear in your app.","You can revoke this request at any time."]),retentionNote:"We keep the records you receive so you always have them. See our Privacy Policy for how records are stored and used.",authorizeLabel:i((e,t)=>`I authorize ${t} to release ${Ne(e)}\u2019s records to Everfur.`,"authorizeLabel"),missingSignatureError:"Please add your signature before submitting.",missingDraftError:"Something went wrong with your selection. Please go back and pick the clinic again.",newClinicDirectSendNote:"We\u2019ll email this clinic directly to request your pet\u2019s medical records. Clinics usually reply within a week.",titleFreeText:"Confirm your request",titleDirectory:"Authorize records release",noEmailNote:i((e,t)=>`We don\u2019t have an email on file for ${t}. Add it so we can request ${Ne(e)}\u2019s records.`,"noEmailNote"),emailLabel:"Clinic email",emailPlaceholder:"records@clinic.com",emailRequired:"Enter the clinic email before sending the request.",reuseSignature:"Reuse a previous signature",reuseHint:"\u2026or sign again below",reuseTileA11y:"Use this earlier signature",reuseTileSelectedA11y:"Earlier signature, selected",signType:"Type your name to sign",signDraw:"Sign with your finger",clear:"Clear",clearA11y:"Clear signature",fullName:"Your full name",fullNamePlaceholder:"Jane Doe",toType:"Can\u2019t draw? Type your name instead",toTypeA11y:"Can\u2019t draw? Type your name to sign instead",toDraw:"Draw your signature instead",signatureHint:i(e=>`Your signature is added to the authorization sent to ${e}.`,"signatureHint"),submit:"Authorize & send request",submitting:"Submitting\u2026",submitA11y:"Submit authorization"});var Ly="value_text",bc=64,hc=512;function Rc(e){return e!==null&&e.httpStatus===409&&!ar(e)}i(Rc,"isFactReviewerLocked");var _n=Object.freeze({num:"value_num",date:"value_date",bool:"value_bool",text:Ly}),vc=/^[+-]?(?:\d+\.?\d*|\.\d+)$/,wc=/^\d{4}-\d{2}-\d{2}$/;function xc(e){if(e==null)return "text";let t=e.trim();return vc.test(t)?"num":wc.test(t)&&!Number.isNaN(Date.parse(t))?"date":t==="true"||t==="false"?"bool":"text"}i(xc,"inferFactValueKind");function cs(e,t){let r=t.trim(),o=xc(e);if(o==="num"&&vc.test(r)){let n=Number(r);if(Number.isFinite(n))return Object.freeze({[_n.num]:n})}return o==="date"&&wc.test(r)&&!Number.isNaN(Date.parse(r))?Object.freeze({[_n.date]:r}):Object.freeze(o==="bool"&&(r==="true"||r==="false")?{[_n.bool]:r==="true"}:{[_n.text]:r})}i(cs,"factCorrectionFor");var Ae=z.string().nullish(),wo=z.number().nullish(),Vy=z.object({collected_at:Ae,at:Ae,value:wo,unit:Ae,qualitative_result:Ae,ref_low:wo,ref_high:wo,status:Ae,source_clinic:Ae,source_doc_id:Ae,doc_id:Ae,reviewed:z.boolean().nullish()}),qy=z.object({collected_at:Ae,at:Ae,value:wo,unit:Ae,qualitative_result:Ae,status:Ae}),zy=z.object({marker_id:z.string().min(1),canonical_name:Ae,name:Ae,loinc_code:Ae,canonical_unit:Ae,unit:Ae,panel_name:Ae,panel:Ae,meaning_text:Ae,meaning:Ae,latest:qy.nullish(),trajectory:Ae,points:z.array(Vy).optional()}),Fy=z.object({total_markers:z.number().int().nonnegative(),in_range_count:z.number().int().nonnegative(),out_of_range_count:z.number().int().nonnegative(),unknown_count:z.number().int().nonnegative()}),Ny=z.object({markers:z.array(zy).optional(),summary:Fy.nullish(),disclaimer:z.string().optional(),featured_marker_id:Ae});function My(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(My,"isObject");function Cc(e){return Object.freeze({petRef:e,withheld:true,markers:Object.freeze([]),summary:null,disclaimer:"",featuredMarkerId:null})}i(Cc,"withheldMarkers");function Ec(e,t){let r=My(t)?t:{},o=typeof r.pet_ref=="string"&&r.pet_ref.length>0?r.pet_ref:e;if(r.withheld===true)return Cc(o);let n=Ny.safeParse(r);if(!n.success)return Cc(o);let a=n.data,l=i(s=>Object.freeze({at:s.collected_at??s.at??null,value:s.value??null,unit:s.unit??null,qualitativeResult:s.qualitative_result??null,refLow:s.ref_low??null,refHigh:s.ref_high??null,status:s.status??null,sourceClinic:s.source_clinic??null,docId:s.source_doc_id??s.doc_id??null,reviewed:s.reviewed===true}),"point"),c=(a.markers??[]).map(s=>Object.freeze({markerId:s.marker_id,name:s.canonical_name??s.name??s.marker_id,loincCode:s.loinc_code??null,unit:s.canonical_unit??s.unit??null,panel:s.panel_name??s.panel??null,meaning:s.meaning_text??s.meaning??null,latest:s.latest?Object.freeze({at:s.latest.collected_at??s.latest.at??null,value:s.latest.value??null,unit:s.latest.unit??null,qualitativeResult:s.latest.qualitative_result??null,status:s.latest.status??null}):null,trajectory:s.trajectory??null,points:Object.freeze((s.points??[]).map(l))}));return Object.freeze({petRef:o,withheld:false,markers:Object.freeze(c),summary:a.summary?Object.freeze({totalMarkers:a.summary.total_markers,inRangeCount:a.summary.in_range_count,outOfRangeCount:a.summary.out_of_range_count,unknownCount:a.summary.unknown_count}):null,disclaimer:a.disclaimer??"",featuredMarkerId:a.featured_marker_id??null})}i(Ec,"mapRecordMarkers");var By=z.string().min(1).refine(e=>e.startsWith("https://")),Hy=z.object({source_doc_id:z.string().min(1),file_name:z.string().nullish(),doc_format:z.string().nullish(),byte_size:z.number().int().nonnegative().nullish(),received_at:z.string().nullish(),download_url:By,expires_in_seconds:z.number().int().nonnegative().nullish()}),Uy=z.object({items:z.array(z.unknown()).optional()});function Sc(e){let t=Uy.safeParse(e);if(!t.success)return null;let r=[];for(let o of t.data.items??[]){let n=Hy.safeParse(o);n.success&&r.push(Object.freeze({sourceDocId:n.data.source_doc_id,fileName:n.data.file_name??null,docFormat:n.data.doc_format??null,byteSize:n.data.byte_size??null,receivedAt:n.data.received_at??null,downloadUrl:n.data.download_url,expiresInSeconds:n.data.expires_in_seconds??0}));}return Object.freeze(r)}i(Sc,"mapRequestDocuments");var jy=z.string().min(1).refine(e=>e.startsWith("https://")),Pn=z.string().nullish(),$y=z.object({share_id:z.string().min(1),share_url:z.string().min(1),expires_at:Pn}),Wy=z.object({shares:z.array(z.object({share_id:z.string().min(1),expires_at:Pn,created_at:Pn,view_count:z.number().int().nonnegative().nullish(),last_viewed_at:Pn})).optional()}),Gy=z.object({download_url:jy,expires_at:Pn});function Yy(e,t){let r=e.trim();if(r.length===0)return null;try{let o=/^[a-z][a-z0-9+.-]*:/i.test(r)?new URL(r):t!==void 0?new URL(r,t):null;return o===null||o.protocol!=="https:"?null:o.toString()}catch{return null}}i(Yy,"resolveShareUrl");function kc(e,t){let r=$y.safeParse(e);if(!r.success)return null;let o=Yy(r.data.share_url,t);return o===null?null:Object.freeze({shareId:r.data.share_id,shareUrl:o,expiresAt:r.data.expires_at??null})}i(kc,"mapRecordShareLink");function Tc(e){let t=Wy.safeParse(e);return t.success?Object.freeze((t.data.shares??[]).map(r=>Object.freeze({shareId:r.share_id,expiresAt:r.expires_at??null,createdAt:r.created_at??null,viewCount:r.view_count??0,lastViewedAt:r.last_viewed_at??null}))):null}i(Tc,"mapRecordShareList");function _c(e){let t=Gy.safeParse(e);return t.success?Object.freeze({downloadUrl:t.data.download_url,expiresAt:t.data.expires_at??null}):null}i(_c,"mapRecordPdfLink");var Ky=z.object({signatures:z.array(z.object({signature_id:z.string().min(1),preview_url:z.string().min(1).refine(e=>e.startsWith("https://")),created_at:z.string().nullish()})).optional()});function Pc(e){let t=Ky.safeParse(e);return t.success?Object.freeze((t.data.signatures??[]).map(r=>Object.freeze({signatureId:r.signature_id,previewUrl:r.preview_url,createdAt:r.created_at??null}))):null}i(Pc,"mapSignatureSuggestions");var U=z.string().nullish(),In=z.number().nullish(),Qy=z.object({at:U,value:In,unit:U,qualitative_result:U,ref_low:In,ref_high:In,status:U,doc_id:U}),Xy=z.object({marker_id:z.string(),name:z.string(),loinc_code:U,unit:U,panel:U,meaning:U,latest:z.object({at:U,value:In,unit:U,qualitative_result:U,status:U}).nullish(),trajectory:U,points:z.array(Qy).optional()}),Jy=z.object({encounter_id:z.string(),date:U,type:U,clinic_name:U,veterinarian:U,doc_id:U}),Zy=z.object({note_id:z.string(),encounter_id:U,observed_on:U,sections:z.array(z.object({section:z.string(),text:z.string()})).optional()}),ef=z.object({exam_id:z.string(),encounter_id:U,observed_on:U,doc_id:U,systems:z.record(z.object({finding_status:U,finding:U})).optional()}),tf=z.object({has_lab_history:z.boolean().optional(),has_vaccination_history:z.boolean().optional(),has_weight_history:z.boolean().optional(),has_vitals_history:z.boolean().optional(),has_physical_exam_history:z.boolean().optional(),has_procedure_history:z.boolean().optional(),has_genetic_history:z.boolean().optional(),has_reproductive_history:z.boolean().optional(),has_parasite_prevention_history:z.boolean().optional(),earliest_record_at:U,latest_record_at:U,documents_ingested:z.number().int().nonnegative().optional(),documents_in_review:z.number().int().nonnegative().optional(),entities_pending_review:z.record(z.number().int().nonnegative()).optional(),held_total:z.number().int().nonnegative().optional()}),rf=z.object({conflict_id:z.string(),entity_type:z.string(),field:U,severity:U,candidates:z.array(z.object({value:z.string(),source_doc_id:U,doc_id:U,collected_at:U})).optional()}),nf=z.object({lab_results:z.array(Xy).optional(),encounters:z.array(Jy).optional(),clinician_notes:z.array(Zy).optional(),physical_exams:z.array(ef).optional(),completeness:tf.nullish(),conflicts:z.array(rf).optional()}),of=z.object({visits:z.array(z.object({visit_id:z.string(),visit_date:U,veterinarian:U,summary:U,doc_id:U})),vaccines:z.array(z.object({vaccine_id:z.string(),product:U,lot:U,administered_on:U,expires_on:U,doc_id:U})),weights:z.array(z.object({weight_id:z.string(),observed_on:U,weight_kg:In,doc_id:U})),medications:z.array(z.object({medication_id:z.string(),drug_name:U,dose:U,route:U,frequency:U,sig:U,rx_number:U,started_on:U,stopped_on:U,doc_id:U})),disclaimer:z.string().optional()}),sf=z.object({document:oi,contributions:z.array(ni),contribution_count:z.number().int().nonnegative().optional()});function us(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(us,"isObject");function ps(e,t){return typeof e.pet_ref=="string"&&e.pet_ref.length>0?e.pet_ref:t}i(ps,"petOf");function ds(e,t){return Object.freeze({petRef:e,available:false,withheld:t,labResults:Object.freeze([]),encounters:Object.freeze([]),clinicianNotes:Object.freeze([]),physicalExams:Object.freeze([]),completeness:null,conflicts:Object.freeze([])})}i(ds,"emptyDepth");function af(e,t){let r=us(t)?t:{},o=ps(r,e);if(r.withheld===true)return ds(o,true);if(!["lab_results","encounters","clinician_notes","physical_exams","completeness","conflicts"].some(s=>s in r))return ds(o,false);let a=nf.safeParse(r);if(!a.success)return ds(o,true);let l=a.data,c=i(s=>Object.freeze({at:s.at??null,value:s.value??null,unit:s.unit??null,qualitativeResult:s.qualitative_result??null,refLow:s.ref_low??null,refHigh:s.ref_high??null,status:s.status??null,docId:s.doc_id??null}),"point");return Object.freeze({petRef:o,available:true,withheld:false,labResults:Object.freeze((l.lab_results??[]).map(s=>Object.freeze({markerId:s.marker_id,name:s.name,loincCode:s.loinc_code??null,unit:s.unit??null,panel:s.panel??null,meaning:s.meaning??null,latest:Object.freeze({at:s.latest?.at??null,value:s.latest?.value??null,unit:s.latest?.unit??null,qualitativeResult:s.latest?.qualitative_result??null,status:s.latest?.status??null}),trajectory:s.trajectory??null,points:Object.freeze((s.points??[]).map(c))}))),encounters:Object.freeze((l.encounters??[]).map(s=>Object.freeze({encounterId:s.encounter_id,date:s.date??null,type:s.type??null,clinicName:s.clinic_name??null,veterinarian:s.veterinarian??null,docId:s.doc_id??null}))),clinicianNotes:Object.freeze((l.clinician_notes??[]).map(s=>Object.freeze({noteId:s.note_id,encounterId:s.encounter_id??null,observedOn:s.observed_on??null,sections:Object.freeze((s.sections??[]).map(d=>Object.freeze({section:d.section,text:d.text})))}))),physicalExams:Object.freeze((l.physical_exams??[]).map(s=>Object.freeze({examId:s.exam_id,encounterId:s.encounter_id??null,observedOn:s.observed_on??null,docId:s.doc_id??null,systems:Object.freeze(Object.entries(s.systems??{}).map(([d,u])=>Object.freeze({system:d,findingStatus:u.finding_status??null,finding:u.finding??null})))}))),completeness:l.completeness?Object.freeze({hasLabHistory:l.completeness.has_lab_history===true,hasVaccinationHistory:l.completeness.has_vaccination_history===true,hasWeightHistory:l.completeness.has_weight_history===true,hasVitalsHistory:l.completeness.has_vitals_history===true,hasPhysicalExamHistory:l.completeness.has_physical_exam_history===true,hasProcedureHistory:l.completeness.has_procedure_history===true,hasGeneticHistory:l.completeness.has_genetic_history===true,hasReproductiveHistory:l.completeness.has_reproductive_history===true,hasParasitePreventionHistory:l.completeness.has_parasite_prevention_history===true,earliestRecordAt:l.completeness.earliest_record_at??null,latestRecordAt:l.completeness.latest_record_at??null,documentsIngested:l.completeness.documents_ingested??0,documentsInReview:l.completeness.documents_in_review??0,entitiesPendingReview:Object.freeze({...l.completeness.entities_pending_review??{}}),heldTotal:l.completeness.held_total??0}):null,conflicts:Object.freeze((l.conflicts??[]).map(s=>Object.freeze({conflictId:s.conflict_id,entityType:s.entity_type,field:s.field??null,severity:s.severity??"needs_review",candidates:Object.freeze((s.candidates??[]).map(d=>Object.freeze({value:d.value,docId:d.source_doc_id??d.doc_id??null,collectedAt:d.collected_at??null})))})))})}i(af,"mapRecordDepth");function Ic(e){return Object.freeze({petRef:e,withheld:true,isEmpty:false,visits:Object.freeze([]),vaccines:Object.freeze([]),weights:Object.freeze([]),medications:Object.freeze([]),disclaimer:""})}i(Ic,"withheldTimeline");function lf(e,t){let r=us(t)?t:{},o=ps(r,e);if(r.withheld===true)return Ic(o);let n=of.safeParse(r);if(!n.success)return Ic(o);let a=n.data,l=a.visits.map(u=>Object.freeze({visitId:u.visit_id,visitDate:u.visit_date??null,veterinarian:u.veterinarian??null,summary:u.summary??null,docId:u.doc_id??null})),c=a.vaccines.map(u=>Object.freeze({vaccineId:u.vaccine_id,product:u.product??null,lot:u.lot??null,administeredOn:u.administered_on??null,expiresOn:u.expires_on??null,docId:u.doc_id??null})),s=a.weights.map(u=>Object.freeze({weightId:u.weight_id,observedOn:u.observed_on??null,weightKg:u.weight_kg??null,docId:u.doc_id??null})),d=a.medications.map(u=>Object.freeze({medicationId:u.medication_id,drugName:u.drug_name??null,dose:u.dose??null,route:u.route??null,frequency:u.frequency??null,sig:u.sig??null,rxNumber:u.rx_number??null,startedOn:u.started_on??null,stoppedOn:u.stopped_on??null,docId:u.doc_id??null}));return Object.freeze({petRef:o,withheld:false,isEmpty:l.length===0&&c.length===0&&s.length===0&&d.length===0,visits:Object.freeze(l),vaccines:Object.freeze(c),weights:Object.freeze(s),medications:Object.freeze(d),disclaimer:a.disclaimer??""})}i(lf,"mapRecordsTimeline");function cf(e,t){let r=us(t)?t:{},o=ps(r,e),n=i(()=>Object.freeze({petRef:o,withheld:true,document:null,contributions:Object.freeze([]),contributionCount:0}),"withheld");if(r.withheld===true)return n();let a=sf.safeParse(r);if(!a.success)return n();let l=Object.freeze(a.data.contributions.map(ii));return Object.freeze({petRef:o,withheld:false,document:si(a.data.document),contributions:l,contributionCount:a.data.contribution_count??l.length})}i(cf,"mapDocumentContributions");var df="/widget/v1/records/pets";function Dc(e){let t=e.funnel??wr({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=i((s,d)=>typeof s=="string"&&s.length>0&&!xr(s)&&[...s].length<=d,"segment"),o=i(async(s,d,u,p)=>{if(!r(d,bt))return mr();let f=await t.send(s,{method:"GET",path:u});if(!f.ok)return f;let b=p(f.value);return b.petRef===d?Ie(b):W(N("internalError",{retryable:false}))},"read"),n=i(s=>`${df}/${encodeURIComponent(s)}`,"pet"),a=i(s=>`${n(s)}/everfur_record`,"record"),l=i(async(s,d,u)=>{let p=await t.send(s,d,d.method==="POST"?{idempotent:false,maxAttempts:1}:void 0);if(!p.ok)return p;let f=u(p.value);return f===null?W(N("internalError",{retryable:false})):Ie(f)},"parsed"),c=i((s,d)=>!r(s.entityType,bc)||!r(s.canonicalKey,hc)||s.idempotencyKey!==void 0&&!r(s.idempotencyKey,dn)||d!==void 0&&Object.keys(d).length===0?null:{entity_type:s.entityType,canonical_key:s.canonicalKey,...d!==void 0?{corrected_fields:d}:{},...s.idempotencyKey!==void 0?{idempotency_key:s.idempotencyKey}:{}},"factBody");return {getRecordDepth:i(s=>o("records.depth.record",s,`${n(s)}/record`,d=>af(s,d)),"getRecordDepth"),getTimeline:i(s=>o("records.depth.timeline",s,`${n(s)}/timeline`,d=>lf(s,d)),"getTimeline"),getDocumentContributions(s,d){return r(d,64)?o("records.depth.contributions",s,`${n(s)}/documents/${encodeURIComponent(d)}/contributions`,u=>cf(s,u)):mr()},getMarkers:i(s=>o("records.depth.markers",s,`${n(s)}/markers`,d=>Ec(s,d)),"getMarkers"),createShare(s){return r(s,bt)?l("records.share.create",{method:"POST",path:`${a(s)}/share`},d=>kc(d,e.apiBaseUrl)):mr()},listShares(s){return r(s,bt)?l("records.share.list",{method:"GET",path:`${a(s)}/shares`},Tc):mr()},async revokeShare(s,d){if(!r(s,bt)||!r(d,64))return mr();let u=await t.send("records.share.revoke",{method:"DELETE",path:`${a(s)}/shares/${encodeURIComponent(d)}`},{idempotent:false,maxAttempts:1});return u.ok?Ie(void 0):u},getPdfLink(s){return r(s,bt)?l("records.pdf.link",{method:"GET",path:`${a(s)}/pdf-link`},_c):mr()},async editFact(s,d){let u=r(s,bt)?c(d,d.correctedFields):null;if(u===null)return mr();let p=await t.send("records.fact.edit",{method:"POST",path:`${a(s)}/facts/edit`,body:u},{idempotent:false,maxAttempts:1});return p.ok?Ie(void 0):p},async removeFact(s,d){let u=r(s,bt)?c(d):null;if(u===null)return mr();let p=await t.send("records.fact.remove",{method:"POST",path:`${a(s)}/facts/remove`,body:u},{idempotent:false,maxAttempts:1});return p.ok?Ie(void 0):p},listRequestDocuments(s){return r(s,64)?l("records.request.documents",{method:"GET",path:`/widget/v1/records/requests/${encodeURIComponent(s)}/documents`},Sc):mr()},listAuthorizationSignatures:i(()=>l("records.signatures.list",{method:"GET",path:"/widget/v1/records/authorization-signatures"},Pc),"listAuthorizationSignatures")}}i(Dc,"createRecordsDepthClient");function mr(){return Promise.resolve(W(N("validationFailed",{retryable:false})))}i(mr,"invalid");function yr(){let{runtime:e,userRef:t,scopeEpoch:r}=Te();return useMemo(()=>{let{services:o}=e.registry;return Dc({auth:o.authFor(t),...o.errorPolicy?{errorPolicy:o.errorPolicy}:{},...typeof o.apiBaseUrl=="string"?{apiBaseUrl:o.apiBaseUrl}:{}})},[e,t,r])}i(yr,"useEverfurRecordsDepthClient");function Yt(e,t,r,o=""){let n=yr(),{userRef:a}=Te(),l=Wn(e),c=useMemo(()=>({}),[n,e,o,l]),[s,d]=useState({scope:c,value:null,error:null,loading:true}),u=useRef(0),p=useCallback(async()=>{let g=u.current+=1;if(d({scope:c,value:null,error:null,loading:true}),a===null){d({scope:c,value:null,error:null,loading:false});return}let y=await t(n,e);g===u.current&&(y.ok?d({scope:c,value:y.value,error:null,loading:false}):d({scope:c,value:null,error:y.error,loading:false}));},[n,e,t,c,a]);useEffect(()=>(p(),()=>{u.current+=1;}),[p]);let f=s.scope===c?s:{value:null,error:null,loading:true},b=useCallback(()=>{p();},[p]),R=f.error===null||f.error.httpStatus!==404,v=R?f.error:null,w=f.loading?"loading":v!==null?"error":f.value===null?"empty":f.value.withheld?"populated":r(f.value)?"empty":"populated";return useMemo(()=>({status:w,value:f.value,error:v,available:R,refresh:b}),[w,f.value,v,R,b])}i(Yt,"useRecordsDepthRead");function _r(e){return e!==null&&e.httpStatus===404}i(_r,"isDarkRouteError");var ff=i((e,t)=>e.getMarkers(t),"readMarkers"),gf=i(e=>e.markers.length===0,"markersEmpty");function ys(e){let t=Yt(e,ff,gf);return useMemo(()=>{let r=t.available&&t.value!==null&&!t.value.withheld?t.value:null;return {status:t.status,markers:r,available:t.available,error:t.error,refresh:t.refresh}},[t])}i(ys,"useRecordsMarkers");var bf=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function Lc(e){let{clinic:t,controller:r,depthClient:o,capture:n,onCreated:a}=e,l=t.clinic?.name??t.freeText??"",c=t.clinic===null,[s,d]=useState(false),[u,p]=useState(e.ownerName),[f,b]=useState(t.email),[R,v]=useState(false),[w,g]=useState(null),[y,x]=useState(null),[h,P]=useState(0),[S,E]=useState(null),[C,I]=useState(false),[F,q]=useState(null),[j,$]=useState([]),[ce,oe]=useState(null),[ve,ie]=useState(false),T=useRef(false),D=useRef(true),L=useRef(lr()),B=useRef(null);useEffect(()=>(D.current=true,()=>{D.current=false,B.current=null;}),[r]),useEffect(()=>{let ke=true;return g(null),B.current=null,r.getAuthorizationCopy().then(M=>{ke&&(M.ok?(g(M.value),x(null)):x(M.error));}).catch(()=>{ke&&x(N("internalError"));}),()=>{ke=false;}},[r,h]),useEffect(()=>{if(o===void 0)return;let ke=true;return o.listAuthorizationSignatures().then(M=>{ke&&(M.ok?$(M.value):_r(M.error)||$([]));}).catch(()=>{}),()=>{ke=false;}},[o]);let H=En(t.clinic),O=f.trim().toLowerCase(),se=bf.test(O),re=H&&(R||O.length>0)&&!se?ue.emailRequired:null,Ee=w?Cn(w,u.trim(),Ne(e.petName),l):null,Ct=e.hostCapture===true||ve||ce!==null,rt=!!(s&&w&&Ee&&u.trim()&&l&&Ct&&(!H||se)),Nt=useCallback(async()=>{if(!(T.current||F!==null||!w||!Ee)){if(!l){E(ue.missingDraftError);return}if(H&&!se){v(true),E(ue.emailRequired);return}if(!(!s||!u.trim())){T.current=true,I(true),E(null);try{if(B.current===null){let M=ce!==null?{signatureId:ce}:await n();if(!D.current)return;if(M===null){E(ue.missingSignatureError);return}let we=t.clinic&&(!H||t.clinic.emailStatus==="none")?{clinicId:t.clinic.id}:{clinicFreeText:l};B.current={petRef:e.petRef,ownerName:u.trim(),authorizationVersion:w.authorizationVersion,...we,...H?{clinicEmail:O}:{},...M.signatureId!==void 0?{signatureId:M.signatureId}:{signaturePngBase64:M.signaturePngBase64},idempotencyKey:L.current()};}let ke=await r.createClinicRequest(B.current);if(!D.current)return;if(!ke.ok){E(ke.error.displayMessage);return}if(ke.value.petRef!==e.petRef){E(N("internalError").displayMessage);return}q(ke.value),B.current=null,a?.(ke.value);}catch{D.current&&E(N("internalError").displayMessage);}finally{T.current=false,D.current&&I(false);}}}},[s,n,t.clinic,l,r,w,F,e.petRef,H,O,a,u,ce,Ee,se]),Mt=useCallback(()=>{B.current=null,E(null);},[]);return {title:c?ue.titleFreeText:ue.titleDirectory,clinicName:l,isFreeText:c,authorized:s,ownerName:u,email:f,emailError:re,needsEmail:H,directoryClinicNoEmail:H&&t.clinic!==null,copy:w,copyError:y,scope:Ee,error:S,busy:C,created:F,ready:rt,signatures:j,reuseSignatureId:ce,hasSignature:Ct,setAuthorized(ke){T.current||(Mt(),d(ke));},setOwnerName(ke){T.current||(Mt(),p(ke));},setEmail(ke){T.current||(Mt(),v(false),b(ke));},setSigned(ke){T.current||(Mt(),ie(ke),ke&&oe(null));},pickReuseSignature(ke){T.current||(Mt(),oe(ke));},retryCopy(){x(null),P(ke=>ke+1);},submit:Nt}}i(Lc,"useRecordsConsentForm");function bs(e){let{userRef:t,scopeEpoch:r}=Te();return jsx(Ve,{capability:"recordsClinic",style:e.style,...Fe(e.onBack,Ye),children:t===null?jsx(m,{accessibilityRole:"alert",children:ye.sessionRequired}):jsx(xf,{...Le(e,["onCreated","onNavigate","onBack"])},JSON.stringify([t,r,e.petRef,e.clinic.key]))})}i(bs,"EverfurRecordsConsent");function xf({petRef:e,petName:t,clinic:r,ownerName:o,onCaptureSignature:n,onCreated:a,controller:l,onNavigate:c,onBack:s,style:d}){let u=me(),p=Cf(),f=V(),b=Ut(),R=yr(),[v,w]=useState(null),[g,y]=useState("draw"),x=useCallback(async()=>v===null?null:{signaturePngBase64:v},[v]),h=Lc({petRef:e,petName:t,ownerName:o??"",clinic:r,controller:l??b,depthClient:R,capture:n?()=>n({petRef:e,petName:Ne(t),ownerName:h.ownerName,clinicName:h.clinicName,authorizationVersion:h.copy?.authorizationVersion??"",scopeText:h.scope??"",signal:new AbortController().signal}):x,hostCapture:n!==void 0,onCreated:i(C=>{a?.(C),c?.({name:"dashboard"});},"onCreated")}),P=useRef(h);P.current=h;let S=useCallback(C=>{w(C),P.current.setSigned(C!==null);},[]),E=h.busy;return jsxs(View,{style:[u.root,d],children:[jsx(Ke,{title:h.title,onBack:s,testID:"records-consent-header"}),jsxs(KeyboardAvoidingView,{behavior:"padding",style:u.body,children:[jsxs(ScrollView,{contentContainerStyle:p.content,keyboardShouldPersistTaps:"handled",testID:"records-consent",children:[jsxs(View,{style:p.scopeCard,accessibilityRole:"summary",children:[jsx(m,{style:p.scopeHeading,accessibilityRole:"header",children:ue.scopeHeading}),jsx(m,{style:p.scopeBody,children:ue.scopeBody}),jsx(View,{style:p.bullets,children:ue.whatWeDo.map(C=>jsxs(View,{style:p.bulletRow,children:[jsx(m,{style:p.check,children:"\u2713"}),jsx(m,{style:p.bulletText,children:C})]},C))}),jsx(View,{style:p.retentionRow,children:jsx(m,{style:p.retentionText,children:ue.retentionNote})}),h.copy&&h.scope?jsx(m,{style:p.serverScope,testID:"records-consent-scope",children:h.scope}):h.copyError?jsxs(Fragment,{children:[jsx(m,{style:u.errorText,accessibilityRole:"alert",children:h.copyError.displayMessage}),jsx(X,{label:ye.retry,kind:"outline",onPress:h.retryCopy,testID:"records-consent-copy-retry"})]}):jsx(m,{style:u.muted,accessibilityLiveRegion:"polite",children:ye.loading})]}),jsxs(Pressable,{onPress:()=>h.setAuthorized(!h.authorized),accessibilityRole:"checkbox",accessibilityState:{checked:h.authorized},accessibilityLabel:ue.authorizeLabel(t,h.clinicName),hitSlop:6,style:[p.toggle,h.authorized?p.toggleChecked:null],testID:"records-authorize-toggle",children:[jsx(View,{style:[p.box,h.authorized?p.boxChecked:null],accessibilityElementsHidden:true,importantForAccessibility:"no",children:h.authorized?jsx(m,{style:p.boxCheck,children:"\u2713"}):null}),jsx(m,{style:p.toggleLabel,children:ue.authorizeLabel(t,h.clinicName)})]}),jsxs(View,{style:p.block,children:[jsx(m,{style:u.fieldLabel,children:ue.fullName}),jsx(He,{accessibilityLabel:ue.fullName,style:u.field,value:h.ownerName,placeholder:ue.fullNamePlaceholder,placeholderTextColor:f.color.text.placeholder,maxLength:200,editable:!E,autoComplete:"name",autoCapitalize:"words",onChangeText:h.setOwnerName,testID:"records-consent-owner-name"})]}),h.needsEmail?jsxs(View,{style:p.block,testID:"records-consent-email-block",children:[h.directoryClinicNoEmail?jsx(View,{style:u.cautionNote,testID:"records-consent-no-email-note",children:jsx(m,{style:u.cautionNoteText,children:ue.noEmailNote(t,h.clinicName)})}):null,jsx(m,{style:u.fieldLabel,children:ue.emailLabel}),jsx(He,{accessibilityLabel:ue.emailLabel,style:u.field,value:h.email,placeholder:ue.emailPlaceholder,placeholderTextColor:f.color.text.placeholder,maxLength:320,editable:!E,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,onChangeText:h.setEmail,testID:"records-consent-clinic-email"}),h.emailError?jsx(m,{style:u.errorText,accessibilityRole:"alert",children:h.emailError}):null,jsx(m,{style:u.muted,testID:"records-consent-review-note",children:ue.newClinicDirectSendNote})]}):null,n?null:jsxs(View,{style:p.signatureBlock,children:[h.signatures.length>0?jsxs(View,{style:p.block,children:[jsx(m,{style:u.fieldLabel,children:ue.reuseSignature}),jsx(ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,contentContainerStyle:p.gallery,children:h.signatures.map(C=>{let I=h.reuseSignatureId===C.signatureId;return jsx(Pressable,{onPress:()=>h.pickReuseSignature(I?null:C.signatureId),accessibilityRole:"button",accessibilityLabel:I?ue.reuseTileSelectedA11y:ue.reuseTileA11y,style:[p.tile,I?p.tileSelected:null],testID:`records-consent-reuse-${C.signatureId}`,children:jsx(Image,{source:{uri:C.previewUrl},style:p.tileImage,resizeMode:"contain",accessibilityIgnoresInvertColors:true})},C.signatureId)})}),jsx(m,{style:u.muted,children:ue.reuseHint})]}):null,jsx(View,{style:p.signatureHeader,children:jsx(m,{style:u.fieldLabel,children:g==="type"?ue.signType:ue.signDraw})}),jsx(Mr,{onChange:S,disabled:E}),jsx(Pressable,{onPress:()=>y(C=>C==="draw"?"type":"draw"),accessibilityRole:"button",accessibilityLabel:g==="draw"?ue.toTypeA11y:ue.toDraw,style:p.modeToggle,testID:"records-consent-sign-mode-toggle",children:jsx(m,{style:p.modeToggleText,children:g==="draw"?ue.toType:ue.toDraw})}),jsx(m,{style:u.muted,children:ue.signatureHint(h.clinicName)})]}),h.error?jsx(View,{style:u.errorBanner,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",children:jsx(m,{style:u.errorText,children:h.error})}):null,h.created?jsx(m,{accessibilityLiveRegion:"polite",style:u.bodyText,children:h.created.statusLabel||ye.records}):null]}),jsx(View,{style:p.footer,children:jsx(X,{label:E?ue.submitting:ue.submit,accessibilityLabel:ue.submitA11y,disabled:!h.ready,busy:E,onPress:()=>{h.submit();},style:p.submit,testID:"records-consent-submit"})})]}),jsx(qe,{})]})}i(xf,"ConsentBody");function Cf(){let e=V();return useMemo(()=>Ef(e),[e])}i(Cf,"useLocalStyles");function Ef(e){let{color:t,space:r,radius:o,type:n}=e,a=StyleSheet.hairlineWidth,l=i((c,s,d,u="regular")=>({...k(e,u),fontSize:c,lineHeight:Math.round(c*s),color:d}),"text");return StyleSheet.create({content:{paddingHorizontal:r.lg,paddingBottom:r.xl+r.xs,gap:r.lg+r.xs/2},scopeCard:{borderRadius:o.lg-r.xs/2,borderWidth:a,borderColor:t.brandBorder,backgroundColor:t.surfaceCream,padding:r.lg,gap:r.md},scopeHeading:{...l(n.size.body+1,n.lineHeight.snug,t.brandInk,"bold")},scopeBody:l(n.size.bodyTight,n.lineHeight.relaxed,t.text.primary),bullets:{gap:r.sm},bulletRow:{flexDirection:"row",alignItems:"flex-start",gap:r.sm},check:{...l(n.size.body,n.lineHeight.normal,t.brandInk,"bold")},bulletText:{flex:1,...l(n.size.bodyTight,n.lineHeight.normal,t.text.primary)},retentionRow:{paddingTop:r.xs,borderTopWidth:1,borderTopColor:t.borderHairlineGreen},retentionText:l(n.size.tiny,n.lineHeight.normal,t.text.muted),serverScope:{...l(n.size.bodyTight,n.lineHeight.relaxed,t.text.secondary),paddingTop:r.xs},toggle:{flexDirection:"row",alignItems:"flex-start",gap:r.md,borderRadius:o.lg-r.xs,borderWidth:a,borderColor:t.brandBorder,backgroundColor:t.surface,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md+r.xs/2},toggleChecked:{borderColor:t.brandInk,backgroundColor:t.brandSoft},box:{width:r.xl,height:r.xl,borderRadius:o.xs+1,borderWidth:1.6,borderColor:t.brandInk,alignItems:"center",justifyContent:"center",backgroundColor:t.surface},boxChecked:{backgroundColor:t.brandInk},boxCheck:{...l(n.size.body,n.lineHeight.tight,t.surface,"bold")},toggleLabel:{flex:1,...l(n.size.bodyTight,n.lineHeight.normal,t.text.primary,"bold")},block:{gap:r.sm},signatureBlock:{gap:r.sm},gallery:{gap:r.sm,paddingVertical:r.xs},tile:{width:r.xxl*3+r.lg,height:r.xxl+r.lg+r.sm,borderRadius:o.sm,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,overflow:"hidden"},tileSelected:{borderColor:t.brandInk,borderWidth:2},tileImage:{width:"100%",height:"100%"},signatureHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},modeToggle:{minHeight:r.xxl+r.md,alignItems:"center",justifyContent:"center"},modeToggleText:{...l(n.size.bodyTight,n.lineHeight.snug,t.linkInk,"bold"),textDecorationLine:"underline"},footer:{paddingHorizontal:r.lg,paddingTop:r.md,paddingBottom:r.xxl,borderTopWidth:a,borderTopColor:t.borderHairlineGreen,backgroundColor:t.background},submit:{minHeight:r.xxl+r.lg+r.xs+r.xs/2}})}i(Ef,"makeLocalStyles");function Co(e){return e==="above"||e==="below"?"critical":e==="in_range"?"positive":"neutral"}i(Co,"markerStatusTone");function kf(e){switch(e){case "above":return "above the reference range";case "below":return "below the reference range";case "in_range":return "within range";default:return "no reference range on file"}}i(kf,"markerStatusSpoken");function Tf(e){return e.refLow!==null&&e.refHigh!==null?`, reference range ${e.refLow} to ${e.refHigh}`:e.refLow!==null?`, reference range at least ${e.refLow}`:e.refHigh!==null?`, reference range up to ${e.refHigh}`:""}i(Tf,"rangePhrase");function Eo(e,t){let r=t?` ${t}`:"";return e.refLow!==null&&e.refHigh!==null?`${e.refLow}-${e.refHigh}${r}`:e.refLow!==null?`\u2265 ${e.refLow}${r}`:e.refHigh!==null?`\u2264 ${e.refHigh}${r}`:"-"}i(Eo,"formatReferenceRange");function Nc(e,t){let r=t.reviewed?", reviewed by our team":"",o=t.sourceClinic?`, from ${t.sourceClinic}`:"";return `${J(t.at)}: ${Tt(t.value,e.unit,t.qualitativeResult)}, ${kf(t.status)}${Tf(t)}${o}${r}`}i(Nc,"markerPointSpoken");function Xe(e){return e?.trim()||"my pet"}i(Xe,"lead");function Mc(e){let t=e.trim();return /[.!?]$/.test(t)?t:`${t}.`}i(Mc,"clause");function Bc(e,t){let r=t.canonicalName.trim()||"a lab marker",o=[`I'm looking at ${Xe(e)}'s ${r}`],n=[t.latestValueText?.trim(),t.statusText?.trim(),t.trajectoryText?.trim()].filter(Boolean).join(", ");return o[0]+=n?`: ${n}.`:".",t.meaningText?.trim()&&o.push(Mc(t.meaningText)),o.push(`What does this trend tell me, and should I do anything differently for ${Xe(e)}?`),{prompt:o.join(" "),entityRef:{type:"marker",id:t.markerId,payload:{marker:r,...t.statusText?.trim()?{status:t.statusText.trim()}:{}}}}}i(Bc,"buildMarkerAskPrompt");function Hc(e,t,r){let{totalMarkers:o,inRangeCount:n,outOfRangeCount:a,unknownCount:l}=t;if(o===0)return {prompt:`I'm looking at ${Xe(e)}'s lab markers, but there aren't any on file yet. What lab work is worth running for ${Xe(e)}?`,entityRef:{type:"marker_summary",id:r,payload:{total:0}}};let c=l>0?`, ${l} without a reference range`:"";return {prompt:`I'm looking at ${Xe(e)}'s lab markers: ${o} total, ${n} in range, ${a} out of range${c}. What should I focus on?`,entityRef:{type:"marker_summary",id:r,payload:{total:o,inRange:n,outOfRange:a,unknown:l}}}}i(Hc,"buildMarkerSummaryAskPrompt");function Uc(e,t){let r=t.canonicalName.trim()||"a lab marker",o=[`${r}: ${t.valueText.trim()}`];t.collectedAt?.trim()&&o.push(`collected ${t.collectedAt.trim()}`),t.sourceClinic?.trim()&&o.push(`from ${t.sourceClinic.trim()}`),t.referenceText?.trim()&&o.push(`reference range ${t.referenceText.trim()}`),t.flagged&&o.push(`flagged ${t.flagged}`);let n={marker:r};return t.flagged&&(n.status=t.flagged),t.reviewed!==void 0&&(n.reviewed=t.reviewed),{prompt:`I'm looking at ${Xe(e)}'s ${o.join(", ")}. What does this mean, and should I be concerned?`,entityRef:{type:"lab_reading",id:t.entityId,payload:n}}}i(Uc,"buildMarkerReadingAskPrompt");function So(e,t,r){let o=t.clinicName?.trim(),n=t.heldItemCount??0,a=n>0?`, ${n} fact${n===1?"":"s"} being verified`:"";return {prompt:`I'm looking at ${Xe(e)}'s records request${o?` to ${o}`:""}, status: ${t.statusLabel.trim()}${a}. What does this status mean, and what happens next?`,entityRef:{type:"records_request",id:r,payload:{status:t.status,held:n,...o?{clinic:o}:{}}}}}i(So,"buildRecordsRequestAskPrompt");var _f=Object.freeze({vaccination:"vaccine",medication:"medication",body_weight:"weight",vital:"weight"});function hs(e,t,r,o){let n=t.entityTypeLabel.trim()||"record",a=t.title.trim()||n,l=t.detail?.trim();return {prompt:`I'm looking at ${Xe(e)}'s ${n.toLowerCase()}: ${a}${l?`, ${l}`:""}. What does this mean, and what should I keep on top of for ${Xe(e)}?`,entityRef:{type:_f[r]??r,id:o,payload:{kind:n,title:a,...l?{detail:l}:{}}}}}i(hs,"buildEntityRowAskPrompt");function jc(e,t,r){let o=t.filter(l=>l.label.trim()),n={type:"upcoming_care",id:r};if(o.length===0)return {prompt:`I'm looking at ${Xe(e)}'s upcoming care, but nothing is scheduled yet. What preventive care and checkups should ${Xe(e)} be on?`,entityRef:n};let a=[...o].sort((l,c)=>(l.tone==="overdue"?0:1)-(c.tone==="overdue"?0:1)).slice(0,4).map(l=>l.relativeText.trim()?`${l.label.trim()} (${l.relativeText.trim().toLowerCase()})`:l.label.trim());return {prompt:`I'm looking at ${Xe(e)}'s upcoming care: ${a.join(", ")}. What should I prioritize for ${Xe(e)}, and how do I stay on top of these?`,entityRef:n}}i(jc,"buildUpcomingCareAskPrompt");function $c(e,t,r){let o=[`I'm looking at ${Xe(e)}'s physical exam${t.observedOn?.trim()?` from ${t.observedOn.trim()}`:""}.`],n=t.abnormal.filter(a=>a.system.trim());return n.length>0?(o.push(`Abnormal: ${n.slice(0,6).map(a=>`${a.system.trim()}: ${a.finding.trim()}`).join("; ")}.`),o.push(`What do these findings mean, and what should I follow up on for ${Xe(e)}?`)):o.push(`Everything examined came back normal. What does this tell me about ${Xe(e)}'s health?`),{prompt:o.join(" "),entityRef:{type:"physical_exam",id:r}}}i($c,"buildPhysicalExamAskPrompt");function Wc(e,t,r){let o=[`I'm looking at ${Xe(e)}'s visit notes${t.observedOn?.trim()?` from ${t.observedOn.trim()}`:""}.`];for(let n of t.sections.filter(a=>a.text.trim()).slice(0,3))o.push(`${n.label.trim()||"Note"}: ${Mc(n.text)}`);return o.push(`Can you summarize what happened and what I should follow up on for ${Xe(e)}?`),{prompt:o.join(" "),entityRef:{type:"visit",id:r}}}i(Wc,"buildVisitNoteAskPrompt");function Gc(e,t,r){let o=t.scopeLabel.trim()||"a detail",n=t.candidates.filter(l=>l.value.trim()),a=n.slice(0,3).map(l=>`"${l.value.trim()}"${l.clinicName?.trim()?` (${l.clinicName.trim()})`:""}`).join(" vs ");return {prompt:`Two of ${Xe(e)}'s documents disagree on ${o}: ${a}. Which is likely correct, and what should I ask my vet?`,entityRef:{type:"conflict",id:r,payload:{field:o,severity:t.severity,values:n.map(l=>l.value.trim()).join(" | ")}}}}i(Gc,"buildConflictAskPrompt");var ft=Object.freeze({title:"Medical records",subtitle:i(e=>{let t=e?.trim()??"";return t.length>0?`${t}\u2019s uploads and clinic requests`:"Every upload and clinic request"},"subtitle"),requestRecords:"Request records",requestRecordsA11y:"Request records from a clinic",uploadOwn:"I already have the records",uploadOwnA11y:"Upload records you already have",ownerUpload:"Records you uploaded",clinicRequest:"Clinic request",meta:i((e,t)=>`${e?"Uploaded":"Requested"} ${J(t)}`,"meta"),rowA11y:i((e,t,r)=>`${e}, ${t}, status ${r}`,"rowA11y"),askA11y:i(e=>`Ask Everfur about ${e}`,"askA11y"),allRequests:"Your record requests"}),ko=Object.freeze({preparing:"Preparing",sent:"Sent",processing:"Processing",done:"Ready"});function Pf(e){switch(e){case "awaiting_clinic":return ko.sent;case "received":case "parsing":case "in_review":return ko.processing;case "published":return ko.done;default:return ko.preparing}}i(Pf,"stepLabel");function Yc(e){let t=e.source==="owner_provided",r=e.clinicName?.trim()||(t?ft.ownerUpload:ft.clinicRequest),o=e.statusLabel.trim()||Pf(e.status),n=ft.meta(t,e.createdAt);return Object.freeze({source:r,meta:n,status:o,ownerUpload:t,a11yLabel:ft.rowA11y(r,n,o)})}i(Yc,"requestRowView");var If=new Set(["records_received","parsing","parsing_failed","in_review","review_email_failed"]),Df=new Set(["received","parsing","in_review"]);function Af(e){return e.wireStatus!==void 0?If.has(e.wireStatus):Df.has(e.status)}i(Af,"isProcessing");function Kc(e,t,r={}){let o=e.filter(c=>!br(c.status));if(e.length===0||r.activeOnly===true&&o.length===0)return null;let n=e.filter(Af).length,a=n>0?`${n} document${n===1?"":"s"} being read`:o.length>0?`${o.length} active record request${o.length===1?"":"s"}`:ft.allRequests,l=n>0?`We\u2019ll add ${n===1?"it":"them"} to ${t}\u2019s records once ready.`:o.length>0?"See each clinic\u2019s status and what happens next.":"See the status of every upload and clinic request.";return Object.freeze({title:a,subtitle:l,processing:n>0,a11yLabel:`${a}. ${l}`})}i(Kc,"requestsStatusCardView");function Dn(e){return e!==void 0}i(Dn,"canUploadRecords");function Rs(e,t){return e??t?.version??""}i(Rs,"resolveConsentVersion");function Hr(e,t){return Rs(e,t).length>0}i(Hr,"canGrantConsent");function Pr(e,t){return e.denialReason==="consent_required"?t?{kind:"consent_required"}:{kind:"consent_unavailable"}:e.denialReason==="pet_not_found"?{kind:"pet_not_found",error:N("petNotFound",{retryable:false})}:e.denialReason==="entitlement"?{kind:"error",error:N("accessDenied")}:e.denialReason==="session_required"?{kind:"session_required"}:e.withheld?{kind:"withheld"}:e.error===null?{kind:"withheld"}:{kind:"error",error:e.error}}i(Pr,"selectErrorView");function To(e){let t=e.clinicName?.trim()??"";return t.length>0?t:e.source==="owner_provided"?Qc.ownerUpload:Qc.clinicRequest}i(To,"selectRequestTitle");var Qc=Object.freeze({ownerUpload:"Records you uploaded",clinicRequest:"Record request"});function vs(e,t){return t===null||t.status!=="awaiting_upload"?null:t}i(vs,"selectResumableUploadRequest");function ws(e){let t=[...e].sort((r,o)=>r.updatedAt!==o.updatedAt?r.updatedAt>o.updatedAt?-1:1:r.createdAt!==o.createdAt?r.createdAt>o.createdAt?-1:1:0);return Object.freeze(t)}i(ws,"selectRequestList");function Ur(e){let t=e.actionNeededLabel?.trim()??"";return t.length>0?t:e.statusLabel}i(Ur,"selectPrimaryLabel");function _o(e){if(e.showClinicPhone!==true)return null;let t=e.clinicPhone?.trim()??"";return t.length===0?null:{phone:t,dial:`tel:${t.replace(/[^+\d]/g,"")}`,clinicName:e.clinicName?.trim()||null}}i(_o,"selectClinicCall");function Xc(e){switch(e.wireStatus??e.status){case "published":return "positive";case "failed":case "clinic_declined":return "critical";case "revoked":return "neutral";case "clinic_responded_no_records":case "awaiting_upload":case "records_received":case "parsing":case "parsing_failed":case "in_review":case "review_email_failed":return "warning";default:return "info"}}i(Xc,"selectRequestStatusTone");var Rt=200,Zc=16;function Lf(e,t){let r=e.inRangeCount+e.outOfRangeCount+e.unknownCount;if(!Number.isFinite(r)||r<=0)return [];let o=[{key:"in_range",color:t.inRange,count:e.inRangeCount},{key:"out_of_range",color:t.outOfRange,count:e.outOfRangeCount},{key:"unknown",color:t.unknown,count:e.unknownCount}],n=0,a=[];for(let l of o){if(!(l.count>0))continue;let c=l.count/r*360;if(!Number.isFinite(c))return null;a.push({key:l.key,color:l.color,startDeg:n,sweepDeg:c}),n+=c;}return a}i(Lf,"buildRingSegments");function td({summary:e,onAsk:t,testID:r}){let o=qf(),n=V(),{totalMarkers:a,inRangeCount:l,outOfRangeCount:c,unknownCount:s}=e,d=useMemo(()=>Lf(e,{inRange:n.color.success,outOfRange:n.color.danger,unknown:n.color.text.muted}),[e,n]),u=d!==null&&d.length>0;return jsxs(View,{style:o.card,accessibilityRole:"summary",testID:r,children:[jsx(m,{style:o.title,children:jt.title}),jsx(View,{style:o.ringRow,accessible:true,accessibilityRole:"image",accessibilityLabel:jt.a11y(a,l,c,s),children:jsxs(View,{style:o.ringWrap,children:[jsx(View,{style:o.track}),d===null?null:d.map(p=>jsx(Vf,{segment:p,styles:o},p.key)),jsxs(View,{style:o.center,pointerEvents:"none",children:[jsx(m,{style:o.centerCount,children:a}),jsx(m,{style:o.centerLabel,children:a===1?jt.marker:jt.markers})]})]})}),u||d===null?jsxs(View,{style:o.badges,children:[jsx(xs,{count:c,label:jt.outOfRange,color:n.color.danger,styles:o}),jsx(xs,{count:l,label:jt.inRange,color:n.color.success,styles:o}),s>0?jsx(xs,{count:s,label:jt.noRange,color:n.color.text.muted,styles:o}):null]}):null,jsx(m,{style:o.subtitle,children:jt.subtitle}),t?jsx(Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:jt.askA11y,style:o.ask,testID:"marker-summary-ask",children:jsx(m,{style:o.askLabel,children:jt.ask})}):null]})}i(td,"MarkerSummaryCard");function Vf({segment:e,styles:t}){return (e.sweepDeg<=180?[{start:e.startDeg,sweep:e.sweepDeg}]:[{start:e.startDeg,sweep:180},{start:e.startDeg+180,sweep:e.sweepDeg-180}]).map((o,n)=>jsx(View,{style:[t.piece,{transform:[{rotate:`${o.start}deg`}]}],pointerEvents:"none",testID:`marker-ring-${e.key}`,children:jsx(View,{style:t.window,children:jsx(View,{style:[t.halfRing,{borderTopColor:e.color,borderRightColor:e.color,transform:[{rotate:`${o.sweep-135}deg`}]}]})})},n))}i(Vf,"Arc");function xs({count:e,label:t,color:r,styles:o}){return jsx(View,{style:[o.badge,{borderColor:r}],children:jsx(m,{style:[o.badgeText,{color:r}],children:`${e} ${t}`})})}i(xs,"Badge");function qf(){let e=V();return useMemo(()=>zf(e),[e])}i(qf,"useStyles");function zf(e){let{color:t,space:r,radius:o,type:n,slots:a}=e,l=StyleSheet.hairlineWidth,c=at(a.recordCard);return StyleSheet.create({card:{borderRadius:o.sm,backgroundColor:t.surfaceCream,borderWidth:l,borderColor:t.brandBorder,padding:r.lg-1,gap:r.sm+r.xs/2,...nt(a.recordCard,l)},title:{...k(e,"bold"),fontSize:n.size.body,lineHeight:Math.round(n.size.body*n.lineHeight.snug),color:t.brandInk,letterSpacing:n.letterSpacing.headerBrand,...c},ringRow:{alignItems:"center"},ringWrap:{width:Rt,height:Rt,alignItems:"center",justifyContent:"center"},track:{position:"absolute",width:Rt,height:Rt,borderRadius:Rt/2,borderWidth:Zc,borderColor:t.surfaceSubtle},piece:{position:"absolute",width:Rt,height:Rt},window:{position:"absolute",left:Rt/2,top:0,width:Rt/2,height:Rt,overflow:"hidden"},halfRing:{position:"absolute",left:-Rt/2,top:0,width:Rt,height:Rt,borderRadius:Rt/2,borderWidth:Zc,borderBottomColor:"transparent",borderLeftColor:"transparent"},center:{position:"absolute",alignItems:"center",justifyContent:"center"},centerCount:{...k(e,"medium"),fontSize:n.size.verdict*2,lineHeight:n.size.verdict*2+r.xs,color:t.text.primary,textAlign:"center",...c},centerLabel:{...k(e,"medium"),fontSize:n.size.heading-1,lineHeight:n.size.heading+r.xs/2,color:t.text.primary,textAlign:"center",...c},badges:{flexDirection:"row",flexWrap:"wrap",justifyContent:"center",gap:r.sm},badge:{borderWidth:1,borderRadius:o.pill,paddingHorizontal:r.sm+r.xs/2,paddingVertical:r.xs},badgeText:{...k(e,"mono"),fontSize:n.size.nano,lineHeight:n.size.tiny,letterSpacing:n.letterSpacing.headerBrand/2,textTransform:"uppercase"},subtitle:{...k(e,"regular"),fontSize:n.size.caption,lineHeight:Math.round(n.size.caption*n.lineHeight.relaxed),color:t.text.primary,...c},ask:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:r.sm,minHeight:r.xxl+r.sm,marginTop:r.xs/2,paddingHorizontal:r.lg,borderRadius:o.pill,borderWidth:l,borderColor:t.borderRingCream,backgroundColor:t.surface},askLabel:{...k(e,"bold"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*n.lineHeight.snug),color:t.text.primary,letterSpacing:n.letterSpacing.tight}})}i(zf,"makeStyles");function Ff(e){return e.value!==null&&Number.isFinite(e.value)}i(Ff,"numeric");function rd(e){let t=e.points.filter(Ff);if(t.length===0)return null;let r=e.points[e.points.length-1]??null,o=r?.refLow??null,n=r?.refHigh??null,a=t.map(g=>g.value),l=Math.min(...a,...o!==null?[o]:[],...n!==null?[n]:[]),c=Math.max(...a,...o!==null?[o]:[],...n!==null?[n]:[]);l===c&&(l-=1,c+=1);let s=(c-l)*.18,d=l-s,u=c+s,p=u-d,f=i(g=>(u-g)/p*100,"y"),b=6,R=t.length,v=t.map((g,y)=>({index:y,xPct:R<=1?50:b+y/(R-1)*(100-2*b),yPct:f(g.value),status:g.status,point:g})),w=o!==null||n!==null?{topPct:n!==null?f(n):0,bottomPct:o!==null?f(o):100}:null;return {points:v,band:w,firstDate:t[0]?.at??null,lastDate:t[t.length-1]?.at??null}}i(rd,"buildMarkerChart");var Bf=416,Hf=140;function Io(e){return `${e}%`}i(Io,"pct");function Uf({marker:e,width:t,onPointPress:r,onAsk:o}){let n=Cs(),a=me(),l=nr(e.latest?.status??null),c=Co(e.latest?.status??null),s=Kr(e.trajectory,e.points.length),d=useMemo(()=>rd(e),[e]),u=e.latest?Tt(e.latest.value,e.unit,e.latest.qualitativeResult):null;return jsx(View,{style:[n.page,t!==void 0?{width:t}:null],testID:`marker-card-${e.markerId}`,children:jsxs(View,{style:n.card,children:[jsxs(View,{style:n.headerRow,children:[jsxs(View,{style:n.nameColumn,children:[jsx(m,{style:n.markerName,numberOfLines:2,children:e.name}),e.unit?jsx(m,{style:n.unit,children:e.unit}):null]}),jsx(View,{accessible:true,accessibilityRole:"text",accessibilityLabel:dr.status(l.label),children:jsx(kt,{label:l.label,tone:c})})]}),e.latest&&u!==null?jsxs(View,{style:n.latestRow,children:[jsx(m,{style:[n.latestValue,l.outOfRange?n.latestValueDanger:null],accessibilityLabel:dr.latestA11y(u,l.label,J(e.latest.at)),children:u}),jsx(m,{style:n.latestDate,children:J(e.latest.at)})]}):null,s?jsx(m,{style:n.trajectory,accessibilityRole:"text",children:s}):null,d!==null?jsxs(View,{style:n.chartWrap,children:[jsxs(View,{style:n.plot,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:[d.band?jsx(View,{style:[n.band,{top:Io(d.band.topPct),height:Io(Math.max(0,d.band.bottomPct-d.band.topPct))}]}):null,d.points.map(p=>jsx(Pressable,{onPress:()=>r(e,p.point),hitSlop:12,style:[n.point,p.status==="above"||p.status==="below"?n.pointDanger:null,{left:Io(p.xPct),top:Io(p.yPct)}],testID:`marker-point-${e.markerId}-${p.index}`},p.index))]}),jsx(View,{style:n.a11yTable,accessibilityRole:"summary",accessibilityLabel:dr.readingsA11y(e.name),children:e.points.map((p,f)=>jsx(View,{accessibilityRole:"text",accessibilityLabel:Nc(e,p)},f))}),jsx(m,{style:e.points.length===1?n.singleHint:n.tapHint,children:e.points.length===1?dr.singleHint:dr.tapHint})]}):jsx(View,{style:n.emptyBody,accessibilityRole:"text",children:jsx(m,{style:n.emptyText,children:dr.empty})}),o?jsx(Pressable,{onPress:()=>o(e),accessibilityRole:"button",accessibilityLabel:dr.askA11y(e.name),style:[a.pill,a.pillAsk],testID:`marker-ask-${e.markerId}`,children:jsx(m,{style:a.pillAskLabel,children:dr.ask})}):null]})})}i(Uf,"MarkerTrendCard");function sd({markers:e,onPointPress:t,onAsk:r}){let o=Cs(),[n,a]=useState(0),[l,c]=useState(0),s=i(p=>a(p.nativeEvent.layout.width),"onLayout"),d=i(p=>{if(n<=0)return;let f=Math.round(p.nativeEvent.contentOffset.x/n);c(Math.max(0,Math.min(f,e.length-1)));},"onMomentumEnd"),u=e[l]??null;return jsxs(View,{style:o.carousel,onLayout:s,testID:"marker-carousel",children:[jsx(ScrollView,{horizontal:true,pagingEnabled:true,showsHorizontalScrollIndicator:false,onMomentumScrollEnd:d,snapToAlignment:"start",children:e.map(p=>jsx(Uf,{marker:p,width:n>0?n:void 0,onPointPress:t,onAsk:r},p.markerId))}),jsxs(View,{style:o.footer,accessible:true,accessibilityRole:"adjustable",accessibilityLabel:Mi.a11y(u?.name??null,l,e.length),children:[jsx(View,{style:o.dots,children:e.map((p,f)=>jsx(View,{style:[o.dot,f===l?o.dotActive:null]},p.markerId))}),jsx(m,{style:o.counter,children:Mi.counter(l,e.length)})]})]})}i(sd,"MarkerTrendCarousel");function ad({marker:e,point:t,onClose:r,onAsk:o}){let n=Cs(),a=me();if(e===null||t===null)return null;let l=i((c,s)=>jsxs(View,{style:n.detailRow,accessible:true,accessibilityRole:"text",accessibilityLabel:`${c}: ${s}`,children:[jsx(m,{style:n.detailLabel,children:c}),jsx(m,{style:n.detailValue,children:s})]},c),"row");return jsxs(Modal,{transparent:true,visible:true,animationType:"slide",onRequestClose:r,children:[jsx(Pressable,{style:n.backdrop,onPress:r,accessibilityRole:"button",accessibilityLabel:St.close}),jsxs(View,{style:n.sheet,accessibilityViewIsModal:true,testID:"marker-provenance-sheet",children:[jsx(View,{style:n.handle}),jsxs(View,{style:n.sheetHeader,children:[jsx(m,{style:n.sheetTitle,accessibilityRole:"header",children:St.title}),jsx(Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:St.close,hitSlop:10,style:n.closeButton,testID:"marker-provenance-close",children:jsx(m,{style:n.closeGlyph,children:"\xD7"})})]}),jsxs(View,{style:n.sheetBody,children:[jsxs(View,{style:n.valueRow,children:[jsx(m,{style:n.sheetName,children:e.name}),jsx(m,{style:n.sheetValue,children:Tt(t.value,e.unit,t.qualitativeResult)})]}),t.reviewed?jsx(View,{style:n.reviewed,accessibilityRole:"text",children:jsx(m,{style:n.reviewedText,children:St.reviewed})}):null,l(St.collected,J(t.at)),t.sourceClinic?l(St.clinic,t.sourceClinic):null,l(St.referenceRange,t.refLow!==null||t.refHigh!==null?Eo(t,e.unit):St.noRange),t.docId?l(St.sourceDocument,t.docId):null,t.reviewed?null:jsx(m,{style:n.unverified,accessibilityRole:"text",children:St.unverified}),o?jsx(Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:St.askA11y,style:[a.pill,a.pillAsk],testID:"marker-provenance-ask",children:jsx(m,{style:a.pillAskLabel,children:St.ask})}):null]})]})]})}i(ad,"MarkerProvenanceSheet");function Cs(){let e=V();return useMemo(()=>jf(e),[e])}i(Cs,"useStyles");function jf(e){let{color:t,space:r,radius:o,type:n,slots:a}=e,l=StyleSheet.hairlineWidth,c=r.md,s=i((f,b,R,v="regular")=>({...k(e,v),fontSize:f,lineHeight:Math.round(f*b),color:R}),"text"),d=at(a.recordCard),u=s(n.size.subtitle,n.lineHeight.snug,t.text.primary,"bold"),p=s(n.size.verdict+r.xs,n.lineHeight.tight,t.text.primary,"bold");return StyleSheet.create({page:{paddingHorizontal:r.sm},card:{borderRadius:o.lg-r.xs/2,borderWidth:l,borderColor:t.brandBorder,backgroundColor:t.surface,padding:r.lg,gap:r.md,...nt(a.recordCard,l)},headerRow:{flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between",gap:r.sm+r.xs/2},nameColumn:{flex:1,gap:r.xs/2},markerName:{...u,...d},sheetName:u,unit:{...k(e,"mono"),fontSize:n.size.tiny,lineHeight:n.size.body,color:t.text.muted,...d},latestRow:{flexDirection:"row",alignItems:"baseline",justifyContent:"space-between",gap:r.md},latestValue:{...p,...d},sheetValue:p,latestValueDanger:{color:t.danger},latestDate:{...s(n.size.caption,n.lineHeight.normal,t.text.muted),...d},trajectory:{...s(n.size.bodyTight,n.lineHeight.normal,t.text.muted),...d},chartWrap:{gap:r.sm},plot:{height:Hf,borderRadius:o.sm,backgroundColor:t.surfaceCream,borderWidth:l,borderColor:t.borderHairlineGreen,overflow:"hidden"},band:{position:"absolute",left:0,right:0,backgroundColor:t.badgeBgPositive},point:{position:"absolute",width:c,height:c,borderRadius:c/2,marginLeft:-c/2,marginTop:-c/2,backgroundColor:t.brand,borderWidth:2,borderColor:t.surface},pointDanger:{backgroundColor:t.danger},a11yTable:{width:1,height:1,overflow:"hidden",position:"absolute"},tapHint:{...s(n.size.tiny,n.lineHeight.normal,t.text.placeholder),textAlign:"center",...d},singleHint:{...s(n.size.caption,n.lineHeight.normal,t.text.muted),textAlign:"center",...d},emptyBody:{alignItems:"center",justifyContent:"center",gap:r.sm,paddingVertical:r.xxl+r.xs},emptyText:{...s(n.size.bodyTight,n.lineHeight.normal,t.text.muted),textAlign:"center",...d},carousel:{height:Bf},footer:{alignItems:"center",gap:r.sm,paddingTop:r.md},dots:{flexDirection:"row",gap:r.xs+r.xs/2},dot:{width:r.xs+r.xs/2,height:r.xs+r.xs/2,borderRadius:r.xs-1,backgroundColor:t.borderHairlineGreen},dotActive:{width:r.lg+r.xs/2,backgroundColor:t.brand},counter:{...k(e,"mono"),fontSize:n.size.tiny,lineHeight:n.size.body,letterSpacing:n.letterSpacing.eyebrow/3,color:t.text.muted},backdrop:{flex:1,backgroundColor:ao},sheet:{backgroundColor:t.surfaceCream,borderTopLeftRadius:o.xl-r.xs,borderTopRightRadius:o.xl-r.xs,paddingHorizontal:r.lg+r.xs,paddingTop:r.sm,paddingBottom:r.xxl+r.xs,maxHeight:"80%",gap:r.md},handle:{alignSelf:"center",width:r.xxl+r.xs,height:r.xs,borderRadius:o.pill,backgroundColor:t.borderRingCream},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},sheetTitle:{flex:1,...s(n.size.subtitle,n.lineHeight.snug,t.text.primary,"bold")},closeButton:{width:r.xxl+r.md,height:r.xxl+r.md,alignItems:"center",justifyContent:"center"},closeGlyph:{...s(n.size.verdict,n.lineHeight.tight,t.text.primary)},sheetBody:{gap:r.md},valueRow:{flexDirection:"row",alignItems:"baseline",justifyContent:"space-between",gap:r.md},reviewed:{alignSelf:"flex-start",borderRadius:o.pill,paddingHorizontal:r.sm+r.xs/2,paddingVertical:r.xs,backgroundColor:t.badgeBgPositive},reviewedText:{...s(n.size.tiny,n.lineHeight.normal,t.success,"medium")},detailRow:{gap:r.xs/2},detailLabel:{...s(n.size.caption,n.lineHeight.normal,t.text.muted,"medium")},detailValue:s(n.size.body,n.lineHeight.normal,t.text.primary),unverified:s(n.size.caption,n.lineHeight.normal,t.text.muted)})}i(jf,"makeStyles");var Z=Object.freeze({title:"Full medical record",shareA11y:"Share medical record",requestClinicsA11y:"Request records from clinics",inReview:i(e=>`${e} ${e===1?"document":"documents"} from your vet ${e===1?"is":"are"} being reviewed. Your full record will appear here once review is complete.`,"inReview"),needsAttention:"Needs your attention",conflictSub:"Two documents list different values. Your vet can confirm which is correct.",askConflict:"Ask Everfur about this",whatsOnFile:"What's on file",coverage:Object.freeze({labs:"Labs",vaccines:"Vaccines",weight:"Weight",vitals:"Vitals",exams:"Exams",procedures:"Procedures",genetics:"Genetics",parasite:"Parasite prevention",reproductive:"Reproductive"}),onFile:"on file",noneOnFile:"none on file",documentsOnFile:i(e=>`${e} ${e===1?"document":"documents"} on file`,"documentsOnFile"),inReviewChip:i(e=>`${e} in review`,"inReviewChip"),beingVerified:i(e=>`${e} being verified`,"beingVerified"),beingVerifiedA11y:i(e=>`${e} ${e===1?"fact is":"facts are"} being verified`,"beingVerifiedA11y"),pendingReview:"Pending review: ",dateRange:i((e,t)=>`${J(e)} to ${J(t)}`,"dateRange"),documents:"Documents",uploadedDocument:be.uploadedDocument,documentRowA11y:i(e=>`View what ${e} contributed to this record`,"documentRowA11y"),identity:"Identity",needsReview:"Needs review",upcomingCare:"Upcoming care",careTimeline:"Care timeline",careTimelineSub:"Related records grouped over time, newest first.",lastDone:i(e=>`Last done ${e}`,"lastDone"),overdue:"Overdue",due:i(e=>`Due ${e}`,"due"),askUpcomingCare:"Ask Everfur about upcoming care",askEverfur:"Ask Everfur",askExam:"Ask Everfur about this exam",askVisit:"Ask Everfur about this visit",labResults:be.labResults,visits:be.visits,physicalExams:be.physicalExams,visitNotes:be.visitNotes,document:Object.freeze({title:"Health Record",download:"Download record PDF",empty:"This record is empty for now.",docTitle:"Medical Record",namelessPet:"Your pet",generated:i(e=>`Generated ${J(e)}`,"generated"),identity:"Identity",labs:"Blood & Lab Work",ref:i(e=>`Ref ${e}`,"ref"),noRange:"No reference range",upcomingCare:"Upcoming Care",physicalExams:"Physical Exams",clinicianNotes:"Clinician Notes"})}),ld=Object.freeze({vaccination:"Vaccinations",medication:"Medications",problem:"Problems & diagnoses",procedure:"Procedures & surgery",allergy:"Allergies",parasite_prevention:"Parasite prevention",reproductive:"Reproductive history",vital:"Vitals",body_weight:"Weight",lab_result:"Lab results",imaging:"Imaging & radiology",genetic_result:"Genetic testing",document_note:"Other notes"});function jr(e){return Object.prototype.hasOwnProperty.call(ld,e)?ld[e]:ur(e)}i(jr,"entityTypeLabel");var cd=Object.freeze(["vaccination","medication","problem","procedure","allergy","parasite_prevention","reproductive","vital","body_weight"]);function dd(e){let t=cd.filter(o=>e.includes(o)),r=e.filter(o=>!cd.includes(o));return [...t,...r]}i(dd,"orderEntityTypes");function Do(e){switch(e){case "identity_risk":return {label:"Identity mismatch",rank:0,tone:"critical"};case "benign":return {label:"Minor difference",rank:2,tone:"neutral"};default:return {label:"Needs review",rank:1,tone:"warning"}}}i(Do,"conflictSeverityMeta");function On(e,t){if(!e)return null;let r=Date.parse(e);if(Number.isNaN(r))return null;let o=r<t-1440*60*1e3;return {label:o?Z.overdue:Z.due(J(e)),overdue:o}}i(On,"dueBadge");function ud(e){return e===null?null:e.refLow!==null&&e.refHigh!==null?`${e.refLow}-${e.refHigh}`:e.refLow!==null?`\u2265 ${e.refLow}`:e.refHigh!==null?`\u2264 ${e.refHigh}`:null}i(ud,"formatReferenceBand");var ct=Object.freeze({editA11y:i(e=>`Edit ${e}. Correct or remove this record detail.`,"editA11y"),title:i(e=>`Edit ${e}`,"title"),helper:"Corrects your record. Your vet can still review it.",close:"Close",closeEditorA11y:"Close editor",save:"Save changes",saving:"Saving...",remove:"Remove this detail",removeA11y:i(e=>`Remove ${e}`,"removeA11y"),confirmRemove:"Remove this detail from your record? This can't be undone.",removeConfirm:"Remove",removing:"Removing...",keep:"Keep",noChange:"Change a value before saving.",saved:"Saved.",removed:"Removed.",detail:"record detail"});function pd(e,t){return ar(e)?t==="remove"?"Records access for this pet is off, so this detail cannot be removed.":"Records access for this pet is off, so this detail cannot be changed.":Rc(e)?t==="remove"?"A clinician already reviewed this detail, so it can't be removed here.":"A clinician already reviewed this detail, so it can't be changed here.":t==="remove"?"Couldn't remove that. Please check your connection and try again.":"Couldn't save that. Please check your connection and try again."}i(pd,"factEditErrorMessage");var $f=Object.freeze({edits:Object.freeze({}),removed:Object.freeze([])});function Es(e,t){if(Object.keys(t.edits).length===0&&t.removed.length===0)return e;let r=[];for(let o of e){let n=o.canonicalKey??null;if(n!==null&&t.removed.includes(n))continue;let a=n!==null?t.edits[n]:void 0;r.push(a===void 0?o:Object.freeze({...o,value:a}));}return Object.freeze(r)}i(Es,"applyFactOverlay");function Oo(e){return typeof e.canonicalKey=="string"&&e.canonicalKey.length>0}i(Oo,"isFactEditable");function Wf(){return `records-fact-${Date.now().toString(36)}`}i(Wf,"defaultFactKey");function Ss(e,t={}){let r=yr(),{userRef:o}=Te(),[n,a]=useState($f),[l,c]=useState(false),[s,d]=useState(null),u=useMemo(()=>({}),[r,e,o]),[p,f]=useState(null),b=useCallback(()=>f(u),[u]),R=o!==null&&p!==u,v=useRef(false),w=useRef(t.newIdempotencyKey);w.current=t.newIdempotencyKey;let g=useCallback(()=>(w.current??Wf)(),[]),y=useCallback((S,E,C)=>{if(c(false),!S.ok){if(E(),_r(S.error)){b();return}d(pd(S.error,C));}},[b]),x=useCallback(async(S,E)=>{let C=S.canonicalKey??"",I=E.trim();if(v.current||C.length===0||I.length===0)return W(N("validationFailed",{retryable:false}));v.current=true,c(true),d(null);let F=n;a(j=>({...j,edits:{...j.edits,[C]:I}}));let q=await r.editFact(e,{entityType:S.category,canonicalKey:C,correctedFields:cs(S.value,I),idempotencyKey:g()});return v.current=false,y(q,()=>a(F),"edit"),q},[r,e,n,y,g]),h=useCallback(async S=>{let E=S.canonicalKey??"";if(v.current||E.length===0)return W(N("validationFailed",{retryable:false}));v.current=true,c(true),d(null);let C=n;a(F=>({...F,removed:[...F.removed,E]}));let I=await r.removeFact(e,{entityType:S.category,canonicalKey:E,idempotencyKey:g()});return v.current=false,y(I,()=>a(C),"remove"),I},[r,e,n,y,g]),P=useCallback(()=>d(null),[]);return useMemo(()=>({overlay:n,busy:l,error:s,available:R,edit:x,remove:h,clearError:P}),[n,l,s,R,x,h,P])}i(Ss,"useRecordFactEdit");var ks=Object.freeze(["vaccination","parasite_prevention"]),Lo="Undated",Gf=Object.freeze({given:"Given",prevention:"Prevention",overdue:"Overdue",noDate:"No date"}),fd=Object.freeze({given:"positive",prevention:"neutral",overdue:"critical",noDate:"neutral"});function Vo(e){if(!e)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}i(Vo,"toMillis");function Yf(e){let t=e.status?.toLowerCase()??"";return /overdue|lapsed|expired/.test(t)}i(Yf,"isLapsed");function Kf(e){return e.category==="parasite_prevention"?"prevention":Vo(e.observedAt)===null?"noDate":Yf(e)?"overdue":"given"}i(Kf,"vaccineTone");function Qf(e){let t=Vo(e);return t===null?Lo:String(new Date(t).getUTCFullYear())}i(Qf,"yearOf");function Xf(e){let t=Kf(e),r=[e.value!==null&&e.value.length>0?e.value:null,e.observedAt!==null?J(e.observedAt):null].filter(o=>o!==null&&o.length>0);return {key:e.key,name:e.label,detail:r.length>0?r.join(" \xB7 "):null,statusLabel:Gf[t],tone:t,entity:e}}i(Xf,"buildRow");function gd(e){let t=new Map;for(let o of e){if(!ks.includes(o.category))continue;let n=Qf(o.observedAt),a=t.get(n),l={row:Xf(o),at:o.observedAt};a===void 0?t.set(n,[l]):a.push(l);}let r=[...t.keys()].sort((o,n)=>o===Lo?1:n===Lo?-1:Number(n)-Number(o));return Object.freeze(r.map(o=>{let n=t.get(o)??[],a=o===Lo?n:[...n].sort((l,c)=>(Vo(c.at)??0)-(Vo(l.at)??0));return Object.freeze({year:o,items:Object.freeze(a.map(l=>l.row))})}))}i(gd,"selectVaccineGroups");var qo=Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});function Ts({entity:e,factEdit:t,children:r}){let o=bd(),[n,a]=useState(false),l=e.label.trim()||ct.detail;return jsxs(View,{style:o.row,children:[jsx(View,{style:o.main,children:r}),jsx(Pressable,{onPress:()=>a(true),accessibilityRole:"button",accessibilityLabel:ct.editA11y(l),hitSlop:6,style:o.editButton,testID:`fact-edit-open-${e.canonicalKey??e.key}`,children:jsx(View,{style:o.pencil,accessibilityElementsHidden:true,importantForAccessibility:"no"})}),n?jsx(ng,{entity:e,title:l,factEdit:t,onClose:()=>a(false)}):null]})}i(Ts,"FactEditAffordance");function ng({entity:e,title:t,factEdit:r,onClose:o}){let n=bd(),a=me(),l=V(),[c,s]=useState(e.value??""),[d,u]=useState(null),[p,f]=useState(false);useEffect(()=>{r.clearError();},[r]);let b=c.trim().length>0&&c.trim()!==(e.value??"").trim(),R=d??r.error,v=r.busy,w=i(()=>{if(!b){u(ct.noChange);return}u(null),r.edit(e,c).then(y=>{y.ok&&o();});},"submitEdit"),g=i(()=>{u(null),r.remove(e).then(y=>{y.ok?o():f(false);});},"submitRemove");return jsx(Modal,{transparent:true,visible:true,animationType:"slide",onRequestClose:o,children:jsxs(KeyboardAvoidingView,{behavior:"padding",style:n.backdrop,children:[jsx(Pressable,{style:qo,accessibilityRole:"button",accessibilityLabel:ct.closeEditorA11y,onPress:o}),jsxs(View,{style:n.sheet,accessibilityViewIsModal:true,testID:"fact-edit-sheet",children:[jsx(View,{style:n.handle}),jsxs(View,{style:n.header,children:[jsxs(View,{style:n.headerText,children:[jsx(m,{style:n.title,accessibilityRole:"header",children:ct.title(t)}),jsx(m,{style:[n.helper,R?n.helperError:null],accessibilityLiveRegion:"polite",children:R??ct.helper})]}),jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:ct.close,onPress:o,hitSlop:12,style:n.closeButton,testID:"fact-edit-close",children:jsx(m,{style:n.closeGlyph,children:"\xD7"})})]}),jsx(m,{style:a.fieldLabel,children:e.label}),jsx(He,{accessibilityLabel:e.label,style:a.field,value:c,onChangeText:y=>{s(y),u(null);},editable:!v,maxLength:512,placeholderTextColor:l.color.text.placeholder,testID:"fact-edit-field"}),p?jsxs(View,{style:n.confirmBlock,testID:"fact-edit-confirm-remove",children:[jsx(m,{style:n.confirmText,children:ct.confirmRemove}),jsxs(View,{style:n.confirmRow,children:[jsx(X,{label:v?ct.removing:ct.removeConfirm,kind:"danger",busy:v,onPress:g,style:n.confirmButton,testID:"fact-edit-remove-confirm"}),jsx(X,{label:ct.keep,kind:"outline",disabled:v,onPress:()=>f(false),style:n.confirmButton,testID:"fact-edit-remove-cancel"})]})]}):jsxs(View,{style:n.actions,children:[jsx(X,{label:v?ct.saving:ct.save,busy:v,disabled:!b,onPress:w,testID:"fact-edit-save"}),jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:ct.removeA11y(t),disabled:v,onPress:()=>{u(null),f(true);},style:[n.removeButton,v?n.removeDisabled:null],testID:"fact-edit-remove",children:jsx(m,{style:n.removeText,children:ct.remove})})]})]})]})})}i(ng,"FactEditSheet");function bd(){let e=V();return useMemo(()=>og(e),[e])}i(bd,"useStyles");function og(e){let{color:t,space:r,radius:o,type:n}=e,a=r.xxl+r.md,l=e.brightness==="dark"?t.errorRed:t.danger,c=i((s,d,u,p="regular")=>({...k(e,p),fontSize:s,lineHeight:Math.round(s*d),color:u}),"text");return StyleSheet.create({row:{flexDirection:"row",alignItems:"center",gap:r.sm},main:{flex:1},editButton:{width:a,height:a,alignItems:"center",justifyContent:"center"},pencil:{width:r.md+r.xs/2,height:r.xs/2,backgroundColor:t.brandInk,borderRadius:o.pill,transform:[{rotate:"-45deg"}]},backdrop:{flex:1,justifyContent:"flex-end",backgroundColor:ao},sheet:{backgroundColor:t.surface,borderTopLeftRadius:o.xl-1,borderTopRightRadius:o.xl-1,paddingHorizontal:r.lg+r.xs+r.xs/2,paddingTop:r.md,paddingBottom:o.xl,maxHeight:"88%",gap:r.md},handle:{alignSelf:"center",width:r.xxl+r.xs,height:r.xs,borderRadius:o.pill,backgroundColor:t.borderRingCream},header:{flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between",gap:r.sm},headerText:{flex:1,gap:r.xs},title:{...c(n.size.heading,n.lineHeight.snug,t.text.primary,"bold")},helper:c(n.size.bodyTight,n.lineHeight.normal,t.text.muted),helperError:{color:l},closeButton:{width:a,height:a,alignItems:"center",justifyContent:"center"},closeGlyph:c(n.size.verdict,n.lineHeight.tight,t.text.primary),actions:{gap:r.sm},removeButton:{minHeight:a,alignItems:"center",justifyContent:"center"},removeDisabled:{opacity:.5},removeText:{...c(n.size.bodyTight,n.lineHeight.snug,t.danger,"bold")},confirmBlock:{gap:r.sm,padding:r.md,borderRadius:o.md,backgroundColor:t.badgeBgCritical},confirmText:c(n.size.bodyTight,n.lineHeight.normal,t.text.primary),confirmRow:{flexDirection:"row",gap:r.sm},confirmButton:{flex:1}})}i(og,"makeStyles");function Mo({record:e,depth:t,petName:r,showLabs:o=true,onNavigate:n,onAsk:a,factEdit:l,nowMs:c}){let s=me(),d=ig(),u=c??Date.now(),p=useMemo(()=>l?Es(e.entities,l.overlay):e.entities,[e.entities,l]),f=useMemo(()=>{let g=[],y=new Map;for(let x of p){let h=x.category.trim();if(h.length===0||ks.includes(h))continue;let P=y.get(h);P===void 0?(g.push(h),y.set(h,[x])):P.push(x);}return {order:dd(g),groups:y}},[p]),b=useMemo(()=>gd(p),[p]),R=Object.values(e.documents),v=i((g,y,x)=>a?jsx(Pressable,{onPress:()=>{let h=g();a(h.prompt,h.entityRef);},accessibilityRole:"button",accessibilityLabel:y,style:[s.pill,s.pillAsk,d.ask],testID:x,children:jsx(m,{style:s.pillAskLabel,children:y})}):null,"ask"),w=l!==void 0&&l.available;return jsxs(Fragment,{children:[jsxs(View,{style:d.sections,children:[t&&t.conflicts.length>0?jsxs(View,{style:s.section,testID:"record-section-conflicts",children:[jsx(At,{title:Z.needsAttention,count:t.conflicts.length}),[...t.conflicts].sort((g,y)=>Do(g.severity).rank-Do(y.severity).rank).map(g=>{let y=Do(g.severity),x=ur(g.field??g.entityType);return jsxs(View,{style:[d.conflictCard,{borderColor:s.chipTones[y.tone].fg.color}],accessibilityRole:"summary",children:[jsxs(View,{style:d.conflictHead,children:[jsx(m,{style:d.conflictTitle,children:y.label}),jsx(kt,{label:x,tone:y.tone})]}),jsx(m,{style:s.rowDetail,children:Z.conflictSub}),g.candidates.map((h,P)=>jsxs(View,{style:d.candidate,children:[jsx(m,{style:s.rowTitle,children:h.value}),jsx(m,{style:s.rowMuted,children:[h.docId?e.documents[h.docId]?.title??Z.uploadedDocument:Z.uploadedDocument,h.collectedAt?J(h.collectedAt):null].filter(Boolean).join(" \xB7 ")})]},P)),v(()=>Gc(r,{scopeLabel:x,severity:g.severity,candidates:g.candidates.map(h=>({value:h.value,clinicName:h.docId?e.documents[h.docId]?.title??null:null}))},g.conflictId),Z.askConflict,`records-ask-conflict-${g.conflictId}`)]},g.conflictId)})]}):null,t?.completeness?jsxs(View,{style:s.section,testID:"record-section-completeness",children:[jsx(At,{title:Z.whatsOnFile}),jsxs(View,{style:s.card,children:[jsx(View,{style:d.coverageRow,children:[[Z.coverage.labs,t.completeness.hasLabHistory],[Z.coverage.vaccines,t.completeness.hasVaccinationHistory],[Z.coverage.weight,t.completeness.hasWeightHistory],[Z.coverage.vitals,t.completeness.hasVitalsHistory],[Z.coverage.exams,t.completeness.hasPhysicalExamHistory],[Z.coverage.procedures,t.completeness.hasProcedureHistory],[Z.coverage.genetics,t.completeness.hasGeneticHistory],[Z.coverage.parasite,t.completeness.hasParasitePreventionHistory],[Z.coverage.reproductive,t.completeness.hasReproductiveHistory]].map(([g,y])=>jsx(View,{style:[d.coveragePill,y?s.chipTones.positive.bg:s.chipTones.neutral.bg],accessible:true,accessibilityRole:"text",accessibilityLabel:`${g}: ${y?Z.onFile:Z.noneOnFile}`,children:jsx(m,{style:[d.coverageText,y?s.chipTones.positive.fg:{color:s.rowMuted.color}],children:g})},g))}),jsxs(View,{style:d.metaRow,children:[jsx(m,{style:d.metaText,children:Z.documentsOnFile(t.completeness.documentsIngested)}),t.completeness.documentsInReview>0?jsx(kt,{label:Z.inReviewChip(t.completeness.documentsInReview),tone:"warning"}):null,_s(t.completeness.heldTotal,t.completeness.entitiesPendingReview)>0?jsx(View,{accessible:true,accessibilityRole:"text",accessibilityLabel:Z.beingVerifiedA11y(_s(t.completeness.heldTotal,t.completeness.entitiesPendingReview)),children:jsx(kt,{label:Z.beingVerified(_s(t.completeness.heldTotal,t.completeness.entitiesPendingReview)),tone:"warning"})}):null]}),t.completeness.earliestRecordAt||t.completeness.latestRecordAt?jsx(View,{style:d.metaRow,children:jsx(m,{style:d.metaText,children:Z.dateRange(t.completeness.earliestRecordAt,t.completeness.latestRecordAt)})}):null,Object.entries(t.completeness.entitiesPendingReview).filter(([,g])=>g>0).length>0?jsxs(m,{style:d.pendingText,children:[Z.pendingReview,Object.entries(t.completeness.entitiesPendingReview).filter(([,g])=>g>0).map(([g,y])=>`${jr(g)} (${y})`).join(", ")]}):null]})]}):null,R.length>0?jsxs(View,{style:s.section,testID:"record-section-documents",children:[jsx(At,{title:Z.documents,count:R.length}),jsx(View,{style:s.card,children:R.map((g,y)=>{let x=g.title?.trim()||Z.uploadedDocument,h=g.receivedAt?J(g.receivedAt):null,P=jsxs(Fragment,{children:[jsxs(View,{style:s.rowMain,children:[jsx(m,{style:s.rowTitle,children:x}),h?jsx(m,{style:s.rowDetail,children:h}):null]}),n?jsx(rr,{}):null]});return n?jsx(Pressable,{onPress:()=>n({name:"contributions",docId:g.docId}),accessibilityRole:"button",accessibilityLabel:Z.documentRowA11y(x),style:[s.row,y>0?s.rowDivider:null],testID:`records-document-row-${g.docId}`,children:P},g.docId):jsx(View,{style:[s.row,y>0?s.rowDivider:null],children:P},g.docId)})})]}):null,e.identity.length>0?jsxs(View,{style:s.section,testID:"record-section-identity",children:[jsx(At,{title:Z.identity}),jsx(View,{style:s.card,children:e.identity.map((g,y)=>jsxs(View,{style:[s.row,y>0?s.rowDivider:null],children:[jsx(m,{style:d.identityLabel,children:g.label}),jsx(m,{style:d.identityValue,children:g.value})]},`${y}:${g.label}`))})]}):null,e.forwardLooking.length>0?jsxs(View,{style:s.section,testID:"record-section-upcoming",children:[jsx(At,{title:Z.upcomingCare,count:e.forwardLooking.length}),jsx(View,{style:s.card,children:e.forwardLooking.map((g,y)=>{let x=On(g.dueAt,u);return jsxs(View,{style:[s.row,y>0?s.rowDivider:null],children:[jsxs(View,{style:s.rowMain,children:[jsx(m,{style:s.rowTitle,children:g.title}),g.detail?jsx(m,{style:s.rowDetail,children:g.detail}):null]}),x?jsx(kt,{label:x.label,tone:x.overdue?"critical":"info"}):null]},`${g.title}-${y}`)})}),v(()=>jc(r,e.forwardLooking.map(g=>{let y=On(g.dueAt,u);return {label:g.title,relativeText:y?.label??"",tone:y?.overdue?"overdue":"upcoming"}}),e.petRef),Z.askUpcomingCare,"records-ask-upcoming-care")]}):null,b.length>0?jsxs(View,{style:s.section,testID:"record-section-vaccination",children:[jsx(At,{title:jr("vaccination"),count:b.reduce((g,y)=>g+y.items.length,0)}),b.map(g=>jsxs(View,{style:d.vaccineGroup,testID:`records-vaccine-group-${g.year}`,children:[jsx(m,{style:d.vaccineYear,accessibilityRole:"header",children:g.year.toUpperCase()}),jsx(View,{style:s.card,children:g.items.map((y,x)=>{let h=jsxs(View,{style:[s.row,x>0?s.rowDivider:null],children:[jsxs(View,{style:s.rowMain,children:[jsx(m,{style:s.rowTitle,children:y.name}),y.detail?jsx(m,{style:s.rowDetail,children:y.detail}):null,v(()=>hs(r,{entityTypeLabel:jr(y.entity.category),title:y.name,detail:y.detail},y.entity.category,y.key),Z.askEverfur,`records-ask-entity-${y.key}`)]}),jsx(kt,{label:y.statusLabel,tone:fd[y.tone]})]});return w&&Oo(y.entity)&&l?jsx(Ts,{entity:y.entity,factEdit:l,children:h},y.key):jsx(View,{children:h},y.key)})})]},g.year))]}):null,f.order.map(g=>{let y=f.groups.get(g)??[];if(y.length===0)return null;let x=jr(g);return jsxs(View,{style:s.section,testID:`record-section-${g}`,children:[jsx(At,{title:x,count:y.length}),jsx(View,{style:s.card,children:y.map((h,P)=>{let E=[Yr(h.value,h.unit),h.observedAt?J(h.observedAt):null].filter(I=>I&&I.length>0).join(" \xB7 "),C=jsxs(View,{style:[s.row,P>0?s.rowDivider:null],children:[jsxs(View,{style:s.rowMain,children:[jsx(m,{style:s.rowTitle,children:h.label}),E?jsx(m,{style:s.rowDetail,children:E}):null,v(()=>hs(r,{entityTypeLabel:x,title:h.label,detail:E||null},g,h.key),Z.askEverfur,`records-ask-entity-${h.key}`)]}),h.status?jsx(kt,{label:ur(h.status)}):null]});return w&&Oo(h)&&l?jsx(Ts,{entity:h,factEdit:l,children:C},h.key):jsx(View,{children:C},h.key)})})]},g)}),t&&t.physicalExams.length>0?jsxs(View,{style:s.section,testID:"record-section-exams",children:[jsx(At,{title:Z.physicalExams,count:t.physicalExams.length}),t.physicalExams.map(g=>jsxs(View,{style:s.card,children:[jsx(m,{style:[s.rowTitle,d.cardTitle],accessibilityRole:"header",children:g.observedOn?J(g.observedOn):be.exam}),g.systems.map((y,x)=>{let h=y.findingStatus==="abnormal",P=h?be.abnormal:y.findingStatus==="not_examined"?be.notExamined:be.normal;return jsxs(View,{style:[s.row,x>0?s.rowDivider:null],accessible:true,accessibilityRole:"text",accessibilityLabel:[qr(y.system),P,h?y.finding:null].filter(Boolean).join(", "),children:[jsxs(View,{style:s.rowMain,children:[jsx(m,{style:s.rowTitle,children:qr(y.system)}),h&&y.finding?jsx(m,{style:s.rowDetail,children:y.finding}):null]}),jsx(kt,{label:P,tone:h?"warning":y.findingStatus==="not_examined"?"neutral":"positive"})]},y.system)}),v(()=>$c(r,{observedOn:g.observedOn?J(g.observedOn):null,abnormal:g.systems.filter(y=>y.findingStatus==="abnormal").map(y=>({system:qr(y.system),finding:y.finding??""}))},g.examId),Z.askExam,`records-ask-exam-${g.examId}`)]},g.examId))]}):null,t&&t.clinicianNotes.length>0?jsxs(View,{style:s.section,testID:"record-section-notes",children:[jsx(At,{title:Z.visitNotes,count:t.clinicianNotes.length}),t.clinicianNotes.map(g=>jsxs(View,{style:s.card,children:[jsx(m,{style:[s.rowTitle,d.cardTitle],accessibilityRole:"header",children:g.observedOn?J(g.observedOn):be.visitNote}),g.sections.map((y,x)=>jsxs(View,{style:[d.noteSection,x>0?s.rowDivider:null],children:[jsx(m,{style:d.noteLabel,children:Qr(y.section)}),jsx(m,{style:y.text?d.noteBody:d.noteBodyMuted,children:y.text||be.notRecorded})]},`${y.section}:${x}`)),v(()=>Wc(r,{observedOn:g.observedOn?J(g.observedOn):null,sections:g.sections.map(y=>({label:Qr(y.section),text:y.text}))},g.noteId),Z.askVisit,`records-ask-note-${g.noteId}`)]},g.noteId))]}):null,o&&t&&t.labResults.length>0?jsxs(View,{style:s.section,testID:"record-section-labs",children:[jsx(At,{title:Z.labResults,count:t.labResults.length}),jsx(View,{style:s.card,children:t.labResults.map((g,y)=>{let x=nr(g.latest.status),h=Hi(g.latest.at,g.trajectory,g.points.length);return jsxs(View,{style:[s.row,y>0?s.rowDivider:null],children:[jsxs(View,{style:s.rowMain,children:[jsx(m,{style:s.rowTitle,children:g.name}),jsx(m,{style:s.rowValue,children:Tt(g.latest.value,g.latest.unit,g.latest.qualitativeResult)}),h?jsx(m,{style:s.rowDetail,children:h}):null]}),jsx(kt,{label:x.label,tone:Co(g.latest.status)})]},g.markerId)})})]}):null,t&&t.encounters.length>0?jsxs(View,{style:s.section,testID:"record-section-visits",children:[jsx(At,{title:Z.visits,count:t.encounters.length}),jsx(View,{style:s.card,children:t.encounters.map((g,y)=>{let x=[g.date?J(g.date):null,g.clinicName,g.veterinarian].filter(h=>h&&h!=="-").join(" \xB7 ");return jsx(View,{style:[s.row,y>0?s.rowDivider:null],children:jsxs(View,{style:s.rowMain,children:[jsx(m,{style:s.rowTitle,children:g.type?ur(g.type):be.visit}),x?jsx(m,{style:s.rowDetail,children:x}):null]})},g.encounterId)})})]}):null]}),jsx(Tr,{disclaimer:e.disclaimer})]})}i(Mo,"RecordSections");function _s(e,t){return e>0?e:Object.values(t).reduce((r,o)=>r+o,0)}i(_s,"heldCount");function ig(){let e=V();return useMemo(()=>sg(e),[e])}i(ig,"useLocalStyles");function sg(e){let{color:t,space:r,radius:o,type:n}=e,a=StyleSheet.hairlineWidth;return StyleSheet.create({sections:{gap:r.lg+r.xs},vaccineGroup:{gap:r.xs+1,marginBottom:r.sm},vaccineYear:{...k(e,"monoMedium"),fontSize:n.size.micro,lineHeight:n.size.micro+r.xs,color:t.text.muted,letterSpacing:n.letterSpacing.eyebrow,textTransform:"uppercase",paddingTop:r.xs+2},ask:{marginTop:r.lg},conflictCard:{borderRadius:o.md,borderWidth:1,backgroundColor:t.surface,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md,gap:r.sm},conflictHead:{flexDirection:"row",alignItems:"center",gap:r.sm},conflictTitle:{flex:1,...k(e,"bold"),fontSize:n.size.body,lineHeight:Math.round(n.size.body*n.lineHeight.snug),color:t.text.primary},candidate:{borderTopWidth:a,borderTopColor:t.borderHairlineGreen,paddingTop:r.sm},coverageRow:{flexDirection:"row",flexWrap:"wrap",gap:r.sm,paddingVertical:r.md},coveragePill:{borderRadius:o.pill,paddingHorizontal:r.sm+r.xs/2,paddingVertical:r.xs+1},coverageText:{...k(e,"medium"),fontSize:n.size.caption,lineHeight:n.size.caption+r.xs-1},metaRow:{flexDirection:"row",alignItems:"center",gap:r.sm,paddingBottom:r.md},metaText:{flex:1,...k(e,"regular"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*n.lineHeight.snug),color:t.text.secondary},pendingText:{...k(e,"regular"),fontSize:n.size.caption,lineHeight:Math.round(n.size.caption*n.lineHeight.normal),color:t.text.muted,paddingBottom:r.md},identityLabel:{...k(e,"medium"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*n.lineHeight.snug),color:t.text.secondary},identityValue:{flexShrink:1,textAlign:"right",...k(e,"medium"),fontSize:n.size.body,lineHeight:Math.round(n.size.body*n.lineHeight.snug),color:t.text.primary},cardTitle:{paddingTop:r.sm},noteSection:{paddingVertical:r.md,gap:r.xs},noteLabel:{...k(e,"bold"),fontSize:n.size.bodyTight,color:t.text.secondary,textTransform:"uppercase",letterSpacing:n.letterSpacing.eyebrow/2},noteBody:{...k(e,"regular"),fontSize:n.size.body+1,lineHeight:Math.round((n.size.body+1)*n.lineHeight.relaxed),color:t.text.primary},noteBodyMuted:{...k(e,"regular"),fontSize:n.size.body+1,lineHeight:Math.round((n.size.body+1)*n.lineHeight.relaxed),color:t.text.muted,fontStyle:"italic"}})}i(sg,"makeLocalStyles");var Ln=Object.freeze({heading:"A quick call can help",fallbackPrompt:"Reaching out to the clinic directly often speeds up a slow records request.",call:"Call the clinic",callAt:i(e=>`Call the clinic at ${e}`,"callAt")});var ag=Math.round(Rr/(1024*1024)),Ze=Object.freeze({title:i(e=>`Upload ${Ne(e)}\u2019s records`,"title"),subtitle:i(e=>`Already have lab results, a vet summary, or test reports? Add them here and we\u2019ll read them and pull out ${Ne(e)}\u2019s health markers.`,"subtitle"),noPet:"Select a pet first, then upload their records.",cardTitle:"Add records",cardSubtitle:`Upload PDF records you already have, up to ${ag} MB each. You can pick several at once. We\u2019ll read them and add the results to your records.`,chooseFiles:"Choose files",chooseFilesA11y:"Choose records to upload",uploading:i((e,t)=>`Uploading ${Math.min(e+1,t)} of ${t}\u2026`,"uploading"),cancel:"Cancel",cancelA11y:"Cancel these uploads",received:i(e=>`${e===1?"Record received.":`${e} records received.`} We\u2019ll read and review ${e===1?"it":"them"}, then add the results to your records, usually within 1-2 business days.`,"received"),retryFailed:i(e=>`Retry ${e} that didn\u2019t upload`,"retryFailed"),retryFailedA11y:i(e=>`Retry ${e} failed upload${e>1?"s":""}`,"retryFailedA11y"),addMore:"Add more files",addMoreA11y:"Add more records",done:"Done",doneA11y:"Done, view records",errors:Object.freeze({start:"We couldn\u2019t start that upload. Check your connection and try again.",startPlain:"We couldn\u2019t start that upload. Please try again.",upload:"We couldn\u2019t upload that record. Check your connection and try again."})});var wd=Math.round(Rr/(1024*1024)),$r=Object.freeze({queued:"Queued",verifying:"Verifying\u2026",done:"Done",failed:"Failed",uploading:i((e,t)=>`Uploading ${Math.min(e+1,t)} of ${t} records`,"uploading"),uploaded:i((e,t)=>`${e} of ${t} records uploaded`,"uploaded")});function xd(e){let t=Math.round(e.progress*100);switch(e.status){case "done":return $r.done;case "failed":return $r.failed;case "uploading":return e.progress>=1?$r.verifying:`${t}%`;case "queued":return $r.queued;default:return null}}i(xd,"uploadItemStatusLabel");function Bo(e){if(e.length===0)return null;let t=i(a=>{let l=a.map(c=>c.name??"");return l.length<=3?l.join(", "):`${l.slice(0,3).join(", ")} and ${l.length-3} more`},"nameList"),r=e.filter(a=>a.reason==="too_large"),o=e.filter(a=>a.reason==="unsupported"),n=[];return o.length>0&&n.push(`${t(o)} ${o.length>1?"are not PDFs":"is not a PDF"}`),r.length>0&&n.push(`${t(r)} ${r.length>1?"are":"is"} over ${wd} MB`),`Didn\u2019t upload: ${n.join("; ")}. We can only read PDFs up to ${wd} MB right now.`}i(Bo,"skippedFilesMessage");function Cd(e){let t=[];for(let r of e)r.status==="skipped"&&r.skipReason!==null&&t.push({name:r.name,reason:r.skipReason});return t}i(Cd,"skippedOf");var zt=Object.freeze({email:"Clinic email",emailPlaceholder:"records@clinic.com",emailError:"Enter a valid clinic email.",updateEmail:"Update email & resend",updateEmailA11y:"Update clinic email and resend request",retry:"Retry sending",retryA11y:"Retry sending records request",retryHint:"Save the updated email first, then retry.",cancelRequest:"Cancel request",keepRequest:"Keep request",uploadInstead:"Upload instead",cancelQuestion:"Cancel this request?",cancelConsequence:"We\u2019ll stop sending reminders to the clinic. If the clinic has already sent records, they may still arrive. You can start a new request or upload your own records anytime."});function Ed({request:e,onRecovered:t,canUpload:r=false},o){let[n,a]=useState(""),[l,c]=useState(false),[s,d]=useState(null),[u,p]=useState(false),[f,b]=useState(null),R=useRef(false),v=useRef(false),w=useRef(0);useEffect(()=>(v.current=true,()=>{v.current=false,w.current+=1;}),[o]);let g=f!==null&&f.before===e.updatedAt?{...f.value,canRetrySend:e.canRetrySend===true&&f.value.canRetrySend===true,canUpdateClinicEmail:e.canUpdateClinicEmail===true&&f.value.canUpdateClinicEmail===true,canRevoke:e.canRevoke===true&&f.value.canRevoke===true,canConvertToUpload:e.canConvertToUpload===true&&f.value.canConvertToUpload===true}:e,y=n.trim(),x=y.length<=320&&!Array.from(y).some(I=>I.charCodeAt(0)<=32||I.charCodeAt(0)===127)&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(y),h=g.canUpdateClinicEmail===true&&y.length>0,P=g.canRetrySend===true&&!l&&!h,S=g.canUpdateClinicEmail===true&&!l&&x,E=g.canConvertToUpload===true&&r,C=i(async I=>{let F={retry:P,email:S,revoke:g.canRevoke===true&&u,convert:E};if(R.current||!v.current||!F[I])return;R.current=true,c(true),d(null);let q=w.current,j=i(()=>v.current&&q===w.current,"live");try{let $=I==="retry"?await o.retryRequest(e.id):I==="email"?await o.updateClinicEmail(e.id,y):I==="revoke"?await o.revokeRequest(e.id):await o.convertToUpload(e.id);if(!j())return;if(!$.ok){d($.error);return}if($.value.id!==e.id||$.value.petRef!==e.petRef){d(N("internalError"));return}b({before:e.updatedAt,value:$.value}),a(""),p(!1),t();}catch{j()&&d(N("internalError"));}finally{R.current=false,j()&&c(false);}},"run");return {request:g,email:n,busy:l,error:s,canRetry:P,canUpdateEmail:S,canConvert:E,hasEmailEdit:h,confirmingRevoke:u&&g.canRevoke===true,emailInvalid:y.length>0&&!x,setEmail(I){R.current||(a(I),d(null));},retry:i(()=>C("retry"),"retry"),updateEmail:i(()=>C("email"),"updateEmail"),revoke:i(()=>C("revoke"),"revoke"),convert:i(()=>C("convert"),"convert"),askRevoke(){!R.current&&g.canRevoke===true&&p(true);},keepRequest(){R.current||p(false);}}}i(Ed,"useRecordsRecovery");var cg=["requested","sent_to_clinic","awaiting_clinic","records_received","processing","ready"],dg=["requested","awaiting_upload","records_received","processing","ready"],ug=["requested","sent_to_clinic","awaiting_clinic","awaiting_upload","records_received","processing","ready"],qn=Object.freeze({requested:"Request created",sent_to_clinic:"Sent to the clinic",awaiting_clinic:"Waiting on the clinic",awaiting_upload:"Add your records",records_received:"Records received",processing:"Preparing your records",parsing_failed:"Needs a closer look",manual_review:"Our team is reviewing it",ready:"Ready to view",delivery_failed:"Email could not be delivered",processing_failed:"Could not process the records",clinic_declined:"Clinic declined the request",clinic_no_records:"Clinic replied without your records",no_response:"No response from the clinic",revoked:"You cancelled this request"}),Pt=Object.freeze({delivered:"Email delivered to the clinic",emailing:"Emailing the clinic",bounced:"The clinic email did not go through",waiting:"Waiting for the clinic to send the records",upload:"Upload the records you already have",ownerAdded:"You added these records",clinicSent:"The clinic sent the records",preparing:"Getting your records ready to view",ready:"Your records are ready to view",parsingFailed:"We couldn\u2019t read this one automatically",manualReview:"Checking these by hand so nothing\u2019s missed",switchedTitle:"Stopped waiting on the clinic",switched:"You switched to uploading your own records"}),pg=Object.freeze({delivery_failed:"The clinic email could not be delivered",processing_failed:"We could not read these records",clinic_declined:"The clinic declined to release records",clinic_no_records:"The clinic replied without records",no_response:"No reply after repeated reminders",revoked:"You cancelled this request"}),mg=Object.freeze({requested:"sent",awaiting_clinic:"awaiting_response",awaiting_upload:"awaiting_upload",received:"records_received",parsing:"parsing",in_review:"in_review",published:"published",failed:"failed",revoked:"revoked"});function yg(e){return e.wireStatus??mg[e.status]??"sent"}i(yg,"wireStatusOf");function fg(e,t){return e!=="awaiting_response"||t<=0?null:`${t} ${t===1?"reminder":"reminders"} sent`}i(fg,"reminderProgressLabel");function gg(e){switch(e){case "submitted":case "sent":return 1;case "awaiting_response":return 2;case "records_received":return 3;case "parsing":case "parsing_failed":case "in_review":case "review_email_failed":return 4;case "published":return 5;default:return -1}}i(gg,"reachedRailIndex");function bg(e){switch(e.dispatchStatus){case "sent":return Pt.delivered;case "preparing":case "queued":case "sending":return Pt.emailing;case "failed":return Pt.bounced;default:return null}}i(bg,"deliveryDetail");function hg(e,t){return fg(t,e.reminderCount??0)??Pt.waiting}i(hg,"awaitingDetail");function Rg(e){return e.source==="owner_provided"||!!e.convertedToUploadAt}i(Rg,"isOwnerSourcedRequest");function vg(e,t,r){let o=Rg(t);switch(e){case "sent_to_clinic":return bg(t);case "awaiting_clinic":return hg(t,r);case "awaiting_upload":return Pt.upload;case "records_received":return o?Pt.ownerAdded:Pt.clinicSent;case "processing":return Pt.preparing;case "ready":return Pt.ready;default:return null}}i(vg,"railDetail");function wg(e,t){return !!e.reviewStartedAt||t==="parsing_failed"||t==="review_email_failed"}i(wg,"tookReviewBranch");function xg(e,t,r){if(e.key!=="processing"||!wg(t,r))return [e];let o=r==="parsing_failed",n=r==="published",a=n?"done":o?"current":"done",l=n?"done":o?"upcoming":"current";return [{key:"parsing_failed",title:qn.parsing_failed,detail:Pt.parsingFailed,at:null,state:a},{key:"manual_review",title:qn.manual_review,detail:Pt.manualReview,at:t.reviewStartedAt??null,state:l}]}i(xg,"expandProcessingPhase");function Cg(e){switch(e){case "awaiting_upload":return 3;case "records_received":return 4;case "parsing":case "parsing_failed":case "in_review":case "review_email_failed":return 5;case "published":return 6;default:return 3}}i(Cg,"convertedReachedIndex");function Sd(e){return {key:"awaiting_clinic",title:Pt.switchedTitle,detail:Pt.switched,at:e.convertedToUploadAt??null,state:"done"}}i(Sd,"convertedClinicSwitchEvent");function Eg(e){switch(e){case "submitted":case "sent":return 0;case "awaiting_upload":return 1;case "records_received":return 2;case "parsing":case "parsing_failed":case "in_review":case "review_email_failed":return 3;case "published":return 4;default:return -1}}i(Eg,"ownerReachedIndex");function Sg(e,t,r){switch(e){case "requested":return t.createdAt||null;case "awaiting_clinic":return t.lastReminderAt??null;case "processing":return t.parsingStartedAt??t.reviewStartedAt??null;case "ready":return r==="published"&&t.updatedAt||null;default:return null}}i(Sg,"railTimestamp");function kd(e,t,r,o){return {key:e,title:qn[e],detail:vg(e,t,r),at:Sg(e,t,r),state:o}}i(kd,"railEvent");function fr(e,t){return {key:e,title:qn[e],detail:pg[e]??null,at:t.updatedAt||null,state:"failed"}}i(fr,"terminalEvent");function Is(e,t,r,o,n){return e.map((a,l)=>{let c=n?.(a)??null;if(c!==null)return c;let s=o==="published"||l<t?"done":l===t?"current":"upcoming";return kd(a,r,o,s)}).flatMap(a=>xg(a,r,o))}i(Is,"walkRail");function Ds(e){let t=yg(e),r=i(n=>kd(n,e,t,"done"),"done");if(t==="revoked")return [r("requested"),fr("revoked",e)];if(e.convertedToUploadAt)return t==="failed"?[r("requested"),r("sent_to_clinic"),Sd(e),r("awaiting_upload"),r("records_received"),fr("processing_failed",e)]:Is(ug,Cg(t),e,t,n=>n==="awaiting_clinic"?Sd(e):null);if(e.source==="owner_provided"){if(t==="failed"||t==="clinic_declined")return [r("requested"),r("awaiting_upload"),r("records_received"),fr("processing_failed",e)];let n=Eg(t);return Is(dg,n<0?1:n,e,t)}if(t==="clinic_declined")return [r("requested"),r("sent_to_clinic"),r("awaiting_clinic"),fr("clinic_declined",e)];if(t==="clinic_responded_no_records")return [r("requested"),r("sent_to_clinic"),r("awaiting_clinic"),fr("clinic_no_records",e)];if(t==="failed"){let n=e.failureCode??null;return n==="no_response"?[r("requested"),r("sent_to_clinic"),r("awaiting_clinic"),fr("no_response",e)]:n==="hard_bounce"||n==="dispatch_failed"?[r("requested"),fr("delivery_failed",e)]:n==="parse_timeout"||n==="parse_error"||e.dispatchStatus==="sent"?[r("requested"),r("sent_to_clinic"),r("awaiting_clinic"),r("records_received"),fr("processing_failed",e)]:[r("requested"),fr("delivery_failed",e)]}let o=gg(t);return Is(cg,o<0?1:o,e,t)}i(Ds,"buildRequestTimeline");var _g=Object.freeze({done:"completed",current:"in progress",failed:"needs attention",upcoming:"not started"}),Ho=24,As=10;function jo({request:e}){let t=Dg(),r=Ds(e);return jsx(View,{style:t.container,accessibilityRole:"summary",children:r.map((o,n)=>jsx(Pg,{event:o,isLast:n===r.length-1,styles:t},o.key))})}i(jo,"RequestTimeline");function Pg({event:e,isLast:t,styles:r}){let o=e.at?J(e.at):null,n=[e.title,e.detail,o,_g[e.state]].filter(Boolean);return jsxs(View,{style:r.row,accessible:true,accessibilityRole:"text",accessibilityLabel:n.join(", "),testID:`records-timeline-${e.key}`,children:[jsxs(View,{style:r.railColumn,children:[jsx(Ig,{state:e.state,styles:r}),t?null:jsx(View,{style:[r.connector,e.state==="done"&&r.connectorDone],accessibilityElementsHidden:true,importantForAccessibility:"no"})]}),jsxs(View,{style:r.body,children:[jsxs(View,{style:r.titleRow,children:[jsx(m,{style:[r.title,e.state==="current"&&r.titleCurrent,e.state==="failed"&&r.titleFailed,e.state==="upcoming"&&r.titleUpcoming],children:e.title}),o?jsx(m,{style:r.date,children:o}):null]}),e.detail?jsx(m,{style:[r.detail,e.state==="upcoming"&&r.detailUpcoming],children:e.detail}):null]})]})}i(Pg,"TimelineRow");function Ig({state:e,styles:t}){return e==="done"?jsx(View,{style:[t.dot,t.dotDone],accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsx(m,{tier:"badge",style:[t.glyph,t.glyphOnBrand],children:"\u2713"})}):e==="failed"?jsx(View,{style:[t.dot,t.dotFailed],accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsx(m,{tier:"badge",style:t.glyph,children:"!"})}):e==="current"?jsx(View,{style:[t.dot,t.dotCurrent],accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsx(View,{style:t.dotCurrentCore})}):jsx(View,{style:[t.dot,t.dotUpcoming],accessibilityElementsHidden:true,importantForAccessibility:"no"})}i(Ig,"TimelineDot");function Dg(){let e=V();return useMemo(()=>Ag(e),[e])}i(Dg,"useStyles");function Ag(e){let{color:t,type:r}=e,{size:o}=r;return StyleSheet.create({container:{gap:0},row:{flexDirection:"row",alignItems:"flex-start",gap:12},railColumn:{alignItems:"center",width:Ho},body:{flex:1,paddingBottom:18,gap:2},titleRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:8},dot:{width:Ho,height:Ho,borderRadius:Ho/2,alignItems:"center",justifyContent:"center"},dotDone:{backgroundColor:t.brand},dotFailed:{backgroundColor:t.danger},dotCurrent:{borderWidth:2,borderColor:t.brandInk,backgroundColor:t.surface},dotCurrentCore:{width:As,height:As,borderRadius:As/2,backgroundColor:t.brand},dotUpcoming:{borderWidth:2,borderColor:t.borderHairlineGreen,backgroundColor:t.surface},glyph:{...k(e,"bold"),fontSize:o.caption,lineHeight:o.caption+2,color:t.surface},glyphOnBrand:{color:t.onPrimary},connector:{width:2,flex:1,minHeight:22,backgroundColor:t.borderHairlineGreen,marginVertical:2},connectorDone:{backgroundColor:t.brand},title:{flex:1,...k(e,"bold"),fontSize:o.body,lineHeight:o.body+4,color:t.text.primary},titleCurrent:{color:t.brandInk},titleFailed:{color:t.danger},titleUpcoming:{color:t.text.muted,...k(e,"regular")},date:{...k(e,"regular"),fontSize:o.caption,lineHeight:o.caption+4,color:t.text.muted},detail:{...k(e,"regular"),fontSize:o.bodyTight,lineHeight:o.bodyTight+4,color:t.text.muted},detailUpcoming:{color:t.text.muted,opacity:.7}})}i(Ag,"makeStyles");function rn(e,t,r){let o=Pr(e,r);switch(o.kind){case "consent_required":return jsx(Vg,{onGrant:t});case "consent_unavailable":return jsx(qg,{});case "session_required":return jsx(zg,{});case "withheld":return jsx(Fg,{});case "pet_not_found":case "error":return jsx(Ng,{error:o.error,onRetry:e.refresh});default:return vr(o)}}i(rn,"renderErrorFamily");function nn(e,t){return ()=>{let r=Rs(t,e.consent);if(r.length===0)return;let o=`records-consent-${Date.now().toString(36)}`;e.grantConsent(r,o);}}i(nn,"makeGrantHandler");function Pd({records:e}){let t=zn(),r=e.uploadQueue;if(r.length===0)return null;let o=r.filter(l=>l.status!=="skipped"),n=o.filter(l=>l.status==="done").length,a=Bo(Cd(r));return jsxs(View,{style:t.timeline,testID:"records-upload-queue",children:[a!==null?jsx(m,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",style:t.errorText,children:a}):null,o.length>0?jsx(View,{accessibilityLiveRegion:"polite",accessibilityLabel:e.isUploading?$r.uploading(n,o.length):$r.uploaded(n,o.length),children:o.map(l=>{let c=Math.round(l.progress*100);return jsxs(View,{style:t.uploadRow,testID:`records-upload-file-${l.status}`,children:[jsxs(View,{style:t.uploadRowHead,children:[jsx(m,{style:t.rowLabel,children:l.name??""}),jsx(m,{style:t.rowValue,children:xd(l)})]}),l.status==="uploading"?jsx(View,{style:t.progressTrack,accessibilityRole:"progressbar",accessibilityValue:{min:0,max:100,now:c},children:jsx(View,{style:[t.progressFill,{width:`${c}%`}]})}):null,l.status==="failed"&&l.error?jsx(m,{style:t.timelineMeta,children:l.error.displayMessage}):null]},l.key)})}):null]})}i(Pd,"UploadQueue");function Vg({onGrant:e}){let t=zn();return jsx(View,{style:t.centered,accessible:true,accessibilityRole:"alert",accessibilityLabel:ye.consentRequired,children:jsx(Pressable,{onPress:e,accessibilityRole:"button",accessibilityLabel:ye.allow,style:t.primaryButton,children:jsx(m,{style:t.primaryLabel,children:ye.allow})})})}i(Vg,"ConsentRequiredState");function Vs({label:e,glyph:t}){let r=zn();return useEffect(()=>{AccessibilityInfo.announceForAccessibility?.(e);},[e]),jsxs(View,{style:r.centered,accessible:true,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:e,children:[jsx(View,{style:t==="withheld"?r.withheldGlyph:r.emptyGlyph}),jsx(m,{style:r.errorText,children:e})]})}i(Vs,"AlertState");function qg(){return jsx(Vs,{label:ye.consentRequired,glyph:"empty"})}i(qg,"ConsentUnavailableState");function zg(){return jsx(Vs,{label:ye.sessionRequired,glyph:"empty"})}i(zg,"SessionRequiredState");function Fg(){return jsx(Vs,{label:ye.recordUnavailable,glyph:"withheld"})}i(Fg,"WithheldState");function Ng({error:e,onRetry:t}){let r=zn();return useEffect(()=>{AccessibilityInfo.announceForAccessibility?.(e.displayMessage);},[e.displayMessage]),jsxs(View,{style:r.centered,accessible:true,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",children:[jsx(m,{style:r.errorText,children:e.displayMessage}),e.retryable?jsx(Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:ye.retry,style:r.primaryButton,children:jsx(m,{style:r.primaryLabel,children:ye.retry})}):null]})}i(Ng,"ErrorState");function Id({call:e,prompt:t}){let r=zn(),o=t.trim().length>0?t:Ln.fallbackPrompt;return jsxs(View,{style:r.callCard,accessibilityRole:"summary",children:[jsx(m,{style:r.timelineLabel,children:Ln.heading}),jsx(m,{style:r.timelineMeta,children:o}),jsx(Pressable,{onPress:()=>{Linking?.openURL?.(e.dial);},accessibilityRole:"button",accessibilityLabel:Ln.callAt(e.phone),style:r.linkButton,testID:"records-call-clinic",children:jsx(m,{style:r.linkLabel,children:Ln.call})})]})}i(Id,"ClinicCallCard");function zn(){let e=V();return useMemo(()=>Mg(e),[e])}i(zn,"useStyles");function Mg(e){let{color:t,space:r,radius:o,type:n,slots:a}=e,{size:l,lineHeight:c,letterSpacing:s}=n,d=nt(a.recordCard,StyleSheet.hairlineWidth),u=at(a.recordCard),p=i((y,x)=>Math.round(y*x),"lh"),f=StyleSheet.hairlineWidth,b=r.xxl*3+r.xl,R=r.xxl+r.md,v=r.xxl+r.sm,w=e.brightness==="dark"?t.errorRed:t.danger,g={shadowColor:t.brand,shadowOffset:{width:0,height:r.xs},shadowRadius:r.sm,shadowOpacity:.08,elevation:r.xs};return StyleSheet.create({container:{flex:1,minHeight:b,backgroundColor:t.background},body:{flex:1},centered:{minHeight:b,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl,gap:r.lg},emptyGlyph:{width:v,height:v,borderRadius:o.lg,backgroundColor:t.brandSoft,borderWidth:f,borderColor:t.brandBorder},withheldGlyph:{width:v,height:v,borderRadius:o.sm,backgroundColor:t.badgeBgCaution,borderWidth:f,borderColor:t.cautionAccent},errorText:{...k(e,"regular"),fontSize:l.subtitle,lineHeight:p(l.subtitle,c.snug),color:w,textAlign:"center",marginBottom:r.md},primaryButton:{minHeight:R,minWidth:R,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.md,borderRadius:o.pill,backgroundColor:t.primary,...g,...nt(a.primaryButton)},primaryLabel:{...k(e,"bold"),color:t.onPrimary,fontSize:l.body,letterSpacing:s.tight,...at(a.primaryButton)},linkButton:{minHeight:R,minWidth:R,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.md,borderRadius:o.pill,backgroundColor:t.primary,...g,...nt(a.primaryButton)},linkLabel:{...k(e,"bold"),color:t.onPrimary,fontSize:l.body,letterSpacing:s.tight,...at(a.primaryButton)},disabledButton:{minHeight:R,minWidth:R,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.md,borderRadius:o.pill,backgroundColor:t.surfaceSubtle,borderWidth:f,borderColor:t.brandBorder},disabledLabel:{...k(e,"bold"),color:t.text.muted,fontSize:l.body,letterSpacing:s.tight},list:{flex:1},listContent:{padding:r.lg,gap:r.md},timeline:{paddingVertical:r.md,paddingHorizontal:r.lg,borderRadius:o.md,backgroundColor:t.surfaceCream,borderWidth:f,borderColor:t.brandBorder,gap:r.xs,...g,...d},timelineTitle:{...k(e,"bold"),fontSize:l.heading,lineHeight:p(l.heading,c.snug),color:t.text.primary,letterSpacing:s.tight,...u},timelineLabel:{...k(e,"bold"),fontSize:l.subtitle,lineHeight:p(l.subtitle,c.snug),color:t.text.secondary,letterSpacing:s.tight,...u},callCard:{gap:r.sm,padding:r.md,borderRadius:o.md,backgroundColor:t.surfaceCream,borderWidth:f,borderColor:t.brandBorder,...d},timelineMeta:{...k(e,"regular"),fontSize:l.bodyTight,lineHeight:p(l.bodyTight,c.normal),color:t.text.muted,...u},recordBlock:{gap:r.sm,padding:r.md,borderRadius:o.md,backgroundColor:t.surfaceCream,borderWidth:f,borderColor:t.brandBorder,...g,...d},row:{flexDirection:"row",justifyContent:"space-between",gap:r.md,paddingVertical:r.xs,borderBottomWidth:f,borderBottomColor:t.borderHairlineGreen},rowLabel:{...k(e,"regular"),fontSize:l.body,lineHeight:p(l.body,c.normal),color:t.text.muted,flexShrink:1,...u},rowValue:{...k(e,"medium"),fontSize:l.body,lineHeight:p(l.body,c.normal),color:t.text.primary,textAlign:"right",flexShrink:1,...u},disclaimer:{...k(e,"regular"),fontSize:l.caption,lineHeight:p(l.caption,c.normal),color:t.text.muted,marginTop:r.md},uploadRow:{gap:r.xs,paddingVertical:r.xs,borderBottomWidth:f,borderBottomColor:t.borderHairlineGreen},uploadRowHead:{flexDirection:"row",justifyContent:"space-between",gap:r.md},progressTrack:{height:r.xs,borderRadius:o.pill,backgroundColor:t.brandSofter,overflow:"hidden",width:"100%"},progressFill:{height:"100%",backgroundColor:t.brand}})}i(Mg,"makeStyles");function qs(e){let{style:t,renderPending:r,...o}=Le(e,["onNavigate","onBack","onAsk"]);return jsx(Ve,{capability:"records",style:t,...r?{renderPending:r}:{},...Fe(o.onBack,Ye),children:jsx(Ug,{...o,style:t})})}i(qs,"EverfurRecordsRequests");function Ug({petRef:e,petName:t,controller:r,onNavigate:o,onBack:n,onAsk:a,style:l}){let c=me(),s=zs(),d=st(r?{petRef:e,controller:r}:{petRef:e}),u=useMemo(()=>ws(d.requests.filter(b=>b.petRef===e)),[d.requests,e]),p=a?b=>{let R=So(t,{clinicName:b.clinicName??null,statusLabel:Ur(b),status:b.status,heldItemCount:b.heldItemCount},b.id);a(R.prompt,R.entityRef);}:void 0,f;return d.status==="loading"&&u.length===0?f=jsx(mo,{testID:"records-list-loading"}):d.status==="error"&&u.length===0?f=jsx(Ue,{variant:mt(d.error),message:d.error?.displayMessage,onAction:d.error?.retryable?d.refresh:void 0,testID:"records-list-error"}):u.length===0?f=jsx(Ue,{variant:"no_requests",testID:"records-list-empty"}):f=jsx(ScrollView,{contentContainerStyle:s.list,testID:"records-list-results",children:u.map(b=>jsx(jg,{request:b,onOpen:o?()=>o({name:"request",requestId:b.id}):void 0,onAsk:p?()=>p(b):void 0},b.id))}),jsxs(View,{style:[c.root,l],children:[jsx(Ke,{title:ft.title,onBack:n,testID:"records-list-header"}),u.length>0?jsx(m,{style:s.subtitle,testID:"records-list-subtitle",children:ft.subtitle(t)}):null,jsx(View,{style:c.body,children:f}),o?jsxs(View,{style:s.footer,children:[jsx(X,{label:ft.requestRecords,accessibilityLabel:ft.requestRecordsA11y,onPress:()=>o({name:"clinicPicker"}),testID:"records-list-new"}),jsx(X,{label:ft.uploadOwn,kind:"outline",accessibilityLabel:ft.uploadOwnA11y,onPress:()=>o({name:"upload"}),testID:"records-list-upload-own"})]}):null,jsx(qe,{})]})}i(Ug,"RequestsBody");function jg({request:e,onOpen:t,onAsk:r}){let o=me(),n=zs(),a=Yc(e),l=Xc(e),c=jsxs(Fragment,{children:[jsx(View,{style:[n.bubble,o.chipTones[l].bg],accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxs(View,{style:n.copy,children:[jsx(m,{style:n.source,numberOfLines:1,children:a.source}),jsx(m,{style:n.meta,numberOfLines:1,children:a.meta}),jsx(View,{accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsx(kt,{label:a.status,tone:l})})]}),t?jsx(rr,{}):null]});return jsxs(View,{style:n.row,testID:`records-request-row-${e.id}`,children:[t?jsx(Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:a.a11yLabel,style:n.rowInner,testID:`records-request-open-${e.id}`,children:c}):jsx(View,{style:n.rowInner,accessible:true,accessibilityLabel:a.a11yLabel,children:c}),t&&vs(null,e)!==null?jsx(X,{label:Ze.cardTitle,onPress:t,testID:`records-request-resume-upload-${e.id}`}):null,r?jsx(X,{label:kr.ask,kind:"ask",accessibilityLabel:ft.askA11y(a.source),onPress:r,testID:`records-request-ask-${e.id}`}):null]})}i(jg,"RequestRow");function Fn({requests:e,petName:t,activeOnly:r=false,onOpen:o}){let n=zs(),a=Kc(e,Ne(t),{activeOnly:r});return a===null||o===void 0?null:jsxs(Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:a.a11yLabel,style:n.card,testID:"records-requests-status",children:[jsx(View,{style:[n.cardBubble,a.processing?n.cardBubbleProcessing:null],accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxs(View,{style:n.cardText,children:[jsx(m,{style:n.cardTitle,children:a.title}),jsx(m,{style:n.cardSubtitle,children:a.subtitle})]}),jsx(rr,{})]})}i(Fn,"RecordsRequestsStatusCard");function zs(){let e=V();return useMemo(()=>$g(e),[e])}i(zs,"useLocalStyles");function $g(e){let{color:t,space:r,radius:o,type:n}=e,a=i((c,s)=>Math.round(c*s),"lh"),l=r.xxl+r.xs/2;return StyleSheet.create({subtitle:{...k(e,"regular"),fontSize:n.size.caption,lineHeight:a(n.size.caption,n.lineHeight.normal),color:t.text.muted,paddingHorizontal:r.lg,paddingBottom:r.md},list:{paddingHorizontal:r.lg,paddingBottom:r.xl,gap:r.md},row:{borderRadius:o.lg,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md,gap:r.sm},rowInner:{flexDirection:"row",alignItems:"center",gap:r.md},bubble:{width:l,height:l,borderRadius:l/2},copy:{flex:1,gap:r.xs+1},source:{...k(e,"bold"),fontSize:n.size.body,lineHeight:a(n.size.body,n.lineHeight.snug),color:t.text.primary},meta:{...k(e,"regular"),fontSize:n.size.tiny,lineHeight:a(n.size.tiny,n.lineHeight.normal),color:t.text.muted},footer:{paddingHorizontal:r.lg,paddingTop:r.sm+r.xs/2,paddingBottom:r.lg,gap:r.sm+r.xs/2,borderTopWidth:1,borderTopColor:t.borderHairlineGreen},card:{flexDirection:"row",alignItems:"center",gap:r.md,borderRadius:o.md,backgroundColor:t.surfaceCream,paddingHorizontal:r.md+r.xs,paddingVertical:r.md},cardBubble:{width:r.xl+r.xs/2,height:r.xl+r.xs/2,borderRadius:o.pill,borderWidth:2,borderColor:t.brandInk},cardBubbleProcessing:{borderColor:t.warningStrong,backgroundColor:t.badgeBgCaution},cardText:{flex:1,gap:2},cardTitle:{...k(e,"bold"),fontSize:n.size.bodyTight,lineHeight:a(n.size.bodyTight,n.lineHeight.snug),color:t.brandInk},cardSubtitle:{...k(e,"regular"),fontSize:n.size.caption,lineHeight:a(n.size.caption,n.lineHeight.normal),color:t.text.muted}})}i($g,"makeLocalStyles");var Kg=i((e,t)=>e.getRecordDepth(t),"readDepth"),Qg=i(e=>!e.available,"depthEmpty");function Ms(e){let{style:t,renderPending:r,...o}=Le(e,["onNavigate","onBack","onAsk"]);return jsx(Ve,{capability:"records",style:t,...r?{renderPending:r}:{},...Fe(o.onBack,Ye),children:jsx(Xg,{...o,style:t})})}i(Ms,"EverfurRecordsDashboard");function Xg({petRef:e,petName:t,controller:r,consentVersion:o,onNavigate:n,onBack:a,onAsk:l,style:c}){let s=me(),d=Bs(),u=st(r?{petRef:e,controller:r}:{petRef:e}),p=ys(e),f=Yt(e,Kg,Qg),[b,R]=useState(null),v=useCallback((O,se)=>R({marker:O,point:se}),[]),w=useMemo(()=>Hr(o,u.consent),[o,u.consent]),g=useMemo(()=>nn(u,o),[u,o]),y=gn("recordsClinic"),x=y.enabled||y.isPending,h=p.markers?.markers??[],P=h.length>0,S=u.record!==null&&!u.record.isEmpty&&!u.record.withheld,E=ro(u.requests,e),C=u.requests.filter(O=>O.petRef===e),I=n?()=>n({name:"requests"}):void 0,F=ki({hasMarkers:P,requests:u.requests,petRef:e}),q=Ti({recordLoading:u.status==="loading",hasFullRecord:S,recordError:u.status==="error",markersLoading:p.status==="loading",markersError:p.status==="error",hasMarkers:P,requestsLoading:u.status==="loading",dashboardState:F,drivingRequest:E}),j=p.markers?.disclaimer??u.record?.disclaimer??"",$=i(()=>{u.refresh(),p.refresh(),f.refresh();},"retryAll"),ce=f.value!==null&&!f.value.withheld&&f.value.available?f.value:null,oe=Ne(t),ve=l&&p.markers?.summary?()=>{let O=Hc(t,p.markers?.summary??{totalMarkers:0,inRangeCount:0,outOfRangeCount:0,unknownCount:0},e);l(O.prompt,O.entityRef);}:void 0,ie=l?O=>{let se=Bc(t,{canonicalName:O.name,markerId:O.markerId,latestValueText:O.latest?Tt(O.latest.value,O.unit,O.latest.qualitativeResult):null,statusText:O.latest?nr(O.latest.status).label:null,trajectoryText:Kr(O.trajectory,O.points.length),meaningText:O.meaning});l(se.prompt,se.entityRef);}:void 0,T=l&&b?()=>{let{marker:O,point:se}=b,re=Uc(t,{canonicalName:O.name,valueText:Tt(se.value,O.unit,se.qualitativeResult),collectedAt:J(se.at),sourceClinic:se.sourceClinic,referenceText:se.refLow!==null||se.refHigh!==null?Eo(se,O.unit):null,flagged:se.status==="above"?"above":se.status==="below"?"below":null,reviewed:se.reviewed,entityId:se.docId??O.markerId});R(null),l(re.prompt,re.entityRef);}:void 0,D=jsxs(Fragment,{children:[p.markers?.summary?jsx(View,{style:s.inset,children:jsx(td,{summary:p.markers.summary,onAsk:ve,testID:"dashboard-marker-summary"})}):null,jsx(m,{style:s.lead,children:yt.lead(t)}),jsx(sd,{markers:h,onPointPress:v,onAsk:ie})]}),L=i(O=>n?jsxs(View,{style:[s.inset,d.actions],children:[O?jsx(Wo,{label:yt.viewFullRecord,onPress:()=>n({name:"record"}),testID:"dashboard-full-record-action"}):null,jsx(Wo,{label:yt.viewTimeline,onPress:()=>n({name:"timeline"}),testID:"dashboard-timeline-action"}),jsx(Wo,{label:ft.allRequests,onPress:()=>n({name:"requests"}),testID:"dashboard-requests-action"})]}):null,"actions"),B=i(O=>n?jsxs(View,{style:[O?s.inset:null,d.addActions],testID:"dashboard-actions",children:[x?jsx(X,{label:$t.requestFromClinic,accessibilityLabel:$t.requestFromClinicA11y(t),onPress:()=>n({name:"clinicPicker"}),style:d.addCta,testID:"dashboard-actions-clinic"}):null,jsx(X,{label:$t.uploadDocument,kind:"outline",accessibilityLabel:$t.uploadDocumentA11y(t),onPress:()=>n({name:"upload"}),style:d.addCta,testID:"dashboard-actions-upload"})]}):null,"addActions"),H;if(u.status==="error"){let O=Pr(u,w);H=O.kind==="error"||O.kind==="pet_not_found"?jsx(Ue,{variant:mt(O.error),message:O.error.displayMessage,onAction:O.error.retryable?$:void 0,testID:"dashboard-error"}):rn(u,g,w);}else switch(q){case "loading":H=jsx(po,{testID:"dashboard-loading"});break;case "record":H=jsxs(ScrollView,{contentContainerStyle:s.contentTight,testID:"dashboard-record",children:[P?D:p.status==="error"?jsx(View,{style:[s.inset,d.actions],children:jsx(Wo,{label:yt.retryMarkers,onPress:$,testID:"dashboard-markers-retry"})}):null,jsx(View,{style:s.inset,children:u.record?jsx(Mo,{record:u.record,depth:ce,petName:t,showLabs:!P,onNavigate:n,onAsk:l}):null}),jsx(View,{style:s.inset,children:jsx(Fn,{requests:C,petName:t,activeOnly:true,onOpen:I})}),B(true),L(true)]});break;case "error":H=jsx(Ue,{variant:mt(p.error??u.error),message:(p.error??u.error)?.displayMessage,onAction:(p.error??u.error)?.retryable?$:void 0,testID:"dashboard-error"});break;case "in_progress":H=jsxs(ScrollView,{contentContainerStyle:s.content,testID:"dashboard-in-progress",children:[E?jsx(Jg,{request:E,petName:oe,onOpen:n?()=>n({name:"request",requestId:E.id}):void 0,onAsk:l?()=>{let O=So(t,{clinicName:E.clinicName??null,statusLabel:Ur(E),status:E.status,heldItemCount:E.heldItemCount},E.id);l(O.prompt,O.entityRef);}:void 0}):null,jsx(Fn,{requests:C,petName:t,onOpen:I}),B(false),jsx(Tr,{disclaimer:j})]});break;case "none":H=jsxs(ScrollView,{contentContainerStyle:s.content,testID:"dashboard-request-prompt",children:[jsxs(View,{style:d.promptCard,children:[jsxs(View,{style:d.promptHeader,children:[jsx(View,{style:d.promptGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsx(m,{style:d.promptTitle,children:$t.title(t)})]}),jsx(m,{style:d.promptBody,children:$t.body}),n?jsxs(Fragment,{children:[jsx(X,{label:$t.requestFromClinic,accessibilityLabel:$t.requestFromClinicA11y(t),onPress:()=>n({name:"clinicPicker"}),style:d.promptCta,testID:"dashboard-request-prompt-clinic"}),jsx(X,{label:$t.uploadDocument,kind:"outline",accessibilityLabel:$t.uploadDocumentA11y(t),onPress:()=>n({name:"upload"}),style:d.promptCtaSecondary,testID:"dashboard-request-prompt-upload"})]}):null]}),jsx(Fn,{requests:C,petName:t,onOpen:I}),jsx(Tr,{disclaimer:j})]});break;case "labs_only":H=jsxs(ScrollView,{contentContainerStyle:s.contentTight,testID:"dashboard-labs-only",children:[D,jsx(View,{style:s.inset,children:jsx(Fn,{requests:C,petName:t,activeOnly:true,onOpen:I})}),B(true),jsx(View,{style:s.inset,children:jsx(Tr,{disclaimer:j})}),L(false)]});break;default:H=vr(q);}return jsxs(View,{style:[s.root,c],children:[jsx(Ke,{title:yt.title,onBack:a,testID:"dashboard-header",right:n?jsx(Pressable,{onPress:()=>n({name:"timeline"}),accessibilityRole:"button",accessibilityLabel:yt.openTimeline,hitSlop:12,style:d.headerButton,testID:"dashboard-timeline-link",children:jsx(zl,{})}):void 0}),jsx(View,{style:s.body,children:H}),jsx(ad,{marker:b?.marker??null,point:b?.point??null,onClose:()=>R(null),onAsk:T}),jsx(qe,{})]})}i(Xg,"DashboardBody");function Wo({label:e,onPress:t,testID:r}){let o=Bs();return jsxs(Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:e,style:o.actionRow,testID:r,children:[jsxs(View,{style:o.actionLeft,children:[jsx(View,{style:o.actionIcon,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsx(m,{style:o.actionLabel,children:e})]}),jsx(rr,{})]})}i(Wo,"ActionRow");function Jg({request:e,petName:t,onOpen:r,onAsk:o}){let n=me(),a=Bs(),l=e.clinicName?.trim()||kr.title(t),c=Ur(e),s=jsxs(View,{style:a.inProgressInner,children:[jsxs(View,{style:a.inProgressHead,children:[jsx(m,{style:a.inProgressTitle,children:l}),r?jsx(rr,{}):null]}),jsx(jo,{request:e}),c.length>0?jsx(View,{style:n.statusCard,children:jsx(m,{style:n.statusText,children:c})}):null]});return jsxs(View,{style:a.inProgressCard,testID:"dashboard-in-progress-card",accessibilityRole:"summary",accessible:r?false:void 0,accessibilityLabel:r?void 0:kr.a11y(t),children:[r?jsx(Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:kr.openA11y(t,c),testID:"dashboard-in-progress-open",children:s}):s,o?jsx(X,{label:kr.ask,kind:"ask",accessibilityLabel:kr.askA11y,onPress:o,testID:"dashboard-in-progress-ask"}):null]})}i(Jg,"InProgressCard");function Bs(){let e=V();return useMemo(()=>Zg(e),[e])}i(Bs,"useLocalStyles");function Zg(e){let{color:t,space:r,radius:o,type:n}=e,a=StyleSheet.hairlineWidth,l=r.xxl+r.md;return StyleSheet.create({headerButton:{width:l,height:l,alignItems:"center",justifyContent:"center"},actions:{gap:r.sm+r.xs/2},actionRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",borderRadius:o.md,borderWidth:a,borderColor:t.brandBorder,backgroundColor:t.surface,paddingHorizontal:r.lg,paddingVertical:r.lg},actionLeft:{flex:1,flexDirection:"row",alignItems:"center",gap:r.md},actionIcon:{width:r.lg+r.xs/2,height:r.lg+r.xs/2,borderRadius:o.xs,backgroundColor:t.brandSoft,borderWidth:a,borderColor:t.brandBorder},actionLabel:{flex:1,...k(e,"medium"),fontSize:n.size.body,lineHeight:Math.round(n.size.body*n.lineHeight.snug),color:t.text.primary},inProgressCard:{borderRadius:o.lg-r.xs/2,backgroundColor:t.surface,borderWidth:a,borderColor:t.brandBorder,padding:r.lg+r.xs/2,gap:r.lg},inProgressInner:{gap:r.lg},inProgressHead:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},inProgressTitle:{flex:1,...k(e,"bold"),fontSize:n.size.subtitle,lineHeight:Math.round(n.size.subtitle*n.lineHeight.snug),color:t.text.primary},promptCard:{borderRadius:o.sm,backgroundColor:t.surfaceCream,borderWidth:a,borderColor:t.borderRingCream,paddingHorizontal:r.lg+r.xs,paddingVertical:r.lg+r.xs/2},promptHeader:{flexDirection:"row",alignItems:"center",gap:r.xs+1},promptGlyph:{width:r.xl+1,height:r.xl+1,borderRadius:o.xs,borderWidth:2,borderColor:t.warningStrong},promptTitle:{flex:1,...k(e,"bold"),fontSize:n.size.subtitle,lineHeight:Math.round(n.size.subtitle*n.lineHeight.snug),letterSpacing:n.letterSpacing.headerBrand,color:t.brandInk},promptBody:{marginTop:r.sm-1,...k(e,"regular"),fontSize:n.size.bodyTight,lineHeight:r.lg+r.xs,color:t.text.primary},promptCta:{marginTop:r.sm-1,minHeight:r.xxl+r.sm},promptCtaSecondary:{marginTop:r.sm,minHeight:r.xxl+r.sm},addActions:{gap:r.sm},addCta:{minHeight:r.xxl+r.sm}})}i(Zg,"makeLocalStyles");var Go=Object.freeze({visit:0,vaccine:1,weight:2,medication:3});function Vd(e){if(!e)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}i(Vd,"toMillis");function qd(e){let t=[...e.visits.map((r,o)=>({key:`visit-${o}-${r.visitId}`,kind:"visit",kindLabel:be.kind.visit,at:r.visitDate,date:J(r.visitDate),title:r.summary??be.clinicVisit,detail:r.veterinarian?be.doctor(r.veterinarian):null,docId:r.docId})),...e.vaccines.map((r,o)=>{let n=[];return r.lot&&n.push(be.lot(r.lot)),r.expiresOn&&n.push(be.expires(J(r.expiresOn))),{key:`vaccine-${o}-${r.vaccineId}`,kind:"vaccine",kindLabel:be.kind.vaccine,at:r.administeredOn,date:J(r.administeredOn),title:r.product||be.kind.vaccine,detail:n.length?n.join(" \xB7 "):null,docId:r.docId}}),...e.weights.map((r,o)=>({key:`weight-${o}-${r.weightId}`,kind:"weight",kindLabel:be.kind.weight,at:r.observedOn,date:J(r.observedOn),title:$l(r.weightKg),detail:null,docId:r.docId})),...e.medications.map((r,o)=>{let n=[r.dose,r.route,r.frequency].filter(a=>!!a);return {key:`medication-${o}-${r.medicationId}`,kind:"medication",kindLabel:be.kind.medication,at:r.startedOn,date:J(r.startedOn),title:r.drugName||be.kind.medication,detail:n.length?n.join(" \xB7 "):null,docId:r.docId}})];return Object.freeze(t.sort((r,o)=>{let n=Vd(r.at),a=Vd(o.at);return n===null&&a===null?Go[r.kind]-Go[o.kind]:n===null?1:a===null?-1:a!==n?a-n:Go[r.kind]-Go[o.kind]}))}i(qd,"buildTimelineRows");var ib=300,sb=i((e,t)=>e.getTimeline(t),"readTimeline"),ab=i(e=>e.isEmpty,"timelineEmpty");var lb=i(e=>e.contributions.length===0,"contributionsEmpty");function Nd({petRef:e,style:t,onBack:r}){let o=Yt(e,sb,ab);return jsx(Bd,{state:o,style:t,onBack:r,header:jsx(Ke,{title:be.timeline,onBack:yn(r),testID:"timeline-header"}),loading:jsx(Ql,{testID:"timeline-loading"}),empty:jsx(Ue,{variant:"no_records",testID:"timeline-empty"}),render:n=>jsx(ub,{timeline:n})})}i(Nd,"EverfurRecordsTimeline");function Md({petRef:e,docId:t,style:r,onBack:o}){let n=useCallback((c,s)=>c.getDocumentContributions(s,t),[t]),a=Yt(e,n,lb,t),l=a.value?.document?.title?.trim()||be.uploadedDocument;return jsx(Bd,{state:a,style:r,onBack:o,header:jsx(Ke,{title:l,onBack:yn(o),testID:"contributions-header"}),empty:jsx(Ue,{variant:"no_records",testID:"contributions-empty"}),render:c=>jsx(pb,{view:c})})}i(Md,"EverfurDocumentContributions");function Bd({state:e,style:t,header:r,loading:o,empty:n,render:a,onBack:l}){let c=Hs();return jsx(Ve,{capability:"records",style:t,...Fe(yn(l),Ye),children:jsxs(View,{style:[c.container,t],children:[r??null,jsx(View,{style:c.body,children:cb(e,a,c,o,n)}),jsx(qe,{})]})})}i(Bd,"DepthSurface");function cb(e,t,r,o,n){switch(e.status){case "loading":return o??jsx(db,{styles:r});case "empty":return n??jsx(View,{style:r.centered,accessible:true,accessibilityRole:"summary",accessibilityLabel:ye.empty,children:jsx(View,{style:r.emptyGlyph})});case "error":return e.error?jsx(Ue,{variant:mt(e.error),message:e.error.displayMessage,onAction:e.error.retryable?e.refresh:void 0,testID:"depth-error"}):null;case "populated":return e.value===null||e.value.withheld?null:t(e.value);default:return null}}i(cb,"renderState");function db({styles:e}){let[t,r]=useState(false);return useEffect(()=>{let o=setTimeout(()=>r(true),ib);return ()=>clearTimeout(o)},[]),jsx(View,{style:e.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:ye.loading,children:t?jsx(ActivityIndicator,{}):null})}i(db,"LoadingState");function ub({timeline:e}){let t=Hs(),r=qd(e);return jsxs(ScrollView,{style:t.list,contentContainerStyle:t.timelineContent,accessibilityLabel:be.timeline,children:[e.disclaimer.length>0?jsx(View,{style:t.timelineBand,accessible:true,accessibilityRole:"text",accessibilityLabel:yt.important(e.disclaimer),children:jsx(m,{style:t.timelineBandText,children:e.disclaimer})}):null,r.map((o,n)=>jsxs(View,{children:[n>0?jsx(View,{style:t.timelineSeparator}):null,jsxs(View,{style:t.timelineRow,accessible:true,accessibilityRole:"text",accessibilityLabel:[o.kindLabel,o.date,o.title,o.detail].filter(Boolean).join(", "),testID:`records-timeline-row-${o.kind}`,children:[jsx(View,{style:t.timelineBubble,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxs(View,{style:t.timelineBody,children:[jsxs(View,{style:t.topLine,children:[jsx(m,{style:t.timelineKind,children:o.kindLabel}),jsx(m,{style:t.date,children:o.date})]}),jsx(m,{style:t.timelineTitle,children:o.title}),o.detail?jsx(m,{style:t.rowDetail,children:o.detail}):null]})]})]},o.key))]})}i(ub,"TimelineBody");function pb({view:e}){let t=Hs();return jsxs(ScrollView,{style:t.list,contentContainerStyle:t.listContent,accessibilityLabel:ye.records,children:[e.document?.receivedAt?jsx(m,{style:t.rowDetail,children:J(e.document.receivedAt)}):null,jsx(View,{style:t.card,children:e.contributions.map(r=>jsxs(View,{style:t.row,accessible:true,accessibilityRole:"text",children:[jsx(m,{style:t.rowTitle,children:r.label}),jsx(m,{style:t.rowValue,children:Yr(r.value,r.unit)}),r.observedAt?jsx(m,{style:t.rowDetail,children:J(r.observedAt)}):null]},r.key))})]})}i(pb,"ContributionsBody");function Hs(){let e=V();return useMemo(()=>mb(e),[e])}i(Hs,"useStyles");function mb(e){let{color:t,space:r,radius:o,type:n,slots:a}=e,{size:l,lineHeight:c}=n,s=i((w,g)=>Math.round(w*g),"lh"),d=StyleSheet.hairlineWidth,u=r.xxl*3+r.xl,p=r.xxl+r.md,f=e.brightness==="dark"?t.errorRed:t.danger,b=at(a.recordCard),R=i((w,g,y,x="regular")=>({...k(e,x),fontSize:w,lineHeight:s(w,g),color:y}),"text"),v=i((w,g,y,x="regular")=>({...R(w,g,y,x),...b}),"inCard");return StyleSheet.create({container:{flex:1,minHeight:u,backgroundColor:t.background},body:{flex:1},centered:{minHeight:u,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl,gap:r.lg},emptyGlyph:{width:r.xxl+r.sm,height:r.xxl+r.sm,borderRadius:o.lg,backgroundColor:t.brandSoft,borderWidth:d,borderColor:t.brandBorder},errorText:{...R(l.subtitle,c.snug,f),textAlign:"center",marginBottom:r.md},primaryButton:{minHeight:p,minWidth:p,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.md,borderRadius:o.pill,backgroundColor:t.primary,...nt(a.primaryButton)},primaryLabel:{...k(e,"bold"),color:t.onPrimary,fontSize:l.body,...at(a.primaryButton)},list:{flex:1},listContent:{padding:r.lg,gap:r.md},section:{gap:r.sm},heading:{...R(l.heading,c.snug,t.text.primary,"bold")},card:{gap:r.sm,padding:r.md,borderRadius:o.md,backgroundColor:t.surfaceCream,borderWidth:d,borderColor:t.brandBorder,...nt(a.recordCard,d)},row:{gap:r.xs,paddingVertical:r.xs,borderBottomWidth:d,borderBottomColor:t.borderHairlineGreen},topLine:{flexDirection:"row",justifyContent:"space-between",gap:r.md},kindLabel:{...v(l.caption,c.normal,t.text.muted,"medium")},date:v(l.caption,c.normal,t.text.muted),rowTitle:{...v(l.body,c.normal,t.text.primary,"bold")},rowValue:{...v(l.body,c.normal,t.text.primary,"medium")},rowDetail:v(l.bodyTight,c.normal,t.text.muted),rowMuted:{...v(l.bodyTight,c.normal,t.text.muted),opacity:.7},chip:{...R(l.caption,c.normal,t.text.primary),alignSelf:"flex-start",paddingHorizontal:r.sm,paddingVertical:r.xs,borderRadius:o.pill},chipNeutral:{backgroundColor:t.badgeBgNeutral},chipCaution:{backgroundColor:t.badgeBgCaution},chipCritical:{backgroundColor:t.badgeBgCritical},disclaimer:{...R(l.caption,c.normal,t.text.muted),marginTop:r.md},timelineContent:{paddingBottom:r.xxl},timelineBand:{flexDirection:"row",gap:r.sm,borderRadius:o.md-r.xs/2,padding:r.md,backgroundColor:t.brandSoft,marginHorizontal:r.lg,marginTop:r.xs,marginBottom:r.md},timelineBandText:{flex:1,...R(l.caption,c.normal,t.text.secondary)},timelineSeparator:{height:d,backgroundColor:t.brandBorder,marginLeft:$i},timelineRow:{flexDirection:"row",gap:r.md,paddingHorizontal:r.lg,paddingVertical:r.md+r.xs/2},timelineBubble:{width:r.xxl+r.xs/2,height:r.xxl+r.xs/2,borderRadius:o.pill,backgroundColor:t.brandSoft,borderWidth:d,borderColor:t.brandBorder},timelineBody:{flex:1,gap:r.xs-1},timelineKind:{...k(e,"mono"),fontSize:l.micro,lineHeight:l.bodyTight,letterSpacing:n.letterSpacing.eyebrow/3,textTransform:"uppercase",color:t.text.secondary},timelineTitle:{...R(l.body,c.normal,t.text.primary,"medium")}})}i(mb,"makeStyles");function Us(e,t={}){let r=yr(),{userRef:o}=Te(),n=t.now??Date.now,[a,l]=useState(null),[c,s]=useState(true),[d,u]=useState(null),[p,f]=useState(null),b=p===true,[R,v]=useState({}),[w,g]=useState(false),[y,x]=useState(null),[h,P]=useState(false),[S,E]=useState(false),C=Wn(e),I=useRef(0),F=useRef(true),q=useCallback(async()=>{let D=I.current+=1;if(s(true),u(null),o===null){l(null),s(false);return}let L=await r.listShares(e);D!==I.current||!F.current||(L.ok?(l(L.value),f(true)):_r(L.error)?(l(null),f(false)):(l(null),u(L.error),Hd(L)&&f(true)),s(false));},[r,e,o]);useEffect(()=>(F.current=true,q(),()=>{F.current=false,I.current+=1;}),[q]);let j=useRef(C);useEffect(()=>{j.current!==C&&(j.current=C,v({}),E(true),q());},[C,q]);let $=useCallback(async()=>{g(true);let D=await r.createShare(e);return F.current&&(g(false),D.ok?(v(L=>({...L,[D.value.shareId]:D.value.shareUrl})),q()):_r(D.error)?f(false):ar(D.error)&&E(true)),D},[r,e,q]),ce=useCallback(async D=>{x(D);let L=await r.revokeShare(e,D);return F.current&&(x(null),q()),L},[r,e,q]),oe=useCallback(async()=>{P(true);let D=await r.getPdfLink(e);return F.current&&(P(false),!D.ok&&ar(D.error)&&E(true)),D},[r,e]),ve=useCallback(()=>{E(false),q();},[q]),ie=useMemo(()=>Wl(a??[],R,n()),[a,R,n]),T=c?"loading":d!==null?"error":ie.length===0?"empty":"populated";return useMemo(()=>({status:T,rows:ie,available:b,consentRequired:S,error:d,creating:w,revokingId:y,preparingPdf:h,createLink:$,revoke:ce,pdfLink:oe,refresh:ve}),[T,ie,b,S,d,w,y,h,$,ce,oe,ve])}i(Us,"useRecordShares");function Hd(e){return e.ok||e.error.httpStatus!==void 0&&e.error.httpStatus!==404}i(Hd,"answeredBehindGate");function Ud(e){return e.available||e.status!=="empty"}i(Ud,"sharesListShown");function js(e){let t=yr(),{userRef:r}=Te(),o=useMemo(()=>({}),[t,e,r]),[n,a]=useState({scope:o,lit:null});useEffect(()=>{if(r===null)return;let c=true;return t.listShares(e).then(s=>{c&&(!s.ok&&_r(s.error)?a({scope:o,lit:false}):Hd(s)&&a({scope:o,lit:true}));},()=>{}),()=>{c=false;}},[t,e,r,o]);let l=n.scope===o?n.lit:null;return useMemo(()=>({lit:l}),[l])}i(js,"useRecordsDepthProbe");function $s(e){let t=yr(),o=js(e).lit===true,[n,a]=useState(false),[l,c]=useState(null),s=useRef(true);useEffect(()=>(s.current=true,()=>{s.current=false;}),[]);let d=useCallback(async()=>{a(true),c(null);let u=await t.getPdfLink(e);return s.current&&(a(false),u.ok||c(u.error)),u},[t,e]);return useMemo(()=>({preparing:n,available:o,error:l,pdfLink:d}),[n,o,l,d])}i($s,"useRecordPdfLink");async function $d(e){await Share.share({message:ae.shareMessage(e),url:e});}i($d,"shareLinkViaOs");async function Qo(e){await Share.share(Platform.OS==="ios"?{url:e}:{message:e});}i(Qo,"shareFileLinkViaOs");var It=Z.document,Yd=Object.freeze(["medication","vaccination","problem","allergy","procedure","body_weight","vital"]),hb=i((e,t)=>e.getRecordDepth(t),"readDepth"),Rb=i(e=>!e.available,"depthEmpty");function Ws(e){let{style:t,renderPending:r,...o}=Le(e,["onBack"]);return jsx(Ve,{capability:"records",style:t,...r?{renderPending:r}:{},...Fe(o.onBack,Ye),children:jsx(wb,{...o,style:t})})}i(Ws,"EverfurRecordDocument");function vb(e,t){return e.identity.length===0&&e.entities.length===0&&e.forwardLooking.length===0&&(t===null||t.labResults.length===0&&t.physicalExams.length===0&&t.clinicianNotes.length===0)}i(vb,"documentIsEmpty");function wb({petRef:e,petName:t,controller:r,consentVersion:o,onBack:n,onOpenUrl:a,style:l}){let c=me(),s=Kd(),d=V(),u=st(r?{petRef:e,controller:r}:{petRef:e}),p=Yt(e,hb,Rb),f=$s(e),b=useMemo(()=>Hr(o,u.consent),[o,u.consent]),R=useMemo(()=>nn(u,o),[u,o]),v=p.value!==null&&!p.value.withheld&&p.value.available?p.value:null,w=u.record,[g,y]=useState(false),x=i(()=>{y(false),f.pdfLink().then(S=>{if(!S.ok)return;Lr(a??(C=>Qo(C)),S.value.downloadUrl,"record_pdf").then(C=>{!C.ok&&!a&&y(true);});});},"download"),h,P=false;if(u.status==="loading"||p.status==="loading"&&w!==null)h=jsx(View,{style:s.centered,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:yt.loading,testID:"record-document-loading",children:jsx(ActivityIndicator,{color:d.color.brandInk})});else if(u.status==="error"){let S=Pr(u,b);h=S.kind==="error"||S.kind==="pet_not_found"?jsx(Ue,{variant:mt(S.error),message:S.error.displayMessage,onAction:S.error.retryable?()=>{u.refresh(),p.refresh();}:void 0,testID:"record-document-error"}):rn(u,R,b);}else w===null||vb(w,v)?h=jsx(View,{style:s.centered,testID:"record-document-empty",children:jsx(m,{style:s.emptyText,children:It.empty})}):(P=true,h=jsx(xb,{record:w,depth:v,petName:t,wordmark:d.meta.displayName}));return jsxs(View,{style:[c.root,s.root,l],children:[jsx(Ke,{title:It.title,variant:"document",onBack:n,testID:"record-document-header",right:f.available&&P?jsx(Pressable,{onPress:x,disabled:f.preparing,accessibilityRole:"button",accessibilityLabel:It.download,accessibilityState:{disabled:f.preparing,busy:f.preparing},hitSlop:8,style:s.download,testID:"record-document-download",children:f.preparing?jsx(ActivityIndicator,{size:"small",color:d.color.brandInk}):jsx(Ml,{})}):void 0}),f.error?jsx(m,{style:[c.errorText,s.inset],accessibilityRole:"alert",children:f.error.displayMessage}):g?jsx(m,{style:[c.errorText,s.inset],accessibilityRole:"alert",testID:"record-document-share-failed",children:ae.toasts.pdfShareSheet}):null,jsx(View,{style:c.body,children:h}),jsx(qe,{})]})}i(wb,"DocumentBody");function xb({record:e,depth:t,petName:r,wordmark:o}){let n=Kd(),a=useMemo(()=>{let s=[],d=new Map;for(let f of e.entities){let b=f.category.trim();if(b.length===0)continue;let R=d.get(b);R===void 0?(s.push(b),d.set(b,[f])):R.push(f);}let u=Yd.filter(f=>s.includes(f)),p=s.filter(f=>!Yd.includes(f));return [...u,...p].map(f=>({type:f,rows:d.get(f)??[]}))},[e.entities]),l=Date.now(),c=i((s,d,u)=>jsxs(View,{style:n.section,testID:u,children:[jsxs(View,{style:n.sectionHeader,children:[jsx(m,{style:n.sectionTitle,accessibilityRole:"header",children:s}),jsx(View,{style:n.rule})]}),jsx(View,{children:d})]},u),"section");return jsxs(ScrollView,{contentContainerStyle:n.page,showsVerticalScrollIndicator:false,testID:"record-document",children:[jsxs(View,{style:n.letterhead,children:[jsx(m,{style:n.wordmark,children:o}),jsx(m,{style:n.docTitle,children:It.docTitle}),jsx(m,{style:n.petName,children:r?.trim()||It.namelessPet}),jsx(m,{style:n.generated,children:It.generated(e.generatedAt)})]}),e.identity.length>0?c(It.identity,e.identity.map((s,d)=>jsxs(View,{style:[n.row,d>0?n.rowDivider:null],children:[jsx(m,{style:n.rowLabel,children:s.label}),jsx(m,{style:n.rowValue,children:s.value})]},`${d}:${s.label}`)),"record-document-identity"):null,t&&t.labResults.length>0?c(It.labs,t.labResults.map((s,d)=>{let u=nr(s.latest.status),p=ud(s.points[s.points.length-1]??null),f=Tt(s.latest.value,s.latest.unit??s.unit,s.latest.qualitativeResult);return jsxs(View,{style:[n.row,u.outOfRange?n.rowFlag:null,d>0?n.rowDivider:null],children:[jsxs(View,{style:n.rowMain,children:[jsx(m,{style:n.rowLabel,children:s.name}),jsxs(m,{style:n.rowMeta,children:[p?It.ref(p):It.noRange,s.latest.at?` \xB7 ${J(s.latest.at)}`:""]})]}),jsxs(View,{style:n.rowRight,children:[f!=="-"?jsx(m,{style:[n.rowValue,u.outOfRange?n.rowValueAlert:null],children:f}):null,jsx(m,{style:[n.markerStatus,u.outOfRange?n.rowValueAlert:null],children:u.label})]})]},s.markerId)}),"record-document-labs"):null,a.map(({type:s,rows:d})=>c(jr(s),d.map((u,p)=>{let f=[Yr(u.value,u.unit),u.observedAt?J(u.observedAt):null].filter(b=>b&&b.length>0).join(" \xB7 ");return jsx(View,{style:[n.row,p>0?n.rowDivider:null],children:jsxs(View,{style:n.rowMain,children:[jsx(m,{style:n.rowLabel,children:u.label}),f?jsx(m,{style:n.rowMeta,children:f}):null]})},u.key)}),`record-document-${s}`)),e.forwardLooking.length>0?c(It.upcomingCare,e.forwardLooking.map((s,d)=>{let u=On(s.dueAt,l);return jsxs(View,{style:[n.row,d>0?n.rowDivider:null],children:[jsxs(View,{style:n.rowMain,children:[jsx(m,{style:n.rowLabel,children:s.title}),s.detail?jsx(m,{style:n.rowMeta,children:s.detail}):null]}),u?jsx(m,{style:[n.rowValue,u.overdue?n.rowValueAlert:null],children:u.label}):null]},`${s.title}-${d}`)}),"record-document-upcoming"):null,t&&t.physicalExams.length>0?c(It.physicalExams,t.physicalExams.map((s,d)=>jsxs(View,{style:[n.block,d>0?n.rowDivider:null],children:[s.observedOn?jsx(m,{style:n.blockDate,children:J(s.observedOn)}):null,s.systems.filter(u=>u.finding).map(u=>jsxs(View,{style:n.fieldRow,children:[jsx(m,{style:n.fieldLabel,children:qr(u.system)}),jsx(m,{style:n.fieldValue,children:u.finding})]},u.system))]},s.examId)),"record-document-exams"):null,t&&t.clinicianNotes.length>0?c(It.clinicianNotes,t.clinicianNotes.map((s,d)=>jsxs(View,{style:[n.block,d>0?n.rowDivider:null],children:[s.observedOn?jsx(m,{style:n.blockDate,children:J(s.observedOn)}):null,s.sections.filter(u=>u.text).map((u,p)=>jsxs(View,{style:n.noteSection,children:[jsx(m,{style:n.noteLabel,children:Qr(u.section)}),jsx(m,{style:n.noteBody,children:u.text})]},`${u.section}-${p}`))]},s.noteId)),"record-document-notes"):null,e.disclaimer.length>0?jsx(View,{style:n.disclaimer,children:jsx(m,{style:n.disclaimerText,children:e.disclaimer})}):null]})}i(xb,"RecordDocument");function Kd(){let e=V();return useMemo(()=>Cb(e),[e])}i(Kd,"useLocalStyles");function Cb(e){let{color:t,space:r,radius:o,type:n}=e,a=StyleSheet.hairlineWidth,l=i((s,d,u,p="regular")=>({...k(e,p),fontSize:s,lineHeight:Math.round(s*d),color:u}),"text"),c=i((s,d)=>({...k(e,"mono"),fontSize:s,lineHeight:s+r.xs-1,color:d,letterSpacing:n.letterSpacing.eyebrow/2,textTransform:"uppercase"}),"mono");return StyleSheet.create({root:{backgroundColor:t.surface},inset:{paddingHorizontal:r.lg},download:{width:r.xxl+r.xs+r.xs/2,height:r.xxl+r.xs+r.xs/2,borderRadius:o.pill,alignItems:"center",justifyContent:"center"},centered:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xxl,minHeight:r.xxl*3+r.xl},emptyText:{...l(n.size.body,n.lineHeight.normal,t.text.muted,"medium"),textAlign:"center"},page:{paddingHorizontal:r.lg+r.xs,paddingBottom:r.xxl+r.lg},letterhead:{alignItems:"center",paddingTop:r.md,paddingBottom:r.lg+r.xs+r.xs/2,borderBottomWidth:2,borderBottomColor:t.brandInk,gap:r.xs+r.xs/2,marginBottom:r.sm},wordmark:{...l(n.size.heading,n.lineHeight.snug,t.brandInk,"bold"),letterSpacing:n.letterSpacing.headerBrand},docTitle:{...c(n.size.caption,t.brandInk),marginTop:r.sm+r.xs/2,letterSpacing:n.letterSpacing.eyebrow+.4},petName:l(n.size.verdict+r.xs/2,n.lineHeight.tight,t.text.primary),generated:{...c(n.size.tiny,t.text.muted),textTransform:"none"},section:{marginTop:r.lg+r.xs+r.xs/2},sectionHeader:{flexDirection:"row",alignItems:"center",gap:r.sm+r.xs/2,marginBottom:r.sm},sectionTitle:c(n.size.tiny,t.brandInk),rule:{flex:1,height:a,backgroundColor:t.borderHairlineGreen},row:{flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between",gap:r.md+r.xs/2,paddingVertical:r.sm+1},rowDivider:{borderTopWidth:a,borderTopColor:t.borderHairlineGreen},rowFlag:{backgroundColor:t.badgeBgCritical,marginHorizontal:-r.sm,paddingHorizontal:r.sm,borderRadius:o.xs},rowMain:{flexShrink:1},rowRight:{alignItems:"flex-end",gap:r.xs/2},rowLabel:{flexShrink:1,...l(n.size.body,n.lineHeight.normal,t.text.primary,"medium")},rowValue:{...l(n.size.body,n.lineHeight.normal,t.text.primary,"bold"),textAlign:"right"},rowValueAlert:{color:t.danger},rowMeta:{marginTop:r.xs/2,...k(e,"mono"),fontSize:n.size.tiny,lineHeight:n.size.body,color:t.text.muted},markerStatus:c(n.size.micro,t.text.muted),block:{paddingVertical:r.sm+r.xs/2},blockDate:{...c(n.size.tiny,t.text.muted),marginBottom:r.xs+r.xs/2},fieldRow:{flexDirection:"row",alignItems:"flex-start",gap:r.md+r.xs/2,paddingVertical:r.xs-1},fieldLabel:{width:120,...l(n.size.bodyTight,n.lineHeight.normal,t.text.muted,"medium")},fieldValue:{flex:1,...l(n.size.bodyTight,n.lineHeight.normal,t.text.primary,"medium")},noteSection:{marginTop:r.sm},noteLabel:{...c(n.size.tiny,t.brandInk),marginBottom:r.xs/2},noteBody:l(n.size.bodyTight,n.lineHeight.relaxed,t.text.primary),disclaimer:{marginTop:o.xl,paddingTop:r.md+r.xs/2,borderTopWidth:a,borderTopColor:t.borderHairlineGreen},disclaimerText:l(n.size.tiny,n.lineHeight.relaxed,t.text.muted)})}i(Cb,"makeLocalStyles");function Zd({petRef:e,onClose:t,onNavigate:r,onOpenUrl:o,onCopy:n}){let a=Tb(),l=me(),c=Us(e),[s,d]=useState(null),[u,p]=useState(null),f=c.available&&!c.consentRequired,b=i((y,x)=>{let h=o??((S,E)=>E==="share_link"?$d(S):Qo(S)),P=x==="share_link"?ae.toasts.shareSheet:ae.toasts.pdfShareSheet;Lr(h,y,x).then(S=>{S.ok||d(P);});},"open"),R=i(()=>{d(null),c.createLink().then(y=>{y.ok?b(y.value.shareUrl,"share_link"):d(lo(y.error,"create"));});},"onCreateLink"),v=i(()=>{d(null),c.pdfLink().then(y=>{y.ok?b(y.value.downloadUrl,"record_pdf"):d(lo(y.error,"download"));});},"onDownload"),w=i(y=>{!n||y.shareUrl===null||Lr(n,y.shareUrl).then(x=>d(x.ok?ae.toasts.copied:ae.toasts.copyFailed));},"onCopyRow"),g=i(y=>{c.revoke(y).then(x=>{p(null),d(x.ok?ae.toasts.turnedOff:lo(x.error,"revoke"));});},"onConfirmRevoke");return jsx(Modal,{transparent:true,visible:true,animationType:"slide",onRequestClose:t,children:jsxs(View,{style:a.backdrop,children:[jsx(Pressable,{style:qo,accessibilityRole:"button",accessibilityLabel:ae.closeSheetA11y,onPress:t}),jsxs(View,{style:a.sheet,accessibilityViewIsModal:true,testID:"share-record-sheet",children:[jsx(View,{style:a.handle}),jsxs(View,{style:a.header,children:[jsxs(View,{style:a.headerText,children:[jsx(m,{style:a.title,accessibilityRole:"header",children:ae.title}),jsx(m,{style:a.helper,children:ae.helper})]}),jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:ae.close,onPress:t,hitSlop:12,style:a.closeButton,testID:"share-record-close",children:jsx(m,{style:a.closeGlyph,children:"\xD7"})})]}),jsxs(ScrollView,{style:a.scroll,contentContainerStyle:a.body,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:a.actions,children:[r?jsx(X,{label:ae.viewDocument,onPress:()=>{t(),r({name:"document"});},testID:"share-view-document"}):null,f?jsx(X,{label:c.creating?ae.creatingLink:ae.createLink,kind:"outline",busy:c.creating,onPress:R,testID:"share-create-link"}):null,f?jsx(X,{label:c.preparingPdf?ae.preparingPdf:ae.downloadPdf,kind:"outline",busy:c.preparingPdf,onPress:v,testID:"share-download-pdf"}):null]}),c.consentRequired?jsxs(View,{style:a.stateCard,testID:"share-consent-off",children:[jsx(m,{style:a.stateTitle,accessibilityRole:"header",children:ae.consentOffTitle}),jsx(m,{style:a.stateBody,children:ae.consentOffBody}),jsx(X,{label:ae.retry,kind:"outline",onPress:c.refresh,testID:"share-consent-retry"})]}):null,s?jsx(m,{style:a.notice,accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"share-notice",children:s}):null,Ud(c)?jsxs(View,{style:a.section,children:[jsx(m,{style:a.sectionLabel,accessibilityRole:"header",children:ae.activeLinks}),c.status==="loading"?jsx(Jl,{testID:"share-record-loading"}):c.status==="error"?jsxs(View,{style:a.stateCard,testID:"share-record-error",children:[jsx(m,{style:a.stateTitle,children:ae.errorTitle}),jsx(m,{style:a.stateBody,children:ae.errorBody}),jsx(X,{label:ae.retry,kind:"outline",onPress:c.refresh,testID:"share-record-retry"})]}):c.rows.length===0?jsxs(View,{style:a.stateCard,testID:"share-record-empty",children:[jsx(m,{style:a.stateTitle,children:ae.emptyTitle}),jsx(m,{style:a.stateBody,children:ae.emptyBody})]}):jsx(View,{style:a.list,children:c.rows.map(y=>jsxs(View,{style:a.row,testID:`share-row-${y.shareId}`,children:[jsxs(View,{accessible:true,accessibilityRole:"text",accessibilityLabel:y.a11yLabel,children:[jsxs(View,{style:a.statusLine,children:[jsx(View,{style:[a.statusDot,{backgroundColor:y.active?a.active.color:a.inactive.color}],accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsx(m,{style:a.status,children:y.statusLabel}),jsx(m,{style:a.expiry,children:y.expiryLabel})]}),y.createdLabel?jsx(m,{style:a.created,children:y.createdLabel}):null]}),y.shareUrl!==null&&!n?jsx(m,{selectable:true,style:a.url,testID:`share-url-${y.shareId}`,children:y.shareUrl}):null,u===y.shareId?jsxs(View,{style:a.confirm,testID:`share-revoke-confirm-${y.shareId}`,children:[jsx(m,{style:a.confirmText,children:ae.confirmTurnOff}),jsxs(View,{style:a.rowActions,children:[jsx(X,{label:c.revokingId===y.shareId?ae.turningOff:ae.turnOff,kind:"danger",busy:c.revokingId===y.shareId,onPress:()=>g(y.shareId),testID:`share-revoke-do-${y.shareId}`}),jsx(X,{label:ae.keep,kind:"outline",disabled:c.revokingId===y.shareId,onPress:()=>p(null),testID:`share-revoke-cancel-${y.shareId}`})]})]}):jsxs(View,{style:a.rowActions,children:[n?jsx(X,{label:ae.copyLink,kind:"outline",disabled:y.shareUrl===null,accessibilityLabel:ae.copyLinkA11y(y.actionContext),onPress:()=>w(y),testID:`share-copy-${y.shareId}`}):null,jsx(X,{label:ae.turnOff,kind:"danger",accessibilityLabel:ae.turnOffA11y(y.actionContext),onPress:()=>p(y.shareId),testID:`share-ask-revoke-${y.shareId}`})]})]},y.shareId))})]}):null]}),jsx(View,{style:l.inset})]})]})})}i(Zd,"ShareSheet");function Tb(){let e=V();return useMemo(()=>_b(e),[e])}i(Tb,"useStyles");function _b(e){let{color:t,space:r,radius:o,type:n}=e,a=r.xxl+r.md,l=StyleSheet.hairlineWidth,c=i((s,d,u,p="regular")=>({...k(e,p),fontSize:s,lineHeight:Math.round(s*d),color:u}),"text");return StyleSheet.create({active:{color:t.success},inactive:{color:t.text.muted},backdrop:{flex:1,justifyContent:"flex-end",backgroundColor:"rgba(0,0,0,0.4)"},sheet:{backgroundColor:t.surface,borderTopLeftRadius:o.xl-1,borderTopRightRadius:o.xl-1,paddingHorizontal:r.lg+r.xs+r.xs/2,paddingTop:r.md,paddingBottom:o.xl,maxHeight:"88%",gap:r.md},handle:{alignSelf:"center",width:r.xxl+r.xs,height:r.xs,borderRadius:o.pill,backgroundColor:t.borderRingCream},header:{flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between",gap:r.sm},headerText:{flex:1,gap:r.xs},title:{...c(n.size.heading,n.lineHeight.snug,t.text.primary,"bold")},helper:c(n.size.bodyTight,n.lineHeight.normal,t.text.muted),closeButton:{width:a,height:a,alignItems:"center",justifyContent:"center"},closeGlyph:c(n.size.verdict,n.lineHeight.tight,t.text.primary),scroll:{flexGrow:0},body:{gap:r.lg,paddingBottom:r.sm},actions:{gap:r.sm},notice:{...c(n.size.bodyTight,n.lineHeight.normal,t.text.secondary),padding:r.md,borderRadius:o.md-r.xs/2,backgroundColor:t.brandSoft},section:{gap:r.sm},sectionLabel:{...c(n.size.bodyTight,n.lineHeight.snug,t.text.secondary,"bold"),textTransform:"uppercase",letterSpacing:n.letterSpacing.eyebrow/2},stateCard:{gap:r.sm,padding:r.md,borderRadius:o.md,backgroundColor:t.surfaceCream,borderWidth:l,borderColor:t.brandBorder},stateTitle:{...c(n.size.body,n.lineHeight.snug,t.text.primary,"bold")},stateBody:c(n.size.bodyTight,n.lineHeight.normal,t.text.muted),list:{gap:r.md},row:{gap:r.sm,padding:r.md,borderRadius:o.md,backgroundColor:t.surfaceCream,borderWidth:l,borderColor:t.brandBorder},statusLine:{flexDirection:"row",alignItems:"center",gap:r.sm},statusDot:{width:r.sm,height:r.sm,borderRadius:r.xs},status:{...c(n.size.bodyTight,n.lineHeight.snug,t.text.primary,"bold")},expiry:{...c(n.size.caption,n.lineHeight.normal,t.text.muted)},created:c(n.size.tiny,n.lineHeight.normal,t.text.muted),url:{...c(n.size.caption,n.lineHeight.normal,t.text.secondary,"mono")},rowActions:{flexDirection:"row",flexWrap:"wrap",gap:r.sm},confirm:{gap:r.sm},confirmText:{...c(n.size.bodyTight,n.lineHeight.normal,t.text.primary,"medium")}})}i(_b,"makeStyles");var Db=i((e,t)=>e.getRecordDepth(t),"readDepth"),Ab=i(e=>!e.available,"depthEmpty");function Ks(e){let{style:t,renderPending:r,...o}=Le(e,["onNavigate","onBack","onAsk"]);return jsx(Ve,{capability:"records",style:t,...r?{renderPending:r}:{},...Fe(o.onBack,Ye),children:jsx(Ob,{...o,style:t})})}i(Ks,"EverfurRecordDetail");function Ob({petRef:e,petName:t,controller:r,consentVersion:o,onNavigate:n,onBack:a,onAsk:l,onOpenUrl:c,onCopy:s,style:d}){let u=me(),p=Lb(),f=st(r?{petRef:e,controller:r}:{petRef:e}),b=Yt(e,Db,Ab),R=Ss(e),v=js(e),[w,g]=useState(false),y=useMemo(()=>Hr(o,f.consent),[o,f.consent]),x=useMemo(()=>nn(f,o),[f,o]),h=b.value!==null&&!b.value.withheld&&b.value.available?b.value:null,P=f.record,S=i(()=>{f.refresh(),b.refresh();},"retry"),E=n!==void 0||v.lit===true,C;if(f.status==="loading"||b.status==="loading"&&P!==null&&!P.isEmpty)C=jsx(po,{testID:"everfur-record-loading"});else if(f.status==="error"){let I=Pr(f,y);C=I.kind==="error"||I.kind==="pet_not_found"?jsx(Ue,{variant:mt(I.error),message:I.error.displayMessage,onAction:I.error.retryable?S:void 0,testID:"everfur-record-error"}):rn(f,x,y);}else if(P===null||P.isEmpty){let I=h?.completeness?.documentsInReview??0;C=jsxs(ScrollView,{contentContainerStyle:u.content,testID:"everfur-record-empty",children:[jsx(Ue,{variant:"no_records",message:I>0?Z.inReview(I):void 0}),jsx(Tr,{disclaimer:P?.disclaimer??""})]});}else C=jsx(ScrollView,{contentContainerStyle:p.content,testID:"everfur-record",children:jsx(Mo,{record:P,depth:h,petName:t,onNavigate:n,onAsk:l,factEdit:R})});return jsxs(View,{style:[u.root,d],children:[jsx(Ke,{title:Z.title,onBack:a,testID:"everfur-record-header",right:E||n?jsxs(Fragment,{children:[n?jsx(Pressable,{onPress:()=>n({name:"clinicBatch"}),accessibilityRole:"button",accessibilityLabel:Z.requestClinicsA11y,hitSlop:8,style:p.share,testID:"everfur-record-request-clinics",children:jsx(Nl,{})}):null,E?jsx(Pressable,{onPress:()=>g(true),accessibilityRole:"button",accessibilityLabel:Z.shareA11y,hitSlop:8,style:p.share,testID:"everfur-record-share",children:jsx(Fl,{})}):null]}):void 0}),jsx(View,{style:u.body,children:C}),w?jsx(Zd,{petRef:e,onClose:()=>g(false),onNavigate:n,...c?{onOpenUrl:c}:{},...s?{onCopy:s}:{}}):null,jsx(qe,{})]})}i(Ob,"RecordBody");function Lb(){let e=V();return useMemo(()=>Vb(e),[e])}i(Lb,"useLocalStyles");function Vb(e){let{space:t,radius:r}=e;return StyleSheet.create({content:{paddingHorizontal:t.lg,paddingBottom:t.xxl+t.sm,gap:t.lg+t.xs},share:{width:t.xxl+t.sm,height:t.xxl+t.sm,borderRadius:r.pill,alignItems:"center",justifyContent:"center"}})}i(Vb,"makeLocalStyles");function nu(e,t){let r=V(),[o,n]=useState(false),a=useCallback(()=>{n(true),e().finally(()=>n(false));},[e]);return jsx(RefreshControl,{refreshing:o,onRefresh:a,tintColor:r.color.brandInk,colors:[r.color.brandInk],testID:t})}i(nu,"useRecordsPullToRefresh");function Xs(e){let{style:t,renderPending:r,...o}=Le(e,["onNavigate","onBack"]);return jsx(Ve,{capability:"records",style:t,...r?{renderPending:r}:{},...Fe(o.onBack,Ye),children:jsx(Ub,{...o,style:t})})}i(Xs,"EverfurRecordsUpload");function Ub({petRef:e,petName:t,controller:r,onPickDocument:o,uploadTransport:n,onNavigate:a,onBack:l,style:c}){let s=me(),d=au(),{runtime:u}=Te(),p=st(r?{petRef:e,controller:r}:n?{petRef:e,uploadTransport:n}:{petRef:e}),f=Dn(o)&&(r!==void 0||n!==void 0||Un(u.registry.services.uploadTransport));return jsxs(View,{style:[s.root,c],children:[jsx(Ke,{title:"",onBack:l,testID:"upload-header"}),jsxs(ScrollView,{contentContainerStyle:d.content,testID:"upload-screen",children:[jsxs(View,{style:d.header,children:[jsx(View,{style:d.iconBubble,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsx(m,{style:d.title,accessibilityRole:"header",children:Ze.title(t)}),jsx(m,{style:d.subtitle,children:Ze.subtitle(t)})]}),jsx(Js,{records:p,requestId:null,onPickDocument:o,canUpload:f,onDone:a?b=>a({name:"request",requestId:b}):void 0})]}),jsx(qe,{})]})}i(Ub,"UploadBody");function Js({records:e,requestId:t,onPickDocument:r,canUpload:o,onDone:n}){let a=me(),l=au(),[c,s]=useState(null),[d,u]=useState(0),p=useRef(t),f=useRef([]),b=e.uploadQueue.filter(h=>h.status!=="skipped"),R=b.filter(h=>h.status==="done").length,v=b.filter(h=>h.status==="failed").length,w=!e.isUploading&&d>0,g=useCallback(async h=>{let{uploadable:P,skipped:S}=Ma(h),E=Bo(S);if(P.length===0){E!==null&&s(E);return}s(E);let C=p.current;if(C===null){let F=await e.createRequest(`records-upload-${Date.now().toString(36)}`);if(!F.ok){s(Ze.errors.start);return}C=F.value.id,p.current=C;}u(F=>F+1);let I=await e.uploadDocuments(C,P);f.current=I.flatMap((F,q)=>F.status==="failed"&&P[q]!==void 0?[P[q]]:[]);},[e]),y=useCallback(()=>{!r||!o||Lr(r).then(h=>{if(!h.ok){s(Ze.errors.startPlain);return}let P=h.value;P!==null&&g(Array.isArray(P)?P:[P]);});},[r,o,g]),x=useCallback(()=>{g(f.current);},[g]);return jsxs(View,{style:l.card,testID:"records-upload-card",children:[jsx(m,{style:l.cardTitle,accessibilityRole:"header",children:Ze.cardTitle}),jsx(m,{style:l.cardSubtitle,children:Ze.cardSubtitle}),c?jsx(View,{style:a.errorBanner,accessibilityRole:"alert",children:jsx(m,{style:a.errorText,children:c})}):null,jsx(Pd,{records:e}),e.isUploading?jsx(View,{style:l.uploadingRow,children:jsx(m,{style:l.progressText,children:Ze.uploading(R,b.length)})}):w?jsxs(View,{style:l.settled,children:[R>0?jsx(m,{style:l.success,accessibilityRole:"alert",children:Ze.received(R)}):null,v>0?jsx(X,{label:Ze.retryFailed(v),kind:"link",accessibilityLabel:Ze.retryFailedA11y(v),onPress:x,testID:"records-upload-retry-failed"}):null,jsxs(View,{style:l.settledActions,children:[jsx(X,{label:Ze.addMore,kind:"link",accessibilityLabel:Ze.addMoreA11y,disabled:!o,onPress:y,testID:"records-upload-another"}),n&&p.current!==null&&R>0?jsx(X,{label:Ze.done,accessibilityLabel:Ze.doneA11y,onPress:()=>n(p.current),testID:"records-upload-done"}):null]})]}):jsx(X,{label:Ze.chooseFiles,accessibilityLabel:Ze.chooseFilesA11y,disabled:!o,onPress:y,testID:"records-upload-choose"})]})}i(Js,"UploadRecordCard");function au(){let e=V();return useMemo(()=>jb(e),[e])}i(au,"useLocalStyles");function jb(e){let{color:t,space:r,radius:o,type:n}=e,a=i((l,c,s,d="regular")=>({...k(e,d),fontSize:l,lineHeight:Math.round(l*c),color:s}),"text");return StyleSheet.create({content:{padding:r.lg+r.xs,gap:r.lg+r.xs},header:{gap:r.sm,alignItems:"center"},iconBubble:{width:r.xxl+r.lg+r.xs,height:r.xxl+r.lg+r.xs,borderRadius:o.pill,backgroundColor:t.brandSoft,borderWidth:StyleSheet.hairlineWidth,borderColor:t.brandBorder,marginBottom:r.xs},title:{...a(n.size.heading+r.xs/2,n.lineHeight.snug,t.brandInk,"bold"),textAlign:"center"},subtitle:{...a(n.size.body,n.lineHeight.normal,t.text.muted),textAlign:"center",maxWidth:340},card:{borderRadius:o.md,backgroundColor:t.surface,borderWidth:1,borderColor:t.brandSoft,padding:r.lg,gap:r.md},cardTitle:{...a(n.size.subtitle,n.lineHeight.snug,t.text.primary,"bold")},cardSubtitle:a(n.size.bodyTight,n.lineHeight.normal,t.text.muted),uploadingRow:{flexDirection:"row",alignItems:"center",gap:r.sm},progressText:{flex:1,...a(n.size.bodyTight,n.lineHeight.normal,t.text.secondary)},settled:{gap:r.sm},success:a(n.size.bodyTight,n.lineHeight.normal,t.text.primary),settledActions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:r.sm}})}i(jb,"makeLocalStyles");function ea(e){let{style:t,renderPending:r,...o}=Le(e,["onNavigate","onBack"]);return jsx(Ve,{capability:"records",style:t,...r?{renderPending:r}:{},...Fe(o.onBack,Ye),children:jsx(Xb,{...o,style:t})})}i(ea,"EverfurRecordsRequest");function Xb({petRef:e,requestId:t,controller:r,onPickDocument:o,uploadTransport:n,onNavigate:a,onBack:l,style:c,nowMs:s}){let d=me(),{runtime:u,userRef:p,scopeEpoch:f}=Te(),b=st(r?{petRef:e,controller:r}:n?{petRef:e,uploadTransport:n}:{petRef:e}),R=b.requests.find(x=>x.id===t)??null,v=Dn(o)&&(r!==void 0||n!==void 0||Un(u.registry.services.uploadTransport)),w=R?To(R):"",g=nu(b.refresh,"records-request-refresh"),y;return b.status==="loading"&&R===null?y=jsx(mo,{testID:"records-request-loading"}):b.status==="error"&&b.error?y=jsx(Ue,{variant:mt(b.error),message:b.error.displayMessage,onAction:b.error.retryable?b.refresh:void 0,testID:"records-request-error"}):R===null?y=jsx(Ue,{variant:"no_requests",testID:"records-request-missing"}):p===null?y=jsx(Ue,{variant:"error",testID:"records-request-error"}):y=jsx(Jb,{request:R,records:b,canUpload:v,onPickDocument:o,onNavigate:a,nowMs:s,refreshControl:g},JSON.stringify([p,f,R.id])),jsxs(View,{style:[d.root,c],children:[jsx(Ke,{title:w,onBack:l,testID:"records-request-header"}),jsx(KeyboardAvoidingView,{behavior:"padding",style:d.body,children:y}),jsx(qe,{})]})}i(Xb,"RequestBody");function Jb({request:e,records:t,canUpload:r,onPickDocument:o,onNavigate:n,nowMs:a,refreshControl:l}){let c=me(),s=Zb(),d=V(),u=Ed({request:e,onRecovered:t.refresh,canUpload:r},Ut()),[p,f]=useState(null),[b,R]=useState(false),[v,w]=useState(null),g=useRef(true);useEffect(()=>(g.current=true,()=>{g.current=false;}),[]);let y=u.request,x=a??Date.now(),h=y.status==="published",P=y.status==="published"||y.status==="failed"||y.status==="revoked",S=Pi(y),E=y.wireStatus==="clinic_responded_no_records",C=sl(y,x),I=_i(y,x),F=P?null:y.waitingExpectation?.trim()||null,q=_o(y),j=al(y),$=u.canConvert,ce=P&&!h,oe=u.error!==null&&p!==null&&p!=="start"?p==="revoke"?he.errors.cancel:he.errors[p]:null,ve=i((T,D)=>{f(T),D();},"run"),ie=i(()=>{b||(R(true),w(null),t.createRequest(`records-upload-${Date.now().toString(36)}`).then(T=>{if(g.current){if(R(false),!T.ok){w(he.errors.start);return}n?.({name:"request",requestId:T.value.id});}}));},"startFresh");return jsxs(ScrollView,{contentContainerStyle:s.content,keyboardShouldPersistTaps:"handled",refreshControl:l,testID:`records-request-${y.id}`,children:[jsx(jo,{request:y}),y.status==="awaiting_upload"?jsx(Js,{records:t,requestId:y.id,onPickDocument:o,canUpload:r}):null,y.statusLabel.length>0?jsx(View,{style:c.statusCard,accessibilityRole:"summary",children:jsx(m,{style:c.statusText,children:y.statusLabel})}):null,F&&!C?jsx(View,{style:c.infoNote,accessibilityRole:"summary",children:jsx(m,{style:c.infoNoteText,children:F})}):y.wireStatus==="awaiting_response"&&!C?jsx(View,{style:c.infoNote,accessibilityRole:"summary",children:jsx(m,{style:c.infoNoteText,children:he.awaitingNote})}):null,C?jsx(View,{style:c.cautionNote,accessibilityRole:"summary",testID:"records-request-waiting-banner",children:jsx(m,{style:c.cautionNoteText,children:he.waitingBanner(I)})}):null,h&&n?jsx(X,{label:he.viewRecords,onPress:()=>n({name:"dashboard"}),style:s.readyCta,testID:"records-request-view-dashboard"}):null,j?jsxs(View,{style:[s.failureCard,S?s.failureCritical:s.failureCaution],accessibilityRole:"summary",testID:"records-failure-card",children:[jsx(m,{style:[s.failureTitle,S?s.failureTitleCritical:s.failureTitleCaution],children:il(y)}),y.canUpdateClinicEmail!==true&&y.canRetrySend!==true?jsx(m,{style:c.rowDetail,children:he.nextStep}):null,y.canUpdateClinicEmail===true?jsxs(View,{style:s.emailBlock,children:[jsx(m,{style:c.fieldLabel,children:zt.email}),jsx(He,{style:c.field,accessibilityLabel:zt.email,placeholder:zt.emailPlaceholder,placeholderTextColor:d.color.text.placeholder,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,maxLength:320,value:u.email,editable:!u.busy,onChangeText:u.setEmail,testID:"records-failure-clinic-email"}),u.emailInvalid?jsx(m,{style:c.errorText,accessibilityRole:"alert",children:he.errors.invalidEmail}):null,jsx(X,{label:zt.updateEmail,accessibilityLabel:zt.updateEmailA11y,disabled:!u.canUpdateEmail,busy:u.busy&&p==="email",onPress:()=>ve("email",u.updateEmail),testID:"records-failure-update-email"})]}):null,y.canRetrySend===true?jsx(X,{label:zt.retry,kind:"outline",accessibilityLabel:zt.retryA11y,disabled:!u.canRetry,busy:u.busy&&p==="retry",onPress:()=>ve("retry",u.retry),testID:"records-failure-retry-send"}):null,y.canRetrySend===true&&u.hasEmailEdit?jsx(m,{style:c.rowDetail,children:zt.retryHint}):null,oe&&(p==="email"||p==="retry")?jsx(View,{style:c.errorBanner,accessibilityRole:"alert",children:jsx(m,{style:c.errorText,children:oe})}):null]}):null,(S||E)&&n?jsx(X,{label:he.tryAnotherClinic,kind:"outline",accessibilityLabel:he.tryAnotherClinicA11y,onPress:()=>n({name:"clinicPicker"}),testID:"records-request-try-another-clinic"}):null,q!==null?jsxs(View,{style:s.callBlock,children:[jsx(Id,{call:q,prompt:y.statusLabel}),y.canRetrySend===true?jsx(X,{label:u.busy&&p==="retry"?he.resending:he.resend,kind:"outline",accessibilityLabel:u.busy&&p==="retry"?he.resendingA11y:he.resendA11y,disabled:!u.canRetry,onPress:()=>ve("retry",u.retry),testID:"records-resend-authorization"}):null]}):null,$?jsxs(View,{style:s.block,children:[jsx(X,{label:u.busy&&p==="convert"?he.converting:he.convert,busy:u.busy&&p==="convert",onPress:()=>ve("convert",u.convert),testID:"records-convert-upload"}),jsx(m,{style:c.muted,children:he.convertHint}),oe&&p==="convert"?jsx(View,{style:c.errorBanner,accessibilityRole:"alert",children:jsx(m,{style:c.errorText,children:oe})}):null]}):null,ce?jsxs(View,{style:s.block,children:[jsx(X,{label:b?he.freshUploadStarting:he.freshUpload,kind:S||E?"outline":"primary",busy:b,onPress:ie,testID:"records-upload-own-fresh"}),v?jsx(View,{style:c.errorBanner,accessibilityRole:"alert",children:jsx(m,{style:c.errorText,children:v})}):null]}):null,oe&&p==="revoke"?jsx(View,{style:c.errorBanner,accessibilityRole:"alert",children:jsx(m,{style:c.errorText,children:oe})}):null,y.canRevoke===true?u.confirmingRevoke?jsxs(View,{style:s.block,testID:"records-revoke-confirm",children:[jsx(m,{style:s.confirmTitle,accessibilityRole:"header",children:zt.cancelQuestion}),jsx(m,{style:c.bodyText,children:zt.cancelConsequence}),jsx(X,{label:u.busy&&p==="revoke"?he.cancelling:he.cancel,kind:"danger",accessibilityLabel:u.busy&&p==="revoke"?he.cancellingA11y:he.cancelA11y,busy:u.busy&&p==="revoke",onPress:()=>ve("revoke",u.revoke),testID:"records-revoke-do"}),jsx(X,{label:zt.keepRequest,kind:"outline",disabled:u.busy,onPress:u.keepRequest,testID:"records-revoke-keep"})]}):jsx(X,{label:he.cancel,kind:"danger",accessibilityLabel:he.cancelA11y,disabled:u.busy,onPress:u.askRevoke,testID:"records-revoke"}):null]})}i(Jb,"RequestDetail");function Zb(){let e=V();return useMemo(()=>eh(e),[e])}i(Zb,"useLocalStyles");function eh(e){let{color:t,space:r,radius:o,type:n}=e,a=i((l,c,s,d="regular")=>({...k(e,d),fontSize:l,lineHeight:Math.round(l*c),color:s}),"text");return StyleSheet.create({content:{paddingHorizontal:r.lg,paddingBottom:r.xxl,gap:r.lg+r.xs/2},readyCta:{minHeight:r.xxl+r.lg+r.xs/2},failureCard:{borderRadius:o.lg-r.xs,borderWidth:1,padding:r.md+r.xs/2,gap:r.md},failureCritical:{borderColor:t.badgeBgCritical,backgroundColor:t.badgeBgCritical},failureCaution:{borderColor:t.badgeBgCaution,backgroundColor:t.badgeBgCaution},failureTitle:{...a(n.size.body,n.lineHeight.snug,t.text.primary,"bold")},failureTitleCritical:{color:t.danger},failureTitleCaution:{color:t.warningStrong},emailBlock:{gap:r.sm},callBlock:{gap:r.sm},block:{gap:r.sm},confirmTitle:{...a(n.size.subtitle,n.lineHeight.snug,t.text.primary,"bold")}})}i(eh,"makeLocalStyles");function lu(e){let{petRef:t,petName:r,controller:o,clinicController:n,onPickDocument:a,uploadTransport:l,consentVersion:c,ownerName:s,onCaptureSignature:d,initialScreen:u,onExit:p,style:f,renderPending:b,onOpenUrl:R,onCopy:v,onAsk:w,location:g}=Le(e,["onExit"]),[y,x]=useReducer(vi,u,Xn),h=Jn(y),P=y.stack.length;useEffect(()=>{let j=i(()=>P<=1?false:(x({type:"pop"}),true),"onBackPress"),$=BackHandler.addEventListener("hardwareBackPress",j);return ()=>{$.remove();}},[P]);let S=useCallback(j=>x({type:"navigate",screen:j}),[]),E=useMemo(()=>Zn(y).handled?()=>x({type:"pop"}):p,[y,p]),C={onNavigate:S,...E?{onBack:E}:{},...r!==void 0?{petName:r}:{},...R?{onOpenUrl:R}:{},...v?{onCopy:v}:{},...w?{onAsk:w}:{},...g?{location:g}:{}},I={...o?{controller:o}:{},...c!==void 0?{consentVersion:c}:{}},F={...a?{onPickDocument:a}:{},...l?{uploadTransport:l}:{}},q=b?{renderPending:b}:{};switch(h.name){case "dashboard":return jsx(Ms,{petRef:t,...C,...I,...q,style:f});case "request":return jsx(ea,{petRef:t,requestId:h.requestId,...C,...I,...F,...q,style:f});case "timeline":return jsx(Nd,{petRef:t,...C,style:f});case "record":return jsx(Ks,{petRef:t,...C,...I,...q,style:f});case "document":return jsx(Ws,{petRef:t,...C,...I,...q,style:f});case "contributions":return jsx(Md,{petRef:t,docId:h.docId,...C,style:f});case "clinicPicker":return jsx(Wi,{petRef:t,...C,...n?{controller:n}:{},...o?{recordsController:o}:{},style:f});case "clinicBatch":return jsx(ls,{petRef:t,petName:r??"",ownerName:s??"",...E?{onClose:E}:{},onCreated:()=>x({type:"navigate",screen:{name:"dashboard"}}),...d?{onCaptureSignature:d}:{},...n?{controller:n}:{},style:f});case "consent":return jsx(bs,{petRef:t,clinic:h.clinic,...C,...s!==void 0?{ownerName:s}:{},...d?{onCaptureSignature:d}:{},...n?{controller:n}:{},style:f});case "upload":return jsx(Xs,{petRef:t,...C,...o?{controller:o}:{},...F,...q,style:f});case "requests":return jsx(qs,{petRef:t,...C,...o?{controller:o}:{},...q,style:f});default:return vr(h)}}i(lu,"EverfurRecordsFlow");var sh=lu;function dh(e){let{userRef:t,scopeEpoch:r}=Te();return jsx(Ve,{capability:"recordsClinic",...Fe(e.onClose,K.cancel),children:t===null?jsx(m,{accessibilityRole:"alert",children:ye.sessionRequired}):jsx(uh,{...Le(e,["onClose","onCreated"])},JSON.stringify([t,r,e.petRef,e.petName]))})}i(dh,"EverfurClinicRequest");function uh(e){let t=Ut(),[r,o]=useState(null),n=useCallback(async()=>r===null?null:{signaturePngBase64:r},[r]),a=ec(e,e.controller??t,e.onCaptureSignature??n),l=e.onCaptureSignature!==void 0||r!==null,c=V(),s={minHeight:44,padding:c.space.sm,borderWidth:1,borderColor:c.color.borderHairlineGreen,borderRadius:c.radius.sm,color:c.color.text.primary,backgroundColor:c.color.surface},d={color:c.color.text.primary,fontSize:c.type.size.body},u=i((p,f,b=false)=>jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:p,accessibilityState:{disabled:b},disabled:b,onPress:f,style:[s,{justifyContent:"center",opacity:b?.5:1}],children:jsx(m,{style:d,children:p})}),"button");return jsxs(View,{accessibilityLabel:K.title,style:[{backgroundColor:c.color.surface,padding:c.space.lg,gap:c.space.md,borderRadius:c.radius.lg,minHeight:120},e.style],children:[jsx(m,{accessibilityRole:"header",style:[d,{...k(c,"bold"),fontSize:c.type.size.heading}],children:K.title}),jsx(m,{style:d,children:e.petName}),a.created?jsx(m,{accessibilityLiveRegion:"polite",style:d,children:a.created.statusLabel||ye.records}):jsxs(Fragment,{children:[jsx(m,{style:d,children:K.ownerName}),jsx(He,{accessibilityLabel:K.ownerName,style:s,value:a.ownerName,maxLength:200,editable:!a.busy,autoComplete:"name",onChangeText:a.setOwnerName}),jsx(m,{style:d,children:K.clinic}),jsx(He,{accessibilityLabel:K.clinic,style:s,value:a.query,placeholder:K.placeholder,placeholderTextColor:c.color.text.placeholder,maxLength:200,editable:!a.busy,onChangeText:a.setQuery}),u(K.search,()=>{a.search();},a.busy||a.searching||a.query.trim().length<2),a.searching&&jsx(m,{accessibilityLiveRegion:"polite",style:d,children:ye.loading}),a.recent.length>0&&jsx(m,{accessibilityRole:"header",style:d,testID:"records-clinic-recent-label",children:K.recentlyUsed}),a.recent.map(p=>jsx(View,{children:u([p.name,p.address,p.phone].filter(Boolean).join(", "),()=>a.selectClinic(p),a.busy)},`recent-${p.id}`)),a.clinics.map(p=>jsx(View,{children:u([p.name,p.address,p.phone].filter(Boolean).join(", "),()=>a.selectClinic(p),a.busy)},p.id)),a.needsEmail&&jsxs(Fragment,{children:[jsx(m,{style:d,children:K.email}),jsx(He,{accessibilityLabel:K.email,style:s,value:a.email,placeholder:K.emailPlaceholder,placeholderTextColor:c.color.text.placeholder,maxLength:320,editable:!a.busy,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,onChangeText:a.setEmail})]}),jsx(m,{accessibilityRole:"header",style:d,children:K.scopeHeading}),a.copy?jsx(m,{style:d,children:a.query.trim()&&a.ownerName.trim()?a.scope??N("internalError").displayMessage:ye.consentRequired}):!a.error&&jsx(m,{accessibilityLiveRegion:"polite",style:d,children:ye.loading}),!e.onCaptureSignature&&jsx(Mr,{onChange:o,disabled:a.busy}),!l&&jsx(m,{accessibilityRole:"alert",style:d,children:K.missingSignature}),a.error&&jsx(m,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:d,children:a.error.displayMessage}),!a.copy&&a.error&&u(ye.retry,a.retryCopy),u(a.busy?K.sending:K.send,()=>{a.submit();},a.busy||!a.ready||!l)]}),e.onClose&&u(K.cancel,e.onClose,a.busy),jsx(qe,{})]})}i(uh,"ClinicRequestBody");
4
- export{Wi as EverfurClinicPicker,dh as EverfurClinicRequest,ls as EverfurClinicRequestBatch,Ks as EverfurRecordDetail,Ws as EverfurRecordDocument,sh as EverfurRecords,bs as EverfurRecordsConsent,Ms as EverfurRecordsDashboard,lu as EverfurRecordsFlow,ea as EverfurRecordsRequest,qs as EverfurRecordsRequests,Xs as EverfurRecordsUpload,Gr as RECORDS_CLINIC_BATCH_MAX,wa as RECORDS_TERMINAL,qn as REQUEST_TIMELINE_TITLES,Mr as SignaturePad,Es as applyFactOverlay,Ds as buildRequestTimeline,Jn as currentRecordsScreen,ki as deriveRecordsDashboardState,Xn as initialRecordsNav,Oo as isFactEditable,br as isTerminalStatus,ro as pickPetRecordsRequest,Zn as popRecordsNav,bi as pushRecordsNav,hr as recordsDenialReasonOf,vi as recordsNavReducer,Ki as registerRnSignature,hi as replaceRecordsNav,Ri as resetRecordsNav,_o as selectClinicCall,Ti as selectDashboardView,Ur as selectPrimaryLabel,ws as selectRequestList,To as selectRequestTitle,Ua as transitionRecordsNav,st as useEverfurRecords,Ut as useEverfurRecordsClinic,Ai as useEverfurRecordsClinicBatch,Ss as useRecordFactEdit,$s as useRecordPdfLink,Us as useRecordShares,ys as useRecordsMarkers};
3
+ `):null,H=g.length>0&&g.every(le=>!Fn(le)||Ky.test(le.email.trim())),N=g.length>=tn,ie=!!(R&&J&&l.trim()&&e.petName.trim()&&H&&o)&&k===null,Ce=i(async()=>{if(de.current)return;let le=++G.current;T(true);try{let Pe=await t.searchClinics({query:c.trim(),limit:_o});if(!z.current||le!==G.current)return;Pe.ok?(u(Pe.value.clinics),b(null)):b(Pe.error);}catch{z.current&&le===G.current&&b(W("internalError"));}finally{z.current&&le===G.current&&T(false);}},"search"),Le=i(le=>{de.current||N||k!==null||le.clinic!==null&&g.some(Pe=>Pe.clinic?.id===le.clinic?.id)||(D(),w(Pe=>[...Pe,{...le,key:M.current(),idempotencyKey:M.current()}]),u([]),s(""));},"add"),rt=i(async()=>{if(de.current||k!==null||!ie||!R||!J||!o)return;de.current=true;let le=ae.current,Pe=i(()=>z.current&&ae.current===le,"current");h(true),b(null);try{if($.current===null){O.current=new AbortController;let Dt=await o({petRef:e.petRef,petName:e.petName,ownerName:l.trim(),clinicName:q.join(", "),authorizationVersion:R.authorizationVersion,scopeText:J,signal:O.current.signal});if(!Pe()||Dt===null)return;if($.current=Dt,Dt.signaturePngBase64!==void 0&&n!==void 0){let Nu=await n(Dt.signaturePngBase64,O.current.signal);if(!Pe())return;$.current={signatureId:Nu.signatureId};}}let Kt=$.current,fn=g.map(Dt=>({...Dt.clinic!==null&&(!Fn(Dt)||Dt.clinic.emailStatus==="none")?{clinicId:Dt.clinic.id}:{clinicFreeText:qn(Dt)},...Fn(Dt)?{clinicEmail:Dt.email.trim().toLowerCase()}:{},...Kt.signatureId!==void 0?{signatureId:Kt.signatureId}:{signaturePngBase64:Kt.signaturePngBase64},idempotencyKey:Dt.idempotencyKey})),gn=await r.createClinicRequestBatch({petRef:e.petRef,ownerName:l.trim(),authorizationVersion:R.authorizationVersion,clinics:fn});if(!Pe())return;if(!gn.ok){b(gn.error);return}_(gn.value),e.onCreated?.(gn.value),Ee(gn.value.requestGroupId,le);}catch{Pe()&&b(W("internalError"));}finally{de.current=false,Pe()&&h(false);}},"submit"),Ee=i(async(le,Pe)=>{try{let Kt=await t.getRequestGroup(le);if(!z.current||ae.current!==Pe)return;Kt.ok&&Kt.value.petRef===e.petRef&&B(Kt.value);}catch{}},"loadGroup"),Tt=i(async()=>{k===null||de.current||await Ee(k.requestGroupId,ae.current);},"refreshGroup");return {ownerName:l,query:c,clinics:d,copy:R,scopeText:J,error:f,busy:C,searching:I,drafts:g,outcome:k,group:E,ready:ie,atCap:N,visibleClinics:U.visible,hasMoreClinics:U.hasMore,showMoreClinics:U.showMore,recent:d.length===0?m.filter(le=>!g.some(Pe=>Pe.clinic?.id===le.id)):[],setOwnerName(le){de.current||(D(),a(le));},setQuery(le){de.current||(G.current+=1,T(false),u([]),s(le));},search:Ce,addClinic(le){Le({clinic:le,freeText:null,email:""});},addFreeText(){let le=c.trim();le.length!==0&&Le({clinic:null,freeText:le,email:""});},setDraftEmail(le,Pe){de.current||(D(),w(Kt=>Kt.map(fn=>fn.key===le?{...fn,email:Pe}:fn)));},removeDraft(le){de.current||k!==null||(D(),w(Pe=>Pe.filter(Kt=>Kt.key!==le)));},submit:rt,refreshGroup:Tt,retryCopy(){b(null),A(le=>le+1);}}}i(Fc,"useClinicBatchForm");function qc(e){try{let t=new URL(e);if(t.protocol!=="https:"||t.username||t.password||t.port&&t.port!=="443")return !1;let r=t.hostname.toLowerCase();return r==="s3.amazonaws.com"||r.endsWith(".s3.amazonaws.com")||/^(?:[a-z0-9][a-z0-9.-]*\.)?s3[.-][a-z0-9-]+\.amazonaws\.com$/.test(r)||/^(?:[a-z0-9][a-z0-9.-]*\.)?s3\.dualstack\.[a-z0-9-]+\.amazonaws\.com$/.test(r)||r==="s3-accelerate.amazonaws.com"||r.endsWith(".s3-accelerate.amazonaws.com")||r==="s3-accelerate.dualstack.amazonaws.com"||r.endsWith(".s3-accelerate.dualstack.amazonaws.com")}catch{return false}}i(qc,"trustedSignatureUploadUrl");var Qy="Signature upload failed",Xy=3e4;function Jy(e){let t=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-t}i(Jy,"base64ByteLength");async function bs(e,t,r,o){let n=i(()=>new Error(Qy),"fail"),l=Jy(e);if(l<=0||r.aborted)throw n();let a=await t.initiateSignatureUpload(l);if(!a.ok||r.aborted||!qc(a.value.uploadUrl))throw n();let c=new FormData;for(let[y,g]of Object.entries(a.value.uploadFields))c.append(y,g);c.append("file",{uri:`data:image/png;base64,${e}`,name:"signature.png",type:"image/png"});let s=new AbortController,d=i(()=>s.abort(),"onAbort");r.addEventListener("abort",d,{once:true});let u=setTimeout(d,Xy);try{if(!(await(o??fetch)(a.value.uploadUrl,{method:"POST",body:c,credentials:"omit",signal:s.signal})).ok||r.aborted)throw n()}catch{throw n()}finally{clearTimeout(u),r.removeEventListener("abort",d);}let m=await t.completeSignatureUpload(a.value.uploadId);if(!m.ok||r.aborted)throw n();return {signatureId:m.value}}i(bs,"registerRnSignature");var sn=Object.freeze({width:360,height:120});function Hc(e,t){return {width:e,height:t,pixels:new Uint8Array(e*t)}}i(Hc,"blank");function Bc(e,t,r,o){for(let n=-o;n<=o;n+=1)for(let l=-o;l<=o;l+=1){if(l*l+n*n>o*o+o)continue;let a=t+l,c=r+n;a<0||c<0||a>=e.width||c>=e.height||(e.pixels[c*e.width+a]=1);}}i(Bc,"stamp");var Zy=16384;function ef(e,t){let[r,o]=e;if(!Number.isFinite(r)||!Number.isFinite(o))return null;let n=Math.min(2*t.width,Math.max(-t.width,Math.round(r))),l=Math.min(2*t.height,Math.max(-t.height,Math.round(o)));return [n,l]}i(ef,"padPoint");function tf(e,t,r,o,n){let[l,a]=t,[c,s]=r,d=Math.abs(c-l),u=-Math.abs(s-a),m=l<c?1:-1,y=a<s?1:-1,g=d+u,w=0;for(;w<n&&(Bc(e,l,a,o),w+=1,!(l===c&&a===s));){let R=2*g;R>=u&&(g+=u,l+=m),R<=d&&(g+=d,a+=y);}return w}i(tf,"line");function Uc(e,t=1){let r=Hc(sn.width,sn.height);for(let o of e){let n=[];for(let a of o){let c=ef(a,r);c!==null&&n.push(c);}if(n.length===0)continue;if(n.length===1){let[a,c]=n[0];Bc(r,a,c,t);continue}let l=Zy;for(let a=1;a<n.length&&l>0;a+=1)l-=tf(r,n[a-1],n[a],t,l);}return r}i(Uc,"rasterizeStrokes");var rf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,'-",nf="ehhvhhhuhhuhhufgggggfuhhhhhuvgguggvvggugggfggnhhfhhhvhhhv44444v72222ichikokihggggggvhrllhhhhpljhhhehhhhheuhhugggehhhliduhhukihfgge11uv444444hhhhhhehhhhha4hhhllrhhha4ahhhha4444v1248gv00e1fhfgguhhhu00fgggf11fhhhf00ehvgf698s8880fhhf1egguhhhh40c444e20622icggikokic44444e00qllhh00uhhhh00ehhhe0uhhugg0fhhf1100mpggg00fge1u88s889600hhhjd00hhha400hhlla00ha4ah00hhf1e00v248vehjlphe4c4444eeh1248vv2421he26aiv22vgu11he68guhhev124888ehhehheehhf12c00000cc0000c48c480000000v000",of="0123456789abcdefghijklmnopqrstuv",Cs=5,Es=7,hs=Cs+1;function sf(e,t){let r=rf.indexOf(e);return r<0?0:of.indexOf(nf.charAt(r*Es+t))}i(sf,"glyphRow");function jc(e){let t=Hc(sn.width,sn.height),r=e.trim();if(r.length===0)return t;let o=[...r],n=4;for(;n>1&&(o.length*hs-1)*n>t.width-8;)n-=1;let l=(o.length*hs-1)*n,a=Math.max(0,Math.floor((t.width-l)/2)),c=Math.floor((t.height-Es*n)/2);return o.forEach((s,d)=>{let u=a+d*hs*n;for(let m=0;m<Es;m+=1){let y=sf(s,m);for(let g=0;g<Cs;g+=1)if((y>>Cs-1-g&1)!==0)for(let w=0;w<n;w+=1)for(let R=0;R<n;R+=1){let v=u+g*n+R,f=c+m*n+w;v<t.width&&f<t.height&&(t.pixels[f*t.width+v]=1);}}}),t}i(jc,"rasterizeTypedName");var _s=class _s{constructor(){this.bytes=[];this.acc=0;this.count=0;}writeBits(t,r){for(this.acc|=t<<this.count,this.count+=r;this.count>=8;)this.bytes.push(this.acc&255),this.acc>>>=8,this.count-=8;}writeCode(t,r){let o=0;for(let n=0;n<r;n+=1)o=o<<1|t>>n&1;this.writeBits(o,r);}finish(){return this.count>0&&this.bytes.push(this.acc&255),Uint8Array.from(this.bytes)}};i(_s,"BitWriter");var Ss=_s;function Ts(e,t){t<144?e.writeCode(48+t,8):t<256?e.writeCode(400+(t-144),9):t<280?e.writeCode(t-256,7):e.writeCode(192+(t-280),8);}i(Ts,"writeLiteral");var Rs=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],zc=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],vs=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],Nc=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];function af(e,t,r){let o=Rs.length-1;for(;Rs[o]>t;)o-=1;Ts(e,257+o),zc[o]>0&&e.writeBits(t-Rs[o],zc[o]);let n=vs.length-1;for(;vs[n]>r;)n-=1;e.writeCode(n,5),Nc[n]>0&&e.writeBits(r-vs[n],Nc[n]);}i(af,"writeMatch");var lf=32768,ws=3,cf=258,Mc=15,df=64;function uf(e){let t=new Ss;t.writeBits(1,1),t.writeBits(1,2);let r=new Int32Array(1<<Mc).fill(-1),o=new Int32Array(e.length).fill(-1),n=i(c=>(e[c]<<10^e[c+1]<<5^e[c+2])&(1<<Mc)-1,"hashAt"),l=i(c=>{if(c+ws>e.length)return;let s=n(c);o[c]=r[s],r[s]=c;},"insert"),a=0;for(;a<e.length;){let c=0,s=0;if(a+ws<=e.length){let d=r[n(a)],u=0,m=Math.min(cf,e.length-a);for(;d>=0&&u<df&&a-d<=lf;){let y=0;for(;y<m&&e[d+y]===e[a+y];)y+=1;if(y>c&&(c=y,s=a-d,y===m))break;d=o[d],u+=1;}}if(c>=ws){af(t,c,s);for(let d=0;d<c;d+=1)l(a+d);a+=c;}else Ts(t,e[a]),l(a),a+=1;}return Ts(t,256),t.finish()}i(uf,"deflate");function pf(e){let t=1,r=0;for(let o of e)t=(t+o)%65521,r=(r+t)%65521;return (r<<16|t)>>>0}i(pf,"adler32");var Io=null;function mf(e){if(Io===null){Io=new Uint32Array(256);for(let r=0;r<256;r+=1){let o=r;for(let n=0;n<8;n+=1)o=o&1?3988292384^o>>>1:o>>>1;Io[r]=o>>>0;}}let t=4294967295;for(let r of e)t=Io[(t^r)&255]^t>>>8;return (t^4294967295)>>>0}i(mf,"crc32");function zn(e){return [e>>>24&255,e>>>16&255,e>>>8&255,e&255]}i(zn,"u32");function xs(e,t){let r=Uint8Array.from([...e].map(n=>n.charCodeAt(0))),o=new Uint8Array(r.length+t.length);return o.set(r,0),o.set(t,r.length),[...zn(t.length),...o,...zn(mf(o))]}i(xs,"chunk");var Do="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function yf(e){let t="";for(let r=0;r<e.length;r+=3){let o=e[r],n=r+1<e.length?e[r+1]:0,l=r+2<e.length?e[r+2]:0,a=o<<16|n<<8|l;t+=Do.charAt(a>>18&63)+Do.charAt(a>>12&63),t+=r+1<e.length?Do.charAt(a>>6&63):"=",t+=r+2<e.length?Do.charAt(a&63):"=";}return t}i(yf,"toBase64");function ks(e){let{width:t,height:r,pixels:o}=e,n=Math.ceil(t/8)+1,l=new Uint8Array(n*r);for(let u=0;u<r;u+=1){let m=u*n;l[m]=0,l.fill(255,m+1,m+n);for(let y=0;y<t;y+=1)if(o[u*t+y]===1){let g=m+1+(y>>3);l[g]=l[g]&~(128>>(y&7));}}let a=uf(l),c=new Uint8Array(2+a.length+4);c[0]=120,c[1]=1,c.set(a,2),c.set(zn(pf(l)),2+a.length);let s=Uint8Array.from([...zn(t),...zn(r),1,0,0,0,0]),d=Uint8Array.from([137,80,78,71,13,10,26,10,...xs("IHDR",s),...xs("IDAT",c),...xs("IEND",new Uint8Array(0))]);return yf(d)}i(ks,"encodeSignaturePng");var Vo=2.6,Gc="#111111";function hf(e,t){let r=[];return e.forEach((o,n)=>{let l=i(a=>{let c=o[a];return [c[0]/t,c[1]/t]},"at");if(o.length===1){let[a,c]=l(0);r.push({key:`${n}-0`,cx:a,cy:c,length:0,angle:0});return}for(let a=1;a<o.length;a+=1){let[c,s]=l(a-1),[d,u]=l(a);r.push({key:`${n}-${a}`,cx:(c+d)/2,cy:(s+u)/2,length:Math.hypot(d-c,u-s),angle:Math.atan2(u-s,d-c)});}}),r}i(hf,"strokeSegments");var Rf=8,Yc=2;function $r({onChange:e,disabled:t=false}){let r=vf(),[o,n]=useState("draw"),[l,a]=useState(""),[c,s]=useState([]),[d,u]=useState(0),m=useRef([]),y=useRef(null),g=d>0?sn.width/d:1,w=useRef(g);w.current=g;let R=useRef(t);R.current=t,useEffect(()=>{if(o==="type"){so(e,l.trim().length>0?ks(jc(l)):null);return}let T=c.reduce((k,_)=>k+_.length,0);so(e,T>=Rf?ks(Uc(c)):null);},[o,l,c,e]);let v=i(T=>{let{locationX:k,locationY:_}=T.nativeEvent;return [k*w.current,_*w.current]},"point"),f=i(()=>{let T=m.current,k=y.current;m.current=[],y.current=null,s(_=>[..._.filter(E=>E!==k),T]);},"commitStroke"),b=useMemo(()=>PanResponder.create({onStartShouldSetPanResponder:i(()=>!R.current,"onStartShouldSetPanResponder"),onMoveShouldSetPanResponder:i(()=>!R.current,"onMoveShouldSetPanResponder"),onPanResponderTerminationRequest:i(()=>false,"onPanResponderTerminationRequest"),onPanResponderGrant:i(T=>{m.current=[v(T)];},"onPanResponderGrant"),onPanResponderMove:i(T=>{let k=v(T),_=m.current[m.current.length-1];if(_!==void 0&&Math.abs(_[0]-k[0])<Yc&&Math.abs(_[1]-k[1])<Yc)return;m.current=[...m.current,k];let E=y.current,B=m.current;y.current=B,s(x=>[...x.filter(A=>A!==E),B]);},"onPanResponderMove"),onPanResponderRelease:i(()=>f(),"onPanResponderRelease"),onPanResponderTerminate:i(()=>f(),"onPanResponderTerminate")}),[]),C=useCallback(()=>{R.current||(m.current=[],y.current=null,s([]),a(""));},[]),h=useCallback(()=>{C(),n(T=>T==="draw"?"type":"draw");},[C]),I=i(T=>u(T.nativeEvent.layout.width),"onLayout");return jsxs(View,{style:r.container,testID:"records-signature-pad",children:[jsx(p,{style:r.label,children:o==="draw"?Z.draw:Z.type}),o==="type"?jsx(Qe,{accessibilityLabel:Z.type,style:r.input,value:l,maxLength:100,editable:!t,autoComplete:"off",autoCorrect:false,onChangeText:T=>{R.current||a(T);}}):null,jsx(View,{onLayout:I,style:[r.canvas,{height:d>0?d/3:120}],accessible:true,accessibilityLabel:Z.sign,accessibilityRole:"image",testID:"records-signature-canvas",...o==="draw"?b.panHandlers:{},children:o==="type"?jsx(p,{style:r.typedPreview,numberOfLines:1,adjustsFontSizeToFit:true,children:l.trim()}):hf(c,g).map(T=>{let k=T.length+Vo;return jsx(View,{pointerEvents:"none",style:[r.segment,{width:k,left:T.cx-k/2,top:T.cy-Vo/2,transform:[{rotate:`${T.angle}rad`}]}]},T.key)})}),jsxs(View,{style:r.actions,children:[jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:Z.clear,accessibilityState:{disabled:t},disabled:t,onPress:C,style:r.button,children:jsx(p,{style:r.buttonLabel,children:Z.clear})}),jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:o==="draw"?Z.toType:Z.toDraw,accessibilityState:{disabled:t},disabled:t,onPress:h,style:r.button,children:jsx(p,{style:r.buttonLabel,children:o==="draw"?Z.toType:Z.toDraw})})]})]})}i($r,"SignaturePad");function vf(){let e=V();return useMemo(()=>wf(e),[e])}i(vf,"useStyles");function wf(e){let{color:t,space:r,radius:o,type:n}=e;return StyleSheet.create({container:{gap:r.sm},label:{...S(e,"regular"),fontSize:n.size.body,color:t.text.primary},input:{minHeight:44,padding:r.sm,borderWidth:1,borderColor:t.borderHairlineGreen,borderRadius:o.sm,color:t.text.primary,backgroundColor:t.surface,...S(e,"regular"),fontSize:n.size.body},canvas:{width:"100%",backgroundColor:"#ffffff",borderWidth:1,borderColor:t.borderHairlineGreen,borderRadius:o.sm,overflow:"hidden",justifyContent:"center"},segment:{position:"absolute",height:Vo,borderRadius:Vo/2,backgroundColor:Gc},typedPreview:{textAlign:"center",fontSize:32,fontStyle:"italic",fontWeight:"700",color:Gc,paddingHorizontal:r.md},actions:{flexDirection:"row",flexWrap:"wrap",gap:r.sm},button:{minHeight:44,paddingHorizontal:r.md,justifyContent:"center",borderWidth:1,borderColor:t.borderHairlineGreen,borderRadius:o.sm,backgroundColor:t.surface},buttonLabel:{...S(e,"regular"),fontSize:n.size.body,color:t.text.primary}})}i(wf,"makeStyles");function Is(e){let{userRef:t,scopeEpoch:r}=Te();return jsx(Ue,{capability:"recordsClinic",...$e(e.onClose,Z.cancel),children:t===null?jsx(p,{accessibilityRole:"alert",children:ve.sessionRequired}):jsx(Ef,{...Be(e,["onClose","onCreated"])},JSON.stringify([t,r,e.petRef,e.petName]))})}i(Is,"EverfurClinicRequestBatch");function Ef(e){let t=Zt(),r=ts(),o=e.controller??t,[n,l]=useState(null),a=useCallback(async()=>n===null?null:{signaturePngBase64:n},[n]),c=useCallback((v,f)=>bs(v,o,f),[o]),s=Fc(e,o,e.batchClient??r,e.onCaptureSignature??a,e.onCaptureSignature?void 0:c),d=e.onCaptureSignature!==void 0||n!==null,u=V(),m={minHeight:44,padding:u.space.sm,borderWidth:1,borderColor:u.color.borderHairlineGreen,borderRadius:u.radius.sm,color:u.color.text.primary,backgroundColor:u.color.surface},y={color:u.color.text.primary,fontSize:u.type.size.body},g={color:u.color.text.muted,fontSize:u.type.size.bodyTight},w=i((v,f,b=false,C=v)=>jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:C,accessibilityState:{disabled:b},disabled:b,onPress:f,style:[m,{justifyContent:"center",opacity:b?.5:1}],children:jsx(p,{style:y,children:v})}),"button"),R=s.busy?We.sending:s.drafts.length===0?We.addToContinue:s.error?We.tryAgain:We.send(s.drafts.length);return jsxs(View,{accessibilityLabel:s.outcome?We.resultTitle:We.title,style:[{backgroundColor:u.color.surface,padding:u.space.lg,gap:u.space.md,borderRadius:u.radius.lg,minHeight:120},e.style],children:[jsx(p,{accessibilityRole:"header",style:[y,{...S(u,"bold"),fontSize:u.type.size.heading}],children:s.outcome?We.resultTitle:We.title}),jsx(p,{style:y,children:e.petName}),s.outcome?jsxs(View,{style:{gap:u.space.sm},testID:"records-batch-result",children:[jsx(p,{accessibilityRole:"summary",accessibilityLiveRegion:"polite",style:y,children:s.outcome.createdCount===0?We.allFailed:s.outcome.failedCount>0?We.partial(s.outcome.createdCount,s.outcome.results.length,s.outcome.failedCount):We.allSent(s.outcome.createdCount)}),jsx(p,{accessibilityRole:"header",style:y,children:We.perClinic}),s.outcome.results.map((v,f)=>{let b=v.request?.clinicName??s.drafts[f]?.clinic?.name??v.clinicFreeText??"",C=v.created?We.sent:We.notSent;return jsxs(View,{accessible:true,accessibilityRole:"text",accessibilityLabel:[`${b}. ${C}.`,v.created?v.request?.statusLabel:v.failureReason].filter(Boolean).join(" "),testID:`records-batch-row-${v.created?"created":"failed"}`,children:[jsx(p,{style:y,children:b}),jsx(p,{style:g,children:C}),v.created&&v.request?.statusLabel?jsx(p,{style:g,children:v.request.statusLabel}):null,!v.created&&v.failureReason?jsx(p,{style:g,children:v.failureReason}):null]},v.idempotencyKey)}),s.group?jsx(p,{accessibilityLiveRegion:"polite",style:y,children:We.responded(s.group.responded,s.group.total)}):null,s.group?.members.map(v=>v.statusLabel?jsx(p,{style:g,children:[v.clinicName,v.statusLabel].filter(Boolean).join(": ")},v.id):null)]}):jsxs(Fragment,{children:[jsx(p,{style:y,children:Z.ownerName}),jsx(Qe,{accessibilityLabel:Z.ownerName,style:m,value:s.ownerName,maxLength:200,editable:!s.busy,autoComplete:"name",onChangeText:s.setOwnerName}),s.drafts.map(v=>jsxs(View,{style:{gap:u.space.xs},testID:`records-batch-draft-${v.key}`,children:[jsx(p,{style:y,children:qn(v)}),Fn(v)?jsxs(Fragment,{children:[jsx(p,{style:g,children:v.email.trim()?v.email:We.emailToAdd}),jsx(Qe,{accessibilityLabel:Z.email,style:m,value:v.email,placeholder:Z.emailPlaceholder,placeholderTextColor:u.color.text.placeholder,maxLength:320,editable:!s.busy,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,onChangeText:f=>s.setDraftEmail(v.key,f)})]}):null,w(We.remove(qn(v)),()=>s.removeDraft(v.key),s.busy)]},v.key)),jsx(p,{style:y,children:s.atCap?We.atCap:We.addClinic}),!s.atCap&&jsxs(Fragment,{children:[jsx(Qe,{accessibilityLabel:Z.clinic,style:m,value:s.query,placeholder:Z.placeholder,placeholderTextColor:u.color.text.placeholder,maxLength:200,editable:!s.busy,onChangeText:s.setQuery}),w(Z.search,()=>{s.search();},s.busy||s.searching||s.query.trim().length<2),s.query.trim().length>0&&s.clinics.length===0&&!s.searching&&w(We.addClinic,s.addFreeText,s.busy),s.searching&&jsx(p,{accessibilityLiveRegion:"polite",style:y,children:ve.loading}),s.recent.length>0&&jsx(p,{accessibilityRole:"header",style:y,children:Z.recentlyUsed}),s.recent.map(v=>jsx(View,{children:w([v.name,v.address,v.phone].filter(Boolean).join(", "),()=>s.addClinic(v),s.busy)},`recent-${v.id}`)),s.visibleClinics.map(v=>jsx(View,{children:w([v.name,v.address,v.phone].filter(Boolean).join(", "),()=>s.addClinic(v),s.busy)},v.id)),s.hasMoreClinics&&w(Z.moreClinics,s.showMoreClinics,s.busy)]}),jsx(p,{accessibilityRole:"header",style:y,children:Z.scopeHeading}),s.copy?jsx(p,{style:y,children:s.drafts.length>0&&s.ownerName.trim()?s.scopeText??W("internalError").displayMessage:ve.consentRequired}):!s.error&&jsx(p,{accessibilityLiveRegion:"polite",style:y,children:ve.loading}),!e.onCaptureSignature&&jsx($r,{onChange:l,disabled:s.busy}),!d&&s.ready&&jsx(p,{accessibilityRole:"alert",style:y,children:Z.missingSignature}),s.error&&jsx(p,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:y,children:s.error.displayMessage}),!s.copy&&s.error&&w(ve.retry,s.retryCopy),w(R,()=>{s.submit();},s.busy||!s.ready||!d,We.sendA11y(s.drafts.length))]}),e.onClose&&w(Z.cancel,e.onClose,s.busy),jsx(je,{})]})}i(Ef,"BatchBody");var me=Object.freeze({scopeHeading:"What we ask for",scopeBody:"You\u2019re asking your pet\u2019s clinic to release their medical records to Everfur, on your behalf, so we can organize them for you.",whatWeDo:Object.freeze(["We email the clinic a signed copy of this authorization.","When records arrive, our team reviews them before they appear in your app.","You can revoke this request at any time."]),retentionNote:"We keep the records you receive so you always have them. See our Privacy Policy for how records are stored and used.",authorizeLabel:i(e=>`I\u2019m ${ke(e)}\u2019s owner. I authorize Everfur to request these records on my behalf.`,"authorizeLabel"),missingSignatureError:"Please add your signature before submitting.",missingDraftError:"Something went wrong with your selection. Please go back and pick the clinic again.",newClinicDirectSendNote:"We\u2019ll email this clinic directly to request your pet\u2019s medical records. Clinics usually reply within a week.",titleFreeText:"Check and send",titleDirectory:"Check and send",leadWeb:i(e=>`The clinic gets a secure request, with your permission to release ${ke(e)}\u2019s records to Everfur.`,"leadWeb"),leadNative:"The clinic gets a secure request, with your permission.",whatHappensNext:"What happens next",whatHappensNextBody:"Most clinics respond within 3 to 5 business days. We follow up automatically, and you can cancel any time before the records arrive.",noEmailNote:i((e,t)=>`We don\u2019t have an email on file for ${t}. Add it so we can request ${ke(e)}\u2019s records.`,"noEmailNote"),emailLabel:"Clinic email for records",emailPlaceholder:"records@clinic.com",emailRequired:"Add the clinic\u2019s records email to send the request.",emailInvalid:"That email doesn\u2019t look right. Check it and try again.",reuseSignature:"Reuse a previous signature",reuseHint:"\u2026or sign again below",reuseTileA11y:"Use this earlier signature",reuseTileSelectedA11y:"Earlier signature, selected",signType:"Type your name to sign",signDraw:"Sign with your finger",clear:"Clear",clearA11y:"Clear signature",fullName:"Your full name",fullNamePlaceholder:"Jane Doe",toType:"Can\u2019t draw? Type your name instead",toTypeA11y:"Can\u2019t draw? Type your name to sign instead",toDraw:"Draw your signature instead",signatureHint:i(e=>`Your signature is added to the authorization sent to ${e}.`,"signatureHint"),submit:"Send request",submitting:"Sending\u2026",submitA11y:"Send request"});var Sf="value_text",Jc=64,Zc=512;function ed(e){return e!==null&&e.httpStatus===409&&!ar(e)}i(ed,"isFactReviewerLocked");var Nn=Object.freeze({num:"value_num",date:"value_date",bool:"value_bool",text:Sf}),td=/^[+-]?(?:\d+\.?\d*|\.\d+)$/,rd=/^\d{4}-\d{2}-\d{2}$/;function nd(e){if(e==null)return "text";let t=e.trim();return td.test(t)?"num":rd.test(t)&&!Number.isNaN(Date.parse(t))?"date":t==="true"||t==="false"?"bool":"text"}i(nd,"inferFactValueKind");function Ds(e,t){let r=t.trim(),o=nd(e);if(o==="num"&&td.test(r)){let n=Number(r);if(Number.isFinite(n))return Object.freeze({[Nn.num]:n})}return o==="date"&&rd.test(r)&&!Number.isNaN(Date.parse(r))?Object.freeze({[Nn.date]:r}):Object.freeze(o==="bool"&&(r==="true"||r==="false")?{[Nn.bool]:r==="true"}:{[Nn.text]:r})}i(Ds,"factCorrectionFor");var qe=z.string().nullish(),Fo=z.number().nullish(),Tf=z.object({collected_at:qe,at:qe,value:Fo,unit:qe,qualitative_result:qe,ref_low:Fo,ref_high:Fo,status:qe,source_clinic:qe,source_doc_id:qe,doc_id:qe,reviewed:z.boolean().nullish()}),kf=z.object({collected_at:qe,at:qe,value:Fo,unit:qe,qualitative_result:qe,status:qe}),_f=z.object({marker_id:z.string().min(1),canonical_name:qe,name:qe,loinc_code:qe,canonical_unit:qe,unit:qe,panel_name:qe,panel:qe,meaning_text:qe,meaning:qe,latest:kf.nullish(),trajectory:qe,points:z.array(Tf).optional()}),Pf=z.object({total_markers:z.number().int().nonnegative(),in_range_count:z.number().int().nonnegative(),out_of_range_count:z.number().int().nonnegative(),unknown_count:z.number().int().nonnegative()}),If=z.object({markers:z.array(_f).optional(),summary:Pf.nullish(),disclaimer:z.string().optional(),featured_marker_id:qe});function Df(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(Df,"isObject");function od(e){return Object.freeze({petRef:e,withheld:true,markers:Object.freeze([]),summary:null,disclaimer:"",featuredMarkerId:null})}i(od,"withheldMarkers");function id(e,t){let r=Df(t)?t:{},o=typeof r.pet_ref=="string"&&r.pet_ref.length>0?r.pet_ref:e;if(r.withheld===true)return od(o);let n=If.safeParse(r);if(!n.success)return od(o);let l=n.data,a=i(s=>Object.freeze({at:s.collected_at??s.at??null,value:s.value??null,unit:s.unit??null,qualitativeResult:s.qualitative_result??null,refLow:s.ref_low??null,refHigh:s.ref_high??null,status:s.status??null,sourceClinic:s.source_clinic??null,docId:s.source_doc_id??s.doc_id??null,reviewed:s.reviewed===true}),"point"),c=(l.markers??[]).map(s=>Object.freeze({markerId:s.marker_id,name:s.canonical_name??s.name??s.marker_id,loincCode:s.loinc_code??null,unit:s.canonical_unit??s.unit??null,panel:s.panel_name??s.panel??null,meaning:s.meaning_text??s.meaning??null,latest:s.latest?Object.freeze({at:s.latest.collected_at??s.latest.at??null,value:s.latest.value??null,unit:s.latest.unit??null,qualitativeResult:s.latest.qualitative_result??null,status:s.latest.status??null}):null,trajectory:s.trajectory??null,points:Object.freeze((s.points??[]).map(a))}));return Object.freeze({petRef:o,withheld:false,markers:Object.freeze(c),summary:l.summary?Object.freeze({totalMarkers:l.summary.total_markers,inRangeCount:l.summary.in_range_count,outOfRangeCount:l.summary.out_of_range_count,unknownCount:l.summary.unknown_count}):null,disclaimer:l.disclaimer??"",featuredMarkerId:l.featured_marker_id??null})}i(id,"mapRecordMarkers");var Af=z.string().min(1).refine(e=>e.startsWith("https://")),Of=z.object({source_doc_id:z.string().min(1),file_name:z.string().nullish(),doc_format:z.string().nullish(),byte_size:z.number().int().nonnegative().nullish(),received_at:z.string().nullish(),download_url:Af,expires_in_seconds:z.number().int().nonnegative().nullish()}),Lf=z.object({items:z.array(z.unknown()).optional()});function sd(e){let t=Lf.safeParse(e);if(!t.success)return null;let r=[];for(let o of t.data.items??[]){let n=Of.safeParse(o);n.success&&r.push(Object.freeze({sourceDocId:n.data.source_doc_id,fileName:n.data.file_name??null,docFormat:n.data.doc_format??null,byteSize:n.data.byte_size??null,receivedAt:n.data.received_at??null,downloadUrl:n.data.download_url,expiresInSeconds:n.data.expires_in_seconds??0}));}return Object.freeze(r)}i(sd,"mapRequestDocuments");var Vf=z.object({signatures:z.array(z.object({signature_id:z.string().min(1),preview_url:z.string().min(1).refine(e=>e.startsWith("https://")),created_at:z.string().nullish()})).optional()});function ad(e){let t=Vf.safeParse(e);return t.success?Object.freeze((t.data.signatures??[]).map(r=>Object.freeze({signatureId:r.signature_id,previewUrl:r.preview_url,createdAt:r.created_at??null}))):null}i(ad,"mapSignatureSuggestions");var Q=z.string().nullish(),Mn=z.number().nullish(),Ff=z.object({at:Q,value:Mn,unit:Q,qualitative_result:Q,ref_low:Mn,ref_high:Mn,status:Q,doc_id:Q}),qf=z.object({marker_id:z.string(),name:z.string(),loinc_code:Q,unit:Q,panel:Q,meaning:Q,latest:z.object({at:Q,value:Mn,unit:Q,qualitative_result:Q,status:Q}).nullish(),trajectory:Q,points:z.array(Ff).optional()}),zf=z.object({encounter_id:z.string(),date:Q,type:Q,clinic_name:Q,veterinarian:Q,doc_id:Q}),Nf=z.object({note_id:z.string(),encounter_id:Q,observed_on:Q,sections:z.array(z.object({section:z.string(),text:z.string()})).optional()}),Mf=z.object({exam_id:z.string(),encounter_id:Q,observed_on:Q,doc_id:Q,systems:z.record(z.object({finding_status:Q,finding:Q})).optional()}),Hf=z.object({has_lab_history:z.boolean().optional(),has_vaccination_history:z.boolean().optional(),has_weight_history:z.boolean().optional(),has_vitals_history:z.boolean().optional(),has_physical_exam_history:z.boolean().optional(),has_procedure_history:z.boolean().optional(),has_genetic_history:z.boolean().optional(),has_reproductive_history:z.boolean().optional(),has_parasite_prevention_history:z.boolean().optional(),earliest_record_at:Q,latest_record_at:Q,documents_ingested:z.number().int().nonnegative().optional(),documents_in_review:z.number().int().nonnegative().optional(),entities_pending_review:z.record(z.number().int().nonnegative()).optional(),held_total:z.number().int().nonnegative().optional()}),Bf=z.object({conflict_id:z.string(),entity_type:z.string(),field:Q,severity:Q,candidates:z.array(z.object({value:z.string(),source_doc_id:Q,doc_id:Q,collected_at:Q})).optional()}),Uf=z.object({lab_results:z.array(qf).optional(),encounters:z.array(zf).optional(),clinician_notes:z.array(Nf).optional(),physical_exams:z.array(Mf).optional(),completeness:Hf.nullish(),conflicts:z.array(Bf).optional()}),jf=z.object({visits:z.array(z.object({visit_id:z.string(),visit_date:Q,veterinarian:Q,summary:Q,doc_id:Q})),vaccines:z.array(z.object({vaccine_id:z.string(),product:Q,lot:Q,administered_on:Q,expires_on:Q,doc_id:Q})),weights:z.array(z.object({weight_id:z.string(),observed_on:Q,weight_kg:Mn,doc_id:Q})),medications:z.array(z.object({medication_id:z.string(),drug_name:Q,dose:Q,route:Q,frequency:Q,sig:Q,rx_number:Q,started_on:Q,stopped_on:Q,doc_id:Q})),disclaimer:z.string().optional()}),$f=z.object({document:Ti,contributions:z.array(Si),contribution_count:z.number().int().nonnegative().optional()});function Os(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(Os,"isObject");function Ls(e,t){return typeof e.pet_ref=="string"&&e.pet_ref.length>0?e.pet_ref:t}i(Ls,"petOf");function As(e,t){return Object.freeze({petRef:e,available:false,withheld:t,labResults:Object.freeze([]),encounters:Object.freeze([]),clinicianNotes:Object.freeze([]),physicalExams:Object.freeze([]),completeness:null,conflicts:Object.freeze([])})}i(As,"emptyDepth");function Wf(e,t){let r=Os(t)?t:{},o=Ls(r,e);if(r.withheld===true)return As(o,true);if(!["lab_results","encounters","clinician_notes","physical_exams","completeness","conflicts"].some(s=>s in r))return As(o,false);let l=Uf.safeParse(r);if(!l.success)return As(o,true);let a=l.data,c=i(s=>Object.freeze({at:s.at??null,value:s.value??null,unit:s.unit??null,qualitativeResult:s.qualitative_result??null,refLow:s.ref_low??null,refHigh:s.ref_high??null,status:s.status??null,docId:s.doc_id??null}),"point");return Object.freeze({petRef:o,available:true,withheld:false,labResults:Object.freeze((a.lab_results??[]).map(s=>Object.freeze({markerId:s.marker_id,name:s.name,loincCode:s.loinc_code??null,unit:s.unit??null,panel:s.panel??null,meaning:s.meaning??null,latest:Object.freeze({at:s.latest?.at??null,value:s.latest?.value??null,unit:s.latest?.unit??null,qualitativeResult:s.latest?.qualitative_result??null,status:s.latest?.status??null}),trajectory:s.trajectory??null,points:Object.freeze((s.points??[]).map(c))}))),encounters:Object.freeze((a.encounters??[]).map(s=>Object.freeze({encounterId:s.encounter_id,date:s.date??null,type:s.type??null,clinicName:s.clinic_name??null,veterinarian:s.veterinarian??null,docId:s.doc_id??null}))),clinicianNotes:Object.freeze((a.clinician_notes??[]).map(s=>Object.freeze({noteId:s.note_id,encounterId:s.encounter_id??null,observedOn:s.observed_on??null,sections:Object.freeze((s.sections??[]).map(d=>Object.freeze({section:d.section,text:d.text})))}))),physicalExams:Object.freeze((a.physical_exams??[]).map(s=>Object.freeze({examId:s.exam_id,encounterId:s.encounter_id??null,observedOn:s.observed_on??null,docId:s.doc_id??null,systems:Object.freeze(Object.entries(s.systems??{}).map(([d,u])=>Object.freeze({system:d,findingStatus:u.finding_status??null,finding:u.finding??null})))}))),completeness:a.completeness?Object.freeze({hasLabHistory:a.completeness.has_lab_history===true,hasVaccinationHistory:a.completeness.has_vaccination_history===true,hasWeightHistory:a.completeness.has_weight_history===true,hasVitalsHistory:a.completeness.has_vitals_history===true,hasPhysicalExamHistory:a.completeness.has_physical_exam_history===true,hasProcedureHistory:a.completeness.has_procedure_history===true,hasGeneticHistory:a.completeness.has_genetic_history===true,hasReproductiveHistory:a.completeness.has_reproductive_history===true,hasParasitePreventionHistory:a.completeness.has_parasite_prevention_history===true,earliestRecordAt:a.completeness.earliest_record_at??null,latestRecordAt:a.completeness.latest_record_at??null,documentsIngested:a.completeness.documents_ingested??0,documentsInReview:a.completeness.documents_in_review??0,entitiesPendingReview:Object.freeze({...a.completeness.entities_pending_review??{}}),heldTotal:a.completeness.held_total??0}):null,conflicts:Object.freeze((a.conflicts??[]).map(s=>Object.freeze({conflictId:s.conflict_id,entityType:s.entity_type,field:s.field??null,severity:s.severity??"needs_review",candidates:Object.freeze((s.candidates??[]).map(d=>Object.freeze({value:d.value,docId:d.source_doc_id??d.doc_id??null,collectedAt:d.collected_at??null})))})))})}i(Wf,"mapRecordDepth");function ld(e){return Object.freeze({petRef:e,withheld:true,isEmpty:false,visits:Object.freeze([]),vaccines:Object.freeze([]),weights:Object.freeze([]),medications:Object.freeze([]),disclaimer:""})}i(ld,"withheldTimeline");function Gf(e,t){let r=Os(t)?t:{},o=Ls(r,e);if(r.withheld===true)return ld(o);let n=jf.safeParse(r);if(!n.success)return ld(o);let l=n.data,a=l.visits.map(u=>Object.freeze({visitId:u.visit_id,visitDate:u.visit_date??null,veterinarian:u.veterinarian??null,summary:u.summary??null,docId:u.doc_id??null})),c=l.vaccines.map(u=>Object.freeze({vaccineId:u.vaccine_id,product:u.product??null,lot:u.lot??null,administeredOn:u.administered_on??null,expiresOn:u.expires_on??null,docId:u.doc_id??null})),s=l.weights.map(u=>Object.freeze({weightId:u.weight_id,observedOn:u.observed_on??null,weightKg:u.weight_kg??null,docId:u.doc_id??null})),d=l.medications.map(u=>Object.freeze({medicationId:u.medication_id,drugName:u.drug_name??null,dose:u.dose??null,route:u.route??null,frequency:u.frequency??null,sig:u.sig??null,rxNumber:u.rx_number??null,startedOn:u.started_on??null,stoppedOn:u.stopped_on??null,docId:u.doc_id??null}));return Object.freeze({petRef:o,withheld:false,isEmpty:a.length===0&&c.length===0&&s.length===0&&d.length===0,visits:Object.freeze(a),vaccines:Object.freeze(c),weights:Object.freeze(s),medications:Object.freeze(d),disclaimer:l.disclaimer??""})}i(Gf,"mapRecordsTimeline");function Yf(e,t){let r=Os(t)?t:{},o=Ls(r,e),n=i(()=>Object.freeze({petRef:o,withheld:true,document:null,contributions:Object.freeze([]),contributionCount:0}),"withheld");if(r.withheld===true)return n();let l=$f.safeParse(r);if(!l.success)return n();let a=Object.freeze(l.data.contributions.map(ki));return Object.freeze({petRef:o,withheld:false,document:_i(l.data.document),contributions:a,contributionCount:l.data.contribution_count??a.length})}i(Yf,"mapDocumentContributions");var Kf="/widget/v1/records/pets";function cd(e){let t=e.funnel??Dr({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=i((s,d)=>typeof s=="string"&&s.length>0&&!br(s)&&[...s].length<=d,"segment"),o=i(async(s,d,u,m)=>{if(!r(d,Rt))return rr();let y=await t.send(s,{method:"GET",path:u});if(!y.ok)return y;let g=m(y.value);return g.petRef===d?Ve(g):te(W("internalError",{retryable:false}))},"read"),n=i(s=>`${Kf}/${encodeURIComponent(s)}`,"pet"),l=i(s=>`${n(s)}/everfur_record`,"record"),a=i(async(s,d,u)=>{let m=await t.send(s,d,d.method==="POST"?{idempotent:false,maxAttempts:1}:void 0);if(!m.ok)return m;let y=u(m.value);return y===null?te(W("internalError",{retryable:false})):Ve(y)},"parsed"),c=i((s,d)=>!r(s.entityType,Jc)||!r(s.canonicalKey,Zc)||s.idempotencyKey!==void 0&&!r(s.idempotencyKey,Rn)||d!==void 0&&Object.keys(d).length===0?null:{entity_type:s.entityType,canonical_key:s.canonicalKey,...d!==void 0?{corrected_fields:d}:{},...s.idempotencyKey!==void 0?{idempotency_key:s.idempotencyKey}:{}},"factBody");return {getRecordDepth:i(s=>o("records.depth.record",s,`${n(s)}/record`,d=>Wf(s,d)),"getRecordDepth"),getTimeline:i(s=>o("records.depth.timeline",s,`${n(s)}/timeline`,d=>Gf(s,d)),"getTimeline"),getDocumentContributions(s,d){return r(d,64)?o("records.depth.contributions",s,`${n(s)}/documents/${encodeURIComponent(d)}/contributions`,u=>Yf(s,u)):rr()},getMarkers:i(s=>o("records.depth.markers",s,`${n(s)}/markers`,d=>id(s,d)),"getMarkers"),createShare(s,d){if(!r(s,Rt))return rr();let u=d?.audience;return u!==void 0&&!Zr.includes(u)?rr():a("records.share.create",{method:"POST",path:`${l(s)}/share`,...u!==void 0?{body:{audience:u}}:{}},m=>Fa(m,e.apiBaseUrl))},emailShare(s,d){let u=d.recipientKind,m=typeof d.recipientEmail=="string"?d.recipientEmail.trim():"",y=u==="other"||Zr.includes(u);return !r(s,Rt)||!y||!Xn(m)||br(m)?rr():a("records.share.email",{method:"POST",path:`${l(s)}/share/email`,body:{recipient_email:m,recipient_kind:u}},za)},async readFeatures(){try{let s=await t.send("records.getFeatures",{method:"GET",path:"/widget/v1/records/features"});return s.ok?Jn(s.value):Mt}catch{return Mt}},listShares(s){return r(s,Rt)?a("records.share.list",{method:"GET",path:`${l(s)}/shares`},qa):rr()},async revokeShare(s,d){if(!r(s,Rt)||!r(d,64))return rr();let u=await t.send("records.share.revoke",{method:"DELETE",path:`${l(s)}/shares/${encodeURIComponent(d)}`},{idempotent:false,maxAttempts:1});return u.ok?Ve(void 0):u},getPdfLink(s){return r(s,Rt)?a("records.pdf.link",{method:"GET",path:`${l(s)}/pdf-link`},Na):rr()},async editFact(s,d){let u=r(s,Rt)?c(d,d.correctedFields):null;if(u===null)return rr();let m=await t.send("records.fact.edit",{method:"POST",path:`${l(s)}/facts/edit`,body:u},{idempotent:false,maxAttempts:1});return m.ok?Ve(void 0):m},async removeFact(s,d){let u=r(s,Rt)?c(d):null;if(u===null)return rr();let m=await t.send("records.fact.remove",{method:"POST",path:`${l(s)}/facts/remove`,body:u},{idempotent:false,maxAttempts:1});return m.ok?Ve(void 0):m},listRequestDocuments(s){return r(s,64)?a("records.request.documents",{method:"GET",path:`/widget/v1/records/requests/${encodeURIComponent(s)}/documents`},sd):rr()},listAuthorizationSignatures:i(()=>a("records.signatures.list",{method:"GET",path:"/widget/v1/records/authorization-signatures"},ad),"listAuthorizationSignatures")}}i(cd,"createRecordsDepthClient");function rr(){return Promise.resolve(te(W("validationFailed",{retryable:false})))}i(rr,"invalid");function xr(){let{runtime:e,userRef:t,scopeEpoch:r}=Te();return useMemo(()=>{let{services:o}=e.registry;return cd({auth:o.authFor(t),...o.errorPolicy?{errorPolicy:o.errorPolicy}:{},...typeof o.apiBaseUrl=="string"?{apiBaseUrl:o.apiBaseUrl}:{}})},[e,t,r])}i(xr,"useEverfurRecordsDepthClient");function nr(e,t,r,o=""){let n=xr(),{userRef:l}=Te(),a=no(e),c=useMemo(()=>({}),[n,e,o,a]),[s,d]=useState({scope:c,value:null,error:null,loading:true}),u=useRef(0),m=useCallback(async()=>{let f=u.current+=1;if(d({scope:c,value:null,error:null,loading:true}),l===null){d({scope:c,value:null,error:null,loading:false});return}let b=await t(n,e);f===u.current&&(b.ok?d({scope:c,value:b.value,error:null,loading:false}):d({scope:c,value:null,error:b.error,loading:false}));},[n,e,t,c,l]);useEffect(()=>(m(),()=>{u.current+=1;}),[m]);let y=s.scope===c?s:{value:null,error:null,loading:true},g=useCallback(()=>{m();},[m]),w=y.error===null||y.error.httpStatus!==404,R=w?y.error:null,v=y.loading?"loading":R!==null?"error":y.value===null?"empty":y.value.withheld?"populated":r(y.value)?"empty":"populated";return useMemo(()=>({status:v,value:y.value,error:R,available:w,refresh:g}),[v,y.value,R,w,g])}i(nr,"useRecordsDepthRead");function Cr(e){return e!==null&&e.httpStatus===404}i(Cr,"isDarkRouteError");var eg=i((e,t)=>e.getMarkers(t),"readMarkers"),tg=i(e=>e.markers.length===0,"markersEmpty");function Fs(e){let t=nr(e,eg,tg);return useMemo(()=>{let r=t.available&&t.value!==null&&!t.value.withheld?t.value:null;return {status:t.status,markers:r,available:t.available,error:t.error,refresh:t.refresh}},[t])}i(Fs,"useRecordsMarkers");var rg=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function pd(e){let{clinic:t,controller:r,depthClient:o,capture:n,onCreated:l}=e,a=t.clinic?.name??t.freeText??"",c=t.clinic===null,[s,d]=useState(false),[u,m]=useState(e.ownerName),[y,g]=useState(t.email),[w,R]=useState(false),[v,f]=useState(null),[b,C]=useState(null),[h,I]=useState(0),[T,k]=useState(null),[_,E]=useState(false),[B,x]=useState(null),[A,z]=useState([]),[de,G]=useState(null),[ae,M]=useState(false),$=useRef(false),O=useRef(true),U=useRef(gr()),D=useRef(null);useEffect(()=>(O.current=true,()=>{O.current=false,D.current=null;}),[r]),useEffect(()=>{let Ee=true;return f(null),D.current=null,r.getAuthorizationCopy().then(Tt=>{Ee&&(Tt.ok?(f(Tt.value),C(null)):C(Tt.error));}).catch(()=>{Ee&&C(W("internalError"));}),()=>{Ee=false;}},[r,h]),useEffect(()=>{if(o===void 0)return;let Ee=true;return o.listAuthorizationSignatures().then(Tt=>{Ee&&(Tt.ok?z(Tt.value):Cr(Tt.error)||z([]));}).catch(()=>{}),()=>{Ee=false;}},[o]);let q=Vn(t.clinic),ee=y.trim().toLowerCase(),J=rg.test(ee),H=q&&(w||ee.length>0)&&!J?ee.length>0?me.emailInvalid:me.emailRequired:null,N=v?Ln(v,u.trim(),ke(e.petName),a):null,ie=e.hostCapture===true||ae||de!==null,Ce=!!(s&&v&&N&&u.trim()&&a&&ie&&(!q||J)),Le=useCallback(async()=>{if(!($.current||B!==null||!v||!N)){if(!a){k(me.missingDraftError);return}if(q&&!J){R(true),k(ee.length>0?me.emailInvalid:me.emailRequired);return}if(!(!s||!u.trim())){$.current=true,E(true),k(null);try{if(D.current===null){let Tt=de!==null?{signatureId:de}:await n();if(!O.current)return;if(Tt===null){k(me.missingSignatureError);return}let le=t.clinic&&(!q||t.clinic.emailStatus==="none")?{clinicId:t.clinic.id}:{clinicFreeText:a};D.current={petRef:e.petRef,ownerName:u.trim(),authorizationVersion:v.authorizationVersion,...le,...q?{clinicEmail:ee}:{},...Tt.signatureId!==void 0?{signatureId:Tt.signatureId}:{signaturePngBase64:Tt.signaturePngBase64},idempotencyKey:U.current()};}let Ee=await r.createClinicRequest(D.current);if(!O.current)return;if(!Ee.ok){k(Ee.error.displayMessage);return}if(Ee.value.petRef!==e.petRef){k(W("internalError").displayMessage);return}x(Ee.value),D.current=null,l?.(Ee.value);}catch{O.current&&k(W("internalError").displayMessage);}finally{$.current=false,O.current&&E(false);}}}},[s,n,t.clinic,a,r,v,B,e.petRef,q,ee,l,u,de,N,J]),rt=useCallback(()=>{D.current=null,k(null);},[]);return {title:c?me.titleFreeText:me.titleDirectory,clinicName:a,isFreeText:c,authorized:s,ownerName:u,email:y,emailError:H,needsEmail:q,directoryClinicNoEmail:q&&t.clinic!==null,copy:v,copyError:b,scope:N,error:T,busy:_,created:B,ready:Ce,signatures:A,reuseSignatureId:de,hasSignature:ie,setAuthorized(Ee){$.current||(rt(),d(Ee));},setOwnerName(Ee){$.current||(rt(),m(Ee));},setEmail(Ee){$.current||(rt(),R(false),g(Ee));},setSigned(Ee){$.current||(rt(),M(Ee),Ee&&G(null));},pickReuseSignature(Ee){$.current||(rt(),G(Ee));},retryCopy(){C(null),I(Ee=>Ee+1);},submit:Le}}i(pd,"useRecordsConsentForm");function Ns(e){let{userRef:t,scopeEpoch:r}=Te();return jsx(Ue,{capability:"recordsClinic",style:e.style,...$e(e.onBack,ot),children:t===null?jsx(p,{accessibilityRole:"alert",children:ve.sessionRequired}):jsx(ag,{...Be(e,["onCreated","onNavigate","onBack"])},JSON.stringify([t,r,e.petRef,e.clinic.key]))})}i(Ns,"EverfurRecordsConsent");function ag({petRef:e,petName:t,clinic:r,ownerName:o,onCaptureSignature:n,onCreated:l,controller:a,onNavigate:c,onBack:s,style:d}){let u=Re(),m=lg(),y=V(),g=Zt(),w=xr(),[R,v]=useState(null),[f,b]=useState("draw"),C=useCallback(async()=>R===null?null:{signaturePngBase64:R},[R]),h=pd({petRef:e,petName:t,ownerName:o??"",clinic:r,controller:a??g,depthClient:w,capture:n?()=>n({petRef:e,petName:ke(t),ownerName:h.ownerName,clinicName:h.clinicName,authorizationVersion:h.copy?.authorizationVersion??"",scopeText:h.scope??"",signal:new AbortController().signal}):C,hostCapture:n!==void 0,onCreated:i(_=>{l?.(_),c?.({name:"dashboard"});},"onCreated")}),I=useRef(h);I.current=h;let T=useCallback(_=>{v(_),I.current.setSigned(_!==null);},[]),k=h.busy;return jsxs(View,{style:[u.root,d],children:[jsx(it,{title:h.title,onBack:s,testID:"records-consent-header"}),jsxs(KeyboardAvoidingView,{behavior:"padding",style:u.body,children:[jsxs(ScrollView,{contentContainerStyle:m.content,keyboardShouldPersistTaps:"handled",testID:"records-consent",children:[jsx(p,{style:m.lead,testID:"records-consent-lead",children:me.leadNative}),jsxs(View,{style:m.scopeCard,accessibilityRole:"summary",children:[jsx(p,{style:m.scopeHeading,accessibilityRole:"header",children:me.scopeHeading}),jsx(p,{style:m.scopeBody,children:me.scopeBody}),jsx(View,{style:m.bullets,children:me.whatWeDo.map(_=>jsxs(View,{style:m.bulletRow,children:[jsx(p,{style:m.check,children:"\u2713"}),jsx(p,{style:m.bulletText,children:_})]},_))}),jsx(View,{style:m.retentionRow,children:jsx(p,{style:m.retentionText,children:me.retentionNote})}),h.copy&&h.scope?jsx(p,{style:m.serverScope,testID:"records-consent-scope",children:h.scope}):h.copyError?jsxs(Fragment,{children:[jsx(p,{style:u.errorText,accessibilityRole:"alert",children:h.copyError.displayMessage}),jsx(X,{label:ve.retry,kind:"outline",onPress:h.retryCopy,testID:"records-consent-copy-retry"})]}):jsx(p,{style:u.muted,accessibilityLiveRegion:"polite",children:ve.loading})]}),jsxs(Pressable,{onPress:()=>h.setAuthorized(!h.authorized),accessibilityRole:"checkbox",accessibilityState:{checked:h.authorized},accessibilityLabel:me.authorizeLabel(t),hitSlop:6,style:[m.toggle,h.authorized?m.toggleChecked:null],testID:"records-authorize-toggle",children:[jsx(View,{style:[m.box,h.authorized?m.boxChecked:null],accessibilityElementsHidden:true,importantForAccessibility:"no",children:h.authorized?jsx(p,{style:m.boxCheck,children:"\u2713"}):null}),jsx(p,{style:m.toggleLabel,children:me.authorizeLabel(t)})]}),jsxs(View,{style:m.block,children:[jsx(p,{style:u.fieldLabel,children:me.fullName}),jsx(Qe,{accessibilityLabel:me.fullName,style:u.field,value:h.ownerName,placeholder:me.fullNamePlaceholder,placeholderTextColor:y.color.text.placeholder,maxLength:200,editable:!k,autoComplete:"name",autoCapitalize:"words",onChangeText:h.setOwnerName,testID:"records-consent-owner-name"})]}),h.needsEmail?jsxs(View,{style:m.block,testID:"records-consent-email-block",children:[h.directoryClinicNoEmail?jsx(View,{style:u.cautionNote,testID:"records-consent-no-email-note",children:jsx(p,{style:u.cautionNoteText,children:me.noEmailNote(t,h.clinicName)})}):null,jsx(p,{style:u.fieldLabel,children:me.emailLabel}),jsx(Qe,{accessibilityLabel:me.emailLabel,style:u.field,value:h.email,placeholder:me.emailPlaceholder,placeholderTextColor:y.color.text.placeholder,maxLength:320,editable:!k,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,onChangeText:h.setEmail,testID:"records-consent-clinic-email"}),h.emailError?jsx(p,{style:u.errorText,accessibilityRole:"alert",children:h.emailError}):null,jsx(p,{style:u.muted,testID:"records-consent-review-note",children:me.newClinicDirectSendNote})]}):null,n?null:jsxs(View,{style:m.signatureBlock,children:[h.signatures.length>0?jsxs(View,{style:m.block,children:[jsx(p,{style:u.fieldLabel,children:me.reuseSignature}),jsx(ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,contentContainerStyle:m.gallery,children:h.signatures.map(_=>{let E=h.reuseSignatureId===_.signatureId;return jsx(Pressable,{onPress:()=>h.pickReuseSignature(E?null:_.signatureId),accessibilityRole:"button",accessibilityLabel:E?me.reuseTileSelectedA11y:me.reuseTileA11y,style:[m.tile,E?m.tileSelected:null],testID:`records-consent-reuse-${_.signatureId}`,children:jsx(Image,{source:{uri:_.previewUrl},style:m.tileImage,resizeMode:"contain",accessibilityIgnoresInvertColors:true})},_.signatureId)})}),jsx(p,{style:u.muted,children:me.reuseHint})]}):null,jsx(View,{style:m.signatureHeader,children:jsx(p,{style:u.fieldLabel,children:f==="type"?me.signType:me.signDraw})}),jsx($r,{onChange:T,disabled:k}),jsx(Pressable,{onPress:()=>b(_=>_==="draw"?"type":"draw"),accessibilityRole:"button",accessibilityLabel:f==="draw"?me.toTypeA11y:me.toDraw,style:m.modeToggle,testID:"records-consent-sign-mode-toggle",children:jsx(p,{style:m.modeToggleText,children:f==="draw"?me.toType:me.toDraw})}),jsx(p,{style:u.muted,children:me.signatureHint(h.clinicName)})]}),jsxs(View,{style:m.nextCard,accessibilityRole:"summary",testID:"records-consent-next",children:[jsx(p,{style:m.scopeHeading,accessibilityRole:"header",children:me.whatHappensNext}),jsx(p,{style:m.scopeBody,children:me.whatHappensNextBody})]}),h.error?jsx(View,{style:u.errorBanner,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",children:jsx(p,{style:u.errorText,children:h.error})}):null,h.created?jsx(p,{accessibilityLiveRegion:"polite",style:u.bodyText,children:h.created.statusLabel||ve.records}):null]}),jsx(View,{style:m.footer,children:jsx(X,{label:k?me.submitting:me.submit,accessibilityLabel:me.submitA11y,disabled:!h.ready,busy:k,onPress:()=>{h.submit();},style:m.submit,testID:"records-consent-submit"})})]}),jsx(je,{})]})}i(ag,"ConsentBody");function lg(){let e=V();return useMemo(()=>cg(e),[e])}i(lg,"useLocalStyles");function cg(e){let{color:t,space:r,radius:o,type:n}=e,l=StyleSheet.hairlineWidth,a=i((c,s,d,u="regular")=>({...S(e,u),fontSize:c,lineHeight:Math.round(c*s),color:d}),"text");return StyleSheet.create({content:{paddingHorizontal:r.lg,paddingBottom:r.xl+r.xs,gap:r.lg+r.xs/2},lead:a(n.size.body,n.lineHeight.normal,t.text.muted),scopeCard:{borderRadius:o.lg,borderWidth:1,borderColor:t.borderRingCream,backgroundColor:t.surfaceCream,padding:r.lg,gap:r.md},nextCard:{borderRadius:o.lg,backgroundColor:t.surfaceSubtle,padding:r.lg,gap:r.sm},scopeHeading:{...a(n.size.subtitle,n.lineHeight.snug,t.brandInk,"bold"),letterSpacing:-0.4},scopeBody:a(n.size.bodyTight,n.lineHeight.relaxed,t.text.primary),bullets:{gap:r.sm},bulletRow:{flexDirection:"row",alignItems:"flex-start",gap:r.sm},check:{...a(n.size.body,n.lineHeight.normal,t.brandInk,"bold")},bulletText:{flex:1,...a(n.size.bodyTight,n.lineHeight.normal,t.text.primary)},retentionRow:{paddingTop:r.xs,borderTopWidth:1,borderTopColor:t.borderHairlineGreen},retentionText:a(n.size.tiny,n.lineHeight.normal,t.text.muted),serverScope:{...a(n.size.bodyTight,n.lineHeight.relaxed,t.text.secondary),paddingTop:r.xs},toggle:{flexDirection:"row",alignItems:"flex-start",gap:r.md,borderRadius:o.lg-r.xs,borderWidth:l,borderColor:t.brandBorder,backgroundColor:t.surface,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md+r.xs/2},toggleChecked:{borderColor:t.brandInk,backgroundColor:t.brandSoft},box:{width:r.xl,height:r.xl,borderRadius:o.xs+1,borderWidth:1.6,borderColor:t.brandInk,alignItems:"center",justifyContent:"center",backgroundColor:t.surface},boxChecked:{backgroundColor:t.brandInk},boxCheck:{...a(n.size.body,n.lineHeight.tight,t.surface,"bold")},toggleLabel:{flex:1,...a(n.size.bodyTight,n.lineHeight.normal,t.text.primary,"bold")},block:{gap:r.sm},signatureBlock:{gap:r.sm},gallery:{gap:r.sm,paddingVertical:r.xs},tile:{width:r.xxl*3+r.lg,height:r.xxl+r.lg+r.sm,borderRadius:o.sm,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,overflow:"hidden"},tileSelected:{borderColor:t.brandInk,borderWidth:2},tileImage:{width:"100%",height:"100%"},signatureHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},modeToggle:{minHeight:r.xxl+r.md,alignItems:"center",justifyContent:"center"},modeToggleText:{...a(n.size.bodyTight,n.lineHeight.snug,t.linkInk,"bold"),textDecorationLine:"underline"},footer:{paddingHorizontal:r.lg,paddingTop:r.md,paddingBottom:r.xxl,borderTopWidth:l,borderTopColor:t.borderHairlineGreen,backgroundColor:t.background},submit:{minHeight:r.xxl+r.lg+r.xs+r.xs/2}})}i(cg,"makeLocalStyles");function bd(e){let t={uri:e.uri,mimeType:e.mimeType},r=ug(e);return r!==null&&(t.sizeBytes=r),Object.freeze(t)}i(bd,"fileHandleFromMedia");function ug(e){let t=e.byteSize??e.sizeBytes;return typeof t=="number"&&Number.isFinite(t)&&t>=0?t:null}i(ug,"mediaByteSize");function hd(e,t){return Object.freeze(t===void 0?{mode:e}:{mode:e,maxDurationSeconds:t})}i(hd,"captureOptionsFor");function zo(e){return e!=null&&e.isAvailable===true}i(zo,"isCaptureAvailable");Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function No(e){return e==="above"||e==="below"?"critical":e==="in_range"?"positive":"neutral"}i(No,"markerStatusTone");function pg(e){switch(e){case "above":return "above the reference range";case "below":return "below the reference range";case "in_range":return "within range";default:return "no reference range on file"}}i(pg,"markerStatusSpoken");function mg(e){return e.refLow!==null&&e.refHigh!==null?`, reference range ${e.refLow} to ${e.refHigh}`:e.refLow!==null?`, reference range at least ${e.refLow}`:e.refHigh!==null?`, reference range up to ${e.refHigh}`:""}i(mg,"rangePhrase");function Mo(e,t){let r=t?` ${t}`:"";return e.refLow!==null&&e.refHigh!==null?`${e.refLow}-${e.refHigh}${r}`:e.refLow!==null?`\u2265 ${e.refLow}${r}`:e.refHigh!==null?`\u2264 ${e.refHigh}${r}`:"-"}i(Mo,"formatReferenceRange");function Rd(e,t){let r=t.reviewed?", reviewed by our team":"",o=t.sourceClinic?`, from ${t.sourceClinic}`:"";return `${re(t.at)}: ${Vt(t.value,e.unit,t.qualitativeResult)}, ${pg(t.status)}${mg(t)}${o}${r}`}i(Rd,"markerPointSpoken");function at(e){return e?.trim()||"my pet"}i(at,"lead");function vd(e){let t=e.trim();return /[.!?]$/.test(t)?t:`${t}.`}i(vd,"clause");function wd(e,t){let r=t.canonicalName.trim()||"a lab marker",o=[`I'm looking at ${at(e)}'s ${r}`],n=[t.latestValueText?.trim(),t.statusText?.trim(),t.trajectoryText?.trim()].filter(Boolean).join(", ");return o[0]+=n?`: ${n}.`:".",t.meaningText?.trim()&&o.push(vd(t.meaningText)),o.push(`What does this trend tell me, and should I do anything differently for ${at(e)}?`),{prompt:o.join(" "),entityRef:{type:"marker",id:t.markerId,payload:{marker:r,...t.statusText?.trim()?{status:t.statusText.trim()}:{}}}}}i(wd,"buildMarkerAskPrompt");function xd(e,t,r){let{totalMarkers:o,inRangeCount:n,outOfRangeCount:l,unknownCount:a}=t;if(o===0)return {prompt:`I'm looking at ${at(e)}'s lab markers, but there aren't any on file yet. What lab work is worth running for ${at(e)}?`,entityRef:{type:"marker_summary",id:r,payload:{total:0}}};let c=a>0?`, ${a} without a reference range`:"";return {prompt:`I'm looking at ${at(e)}'s lab markers: ${o} total, ${n} in range, ${l} out of range${c}. What should I focus on?`,entityRef:{type:"marker_summary",id:r,payload:{total:o,inRange:n,outOfRange:l,unknown:a}}}}i(xd,"buildMarkerSummaryAskPrompt");function Cd(e,t){let r=t.canonicalName.trim()||"a lab marker",o=[`${r}: ${t.valueText.trim()}`];t.collectedAt?.trim()&&o.push(`collected ${t.collectedAt.trim()}`),t.sourceClinic?.trim()&&o.push(`from ${t.sourceClinic.trim()}`),t.referenceText?.trim()&&o.push(`reference range ${t.referenceText.trim()}`),t.flagged&&o.push(`flagged ${t.flagged}`);let n={marker:r};return t.flagged&&(n.status=t.flagged),t.reviewed!==void 0&&(n.reviewed=t.reviewed),{prompt:`I'm looking at ${at(e)}'s ${o.join(", ")}. What does this mean, and should I be concerned?`,entityRef:{type:"lab_reading",id:t.entityId,payload:n}}}i(Cd,"buildMarkerReadingAskPrompt");function Ho(e,t,r){let o=t.clinicName?.trim(),n=t.heldItemCount??0,l=n>0?`, ${n} fact${n===1?"":"s"} being verified`:"";return {prompt:`I'm looking at ${at(e)}'s records request${o?` to ${o}`:""}, status: ${t.statusLabel.trim()}${l}. What does this status mean, and what happens next?`,entityRef:{type:"records_request",id:r,payload:{status:t.status,held:n,...o?{clinic:o}:{}}}}}i(Ho,"buildRecordsRequestAskPrompt");var yg=Object.freeze({vaccination:"vaccine",medication:"medication",body_weight:"weight",vital:"weight"});function Ms(e,t,r,o){let n=t.entityTypeLabel.trim()||"record",l=t.title.trim()||n,a=t.detail?.trim();return {prompt:`I'm looking at ${at(e)}'s ${n.toLowerCase()}: ${l}${a?`, ${a}`:""}. What does this mean, and what should I keep on top of for ${at(e)}?`,entityRef:{type:yg[r]??r,id:o,payload:{kind:n,title:l,...a?{detail:a}:{}}}}}i(Ms,"buildEntityRowAskPrompt");function Ed(e,t,r){let o=t.filter(a=>a.label.trim()),n={type:"upcoming_care",id:r};if(o.length===0)return {prompt:`I'm looking at ${at(e)}'s upcoming care, but nothing is scheduled yet. What preventive care and checkups should ${at(e)} be on?`,entityRef:n};let l=[...o].sort((a,c)=>(a.tone==="overdue"?0:1)-(c.tone==="overdue"?0:1)).slice(0,4).map(a=>a.relativeText.trim()?`${a.label.trim()} (${a.relativeText.trim().toLowerCase()})`:a.label.trim());return {prompt:`I'm looking at ${at(e)}'s upcoming care: ${l.join(", ")}. What should I prioritize for ${at(e)}, and how do I stay on top of these?`,entityRef:n}}i(Ed,"buildUpcomingCareAskPrompt");function Sd(e,t,r){let o=[`I'm looking at ${at(e)}'s physical exam${t.observedOn?.trim()?` from ${t.observedOn.trim()}`:""}.`],n=t.abnormal.filter(l=>l.system.trim());return n.length>0?(o.push(`Abnormal: ${n.slice(0,6).map(l=>`${l.system.trim()}: ${l.finding.trim()}`).join("; ")}.`),o.push(`What do these findings mean, and what should I follow up on for ${at(e)}?`)):o.push(`Everything examined came back normal. What does this tell me about ${at(e)}'s health?`),{prompt:o.join(" "),entityRef:{type:"physical_exam",id:r}}}i(Sd,"buildPhysicalExamAskPrompt");function Td(e,t,r){let o=[`I'm looking at ${at(e)}'s visit notes${t.observedOn?.trim()?` from ${t.observedOn.trim()}`:""}.`];for(let n of t.sections.filter(l=>l.text.trim()).slice(0,3))o.push(`${n.label.trim()||"Note"}: ${vd(n.text)}`);return o.push(`Can you summarize what happened and what I should follow up on for ${at(e)}?`),{prompt:o.join(" "),entityRef:{type:"visit",id:r}}}i(Td,"buildVisitNoteAskPrompt");function kd(e,t,r){let o=t.scopeLabel.trim()||"a detail",n=t.candidates.filter(a=>a.value.trim()),l=n.slice(0,3).map(a=>`"${a.value.trim()}"${a.clinicName?.trim()?` (${a.clinicName.trim()})`:""}`).join(" vs ");return {prompt:`Two of ${at(e)}'s documents disagree on ${o}: ${l}. Which is likely correct, and what should I ask my vet?`,entityRef:{type:"conflict",id:r,payload:{field:o,severity:t.severity,values:n.map(a=>a.value.trim()).join(" | ")}}}}i(kd,"buildConflictAskPrompt");var St=Object.freeze({title:"Medical records",subtitle:i(e=>{let t=e?.trim()??"";return t.length>0?`${t}\u2019s uploads and clinic requests`:"Every upload and clinic request"},"subtitle"),requestRecords:"Request records",requestRecordsA11y:"Request records from a clinic",uploadOwn:"I already have the records",uploadOwnA11y:"Upload records you already have",ownerUpload:"Records you uploaded",clinicRequest:"Clinic request",meta:i((e,t)=>`${e?"Uploaded":"Requested"} ${re(t)}`,"meta"),rowA11y:i((e,t,r)=>`${e}, ${t}, status ${r}`,"rowA11y"),askA11y:i(e=>`Ask Everfur about ${e}`,"askA11y"),allRequests:"Your record requests"}),Bo=Object.freeze({preparing:"Preparing",sent:"Sent",processing:"Processing",done:"Ready"});function fg(e){switch(e){case "awaiting_clinic":return Bo.sent;case "received":case "parsing":case "in_review":return Bo.processing;case "published":return Bo.done;default:return Bo.preparing}}i(fg,"stepLabel");function _d(e){let t=e.source==="owner_provided",r=e.clinicName?.trim()||(t?St.ownerUpload:St.clinicRequest),o=e.statusLabel.trim()||fg(e.status),n=St.meta(t,e.createdAt);return Object.freeze({source:r,meta:n,status:o,ownerUpload:t,a11yLabel:St.rowA11y(r,n,o)})}i(_d,"requestRowView");var gg=new Set(["records_received","parsing","parsing_failed","in_review","review_email_failed"]),bg=new Set(["received","parsing","in_review"]);function hg(e){return e.wireStatus!==void 0?gg.has(e.wireStatus):bg.has(e.status)}i(hg,"isProcessing");function Pd(e,t,r={}){let o=e.filter(c=>!kr(c.status));if(e.length===0||r.activeOnly===true&&o.length===0)return null;let n=e.filter(hg).length,l=n>0?`${n} document${n===1?"":"s"} being read`:o.length>0?`${o.length} active record request${o.length===1?"":"s"}`:St.allRequests,a=n>0?`We\u2019ll add ${n===1?"it":"them"} to ${t}\u2019s records once ready.`:o.length>0?"See each clinic\u2019s status and what happens next.":"See the status of every upload and clinic request.";return Object.freeze({title:l,subtitle:a,processing:n>0,a11yLabel:`${l}. ${a}`})}i(Pd,"requestsStatusCardView");function Hn(e){return e!==void 0}i(Hn,"canUploadRecords");function Hs(e,t){return e??t?.version??""}i(Hs,"resolveConsentVersion");function Gr(e,t){return Hs(e,t).length>0}i(Gr,"canGrantConsent");function qr(e,t){return e.denialReason==="consent_required"?t?{kind:"consent_required"}:{kind:"consent_unavailable"}:e.denialReason==="pet_not_found"?{kind:"pet_not_found",error:W("petNotFound",{retryable:false})}:e.denialReason==="entitlement"?{kind:"error",error:W("accessDenied")}:e.denialReason==="session_required"?{kind:"session_required"}:e.withheld?{kind:"withheld"}:e.error===null?{kind:"withheld"}:{kind:"error",error:e.error}}i(qr,"selectErrorView");function Uo(e){let t=e.clinicName?.trim()??"";return t.length>0?t:e.source==="owner_provided"?Id.ownerUpload:Id.clinicRequest}i(Uo,"selectRequestTitle");var Id=Object.freeze({ownerUpload:"Records you uploaded",clinicRequest:"Record request"});function Bs(e,t){return t===null||t.status!=="awaiting_upload"?null:t}i(Bs,"selectResumableUploadRequest");function Us(e){let t=[...e].sort((r,o)=>r.updatedAt!==o.updatedAt?r.updatedAt>o.updatedAt?-1:1:r.createdAt!==o.createdAt?r.createdAt>o.createdAt?-1:1:0);return Object.freeze(t)}i(Us,"selectRequestList");function Yr(e){let t=e.actionNeededLabel?.trim()??"";return t.length>0?t:e.statusLabel}i(Yr,"selectPrimaryLabel");function jo(e){if(e.showClinicPhone!==true)return null;let t=e.clinicPhone?.trim()??"";return t.length===0?null:{phone:t,dial:`tel:${t.replace(/[^+\d]/g,"")}`,clinicName:e.clinicName?.trim()||null}}i(jo,"selectClinicCall");function Dd(e){switch(e.wireStatus??e.status){case "published":return "positive";case "failed":case "clinic_declined":return "critical";case "revoked":return "neutral";case "clinic_responded_no_records":case "awaiting_upload":case "records_received":case "parsing":case "parsing_failed":case "in_review":case "review_email_failed":return "warning";default:return "info"}}i(Dd,"selectRequestStatusTone");var kt=200,Od=16;function vg(e,t){let r=e.inRangeCount+e.outOfRangeCount+e.unknownCount;if(!Number.isFinite(r)||r<=0)return [];let o=[{key:"in_range",color:t.inRange,count:e.inRangeCount},{key:"out_of_range",color:t.outOfRange,count:e.outOfRangeCount},{key:"unknown",color:t.unknown,count:e.unknownCount}],n=0,l=[];for(let a of o){if(!(a.count>0))continue;let c=a.count/r*360;if(!Number.isFinite(c))return null;l.push({key:a.key,color:a.color,startDeg:n,sweepDeg:c}),n+=c;}return l}i(vg,"buildRingSegments");function Vd({summary:e,onAsk:t,testID:r}){let o=xg(),n=V(),{totalMarkers:l,inRangeCount:a,outOfRangeCount:c,unknownCount:s}=e,d=useMemo(()=>vg(e,{inRange:n.color.success,outOfRange:n.color.danger,unknown:n.color.text.muted}),[e,n]),u=d!==null&&d.length>0;return jsxs(View,{style:o.card,accessibilityRole:"summary",testID:r,children:[jsx(p,{style:o.title,children:Qt.title}),jsx(View,{style:o.ringRow,accessible:true,accessibilityRole:"image",accessibilityLabel:Qt.a11y(l,a,c,s),children:jsxs(View,{style:o.ringWrap,children:[jsx(View,{style:o.track}),d===null?null:d.map(m=>jsx(wg,{segment:m,styles:o},m.key)),jsxs(View,{style:o.center,pointerEvents:"none",children:[jsx(p,{style:o.centerCount,children:l}),jsx(p,{style:o.centerLabel,children:l===1?Qt.marker:Qt.markers})]})]})}),u||d===null?jsxs(View,{style:o.badges,children:[jsx(js,{count:c,label:Qt.outOfRange,color:n.color.danger,styles:o}),jsx(js,{count:a,label:Qt.inRange,color:n.color.success,styles:o}),s>0?jsx(js,{count:s,label:Qt.noRange,color:n.color.text.muted,styles:o}):null]}):null,jsx(p,{style:o.subtitle,children:Qt.subtitle}),t?jsx(Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:Qt.askA11y,style:o.ask,testID:"marker-summary-ask",children:jsx(p,{style:o.askLabel,children:Qt.ask})}):null]})}i(Vd,"MarkerSummaryCard");function wg({segment:e,styles:t}){return (e.sweepDeg<=180?[{start:e.startDeg,sweep:e.sweepDeg}]:[{start:e.startDeg,sweep:180},{start:e.startDeg+180,sweep:e.sweepDeg-180}]).map((o,n)=>jsx(View,{style:[t.piece,{transform:[{rotate:`${o.start}deg`}]}],pointerEvents:"none",testID:`marker-ring-${e.key}`,children:jsx(View,{style:t.window,children:jsx(View,{style:[t.halfRing,{borderTopColor:e.color,borderRightColor:e.color,transform:[{rotate:`${o.sweep-135}deg`}]}]})})},n))}i(wg,"Arc");function js({count:e,label:t,color:r,styles:o}){return jsx(View,{style:[o.badge,{borderColor:r}],children:jsx(p,{style:[o.badgeText,{color:r}],children:`${e} ${t}`})})}i(js,"Badge");function xg(){let e=V();return useMemo(()=>Cg(e),[e])}i(xg,"useStyles");function Cg(e){let{color:t,space:r,radius:o,type:n,slots:l}=e,a=StyleSheet.hairlineWidth,c=yt(l.recordCard);return StyleSheet.create({card:{borderRadius:o.lg,backgroundColor:t.surfaceCream,borderWidth:1,borderColor:t.borderRingCream,padding:r.lg,gap:r.sm+r.xs/2,...dt(l.recordCard,1)},title:{...S(e,"bold"),fontSize:n.size.subtitle,lineHeight:Math.round(n.size.subtitle*n.lineHeight.snug),color:t.brandInk,letterSpacing:-0.4,...c},ringRow:{alignItems:"center"},ringWrap:{width:kt,height:kt,alignItems:"center",justifyContent:"center"},track:{position:"absolute",width:kt,height:kt,borderRadius:kt/2,borderWidth:Od,borderColor:t.surfaceSubtle},piece:{position:"absolute",width:kt,height:kt},window:{position:"absolute",left:kt/2,top:0,width:kt/2,height:kt,overflow:"hidden"},halfRing:{position:"absolute",left:-kt/2,top:0,width:kt,height:kt,borderRadius:kt/2,borderWidth:Od,borderBottomColor:"transparent",borderLeftColor:"transparent"},center:{position:"absolute",alignItems:"center",justifyContent:"center"},centerCount:{...S(e,"medium"),fontSize:n.size.verdict*2,lineHeight:n.size.verdict*2+r.xs,color:t.text.primary,textAlign:"center",...c},centerLabel:{...S(e,"medium"),fontSize:n.size.heading-1,lineHeight:n.size.heading+r.xs/2,color:t.text.primary,textAlign:"center",...c},badges:{flexDirection:"row",flexWrap:"wrap",justifyContent:"center",gap:r.sm},badge:{borderWidth:1,borderRadius:o.pill,paddingHorizontal:r.sm+r.xs/2,paddingVertical:r.xs},badgeText:{...S(e,"mono"),fontSize:n.size.nano,lineHeight:n.size.tiny,letterSpacing:n.letterSpacing.headerBrand/2,textTransform:"uppercase"},subtitle:{...S(e,"regular"),fontSize:n.size.caption,lineHeight:Math.round(n.size.caption*n.lineHeight.relaxed),color:t.text.primary,...c},ask:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:r.sm,minHeight:r.xxl+r.sm,marginTop:r.xs/2,paddingHorizontal:r.lg,borderRadius:o.pill,borderWidth:a,borderColor:t.borderRingCream,backgroundColor:t.surface},askLabel:{...S(e,"bold"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*n.lineHeight.snug),color:t.text.primary,letterSpacing:n.letterSpacing.tight}})}i(Cg,"makeStyles");function Eg(e){return e.value!==null&&Number.isFinite(e.value)}i(Eg,"numeric");function Fd(e){let t=e.points.filter(Eg);if(t.length===0)return null;let r=e.points[e.points.length-1]??null,o=r?.refLow??null,n=r?.refHigh??null,l=t.map(f=>f.value),a=Math.min(...l,...o!==null?[o]:[],...n!==null?[n]:[]),c=Math.max(...l,...o!==null?[o]:[],...n!==null?[n]:[]);a===c&&(a-=1,c+=1);let s=(c-a)*.18,d=a-s,u=c+s,m=u-d,y=i(f=>(u-f)/m*100,"y"),g=6,w=t.length,R=t.map((f,b)=>({index:b,xPct:w<=1?50:g+b/(w-1)*(100-2*g),yPct:y(f.value),status:f.status,point:f})),v=o!==null||n!==null?{topPct:n!==null?y(n):0,bottomPct:o!==null?y(o):100}:null;return {points:R,band:v,firstDate:t[0]?.at??null,lastDate:t[t.length-1]?.at??null}}i(Fd,"buildMarkerChart");var kg=416,_g=140;function Wo(e){return `${e}%`}i(Wo,"pct");function Pg({marker:e,width:t,onPointPress:r,onAsk:o}){let n=$s(),l=Re(),a=pr(e.latest?.status??null),c=No(e.latest?.status??null),s=nn(e.trajectory,e.points.length),d=useMemo(()=>Fd(e),[e]),u=e.latest?Vt(e.latest.value,e.unit,e.latest.qualitativeResult):null;return jsx(View,{style:[n.page,t!==void 0?{width:t}:null],testID:`marker-card-${e.markerId}`,children:jsxs(View,{style:n.card,children:[jsxs(View,{style:n.headerRow,children:[jsxs(View,{style:n.nameColumn,children:[jsx(p,{style:n.markerName,numberOfLines:2,children:e.name}),e.unit?jsx(p,{style:n.unit,children:e.unit}):null]}),jsx(View,{accessible:true,accessibilityRole:"text",accessibilityLabel:hr.status(a.label),children:jsx(Lt,{label:a.label,tone:c})})]}),e.latest&&u!==null?jsxs(View,{style:n.latestRow,children:[jsx(p,{style:[n.latestValue,a.outOfRange?n.latestValueDanger:null],accessibilityLabel:hr.latestA11y(u,a.label,re(e.latest.at)),children:u}),jsx(p,{style:n.latestDate,children:re(e.latest.at)})]}):null,s?jsx(p,{style:n.trajectory,accessibilityRole:"text",children:s}):null,d!==null?jsxs(View,{style:n.chartWrap,children:[jsxs(View,{style:n.plot,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:[d.band?jsx(View,{style:[n.band,{top:Wo(d.band.topPct),height:Wo(Math.max(0,d.band.bottomPct-d.band.topPct))}]}):null,d.points.map(m=>jsx(Pressable,{onPress:()=>r(e,m.point),hitSlop:12,style:[n.point,m.status==="above"||m.status==="below"?n.pointDanger:null,{left:Wo(m.xPct),top:Wo(m.yPct)}],testID:`marker-point-${e.markerId}-${m.index}`},m.index))]}),jsx(View,{style:n.a11yTable,accessibilityRole:"summary",accessibilityLabel:hr.readingsA11y(e.name),children:e.points.map((m,y)=>jsx(View,{accessibilityRole:"text",accessibilityLabel:Rd(e,m)},y))}),jsx(p,{style:e.points.length===1?n.singleHint:n.tapHint,children:e.points.length===1?hr.singleHint:hr.tapHint})]}):jsx(View,{style:n.emptyBody,accessibilityRole:"text",children:jsx(p,{style:n.emptyText,children:hr.empty})}),o?jsx(Pressable,{onPress:()=>o(e),accessibilityRole:"button",accessibilityLabel:hr.askA11y(e.name),style:[l.pill,l.pillAsk],testID:`marker-ask-${e.markerId}`,children:jsx(p,{style:l.pillAskLabel,children:hr.askNamed(e.name)})}):null]})})}i(Pg,"MarkerTrendCard");function Md({markers:e,onPointPress:t,onAsk:r}){let o=$s(),[n,l]=useState(0),[a,c]=useState(0),s=i(m=>l(m.nativeEvent.layout.width),"onLayout"),d=i(m=>{if(n<=0)return;let y=Math.round(m.nativeEvent.contentOffset.x/n);c(Math.max(0,Math.min(y,e.length-1)));},"onMomentumEnd"),u=e[a]??null;return jsxs(View,{style:o.carousel,onLayout:s,testID:"marker-carousel",children:[jsx(ScrollView,{horizontal:true,pagingEnabled:true,showsHorizontalScrollIndicator:false,onMomentumScrollEnd:d,snapToAlignment:"start",children:e.map(m=>jsx(Pg,{marker:m,width:n>0?n:void 0,onPointPress:t,onAsk:r},m.markerId))}),jsxs(View,{style:o.footer,accessible:true,accessibilityRole:"adjustable",accessibilityLabel:Yi.a11y(u?.name??null,a,e.length),children:[jsx(View,{style:o.dots,children:e.map((m,y)=>jsx(View,{style:[o.dot,y===a?o.dotActive:null]},m.markerId))}),jsx(p,{style:o.counter,children:Yi.counter(a,e.length)})]})]})}i(Md,"MarkerTrendCarousel");function Hd({marker:e,point:t,onClose:r,onAsk:o}){let n=$s(),l=Re();if(e===null||t===null)return null;let a=i((c,s)=>jsxs(View,{style:n.detailRow,accessible:true,accessibilityRole:"text",accessibilityLabel:`${c}: ${s}`,children:[jsx(p,{style:n.detailLabel,children:c}),jsx(p,{style:n.detailValue,children:s})]},c),"row");return jsxs(Modal,{transparent:true,visible:true,animationType:"slide",onRequestClose:r,children:[jsx(Pressable,{style:n.backdrop,onPress:r,accessibilityRole:"button",accessibilityLabel:At.close}),jsxs(View,{style:n.sheet,accessibilityViewIsModal:true,testID:"marker-provenance-sheet",children:[jsx(View,{style:n.handle}),jsxs(View,{style:n.sheetHeader,children:[jsx(p,{style:n.sheetTitle,accessibilityRole:"header",children:At.title}),jsx(Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:At.close,hitSlop:10,style:n.closeButton,testID:"marker-provenance-close",children:jsx(p,{style:n.closeGlyph,children:"\xD7"})})]}),jsxs(View,{style:n.sheetBody,children:[jsxs(View,{style:n.valueRow,children:[jsx(p,{style:n.sheetName,children:e.name}),jsx(p,{style:n.sheetValue,children:Vt(t.value,e.unit,t.qualitativeResult)})]}),t.reviewed?jsx(View,{style:n.reviewed,accessibilityRole:"text",children:jsx(p,{style:n.reviewedText,children:At.reviewed})}):null,a(At.collected,re(t.at)),t.sourceClinic?a(At.clinic,t.sourceClinic):null,a(At.referenceRange,t.refLow!==null||t.refHigh!==null?Mo(t,e.unit):At.noRange),t.docId?a(At.sourceDocument,t.docId):null,t.reviewed?null:jsx(p,{style:n.unverified,accessibilityRole:"text",children:At.unverified}),o?jsx(Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:At.askA11y,style:[l.pill,l.pillAsk],testID:"marker-provenance-ask",children:jsx(p,{style:l.pillAskLabel,children:At.ask})}):null]})]})]})}i(Hd,"MarkerProvenanceSheet");function $s(){let e=V();return useMemo(()=>Ig(e),[e])}i($s,"useStyles");function Ig(e){let{color:t,space:r,radius:o,type:n,slots:l}=e,a=StyleSheet.hairlineWidth,c=r.md,s=i((y,g,w,R="regular")=>({...S(e,R),fontSize:y,lineHeight:Math.round(y*g),color:w}),"text"),d=yt(l.recordCard),u=s(n.size.subtitle,n.lineHeight.snug,t.text.primary,"bold"),m=s(n.size.verdict+r.xs,n.lineHeight.tight,t.text.primary,"bold");return StyleSheet.create({page:{paddingHorizontal:r.sm},card:{borderRadius:o.lg,borderWidth:1,borderColor:t.borderRingCream,backgroundColor:t.surface,padding:r.lg,gap:r.md,...dt(l.recordCard,1)},headerRow:{flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between",gap:r.sm+r.xs/2},nameColumn:{flex:1,gap:r.xs/2},markerName:{...u,...d},sheetName:u,unit:{...S(e,"mono"),fontSize:n.size.tiny,lineHeight:n.size.body,color:t.text.muted,...d},latestRow:{flexDirection:"row",alignItems:"baseline",justifyContent:"space-between",gap:r.md},latestValue:{...m,...d},sheetValue:m,latestValueDanger:{color:t.danger},latestDate:{...s(n.size.caption,n.lineHeight.normal,t.text.muted),...d},trajectory:{...s(n.size.bodyTight,n.lineHeight.normal,t.text.muted),...d},chartWrap:{gap:r.sm},plot:{height:_g,borderRadius:o.sm,backgroundColor:t.surfaceCream,borderWidth:a,borderColor:t.borderHairlineGreen,overflow:"hidden"},band:{position:"absolute",left:0,right:0,backgroundColor:t.badgeBgPositive},point:{position:"absolute",width:c,height:c,borderRadius:c/2,marginLeft:-c/2,marginTop:-c/2,backgroundColor:t.brand,borderWidth:2,borderColor:t.surface},pointDanger:{backgroundColor:t.danger},a11yTable:{width:1,height:1,overflow:"hidden",position:"absolute"},tapHint:{...s(n.size.tiny,n.lineHeight.normal,t.text.placeholder),textAlign:"center",...d},singleHint:{...s(n.size.caption,n.lineHeight.normal,t.text.muted),textAlign:"center",...d},emptyBody:{alignItems:"center",justifyContent:"center",gap:r.sm,paddingVertical:r.xxl+r.xs},emptyText:{...s(n.size.bodyTight,n.lineHeight.normal,t.text.muted),textAlign:"center",...d},carousel:{height:kg},footer:{alignItems:"center",gap:r.sm,paddingTop:r.md},dots:{flexDirection:"row",gap:r.xs+r.xs/2},dot:{width:r.xs+r.xs/2,height:r.xs+r.xs/2,borderRadius:r.xs-1,backgroundColor:t.borderHairlineGreen},dotActive:{width:r.lg+r.xs/2,backgroundColor:t.brand},counter:{...S(e,"mono"),fontSize:n.size.tiny,lineHeight:n.size.body,letterSpacing:n.letterSpacing.eyebrow/3,color:t.text.muted},backdrop:{flex:1,backgroundColor:Ro},sheet:{backgroundColor:t.surfaceCream,borderTopLeftRadius:o.xl-r.xs,borderTopRightRadius:o.xl-r.xs,paddingHorizontal:r.lg+r.xs,paddingTop:r.sm,paddingBottom:r.xxl+r.xs,maxHeight:"80%",gap:r.md},handle:{alignSelf:"center",width:r.xxl+r.xs,height:r.xs,borderRadius:o.pill,backgroundColor:t.borderRingCream},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},sheetTitle:{flex:1,...s(n.size.subtitle,n.lineHeight.snug,t.text.primary,"bold")},closeButton:{width:r.xxl+r.md,height:r.xxl+r.md,alignItems:"center",justifyContent:"center"},closeGlyph:{...s(n.size.verdict,n.lineHeight.tight,t.text.primary)},sheetBody:{gap:r.md},valueRow:{flexDirection:"row",alignItems:"baseline",justifyContent:"space-between",gap:r.md},reviewed:{alignSelf:"flex-start",borderRadius:o.pill,paddingHorizontal:r.sm+r.xs/2,paddingVertical:r.xs,backgroundColor:t.badgeBgPositive},reviewedText:{...s(n.size.tiny,n.lineHeight.normal,t.success,"medium")},detailRow:{gap:r.xs/2},detailLabel:{...s(n.size.caption,n.lineHeight.normal,t.text.muted,"medium")},detailValue:s(n.size.body,n.lineHeight.normal,t.text.primary),unverified:s(n.size.caption,n.lineHeight.normal,t.text.muted)})}i(Ig,"makeStyles");var gt=Object.freeze({editA11y:i(e=>`Edit ${e}. Correct or remove this record detail.`,"editA11y"),title:i(e=>`Edit ${e}`,"title"),helper:"Corrects your record. Your vet can still review it.",close:"Close",closeEditorA11y:"Close editor",save:"Save changes",saving:"Saving...",remove:"Remove this detail",removeA11y:i(e=>`Remove ${e}`,"removeA11y"),confirmRemove:"Remove this detail from your record? This can't be undone.",removeConfirm:"Remove",removing:"Removing...",keep:"Keep",noChange:"Change a value before saving.",saved:"Saved.",removed:"Removed.",detail:"record detail"});function Bd(e,t){return ar(e)?t==="remove"?"Records access for this pet is off, so this detail cannot be removed.":"Records access for this pet is off, so this detail cannot be changed.":ed(e)?t==="remove"?"A clinician already reviewed this detail, so it can't be removed here.":"A clinician already reviewed this detail, so it can't be changed here.":t==="remove"?"Couldn't remove that. Please check your connection and try again.":"Couldn't save that. Please check your connection and try again."}i(Bd,"factEditErrorMessage");var Dg=Object.freeze({edits:Object.freeze({}),removed:Object.freeze([])});function Ws(e,t){if(Object.keys(t.edits).length===0&&t.removed.length===0)return e;let r=[];for(let o of e){let n=o.canonicalKey??null;if(n!==null&&t.removed.includes(n))continue;let l=n!==null?t.edits[n]:void 0;r.push(l===void 0?o:Object.freeze({...o,value:l}));}return Object.freeze(r)}i(Ws,"applyFactOverlay");function Yo(e){return typeof e.canonicalKey=="string"&&e.canonicalKey.length>0}i(Yo,"isFactEditable");function Ag(){return `records-fact-${Date.now().toString(36)}`}i(Ag,"defaultFactKey");function Gs(e,t={}){let r=xr(),{userRef:o}=Te(),[n,l]=useState(Dg),[a,c]=useState(false),[s,d]=useState(null),u=useMemo(()=>({}),[r,e,o]),[m,y]=useState(null),g=useCallback(()=>y(u),[u]),w=o!==null&&m!==u,R=useRef(false),v=useRef(t.newIdempotencyKey);v.current=t.newIdempotencyKey;let f=useCallback(()=>(v.current??Ag)(),[]),b=useCallback((T,k,_)=>{if(c(false),!T.ok){if(k(),Cr(T.error)){g();return}d(Bd(T.error,_));}},[g]),C=useCallback(async(T,k)=>{let _=T.canonicalKey??"",E=k.trim();if(R.current||_.length===0||E.length===0)return te(W("validationFailed",{retryable:false}));R.current=true,c(true),d(null);let B=n;l(A=>({...A,edits:{...A.edits,[_]:E}}));let x=await r.editFact(e,{entityType:T.category,canonicalKey:_,correctedFields:Ds(T.value,E),idempotencyKey:f()});return R.current=false,b(x,()=>l(B),"edit"),x},[r,e,n,b,f]),h=useCallback(async T=>{let k=T.canonicalKey??"";if(R.current||k.length===0)return te(W("validationFailed",{retryable:false}));R.current=true,c(true),d(null);let _=n;l(B=>({...B,removed:[...B.removed,k]}));let E=await r.removeFact(e,{entityType:T.category,canonicalKey:k,idempotencyKey:f()});return R.current=false,b(E,()=>l(_),"remove"),E},[r,e,n,b,f]),I=useCallback(()=>d(null),[]);return useMemo(()=>({overlay:n,busy:a,error:s,available:w,edit:C,remove:h,clearError:I}),[n,a,s,w,C,h,I])}i(Gs,"useRecordFactEdit");var Ys=Object.freeze(["vaccination","parasite_prevention"]),Ko="Undated",Og=Object.freeze({given:"Given",prevention:"Prevention",overdue:"Overdue",noDate:"No date"}),$d=Object.freeze({given:"positive",prevention:"neutral",overdue:"critical",noDate:"neutral"});function Qo(e){if(!e)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}i(Qo,"toMillis");function Lg(e){let t=e.status?.toLowerCase()??"";return /overdue|lapsed|expired/.test(t)}i(Lg,"isLapsed");function Vg(e){return e.category==="parasite_prevention"?"prevention":Qo(e.observedAt)===null?"noDate":Lg(e)?"overdue":"given"}i(Vg,"vaccineTone");function Fg(e){let t=Qo(e);return t===null?Ko:String(new Date(t).getUTCFullYear())}i(Fg,"yearOf");function qg(e){let t=Vg(e),r=[e.value!==null&&e.value.length>0?e.value:null,e.observedAt!==null?re(e.observedAt):null].filter(o=>o!==null&&o.length>0);return {key:e.key,name:e.label,detail:r.length>0?r.join(" \xB7 "):null,statusLabel:Og[t],tone:t,entity:e}}i(qg,"buildRow");function Wd(e){let t=new Map;for(let o of e){if(!Ys.includes(o.category))continue;let n=Fg(o.observedAt),l=t.get(n),a={row:qg(o),at:o.observedAt};l===void 0?t.set(n,[a]):l.push(a);}let r=[...t.keys()].sort((o,n)=>o===Ko?1:n===Ko?-1:Number(n)-Number(o));return Object.freeze(r.map(o=>{let n=t.get(o)??[],l=o===Ko?n:[...n].sort((a,c)=>(Qo(c.at)??0)-(Qo(a.at)??0));return Object.freeze({year:o,items:Object.freeze(l.map(a=>a.row))})}))}i(Wd,"selectVaccineGroups");var Xo=Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});function Ks({entity:e,factEdit:t,children:r}){let o=Gd(),[n,l]=useState(false),a=e.label.trim()||gt.detail;return jsxs(View,{style:o.row,children:[jsx(View,{style:o.main,children:r}),jsx(Pressable,{onPress:()=>l(true),accessibilityRole:"button",accessibilityLabel:gt.editA11y(a),hitSlop:6,style:o.editButton,testID:`fact-edit-open-${e.canonicalKey??e.key}`,children:jsx(View,{style:o.pencil,accessibilityElementsHidden:true,importantForAccessibility:"no"})}),n?jsx(Ug,{entity:e,title:a,factEdit:t,onClose:()=>l(false)}):null]})}i(Ks,"FactEditAffordance");function Ug({entity:e,title:t,factEdit:r,onClose:o}){let n=Gd(),l=Re(),a=V(),[c,s]=useState(e.value??""),[d,u]=useState(null),[m,y]=useState(false);useEffect(()=>{r.clearError();},[r]);let g=c.trim().length>0&&c.trim()!==(e.value??"").trim(),w=d??r.error,R=r.busy,v=i(()=>{if(!g){u(gt.noChange);return}u(null),r.edit(e,c).then(b=>{b.ok&&o();});},"submitEdit"),f=i(()=>{u(null),r.remove(e).then(b=>{b.ok?o():y(false);});},"submitRemove");return jsx(Modal,{transparent:true,visible:true,animationType:"slide",onRequestClose:o,children:jsxs(KeyboardAvoidingView,{behavior:"padding",style:n.backdrop,children:[jsx(Pressable,{style:Xo,accessibilityRole:"button",accessibilityLabel:gt.closeEditorA11y,onPress:o}),jsxs(View,{style:n.sheet,accessibilityViewIsModal:true,testID:"fact-edit-sheet",children:[jsx(View,{style:n.handle}),jsxs(View,{style:n.header,children:[jsxs(View,{style:n.headerText,children:[jsx(p,{style:n.title,accessibilityRole:"header",children:gt.title(t)}),jsx(p,{style:[n.helper,w?n.helperError:null],accessibilityLiveRegion:"polite",children:w??gt.helper})]}),jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:gt.close,onPress:o,hitSlop:12,style:n.closeButton,testID:"fact-edit-close",children:jsx(p,{style:n.closeGlyph,children:"\xD7"})})]}),jsx(p,{style:l.fieldLabel,children:e.label}),jsx(Qe,{accessibilityLabel:e.label,style:l.field,value:c,onChangeText:b=>{s(b),u(null);},editable:!R,maxLength:512,placeholderTextColor:a.color.text.placeholder,testID:"fact-edit-field"}),m?jsxs(View,{style:n.confirmBlock,testID:"fact-edit-confirm-remove",children:[jsx(p,{style:n.confirmText,children:gt.confirmRemove}),jsxs(View,{style:n.confirmRow,children:[jsx(X,{label:R?gt.removing:gt.removeConfirm,kind:"danger",busy:R,onPress:f,style:n.confirmButton,testID:"fact-edit-remove-confirm"}),jsx(X,{label:gt.keep,kind:"outline",disabled:R,onPress:()=>y(false),style:n.confirmButton,testID:"fact-edit-remove-cancel"})]})]}):jsxs(View,{style:n.actions,children:[jsx(X,{label:R?gt.saving:gt.save,busy:R,disabled:!g,onPress:v,testID:"fact-edit-save"}),jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:gt.removeA11y(t),disabled:R,onPress:()=>{u(null),y(true);},style:[n.removeButton,R?n.removeDisabled:null],testID:"fact-edit-remove",children:jsx(p,{style:n.removeText,children:gt.remove})})]})]})]})})}i(Ug,"FactEditSheet");function Gd(){let e=V();return useMemo(()=>jg(e),[e])}i(Gd,"useStyles");function jg(e){let{color:t,space:r,radius:o,type:n}=e,l=r.xxl+r.md,a=e.brightness==="dark"?t.errorRed:t.danger,c=i((s,d,u,m="regular")=>({...S(e,m),fontSize:s,lineHeight:Math.round(s*d),color:u}),"text");return StyleSheet.create({row:{flexDirection:"row",alignItems:"center",gap:r.sm},main:{flex:1},editButton:{width:l,height:l,alignItems:"center",justifyContent:"center"},pencil:{width:r.md+r.xs/2,height:r.xs/2,backgroundColor:t.brandInk,borderRadius:o.pill,transform:[{rotate:"-45deg"}]},backdrop:{flex:1,justifyContent:"flex-end",backgroundColor:Ro},sheet:{backgroundColor:t.surface,borderTopLeftRadius:o.xl-1,borderTopRightRadius:o.xl-1,paddingHorizontal:r.lg+r.xs+r.xs/2,paddingTop:r.md,paddingBottom:o.xl,maxHeight:"88%",gap:r.md},handle:{alignSelf:"center",width:r.xxl+r.xs,height:r.xs,borderRadius:o.pill,backgroundColor:t.borderRingCream},header:{flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between",gap:r.sm},headerText:{flex:1,gap:r.xs},title:{...c(n.size.heading,n.lineHeight.snug,t.text.primary,"bold")},helper:c(n.size.bodyTight,n.lineHeight.normal,t.text.muted),helperError:{color:a},closeButton:{width:l,height:l,alignItems:"center",justifyContent:"center"},closeGlyph:c(n.size.verdict,n.lineHeight.tight,t.text.primary),actions:{gap:r.sm},removeButton:{minHeight:l,alignItems:"center",justifyContent:"center"},removeDisabled:{opacity:.5},removeText:{...c(n.size.bodyTight,n.lineHeight.snug,t.danger,"bold")},confirmBlock:{gap:r.sm,padding:r.md,borderRadius:o.md,backgroundColor:t.badgeBgCritical},confirmText:c(n.size.bodyTight,n.lineHeight.normal,t.text.primary),confirmRow:{flexDirection:"row",gap:r.sm},confirmButton:{flex:1}})}i(jg,"makeStyles");function ti({record:e,depth:t,petName:r,showLabs:o=true,onNavigate:n,onAsk:l,factEdit:a,nowMs:c}){let s=Re(),d=$g(),u=c??Date.now(),m=useMemo(()=>a?Ws(e.entities,a.overlay):e.entities,[e.entities,a]),y=useMemo(()=>{let f=[],b=new Map;for(let C of m){let h=C.category.trim();if(h.length===0||Ys.includes(h))continue;let I=b.get(h);I===void 0?(f.push(h),b.set(h,[C])):I.push(C);}return {order:vo(f),groups:b}},[m]),g=useMemo(()=>Wd(m),[m]),w=Object.values(e.documents),R=i((f,b,C)=>l?jsx(Pressable,{onPress:()=>{let h=f();l(h.prompt,h.entityRef);},accessibilityRole:"button",accessibilityLabel:b,style:[s.pill,s.pillAsk,d.ask],testID:C,children:jsx(p,{style:s.pillAskLabel,children:b})}):null,"ask"),v=a!==void 0&&a.available;return jsxs(Fragment,{children:[jsxs(View,{style:d.sections,children:[t&&t.conflicts.length>0?jsxs(View,{style:s.section,testID:"record-section-conflicts",children:[jsx(Bt,{title:ne.needsAttention,count:t.conflicts.length}),[...t.conflicts].sort((f,b)=>wo(f.severity).rank-wo(b.severity).rank).map(f=>{let b=wo(f.severity),C=Rr(f.field??f.entityType);return jsxs(View,{style:[d.conflictCard,{borderColor:s.chipTones[b.tone].fg.color}],accessibilityRole:"summary",children:[jsxs(View,{style:d.conflictHead,children:[jsx(p,{style:d.conflictTitle,children:b.label}),jsx(Lt,{label:C,tone:b.tone})]}),jsx(p,{style:s.rowDetail,children:ne.conflictSub}),f.candidates.map((h,I)=>jsxs(View,{style:d.candidate,children:[jsx(p,{style:s.rowTitle,children:h.value}),jsx(p,{style:s.rowMuted,children:[h.docId?e.documents[h.docId]?.title??ne.uploadedDocument:ne.uploadedDocument,h.collectedAt?re(h.collectedAt):null].filter(Boolean).join(" \xB7 ")})]},I)),R(()=>kd(r,{scopeLabel:C,severity:f.severity,candidates:f.candidates.map(h=>({value:h.value,clinicName:h.docId?e.documents[h.docId]?.title??null:null}))},f.conflictId),ne.askConflict,`records-ask-conflict-${f.conflictId}`)]},f.conflictId)})]}):null,t?.completeness?jsxs(View,{style:s.section,testID:"record-section-completeness",children:[jsx(Bt,{title:ne.whatsOnFile}),jsxs(View,{style:s.card,children:[jsx(View,{style:d.coverageRow,children:[[ne.coverage.labs,t.completeness.hasLabHistory],[ne.coverage.vaccines,t.completeness.hasVaccinationHistory],[ne.coverage.weight,t.completeness.hasWeightHistory],[ne.coverage.vitals,t.completeness.hasVitalsHistory],[ne.coverage.exams,t.completeness.hasPhysicalExamHistory],[ne.coverage.procedures,t.completeness.hasProcedureHistory],[ne.coverage.genetics,t.completeness.hasGeneticHistory],[ne.coverage.parasite,t.completeness.hasParasitePreventionHistory],[ne.coverage.reproductive,t.completeness.hasReproductiveHistory]].map(([f,b])=>jsx(View,{style:[d.coveragePill,b?s.chipTones.positive.bg:s.chipTones.neutral.bg],accessible:true,accessibilityRole:"text",accessibilityLabel:`${f}: ${b?ne.onFile:ne.noneOnFile}`,children:jsx(p,{style:[d.coverageText,b?s.chipTones.positive.fg:{color:s.rowMuted.color}],children:f})},f))}),jsxs(View,{style:d.metaRow,children:[jsx(p,{style:d.metaText,children:ne.documentsOnFile(t.completeness.documentsIngested)}),t.completeness.documentsInReview>0?jsx(Lt,{label:ne.inReviewChip(t.completeness.documentsInReview),tone:"warning"}):null,Qs(t.completeness.heldTotal,t.completeness.entitiesPendingReview)>0?jsx(View,{accessible:true,accessibilityRole:"text",accessibilityLabel:ne.beingVerifiedA11y(Qs(t.completeness.heldTotal,t.completeness.entitiesPendingReview)),children:jsx(Lt,{label:ne.beingVerified(Qs(t.completeness.heldTotal,t.completeness.entitiesPendingReview)),tone:"warning"})}):null]}),t.completeness.earliestRecordAt||t.completeness.latestRecordAt?jsx(View,{style:d.metaRow,children:jsx(p,{style:d.metaText,children:ne.dateRange(t.completeness.earliestRecordAt,t.completeness.latestRecordAt)})}):null,Object.entries(t.completeness.entitiesPendingReview).filter(([,f])=>f>0).length>0?jsxs(p,{style:d.pendingText,children:[ne.pendingReview,Object.entries(t.completeness.entitiesPendingReview).filter(([,f])=>f>0).map(([f,b])=>`${vr(f)} (${b})`).join(", ")]}):null]})]}):null,w.length>0?jsxs(View,{style:s.section,testID:"record-section-documents",children:[jsx(Bt,{title:ne.documents,count:w.length}),jsx(View,{style:s.card,children:w.map((f,b)=>{let C=f.title?.trim()||ne.uploadedDocument,h=ne.documentMeta(f.pageCount,f.receivedAt),I=jsxs(Fragment,{children:[jsxs(View,{style:s.rowMain,children:[jsx(p,{style:s.rowTitle,children:C}),h?jsx(p,{style:s.rowDetail,children:h}):null]}),n?jsx(er,{}):null]});return n?jsx(Pressable,{onPress:()=>n({name:"contributions",docId:f.docId}),accessibilityRole:"button",accessibilityLabel:ne.documentRowA11y(C),style:[s.row,b>0?s.rowDivider:null],testID:`records-document-row-${f.docId}`,children:I},f.docId):jsx(View,{style:[s.row,b>0?s.rowDivider:null],children:I},f.docId)})})]}):null,e.identity.length>0?jsxs(View,{style:s.section,testID:"record-section-identity",children:[jsx(Bt,{title:ne.identity}),jsx(View,{style:s.card,children:e.identity.map((f,b)=>jsxs(View,{style:[s.row,b>0?s.rowDivider:null],children:[jsx(p,{style:d.identityLabel,children:f.label}),jsx(p,{style:d.identityValue,children:Rc(f.value)})]},`${b}:${f.label}`))})]}):null,e.forwardLooking.length>0?jsxs(View,{style:s.section,testID:"record-section-upcoming",children:[jsx(Bt,{title:ne.upcomingCare,count:e.forwardLooking.length}),jsx(View,{style:s.card,children:e.forwardLooking.map((f,b)=>{let C=Dn(f.dueAt,u);return jsxs(View,{style:[s.row,b>0?s.rowDivider:null],children:[jsxs(View,{style:s.rowMain,children:[jsx(p,{style:s.rowTitle,children:f.title}),f.detail?jsx(p,{style:s.rowDetail,children:f.detail}):null]}),C?jsx(Lt,{label:C.label,tone:C.overdue?"critical":"info"}):null]},`${f.title}-${b}`)})}),R(()=>Ed(r,e.forwardLooking.map(f=>{let b=Dn(f.dueAt,u);return {label:f.title,relativeText:b?.label??"",tone:b?.overdue?"overdue":"upcoming"}}),e.petRef),ne.askUpcomingCare,"records-ask-upcoming-care")]}):null,g.length>0?jsxs(View,{style:s.section,testID:"record-section-vaccination",children:[jsx(Bt,{title:vr("vaccination"),count:g.reduce((f,b)=>f+b.items.length,0)}),g.map(f=>jsxs(View,{style:d.vaccineGroup,testID:`records-vaccine-group-${f.year}`,children:[jsx(p,{style:d.vaccineYear,accessibilityRole:"header",children:f.year.toUpperCase()}),jsx(View,{style:s.card,children:f.items.map((b,C)=>{let h=jsxs(View,{style:[s.row,C>0?s.rowDivider:null],children:[jsxs(View,{style:s.rowMain,children:[jsx(p,{style:s.rowTitle,children:b.name}),b.detail?jsx(p,{style:s.rowDetail,children:b.detail}):null,R(()=>Ms(r,{entityTypeLabel:vr(b.entity.category),title:b.name,detail:b.detail},b.entity.category,b.key),ne.askEverfur,`records-ask-entity-${b.key}`)]}),jsx(Lt,{label:b.statusLabel,tone:$d[b.tone]})]});return v&&Yo(b.entity)&&a?jsx(Ks,{entity:b.entity,factEdit:a,children:h},b.key):jsx(View,{children:h},b.key)})})]},f.year))]}):null,y.order.map(f=>{let b=y.groups.get(f)??[];if(b.length===0)return null;let C=vr(f);return jsxs(View,{style:s.section,testID:`record-section-${f}`,children:[jsx(Bt,{title:C,count:b.length}),jsx(View,{style:s.card,children:b.map((h,I)=>{let k=[rn(h.value,h.unit),h.observedAt?re(h.observedAt):null].filter(E=>E&&E.length>0).join(" \xB7 "),_=jsxs(View,{style:[s.row,I>0?s.rowDivider:null],children:[jsxs(View,{style:s.rowMain,children:[jsx(p,{style:s.rowTitle,children:h.label}),k?jsx(p,{style:s.rowDetail,children:k}):null,R(()=>Ms(r,{entityTypeLabel:C,title:h.label,detail:k||null},f,h.key),ne.askEverfur,`records-ask-entity-${h.key}`)]}),h.status?jsx(Lt,{label:Rr(h.status)}):null]});return v&&Yo(h)&&a?jsx(Ks,{entity:h,factEdit:a,children:_},h.key):jsx(View,{children:_},h.key)})})]},f)}),t&&t.physicalExams.length>0?jsxs(View,{style:s.section,testID:"record-section-exams",children:[jsx(Bt,{title:ne.physicalExams,count:t.physicalExams.length}),t.physicalExams.map(f=>jsxs(View,{style:s.card,children:[jsx(p,{style:[s.rowTitle,d.cardTitle],accessibilityRole:"header",children:f.observedOn?re(f.observedOn):be.exam}),f.systems.map((b,C)=>{let h=b.findingStatus==="abnormal",I=h?be.abnormal:b.findingStatus==="not_examined"?be.notExamined:be.normal;return jsxs(View,{style:[s.row,C>0?s.rowDivider:null],accessible:true,accessibilityRole:"text",accessibilityLabel:[Hr(b.system),I,h?b.finding:null].filter(Boolean).join(", "),children:[jsxs(View,{style:s.rowMain,children:[jsx(p,{style:s.rowTitle,children:Hr(b.system)}),h&&b.finding?jsx(p,{style:s.rowDetail,children:b.finding}):null]}),jsx(Lt,{label:I,tone:h?"warning":b.findingStatus==="not_examined"?"neutral":"positive"})]},b.system)}),R(()=>Sd(r,{observedOn:f.observedOn?re(f.observedOn):null,abnormal:f.systems.filter(b=>b.findingStatus==="abnormal").map(b=>({system:Hr(b.system),finding:b.finding??""}))},f.examId),ne.askExam,`records-ask-exam-${f.examId}`)]},f.examId))]}):null,t&&t.clinicianNotes.length>0?jsxs(View,{style:s.section,testID:"record-section-notes",children:[jsx(Bt,{title:ne.visitNotes,count:t.clinicianNotes.length}),t.clinicianNotes.map(f=>jsxs(View,{style:s.card,children:[jsx(p,{style:[s.rowTitle,d.cardTitle],accessibilityRole:"header",children:f.observedOn?re(f.observedOn):be.visitNote}),f.sections.map((b,C)=>jsxs(View,{style:[d.noteSection,C>0?s.rowDivider:null],children:[jsx(p,{style:d.noteLabel,children:on(b.section)}),jsx(p,{style:b.text?d.noteBody:d.noteBodyMuted,children:b.text||be.notRecorded})]},`${b.section}:${C}`)),R(()=>Td(r,{observedOn:f.observedOn?re(f.observedOn):null,sections:f.sections.map(b=>({label:on(b.section),text:b.text}))},f.noteId),ne.askVisit,`records-ask-note-${f.noteId}`)]},f.noteId))]}):null,o&&t&&t.labResults.length>0?jsxs(View,{style:s.section,testID:"record-section-labs",children:[jsx(Bt,{title:ne.labResults,count:t.labResults.length}),jsx(View,{style:s.card,children:t.labResults.map((f,b)=>{let C=pr(f.latest.status),h=ds(f.latest.at,f.trajectory,f.points.length);return jsxs(View,{style:[s.row,b>0?s.rowDivider:null],children:[jsxs(View,{style:s.rowMain,children:[jsx(p,{style:s.rowTitle,children:f.name}),jsx(p,{style:s.rowValue,children:Vt(f.latest.value,f.latest.unit,f.latest.qualitativeResult)}),h?jsx(p,{style:s.rowDetail,children:h}):null]}),jsx(Lt,{label:C.label,tone:No(f.latest.status)})]},f.markerId)})})]}):null,t&&t.encounters.length>0?jsxs(View,{style:s.section,testID:"record-section-visits",children:[jsx(Bt,{title:ne.visits,count:t.encounters.length}),jsx(View,{style:s.card,children:t.encounters.map((f,b)=>{let C=[f.date?re(f.date):null,f.clinicName,f.veterinarian].filter(h=>h&&h!=="-").join(" \xB7 ");return jsx(View,{style:[s.row,b>0?s.rowDivider:null],children:jsxs(View,{style:s.rowMain,children:[jsx(p,{style:s.rowTitle,children:f.type?Rr(f.type):be.visit}),C?jsx(p,{style:s.rowDetail,children:C}):null]})},f.encounterId)})})]}):null]}),jsx(Fr,{disclaimer:e.disclaimer})]})}i(ti,"RecordSections");function Qs(e,t){return e>0?e:Object.values(t).reduce((r,o)=>r+o,0)}i(Qs,"heldCount");function $g(){let e=V();return useMemo(()=>Wg(e),[e])}i($g,"useLocalStyles");function Wg(e){let{color:t,space:r,radius:o,type:n}=e,l=StyleSheet.hairlineWidth;return StyleSheet.create({sections:{gap:r.lg+r.xs},vaccineGroup:{gap:r.xs+1,marginBottom:r.sm},vaccineYear:{...S(e,"monoMedium"),fontSize:n.size.micro,lineHeight:n.size.micro+r.xs,color:t.text.muted,letterSpacing:n.letterSpacing.eyebrow,textTransform:"uppercase",paddingTop:r.xs+2},ask:{marginTop:r.lg},conflictCard:{borderRadius:o.md,borderWidth:1,backgroundColor:t.surface,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md,gap:r.sm},conflictHead:{flexDirection:"row",alignItems:"center",gap:r.sm},conflictTitle:{flex:1,...S(e,"bold"),fontSize:n.size.body,lineHeight:Math.round(n.size.body*n.lineHeight.snug),color:t.text.primary},candidate:{borderTopWidth:l,borderTopColor:t.borderHairlineGreen,paddingTop:r.sm},coverageRow:{flexDirection:"row",flexWrap:"wrap",gap:r.sm,paddingVertical:r.md},coveragePill:{borderRadius:o.pill,paddingHorizontal:r.sm+r.xs/2,paddingVertical:r.xs+1},coverageText:{...S(e,"medium"),fontSize:n.size.caption,lineHeight:n.size.caption+r.xs-1},metaRow:{flexDirection:"row",alignItems:"center",gap:r.sm,paddingBottom:r.md},metaText:{flex:1,...S(e,"regular"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*n.lineHeight.snug),color:t.text.secondary},pendingText:{...S(e,"regular"),fontSize:n.size.caption,lineHeight:Math.round(n.size.caption*n.lineHeight.normal),color:t.text.muted,paddingBottom:r.md},identityLabel:{...S(e,"medium"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*n.lineHeight.snug),color:t.text.secondary},identityValue:{flexShrink:1,textAlign:"right",...S(e,"medium"),fontSize:n.size.body,lineHeight:Math.round(n.size.body*n.lineHeight.snug),color:t.text.primary},cardTitle:{paddingTop:r.sm},noteSection:{paddingVertical:r.md,gap:r.xs},noteLabel:{...S(e,"bold"),fontSize:n.size.bodyTight,color:t.text.secondary,textTransform:"uppercase",letterSpacing:n.letterSpacing.eyebrow/2},noteBody:{...S(e,"regular"),fontSize:n.size.body+1,lineHeight:Math.round((n.size.body+1)*n.lineHeight.relaxed),color:t.text.primary},noteBodyMuted:{...S(e,"regular"),fontSize:n.size.body+1,lineHeight:Math.round((n.size.body+1)*n.lineHeight.relaxed),color:t.text.muted,fontStyle:"italic"}})}i(Wg,"makeLocalStyles");var Un=Object.freeze({heading:"A quick call can help",fallbackPrompt:"Reaching out to the clinic directly often speeds up a slow records request.",call:"Call the clinic",callAt:i(e=>`Call the clinic at ${e}`,"callAt")});var Gg=Math.round(Pr/(1024*1024)),Me=Object.freeze({title:i(e=>`Upload ${ke(e)}\u2019s records`,"title"),screenTitle:"Upload a document",subtitle:i(e=>`Already have lab results, a vet summary, or test reports? Add them here and we\u2019ll read them and pull out ${ke(e)}\u2019s health markers.`,"subtitle"),noPet:"Select a pet first, then upload their records.",cardTitle:"Add records",cardSubtitle:`Upload PDF records you already have, up to ${Gg} MB each. You can pick several at once. We\u2019ll read them and add the results to your records.`,chooseFiles:"Choose a file",chooseFilesA11y:"Choose records to upload",uploading:i((e,t)=>`Uploading ${Math.min(e+1,t)} of ${t}\u2026`,"uploading"),cancel:"Cancel",cancelA11y:"Cancel these uploads",received:i(e=>`${e===1?"Record received.":`${e} records received.`} We\u2019ll read and review ${e===1?"it":"them"}, then add the results to your records, usually within 1-2 business days.`,"received"),retryFailed:i(e=>`Retry ${e} that didn\u2019t upload`,"retryFailed"),retryFailedA11y:i(e=>`Retry ${e} failed upload${e>1?"s":""}`,"retryFailedA11y"),haveMore:"Have more?",addMore:"Upload another document",addMoreA11y:"Upload another document",done:"Done",doneA11y:"Done, view records",errors:Object.freeze({start:"We couldn\u2019t start that upload. Check your connection and try again.",startPlain:"We couldn\u2019t start that upload. Please try again.",upload:"We couldn\u2019t upload that record. Check your connection and try again."})}),or=Object.freeze({note:"A PDF, or a photo of a paper record. Add them all; we sort them by date.",takePhoto:"Take a photo",takePhotoMeta:"of a paper record",choosePhotos:"Choose from photos",chooseFileMeta:"PDF",haveMoreLead:"PDFs and photos of paper records both work. Add them all; we sort them by date.",unreadable:"We can\u2019t read this kind of file. Upload a PDF or a photo of the record."});function Xd(e,t){return `${e} ${t}`}i(Xd,"uploadActionA11y");var Xs=Math.round(Pr/(1024*1024)),Kr=Object.freeze({queued:"Queued",verifying:"Verifying\u2026",done:"Done",failed:"Failed",uploading:i((e,t)=>`Uploading ${Math.min(e+1,t)} of ${t} records`,"uploading"),uploaded:i((e,t)=>`${e} of ${t} records uploaded`,"uploaded")});function Jd(e){let t=Math.round(e.progress*100);switch(e.status){case "done":return Kr.done;case "failed":return Kr.failed;case "uploading":return e.progress>=1?Kr.verifying:`${t}%`;case "queued":return Kr.queued;default:return null}}i(Jd,"uploadItemStatusLabel");function ri(e,t=false){if(e.length===0)return null;let r=i(a=>{let c=a.map(s=>s.name??"");return c.length<=3?c.join(", "):`${c.slice(0,3).join(", ")} and ${c.length-3} more`},"nameList"),o=e.filter(a=>a.reason==="too_large"),n=e.filter(a=>a.reason==="unsupported");if(t){let a=[];return n.length>0&&a.push(or.unreadable),o.length>0&&a.push(`Didn\u2019t upload: ${r(o)} ${o.length>1?"are":"is"} over ${Xs} MB.`),a.join(" ")}let l=[];return n.length>0&&l.push(`${r(n)} ${n.length>1?"are not PDFs":"is not a PDF"}`),o.length>0&&l.push(`${r(o)} ${o.length>1?"are":"is"} over ${Xs} MB`),`Didn\u2019t upload: ${l.join("; ")}. We can only read PDFs up to ${Xs} MB right now.`}i(ri,"skippedFilesMessage");function Zd(e){let t=[];for(let r of e)r.status==="skipped"&&r.skipReason!==null&&t.push({name:r.name,reason:r.skipReason});return t}i(Zd,"skippedOf");var Wt=Object.freeze({email:"Clinic email",emailPlaceholder:"records@clinic.com",emailError:"Enter a valid clinic email.",updateEmail:"Update email & resend",updateEmailA11y:"Update clinic email and resend request",retry:"Retry sending",retryA11y:"Retry sending records request",retryHint:"Save the updated email first, then retry.",cancelRequest:"Cancel request",keepRequest:"Keep it",uploadInstead:"Upload instead",cancelQuestion:"Cancel this request?",cancelConsequence:"We\u2019ll stop sending reminders to the clinic. If the clinic has already sent records, they may still arrive. You can start a new request or upload your own records anytime."});function eu({request:e,onRecovered:t,canUpload:r=false},o){let[n,l]=useState(""),[a,c]=useState(false),[s,d]=useState(null),[u,m]=useState(false),[y,g]=useState(null),w=useRef(false),R=useRef(false),v=useRef(0);useEffect(()=>(R.current=true,()=>{R.current=false,v.current+=1;}),[o]);let f=y!==null&&y.before===e.updatedAt?{...y.value,canRetrySend:e.canRetrySend===true&&y.value.canRetrySend===true,canUpdateClinicEmail:e.canUpdateClinicEmail===true&&y.value.canUpdateClinicEmail===true,canRevoke:e.canRevoke===true&&y.value.canRevoke===true,canConvertToUpload:e.canConvertToUpload===true&&y.value.canConvertToUpload===true}:e,b=n.trim(),C=b.length<=320&&!Array.from(b).some(E=>E.charCodeAt(0)<=32||E.charCodeAt(0)===127)&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(b),h=f.canUpdateClinicEmail===true&&b.length>0,I=f.canRetrySend===true&&!a&&!h,T=f.canUpdateClinicEmail===true&&!a&&C,k=f.canConvertToUpload===true&&r,_=i(async E=>{let B={retry:I,email:T,revoke:f.canRevoke===true&&u,convert:k};if(w.current||!R.current||!B[E])return;w.current=true,c(true),d(null);let x=v.current,A=i(()=>R.current&&x===v.current,"live");try{let z=E==="retry"?await o.retryRequest(e.id):E==="email"?await o.updateClinicEmail(e.id,b):E==="revoke"?await o.revokeRequest(e.id):await o.convertToUpload(e.id);if(!A())return;if(!z.ok){d(z.error);return}if(z.value.id!==e.id||z.value.petRef!==e.petRef){d(W("internalError"));return}g({before:e.updatedAt,value:z.value}),l(""),m(!1),t();}catch{A()&&d(W("internalError"));}finally{w.current=false,A()&&c(false);}},"run");return {request:f,email:n,busy:a,error:s,canRetry:I,canUpdateEmail:T,canConvert:k,hasEmailEdit:h,confirmingRevoke:u&&f.canRevoke===true,emailInvalid:b.length>0&&!C,setEmail(E){w.current||(l(E),d(null));},retry:i(()=>_("retry"),"retry"),updateEmail:i(()=>_("email"),"updateEmail"),revoke:i(()=>_("revoke"),"revoke"),convert:i(()=>_("convert"),"convert"),askRevoke(){!w.current&&f.canRevoke===true&&m(true);},keepRequest(){w.current||m(false);}}}i(eu,"useRecordsRecovery");var Kg=["requested","sent_to_clinic","awaiting_clinic","records_received","processing","ready"],Qg=["requested","awaiting_upload","records_received","processing","ready"],Xg=["requested","sent_to_clinic","awaiting_clinic","awaiting_upload","records_received","processing","ready"],dn=Object.freeze({requested:"Request created",sent_to_clinic:"Sent to the clinic",awaiting_clinic:"Waiting on the clinic",awaiting_upload:"Add your records",records_received:"Records received",processing:"Preparing your records",parsing_failed:"Needs a closer look",manual_review:"Our team is reviewing it",ready:"Ready to view",delivery_failed:"Email could not be delivered",processing_failed:"Could not process the records",clinic_declined:"Clinic declined the request",clinic_no_records:"Clinic replied without your records",no_response:"No response from the clinic",revoked:"You cancelled this request"}),Jg=Object.freeze({requested:"Request sent",sent_to_clinic:"Clinic notified",awaiting_clinic:"Waiting for records\u2026"}),Zs=Object.freeze({notified:i(e=>`A secure request went to ${e}.`,"notified"),received:"Everfur reads every page: dates, vaccines, labs and prescriptions.",added:i(e=>`Added to ${e}\u2019s records`,"added")}),qt=Object.freeze({delivered:"Email delivered to the clinic",emailing:"Emailing the clinic",bounced:"The clinic email did not go through",waiting:"Waiting for the clinic to send the records",upload:"Upload the records you already have",ownerAdded:"You added these records",clinicSent:"The clinic sent the records",preparing:"Getting your records ready to view",ready:"Your records are ready to view",parsingFailed:"We couldn\u2019t read this one automatically",manualReview:"Checking these by hand so nothing\u2019s missed",switchedTitle:"Stopped waiting on the clinic",switched:"You switched to uploading your own records"}),Zg=Object.freeze({delivery_failed:"The clinic email could not be delivered",processing_failed:"We could not read these records",clinic_declined:"The clinic declined to release records",clinic_no_records:"The clinic replied without records",no_response:"No reply after repeated reminders",revoked:"You cancelled this request"}),eb=Object.freeze({requested:"sent",awaiting_clinic:"awaiting_response",awaiting_upload:"awaiting_upload",received:"records_received",parsing:"parsing",in_review:"in_review",published:"published",failed:"failed",revoked:"revoked"});function tb(e){return e.wireStatus??eb[e.status]??"sent"}i(tb,"wireStatusOf");function rb(e,t){return e!=="awaiting_response"||t<=0?null:`${t} ${t===1?"reminder":"reminders"} sent`}i(rb,"reminderProgressLabel");function nb(e){switch(e){case "submitted":case "sent":return 1;case "awaiting_response":return 2;case "records_received":return 3;case "parsing":case "parsing_failed":case "in_review":case "review_email_failed":return 4;case "published":return 5;default:return -1}}i(nb,"reachedRailIndex");function ob(e){switch(e.dispatchStatus){case "sent":return qt.delivered;case "preparing":case "queued":case "sending":return qt.emailing;case "failed":return qt.bounced;default:return null}}i(ob,"deliveryDetail");function ib(e,t){return rb(t,e.reminderCount??0)??qt.waiting}i(ib,"awaitingDetail");function ni(e){return e.source==="owner_provided"||!!e.convertedToUploadAt}i(ni,"isOwnerSourcedRequest");function sb(e,t,r){let o=ni(t);switch(e){case "sent_to_clinic":return ob(t);case "awaiting_clinic":return ib(t,r);case "awaiting_upload":return qt.upload;case "records_received":return o?qt.ownerAdded:qt.clinicSent;case "processing":return qt.preparing;case "ready":return qt.ready;default:return null}}i(sb,"railDetail");function ab(e,t){return !!e.reviewStartedAt||t==="parsing_failed"||t==="review_email_failed"}i(ab,"tookReviewBranch");function lb(e,t,r){if(e.key!=="processing"||!ab(t,r))return [e];let o=r==="parsing_failed",n=r==="published",l=n?"done":o?"current":"done",a=n?"done":o?"upcoming":"current";return [{key:"parsing_failed",title:dn.parsing_failed,detail:qt.parsingFailed,at:null,state:l},{key:"manual_review",title:dn.manual_review,detail:qt.manualReview,at:t.reviewStartedAt??null,state:a}]}i(lb,"expandProcessingPhase");function cb(e){switch(e){case "awaiting_upload":return 3;case "records_received":return 4;case "parsing":case "parsing_failed":case "in_review":case "review_email_failed":return 5;case "published":return 6;default:return 3}}i(cb,"convertedReachedIndex");function tu(e){return {key:"awaiting_clinic",title:qt.switchedTitle,detail:qt.switched,at:e.convertedToUploadAt??null,state:"done"}}i(tu,"convertedClinicSwitchEvent");function db(e){switch(e){case "submitted":case "sent":return 0;case "awaiting_upload":return 1;case "records_received":return 2;case "parsing":case "parsing_failed":case "in_review":case "review_email_failed":return 3;case "published":return 4;default:return -1}}i(db,"ownerReachedIndex");function ub(e,t,r){switch(e){case "requested":return t.createdAt||null;case "awaiting_clinic":return t.lastReminderAt??null;case "processing":return t.parsingStartedAt??t.reviewStartedAt??null;case "ready":return r==="published"&&t.updatedAt||null;default:return null}}i(ub,"railTimestamp");function ru(e,t,r,o){return {key:e,title:dn[e],detail:sb(e,t,r),at:ub(e,t,r),state:o}}i(ru,"railEvent");function Er(e,t){return {key:e,title:dn[e],detail:Zg[e]??null,at:t.updatedAt||null,state:"failed"}}i(Er,"terminalEvent");function ea(e,t,r,o,n){return e.map((l,a)=>{let c=n?.(l)??null;if(c!==null)return c;let s=o==="published"||a<t?"done":a===t?"current":"upcoming";return ru(l,r,o,s)}).flatMap(l=>lb(l,r,o))}i(ea,"walkRail");function ta(e,t={}){return pb(mb(e),e,t.petName??null)}i(ta,"buildRequestTimeline");function pb(e,t,r){let o=t.source!=="owner_provided"&&!e.some(l=>l.key==="delivery_failed"),n=t.clinicEmail?.trim()??"";return e.map(l=>{if(l.title!==dn[l.key])return l;if(l.key==="ready")return {...l,title:Zs.added(ke(r))};if(!o)return l;let a=Jg[l.key]??l.title;return l.key==="sent_to_clinic"&&t.dispatchStatus==="sent"&&n.length>0?{...l,title:a,detail:Zs.notified(n)}:l.key==="records_received"&&!ni(t)?{...l,title:a,detail:Zs.received}:{...l,title:a}})}i(pb,"inArtifactWords");function mb(e){let t=tb(e),r=i(n=>ru(n,e,t,"done"),"done");if(t==="revoked")return [r("requested"),Er("revoked",e)];if(e.convertedToUploadAt)return t==="failed"?[r("requested"),r("sent_to_clinic"),tu(e),r("awaiting_upload"),r("records_received"),Er("processing_failed",e)]:ea(Xg,cb(t),e,t,n=>n==="awaiting_clinic"?tu(e):null);if(e.source==="owner_provided"){if(t==="failed"||t==="clinic_declined")return [r("requested"),r("awaiting_upload"),r("records_received"),Er("processing_failed",e)];let n=db(t);return ea(Qg,n<0?1:n,e,t)}if(t==="clinic_declined")return [r("requested"),r("sent_to_clinic"),r("awaiting_clinic"),Er("clinic_declined",e)];if(t==="clinic_responded_no_records")return [r("requested"),r("sent_to_clinic"),r("awaiting_clinic"),Er("clinic_no_records",e)];if(t==="failed"){let n=e.failureCode??null;return n==="no_response"?[r("requested"),r("sent_to_clinic"),r("awaiting_clinic"),Er("no_response",e)]:n==="hard_bounce"||n==="dispatch_failed"?[r("requested"),Er("delivery_failed",e)]:n==="parse_timeout"||n==="parse_error"||e.dispatchStatus==="sent"?[r("requested"),r("sent_to_clinic"),r("awaiting_clinic"),r("records_received"),Er("processing_failed",e)]:[r("requested"),Er("delivery_failed",e)]}let o=nb(t);return ea(Kg,o<0?1:o,e,t)}i(mb,"buildRailEvents");var gb=Object.freeze({done:"completed",current:"in progress",failed:"needs attention",upcoming:"not started"}),oi=28,bb="Now",ra=10;function si({request:e,petName:t}){let r=vb(),o=ta(e,{petName:t??null});return jsx(View,{style:r.container,accessibilityRole:"summary",children:o.map((n,l)=>jsx(hb,{event:n,isLast:l===o.length-1,styles:r},n.key))})}i(si,"RequestTimeline");function hb({event:e,isLast:t,styles:r}){let o=e.at?re(e.at):null,n=[e.title,e.detail,o,gb[e.state]].filter(Boolean);return jsxs(View,{style:r.row,accessible:true,accessibilityRole:"text",accessibilityLabel:n.join(", "),testID:`records-timeline-${e.key}`,children:[jsxs(View,{style:r.railColumn,children:[jsx(Rb,{state:e.state,styles:r}),t?null:jsx(View,{style:[r.connector,e.state==="done"&&r.connectorDone],accessibilityElementsHidden:true,importantForAccessibility:"no"})]}),jsxs(View,{style:r.body,children:[jsxs(View,{style:r.titleRow,children:[jsx(p,{style:[r.title,e.state==="current"&&r.titleCurrent,e.state==="failed"&&r.titleFailed,e.state==="upcoming"&&r.titleUpcoming],children:e.title}),e.state==="current"?jsx(View,{style:r.now,children:jsx(p,{tier:"badge",style:r.nowText,children:bb})}):null,o?jsx(p,{style:r.date,children:o}):null]}),e.detail?jsx(p,{style:[r.detail,e.state==="upcoming"&&r.detailUpcoming],children:e.detail}):null]})]})}i(hb,"TimelineRow");function Rb({state:e,styles:t}){return e==="done"?jsx(View,{style:[t.dot,t.dotDone],accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsx(p,{tier:"badge",style:[t.glyph,t.glyphOnBrand],children:"\u2713"})}):e==="failed"?jsx(View,{style:[t.dot,t.dotFailed],accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsx(p,{tier:"badge",style:t.glyph,children:"!"})}):e==="current"?jsx(View,{style:[t.dot,t.dotCurrent],accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsx(View,{style:t.dotCurrentCore})}):jsx(View,{style:[t.dot,t.dotUpcoming],accessibilityElementsHidden:true,importantForAccessibility:"no"})}i(Rb,"TimelineDot");function vb(){let e=V();return useMemo(()=>wb(e),[e])}i(vb,"useStyles");function wb(e){let{color:t,type:r}=e,{size:o}=r;return StyleSheet.create({container:{gap:0},row:{flexDirection:"row",alignItems:"flex-start",gap:12},railColumn:{alignItems:"center",width:oi},body:{flex:1,paddingBottom:18,gap:2},titleRow:{flexDirection:"row",alignItems:"center",gap:8},dot:{width:oi,height:oi,borderRadius:oi/2,alignItems:"center",justifyContent:"center"},dotDone:{backgroundColor:t.brand},dotFailed:{backgroundColor:t.danger},dotCurrent:{borderWidth:2,borderColor:t.brandInk,backgroundColor:t.surface},dotCurrentCore:{width:ra,height:ra,borderRadius:ra/2,backgroundColor:t.success},now:{borderRadius:e.radius.pill,backgroundColor:t.scanButtonPink,paddingHorizontal:e.space.sm,paddingVertical:e.space.xs/2},nowText:{...S(e,"monoBold"),fontSize:o.tiny,lineHeight:o.tiny+4,letterSpacing:.6,color:t.onBubbleVet,textTransform:"uppercase"},dotUpcoming:{borderWidth:2,borderColor:t.borderHairlineGreen,backgroundColor:t.surface},glyph:{...S(e,"bold"),fontSize:o.caption,lineHeight:o.caption+2,color:t.surface},glyphOnBrand:{color:t.onPrimary},connector:{width:2,flex:1,minHeight:22,backgroundColor:t.borderHairlineGreen,marginVertical:2},connectorDone:{backgroundColor:t.brand},title:{flexShrink:1,...S(e,"bold"),fontSize:o.bodyTight,lineHeight:o.bodyTight+4,color:t.text.primary},titleCurrent:{color:t.brandInk},titleFailed:{color:t.danger},titleUpcoming:{color:t.text.muted,...S(e,"regular")},date:{marginLeft:"auto",...S(e,"regular"),fontSize:o.caption,lineHeight:o.caption+4,color:t.text.muted},detail:{...S(e,"regular"),fontSize:o.caption,lineHeight:o.caption+5,color:t.text.muted},detailUpcoming:{color:t.text.muted,opacity:.7}})}i(wb,"makeStyles");function pn(e,t,r){let o=qr(e,r);switch(o.kind){case "consent_required":return jsx(Eb,{onGrant:t});case "consent_unavailable":return jsx(Sb,{});case "session_required":return jsx(Tb,{});case "withheld":return jsx(kb,{});case "pet_not_found":case "error":return jsx(_b,{error:o.error,onRetry:e.refresh});default:return Ir(o)}}i(pn,"renderErrorFamily");function mn(e,t){return ()=>{let r=Hs(t,e.consent);if(r.length===0)return;let o=`records-consent-${Date.now().toString(36)}`;e.grantConsent(r,o);}}i(mn,"makeGrantHandler");function iu({records:e}){let t=$n(),r=e.uploadQueue;if(r.length===0)return null;let o=r.filter(a=>a.status!=="skipped"),n=o.filter(a=>a.status==="done").length,l=ri(Zd(r));return jsxs(View,{style:t.timeline,testID:"records-upload-queue",children:[l!==null?jsx(p,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",style:t.errorText,children:l}):null,o.length>0?jsx(View,{accessibilityLiveRegion:"polite",accessibilityLabel:e.isUploading?Kr.uploading(n,o.length):Kr.uploaded(n,o.length),children:o.map(a=>{let c=Math.round(a.progress*100);return jsxs(View,{style:t.uploadRow,testID:`records-upload-file-${a.status}`,children:[jsxs(View,{style:t.uploadRowHead,children:[jsx(p,{style:t.rowLabel,children:a.name??""}),jsx(p,{style:t.rowValue,children:Jd(a)})]}),a.status==="uploading"?jsx(View,{style:t.progressTrack,accessibilityRole:"progressbar",accessibilityValue:{min:0,max:100,now:c},children:jsx(View,{style:[t.progressFill,{width:`${c}%`}]})}):null,a.status==="failed"&&a.error?jsx(p,{style:t.timelineMeta,children:a.error.displayMessage}):null]},a.key)})}):null]})}i(iu,"UploadQueue");function Eb({onGrant:e}){let t=$n();return jsx(View,{style:t.centered,accessible:true,accessibilityRole:"alert",accessibilityLabel:ve.consentRequired,children:jsx(Pressable,{onPress:e,accessibilityRole:"button",accessibilityLabel:ve.allow,style:t.primaryButton,children:jsx(p,{style:t.primaryLabel,children:ve.allow})})})}i(Eb,"ConsentRequiredState");function ia({label:e,glyph:t}){let r=$n();return useEffect(()=>{AccessibilityInfo.announceForAccessibility?.(e);},[e]),jsxs(View,{style:r.centered,accessible:true,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:e,children:[jsx(View,{style:t==="withheld"?r.withheldGlyph:r.emptyGlyph}),jsx(p,{style:r.errorText,children:e})]})}i(ia,"AlertState");function Sb(){return jsx(ia,{label:ve.consentRequired,glyph:"empty"})}i(Sb,"ConsentUnavailableState");function Tb(){return jsx(ia,{label:ve.sessionRequired,glyph:"empty"})}i(Tb,"SessionRequiredState");function kb(){return jsx(ia,{label:ve.recordUnavailable,glyph:"withheld"})}i(kb,"WithheldState");function _b({error:e,onRetry:t}){let r=$n();return useEffect(()=>{AccessibilityInfo.announceForAccessibility?.(e.displayMessage);},[e.displayMessage]),jsxs(View,{style:r.centered,accessible:true,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",children:[jsx(p,{style:r.errorText,children:e.displayMessage}),e.retryable?jsx(Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:ve.retry,style:r.primaryButton,children:jsx(p,{style:r.primaryLabel,children:ve.retry})}):null]})}i(_b,"ErrorState");function su({call:e,prompt:t}){let r=$n(),o=t.trim().length>0?t:Un.fallbackPrompt;return jsxs(View,{style:r.callCard,accessibilityRole:"summary",children:[jsx(p,{style:r.timelineLabel,children:Un.heading}),jsx(p,{style:r.timelineMeta,children:o}),jsx(Pressable,{onPress:()=>{Linking?.openURL?.(e.dial);},accessibilityRole:"button",accessibilityLabel:Un.callAt(e.phone),style:r.linkButton,testID:"records-call-clinic",children:jsx(p,{style:r.linkLabel,children:Un.call})})]})}i(su,"ClinicCallCard");function $n(){let e=V();return useMemo(()=>Pb(e),[e])}i($n,"useStyles");function Pb(e){let{color:t,space:r,radius:o,type:n,slots:l}=e,{size:a,lineHeight:c,letterSpacing:s}=n,d=dt(l.recordCard,StyleSheet.hairlineWidth),u=yt(l.recordCard),m=i((b,C)=>Math.round(b*C),"lh"),y=StyleSheet.hairlineWidth,g=r.xxl*3+r.xl,w=r.xxl+r.md,R=r.xxl+r.sm,v=e.brightness==="dark"?t.errorRed:t.danger,f={shadowColor:t.brand,shadowOffset:{width:0,height:r.xs},shadowRadius:r.sm,shadowOpacity:.08,elevation:r.xs};return StyleSheet.create({container:{flex:1,minHeight:g,backgroundColor:t.background},body:{flex:1},centered:{minHeight:g,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl,gap:r.lg},emptyGlyph:{width:R,height:R,borderRadius:o.lg,backgroundColor:t.brandSoft,borderWidth:y,borderColor:t.brandBorder},withheldGlyph:{width:R,height:R,borderRadius:o.sm,backgroundColor:t.badgeBgCaution,borderWidth:y,borderColor:t.cautionAccent},errorText:{...S(e,"regular"),fontSize:a.subtitle,lineHeight:m(a.subtitle,c.snug),color:v,textAlign:"center",marginBottom:r.md},primaryButton:{minHeight:w,minWidth:w,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.md,borderRadius:o.pill,backgroundColor:t.primary,...f,...dt(l.primaryButton)},primaryLabel:{...S(e,"bold"),color:t.onPrimary,fontSize:a.body,letterSpacing:s.tight,...yt(l.primaryButton)},linkButton:{minHeight:w,minWidth:w,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.md,borderRadius:o.pill,backgroundColor:t.primary,...f,...dt(l.primaryButton)},linkLabel:{...S(e,"bold"),color:t.onPrimary,fontSize:a.body,letterSpacing:s.tight,...yt(l.primaryButton)},disabledButton:{minHeight:w,minWidth:w,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.md,borderRadius:o.pill,backgroundColor:t.surfaceSubtle,borderWidth:y,borderColor:t.brandBorder},disabledLabel:{...S(e,"bold"),color:t.text.muted,fontSize:a.body,letterSpacing:s.tight},list:{flex:1},listContent:{padding:r.lg,gap:r.md},timeline:{paddingVertical:r.md,paddingHorizontal:r.lg,borderRadius:o.md,backgroundColor:t.surfaceCream,borderWidth:y,borderColor:t.brandBorder,gap:r.xs,...f,...d},timelineTitle:{...S(e,"bold"),fontSize:a.heading,lineHeight:m(a.heading,c.snug),color:t.text.primary,letterSpacing:s.tight,...u},timelineLabel:{...S(e,"bold"),fontSize:a.subtitle,lineHeight:m(a.subtitle,c.snug),color:t.text.secondary,letterSpacing:s.tight,...u},callCard:{gap:r.sm,padding:r.md,borderRadius:o.md,backgroundColor:t.surfaceCream,borderWidth:y,borderColor:t.brandBorder,...d},timelineMeta:{...S(e,"regular"),fontSize:a.bodyTight,lineHeight:m(a.bodyTight,c.normal),color:t.text.muted,...u},recordBlock:{gap:r.sm,padding:r.md,borderRadius:o.md,backgroundColor:t.surfaceCream,borderWidth:y,borderColor:t.brandBorder,...f,...d},row:{flexDirection:"row",justifyContent:"space-between",gap:r.md,paddingVertical:r.xs,borderBottomWidth:y,borderBottomColor:t.borderHairlineGreen},rowLabel:{...S(e,"regular"),fontSize:a.body,lineHeight:m(a.body,c.normal),color:t.text.muted,flexShrink:1,...u},rowValue:{...S(e,"medium"),fontSize:a.body,lineHeight:m(a.body,c.normal),color:t.text.primary,textAlign:"right",flexShrink:1,...u},disclaimer:{...S(e,"regular"),fontSize:a.caption,lineHeight:m(a.caption,c.normal),color:t.text.muted,marginTop:r.md},uploadRow:{gap:r.xs,paddingVertical:r.xs,borderBottomWidth:y,borderBottomColor:t.borderHairlineGreen},uploadRowHead:{flexDirection:"row",justifyContent:"space-between",gap:r.md},progressTrack:{height:r.xs,borderRadius:o.pill,backgroundColor:t.brandSofter,overflow:"hidden",width:"100%"},progressFill:{height:"100%",backgroundColor:t.brand}})}i(Pb,"makeStyles");function sa(e){let{style:t,renderPending:r,...o}=Be(e,["onNavigate","onBack","onAsk"]);return jsx(Ue,{capability:"records",style:t,...r?{renderPending:r}:{},...$e(o.onBack,ot),children:jsx(Ab,{...o,style:t})})}i(sa,"EverfurRecordsRequests");function Ab({petRef:e,petName:t,controller:r,onNavigate:o,onBack:n,onAsk:l,style:a}){let c=Re(),s=aa(),d=mt(r?{petRef:e,controller:r}:{petRef:e}),u=useMemo(()=>Us(d.requests.filter(g=>g.petRef===e)),[d.requests,e]),m=l?g=>{let w=Ho(t,{clinicName:g.clinicName??null,statusLabel:Yr(g),status:g.status,heldItemCount:g.heldItemCount},g.id);l(w.prompt,w.entityRef);}:void 0,y;return d.status==="loading"&&u.length===0?y=jsx(So,{testID:"records-list-loading"}):d.status==="error"&&u.length===0?y=jsx(Xe,{variant:wt(d.error),message:d.error?.displayMessage,onAction:d.error?.retryable?d.refresh:void 0,testID:"records-list-error"}):u.length===0?y=jsx(Xe,{variant:"no_requests",testID:"records-list-empty"}):y=jsx(ScrollView,{contentContainerStyle:s.list,testID:"records-list-results",children:u.map(g=>jsx(Ob,{request:g,onOpen:o?()=>o({name:"request",requestId:g.id}):void 0,onAsk:m?()=>m(g):void 0},g.id))}),jsxs(View,{style:[c.root,a],children:[jsx(it,{title:St.title,onBack:n,testID:"records-list-header"}),u.length>0?jsx(p,{style:s.subtitle,testID:"records-list-subtitle",children:St.subtitle(t)}):null,jsx(View,{style:c.body,children:y}),o?jsxs(View,{style:s.footer,children:[jsx(X,{label:St.requestRecords,accessibilityLabel:St.requestRecordsA11y,onPress:()=>o({name:"clinicPicker"}),testID:"records-list-new"}),jsx(X,{label:St.uploadOwn,kind:"outline",accessibilityLabel:St.uploadOwnA11y,onPress:()=>o({name:"upload"}),testID:"records-list-upload-own"})]}):null,jsx(je,{})]})}i(Ab,"RequestsBody");function Ob({request:e,onOpen:t,onAsk:r}){let o=Re(),n=aa(),l=_d(e),a=Dd(e),c=jsxs(Fragment,{children:[jsx(View,{style:[n.bubble,o.chipTones[a].bg],accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxs(View,{style:n.copy,children:[jsx(p,{style:n.source,numberOfLines:1,children:l.source}),jsx(p,{style:n.meta,numberOfLines:1,children:l.meta}),jsx(View,{accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsx(Lt,{label:l.status,tone:a})})]}),t?jsx(er,{}):null]});return jsxs(View,{style:n.row,testID:`records-request-row-${e.id}`,children:[t?jsx(Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:l.a11yLabel,style:n.rowInner,testID:`records-request-open-${e.id}`,children:c}):jsx(View,{style:n.rowInner,accessible:true,accessibilityLabel:l.a11yLabel,children:c}),t&&Bs(null,e)!==null?jsx(X,{label:Me.cardTitle,onPress:t,testID:`records-request-resume-upload-${e.id}`}):null,r?jsx(X,{label:Xt.ask,kind:"ask",accessibilityLabel:St.askA11y(l.source),onPress:r,testID:`records-request-ask-${e.id}`}):null]})}i(Ob,"RequestRow");function Wn({requests:e,petName:t,activeOnly:r=false,onOpen:o}){let n=aa(),l=Pd(e,ke(t),{activeOnly:r});return l===null||o===void 0?null:jsxs(Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:l.a11yLabel,style:n.card,testID:"records-requests-status",children:[jsx(View,{style:[n.cardBubble,l.processing?n.cardBubbleProcessing:null],accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxs(View,{style:n.cardText,children:[jsx(p,{style:n.cardTitle,children:l.title}),jsx(p,{style:n.cardSubtitle,children:l.subtitle})]}),jsx(er,{})]})}i(Wn,"RecordsRequestsStatusCard");function aa(){let e=V();return useMemo(()=>Lb(e),[e])}i(aa,"useLocalStyles");function Lb(e){let{color:t,space:r,radius:o,type:n}=e,l=i((c,s)=>Math.round(c*s),"lh"),a=r.xxl+r.xs/2;return StyleSheet.create({subtitle:{...S(e,"regular"),fontSize:n.size.caption,lineHeight:l(n.size.caption,n.lineHeight.normal),color:t.text.muted,paddingHorizontal:r.lg,paddingBottom:r.md},list:{paddingHorizontal:r.lg,paddingBottom:r.xl,gap:r.md},row:{borderRadius:o.lg,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,paddingHorizontal:r.md+r.xs/2,paddingVertical:r.md,gap:r.sm},rowInner:{flexDirection:"row",alignItems:"center",gap:r.md},bubble:{width:a,height:a,borderRadius:a/2},copy:{flex:1,gap:r.xs+1},source:{...S(e,"bold"),fontSize:n.size.body,lineHeight:l(n.size.body,n.lineHeight.snug),color:t.text.primary},meta:{...S(e,"regular"),fontSize:n.size.tiny,lineHeight:l(n.size.tiny,n.lineHeight.normal),color:t.text.muted},footer:{paddingHorizontal:r.lg,paddingTop:r.sm+r.xs/2,paddingBottom:r.lg,gap:r.sm+r.xs/2,borderTopWidth:1,borderTopColor:t.borderHairlineGreen},card:{flexDirection:"row",alignItems:"center",gap:r.md,borderRadius:o.md,backgroundColor:t.surfaceCream,paddingHorizontal:r.md+r.xs,paddingVertical:r.md},cardBubble:{width:r.xl+r.xs/2,height:r.xl+r.xs/2,borderRadius:o.pill,borderWidth:2,borderColor:t.brandInk},cardBubbleProcessing:{borderColor:t.warningStrong,backgroundColor:t.badgeBgCaution},cardText:{flex:1,gap:2},cardTitle:{...S(e,"bold"),fontSize:n.size.bodyTight,lineHeight:l(n.size.bodyTight,n.lineHeight.snug),color:t.brandInk},cardSubtitle:{...S(e,"regular"),fontSize:n.size.caption,lineHeight:l(n.size.caption,n.lineHeight.normal),color:t.text.muted}})}i(Lb,"makeLocalStyles");var zb=i((e,t)=>e.getRecordDepth(t),"readDepth"),Nb=i(e=>!e.available,"depthEmpty");function ca(e){let{style:t,renderPending:r,...o}=Be(e,["onNavigate","onBack","onAsk"]);return jsx(Ue,{capability:"records",style:t,...r?{renderPending:r}:{},...$e(o.onBack,ot),children:jsx(Mb,{...o,style:t})})}i(ca,"EverfurRecordsDashboard");function Mb({petRef:e,petName:t,controller:r,consentVersion:o,onNavigate:n,onBack:l,onAsk:a,style:c}){let s=Re(),d=di(),u=mt(r?{petRef:e,controller:r,readUploadFeatures:true}:{petRef:e,readUploadFeatures:true}),{runtime:m}=Te(),y=hn(u.uploadContentTypes)&&zo(m.registry.services.camera),g=Fs(e),w=nr(e,zb,Nb),[R,v]=useState(null),f=useCallback((H,N)=>v({marker:H,point:N}),[]),b=useMemo(()=>Gr(o,u.consent),[o,u.consent]),C=useMemo(()=>mn(u,o),[u,o]),h=Tn("recordsClinic"),I=h.enabled||h.isPending,T=g.markers?.markers??[],k=T.length>0,_=u.record!==null&&!u.record.isEmpty&&!u.record.withheld,E=mo(u.requests,e),B=u.requests.filter(H=>H.petRef===e),x=n?()=>n({name:"requests"}):void 0,A=Ki({hasMarkers:k,requests:u.requests,petRef:e}),z=Qi({recordLoading:u.status==="loading",hasFullRecord:_,recordError:u.status==="error",markersLoading:g.status==="loading",markersError:g.status==="error",hasMarkers:k,requestsLoading:u.status==="loading",dashboardState:A,drivingRequest:E}),de=g.markers?.disclaimer??u.record?.disclaimer??"",G=i(()=>{u.refresh(),g.refresh(),w.refresh();},"retryAll"),ae=w.value!==null&&!w.value.withheld&&w.value.available?w.value:null,M=ke(t),$=a&&g.markers?.summary?()=>{let H=xd(t,g.markers?.summary??{totalMarkers:0,inRangeCount:0,outOfRangeCount:0,unknownCount:0},e);a(H.prompt,H.entityRef);}:void 0,O=a?H=>{let N=wd(t,{canonicalName:H.name,markerId:H.markerId,latestValueText:H.latest?Vt(H.latest.value,H.unit,H.latest.qualitativeResult):null,statusText:H.latest?pr(H.latest.status).label:null,trajectoryText:nn(H.trajectory,H.points.length),meaningText:H.meaning});a(N.prompt,N.entityRef);}:void 0,U=a&&R?()=>{let{marker:H,point:N}=R,ie=Cd(t,{canonicalName:H.name,valueText:Vt(N.value,H.unit,N.qualitativeResult),collectedAt:re(N.at),sourceClinic:N.sourceClinic,referenceText:N.refLow!==null||N.refHigh!==null?Mo(N,H.unit):null,flagged:N.status==="above"?"above":N.status==="below"?"below":null,reviewed:N.reviewed,entityId:N.docId??H.markerId});v(null),a(ie.prompt,ie.entityRef);}:void 0,D=jsxs(Fragment,{children:[g.markers?.summary?jsx(View,{style:s.inset,children:jsx(Vd,{summary:g.markers.summary,onAsk:$,testID:"dashboard-marker-summary"})}):null,jsx(p,{style:s.lead,children:vt.lead(t)}),jsx(Md,{markers:T,onPointPress:f,onAsk:O})]}),q=i(H=>n?jsxs(View,{style:[s.inset,d.actions],children:[H?jsx(li,{label:vt.viewFullRecord,onPress:()=>n({name:"record"}),testID:"dashboard-full-record-action"}):null,jsx(li,{label:vt.viewTimeline,onPress:()=>n({name:"timeline"}),testID:"dashboard-timeline-action"}),jsx(li,{label:St.allRequests,onPress:()=>n({name:"requests"}),testID:"dashboard-requests-action"})]}):null,"actions"),ee=i(H=>n?jsxs(View,{style:[H?s.inset:null,d.addActions],testID:"dashboard-actions",children:[I?jsx(X,{label:Ot.requestFromClinic,accessibilityLabel:Ot.requestFromClinicA11y(t),onPress:()=>n({name:"clinicPicker"}),style:d.addCta,testID:"dashboard-actions-clinic"}):null,jsx(X,{label:Ot.uploadDocument,kind:"outline",accessibilityLabel:Ot.uploadDocumentA11y(t),onPress:()=>n({name:"upload"}),style:d.addCta,testID:"dashboard-actions-upload"})]}):null,"addActions"),J;if(u.status==="error"){let H=qr(u,b);J=H.kind==="error"||H.kind==="pet_not_found"?jsx(Xe,{variant:wt(H.error),message:H.error.displayMessage,onAction:H.error.retryable?G:void 0,testID:"dashboard-error"}):pn(u,C,b);}else switch(z){case "loading":J=jsx(Eo,{testID:"dashboard-loading"});break;case "record":J=jsxs(ScrollView,{contentContainerStyle:s.contentTight,testID:"dashboard-record",children:[k?D:g.status==="error"?jsx(View,{style:[s.inset,d.actions],children:jsx(li,{label:vt.retryMarkers,onPress:G,testID:"dashboard-markers-retry"})}):null,jsx(View,{style:s.inset,children:u.record?jsx(ti,{record:u.record,depth:ae,petName:t,showLabs:!k,onNavigate:n,onAsk:a}):null}),jsx(View,{style:s.inset,children:jsx(Wn,{requests:B,petName:t,activeOnly:true,onOpen:x})}),ee(true),q(true)]});break;case "error":J=jsx(Xe,{variant:wt(g.error??u.error),message:(g.error??u.error)?.displayMessage,onAction:(g.error??u.error)?.retryable?G:void 0,testID:"dashboard-error"});break;case "in_progress":J=jsxs(ScrollView,{contentContainerStyle:s.content,testID:"dashboard-in-progress",children:[E?jsx(Hb,{request:E,petName:M,onOpen:n?()=>n({name:"request",requestId:E.id}):void 0,onAsk:a?()=>{let H=Ho(t,{clinicName:E.clinicName??null,statusLabel:Yr(E),status:E.status,heldItemCount:E.heldItemCount},E.id);a(H.prompt,H.entityRef);}:void 0}):null,jsx(Wn,{requests:B,petName:t,onOpen:x}),n?jsxs(View,{style:d.ways,testID:"dashboard-ways",children:[I?jsx(du,{title:Xt.anotherClinic,sub:Xt.anotherClinicSub,onPress:()=>n({name:"clinicPicker"}),testID:"dashboard-way-clinic"}):null,jsx(du,{title:Ot.uploadDocument,...y?{sub:Xt.uploadDocumentPhotoSub}:{},accessibilityLabel:Ot.uploadDocumentA11y(t),dashed:true,onPress:()=>n({name:"upload"}),testID:"dashboard-way-upload"})]}):null,jsx(Fr,{disclaimer:de})]});break;case "none":J=jsxs(ScrollView,{contentContainerStyle:s.content,testID:"dashboard-request-prompt",children:[jsxs(View,{style:d.promptCard,children:[jsxs(View,{style:d.promptHeader,children:[jsx(View,{style:d.promptGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsx(p,{style:d.promptTitle,children:Ot.title(t)})]}),jsx(p,{style:d.promptBody,children:Ot.body}),n?jsxs(Fragment,{children:[jsx(X,{label:Ot.requestFromClinic,accessibilityLabel:Ot.requestFromClinicA11y(t),onPress:()=>n({name:"clinicPicker"}),style:d.promptCta,testID:"dashboard-request-prompt-clinic"}),jsx(X,{label:Ot.uploadDocument,kind:"outline",accessibilityLabel:Ot.uploadDocumentA11y(t),onPress:()=>n({name:"upload"}),style:d.promptCtaSecondary,testID:"dashboard-request-prompt-upload"})]}):null]}),jsx(Wn,{requests:B,petName:t,onOpen:x}),jsx(Fr,{disclaimer:de})]});break;case "labs_only":J=jsxs(ScrollView,{contentContainerStyle:s.contentTight,testID:"dashboard-labs-only",children:[D,jsx(View,{style:s.inset,children:jsx(Wn,{requests:B,petName:t,activeOnly:true,onOpen:x})}),ee(true),jsx(View,{style:s.inset,children:jsx(Fr,{disclaimer:de})}),q(false)]});break;default:J=Ir(z);}return jsxs(View,{style:[s.root,c],children:[jsx(it,{title:vt.titleNative(t),onBack:l,testID:"dashboard-header",right:n?jsx(Pressable,{onPress:()=>n({name:"timeline"}),accessibilityRole:"button",accessibilityLabel:vt.openTimeline,hitSlop:12,style:d.headerButton,testID:"dashboard-timeline-link",children:jsx(mc,{})}):void 0}),jsx(View,{style:s.body,children:J}),jsx(Hd,{marker:R?.marker??null,point:R?.point??null,onClose:()=>v(null),onAsk:U}),jsx(je,{})]})}i(Mb,"DashboardBody");function li({label:e,onPress:t,testID:r}){let o=di();return jsxs(Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:e,style:o.actionRow,testID:r,children:[jsxs(View,{style:o.actionLeft,children:[jsx(View,{style:o.actionIcon,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsx(p,{style:o.actionLabel,children:e})]}),jsx(er,{})]})}i(li,"ActionRow");function Hb({request:e,petName:t,onOpen:r,onAsk:o}){let n=Re(),l=di(),a=Xt.title(t),c=e.clinicName?.trim()??"",s=Yr(e),d=jsxs(View,{style:l.inProgressInner,children:[jsxs(View,{style:l.inProgressHead,children:[jsxs(View,{style:l.inProgressHeadText,children:[jsx(p,{style:l.inProgressTitle,children:a}),c.length>0?jsx(p,{style:n.rowDetail,children:c}):null]}),r?jsx(er,{}):null]}),jsx(si,{request:e,petName:t}),s.length>0?jsx(View,{style:n.statusCard,children:jsx(p,{style:n.statusText,children:s})}):null]});return jsxs(View,{style:l.inProgressCard,testID:"dashboard-in-progress-card",accessibilityRole:"summary",accessible:r?false:void 0,accessibilityLabel:r?void 0:Xt.a11y(t),children:[r?jsx(Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:Xt.openA11y(t,s),testID:"dashboard-in-progress-open",children:d}):d,o?jsx(X,{label:Xt.ask,kind:"ask",accessibilityLabel:Xt.askA11y,onPress:o,testID:"dashboard-in-progress-ask"}):null]})}i(Hb,"InProgressCard");function du({title:e,sub:t,accessibilityLabel:r,dashed:o=false,onPress:n,testID:l}){let a=di(),s=V().motion.reducedMotion;return jsxs(Pressable,{onPress:n,accessibilityRole:"button",accessibilityLabel:r??(t?`${e}. ${t}`:e),style:({pressed:d})=>[a.way,o?a.wayDashed:null,d&&!s?{transform:[{scale:ho.pressScale}]}:null],testID:l,children:[jsxs(View,{style:a.wayText,children:[jsx(p,{style:a.wayTitle,children:e}),t?jsx(p,{style:a.waySub,children:t}):null]}),jsx(er,{})]})}i(du,"WayCard");function di(){let e=V();return useMemo(()=>Bb(e),[e])}i(di,"useLocalStyles");function Bb(e){let{color:t,space:r,radius:o,type:n}=e,l=StyleSheet.hairlineWidth,a=r.xxl+r.md;return StyleSheet.create({headerButton:{width:a,height:a,alignItems:"center",justifyContent:"center"},actions:{gap:r.sm+r.xs/2},actionRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",borderRadius:o.lg,borderWidth:1,borderColor:t.borderRingCream,backgroundColor:t.surface,paddingHorizontal:r.lg,paddingVertical:r.lg},actionLeft:{flex:1,flexDirection:"row",alignItems:"center",gap:r.md},actionIcon:{width:r.lg+r.xs/2,height:r.lg+r.xs/2,borderRadius:o.xs,backgroundColor:t.brandSoft,borderWidth:l,borderColor:t.brandBorder},actionLabel:{flex:1,...S(e,"medium"),fontSize:n.size.body,lineHeight:Math.round(n.size.body*n.lineHeight.snug),color:t.text.primary},inProgressCard:{borderRadius:o.lg,backgroundColor:t.surface,borderWidth:1,borderColor:t.borderRingCream,padding:r.lg,gap:r.lg},inProgressHeadText:{flex:1,gap:r.xs/2},ways:{gap:r.sm},way:{flexDirection:"row",alignItems:"center",gap:r.md,borderRadius:o.lg,borderWidth:1,borderColor:t.borderRingCream,backgroundColor:t.surface,padding:r.lg},wayDashed:{borderStyle:"dashed",borderColor:t.brandBorderStrong},wayText:{flex:1,gap:r.xs/2},wayTitle:{...S(e,"bold"),fontSize:n.size.body,lineHeight:Math.round(n.size.body*n.lineHeight.snug),color:t.text.primary},waySub:{...S(e,"regular"),fontSize:n.size.caption,lineHeight:Math.round(n.size.caption*n.lineHeight.normal),color:t.text.muted},inProgressInner:{gap:r.lg},inProgressHead:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},inProgressTitle:{...S(e,"bold"),fontSize:n.size.subtitle,lineHeight:Math.round(n.size.subtitle*n.lineHeight.snug),letterSpacing:-0.4,color:t.brandInk},promptCard:{borderRadius:o.sm,backgroundColor:t.surfaceCream,borderWidth:l,borderColor:t.borderRingCream,paddingHorizontal:r.lg+r.xs,paddingVertical:r.lg+r.xs/2},promptHeader:{flexDirection:"row",alignItems:"center",gap:r.xs+1},promptGlyph:{width:r.xl+1,height:r.xl+1,borderRadius:o.xs,borderWidth:2,borderColor:t.warningStrong},promptTitle:{flex:1,...S(e,"bold"),fontSize:n.size.subtitle,lineHeight:Math.round(n.size.subtitle*n.lineHeight.snug),letterSpacing:n.letterSpacing.headerBrand,color:t.brandInk},promptBody:{marginTop:r.sm-1,...S(e,"regular"),fontSize:n.size.bodyTight,lineHeight:r.lg+r.xs,color:t.text.primary},promptCta:{marginTop:r.sm-1,minHeight:r.xxl+r.sm},promptCtaSecondary:{marginTop:r.sm,minHeight:r.xxl+r.sm},addActions:{gap:r.sm},addCta:{minHeight:r.xxl+r.sm}})}i(Bb,"makeLocalStyles");var ui=Object.freeze({visit:0,vaccine:1,weight:2,medication:3});function pu(e){if(!e)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}i(pu,"toMillis");function mu(e){let t=[...e.visits.map((r,o)=>({key:`visit-${o}-${r.visitId}`,kind:"visit",kindLabel:be.kind.visit,at:r.visitDate,date:re(r.visitDate),title:r.summary??be.clinicVisit,detail:r.veterinarian?be.doctor(r.veterinarian):null,docId:r.docId})),...e.vaccines.map((r,o)=>{let n=[];return r.lot&&n.push(be.lot(r.lot)),r.expiresOn&&n.push(be.expires(re(r.expiresOn))),{key:`vaccine-${o}-${r.vaccineId}`,kind:"vaccine",kindLabel:be.kind.vaccine,at:r.administeredOn,date:re(r.administeredOn),title:r.product||be.kind.vaccine,detail:n.length?n.join(" \xB7 "):null,docId:r.docId}}),...e.weights.map((r,o)=>({key:`weight-${o}-${r.weightId}`,kind:"weight",kindLabel:be.kind.weight,at:r.observedOn,date:re(r.observedOn),title:xc(r.weightKg),detail:null,docId:r.docId})),...e.medications.map((r,o)=>{let n=[r.dose,r.route,r.frequency].filter(l=>!!l);return {key:`medication-${o}-${r.medicationId}`,kind:"medication",kindLabel:be.kind.medication,at:r.startedOn,date:re(r.startedOn),title:r.drugName||be.kind.medication,detail:n.length?n.join(" \xB7 "):null,docId:r.docId}})];return Object.freeze(t.sort((r,o)=>{let n=pu(r.at),l=pu(o.at);return n===null&&l===null?ui[r.kind]-ui[o.kind]:n===null?1:l===null?-1:l!==n?l-n:ui[r.kind]-ui[o.kind]}))}i(mu,"buildTimelineRows");var Yb=300,Kb=i((e,t)=>e.getTimeline(t),"readTimeline"),Qb=i(e=>e.isEmpty,"timelineEmpty");var Xb=i(e=>e.contributions.length===0,"contributionsEmpty");function gu({petRef:e,style:t,onBack:r}){let o=nr(e,Kb,Qb);return jsx(hu,{state:o,style:t,onBack:r,header:jsx(it,{title:be.timeline,onBack:En(r),testID:"timeline-header"}),loading:jsx(Dc,{testID:"timeline-loading"}),empty:jsx(Xe,{variant:"no_records",testID:"timeline-empty"}),render:n=>jsx(eh,{timeline:n})})}i(gu,"EverfurRecordsTimeline");function bu({petRef:e,docId:t,style:r,onBack:o}){let n=useCallback((c,s)=>c.getDocumentContributions(s,t),[t]),l=nr(e,n,Xb,t),a=l.value?.document?.title?.trim()||be.uploadedDocument;return jsx(hu,{state:l,style:r,onBack:o,header:jsx(it,{title:a,onBack:En(o),testID:"contributions-header"}),empty:jsx(Xe,{variant:"no_records",testID:"contributions-empty"}),render:c=>jsx(th,{view:c})})}i(bu,"EverfurDocumentContributions");function hu({state:e,style:t,header:r,loading:o,empty:n,render:l,onBack:a}){let c=da();return jsx(Ue,{capability:"records",style:t,...$e(En(a),ot),children:jsxs(View,{style:[c.container,t],children:[r??null,jsx(View,{style:c.body,children:Jb(e,l,c,o,n)}),jsx(je,{})]})})}i(hu,"DepthSurface");function Jb(e,t,r,o,n){switch(e.status){case "loading":return o??jsx(Zb,{styles:r});case "empty":return n??jsx(View,{style:r.centered,accessible:true,accessibilityRole:"summary",accessibilityLabel:ve.empty,children:jsx(View,{style:r.emptyGlyph})});case "error":return e.error?jsx(Xe,{variant:wt(e.error),message:e.error.displayMessage,onAction:e.error.retryable?e.refresh:void 0,testID:"depth-error"}):null;case "populated":return e.value===null||e.value.withheld?null:t(e.value);default:return null}}i(Jb,"renderState");function Zb({styles:e}){let[t,r]=useState(false);return useEffect(()=>{let o=setTimeout(()=>r(true),Yb);return ()=>clearTimeout(o)},[]),jsx(View,{style:e.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:ve.loading,children:t?jsx(ActivityIndicator,{}):null})}i(Zb,"LoadingState");function eh({timeline:e}){let t=da(),r=mu(e);return jsxs(ScrollView,{style:t.list,contentContainerStyle:t.timelineContent,accessibilityLabel:be.timeline,children:[e.disclaimer.length>0?jsx(View,{style:t.timelineBand,accessible:true,accessibilityRole:"text",accessibilityLabel:vt.important(e.disclaimer),children:jsx(p,{style:t.timelineBandText,children:e.disclaimer})}):null,r.map((o,n)=>jsxs(View,{children:[n>0?jsx(View,{style:t.timelineSeparator}):null,jsxs(View,{style:t.timelineRow,accessible:true,accessibilityRole:"text",accessibilityLabel:[o.kindLabel,o.date,o.title,o.detail].filter(Boolean).join(", "),testID:`records-timeline-row-${o.kind}`,children:[jsx(View,{style:t.timelineBubble,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxs(View,{style:t.timelineBody,children:[jsxs(View,{style:t.topLine,children:[jsx(p,{style:t.timelineKind,children:o.kindLabel}),jsx(p,{style:t.date,children:o.date})]}),jsx(p,{style:t.timelineTitle,children:o.title}),o.detail?jsx(p,{style:t.rowDetail,children:o.detail}):null]})]})]},o.key))]})}i(eh,"TimelineBody");function th({view:e}){let t=da();return jsxs(ScrollView,{style:t.list,contentContainerStyle:t.listContent,accessibilityLabel:ve.records,children:[e.document?.receivedAt?jsx(p,{style:t.rowDetail,children:re(e.document.receivedAt)}):null,jsx(View,{style:t.card,children:e.contributions.map(r=>jsxs(View,{style:t.row,accessible:true,accessibilityRole:"text",children:[jsx(p,{style:t.rowTitle,children:r.label}),jsx(p,{style:t.rowValue,children:rn(r.value,r.unit)}),r.observedAt?jsx(p,{style:t.rowDetail,children:re(r.observedAt)}):null]},r.key))})]})}i(th,"ContributionsBody");function da(){let e=V();return useMemo(()=>rh(e),[e])}i(da,"useStyles");function rh(e){let{color:t,space:r,radius:o,type:n,slots:l}=e,{size:a,lineHeight:c}=n,s=i((v,f)=>Math.round(v*f),"lh"),d=StyleSheet.hairlineWidth,u=r.xxl*3+r.xl,m=r.xxl+r.md,y=e.brightness==="dark"?t.errorRed:t.danger,g=yt(l.recordCard),w=i((v,f,b,C="regular")=>({...S(e,C),fontSize:v,lineHeight:s(v,f),color:b}),"text"),R=i((v,f,b,C="regular")=>({...w(v,f,b,C),...g}),"inCard");return StyleSheet.create({container:{flex:1,minHeight:u,backgroundColor:t.background},body:{flex:1},centered:{minHeight:u,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl,gap:r.lg},emptyGlyph:{width:r.xxl+r.sm,height:r.xxl+r.sm,borderRadius:o.lg,backgroundColor:t.brandSoft,borderWidth:d,borderColor:t.brandBorder},errorText:{...w(a.subtitle,c.snug,y),textAlign:"center",marginBottom:r.md},primaryButton:{minHeight:m,minWidth:m,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.md,borderRadius:o.pill,backgroundColor:t.primary,...dt(l.primaryButton)},primaryLabel:{...S(e,"bold"),color:t.onPrimary,fontSize:a.body,...yt(l.primaryButton)},list:{flex:1},listContent:{padding:r.lg,gap:r.md},section:{gap:r.sm},heading:{...w(a.heading,c.snug,t.text.primary,"bold")},card:{gap:r.sm,padding:r.md,borderRadius:o.md,backgroundColor:t.surfaceCream,borderWidth:d,borderColor:t.brandBorder,...dt(l.recordCard,d)},row:{gap:r.xs,paddingVertical:r.xs,borderBottomWidth:d,borderBottomColor:t.borderHairlineGreen},topLine:{flexDirection:"row",justifyContent:"space-between",gap:r.md},kindLabel:{...R(a.caption,c.normal,t.text.muted,"medium")},date:R(a.caption,c.normal,t.text.muted),rowTitle:{...R(a.body,c.normal,t.text.primary,"bold")},rowValue:{...R(a.body,c.normal,t.text.primary,"medium")},rowDetail:R(a.bodyTight,c.normal,t.text.muted),rowMuted:{...R(a.bodyTight,c.normal,t.text.muted),opacity:.7},chip:{...w(a.caption,c.normal,t.text.primary),alignSelf:"flex-start",paddingHorizontal:r.sm,paddingVertical:r.xs,borderRadius:o.pill},chipNeutral:{backgroundColor:t.badgeBgNeutral},chipCaution:{backgroundColor:t.badgeBgCaution},chipCritical:{backgroundColor:t.badgeBgCritical},disclaimer:{...w(a.caption,c.normal,t.text.muted),marginTop:r.md},timelineContent:{paddingBottom:r.xxl},timelineBand:{flexDirection:"row",gap:r.sm,borderRadius:o.md-r.xs/2,padding:r.md,backgroundColor:t.brandSoft,marginHorizontal:r.lg,marginTop:r.xs,marginBottom:r.md},timelineBandText:{flex:1,...w(a.caption,c.normal,t.text.secondary)},timelineSeparator:{height:d,backgroundColor:t.brandBorder,marginLeft:ms},timelineRow:{flexDirection:"row",gap:r.md,paddingHorizontal:r.lg,paddingVertical:r.md+r.xs/2},timelineBubble:{width:r.xxl+r.xs/2,height:r.xxl+r.xs/2,borderRadius:o.pill,backgroundColor:t.brandSoft,borderWidth:d,borderColor:t.brandBorder},timelineBody:{flex:1,gap:r.xs-1},timelineKind:{...S(e,"mono"),fontSize:a.micro,lineHeight:a.bodyTight,letterSpacing:n.letterSpacing.eyebrow/3,textTransform:"uppercase",color:t.text.secondary},timelineTitle:{...w(a.body,c.normal,t.text.primary,"medium")}})}i(rh,"makeStyles");function ua(e,t={}){let r=xr(),{userRef:o}=Te(),n=t.now??Date.now,[l,a]=useState(null),[c,s]=useState(true),[d,u]=useState(null),[m,y]=useState(null),g=m===true,[w,R]=useState({}),[v,f]=useState(false),[b,C]=useState(null),[h,I]=useState(false),[T,k]=useState(false),[_,E]=useState(false),[B,x]=useState(null),A=B!==null&&B.client===r?B.value:Mt,z=A.shareAudiences,de=no(e),G=useRef(0),ae=useRef(true),M=useCallback(async()=>{let ie=G.current+=1;if(s(true),u(null),o===null){a(null),s(false);return}let Ce=await r.listShares(e);ie!==G.current||!ae.current||(Ce.ok?(a(Ce.value),y(true)):Cr(Ce.error)?(a(null),y(false)):(a(null),u(Ce.error),Ru(Ce)&&y(true)),s(false));},[r,e,o]);useEffect(()=>(ae.current=true,M(),()=>{ae.current=false,G.current+=1;}),[M]),useEffect(()=>{if(o===null||r.readFeatures===void 0)return;let ie=true;return r.readFeatures().then(Ce=>{ie&&x({client:r,value:Ce});},()=>{}),()=>{ie=false;}},[r,o]);let $=useRef(de);useEffect(()=>{$.current!==de&&($.current=de,R({}),k(true),M());},[de,M]);let O=useCallback(async ie=>{f(true);let Le=await(ie!==void 0&&z.some(rt=>rt.audience===ie)?r.createShare(e,{audience:ie}):r.createShare(e));return ae.current&&(f(false),Le.ok?(R(rt=>({...rt,[Le.value.shareId]:Le.value.shareUrl})),M()):Cr(Le.error)?y(false):ar(Le.error)&&k(true)),Le},[r,e,M,z]),U=useCallback(async ie=>{E(true);let Ce=await r.emailShare(e,ie);return ae.current&&(E(false),Ce.ok?M():Cr(Ce.error)?y(false):ar(Ce.error)?k(true):Ce.error.httpStatus===502&&M()),Ce},[r,e,M]),D=useCallback(async ie=>{C(ie);let Ce=await r.revokeShare(e,ie);return ae.current&&(C(null),M()),Ce},[r,e,M]),q=useCallback(async()=>{I(true);let ie=await r.getPdfLink(e);return ae.current&&(I(false),!ie.ok&&ar(ie.error)&&k(true)),ie},[r,e]),ee=useCallback(()=>{k(false),M();},[M]),J=useMemo(()=>kc(l??[],w,n()),[l,w,n]),H=c?"loading":d!==null?"error":J.length===0?"empty":"populated",N=A.features;return useMemo(()=>({status:H,rows:J,available:g,consentRequired:T,error:d,creating:v,revokingId:b,preparingPdf:h,shareAudiences:z,features:N,sending:_,createLink:O,sendEmail:U,revoke:D,pdfLink:q,refresh:ee}),[H,J,g,T,d,v,b,h,z,N,_,O,U,D,q,ee])}i(ua,"useRecordShares");function Ru(e){return e.ok||e.error.httpStatus!==void 0&&e.error.httpStatus!==404}i(Ru,"answeredBehindGate");function vu(e){return e.available||e.status!=="empty"}i(vu,"sharesListShown");function pa(e){let t=xr(),{userRef:r}=Te(),o=useMemo(()=>({}),[t,e,r]),[n,l]=useState({scope:o,lit:null});useEffect(()=>{if(r===null)return;let c=true;return t.listShares(e).then(s=>{c&&(!s.ok&&Cr(s.error)?l({scope:o,lit:false}):Ru(s)&&l({scope:o,lit:true}));},()=>{}),()=>{c=false;}},[t,e,r,o]);let a=n.scope===o?n.lit:null;return useMemo(()=>({lit:a}),[a])}i(pa,"useRecordsDepthProbe");function ma(e){let t=xr(),o=pa(e).lit===true,[n,l]=useState(false),[a,c]=useState(null),s=useRef(true);useEffect(()=>(s.current=true,()=>{s.current=false;}),[]);let d=useCallback(async()=>{l(true),c(null);let u=await t.getPdfLink(e);return s.current&&(l(false),u.ok||c(u.error)),u},[t,e]);return useMemo(()=>({preparing:n,available:o,error:a,pdfLink:d}),[n,o,a,d])}i(ma,"useRecordPdfLink");async function xu(e){await Share.share({message:j.shareMessage(e),url:e});}i(xu,"shareLinkViaOs");async function mi(e){await Share.share(Platform.OS==="ios"?{url:e}:{message:e});}i(mi,"shareFileLinkViaOs");var zt=ne.document,Su=Object.freeze(["medication","vaccination","problem","allergy","procedure","body_weight","vital"]),ah=i((e,t)=>e.getRecordDepth(t),"readDepth"),lh=i(e=>!e.available,"depthEmpty");function ya(e){let{style:t,renderPending:r,...o}=Be(e,["onBack"]);return jsx(Ue,{capability:"records",style:t,...r?{renderPending:r}:{},...$e(o.onBack,ot),children:jsx(dh,{...o,style:t})})}i(ya,"EverfurRecordDocument");function ch(e,t){return e.identity.length===0&&e.entities.length===0&&e.forwardLooking.length===0&&(t===null||t.labResults.length===0&&t.physicalExams.length===0&&t.clinicianNotes.length===0)}i(ch,"documentIsEmpty");function dh({petRef:e,petName:t,controller:r,consentVersion:o,onBack:n,onOpenUrl:l,style:a}){let c=Re(),s=Tu(),d=V(),u=mt(r?{petRef:e,controller:r}:{petRef:e}),m=nr(e,ah,lh),y=ma(e),g=useMemo(()=>Gr(o,u.consent),[o,u.consent]),w=useMemo(()=>mn(u,o),[u,o]),R=m.value!==null&&!m.value.withheld&&m.value.available?m.value:null,v=u.record,[f,b]=useState(false),C=i(()=>{b(false),y.pdfLink().then(T=>{if(!T.ok)return;Ar(l??(_=>mi(_)),T.value.downloadUrl,"record_pdf").then(_=>{!_.ok&&!l&&b(true);});});},"download"),h,I=false;if(u.status==="loading"||m.status==="loading"&&v!==null)h=jsx(View,{style:s.centered,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:vt.loading,testID:"record-document-loading",children:jsx(ActivityIndicator,{color:d.color.brandInk})});else if(u.status==="error"){let T=qr(u,g);h=T.kind==="error"||T.kind==="pet_not_found"?jsx(Xe,{variant:wt(T.error),message:T.error.displayMessage,onAction:T.error.retryable?()=>{u.refresh(),m.refresh();}:void 0,testID:"record-document-error"}):pn(u,w,g);}else v===null||ch(v,R)?h=jsx(View,{style:s.centered,testID:"record-document-empty",children:jsx(p,{style:s.emptyText,children:zt.empty})}):(I=true,h=jsx(uh,{record:v,depth:R,petName:t,wordmark:d.meta.displayName}));return jsxs(View,{style:[c.root,s.root,a],children:[jsx(it,{title:zt.titleFor(t),variant:"document",onBack:n,testID:"record-document-header",right:y.available&&I?jsx(Pressable,{onPress:C,disabled:y.preparing,accessibilityRole:"button",accessibilityLabel:zt.download,accessibilityState:{disabled:y.preparing,busy:y.preparing},hitSlop:8,style:s.download,testID:"record-document-download",children:y.preparing?jsx(ActivityIndicator,{size:"small",color:d.color.brandInk}):jsx(gc,{})}):void 0}),y.error?jsx(p,{style:[c.errorText,s.inset],accessibilityRole:"alert",children:y.error.displayMessage}):f?jsx(p,{style:[c.errorText,s.inset],accessibilityRole:"alert",testID:"record-document-share-failed",children:j.toasts.pdfShareSheet}):null,jsx(View,{style:c.body,children:h}),jsx(je,{})]})}i(dh,"DocumentBody");function uh({record:e,depth:t,petName:r,wordmark:o}){let n=Tu(),l=useMemo(()=>{let s=[],d=new Map;for(let y of e.entities){let g=y.category.trim();if(g.length===0)continue;let w=d.get(g);w===void 0?(s.push(g),d.set(g,[y])):w.push(y);}let u=Su.filter(y=>s.includes(y)),m=s.filter(y=>!Su.includes(y));return [...u,...m].map(y=>({type:y,rows:d.get(y)??[]}))},[e.entities]),a=Date.now(),c=i((s,d,u)=>jsxs(View,{style:n.section,testID:u,children:[jsxs(View,{style:n.sectionHeader,children:[jsx(p,{style:n.sectionTitle,accessibilityRole:"header",children:s}),jsx(View,{style:n.rule})]}),jsx(View,{children:d})]},u),"section");return jsxs(ScrollView,{contentContainerStyle:n.page,showsVerticalScrollIndicator:false,testID:"record-document",children:[jsxs(View,{style:n.letterhead,children:[jsx(p,{style:n.wordmark,children:o}),jsx(p,{style:n.docTitle,children:zt.docTitle}),jsx(p,{style:n.petName,children:r?.trim()||zt.namelessPet}),jsx(p,{style:n.generated,children:zt.generated(e.generatedAt)})]}),e.identity.length>0?c(zt.identity,e.identity.map((s,d)=>jsxs(View,{style:[n.row,d>0?n.rowDivider:null],children:[jsx(p,{style:n.rowLabel,children:s.label}),jsx(p,{style:n.rowValue,children:s.value})]},`${d}:${s.label}`)),"record-document-identity"):null,t&&t.labResults.length>0?c(zt.labs,t.labResults.map((s,d)=>{let u=pr(s.latest.status),m=Sc(s.points[s.points.length-1]??null),y=Vt(s.latest.value,s.latest.unit??s.unit,s.latest.qualitativeResult);return jsxs(View,{style:[n.row,u.outOfRange?n.rowFlag:null,d>0?n.rowDivider:null],children:[jsxs(View,{style:n.rowMain,children:[jsx(p,{style:n.rowLabel,children:s.name}),jsxs(p,{style:n.rowMeta,children:[m?zt.ref(m):zt.noRange,s.latest.at?` \xB7 ${re(s.latest.at)}`:""]})]}),jsxs(View,{style:n.rowRight,children:[y!=="-"?jsx(p,{style:[n.rowValue,u.outOfRange?n.rowValueAlert:null],children:y}):null,jsx(p,{style:[n.markerStatus,u.outOfRange?n.rowValueAlert:null],children:u.label})]})]},s.markerId)}),"record-document-labs"):null,l.map(({type:s,rows:d})=>c(vr(s),d.map((u,m)=>{let y=[rn(u.value,u.unit),u.observedAt?re(u.observedAt):null].filter(g=>g&&g.length>0).join(" \xB7 ");return jsx(View,{style:[n.row,m>0?n.rowDivider:null],children:jsxs(View,{style:n.rowMain,children:[jsx(p,{style:n.rowLabel,children:u.label}),y?jsx(p,{style:n.rowMeta,children:y}):null]})},u.key)}),`record-document-${s}`)),e.forwardLooking.length>0?c(zt.upcomingCare,e.forwardLooking.map((s,d)=>{let u=Dn(s.dueAt,a);return jsxs(View,{style:[n.row,d>0?n.rowDivider:null],children:[jsxs(View,{style:n.rowMain,children:[jsx(p,{style:n.rowLabel,children:s.title}),s.detail?jsx(p,{style:n.rowMeta,children:s.detail}):null]}),u?jsx(p,{style:[n.rowValue,u.overdue?n.rowValueAlert:null],children:u.label}):null]},`${s.title}-${d}`)}),"record-document-upcoming"):null,t&&t.physicalExams.length>0?c(zt.physicalExams,t.physicalExams.map((s,d)=>jsxs(View,{style:[n.block,d>0?n.rowDivider:null],children:[s.observedOn?jsx(p,{style:n.blockDate,children:re(s.observedOn)}):null,s.systems.filter(u=>u.finding).map(u=>jsxs(View,{style:n.fieldRow,children:[jsx(p,{style:n.fieldLabel,children:Hr(u.system)}),jsx(p,{style:n.fieldValue,children:u.finding})]},u.system))]},s.examId)),"record-document-exams"):null,t&&t.clinicianNotes.length>0?c(zt.clinicianNotes,t.clinicianNotes.map((s,d)=>jsxs(View,{style:[n.block,d>0?n.rowDivider:null],children:[s.observedOn?jsx(p,{style:n.blockDate,children:re(s.observedOn)}):null,s.sections.filter(u=>u.text).map((u,m)=>jsxs(View,{style:n.noteSection,children:[jsx(p,{style:n.noteLabel,children:on(u.section)}),jsx(p,{style:n.noteBody,children:u.text})]},`${u.section}-${m}`))]},s.noteId)),"record-document-notes"):null,e.disclaimer.length>0?jsx(View,{style:n.disclaimer,children:jsx(p,{style:n.disclaimerText,children:e.disclaimer})}):null]})}i(uh,"RecordDocument");function Tu(){let e=V();return useMemo(()=>ph(e),[e])}i(Tu,"useLocalStyles");function ph(e){let{color:t,space:r,radius:o,type:n}=e,l=StyleSheet.hairlineWidth,a=i((s,d,u,m="regular")=>({...S(e,m),fontSize:s,lineHeight:Math.round(s*d),color:u}),"text"),c=i((s,d)=>({...S(e,"mono"),fontSize:s,lineHeight:s+r.xs-1,color:d,letterSpacing:n.letterSpacing.eyebrow/2,textTransform:"uppercase"}),"mono");return StyleSheet.create({root:{backgroundColor:t.surface},inset:{paddingHorizontal:r.lg},download:{width:r.xxl+r.xs+r.xs/2,height:r.xxl+r.xs+r.xs/2,borderRadius:o.pill,alignItems:"center",justifyContent:"center"},centered:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xxl,minHeight:r.xxl*3+r.xl},emptyText:{...a(n.size.body,n.lineHeight.normal,t.text.muted,"medium"),textAlign:"center"},page:{paddingHorizontal:r.lg+r.xs,paddingBottom:r.xxl+r.lg},letterhead:{alignItems:"center",paddingTop:r.md,paddingBottom:r.lg+r.xs+r.xs/2,borderBottomWidth:2,borderBottomColor:t.brandInk,gap:r.xs+r.xs/2,marginBottom:r.sm},wordmark:{...a(n.size.heading,n.lineHeight.snug,t.brandInk,"bold"),letterSpacing:n.letterSpacing.headerBrand},docTitle:{...c(n.size.caption,t.brandInk),marginTop:r.sm+r.xs/2,letterSpacing:n.letterSpacing.eyebrow+.4},petName:a(n.size.verdict+r.xs/2,n.lineHeight.tight,t.text.primary),generated:{...c(n.size.tiny,t.text.muted),textTransform:"none"},section:{marginTop:r.lg+r.xs+r.xs/2},sectionHeader:{flexDirection:"row",alignItems:"center",gap:r.sm+r.xs/2,marginBottom:r.sm},sectionTitle:c(n.size.tiny,t.brandInk),rule:{flex:1,height:l,backgroundColor:t.borderHairlineGreen},row:{flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between",gap:r.md+r.xs/2,paddingVertical:r.sm+1},rowDivider:{borderTopWidth:l,borderTopColor:t.borderHairlineGreen},rowFlag:{backgroundColor:t.badgeBgCritical,marginHorizontal:-r.sm,paddingHorizontal:r.sm,borderRadius:o.xs},rowMain:{flexShrink:1},rowRight:{alignItems:"flex-end",gap:r.xs/2},rowLabel:{flexShrink:1,...a(n.size.body,n.lineHeight.normal,t.text.primary,"medium")},rowValue:{...a(n.size.body,n.lineHeight.normal,t.text.primary,"bold"),textAlign:"right"},rowValueAlert:{color:t.danger},rowMeta:{marginTop:r.xs/2,...S(e,"mono"),fontSize:n.size.tiny,lineHeight:n.size.body,color:t.text.muted},markerStatus:c(n.size.micro,t.text.muted),block:{paddingVertical:r.sm+r.xs/2},blockDate:{...c(n.size.tiny,t.text.muted),marginBottom:r.xs+r.xs/2},fieldRow:{flexDirection:"row",alignItems:"flex-start",gap:r.md+r.xs/2,paddingVertical:r.xs-1},fieldLabel:{width:120,...a(n.size.bodyTight,n.lineHeight.normal,t.text.muted,"medium")},fieldValue:{flex:1,...a(n.size.bodyTight,n.lineHeight.normal,t.text.primary,"medium")},noteSection:{marginTop:r.sm},noteLabel:{...c(n.size.tiny,t.brandInk),marginBottom:r.xs/2},noteBody:a(n.size.bodyTight,n.lineHeight.relaxed,t.text.primary),disclaimer:{marginTop:o.xl,paddingTop:r.md+r.xs/2,borderTopWidth:l,borderTopColor:t.borderHairlineGreen},disclaimerText:a(n.size.tiny,n.lineHeight.relaxed,t.text.muted)})}i(ph,"makeLocalStyles");function _u({petRef:e,petName:t,onClose:r,onNavigate:o,onOpenUrl:n,onCopy:l}){let a=bh(),c=Re(),s=ua(e),[d,u]=useState(null),[m,y]=useState(null),[g,w]=useState("vet"),[R,v]=useState(""),f=s.available&&!s.consentRequired,b=s.shareAudiences.length>0,C=s.shareAudiences.find(x=>x.audience===g)??null,h=C!==null?Tc(C,s.features):[],I=i((x,A)=>{let z=n??((G,ae)=>ae==="share_link"?xu(G):mi(G)),de=A==="share_link"?j.toasts.shareSheet:j.toasts.pdfShareSheet;Ar(z,x,A).then(G=>{G.ok||u(de);});},"open"),T=i(()=>{u(null),s.createLink(b?g:void 0).then(x=>{x.ok?I(x.value.shareUrl,"share_link"):u(An(x.error,"create"));});},"onCreateLink"),k=i(()=>{if(s.sending)return;u(null);let x=R.trim();if(x.length===0){u(j.addEmailFor(t));return}if(!Xn(x)){u(j.emailInvalid);return}s.sendEmail({recipientEmail:x,recipientKind:g}).then(A=>{A.ok?(v(""),u(j.toasts.sentTo(x))):u(An(A.error,"email"));});},"onSend"),_=i(()=>{u(null),s.pdfLink().then(x=>{x.ok?I(x.value.downloadUrl,"record_pdf"):u(An(x.error,"download"));});},"onDownload"),E=i(x=>{if(!l||x.shareUrl===null)return;let A=x.shareUrl;Ar(l,A).then(z=>u(z.ok?j.toasts.copiedNative:j.toasts.copyFailedNative(A)));},"onCopyRow"),B=i(x=>{s.revoke(x).then(A=>{y(null),u(A.ok?j.toasts.turnedOff:An(A.error,"revoke"));});},"onConfirmRevoke");return jsx(Modal,{transparent:true,visible:true,animationType:"slide",onRequestClose:r,children:jsxs(View,{style:a.backdrop,children:[jsx(Pressable,{style:Xo,accessibilityRole:"button",accessibilityLabel:j.closeSheetA11y,onPress:r}),jsxs(View,{style:a.sheet,accessibilityViewIsModal:true,testID:"share-record-sheet",children:[jsx(View,{style:a.handle}),jsxs(View,{style:a.header,children:[jsxs(View,{style:a.headerText,children:[jsx(p,{style:a.title,accessibilityRole:"header",children:j.titleFor(t)}),jsx(p,{style:a.helper,children:b?j.leadNative:j.helper})]}),jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:j.close,onPress:r,hitSlop:12,style:a.closeButton,testID:"share-record-close",children:jsx(p,{style:a.closeGlyph,children:"\xD7"})})]}),jsxs(ScrollView,{style:a.scroll,contentContainerStyle:a.body,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:a.actions,children:[f?jsxs(View,{style:a.form,testID:"share-email-form",children:[jsx(p,{style:a.fieldLabel,children:j.audienceLabel}),jsx(View,{style:a.choices,accessibilityRole:"radiogroup",accessibilityLabel:j.audienceLabel,children:Zr.map(x=>{let A=g===x;return jsx(Pressable,{onPress:()=>w(x),accessibilityRole:"radio",accessibilityLabel:j.audiences[x],accessibilityState:{checked:A,selected:A},style:[a.choice,A?a.choiceOn:null],testID:`share-audience-${x}`,children:jsx(p,{style:A?a.choiceTitleOn:a.choiceTitle,children:j.audiences[x]})},x)})}),b&&h.length>0?jsxs(View,{style:a.included,testID:"share-included",children:[jsx(p,{style:a.fieldLabel,children:j.included}),h.map(x=>jsxs(View,{style:a.includedRow,children:[jsx(p,{style:a.includedLine,accessibilityElementsHidden:true,importantForAccessibility:"no",children:"\u2022"}),jsx(p,{style:[a.includedLine,a.includedText],testID:`share-included-line-${x}`,children:x})]},x))]}):null,o?jsx(X,{label:j.previewNative,onPress:()=>{r(),o({name:"document"});},testID:"share-view-document"}):null,jsx(p,{style:a.fieldLabel,children:j.sendTo}),jsx(TextInput,{accessibilityLabel:j.sendTo,style:a.field,value:R,placeholder:j.sendToPlaceholder,placeholderTextColor:a.placeholder.color,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,autoComplete:"email",maxLength:wi,editable:!s.sending,returnKeyType:"send",onChangeText:v,onSubmitEditing:k,testID:"share-email-input"}),jsx(X,{label:s.sending?j.sending:j.send,busy:s.sending,onPress:k,testID:"share-email-send"})]}):o?jsx(X,{label:j.previewNative,onPress:()=>{r(),o({name:"document"});},testID:"share-view-document"}):null,f?jsx(X,{label:s.creating?j.creatingLink:j.shareLinkNative,kind:"outline",busy:s.creating,onPress:T,testID:"share-create-link"}):null,f?jsx(X,{label:s.preparingPdf?j.preparingPdf:j.downloadPdf,kind:"outline",busy:s.preparingPdf,onPress:_,testID:"share-download-pdf"}):null,f?jsx(p,{style:a.terms,testID:"share-link-terms",children:j.linkTerms}):null]}),s.consentRequired?jsxs(View,{style:a.stateCard,testID:"share-consent-off",children:[jsx(p,{style:a.stateTitle,accessibilityRole:"header",children:j.consentOffTitle}),jsx(p,{style:a.stateBody,children:j.consentOffBody}),jsx(X,{label:j.retry,kind:"outline",onPress:s.refresh,testID:"share-consent-retry"})]}):null,d?jsx(p,{style:a.notice,accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"share-notice",children:d}):null,vu(s)?jsxs(View,{style:a.section,children:[jsx(p,{style:a.sectionLabel,accessibilityRole:"header",children:j.activeLinks}),s.status==="loading"?jsx(Oc,{testID:"share-record-loading"}):s.status==="error"?jsxs(View,{style:a.stateCard,testID:"share-record-error",children:[jsx(p,{style:a.stateTitle,children:j.errorTitle}),jsx(p,{style:a.stateBody,children:j.errorBody}),jsx(X,{label:j.retry,kind:"outline",onPress:s.refresh,testID:"share-record-retry"})]}):s.rows.length===0?jsxs(View,{style:a.stateCard,testID:"share-record-empty",children:[jsx(p,{style:a.stateTitle,children:j.emptyTitle}),jsx(p,{style:a.stateBody,children:j.emptyBody})]}):jsx(View,{style:a.list,children:s.rows.map(x=>jsxs(View,{style:a.row,testID:`share-row-${x.shareId}`,children:[jsxs(View,{accessible:true,accessibilityRole:"text",accessibilityLabel:x.a11yLabel,children:[jsxs(View,{style:a.statusLine,children:[jsx(View,{style:[a.statusDot,{backgroundColor:x.active?a.active.color:a.inactive.color}],accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsx(p,{style:a.status,children:x.statusLabel}),jsx(p,{style:a.expiry,children:x.expiryLabel})]}),x.createdLabel?jsx(p,{style:a.created,children:x.createdLabel}):null]}),x.shareUrl!==null&&!l?jsx(p,{selectable:true,style:a.url,testID:`share-url-${x.shareId}`,children:x.shareUrl}):null,m===x.shareId?jsxs(View,{style:a.confirm,testID:`share-revoke-confirm-${x.shareId}`,children:[jsx(p,{style:a.confirmText,children:j.confirmTurnOff}),jsxs(View,{style:a.rowActions,children:[jsx(X,{label:s.revokingId===x.shareId?j.turningOff:j.turnOff,kind:"danger",busy:s.revokingId===x.shareId,onPress:()=>B(x.shareId),testID:`share-revoke-do-${x.shareId}`}),jsx(X,{label:j.keep,kind:"outline",disabled:s.revokingId===x.shareId,onPress:()=>y(null),testID:`share-revoke-cancel-${x.shareId}`})]})]}):jsxs(View,{style:a.rowActions,children:[l?jsx(X,{label:j.copyLink,kind:"outline",disabled:x.shareUrl===null,accessibilityLabel:j.copyLinkA11y(x.actionContext),onPress:()=>E(x),testID:`share-copy-${x.shareId}`}):null,jsx(X,{label:j.turnOff,kind:"danger",accessibilityLabel:j.turnOffA11y(x.actionContext),onPress:()=>y(x.shareId),testID:`share-ask-revoke-${x.shareId}`})]})]},x.shareId))})]}):null]}),jsx(View,{style:c.inset})]})]})})}i(_u,"ShareSheet");function bh(){let e=V();return useMemo(()=>hh(e),[e])}i(bh,"useStyles");function hh(e){let{color:t,space:r,radius:o,type:n}=e,l=r.xxl+r.md,a=StyleSheet.hairlineWidth,c=i((s,d,u,m="regular")=>({...S(e,m),fontSize:s,lineHeight:Math.round(s*d),color:u}),"text");return StyleSheet.create({active:{color:t.success},inactive:{color:t.text.muted},backdrop:{flex:1,justifyContent:"flex-end",backgroundColor:"rgba(0,0,0,0.4)"},sheet:{backgroundColor:t.surface,borderTopLeftRadius:o.xl-1,borderTopRightRadius:o.xl-1,paddingHorizontal:r.lg+r.xs+r.xs/2,paddingTop:r.md,paddingBottom:o.xl,maxHeight:"88%",gap:r.md},handle:{alignSelf:"center",width:r.xxl+r.xs,height:r.xs,borderRadius:o.pill,backgroundColor:t.borderRingCream},header:{flexDirection:"row",alignItems:"flex-start",justifyContent:"space-between",gap:r.sm},headerText:{flex:1,gap:r.xs},title:{...c(n.size.heading,n.lineHeight.snug,t.text.primary,"bold")},helper:c(n.size.bodyTight,n.lineHeight.normal,t.text.muted),terms:{...c(n.size.caption,n.lineHeight.normal,t.text.muted),textAlign:"center"},closeButton:{width:l,height:l,alignItems:"center",justifyContent:"center"},closeGlyph:c(n.size.verdict,n.lineHeight.tight,t.text.primary),scroll:{flexGrow:0},body:{gap:r.lg,paddingBottom:r.sm},actions:{gap:r.sm},form:{gap:r.sm,paddingBottom:r.sm},fieldLabel:{...c(n.size.bodyTight,n.lineHeight.normal,t.text.secondary,"medium")},choices:{flexDirection:"row",gap:r.sm},choice:{flex:1,minHeight:l,alignItems:"center",justifyContent:"center",paddingHorizontal:r.sm,borderRadius:o.md,borderWidth:a,borderColor:t.borderHairlineGreen,backgroundColor:t.surface},choiceOn:{borderWidth:1.5,borderColor:t.brandInk,backgroundColor:t.brandSoft},choiceTitle:{...c(n.size.body,n.lineHeight.snug,t.text.primary,"medium")},choiceTitleOn:{...c(n.size.body,n.lineHeight.snug,t.text.primary,"bold")},included:{gap:r.xs},includedRow:{flexDirection:"row",gap:r.sm},includedLine:c(n.size.bodyTight,n.lineHeight.normal,t.text.primary),includedText:{flex:1},field:{...c(n.size.body,n.lineHeight.normal,t.text.primary),minHeight:l,paddingHorizontal:r.md,borderRadius:o.sm,borderWidth:a,borderColor:t.borderHairlineGreen,backgroundColor:t.surface},placeholder:{color:t.text.placeholder},notice:{...c(n.size.bodyTight,n.lineHeight.normal,t.text.secondary),padding:r.md,borderRadius:o.md-r.xs/2,backgroundColor:t.brandSoft},section:{gap:r.sm},sectionLabel:{...c(n.size.bodyTight,n.lineHeight.snug,t.text.secondary,"bold"),textTransform:"uppercase",letterSpacing:n.letterSpacing.eyebrow/2},stateCard:{gap:r.sm,padding:r.md,borderRadius:o.md,backgroundColor:t.surfaceCream,borderWidth:a,borderColor:t.brandBorder},stateTitle:{...c(n.size.body,n.lineHeight.snug,t.text.primary,"bold")},stateBody:c(n.size.bodyTight,n.lineHeight.normal,t.text.muted),list:{gap:r.md},row:{gap:r.sm,padding:r.md,borderRadius:o.md,backgroundColor:t.surfaceCream,borderWidth:a,borderColor:t.brandBorder},statusLine:{flexDirection:"row",alignItems:"center",gap:r.sm},statusDot:{width:r.sm,height:r.sm,borderRadius:r.xs},status:{...c(n.size.bodyTight,n.lineHeight.snug,t.text.primary,"bold")},expiry:{...c(n.size.caption,n.lineHeight.normal,t.text.muted)},created:c(n.size.tiny,n.lineHeight.normal,t.text.muted),url:{...c(n.size.caption,n.lineHeight.normal,t.text.secondary,"mono")},rowActions:{flexDirection:"row",flexWrap:"wrap",gap:r.sm},confirm:{gap:r.sm},confirmText:{...c(n.size.bodyTight,n.lineHeight.normal,t.text.primary,"medium")}})}i(hh,"makeStyles");var wh=i((e,t)=>e.getRecordDepth(t),"readDepth"),xh=i(e=>!e.available,"depthEmpty");function ha(e){let{style:t,renderPending:r,...o}=Be(e,["onNavigate","onBack","onAsk"]);return jsx(Ue,{capability:"records",style:t,...r?{renderPending:r}:{},...$e(o.onBack,ot),children:jsx(Ch,{...o,style:t})})}i(ha,"EverfurRecordDetail");function Ch({petRef:e,petName:t,controller:r,consentVersion:o,onNavigate:n,onBack:l,onAsk:a,onOpenUrl:c,onCopy:s,style:d}){let u=Re(),m=Eh(),y=mt(r?{petRef:e,controller:r}:{petRef:e}),g=nr(e,wh,xh),w=Gs(e),R=pa(e),[v,f]=useState(false),b=useMemo(()=>Gr(o,y.consent),[o,y.consent]),C=useMemo(()=>mn(y,o),[y,o]),h=g.value!==null&&!g.value.withheld&&g.value.available?g.value:null,I=y.record,T=i(()=>{y.refresh(),g.refresh();},"retry"),k=n!==void 0||R.lit===true,_;if(y.status==="loading"||g.status==="loading"&&I!==null&&!I.isEmpty)_=jsx(Eo,{testID:"everfur-record-loading"});else if(y.status==="error"){let E=qr(y,b);_=E.kind==="error"||E.kind==="pet_not_found"?jsx(Xe,{variant:wt(E.error),message:E.error.displayMessage,onAction:E.error.retryable?T:void 0,testID:"everfur-record-error"}):pn(y,C,b);}else if(I===null||I.isEmpty){let E=h?.completeness?.documentsInReview??0;_=jsxs(ScrollView,{contentContainerStyle:u.content,testID:"everfur-record-empty",children:[jsx(Xe,{variant:"no_records",message:E>0?ne.inReview(E):void 0}),jsx(Fr,{disclaimer:I?.disclaimer??""})]});}else _=jsx(ScrollView,{contentContainerStyle:m.content,testID:"everfur-record",children:jsx(ti,{record:I,depth:h,petName:t,onNavigate:n,onAsk:a,factEdit:w})});return jsxs(View,{style:[u.root,d],children:[jsx(it,{title:ne.title,onBack:l,testID:"everfur-record-header",right:k||n?jsxs(Fragment,{children:[n?jsx(Pressable,{onPress:()=>n({name:"clinicBatch"}),accessibilityRole:"button",accessibilityLabel:ne.requestClinicsA11y,hitSlop:8,style:m.share,testID:"everfur-record-request-clinics",children:jsx(fc,{})}):null,k?jsx(Pressable,{onPress:()=>f(true),accessibilityRole:"button",accessibilityLabel:j.openA11yFor(t),hitSlop:8,style:m.share,testID:"everfur-record-share",children:jsx(yc,{})}):null]}):void 0}),jsx(View,{style:u.body,children:_}),v?jsx(_u,{petRef:e,petName:t,onClose:()=>f(false),onNavigate:n,...c?{onOpenUrl:c}:{},...s?{onCopy:s}:{}}):null,jsx(je,{})]})}i(Ch,"RecordBody");function Eh(){let e=V();return useMemo(()=>Sh(e),[e])}i(Eh,"useLocalStyles");function Sh(e){let{space:t,radius:r}=e;return StyleSheet.create({content:{paddingHorizontal:t.lg,paddingBottom:t.xxl+t.sm,gap:t.lg+t.xs},share:{width:t.xxl+t.sm,height:t.xxl+t.sm,borderRadius:r.pill,alignItems:"center",justifyContent:"center"}})}i(Sh,"makeLocalStyles");function Au(e,t){let r=V(),[o,n]=useState(false),l=useCallback(()=>{n(true),e().finally(()=>n(false));},[e]);return jsx(RefreshControl,{refreshing:o,onRefresh:l,tintColor:r.color.brandInk,colors:[r.color.brandInk],testID:t})}i(Au,"useRecordsPullToRefresh");function Ra(e){let{style:t,renderPending:r,...o}=Be(e,["onNavigate","onBack"]);return jsx(Ue,{capability:"records",style:t,...r?{renderPending:r}:{},...$e(o.onBack,ot),children:jsx(Oh,{...o,style:t})})}i(Ra,"EverfurRecordsUpload");function Oh({petRef:e,petName:t,controller:r,onPickDocument:o,onPickPhotos:n,uploadTransport:l,onNavigate:a,onBack:c,style:s}){let d=Re(),u=Fu(),{runtime:m}=Te(),y=mt(r?{petRef:e,controller:r,readUploadFeatures:true}:l?{petRef:e,uploadTransport:l,readUploadFeatures:true}:{petRef:e,readUploadFeatures:true}),g=Hn(o)&&(r!==void 0||l!==void 0||to(m.registry.services.uploadTransport));return jsxs(View,{style:[d.root,s],children:[jsx(it,{title:"",onBack:c,testID:"upload-header"}),jsxs(ScrollView,{contentContainerStyle:u.content,testID:"upload-screen",children:[jsxs(View,{style:u.header,children:[jsx(View,{style:u.iconBubble,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsx(p,{style:u.title,accessibilityRole:"header",children:Me.screenTitle}),jsx(p,{style:u.subtitle,children:Me.subtitle(t)})]}),jsx(va,{records:y,requestId:null,onPickDocument:o,onPickPhotos:n,canUpload:g,onDone:a?w=>a({name:"request",requestId:w}):void 0})]}),jsx(je,{})]})}i(Oh,"UploadBody");function va({records:e,requestId:t,onPickDocument:r,onPickPhotos:o,canUpload:n,onDone:l}){let a=Re(),c=Fu(),{runtime:s}=Te(),d=s.registry.services.camera,u=e.uploadContentTypes,m=hn(u),y=m&&zo(d),g=m&&o!==void 0,w=y||g,[R,v]=useState(null),[f,b]=useState(0),C=useRef(t),h=useRef([]),I=e.uploadQueue.filter(G=>G.status!=="skipped"),T=I.filter(G=>G.status==="done").length,k=I.filter(G=>G.status==="failed").length,_=!e.isUploading&&f>0,E=useCallback(async G=>{let{uploadable:ae,skipped:M}=gl(G,u),$=ri(M,w);if(ae.length===0){$!==null&&v($);return}v($);let O=C.current;if(O===null){let D=await e.createRequest(`records-upload-${Date.now().toString(36)}`);if(!D.ok){v(Me.errors.start);return}O=D.value.id,C.current=O;}b(D=>D+1);let U=await e.uploadDocuments(O,ae);h.current=U.flatMap((D,q)=>D.status==="failed"&&ae[q]!==void 0?[ae[q]]:[]);},[e,u,w]),B=useCallback(G=>{!G||!n||Ar(G).then(ae=>{if(!ae.ok){v(Me.errors.startPlain);return}let M=ae.value;M!==null&&E(Array.isArray(M)?M:[M]);});},[n,E]),x=useCallback(()=>{B(r);},[B,r]),A=useCallback(()=>{B(o);},[B,o]),z=useCallback(()=>{!y||!n||Ar(()=>d.capture(hd("photo"))).then(G=>{if(!G.ok)return;let ae=bd(G.value);if(ae.sizeBytes===void 0){v(Me.errors.startPlain);return}E([ae]);});},[d,y,n,E]),de=useCallback(()=>{E(h.current);},[E]);return jsxs(View,{style:c.card,testID:"records-upload-card",children:[jsx(p,{style:c.cardTitle,accessibilityRole:"header",children:Me.cardTitle}),jsx(p,{style:c.cardSubtitle,children:w?or.note:Me.cardSubtitle}),R?jsx(View,{style:a.errorBanner,accessibilityRole:"alert",children:jsx(p,{style:a.errorText,children:R})}):null,jsx(iu,{records:e}),e.isUploading?jsx(View,{style:c.uploadingRow,children:jsx(p,{style:c.progressText,children:Me.uploading(T,I.length)})}):_?jsxs(View,{style:c.settled,children:[T>0?jsx(p,{style:c.success,accessibilityRole:"alert",children:Me.received(T)}):null,k>0?jsx(X,{label:Me.retryFailed(k),kind:"link",accessibilityLabel:Me.retryFailedA11y(k),onPress:de,testID:"records-upload-retry-failed"}):null,jsx(p,{style:c.cardTitle,accessibilityRole:"header",children:Me.haveMore}),w?jsx(p,{style:c.cardSubtitle,children:or.haveMoreLead}):null,jsxs(View,{style:c.settledActions,children:[jsx(X,{label:Me.addMore,kind:"link",accessibilityLabel:Me.addMoreA11y,disabled:!n,onPress:x,testID:"records-upload-another"}),l&&C.current!==null&&T>0?jsx(X,{label:Me.done,accessibilityLabel:Me.doneA11y,onPress:()=>l(C.current),testID:"records-upload-done"}):null]})]}):w?jsxs(View,{style:c.actions,children:[y?jsxs(View,{style:c.action,children:[jsx(X,{label:or.takePhoto,kind:"outline",accessibilityLabel:Xd(or.takePhoto,or.takePhotoMeta),disabled:!n,onPress:z,testID:"records-upload-take-photo"}),jsx(p,{style:c.actionMeta,children:or.takePhotoMeta})]}):null,g?jsx(View,{style:c.action,children:jsx(X,{label:or.choosePhotos,kind:"outline",disabled:!n,onPress:A,testID:"records-upload-choose-photos"})}):null,jsxs(View,{style:c.action,children:[jsx(X,{label:Me.chooseFiles,accessibilityLabel:Me.chooseFilesA11y,disabled:!n,onPress:x,testID:"records-upload-choose"}),jsx(p,{style:c.actionMeta,children:or.chooseFileMeta})]})]}):jsx(X,{label:Me.chooseFiles,accessibilityLabel:Me.chooseFilesA11y,disabled:!n,onPress:x,testID:"records-upload-choose"})]})}i(va,"UploadRecordCard");function Fu(){let e=V();return useMemo(()=>Lh(e),[e])}i(Fu,"useLocalStyles");function Lh(e){let{color:t,space:r,radius:o,type:n}=e,l=i((a,c,s,d="regular")=>({...S(e,d),fontSize:a,lineHeight:Math.round(a*c),color:s}),"text");return StyleSheet.create({content:{padding:r.lg+r.xs,gap:r.lg+r.xs},header:{gap:r.sm,alignItems:"center"},iconBubble:{width:r.xxl+r.lg+r.xs,height:r.xxl+r.lg+r.xs,borderRadius:o.pill,backgroundColor:t.brandSoft,borderWidth:StyleSheet.hairlineWidth,borderColor:t.brandBorder,marginBottom:r.xs},title:{...l(n.size.heading+r.xs/2,n.lineHeight.snug,t.brandInk,"bold"),textAlign:"center"},subtitle:{...l(n.size.body,n.lineHeight.normal,t.text.muted),textAlign:"center",maxWidth:340},card:{borderRadius:o.lg,backgroundColor:t.surface,borderWidth:1,borderColor:t.borderRingCream,padding:r.lg,gap:r.md},cardTitle:{...l(n.size.subtitle,n.lineHeight.snug,t.text.primary,"bold")},cardSubtitle:l(n.size.bodyTight,n.lineHeight.normal,t.text.muted),uploadingRow:{flexDirection:"row",alignItems:"center",gap:r.sm},progressText:{flex:1,...l(n.size.bodyTight,n.lineHeight.normal,t.text.secondary)},settled:{gap:r.sm},success:l(n.size.bodyTight,n.lineHeight.normal,t.text.primary),settledActions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:r.sm},actions:{gap:r.md},action:{gap:r.xs},actionMeta:l(n.size.bodyTight,n.lineHeight.normal,t.text.muted)})}i(Lh,"makeLocalStyles");function xa(e){let{style:t,renderPending:r,...o}=Be(e,["onNavigate","onBack"]);return jsx(Ue,{capability:"records",style:t,...r?{renderPending:r}:{},...$e(o.onBack,ot),children:jsx(Hh,{...o,style:t})})}i(xa,"EverfurRecordsRequest");function Hh({petRef:e,petName:t,requestId:r,controller:o,onPickDocument:n,onPickPhotos:l,uploadTransport:a,onNavigate:c,onBack:s,style:d,nowMs:u}){let m=Re(),{runtime:y,userRef:g,scopeEpoch:w}=Te(),R=mt(o?{petRef:e,controller:o,readUploadFeatures:true}:a?{petRef:e,uploadTransport:a,readUploadFeatures:true}:{petRef:e,readUploadFeatures:true}),v=R.requests.find(I=>I.id===r)??null,f=Hn(n)&&(o!==void 0||a!==void 0||to(y.registry.services.uploadTransport)),b=v?Uo(v):"",C=Au(R.refresh,"records-request-refresh"),h;return R.status==="loading"&&v===null?h=jsx(So,{testID:"records-request-loading"}):R.status==="error"&&R.error?h=jsx(Xe,{variant:wt(R.error),message:R.error.displayMessage,onAction:R.error.retryable?R.refresh:void 0,testID:"records-request-error"}):v===null?h=jsx(Xe,{variant:"no_requests",testID:"records-request-missing"}):g===null?h=jsx(Xe,{variant:"error",testID:"records-request-error"}):h=jsx(Bh,{petName:t,request:v,records:R,canUpload:f,onPickDocument:n,onPickPhotos:l,onNavigate:c,nowMs:u,refreshControl:C},JSON.stringify([g,w,v.id])),jsxs(View,{style:[m.root,d],children:[jsx(it,{title:b,onBack:s,testID:"records-request-header"}),jsx(KeyboardAvoidingView,{behavior:"padding",style:m.body,children:h}),jsx(je,{})]})}i(Hh,"RequestBody");function Bh({petName:e,request:t,records:r,canUpload:o,onPickDocument:n,onPickPhotos:l,onNavigate:a,nowMs:c,refreshControl:s}){let d=Re(),u=Uh(),m=V(),y=eu({request:t,onRecovered:r.refresh,canUpload:o},Zt()),[g,w]=useState(null),[R,v]=useState(false),[f,b]=useState(null),C=useRef(true);useEffect(()=>(C.current=true,()=>{C.current=false;}),[]);let h=y.request,I=c??Date.now(),T=h.status==="published",k=h.status==="published"||h.status==="failed"||h.status==="revoked",_=Ji(h),E=h.wireStatus==="clinic_responded_no_records",B=zl(h,I),x=Xi(h,I),A=k?null:h.waitingExpectation?.trim()||null,z=jo(h),de=Nl(h),G=y.canConvert,ae=k&&!T,M=y.error!==null&&g!==null&&g!=="start"?g==="revoke"?fe.errors.cancel:fe.errors[g]:null,$=i((J,H)=>{w(J),H();},"run"),O=i(()=>{R||(v(true),b(null),r.createRequest(`records-upload-${Date.now().toString(36)}`).then(J=>{if(C.current){if(v(false),!J.ok){b(fe.errors.start);return}a?.({name:"request",requestId:J.value.id});}}));},"startFresh"),U=h.clinicName?.trim()??"",D=!ni(h)&&U.length>0,q=D&&(h.status==="requested"||h.status==="awaiting_clinic"),ee=re(h.createdAt);return jsxs(ScrollView,{contentContainerStyle:u.content,keyboardShouldPersistTaps:"handled",refreshControl:s,testID:`records-request-${h.id}`,children:[q?jsxs(View,{style:u.sent,testID:"records-request-sent",children:[jsx(p,{style:u.cardTitle,accessibilityRole:"header",children:fe.sentTitle}),jsx(p,{style:d.bodyText,children:fe.sentLeadNative(ke(e))})]}):null,jsxs(View,{style:u.card,testID:"records-request-where",children:[jsx(p,{style:u.cardTitle,accessibilityRole:"header",children:fe.whereItStands}),jsx(si,{request:h,petName:e})]}),D?jsxs(View,{style:u.card,testID:"records-request-details",children:[jsx(p,{style:u.cardTitle,accessibilityRole:"header",children:fe.details}),jsxs(View,{style:u.detailRow,children:[jsx(p,{style:d.muted,children:fe.detailsClinic}),jsx(p,{style:u.detailValue,children:U})]}),ee!=="-"?jsxs(View,{style:u.detailRow,children:[jsx(p,{style:d.muted,children:fe.detailsSent}),jsx(p,{style:u.detailValue,children:ee})]}):null]}):null,h.status==="awaiting_upload"?jsx(va,{records:r,requestId:h.id,onPickDocument:n,onPickPhotos:l,canUpload:o}):null,h.statusLabel.length>0?jsx(View,{style:d.statusCard,accessibilityRole:"summary",children:jsx(p,{style:d.statusText,children:h.statusLabel})}):null,A&&!B?jsx(View,{style:d.infoNote,accessibilityRole:"summary",children:jsx(p,{style:d.infoNoteText,children:A})}):h.wireStatus==="awaiting_response"&&!B?jsx(View,{style:d.infoNote,accessibilityRole:"summary",children:jsx(p,{style:d.infoNoteText,children:fe.awaitingNote})}):null,B?jsx(View,{style:d.cautionNote,accessibilityRole:"summary",testID:"records-request-waiting-banner",children:jsx(p,{style:d.cautionNoteText,children:fe.waitingBanner(x)})}):null,T&&a?jsx(X,{label:fe.viewRecords,onPress:()=>a({name:"dashboard"}),style:u.readyCta,testID:"records-request-view-dashboard"}):null,de?jsxs(View,{style:[u.failureCard,_?u.failureCritical:u.failureCaution],accessibilityRole:"summary",testID:"records-failure-card",children:[jsx(p,{style:[u.failureTitle,_?u.failureTitleCritical:u.failureTitleCaution],children:ql(h)}),h.canUpdateClinicEmail!==true&&h.canRetrySend!==true?jsx(p,{style:d.rowDetail,children:fe.nextStep}):null,h.canUpdateClinicEmail===true?jsxs(View,{style:u.emailBlock,children:[jsx(p,{style:d.fieldLabel,children:Wt.email}),jsx(Qe,{style:d.field,accessibilityLabel:Wt.email,placeholder:Wt.emailPlaceholder,placeholderTextColor:m.color.text.placeholder,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,maxLength:320,value:y.email,editable:!y.busy,onChangeText:y.setEmail,testID:"records-failure-clinic-email"}),y.emailInvalid?jsx(p,{style:d.errorText,accessibilityRole:"alert",children:fe.errors.invalidEmail}):null,jsx(X,{label:Wt.updateEmail,accessibilityLabel:Wt.updateEmailA11y,disabled:!y.canUpdateEmail,busy:y.busy&&g==="email",onPress:()=>$("email",y.updateEmail),testID:"records-failure-update-email"})]}):null,h.canRetrySend===true?jsx(X,{label:Wt.retry,kind:"outline",accessibilityLabel:Wt.retryA11y,disabled:!y.canRetry,busy:y.busy&&g==="retry",onPress:()=>$("retry",y.retry),testID:"records-failure-retry-send"}):null,h.canRetrySend===true&&y.hasEmailEdit?jsx(p,{style:d.rowDetail,children:Wt.retryHint}):null,M&&(g==="email"||g==="retry")?jsx(View,{style:d.errorBanner,accessibilityRole:"alert",children:jsx(p,{style:d.errorText,children:M})}):null]}):null,(_||E)&&a?jsx(X,{label:fe.tryAnotherClinic,kind:"outline",accessibilityLabel:fe.tryAnotherClinicA11y,onPress:()=>a({name:"clinicPicker"}),testID:"records-request-try-another-clinic"}):null,z!==null?jsxs(View,{style:u.callBlock,children:[jsx(su,{call:z,prompt:h.statusLabel}),h.canRetrySend===true?jsx(X,{label:y.busy&&g==="retry"?fe.resending:fe.resend,kind:"outline",accessibilityLabel:y.busy&&g==="retry"?fe.resendingA11y:fe.resendA11y,disabled:!y.canRetry,onPress:()=>$("retry",y.retry),testID:"records-resend-authorization"}):null]}):null,G?jsxs(View,{style:u.block,children:[jsx(X,{label:y.busy&&g==="convert"?fe.converting:fe.convert,busy:y.busy&&g==="convert",onPress:()=>$("convert",y.convert),testID:"records-convert-upload"}),jsx(p,{style:d.muted,children:fe.convertHint}),M&&g==="convert"?jsx(View,{style:d.errorBanner,accessibilityRole:"alert",children:jsx(p,{style:d.errorText,children:M})}):null]}):null,ae?jsxs(View,{style:u.block,children:[jsx(X,{label:R?fe.freshUploadStarting:fe.freshUpload,kind:_||E?"outline":"primary",busy:R,onPress:O,testID:"records-upload-own-fresh"}),f?jsx(View,{style:d.errorBanner,accessibilityRole:"alert",children:jsx(p,{style:d.errorText,children:f})}):null]}):null,M&&g==="revoke"?jsx(View,{style:d.errorBanner,accessibilityRole:"alert",children:jsx(p,{style:d.errorText,children:M})}):null,h.canRevoke===true?y.confirmingRevoke?jsxs(View,{style:u.block,testID:"records-revoke-confirm",children:[jsx(p,{style:u.confirmTitle,accessibilityRole:"header",children:Wt.cancelQuestion}),jsx(p,{style:d.bodyText,children:Wt.cancelConsequence}),jsx(X,{label:y.busy&&g==="revoke"?fe.cancelling:fe.cancel,kind:"danger",accessibilityLabel:y.busy&&g==="revoke"?fe.cancellingA11y:fe.cancelA11y,busy:y.busy&&g==="revoke",onPress:()=>$("revoke",y.revoke),testID:"records-revoke-do"}),jsx(X,{label:Wt.keepRequest,kind:"outline",disabled:y.busy,onPress:y.keepRequest,testID:"records-revoke-keep"})]}):jsx(X,{label:fe.cancel,kind:"danger",accessibilityLabel:fe.cancelA11y,disabled:y.busy,onPress:y.askRevoke,testID:"records-revoke"}):null]})}i(Bh,"RequestDetail");function Uh(){let e=V();return useMemo(()=>jh(e),[e])}i(Uh,"useLocalStyles");function jh(e){let{color:t,space:r,radius:o,type:n}=e,l=i((a,c,s,d="regular")=>({...S(e,d),fontSize:a,lineHeight:Math.round(a*c),color:s}),"text");return StyleSheet.create({content:{paddingHorizontal:r.lg,paddingBottom:r.xxl,gap:r.lg+r.xs/2},readyCta:{minHeight:r.xxl+r.lg+r.xs/2},sent:{gap:r.xs},card:{borderRadius:o.lg,borderWidth:1,borderColor:t.borderRingCream,backgroundColor:t.surface,padding:r.lg,gap:r.md},cardTitle:{...l(n.size.subtitle,n.lineHeight.snug,t.brandInk,"bold"),letterSpacing:-0.4},detailRow:{flexDirection:"row",alignItems:"baseline",justifyContent:"space-between",gap:r.lg},detailValue:{flexShrink:1,textAlign:"right",...l(n.size.body,n.lineHeight.normal,t.text.primary)},failureCard:{borderRadius:o.lg-r.xs,borderWidth:1,padding:r.md+r.xs/2,gap:r.md},failureCritical:{borderColor:t.badgeBgCritical,backgroundColor:t.badgeBgCritical},failureCaution:{borderColor:t.badgeBgCaution,backgroundColor:t.badgeBgCaution},failureTitle:{...l(n.size.body,n.lineHeight.snug,t.text.primary,"bold")},failureTitleCritical:{color:t.danger},failureTitleCaution:{color:t.warningStrong},emailBlock:{gap:r.sm},callBlock:{gap:r.sm},block:{gap:r.sm},confirmTitle:{...l(n.size.subtitle,n.lineHeight.snug,t.text.primary,"bold")}})}i(jh,"makeLocalStyles");function qu(e){let{petRef:t,petName:r,controller:o,clinicController:n,onPickDocument:l,onPickPhotos:a,uploadTransport:c,consentVersion:s,ownerName:d,onCaptureSignature:u,initialScreen:m,onExit:y,style:g,renderPending:w,onOpenUrl:R,onCopy:v,onAsk:f,location:b}=Be(e,["onExit"]),[C,h]=useReducer(Bi,m,ao),I=lo(C),T=C.stack.length;useEffect(()=>{let z=i(()=>T<=1?false:(h({type:"pop"}),true),"onBackPress"),de=BackHandler.addEventListener("hardwareBackPress",z);return ()=>{de.remove();}},[T]);let k=useCallback(z=>h({type:"navigate",screen:z}),[]),_=useMemo(()=>co(C).handled?()=>h({type:"pop"}):y,[C,y]),E={onNavigate:k,..._?{onBack:_}:{},...r!==void 0?{petName:r}:{},...R?{onOpenUrl:R}:{},...v?{onCopy:v}:{},...f?{onAsk:f}:{},...b?{location:b}:{}},B={...o?{controller:o}:{},...s!==void 0?{consentVersion:s}:{}},x={...l?{onPickDocument:l}:{},...a?{onPickPhotos:a}:{},...c?{uploadTransport:c}:{}},A=w?{renderPending:w}:{};switch(I.name){case "dashboard":return jsx(ca,{petRef:t,...E,...B,...A,style:g});case "request":return jsx(xa,{petRef:t,requestId:I.requestId,...E,...B,...x,...A,style:g});case "timeline":return jsx(gu,{petRef:t,...E,style:g});case "record":return jsx(ha,{petRef:t,...E,...B,...A,style:g});case "document":return jsx(ya,{petRef:t,...E,...B,...A,style:g});case "contributions":return jsx(bu,{petRef:t,docId:I.docId,...E,style:g});case "clinicPicker":return jsx(ys,{petRef:t,...E,...n?{controller:n}:{},...o?{recordsController:o}:{},style:g});case "clinicBatch":return jsx(Is,{petRef:t,petName:r??"",ownerName:d??"",..._?{onClose:_}:{},onCreated:()=>h({type:"navigate",screen:{name:"dashboard"}}),...u?{onCaptureSignature:u}:{},...n?{controller:n}:{},style:g});case "consent":return jsx(Ns,{petRef:t,clinic:I.clinic,...E,...d!==void 0?{ownerName:d}:{},...u?{onCaptureSignature:u}:{},...n?{controller:n}:{},style:g});case "upload":return jsx(Ra,{petRef:t,...E,...o?{controller:o}:{},...x,...A,style:g});case "requests":return jsx(sa,{petRef:t,...E,...o?{controller:o}:{},...A,style:g});default:return Ir(I)}}i(qu,"EverfurRecordsFlow");var Qh=qu;function eR(e){let{userRef:t,scopeEpoch:r}=Te();return jsx(Ue,{capability:"recordsClinic",...$e(e.onClose,Z.cancel),children:t===null?jsx(p,{accessibilityRole:"alert",children:ve.sessionRequired}):jsx(tR,{...Be(e,["onClose","onCreated"])},JSON.stringify([t,r,e.petRef,e.petName]))})}i(eR,"EverfurClinicRequest");function tR(e){let t=Zt(),[r,o]=useState(null),n=useCallback(async()=>r===null?null:{signaturePngBase64:r},[r]),l=Vc(e,e.controller??t,e.onCaptureSignature??n),a=e.onCaptureSignature!==void 0||r!==null,c=V(),s={minHeight:44,padding:c.space.sm,borderWidth:1,borderColor:c.color.borderHairlineGreen,borderRadius:c.radius.sm,color:c.color.text.primary,backgroundColor:c.color.surface},d={color:c.color.text.primary,fontSize:c.type.size.body},u=i((m,y,g=false)=>jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:m,accessibilityState:{disabled:g},disabled:g,onPress:y,style:[s,{justifyContent:"center",opacity:g?.5:1}],children:jsx(p,{style:d,children:m})}),"button");return jsxs(View,{accessibilityLabel:Z.title,style:[{backgroundColor:c.color.surface,padding:c.space.lg,gap:c.space.md,borderRadius:c.radius.lg,minHeight:120},e.style],children:[jsx(p,{accessibilityRole:"header",style:[d,{...S(c,"bold"),fontSize:c.type.size.heading}],children:Z.title}),jsx(p,{style:d,children:e.petName}),l.created?jsx(p,{accessibilityLiveRegion:"polite",style:d,children:l.created.statusLabel||ve.records}):jsxs(Fragment,{children:[jsx(p,{style:d,children:Z.ownerName}),jsx(Qe,{accessibilityLabel:Z.ownerName,style:s,value:l.ownerName,maxLength:200,editable:!l.busy,autoComplete:"name",onChangeText:l.setOwnerName}),jsx(p,{style:d,children:Z.clinic}),jsx(Qe,{accessibilityLabel:Z.clinic,style:s,value:l.query,placeholder:Z.placeholder,placeholderTextColor:c.color.text.placeholder,maxLength:200,editable:!l.busy,onChangeText:l.setQuery}),u(Z.search,()=>{l.search();},l.busy||l.searching||l.query.trim().length<2),l.searching&&jsx(p,{accessibilityLiveRegion:"polite",style:d,children:ve.loading}),l.recent.length>0&&jsx(p,{accessibilityRole:"header",style:d,testID:"records-clinic-recent-label",children:Z.recentlyUsed}),l.recent.map(m=>jsx(View,{children:u([m.name,m.address,m.phone].filter(Boolean).join(", "),()=>l.selectClinic(m),l.busy)},`recent-${m.id}`)),l.visibleClinics.map(m=>jsx(View,{children:u([m.name,m.address,m.phone].filter(Boolean).join(", "),()=>l.selectClinic(m),l.busy)},m.id)),l.hasMoreClinics&&u(Z.moreClinics,l.showMoreClinics,l.busy),l.needsEmail&&jsxs(Fragment,{children:[jsx(p,{style:d,children:Z.email}),jsx(Qe,{accessibilityLabel:Z.email,style:s,value:l.email,placeholder:Z.emailPlaceholder,placeholderTextColor:c.color.text.placeholder,maxLength:320,editable:!l.busy,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,onChangeText:l.setEmail})]}),jsx(p,{accessibilityRole:"header",style:d,children:Z.scopeHeading}),l.copy?jsx(p,{style:d,children:l.query.trim()&&l.ownerName.trim()?l.scope??W("internalError").displayMessage:ve.consentRequired}):!l.error&&jsx(p,{accessibilityLiveRegion:"polite",style:d,children:ve.loading}),!e.onCaptureSignature&&jsx($r,{onChange:o,disabled:l.busy}),!a&&l.ready&&jsx(p,{accessibilityRole:"alert",style:d,children:Z.missingSignature}),l.error&&jsx(p,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:d,children:l.error.displayMessage}),!l.copy&&l.error&&u(ve.retry,l.retryCopy),u(l.busy?Z.sending:Z.send,()=>{l.submit();},l.busy||!l.ready||!a)]}),e.onClose&&u(Z.cancel,e.onClose,l.busy),jsx(je,{})]})}i(tR,"ClinicRequestBody");
4
+ export{ys as EverfurClinicPicker,eR as EverfurClinicRequest,Is as EverfurClinicRequestBatch,ha as EverfurRecordDetail,ya as EverfurRecordDocument,Qh as EverfurRecords,Ns as EverfurRecordsConsent,ca as EverfurRecordsDashboard,qu as EverfurRecordsFlow,xa as EverfurRecordsRequest,sa as EverfurRecordsRequests,Ra as EverfurRecordsUpload,tn as RECORDS_CLINIC_BATCH_MAX,Xa as RECORDS_TERMINAL,dn as REQUEST_TIMELINE_TITLES,$r as SignaturePad,hn as acceptsPhotos,Ws as applyFactOverlay,ta as buildRequestTimeline,lo as currentRecordsScreen,Ki as deriveRecordsDashboardState,ao as initialRecordsNav,Yo as isFactEditable,kr as isTerminalStatus,mo as pickPetRecordsRequest,co as popRecordsNav,Ni as pushRecordsNav,_r as recordsDenialReasonOf,Bi as recordsNavReducer,bs as registerRnSignature,Mi as replaceRecordsNav,Hi as resetRecordsNav,jo as selectClinicCall,Qi as selectDashboardView,Yr as selectPrimaryLabel,Us as selectRequestList,Uo as selectRequestTitle,Rl as transitionRecordsNav,mt as useEverfurRecords,Zt as useEverfurRecordsClinic,ts as useEverfurRecordsClinicBatch,Gs as useRecordFactEdit,ma as useRecordPdfLink,ua as useRecordShares,Fs as useRecordsMarkers};