@everfur/sdk 0.5.9 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +66 -0
- package/dist/{Chat-WmdRwC3b.d.cts → Chat-BoAvCWhI.d.cts} +3 -3
- package/dist/{Chat-C9dVhnyt.d.ts → Chat-CHqcgMyw.d.ts} +3 -3
- package/dist/{DepthViews-CBoI9EYy.d.ts → DepthViews-7Y8Ur058.d.ts} +1 -1
- package/dist/{DepthViews-NPFtO5Kz.d.cts → DepthViews-B0g83e_N.d.cts} +1 -1
- package/dist/{DepthViews-DoODlUnQ.d.cts → DepthViews-CT5mQld9.d.cts} +1 -1
- package/dist/{DepthViews-CmxhM8iP.d.ts → DepthViews-Dg2bIon_.d.ts} +1 -1
- package/dist/animations/index.cjs +1 -1
- package/dist/animations/index.d.cts +3 -3
- package/dist/animations/index.d.ts +3 -3
- package/dist/animations/index.js +1 -1
- package/dist/{attachments-OaW36D0H.d.cts → attachments-C3HJNYQ7.d.cts} +2 -2
- package/dist/{attachments-CuFT1o5q.d.ts → attachments-CThFsH4b.d.ts} +5 -5
- package/dist/{attachments-R2oajKPT.d.ts → attachments-CfxsVg7W.d.ts} +2 -2
- package/dist/{attachments-c4mJcIWU.d.cts → attachments-rkox0ewd.d.cts} +5 -5
- package/dist/{bookingCopy-DGQPrisa.d.cts → bookingCopy-Do3zMeXb.d.cts} +2 -2
- package/dist/{bookingCopy-EtPJ4nME.d.ts → bookingCopy-Y3OGdoMT.d.ts} +2 -2
- package/dist/{branding-Ry0em51L.d.ts → branding-ChXm8gxI.d.cts} +135 -3
- package/dist/{branding-DiaCIJZL.d.cts → branding-DYWma2il.d.ts} +135 -3
- package/dist/{casesRepository-Cu8h8gQK.d.ts → casesRepository-BbgXYPxa.d.ts} +1 -1
- package/dist/{casesRepository-DB5c8AAo.d.cts → casesRepository-Jj6t60AY.d.cts} +1 -1
- package/dist/chat/index.cjs +1 -1
- package/dist/chat/index.d.cts +9 -9
- package/dist/chat/index.d.ts +9 -9
- package/dist/chat/index.js +1 -1
- package/dist/client/index.cjs +6 -6
- package/dist/client/index.d.cts +10 -10
- package/dist/client/index.d.ts +10 -10
- package/dist/client/index.js +6 -6
- package/dist/{config-DQFMkaTU.d.cts → config-BZX97FmW.d.cts} +1 -1
- package/dist/{config-DlR_I-0S.d.ts → config-Dfbj5mlx.d.ts} +1 -1
- package/dist/consent/index.cjs +1 -1
- package/dist/consent/index.d.cts +5 -5
- package/dist/consent/index.d.ts +5 -5
- package/dist/consent/index.js +1 -1
- package/dist/{context-CLuquPRB.d.ts → context-Cbe0zYym.d.ts} +7 -7
- package/dist/{context-DZEieVJ5.d.cts → context-DJXnZ1Mx.d.cts} +7 -7
- package/dist/{copy-ptTCT5-J.d.ts → copy-DHekqSKE.d.ts} +2 -2
- package/dist/{copy-B2DOzSSy.d.cts → copy-dKK5KoAQ.d.cts} +2 -2
- package/dist/core/index.cjs +9 -9
- package/dist/core/index.d.cts +15 -15
- package/dist/core/index.d.ts +15 -15
- package/dist/core/index.js +9 -9
- package/dist/{depth-CtyC7HOF.d.ts → depth-CrpRjWGB.d.ts} +2 -2
- package/dist/{depth-DuOyvthD.d.cts → depth-NmWSbvfi.d.cts} +2 -2
- package/dist/{entitlementRepository-DlGwxZ1k.d.cts → entitlementRepository-iL-9vS1i.d.cts} +3 -3
- package/dist/{entitlementRepository-CAtyh8Xt.d.ts → entitlementRepository-tVNazi8R.d.ts} +3 -3
- package/dist/{identity-D_NR9ucT.d.ts → identity-B8rp0L9G.d.ts} +1 -1
- package/dist/{identity-BC9AF3y4.d.cts → identity-D7PO5s9m.d.cts} +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +16 -16
- package/dist/index.d.ts +16 -16
- package/dist/index.js +6 -6
- package/dist/notifications/index.d.cts +2 -2
- package/dist/notifications/index.d.ts +2 -2
- package/dist/{pets-DuuNvKTK.d.ts → pets-BQbXmICf.d.ts} +1 -1
- package/dist/{pets-D7UjvR1A.d.cts → pets-BWx9BKea.d.cts} +1 -1
- package/dist/{petsRepository-C28NKFwy.d.ts → petsRepository-0oBVydl6.d.ts} +1 -1
- package/dist/{petsRepository-llMvpMkp.d.cts → petsRepository-SqIvEMiT.d.cts} +1 -1
- package/dist/photo/index.cjs +1 -1
- package/dist/photo/index.js +1 -1
- package/dist/{ports-Dbw2h_M1.d.cts → ports-ChnzSy4E.d.cts} +4 -4
- package/dist/{ports-s45HNNyc.d.ts → ports-iXPWd7Vt.d.ts} +4 -4
- package/dist/records/depth/index.cjs +1 -1
- package/dist/records/depth/index.d.cts +7 -7
- package/dist/records/depth/index.d.ts +7 -7
- package/dist/records/depth/index.js +1 -1
- package/dist/records/index.cjs +2 -2
- package/dist/records/index.d.cts +9 -9
- package/dist/records/index.d.ts +9 -9
- package/dist/records/index.js +2 -2
- package/dist/{requestFunnel-CqwOiZNJ.d.ts → requestFunnel-CQzz2DIW.d.ts} +2 -2
- package/dist/{requestFunnel-D_o7se38.d.cts → requestFunnel-DAwb7haa.d.cts} +2 -2
- package/dist/{runtimeTypes-DS0RLoKN.d.ts → runtimeTypes-BNOxfmfg.d.ts} +5 -5
- package/dist/{runtimeTypes-BNBENMkz.d.cts → runtimeTypes-DB9-kigO.d.cts} +5 -5
- package/dist/server/events/index.cjs +1 -1
- package/dist/server/events/index.d.cts +2 -2
- package/dist/server/events/index.d.ts +2 -2
- package/dist/server/events/index.js +1 -1
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.d.cts +3 -3
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +1 -1
- package/dist/televet/booking/index.cjs +1 -1
- package/dist/televet/booking/index.d.cts +6 -6
- package/dist/televet/booking/index.d.ts +6 -6
- package/dist/televet/booking/index.js +1 -1
- package/dist/televet/call/index.cjs +1 -1
- package/dist/televet/call/index.js +1 -1
- package/dist/televet/index.cjs +1 -1
- package/dist/televet/index.js +1 -1
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/rn/index.cjs +1 -1
- package/dist/testing/rn/index.d.cts +9 -9
- package/dist/testing/rn/index.d.ts +9 -9
- package/dist/testing/rn/index.js +1 -1
- package/dist/testing/web/index.d.cts +9 -9
- package/dist/testing/web/index.d.ts +9 -9
- package/dist/{timelineRows-B6nCq30k.d.cts → timelineRows-BuNhzDbH.d.cts} +1 -1
- package/dist/{timelineRows-DacfDpDU.d.ts → timelineRows-Dll2IGFg.d.ts} +1 -1
- package/dist/{tokens-DOTIxrws.d.cts → tokens-ARWZtMOU.d.cts} +6 -1
- package/dist/{tokens-DOTIxrws.d.ts → tokens-ARWZtMOU.d.ts} +6 -1
- package/dist/{typeStyle-DROhJNkh.d.ts → typeStyle-8iEqQmP_.d.ts} +2 -2
- package/dist/{typeStyle-achxqQ-h.d.cts → typeStyle-YCS8dt19.d.cts} +2 -2
- package/dist/{useRecordsDepth-BLK8W646.d.cts → useRecordsDepth-CNEHZJtj.d.cts} +1 -1
- package/dist/{useRecordsDepth-C7guUoLc.d.ts → useRecordsDepth-CuNdne6E.d.ts} +1 -1
- package/dist/video/index.cjs +1 -1
- package/dist/video/index.js +1 -1
- package/dist/{view-BF9oW2GJ.d.cts → view-BhqWlYrZ.d.cts} +2 -2
- package/dist/{view-B6JsD22K.d.ts → view-DFy8EDwf.d.ts} +2 -2
- package/dist/web/consent/index.cjs +1 -1
- package/dist/web/consent/index.d.cts +5 -5
- package/dist/web/consent/index.d.ts +5 -5
- package/dist/web/consent/index.js +1 -1
- package/dist/web/index.cjs +7 -7
- package/dist/web/index.d.cts +19 -19
- package/dist/web/index.d.ts +19 -19
- package/dist/web/index.js +7 -7
- package/dist/web/notifications/index.d.cts +3 -3
- package/dist/web/notifications/index.d.ts +3 -3
- package/dist/web/records/depth/index.cjs +1 -1
- package/dist/web/records/depth/index.d.cts +7 -7
- package/dist/web/records/depth/index.d.ts +7 -7
- package/dist/web/records/depth/index.js +1 -1
- package/dist/web/records/index.cjs +3 -3
- package/dist/web/records/index.d.cts +9 -9
- package/dist/web/records/index.d.ts +9 -9
- package/dist/web/records/index.js +3 -3
- package/dist/web/televet/booking/index.cjs +2 -2
- package/dist/web/televet/booking/index.d.cts +7 -7
- package/dist/web/televet/booking/index.d.ts +7 -7
- package/dist/web/televet/booking/index.js +2 -2
- package/dist/web/televet/call/index.cjs +1 -1
- package/dist/web/televet/call/index.js +1 -1
- package/dist/web/televet/index.cjs +3 -3
- package/dist/web/televet/index.js +3 -3
- package/package.json +1 -1
package/dist/records/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var react=require('react'),zod=require('zod'),reactNative=require('react-native'),jsxRuntime=require('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=zod.z.object({request_id:zod.z.string().min(1),pet_ref:zod.z.string().min(1),status:zod.z.string(),simple_status:zod.z.string().nullish(),simple_status_detail:zod.z.string().nullish(),status_label:zod.z.string().optional(),dispatch_status:zod.z.string().nullish(),can_retry_send:zod.z.boolean().optional(),can_revoke:zod.z.boolean().optional(),can_convert_to_upload:zod.z.boolean().optional(),can_update_clinic_email:zod.z.boolean().optional(),reminder_count:zod.z.number().int().nonnegative().optional(),last_reminder_at:zod.z.string().nullish(),waiting_expectation:zod.z.string().nullish(),document_count:zod.z.number().optional(),held_item_count:zod.z.number().optional(),received_at:zod.z.string().nullish(),parsing_started_at:zod.z.string().nullish(),review_started_at:zod.z.string().nullish(),created_at:zod.z.string().optional(),updated_at:zod.z.string().optional(),source:zod.z.string().nullish().catch(null),action_needed_label:zod.z.string().nullish().catch(null),failure_reason:zod.z.string().nullish().catch(null),failure_code:zod.z.string().nullish().catch(null),recovery_stage:zod.z.string().nullish().catch(null),show_clinic_phone:zod.z.boolean().optional().catch(void 0),clinic_name:zod.z.string().nullish().catch(null),clinic_email:zod.z.string().nullish().catch(null),clinic_phone:zod.z.string().nullish().catch(null),converted_to_upload_at:zod.z.string().nullish().catch(null),request_group_id:zod.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=zod.z.object({request_group_id:zod.z.string().min(1),pet_ref:zod.z.string().min(1),total:zod.z.number().int().nonnegative(),responded:zod.z.number().int().nonnegative(),pending:zod.z.number().int().nonnegative(),members:zod.z.array(zod.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=zod.z.object({source_doc_id:zod.z.string().min(1),request_id:zod.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=zod.z.object({label:zod.z.string(),value:zod.z.string()}),ni=zod.z.object({key:zod.z.string(),category:zod.z.string().optional(),label:zod.z.string().optional(),value:zod.z.string().nullish(),unit:zod.z.string().nullish(),observed_at:zod.z.string().nullish(),status:zod.z.string().nullish(),origin:zod.z.string().nullish(),canonical_key:zod.z.string().nullish()}),_u=zod.z.object({at:zod.z.string(),value:zod.z.number().nullish(),display:zod.z.string().nullish(),origin:zod.z.string().nullish()}),Pu=zod.z.object({key:zod.z.string(),label:zod.z.string().optional(),points:zod.z.array(_u).optional()}),Iu=zod.z.object({title:zod.z.string(),detail:zod.z.string().nullish(),due_at:zod.z.string().nullish()}),oi=zod.z.object({doc_id:zod.z.string(),title:zod.z.string().nullish(),page_count:zod.z.number().nullish(),received_at:zod.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=zod.z.object({identity:zod.z.array(Tu).optional(),entities:zod.z.array(ni).optional(),entity_series:zod.z.array(Pu).optional(),forward_looking:zod.z.array(Iu).optional(),documents:zod.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=zod.z.object({pet_ref:zod.z.string().optional(),granted:zod.z.boolean().optional(),version:zod.z.string().nullish(),granted_at:zod.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]=react.createContext(null));Va.displayName??="EverfurContext";function Te(){let e=react.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=react.useCallback(()=>Cp(e),[e]);return react.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=react.useRef(e.uploadTransport);r.current=e.uploadTransport;let o=e.uploadTransport!==void 0,{runtime:n,userRef:a,scopeEpoch:l}=Te(),c=react.useMemo(()=>({}),[n,a,t,l,e.controller]),s=react.useRef(c),[d,u]=react.useState({scope:c,controller:e.controller??null}),p=e.controller??(d.scope===c?d.controller:null),[f,b]=react.useState({scope:c,value:fi}),R=f.scope===c?f.value:fi,v=react.useCallback(T=>{b(D=>D.scope===c?{scope:c,value:T(D.value)}:D);},[c]),w=react.useRef(0);react.useEffect(()=>(s.current=c,b({scope:c,value:fi}),()=>{s.current=null,w.current+=1;}),[c]),react.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=react.useCallback(T=>{v(D=>({...D,...T}));},[v]),y=react.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]);react.useEffect(()=>(y(),()=>{w.current+=1;}),[y]);let x=react.useMemo(()=>_p(R.requests),[R.requests]),h=x?.id??null,P=x?.status??null,S=react.useRef(0),E=react.useRef(null),[C,I]=react.useReducer(T=>T+1,0);react.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=react.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=react.useCallback((T,D)=>{v(L=>({...L,uploadQueue:L.uploadQueue.map(B=>B.key===T?D(B):B)}));},[v]),j=react.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]),$=react.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=react.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=react.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=react.useCallback(()=>y(),[y]),ie=Tp(R,p!==null);return react.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",errorRed:"#FF1B00",warningStrong:"#A45610",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.12)",badgeBgCaution:"rgba(217,130,29,0.14)",badgeBgCritical:"rgba(185,28,28,0.12)",badgeBgNeutral:"rgba(110,102,96,0.12)",bubbleUser:"#10462E",bubbleAssistant:"#FFFFFF",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",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]=react.createContext(Qa));Ei.displayName??="EverfurThemeContext";function V(){return react.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 react.createElement(reactNative.Text,o===void 0?t:{maxFontSizeMultiplier:o,...t})}i(m,"Text");var He=react.forwardRef(i(function(t,r){return react.createElement(reactNative.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]=react.useState(""),[n,a]=react.useState(""),[l,c]=react.useState([]),[s,d]=react.useState(null),[u,p]=react.useState([]),[f,b]=react.useState(true),[R,v]=react.useState(false),[w,g]=react.useState(false),[y,x]=react.useState(null),[h,P]=react.useState(null),[S,E]=react.useState(0),C=react.useRef(0),I=react.useRef(true),F=t?.latitude,q=t?.longitude,j=react.useMemo(()=>F!==void 0&&q!==void 0?{latitude:F,longitude:q}:void 0,[F,q]);react.useEffect(()=>(I.current=true,()=>{I.current=false,C.current+=1;}),[e]),react.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]),react.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;react.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=react.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=react.useCallback(ie=>o(ie),[]),ve=react.useCallback(()=>E(ie=>ie+1),[]);return react.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=zod.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)=>zod.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=zod.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:zod.z.string().min(1).max(2*1024*1024).optional(),idempotencyKey:zod.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=zod.z.object({petRef:fn(128),ownerName:fn(200).refine(e=>e.trim().length>0&&!pl(e)),authorizationVersion:fn(64),clinics:zod.z.array(Jp).min(1).max(Gr)}).strict(),em=zod.z.object({request_group_id:oo,pet_ref:zod.z.string(),created_count:zod.z.number().int().nonnegative(),failed_count:zod.z.number().int().nonnegative(),results:zod.z.array(zod.z.object({idempotency_key:zod.z.string(),clinic_id:oo.nullable().optional(),clinic_free_text:zod.z.string().nullable().optional(),created:zod.z.boolean(),request:zod.z.unknown().optional(),failure_code:zod.z.string().nullable().optional(),failure_reason:zod.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=zod.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=zod.z.object({clinics:zod.z.array(zod.z.object({clinic_id:yl,name:zod.z.string().min(1),address:zod.z.string().nullable(),phone:zod.z.string().nullable(),email_status:zod.z.string(),distance_km:zod.z.number().finite().nonnegative().nullable()})),next_cursor:zod.z.string().nullable().optional()}),rm=zod.z.object({authorization_version:zod.z.string().min(1),scope_template:zod.z.string().min(1),authorization_template:zod.z.string().min(1)}),nm=zod.z.object({upload_id:zod.z.string().min(1),upload_url:zod.z.string().url().refine(e=>e.startsWith("https://")),upload_fields:zod.z.record(zod.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=zod.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=zod.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)=>zod.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=zod.z.object({limit:zod.z.number().int().min(1).max(25).optional()}).strict(),im=zod.z.object({query:Sr(200,0).optional(),location:zod.z.object({latitude:zod.z.number().finite().min(-90).max(90),longitude:zod.z.number().finite().min(-180).max(180)}).strict().optional(),limit:zod.z.number().int().min(1).max(100).optional(),cursor:Sr(512,0).optional()}).strict(),sm=zod.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:zod.z.string().min(1).max(2*1024*1024).optional(),idempotencyKey:zod.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=react.useMemo(()=>{let{services:a}=e.registry;return fl({repository:vl({auth:a.authFor(t),...a.errorPolicy?{errorPolicy:a.errorPolicy}:{}})})},[e,t,r]),n=react.useRef(o);return react.useEffect(()=>(n.current=o,()=>{n.current=null;}),[o]),react.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=react.useMemo(()=>{let{services:a}=e.registry;return ml({auth:a.authFor(t),...a.errorPolicy?{errorPolicy:a.errorPolicy}:{}})},[e,t,r]),n=react.useRef(o);return react.useEffect(()=>(n.current=o,()=>{n.current=null;}),[o]),react.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 react.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 react.createElement(Oi,{fallback:t,resetKey:r,children:react.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=react.useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot);return react.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=react.useMemo(()=>gm(l),[l]);switch(c){case "enabled":return r;case "pending":return n?jsxRuntime.jsx(Li,{render:n,fallback:jsxRuntime.jsx(kl,{capability:t,style:a})}):jsxRuntime.jsx(kl,{capability:t,style:a});case "disabled":return o?jsxRuntime.jsx(Li,{render:()=>o(l),fallback:jsxRuntime.jsx(Tl,{decision:l,style:a}),resetKey:l}):jsxRuntime.jsx(Tl,{decision:l,style:a});default:return vr(c)}}i(Ve,"CapabilityGate");function kl({capability:e,style:t}){let r=V(),o=react.useMemo(()=>_l(r),[r]);return jsxRuntime.jsx(reactNative.View,{style:[o.offstate,t],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${e}`,children:jsxRuntime.jsx(reactNative.View,{style:o.skeletonBar})})}i(kl,"PendingSkeleton");function Tl({decision:e,style:t}){let r=V(),o=react.useMemo(()=>_l(r),[r]),n=e.disabled?.reason??"";return jsxRuntime.jsx(reactNative.View,{style:[o.offstate,t],accessible:true,accessibilityRole:"text",accessibilityLabel:n,children:n.length>0?jsxRuntime.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 reactNative.StyleSheet.create({offstate:{minHeight:fm,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:o.md,borderWidth:reactNative.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=react.useMemo(()=>Rm(t),[t]);return jsxRuntime.jsxs(reactNative.View,{style:[r.container,e.style],accessible:true,accessibilityRole:"text",accessibilityLabel:`${bn.title}. ${bn.body}`,children:[jsxRuntime.jsx(m,{style:r.title,children:bn.title}),jsxRuntime.jsx(m,{style:r.body,children:bn.body})]})}i(qe,"ClinicalDisclaimer");function Rm(e){let{color:t,space:r,type:o}=e;return reactNative.StyleSheet.create({container:{paddingHorizontal:r.lg,paddingVertical:r.md,borderTopWidth:reactNative.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]=react.useState(e==="rate_limited"?Ni:0);react.useEffect(()=>{e==="rate_limited"&&c(Ni);},[e]),react.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 jsxRuntime.jsxs(reactNative.View,{style:n.container,accessibilityRole:"summary",testID:o,children:[jsxRuntime.jsx(reactNative.View,{style:n.glyph,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxRuntime.jsx(m,{style:n.title,children:a.title}),jsxRuntime.jsx(m,{style:n.body,children:r??a.body}),d!==null&&t?jsxRuntime.jsx(reactNative.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:jsxRuntime.jsx(m,{style:n.actionLabel,children:d})}):null]})}i(Ue,"RecordsEmptyState");function Em(){let e=V();return react.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 reactNative.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:reactNative.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 jsxRuntime.jsxs(reactNative.View,{style:a.row,testID:o,children:[t?jsxRuntime.jsx(reactNative.Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:Ye,hitSlop:12,style:a.back,testID:o?`${o}-back`:void 0,children:jsxRuntime.jsx(reactNative.View,{style:a.chevron,accessibilityElementsHidden:true,importantForAccessibility:"no"})}):jsxRuntime.jsx(reactNative.View,{style:a.back}),jsxRuntime.jsx(m,{style:n==="document"?a.documentTitle:a.title,accessibilityRole:"header",numberOfLines:1,children:e}),jsxRuntime.jsx(reactNative.View,{style:a.right,children:r??jsxRuntime.jsx(reactNative.View,{style:a.back})})]})}i(Ke,"ScreenHeader");function zl(){let e=Rn();return jsxRuntime.jsxs(reactNative.View,{style:e.listGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:[jsxRuntime.jsx(reactNative.View,{style:e.listBar}),jsxRuntime.jsx(reactNative.View,{style:e.listBar}),jsxRuntime.jsx(reactNative.View,{style:e.listBar})]})}i(zl,"ListGlyph");function Fl(){let e=Rn();return jsxRuntime.jsxs(reactNative.View,{style:e.shareGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:[jsxRuntime.jsx(reactNative.View,{style:[e.shareDot,e.shareDotTop]}),jsxRuntime.jsx(reactNative.View,{style:[e.shareDot,e.shareDotLeft]}),jsxRuntime.jsx(reactNative.View,{style:[e.shareDot,e.shareDotBottom]}),jsxRuntime.jsx(reactNative.View,{style:[e.shareStroke,e.shareStrokeUp]}),jsxRuntime.jsx(reactNative.View,{style:[e.shareStroke,e.shareStrokeDown]})]})}i(Fl,"ShareGlyph");function Nl(){let e=Rn();return jsxRuntime.jsxs(reactNative.View,{style:e.sendGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:[jsxRuntime.jsx(reactNative.View,{style:e.sendBody}),jsxRuntime.jsx(reactNative.View,{style:e.sendFold})]})}i(Nl,"SendGlyph");function Ml(){let e=Rn();return jsxRuntime.jsxs(reactNative.View,{style:e.downloadGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:[jsxRuntime.jsx(reactNative.View,{style:e.downloadStem}),jsxRuntime.jsx(reactNative.View,{style:e.downloadHead}),jsxRuntime.jsx(reactNative.View,{style:e.downloadTray})]})}i(Ml,"DownloadGlyph");function Rn(){let e=V();return react.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 reactNative.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 jsxRuntime.jsxs(reactNative.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?jsxRuntime.jsx(m,{style:{fontSize:c.size.bodyTight,color:n.text.muted},children:e}):null,jsxRuntime.jsx(reactNative.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.brand},children:jsxRuntime.jsx(m,{style:{fontSize:c.size.body,color:n.brand},children:r})})]})}i(Vm,"RecordsGateOffState");function Fe(e,t){return e===void 0?{}:{renderDisabled:i(r=>jsxRuntime.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 react.useMemo(()=>Bm(e),[e])}i(me,"useScreenStyles");function Tr({disclaimer:e,style:t}){let r=me();return e.trim().length===0?null:jsxRuntime.jsxs(reactNative.View,{style:[r.band,t],accessible:true,accessibilityRole:"text",accessibilityLabel:yt.important(e),testID:"records-disclaimer-band",children:[jsxRuntime.jsx(reactNative.View,{style:r.infoGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsxRuntime.jsx(m,{style:r.infoGlyphText,children:"i"})}),jsxRuntime.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 jsxRuntime.jsxs(reactNative.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?jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:r==="primary"?d.color.onPrimary:d.color.brandInk}):null,jsxRuntime.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 jsxRuntime.jsx(reactNative.View,{style:[o.chip,n],testID:r,children:jsxRuntime.jsx(m,{style:[o.chipText,a],children:e})})}i(kt,"Chip");function At({title:e,count:t}){let r=me();return jsxRuntime.jsxs(reactNative.View,{style:r.sectionHeader,children:[jsxRuntime.jsx(m,{style:r.sectionTitle,accessibilityRole:"header",children:e}),t!==void 0?jsxRuntime.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 jsxRuntime.jsx(reactNative.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=reactNative.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)},...reactNative.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 jsxRuntime.jsx(reactNative.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=>jsxRuntime.jsxs(reactNative.View,{style:t.actionRow,children:[jsxRuntime.jsxs(reactNative.View,{style:t.actionLeft,children:[jsxRuntime.jsx(xe,{width:18,height:18,radius:9}),jsxRuntime.jsx(xe,{width:"55%",height:14,radius:7})]}),jsxRuntime.jsx(xe,{width:18,height:18,radius:9})]},o),"action");return jsxRuntime.jsxs(reactNative.View,{style:t.dashboard,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:yt.loading,testID:e,children:[jsxRuntime.jsx(reactNative.View,{style:t.inset,children:jsxRuntime.jsxs(reactNative.View,{style:t.summaryCard,children:[jsxRuntime.jsx(xe,{width:Ui,height:Ui,radius:Ui/2}),jsxRuntime.jsxs(reactNative.View,{style:t.badges,children:[jsxRuntime.jsx(xe,{width:Yl,height:co,radius:co/2}),jsxRuntime.jsx(xe,{width:Yl,height:co,radius:co/2})]})]})}),jsxRuntime.jsx(xe,{width:150,height:16,radius:8,style:t.inset}),jsxRuntime.jsx(reactNative.View,{style:t.carouselCard,children:jsxRuntime.jsx(xe,{width:"100%",height:$m,radius:14})}),jsxRuntime.jsxs(reactNative.View,{style:t.dots,children:[jsxRuntime.jsx(xe,{width:6,height:6,radius:3}),jsxRuntime.jsx(xe,{width:18,height:6,radius:3}),jsxRuntime.jsx(xe,{width:6,height:6,radius:3})]}),jsxRuntime.jsx(xe,{width:46,height:12,radius:6,style:t.centered}),jsxRuntime.jsx(reactNative.View,{style:t.inset,children:jsxRuntime.jsx(xe,{width:"100%",height:Kl,radius:12})}),jsxRuntime.jsxs(reactNative.View,{style:[t.inset,t.actions],children:[r("a"),r("b")]})]})}i(po,"DashboardSkeleton");function mo({testID:e}){let t=xn();return jsxRuntime.jsxs(reactNative.View,{style:t.request,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:he.loading,testID:e,children:[jsxRuntime.jsx(reactNative.View,{children:[0,1,2,3].map(r=>jsxRuntime.jsxs(reactNative.View,{style:t.railRow,children:[jsxRuntime.jsxs(reactNative.View,{style:t.railColumn,children:[jsxRuntime.jsx(xe,{width:uo,height:uo,radius:uo/2}),r<3?jsxRuntime.jsx(xe,{width:2,height:20,radius:1,style:t.connector}):null]}),jsxRuntime.jsxs(reactNative.View,{style:t.railBody,children:[jsxRuntime.jsx(xe,{width:"55%",height:14,radius:7}),jsxRuntime.jsx(xe,{width:"75%",height:11,radius:6})]})]},r))}),jsxRuntime.jsxs(reactNative.View,{style:t.statusCard,children:[jsxRuntime.jsx(xe,{width:"90%",height:13,radius:6}),jsxRuntime.jsx(xe,{width:"60%",height:13,radius:6})]}),jsxRuntime.jsx(xe,{width:"100%",height:50,radius:25})]})}i(mo,"RequestSkeleton");function Ql({testID:e}){let t=xn();return jsxRuntime.jsxs(reactNative.View,{style:t.timeline,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:be.loadingTimeline,testID:e,children:[jsxRuntime.jsx(reactNative.View,{style:t.timelineDisclaimer,children:jsxRuntime.jsx(xe,{width:"100%",height:Kl,radius:12})}),Array.from({length:Wm},(r,o)=>jsxRuntime.jsxs(reactNative.View,{children:[o>0?jsxRuntime.jsx(reactNative.View,{style:t.timelineSeparator}):null,jsxRuntime.jsxs(reactNative.View,{style:t.timelineRow,children:[jsxRuntime.jsx(xe,{width:ji,height:ji,radius:ji/2}),jsxRuntime.jsxs(reactNative.View,{style:t.timelineBody,children:[jsxRuntime.jsxs(reactNative.View,{style:t.timelineTop,children:[jsxRuntime.jsx(xe,{width:44,height:10,radius:5}),jsxRuntime.jsx(xe,{width:56,height:12,radius:6})]}),jsxRuntime.jsx(xe,{width:"70%",height:14,radius:7}),o%2===0?jsxRuntime.jsx(xe,{width:"45%",height:12,radius:6}):null]})]})]},o))]})}i(Ql,"TimelineSkeleton");function Xl({testID:e}){let t=xn();return jsxRuntime.jsx(reactNative.View,{style:t.clinics,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:Ce.loading,testID:e,children:Array.from({length:Gm},(r,o)=>jsxRuntime.jsxs(reactNative.View,{style:t.clinicRow,children:[jsxRuntime.jsx(xe,{width:"65%",height:14,radius:7}),jsxRuntime.jsx(xe,{width:"40%",height:11,radius:6})]},o))})}i(Xl,"ClinicsSkeleton");function Jl({testID:e}){let t=xn();return jsxRuntime.jsx(reactNative.View,{style:t.shares,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:ae.loadingLinks,testID:e,children:[0,1].map(r=>jsxRuntime.jsxs(reactNative.View,{style:t.shareRow,children:[jsxRuntime.jsx(xe,{width:"55%",height:13}),jsxRuntime.jsx(xe,{width:"40%",height:11})]},r))})}i(Jl,"SharesSkeleton");var $i=62;function xn(){let e=V();return react.useMemo(()=>Ym(e),[e])}i(xn,"useStyles");function Ym(e){let{color:t,space:r,radius:o}=e,n=reactNative.StyleSheet.hairlineWidth;return reactNative.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 jsxRuntime.jsx(Ve,{capability:"recordsClinic",style:e.style,...Fe(e.onBack,Ye),children:t===null?jsxRuntime.jsx(m,{accessibilityRole:"alert",children:ye.sessionRequired}):jsxRuntime.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=react.useRef(lr()),[R,v]=react.useState(false),[w,g]=react.useState(null),[y,x]=react.useState(false),[h,P]=react.useState(""),[S,E]=react.useState(false),[C,I]=react.useState(""),[F,q]=react.useState(false),j=react.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 jsxRuntime.jsxs(reactNative.View,{style:[c.root,l],children:[jsxRuntime.jsx(Ke,{title:Ce.title,onBack:a,testID:"records-clinic-header"}),jsxRuntime.jsxs(reactNative.View,{style:s.searchBar,children:[jsxRuntime.jsx(reactNative.View,{style:s.searchGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxRuntime.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?jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>p.setQuery(""),accessibilityRole:"button",accessibilityLabel:Ce.clearSearch,hitSlop:8,testID:"records-clinic-search-clear",children:jsxRuntime.jsx(m,{style:s.clearGlyph,children:"\xD7"})}):null]}),n?jsxRuntime.jsxs(reactNative.View,{style:s.uploadWrap,children:[w?jsxRuntime.jsx(reactNative.View,{style:c.errorBanner,accessibilityRole:"alert",children:jsxRuntime.jsx(m,{style:c.errorText,children:w})}):null,jsxRuntime.jsx(X,{label:R?Ce.uploadOwnStarting:Ce.uploadOwn,kind:"outline",accessibilityLabel:Ce.uploadOwnA11y,busy:R,onPress:$,testID:"records-clinic-upload-own"})]}):null,jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:s.list,keyboardShouldPersistTaps:"handled",onScroll:p.isSearchActive?ie:void 0,scrollEventThrottle:200,testID:"records-clinic-results",children:[p.isSearchActive?jsxRuntime.jsxs(reactNative.View,{style:s.fallbackCard,testID:"records-clinic-fallback-card",children:[jsxRuntime.jsxs(reactNative.Pressable,{onPress:()=>x(L=>!L),accessibilityRole:"button",accessibilityLabel:y?Ce.fallback.collapseA11y:Ce.fallback.expandA11y,style:s.fallbackHeader,testID:"records-clinic-fallback",children:[jsxRuntime.jsxs(reactNative.View,{style:s.fallbackCopy,children:[jsxRuntime.jsx(m,{style:s.fallbackTitle,numberOfLines:1,children:Ce.fallback.title}),jsxRuntime.jsx(m,{style:s.fallbackSubtitle,numberOfLines:2,children:Ce.fallback.subtitle})]}),jsxRuntime.jsx(rr,{direction:y?"up":"down"})]}),y?jsxRuntime.jsxs(reactNative.View,{style:s.fallbackForm,children:[jsxRuntime.jsx(m,{style:c.fieldLabel,children:Ce.fallback.nameLabel}),jsxRuntime.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"}),jsxRuntime.jsx(m,{style:c.fieldLabel,children:Ce.fallback.emailLabel}),jsxRuntime.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?jsxRuntime.jsx(m,{style:c.errorText,accessibilityRole:"alert",children:he.errors.invalidEmail}):null,jsxRuntime.jsx(m,{style:c.muted,children:Ce.fallback.reviewNote}),jsxRuntime.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?jsxRuntime.jsx(m,{style:s.sectionLabel,accessibilityRole:"header",testID:"records-clinic-recent-label",children:Ce.recentlyUsed}):null,p.isSearchActive&&p.initialLoading?jsxRuntime.jsx(Xl,{testID:"records-clinic-page-loading"}):null,T.map(L=>jsxRuntime.jsx(ry,{clinic:L,onSelect:j,styles:s},L.id)),D&&!p.initialLoading?jsxRuntime.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,jsxRuntime.jsxs(reactNative.View,{style:s.footer,children:[p.loadingMore?jsxRuntime.jsxs(reactNative.View,{style:s.footerLoading,testID:"records-clinic-loading-more",children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{color:d.color.brandInk,size:"small"}),jsxRuntime.jsx(m,{style:c.muted,children:Ce.loadingMore})]}):null,p.pageError?jsxRuntime.jsx(reactNative.Pressable,{onPress:p.loadMore,accessibilityRole:"button",accessibilityLabel:Ce.loadMoreRetryA11y,style:s.footerRetry,testID:"records-clinic-page-error-retry",children:jsxRuntime.jsx(m,{style:s.footerRetryLabel,children:Ce.loadMoreFailed})}):null]})]}),jsxRuntime.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 jsxRuntime.jsxs(reactNative.Pressable,{onPress:()=>t(e),accessibilityRole:"button",accessibilityLabel:Ce.selectA11y(a),hitSlop:8,style:r.item,testID:`records-clinic-${e.id}`,children:[jsxRuntime.jsxs(reactNative.View,{style:r.itemHeader,children:[jsxRuntime.jsx(m,{style:r.itemName,numberOfLines:1,children:e.name}),n?jsxRuntime.jsx(m,{style:r.itemDistance,accessibilityElementsHidden:true,importantForAccessibility:"no",children:n}):null]}),e.address?jsxRuntime.jsx(m,{style:r.itemAddress,numberOfLines:2,children:e.address}):null,e.phone?jsxRuntime.jsx(m,{style:r.itemPhone,numberOfLines:1,accessibilityElementsHidden:true,importantForAccessibility:"no",children:e.phone}):null,jsxRuntime.jsx(reactNative.View,{style:[r.badge,o.tone==="positive"?r.badgePositive:o.tone==="caution"?r.badgeCaution:r.badgeNeutral],accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsxRuntime.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 react.useMemo(()=>oy(e),[e])}i(ny,"useLocalStyles");function oy(e){let{color:t,space:r,radius:o,type:n}=e,a=reactNative.StyleSheet.hairlineWidth,l=i((c,s,d,u="regular")=>({...k(e,u),fontSize:c,lineHeight:Math.round(c*s),color:d}),"text");return reactNative.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]=react.useState(e.ownerName),[a,l]=react.useState(""),[c,s]=react.useState(null),[d,u]=react.useState(""),[p,f]=react.useState([]),[b,R]=react.useState([]),[v,w]=react.useState(null),[g,y]=react.useState(null),[x,h]=react.useState(false),[P,S]=react.useState(false),[E,C]=react.useState(null),[I,F]=react.useState(0),q=react.useRef(false),j=react.useRef(false),$=react.useRef(0),ce=react.useRef(lr()),oe=react.useRef(null),ve=react.useRef(null),ie=react.useRef(0);react.useEffect(()=>(q.current=true,j.current=false,h(false),()=>{q.current=false,ie.current+=1,$.current+=1,oe.current=null,ve.current?.abort();}),[t]),react.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]),react.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]=react.useState(e.ownerName),[c,s]=react.useState(""),[d,u]=react.useState([]),[p,f]=react.useState([]),[b,R]=react.useState([]),[v,w]=react.useState(null),[g,y]=react.useState(null),[x,h]=react.useState(false),[P,S]=react.useState(false),[E,C]=react.useState(null),[I,F]=react.useState(null),[q,j]=react.useState(0),$=react.useRef(false),ce=react.useRef(false),oe=react.useRef(0),ve=react.useRef(0),ie=react.useRef(lr()),T=react.useRef(null),D=react.useRef(null);react.useEffect(()=>($.current=true,ce.current=false,h(false),()=>{$.current=false,ve.current+=1,oe.current+=1,T.current=null,D.current?.abort();}),[t,r]),react.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]),react.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
|
+
'use strict';var react=require('react'),zod=require('zod'),reactNative=require('react-native'),jsxRuntime=require('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=zod.z.object({request_id:zod.z.string().min(1),pet_ref:zod.z.string().min(1),status:zod.z.string(),simple_status:zod.z.string().nullish(),simple_status_detail:zod.z.string().nullish(),status_label:zod.z.string().optional(),dispatch_status:zod.z.string().nullish(),can_retry_send:zod.z.boolean().optional(),can_revoke:zod.z.boolean().optional(),can_convert_to_upload:zod.z.boolean().optional(),can_update_clinic_email:zod.z.boolean().optional(),reminder_count:zod.z.number().int().nonnegative().optional(),last_reminder_at:zod.z.string().nullish(),waiting_expectation:zod.z.string().nullish(),document_count:zod.z.number().optional(),held_item_count:zod.z.number().optional(),received_at:zod.z.string().nullish(),parsing_started_at:zod.z.string().nullish(),review_started_at:zod.z.string().nullish(),created_at:zod.z.string().optional(),updated_at:zod.z.string().optional(),source:zod.z.string().nullish().catch(null),action_needed_label:zod.z.string().nullish().catch(null),failure_reason:zod.z.string().nullish().catch(null),failure_code:zod.z.string().nullish().catch(null),recovery_stage:zod.z.string().nullish().catch(null),show_clinic_phone:zod.z.boolean().optional().catch(void 0),clinic_name:zod.z.string().nullish().catch(null),clinic_email:zod.z.string().nullish().catch(null),clinic_phone:zod.z.string().nullish().catch(null),converted_to_upload_at:zod.z.string().nullish().catch(null),request_group_id:zod.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=zod.z.object({request_group_id:zod.z.string().min(1),pet_ref:zod.z.string().min(1),total:zod.z.number().int().nonnegative(),responded:zod.z.number().int().nonnegative(),pending:zod.z.number().int().nonnegative(),members:zod.z.array(zod.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=zod.z.object({source_doc_id:zod.z.string().min(1),request_id:zod.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=zod.z.object({label:zod.z.string(),value:zod.z.string()}),ni=zod.z.object({key:zod.z.string(),category:zod.z.string().optional(),label:zod.z.string().optional(),value:zod.z.string().nullish(),unit:zod.z.string().nullish(),observed_at:zod.z.string().nullish(),status:zod.z.string().nullish(),origin:zod.z.string().nullish(),canonical_key:zod.z.string().nullish()}),_u=zod.z.object({at:zod.z.string(),value:zod.z.number().nullish(),display:zod.z.string().nullish(),origin:zod.z.string().nullish()}),Pu=zod.z.object({key:zod.z.string(),label:zod.z.string().optional(),points:zod.z.array(_u).optional()}),Iu=zod.z.object({title:zod.z.string(),detail:zod.z.string().nullish(),due_at:zod.z.string().nullish()}),oi=zod.z.object({doc_id:zod.z.string(),title:zod.z.string().nullish(),page_count:zod.z.number().nullish(),received_at:zod.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=zod.z.object({identity:zod.z.array(Tu).optional(),entities:zod.z.array(ni).optional(),entity_series:zod.z.array(Pu).optional(),forward_looking:zod.z.array(Iu).optional(),documents:zod.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=zod.z.object({pet_ref:zod.z.string().optional(),granted:zod.z.boolean().optional(),version:zod.z.string().nullish(),granted_at:zod.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]=react.createContext(null));Va.displayName??="EverfurContext";function Te(){let e=react.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=react.useCallback(()=>Cp(e),[e]);return react.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=react.useRef(e.uploadTransport);r.current=e.uploadTransport;let o=e.uploadTransport!==void 0,{runtime:n,userRef:a,scopeEpoch:l}=Te(),c=react.useMemo(()=>({}),[n,a,t,l,e.controller]),s=react.useRef(c),[d,u]=react.useState({scope:c,controller:e.controller??null}),p=e.controller??(d.scope===c?d.controller:null),[f,b]=react.useState({scope:c,value:fi}),R=f.scope===c?f.value:fi,v=react.useCallback(T=>{b(D=>D.scope===c?{scope:c,value:T(D.value)}:D);},[c]),w=react.useRef(0);react.useEffect(()=>(s.current=c,b({scope:c,value:fi}),()=>{s.current=null,w.current+=1;}),[c]),react.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=react.useCallback(T=>{v(D=>({...D,...T}));},[v]),y=react.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]);react.useEffect(()=>(y(),()=>{w.current+=1;}),[y]);let x=react.useMemo(()=>_p(R.requests),[R.requests]),h=x?.id??null,P=x?.status??null,S=react.useRef(0),E=react.useRef(null),[C,I]=react.useReducer(T=>T+1,0);react.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=react.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=react.useCallback((T,D)=>{v(L=>({...L,uploadQueue:L.uploadQueue.map(B=>B.key===T?D(B):B)}));},[v]),j=react.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]),$=react.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=react.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=react.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=react.useCallback(()=>y(),[y]),ie=Tp(R,p!==null);return react.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]=react.createContext(Qa));Ei.displayName??="EverfurThemeContext";function V(){return react.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 react.createElement(reactNative.Text,o===void 0?t:{maxFontSizeMultiplier:o,...t})}i(m,"Text");var He=react.forwardRef(i(function(t,r){return react.createElement(reactNative.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]=react.useState(""),[n,a]=react.useState(""),[l,c]=react.useState([]),[s,d]=react.useState(null),[u,p]=react.useState([]),[f,b]=react.useState(true),[R,v]=react.useState(false),[w,g]=react.useState(false),[y,x]=react.useState(null),[h,P]=react.useState(null),[S,E]=react.useState(0),C=react.useRef(0),I=react.useRef(true),F=t?.latitude,q=t?.longitude,j=react.useMemo(()=>F!==void 0&&q!==void 0?{latitude:F,longitude:q}:void 0,[F,q]);react.useEffect(()=>(I.current=true,()=>{I.current=false,C.current+=1;}),[e]),react.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]),react.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;react.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=react.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=react.useCallback(ie=>o(ie),[]),ve=react.useCallback(()=>E(ie=>ie+1),[]);return react.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=zod.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)=>zod.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=zod.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:zod.z.string().min(1).max(2*1024*1024).optional(),idempotencyKey:zod.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=zod.z.object({petRef:fn(128),ownerName:fn(200).refine(e=>e.trim().length>0&&!pl(e)),authorizationVersion:fn(64),clinics:zod.z.array(Jp).min(1).max(Gr)}).strict(),em=zod.z.object({request_group_id:oo,pet_ref:zod.z.string(),created_count:zod.z.number().int().nonnegative(),failed_count:zod.z.number().int().nonnegative(),results:zod.z.array(zod.z.object({idempotency_key:zod.z.string(),clinic_id:oo.nullable().optional(),clinic_free_text:zod.z.string().nullable().optional(),created:zod.z.boolean(),request:zod.z.unknown().optional(),failure_code:zod.z.string().nullable().optional(),failure_reason:zod.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=zod.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=zod.z.object({clinics:zod.z.array(zod.z.object({clinic_id:yl,name:zod.z.string().min(1),address:zod.z.string().nullable(),phone:zod.z.string().nullable(),email_status:zod.z.string(),distance_km:zod.z.number().finite().nonnegative().nullable()})),next_cursor:zod.z.string().nullable().optional()}),rm=zod.z.object({authorization_version:zod.z.string().min(1),scope_template:zod.z.string().min(1),authorization_template:zod.z.string().min(1)}),nm=zod.z.object({upload_id:zod.z.string().min(1),upload_url:zod.z.string().url().refine(e=>e.startsWith("https://")),upload_fields:zod.z.record(zod.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=zod.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=zod.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)=>zod.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=zod.z.object({limit:zod.z.number().int().min(1).max(25).optional()}).strict(),im=zod.z.object({query:Sr(200,0).optional(),location:zod.z.object({latitude:zod.z.number().finite().min(-90).max(90),longitude:zod.z.number().finite().min(-180).max(180)}).strict().optional(),limit:zod.z.number().int().min(1).max(100).optional(),cursor:Sr(512,0).optional()}).strict(),sm=zod.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:zod.z.string().min(1).max(2*1024*1024).optional(),idempotencyKey:zod.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=react.useMemo(()=>{let{services:a}=e.registry;return fl({repository:vl({auth:a.authFor(t),...a.errorPolicy?{errorPolicy:a.errorPolicy}:{}})})},[e,t,r]),n=react.useRef(o);return react.useEffect(()=>(n.current=o,()=>{n.current=null;}),[o]),react.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=react.useMemo(()=>{let{services:a}=e.registry;return ml({auth:a.authFor(t),...a.errorPolicy?{errorPolicy:a.errorPolicy}:{}})},[e,t,r]),n=react.useRef(o);return react.useEffect(()=>(n.current=o,()=>{n.current=null;}),[o]),react.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 react.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 react.createElement(Oi,{fallback:t,resetKey:r,children:react.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=react.useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot);return react.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=react.useMemo(()=>gm(l),[l]);switch(c){case "enabled":return r;case "pending":return n?jsxRuntime.jsx(Li,{render:n,fallback:jsxRuntime.jsx(kl,{capability:t,style:a})}):jsxRuntime.jsx(kl,{capability:t,style:a});case "disabled":return o?jsxRuntime.jsx(Li,{render:()=>o(l),fallback:jsxRuntime.jsx(Tl,{decision:l,style:a}),resetKey:l}):jsxRuntime.jsx(Tl,{decision:l,style:a});default:return vr(c)}}i(Ve,"CapabilityGate");function kl({capability:e,style:t}){let r=V(),o=react.useMemo(()=>_l(r),[r]);return jsxRuntime.jsx(reactNative.View,{style:[o.offstate,t],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${e}`,children:jsxRuntime.jsx(reactNative.View,{style:o.skeletonBar})})}i(kl,"PendingSkeleton");function Tl({decision:e,style:t}){let r=V(),o=react.useMemo(()=>_l(r),[r]),n=e.disabled?.reason??"";return jsxRuntime.jsx(reactNative.View,{style:[o.offstate,t],accessible:true,accessibilityRole:"text",accessibilityLabel:n,children:n.length>0?jsxRuntime.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 reactNative.StyleSheet.create({offstate:{minHeight:fm,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:o.md,borderWidth:reactNative.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=react.useMemo(()=>Rm(t),[t]);return jsxRuntime.jsxs(reactNative.View,{style:[r.container,e.style],accessible:true,accessibilityRole:"text",accessibilityLabel:`${bn.title}. ${bn.body}`,children:[jsxRuntime.jsx(m,{style:r.title,children:bn.title}),jsxRuntime.jsx(m,{style:r.body,children:bn.body})]})}i(qe,"ClinicalDisclaimer");function Rm(e){let{color:t,space:r,type:o}=e;return reactNative.StyleSheet.create({container:{paddingHorizontal:r.lg,paddingVertical:r.md,borderTopWidth:reactNative.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]=react.useState(e==="rate_limited"?Ni:0);react.useEffect(()=>{e==="rate_limited"&&c(Ni);},[e]),react.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 jsxRuntime.jsxs(reactNative.View,{style:n.container,accessibilityRole:"summary",testID:o,children:[jsxRuntime.jsx(reactNative.View,{style:n.glyph,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxRuntime.jsx(m,{style:n.title,children:a.title}),jsxRuntime.jsx(m,{style:n.body,children:r??a.body}),d!==null&&t?jsxRuntime.jsx(reactNative.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:jsxRuntime.jsx(m,{style:n.actionLabel,children:d})}):null]})}i(Ue,"RecordsEmptyState");function Em(){let e=V();return react.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 reactNative.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:reactNative.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 jsxRuntime.jsxs(reactNative.View,{style:a.row,testID:o,children:[t?jsxRuntime.jsx(reactNative.Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:Ye,hitSlop:12,style:a.back,testID:o?`${o}-back`:void 0,children:jsxRuntime.jsx(reactNative.View,{style:a.chevron,accessibilityElementsHidden:true,importantForAccessibility:"no"})}):jsxRuntime.jsx(reactNative.View,{style:a.back}),jsxRuntime.jsx(m,{style:n==="document"?a.documentTitle:a.title,accessibilityRole:"header",numberOfLines:1,children:e}),jsxRuntime.jsx(reactNative.View,{style:a.right,children:r??jsxRuntime.jsx(reactNative.View,{style:a.back})})]})}i(Ke,"ScreenHeader");function zl(){let e=Rn();return jsxRuntime.jsxs(reactNative.View,{style:e.listGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:[jsxRuntime.jsx(reactNative.View,{style:e.listBar}),jsxRuntime.jsx(reactNative.View,{style:e.listBar}),jsxRuntime.jsx(reactNative.View,{style:e.listBar})]})}i(zl,"ListGlyph");function Fl(){let e=Rn();return jsxRuntime.jsxs(reactNative.View,{style:e.shareGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:[jsxRuntime.jsx(reactNative.View,{style:[e.shareDot,e.shareDotTop]}),jsxRuntime.jsx(reactNative.View,{style:[e.shareDot,e.shareDotLeft]}),jsxRuntime.jsx(reactNative.View,{style:[e.shareDot,e.shareDotBottom]}),jsxRuntime.jsx(reactNative.View,{style:[e.shareStroke,e.shareStrokeUp]}),jsxRuntime.jsx(reactNative.View,{style:[e.shareStroke,e.shareStrokeDown]})]})}i(Fl,"ShareGlyph");function Nl(){let e=Rn();return jsxRuntime.jsxs(reactNative.View,{style:e.sendGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:[jsxRuntime.jsx(reactNative.View,{style:e.sendBody}),jsxRuntime.jsx(reactNative.View,{style:e.sendFold})]})}i(Nl,"SendGlyph");function Ml(){let e=Rn();return jsxRuntime.jsxs(reactNative.View,{style:e.downloadGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:[jsxRuntime.jsx(reactNative.View,{style:e.downloadStem}),jsxRuntime.jsx(reactNative.View,{style:e.downloadHead}),jsxRuntime.jsx(reactNative.View,{style:e.downloadTray})]})}i(Ml,"DownloadGlyph");function Rn(){let e=V();return react.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 reactNative.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 jsxRuntime.jsxs(reactNative.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?jsxRuntime.jsx(m,{style:{fontSize:c.size.bodyTight,color:n.text.muted},children:e}):null,jsxRuntime.jsx(reactNative.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:jsxRuntime.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=>jsxRuntime.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 react.useMemo(()=>Bm(e),[e])}i(me,"useScreenStyles");function Tr({disclaimer:e,style:t}){let r=me();return e.trim().length===0?null:jsxRuntime.jsxs(reactNative.View,{style:[r.band,t],accessible:true,accessibilityRole:"text",accessibilityLabel:yt.important(e),testID:"records-disclaimer-band",children:[jsxRuntime.jsx(reactNative.View,{style:r.infoGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsxRuntime.jsx(m,{style:r.infoGlyphText,children:"i"})}),jsxRuntime.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 jsxRuntime.jsxs(reactNative.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?jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:r==="primary"?d.color.onPrimary:d.color.brandInk}):null,jsxRuntime.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 jsxRuntime.jsx(reactNative.View,{style:[o.chip,n],testID:r,children:jsxRuntime.jsx(m,{style:[o.chipText,a],children:e})})}i(kt,"Chip");function At({title:e,count:t}){let r=me();return jsxRuntime.jsxs(reactNative.View,{style:r.sectionHeader,children:[jsxRuntime.jsx(m,{style:r.sectionTitle,accessibilityRole:"header",children:e}),t!==void 0?jsxRuntime.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 jsxRuntime.jsx(reactNative.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=reactNative.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)},...reactNative.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 jsxRuntime.jsx(reactNative.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=>jsxRuntime.jsxs(reactNative.View,{style:t.actionRow,children:[jsxRuntime.jsxs(reactNative.View,{style:t.actionLeft,children:[jsxRuntime.jsx(xe,{width:18,height:18,radius:9}),jsxRuntime.jsx(xe,{width:"55%",height:14,radius:7})]}),jsxRuntime.jsx(xe,{width:18,height:18,radius:9})]},o),"action");return jsxRuntime.jsxs(reactNative.View,{style:t.dashboard,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:yt.loading,testID:e,children:[jsxRuntime.jsx(reactNative.View,{style:t.inset,children:jsxRuntime.jsxs(reactNative.View,{style:t.summaryCard,children:[jsxRuntime.jsx(xe,{width:Ui,height:Ui,radius:Ui/2}),jsxRuntime.jsxs(reactNative.View,{style:t.badges,children:[jsxRuntime.jsx(xe,{width:Yl,height:co,radius:co/2}),jsxRuntime.jsx(xe,{width:Yl,height:co,radius:co/2})]})]})}),jsxRuntime.jsx(xe,{width:150,height:16,radius:8,style:t.inset}),jsxRuntime.jsx(reactNative.View,{style:t.carouselCard,children:jsxRuntime.jsx(xe,{width:"100%",height:$m,radius:14})}),jsxRuntime.jsxs(reactNative.View,{style:t.dots,children:[jsxRuntime.jsx(xe,{width:6,height:6,radius:3}),jsxRuntime.jsx(xe,{width:18,height:6,radius:3}),jsxRuntime.jsx(xe,{width:6,height:6,radius:3})]}),jsxRuntime.jsx(xe,{width:46,height:12,radius:6,style:t.centered}),jsxRuntime.jsx(reactNative.View,{style:t.inset,children:jsxRuntime.jsx(xe,{width:"100%",height:Kl,radius:12})}),jsxRuntime.jsxs(reactNative.View,{style:[t.inset,t.actions],children:[r("a"),r("b")]})]})}i(po,"DashboardSkeleton");function mo({testID:e}){let t=xn();return jsxRuntime.jsxs(reactNative.View,{style:t.request,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:he.loading,testID:e,children:[jsxRuntime.jsx(reactNative.View,{children:[0,1,2,3].map(r=>jsxRuntime.jsxs(reactNative.View,{style:t.railRow,children:[jsxRuntime.jsxs(reactNative.View,{style:t.railColumn,children:[jsxRuntime.jsx(xe,{width:uo,height:uo,radius:uo/2}),r<3?jsxRuntime.jsx(xe,{width:2,height:20,radius:1,style:t.connector}):null]}),jsxRuntime.jsxs(reactNative.View,{style:t.railBody,children:[jsxRuntime.jsx(xe,{width:"55%",height:14,radius:7}),jsxRuntime.jsx(xe,{width:"75%",height:11,radius:6})]})]},r))}),jsxRuntime.jsxs(reactNative.View,{style:t.statusCard,children:[jsxRuntime.jsx(xe,{width:"90%",height:13,radius:6}),jsxRuntime.jsx(xe,{width:"60%",height:13,radius:6})]}),jsxRuntime.jsx(xe,{width:"100%",height:50,radius:25})]})}i(mo,"RequestSkeleton");function Ql({testID:e}){let t=xn();return jsxRuntime.jsxs(reactNative.View,{style:t.timeline,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:be.loadingTimeline,testID:e,children:[jsxRuntime.jsx(reactNative.View,{style:t.timelineDisclaimer,children:jsxRuntime.jsx(xe,{width:"100%",height:Kl,radius:12})}),Array.from({length:Wm},(r,o)=>jsxRuntime.jsxs(reactNative.View,{children:[o>0?jsxRuntime.jsx(reactNative.View,{style:t.timelineSeparator}):null,jsxRuntime.jsxs(reactNative.View,{style:t.timelineRow,children:[jsxRuntime.jsx(xe,{width:ji,height:ji,radius:ji/2}),jsxRuntime.jsxs(reactNative.View,{style:t.timelineBody,children:[jsxRuntime.jsxs(reactNative.View,{style:t.timelineTop,children:[jsxRuntime.jsx(xe,{width:44,height:10,radius:5}),jsxRuntime.jsx(xe,{width:56,height:12,radius:6})]}),jsxRuntime.jsx(xe,{width:"70%",height:14,radius:7}),o%2===0?jsxRuntime.jsx(xe,{width:"45%",height:12,radius:6}):null]})]})]},o))]})}i(Ql,"TimelineSkeleton");function Xl({testID:e}){let t=xn();return jsxRuntime.jsx(reactNative.View,{style:t.clinics,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:Ce.loading,testID:e,children:Array.from({length:Gm},(r,o)=>jsxRuntime.jsxs(reactNative.View,{style:t.clinicRow,children:[jsxRuntime.jsx(xe,{width:"65%",height:14,radius:7}),jsxRuntime.jsx(xe,{width:"40%",height:11,radius:6})]},o))})}i(Xl,"ClinicsSkeleton");function Jl({testID:e}){let t=xn();return jsxRuntime.jsx(reactNative.View,{style:t.shares,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:ae.loadingLinks,testID:e,children:[0,1].map(r=>jsxRuntime.jsxs(reactNative.View,{style:t.shareRow,children:[jsxRuntime.jsx(xe,{width:"55%",height:13}),jsxRuntime.jsx(xe,{width:"40%",height:11})]},r))})}i(Jl,"SharesSkeleton");var $i=62;function xn(){let e=V();return react.useMemo(()=>Ym(e),[e])}i(xn,"useStyles");function Ym(e){let{color:t,space:r,radius:o}=e,n=reactNative.StyleSheet.hairlineWidth;return reactNative.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 jsxRuntime.jsx(Ve,{capability:"recordsClinic",style:e.style,...Fe(e.onBack,Ye),children:t===null?jsxRuntime.jsx(m,{accessibilityRole:"alert",children:ye.sessionRequired}):jsxRuntime.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=react.useRef(lr()),[R,v]=react.useState(false),[w,g]=react.useState(null),[y,x]=react.useState(false),[h,P]=react.useState(""),[S,E]=react.useState(false),[C,I]=react.useState(""),[F,q]=react.useState(false),j=react.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 jsxRuntime.jsxs(reactNative.View,{style:[c.root,l],children:[jsxRuntime.jsx(Ke,{title:Ce.title,onBack:a,testID:"records-clinic-header"}),jsxRuntime.jsxs(reactNative.View,{style:s.searchBar,children:[jsxRuntime.jsx(reactNative.View,{style:s.searchGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxRuntime.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?jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>p.setQuery(""),accessibilityRole:"button",accessibilityLabel:Ce.clearSearch,hitSlop:8,testID:"records-clinic-search-clear",children:jsxRuntime.jsx(m,{style:s.clearGlyph,children:"\xD7"})}):null]}),n?jsxRuntime.jsxs(reactNative.View,{style:s.uploadWrap,children:[w?jsxRuntime.jsx(reactNative.View,{style:c.errorBanner,accessibilityRole:"alert",children:jsxRuntime.jsx(m,{style:c.errorText,children:w})}):null,jsxRuntime.jsx(X,{label:R?Ce.uploadOwnStarting:Ce.uploadOwn,kind:"outline",accessibilityLabel:Ce.uploadOwnA11y,busy:R,onPress:$,testID:"records-clinic-upload-own"})]}):null,jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:s.list,keyboardShouldPersistTaps:"handled",onScroll:p.isSearchActive?ie:void 0,scrollEventThrottle:200,testID:"records-clinic-results",children:[p.isSearchActive?jsxRuntime.jsxs(reactNative.View,{style:s.fallbackCard,testID:"records-clinic-fallback-card",children:[jsxRuntime.jsxs(reactNative.Pressable,{onPress:()=>x(L=>!L),accessibilityRole:"button",accessibilityLabel:y?Ce.fallback.collapseA11y:Ce.fallback.expandA11y,style:s.fallbackHeader,testID:"records-clinic-fallback",children:[jsxRuntime.jsxs(reactNative.View,{style:s.fallbackCopy,children:[jsxRuntime.jsx(m,{style:s.fallbackTitle,numberOfLines:1,children:Ce.fallback.title}),jsxRuntime.jsx(m,{style:s.fallbackSubtitle,numberOfLines:2,children:Ce.fallback.subtitle})]}),jsxRuntime.jsx(rr,{direction:y?"up":"down"})]}),y?jsxRuntime.jsxs(reactNative.View,{style:s.fallbackForm,children:[jsxRuntime.jsx(m,{style:c.fieldLabel,children:Ce.fallback.nameLabel}),jsxRuntime.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"}),jsxRuntime.jsx(m,{style:c.fieldLabel,children:Ce.fallback.emailLabel}),jsxRuntime.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?jsxRuntime.jsx(m,{style:c.errorText,accessibilityRole:"alert",children:he.errors.invalidEmail}):null,jsxRuntime.jsx(m,{style:c.muted,children:Ce.fallback.reviewNote}),jsxRuntime.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?jsxRuntime.jsx(m,{style:s.sectionLabel,accessibilityRole:"header",testID:"records-clinic-recent-label",children:Ce.recentlyUsed}):null,p.isSearchActive&&p.initialLoading?jsxRuntime.jsx(Xl,{testID:"records-clinic-page-loading"}):null,T.map(L=>jsxRuntime.jsx(ry,{clinic:L,onSelect:j,styles:s},L.id)),D&&!p.initialLoading?jsxRuntime.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,jsxRuntime.jsxs(reactNative.View,{style:s.footer,children:[p.loadingMore?jsxRuntime.jsxs(reactNative.View,{style:s.footerLoading,testID:"records-clinic-loading-more",children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{color:d.color.brandInk,size:"small"}),jsxRuntime.jsx(m,{style:c.muted,children:Ce.loadingMore})]}):null,p.pageError?jsxRuntime.jsx(reactNative.Pressable,{onPress:p.loadMore,accessibilityRole:"button",accessibilityLabel:Ce.loadMoreRetryA11y,style:s.footerRetry,testID:"records-clinic-page-error-retry",children:jsxRuntime.jsx(m,{style:s.footerRetryLabel,children:Ce.loadMoreFailed})}):null]})]}),jsxRuntime.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 jsxRuntime.jsxs(reactNative.Pressable,{onPress:()=>t(e),accessibilityRole:"button",accessibilityLabel:Ce.selectA11y(a),hitSlop:8,style:r.item,testID:`records-clinic-${e.id}`,children:[jsxRuntime.jsxs(reactNative.View,{style:r.itemHeader,children:[jsxRuntime.jsx(m,{style:r.itemName,numberOfLines:1,children:e.name}),n?jsxRuntime.jsx(m,{style:r.itemDistance,accessibilityElementsHidden:true,importantForAccessibility:"no",children:n}):null]}),e.address?jsxRuntime.jsx(m,{style:r.itemAddress,numberOfLines:2,children:e.address}):null,e.phone?jsxRuntime.jsx(m,{style:r.itemPhone,numberOfLines:1,accessibilityElementsHidden:true,importantForAccessibility:"no",children:e.phone}):null,jsxRuntime.jsx(reactNative.View,{style:[r.badge,o.tone==="positive"?r.badgePositive:o.tone==="caution"?r.badgeCaution:r.badgeNeutral],accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsxRuntime.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 react.useMemo(()=>oy(e),[e])}i(ny,"useLocalStyles");function oy(e){let{color:t,space:r,radius:o,type:n}=e,a=reactNative.StyleSheet.hairlineWidth,l=i((c,s,d,u="regular")=>({...k(e,u),fontSize:c,lineHeight:Math.round(c*s),color:d}),"text");return reactNative.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]=react.useState(e.ownerName),[a,l]=react.useState(""),[c,s]=react.useState(null),[d,u]=react.useState(""),[p,f]=react.useState([]),[b,R]=react.useState([]),[v,w]=react.useState(null),[g,y]=react.useState(null),[x,h]=react.useState(false),[P,S]=react.useState(false),[E,C]=react.useState(null),[I,F]=react.useState(0),q=react.useRef(false),j=react.useRef(false),$=react.useRef(0),ce=react.useRef(lr()),oe=react.useRef(null),ve=react.useRef(null),ie=react.useRef(0);react.useEffect(()=>(q.current=true,j.current=false,h(false),()=>{q.current=false,ie.current+=1,$.current+=1,oe.current=null,ve.current?.abort();}),[t]),react.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]),react.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]=react.useState(e.ownerName),[c,s]=react.useState(""),[d,u]=react.useState([]),[p,f]=react.useState([]),[b,R]=react.useState([]),[v,w]=react.useState(null),[g,y]=react.useState(null),[x,h]=react.useState(false),[P,S]=react.useState(false),[E,C]=react.useState(null),[I,F]=react.useState(null),[q,j]=react.useState(0),$=react.useRef(false),ce=react.useRef(false),oe=react.useRef(0),ve=react.useRef(0),ie=react.useRef(lr()),T=react.useRef(null),D=react.useRef(null);react.useEffect(()=>($.current=true,ce.current=false,h(false),()=>{$.current=false,ve.current+=1,oe.current+=1,T.current=null,D.current?.abort();}),[t,r]),react.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]),react.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(`
|
|
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]=react.useState("draw"),[a,l]=react.useState(""),[c,s]=react.useState([]),[d,u]=react.useState(0),p=react.useRef([]),f=react.useRef(null),b=d>0?Xr.width/d:1,R=react.useRef(b);R.current=b;let v=react.useRef(t);v.current=t,react.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=react.useMemo(()=>reactNative.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=react.useCallback(()=>{v.current||(p.current=[],f.current=null,s([]),l(""));},[]),h=react.useCallback(()=>{x(),n(S=>S==="draw"?"type":"draw");},[x]),P=i(S=>u(S.nativeEvent.layout.width),"onLayout");return jsxRuntime.jsxs(reactNative.View,{style:r.container,testID:"records-signature-pad",children:[jsxRuntime.jsx(m,{style:r.label,children:o==="draw"?K.draw:K.type}),o==="type"?jsxRuntime.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,jsxRuntime.jsx(reactNative.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"?jsxRuntime.jsx(m,{style:r.typedPreview,numberOfLines:1,adjustsFontSizeToFit:true,children:a.trim()}):Ty(c,b).map(S=>{let E=S.length+vo;return jsxRuntime.jsx(reactNative.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)})}),jsxRuntime.jsxs(reactNative.View,{style:r.actions,children:[jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:K.clear,accessibilityState:{disabled:t},disabled:t,onPress:x,style:r.button,children:jsxRuntime.jsx(m,{style:r.buttonLabel,children:K.clear})}),jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:o==="draw"?K.toType:K.toDraw,accessibilityState:{disabled:t},disabled:t,onPress:h,style:r.button,children:jsxRuntime.jsx(m,{style:r.buttonLabel,children:o==="draw"?K.toType:K.toDraw})})]})]})}i(Mr,"SignaturePad");function Py(){let e=V();return react.useMemo(()=>Iy(e),[e])}i(Py,"useStyles");function Iy(e){let{color:t,space:r,radius:o,type:n}=e;return reactNative.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 jsxRuntime.jsx(Ve,{capability:"recordsClinic",...Fe(e.onClose,K.cancel),children:t===null?jsxRuntime.jsx(m,{accessibilityRole:"alert",children:ye.sessionRequired}):jsxRuntime.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]=react.useState(null),l=react.useCallback(async()=>n===null?null:{signaturePngBase64:n},[n]),c=react.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)=>jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:x,accessibilityState:{disabled:y},disabled:y,onPress:g,style:[p,{justifyContent:"center",opacity:y?.5:1}],children:jsxRuntime.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 jsxRuntime.jsxs(reactNative.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:[jsxRuntime.jsx(m,{accessibilityRole:"header",style:[f,{...k(u,"bold"),fontSize:u.type.size.heading}],children:s.outcome?Me.resultTitle:Me.title}),jsxRuntime.jsx(m,{style:f,children:e.petName}),s.outcome?jsxRuntime.jsxs(reactNative.View,{style:{gap:u.space.sm},testID:"records-batch-result",children:[jsxRuntime.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)}),jsxRuntime.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 jsxRuntime.jsxs(reactNative.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:[jsxRuntime.jsx(m,{style:f,children:y}),jsxRuntime.jsx(m,{style:b,children:x}),w.created&&w.request?.statusLabel?jsxRuntime.jsx(m,{style:b,children:w.request.statusLabel}):null,!w.created&&w.failureReason?jsxRuntime.jsx(m,{style:b,children:w.failureReason}):null]},w.idempotencyKey)}),s.group?jsxRuntime.jsx(m,{accessibilityLiveRegion:"polite",style:f,children:Me.responded(s.group.responded,s.group.total)}):null,s.group?.members.map(w=>w.statusLabel?jsxRuntime.jsx(m,{style:b,children:[w.clinicName,w.statusLabel].filter(Boolean).join(": ")},w.id):null)]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(m,{style:f,children:K.ownerName}),jsxRuntime.jsx(He,{accessibilityLabel:K.ownerName,style:p,value:s.ownerName,maxLength:200,editable:!s.busy,autoComplete:"name",onChangeText:s.setOwnerName}),s.drafts.map(w=>jsxRuntime.jsxs(reactNative.View,{style:{gap:u.space.xs},testID:`records-batch-draft-${w.key}`,children:[jsxRuntime.jsx(m,{style:f,children:kn(w)}),Sn(w)?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(m,{style:b,children:w.email.trim()?w.email:Me.emailToAdd}),jsxRuntime.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)),jsxRuntime.jsx(m,{style:f,children:s.atCap?Me.atCap:Me.addClinic}),!s.atCap&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.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&&jsxRuntime.jsx(m,{accessibilityLiveRegion:"polite",style:f,children:ye.loading}),s.recent.length>0&&jsxRuntime.jsx(m,{accessibilityRole:"header",style:f,children:K.recentlyUsed}),s.recent.map(w=>jsxRuntime.jsx(reactNative.View,{children:R([w.name,w.address,w.phone].filter(Boolean).join(", "),()=>s.addClinic(w),s.busy)},`recent-${w.id}`)),s.clinics.map(w=>jsxRuntime.jsx(reactNative.View,{children:R([w.name,w.address,w.phone].filter(Boolean).join(", "),()=>s.addClinic(w),s.busy)},w.id))]}),jsxRuntime.jsx(m,{accessibilityRole:"header",style:f,children:K.scopeHeading}),s.copy?jsxRuntime.jsx(m,{style:f,children:s.drafts.length>0&&s.ownerName.trim()?s.scopeText??N("internalError").displayMessage:ye.consentRequired}):!s.error&&jsxRuntime.jsx(m,{accessibilityLiveRegion:"polite",style:f,children:ye.loading}),!e.onCaptureSignature&&jsxRuntime.jsx(Mr,{onChange:a,disabled:s.busy}),!d&&jsxRuntime.jsx(m,{accessibilityRole:"alert",style:f,children:K.missingSignature}),s.error&&jsxRuntime.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),jsxRuntime.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=zod.z.string().nullish(),wo=zod.z.number().nullish(),Vy=zod.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:zod.z.boolean().nullish()}),qy=zod.z.object({collected_at:Ae,at:Ae,value:wo,unit:Ae,qualitative_result:Ae,status:Ae}),zy=zod.z.object({marker_id:zod.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:zod.z.array(Vy).optional()}),Fy=zod.z.object({total_markers:zod.z.number().int().nonnegative(),in_range_count:zod.z.number().int().nonnegative(),out_of_range_count:zod.z.number().int().nonnegative(),unknown_count:zod.z.number().int().nonnegative()}),Ny=zod.z.object({markers:zod.z.array(zy).optional(),summary:Fy.nullish(),disclaimer:zod.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=zod.z.string().min(1).refine(e=>e.startsWith("https://")),Hy=zod.z.object({source_doc_id:zod.z.string().min(1),file_name:zod.z.string().nullish(),doc_format:zod.z.string().nullish(),byte_size:zod.z.number().int().nonnegative().nullish(),received_at:zod.z.string().nullish(),download_url:By,expires_in_seconds:zod.z.number().int().nonnegative().nullish()}),Uy=zod.z.object({items:zod.z.array(zod.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=zod.z.string().min(1).refine(e=>e.startsWith("https://")),Pn=zod.z.string().nullish(),$y=zod.z.object({share_id:zod.z.string().min(1),share_url:zod.z.string().min(1),expires_at:Pn}),Wy=zod.z.object({shares:zod.z.array(zod.z.object({share_id:zod.z.string().min(1),expires_at:Pn,created_at:Pn,view_count:zod.z.number().int().nonnegative().nullish(),last_viewed_at:Pn})).optional()}),Gy=zod.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=zod.z.object({signatures:zod.z.array(zod.z.object({signature_id:zod.z.string().min(1),preview_url:zod.z.string().min(1).refine(e=>e.startsWith("https://")),created_at:zod.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=zod.z.string().nullish(),In=zod.z.number().nullish(),Qy=zod.z.object({at:U,value:In,unit:U,qualitative_result:U,ref_low:In,ref_high:In,status:U,doc_id:U}),Xy=zod.z.object({marker_id:zod.z.string(),name:zod.z.string(),loinc_code:U,unit:U,panel:U,meaning:U,latest:zod.z.object({at:U,value:In,unit:U,qualitative_result:U,status:U}).nullish(),trajectory:U,points:zod.z.array(Qy).optional()}),Jy=zod.z.object({encounter_id:zod.z.string(),date:U,type:U,clinic_name:U,veterinarian:U,doc_id:U}),Zy=zod.z.object({note_id:zod.z.string(),encounter_id:U,observed_on:U,sections:zod.z.array(zod.z.object({section:zod.z.string(),text:zod.z.string()})).optional()}),ef=zod.z.object({exam_id:zod.z.string(),encounter_id:U,observed_on:U,doc_id:U,systems:zod.z.record(zod.z.object({finding_status:U,finding:U})).optional()}),tf=zod.z.object({has_lab_history:zod.z.boolean().optional(),has_vaccination_history:zod.z.boolean().optional(),has_weight_history:zod.z.boolean().optional(),has_vitals_history:zod.z.boolean().optional(),has_physical_exam_history:zod.z.boolean().optional(),has_procedure_history:zod.z.boolean().optional(),has_genetic_history:zod.z.boolean().optional(),has_reproductive_history:zod.z.boolean().optional(),has_parasite_prevention_history:zod.z.boolean().optional(),earliest_record_at:U,latest_record_at:U,documents_ingested:zod.z.number().int().nonnegative().optional(),documents_in_review:zod.z.number().int().nonnegative().optional(),entities_pending_review:zod.z.record(zod.z.number().int().nonnegative()).optional(),held_total:zod.z.number().int().nonnegative().optional()}),rf=zod.z.object({conflict_id:zod.z.string(),entity_type:zod.z.string(),field:U,severity:U,candidates:zod.z.array(zod.z.object({value:zod.z.string(),source_doc_id:U,doc_id:U,collected_at:U})).optional()}),nf=zod.z.object({lab_results:zod.z.array(Xy).optional(),encounters:zod.z.array(Jy).optional(),clinician_notes:zod.z.array(Zy).optional(),physical_exams:zod.z.array(ef).optional(),completeness:tf.nullish(),conflicts:zod.z.array(rf).optional()}),of=zod.z.object({visits:zod.z.array(zod.z.object({visit_id:zod.z.string(),visit_date:U,veterinarian:U,summary:U,doc_id:U})),vaccines:zod.z.array(zod.z.object({vaccine_id:zod.z.string(),product:U,lot:U,administered_on:U,expires_on:U,doc_id:U})),weights:zod.z.array(zod.z.object({weight_id:zod.z.string(),observed_on:U,weight_kg:In,doc_id:U})),medications:zod.z.array(zod.z.object({medication_id:zod.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:zod.z.string().optional()}),sf=zod.z.object({document:oi,contributions:zod.z.array(ni),contribution_count:zod.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 react.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=react.useMemo(()=>({}),[n,e,o,l]),[s,d]=react.useState({scope:c,value:null,error:null,loading:true}),u=react.useRef(0),p=react.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]);react.useEffect(()=>(p(),()=>{u.current+=1;}),[p]);let f=s.scope===c?s:{value:null,error:null,loading:true},b=react.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 react.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 react.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]=react.useState(false),[u,p]=react.useState(e.ownerName),[f,b]=react.useState(t.email),[R,v]=react.useState(false),[w,g]=react.useState(null),[y,x]=react.useState(null),[h,P]=react.useState(0),[S,E]=react.useState(null),[C,I]=react.useState(false),[F,q]=react.useState(null),[j,$]=react.useState([]),[ce,oe]=react.useState(null),[ve,ie]=react.useState(false),T=react.useRef(false),D=react.useRef(true),L=react.useRef(lr()),B=react.useRef(null);react.useEffect(()=>(D.current=true,()=>{D.current=false,B.current=null;}),[r]),react.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]),react.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=react.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=react.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 jsxRuntime.jsx(Ve,{capability:"recordsClinic",style:e.style,...Fe(e.onBack,Ye),children:t===null?jsxRuntime.jsx(m,{accessibilityRole:"alert",children:ye.sessionRequired}):jsxRuntime.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]=react.useState(null),[g,y]=react.useState("draw"),x=react.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=react.useRef(h);P.current=h;let S=react.useCallback(C=>{w(C),P.current.setSigned(C!==null);},[]),E=h.busy;return jsxRuntime.jsxs(reactNative.View,{style:[u.root,d],children:[jsxRuntime.jsx(Ke,{title:h.title,onBack:s,testID:"records-consent-header"}),jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{behavior:"padding",style:u.body,children:[jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:p.content,keyboardShouldPersistTaps:"handled",testID:"records-consent",children:[jsxRuntime.jsxs(reactNative.View,{style:p.scopeCard,accessibilityRole:"summary",children:[jsxRuntime.jsx(m,{style:p.scopeHeading,accessibilityRole:"header",children:ue.scopeHeading}),jsxRuntime.jsx(m,{style:p.scopeBody,children:ue.scopeBody}),jsxRuntime.jsx(reactNative.View,{style:p.bullets,children:ue.whatWeDo.map(C=>jsxRuntime.jsxs(reactNative.View,{style:p.bulletRow,children:[jsxRuntime.jsx(m,{style:p.check,children:"\u2713"}),jsxRuntime.jsx(m,{style:p.bulletText,children:C})]},C))}),jsxRuntime.jsx(reactNative.View,{style:p.retentionRow,children:jsxRuntime.jsx(m,{style:p.retentionText,children:ue.retentionNote})}),h.copy&&h.scope?jsxRuntime.jsx(m,{style:p.serverScope,testID:"records-consent-scope",children:h.scope}):h.copyError?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(m,{style:u.errorText,accessibilityRole:"alert",children:h.copyError.displayMessage}),jsxRuntime.jsx(X,{label:ye.retry,kind:"outline",onPress:h.retryCopy,testID:"records-consent-copy-retry"})]}):jsxRuntime.jsx(m,{style:u.muted,accessibilityLiveRegion:"polite",children:ye.loading})]}),jsxRuntime.jsxs(reactNative.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:[jsxRuntime.jsx(reactNative.View,{style:[p.box,h.authorized?p.boxChecked:null],accessibilityElementsHidden:true,importantForAccessibility:"no",children:h.authorized?jsxRuntime.jsx(m,{style:p.boxCheck,children:"\u2713"}):null}),jsxRuntime.jsx(m,{style:p.toggleLabel,children:ue.authorizeLabel(t,h.clinicName)})]}),jsxRuntime.jsxs(reactNative.View,{style:p.block,children:[jsxRuntime.jsx(m,{style:u.fieldLabel,children:ue.fullName}),jsxRuntime.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?jsxRuntime.jsxs(reactNative.View,{style:p.block,testID:"records-consent-email-block",children:[h.directoryClinicNoEmail?jsxRuntime.jsx(reactNative.View,{style:u.cautionNote,testID:"records-consent-no-email-note",children:jsxRuntime.jsx(m,{style:u.cautionNoteText,children:ue.noEmailNote(t,h.clinicName)})}):null,jsxRuntime.jsx(m,{style:u.fieldLabel,children:ue.emailLabel}),jsxRuntime.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?jsxRuntime.jsx(m,{style:u.errorText,accessibilityRole:"alert",children:h.emailError}):null,jsxRuntime.jsx(m,{style:u.muted,testID:"records-consent-review-note",children:ue.newClinicDirectSendNote})]}):null,n?null:jsxRuntime.jsxs(reactNative.View,{style:p.signatureBlock,children:[h.signatures.length>0?jsxRuntime.jsxs(reactNative.View,{style:p.block,children:[jsxRuntime.jsx(m,{style:u.fieldLabel,children:ue.reuseSignature}),jsxRuntime.jsx(reactNative.ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,contentContainerStyle:p.gallery,children:h.signatures.map(C=>{let I=h.reuseSignatureId===C.signatureId;return jsxRuntime.jsx(reactNative.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:jsxRuntime.jsx(reactNative.Image,{source:{uri:C.previewUrl},style:p.tileImage,resizeMode:"contain",accessibilityIgnoresInvertColors:true})},C.signatureId)})}),jsxRuntime.jsx(m,{style:u.muted,children:ue.reuseHint})]}):null,jsxRuntime.jsx(reactNative.View,{style:p.signatureHeader,children:jsxRuntime.jsx(m,{style:u.fieldLabel,children:g==="type"?ue.signType:ue.signDraw})}),jsxRuntime.jsx(Mr,{onChange:S,disabled:E}),jsxRuntime.jsx(reactNative.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:jsxRuntime.jsx(m,{style:p.modeToggleText,children:g==="draw"?ue.toType:ue.toDraw})}),jsxRuntime.jsx(m,{style:u.muted,children:ue.signatureHint(h.clinicName)})]}),h.error?jsxRuntime.jsx(reactNative.View,{style:u.errorBanner,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",children:jsxRuntime.jsx(m,{style:u.errorText,children:h.error})}):null,h.created?jsxRuntime.jsx(m,{accessibilityLiveRegion:"polite",style:u.bodyText,children:h.created.statusLabel||ye.records}):null]}),jsxRuntime.jsx(reactNative.View,{style:p.footer,children:jsxRuntime.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"})})]}),jsxRuntime.jsx(qe,{})]})}i(xf,"ConsentBody");function Cf(){let e=V();return react.useMemo(()=>Ef(e),[e])}i(Cf,"useLocalStyles");function Ef(e){let{color:t,space:r,radius:o,type:n}=e,a=reactNative.StyleSheet.hairlineWidth,l=i((c,s,d,u="regular")=>({...k(e,u),fontSize:c,lineHeight:Math.round(c*s),color:d}),"text");return reactNative.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=react.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 jsxRuntime.jsxs(reactNative.View,{style:o.card,accessibilityRole:"summary",testID:r,children:[jsxRuntime.jsx(m,{style:o.title,children:jt.title}),jsxRuntime.jsx(reactNative.View,{style:o.ringRow,accessible:true,accessibilityRole:"image",accessibilityLabel:jt.a11y(a,l,c,s),children:jsxRuntime.jsxs(reactNative.View,{style:o.ringWrap,children:[jsxRuntime.jsx(reactNative.View,{style:o.track}),d===null?null:d.map(p=>jsxRuntime.jsx(Vf,{segment:p,styles:o},p.key)),jsxRuntime.jsxs(reactNative.View,{style:o.center,pointerEvents:"none",children:[jsxRuntime.jsx(m,{style:o.centerCount,children:a}),jsxRuntime.jsx(m,{style:o.centerLabel,children:a===1?jt.marker:jt.markers})]})]})}),u||d===null?jsxRuntime.jsxs(reactNative.View,{style:o.badges,children:[jsxRuntime.jsx(xs,{count:c,label:jt.outOfRange,color:n.color.danger,styles:o}),jsxRuntime.jsx(xs,{count:l,label:jt.inRange,color:n.color.success,styles:o}),s>0?jsxRuntime.jsx(xs,{count:s,label:jt.noRange,color:n.color.text.muted,styles:o}):null]}):null,jsxRuntime.jsx(m,{style:o.subtitle,children:jt.subtitle}),t?jsxRuntime.jsx(reactNative.Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:jt.askA11y,style:o.ask,testID:"marker-summary-ask",children:jsxRuntime.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)=>jsxRuntime.jsx(reactNative.View,{style:[t.piece,{transform:[{rotate:`${o.start}deg`}]}],pointerEvents:"none",testID:`marker-ring-${e.key}`,children:jsxRuntime.jsx(reactNative.View,{style:t.window,children:jsxRuntime.jsx(reactNative.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 jsxRuntime.jsx(reactNative.View,{style:[o.badge,{borderColor:r}],children:jsxRuntime.jsx(m,{style:[o.badgeText,{color:r}],children:`${e} ${t}`})})}i(xs,"Badge");function qf(){let e=V();return react.useMemo(()=>zf(e),[e])}i(qf,"useStyles");function zf(e){let{color:t,space:r,radius:o,type:n,slots:a}=e,l=reactNative.StyleSheet.hairlineWidth,c=at(a.recordCard);return reactNative.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=react.useMemo(()=>rd(e),[e]),u=e.latest?Tt(e.latest.value,e.unit,e.latest.qualitativeResult):null;return jsxRuntime.jsx(reactNative.View,{style:[n.page,t!==void 0?{width:t}:null],testID:`marker-card-${e.markerId}`,children:jsxRuntime.jsxs(reactNative.View,{style:n.card,children:[jsxRuntime.jsxs(reactNative.View,{style:n.headerRow,children:[jsxRuntime.jsxs(reactNative.View,{style:n.nameColumn,children:[jsxRuntime.jsx(m,{style:n.markerName,numberOfLines:2,children:e.name}),e.unit?jsxRuntime.jsx(m,{style:n.unit,children:e.unit}):null]}),jsxRuntime.jsx(reactNative.View,{accessible:true,accessibilityRole:"text",accessibilityLabel:dr.status(l.label),children:jsxRuntime.jsx(kt,{label:l.label,tone:c})})]}),e.latest&&u!==null?jsxRuntime.jsxs(reactNative.View,{style:n.latestRow,children:[jsxRuntime.jsx(m,{style:[n.latestValue,l.outOfRange?n.latestValueDanger:null],accessibilityLabel:dr.latestA11y(u,l.label,J(e.latest.at)),children:u}),jsxRuntime.jsx(m,{style:n.latestDate,children:J(e.latest.at)})]}):null,s?jsxRuntime.jsx(m,{style:n.trajectory,accessibilityRole:"text",children:s}):null,d!==null?jsxRuntime.jsxs(reactNative.View,{style:n.chartWrap,children:[jsxRuntime.jsxs(reactNative.View,{style:n.plot,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:[d.band?jsxRuntime.jsx(reactNative.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=>jsxRuntime.jsx(reactNative.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))]}),jsxRuntime.jsx(reactNative.View,{style:n.a11yTable,accessibilityRole:"summary",accessibilityLabel:dr.readingsA11y(e.name),children:e.points.map((p,f)=>jsxRuntime.jsx(reactNative.View,{accessibilityRole:"text",accessibilityLabel:Nc(e,p)},f))}),jsxRuntime.jsx(m,{style:e.points.length===1?n.singleHint:n.tapHint,children:e.points.length===1?dr.singleHint:dr.tapHint})]}):jsxRuntime.jsx(reactNative.View,{style:n.emptyBody,accessibilityRole:"text",children:jsxRuntime.jsx(m,{style:n.emptyText,children:dr.empty})}),o?jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>o(e),accessibilityRole:"button",accessibilityLabel:dr.askA11y(e.name),style:[a.pill,a.pillAsk],testID:`marker-ask-${e.markerId}`,children:jsxRuntime.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]=react.useState(0),[l,c]=react.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 jsxRuntime.jsxs(reactNative.View,{style:o.carousel,onLayout:s,testID:"marker-carousel",children:[jsxRuntime.jsx(reactNative.ScrollView,{horizontal:true,pagingEnabled:true,showsHorizontalScrollIndicator:false,onMomentumScrollEnd:d,snapToAlignment:"start",children:e.map(p=>jsxRuntime.jsx(Uf,{marker:p,width:n>0?n:void 0,onPointPress:t,onAsk:r},p.markerId))}),jsxRuntime.jsxs(reactNative.View,{style:o.footer,accessible:true,accessibilityRole:"adjustable",accessibilityLabel:Mi.a11y(u?.name??null,l,e.length),children:[jsxRuntime.jsx(reactNative.View,{style:o.dots,children:e.map((p,f)=>jsxRuntime.jsx(reactNative.View,{style:[o.dot,f===l?o.dotActive:null]},p.markerId))}),jsxRuntime.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)=>jsxRuntime.jsxs(reactNative.View,{style:n.detailRow,accessible:true,accessibilityRole:"text",accessibilityLabel:`${c}: ${s}`,children:[jsxRuntime.jsx(m,{style:n.detailLabel,children:c}),jsxRuntime.jsx(m,{style:n.detailValue,children:s})]},c),"row");return jsxRuntime.jsxs(reactNative.Modal,{transparent:true,visible:true,animationType:"slide",onRequestClose:r,children:[jsxRuntime.jsx(reactNative.Pressable,{style:n.backdrop,onPress:r,accessibilityRole:"button",accessibilityLabel:St.close}),jsxRuntime.jsxs(reactNative.View,{style:n.sheet,accessibilityViewIsModal:true,testID:"marker-provenance-sheet",children:[jsxRuntime.jsx(reactNative.View,{style:n.handle}),jsxRuntime.jsxs(reactNative.View,{style:n.sheetHeader,children:[jsxRuntime.jsx(m,{style:n.sheetTitle,accessibilityRole:"header",children:St.title}),jsxRuntime.jsx(reactNative.Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:St.close,hitSlop:10,style:n.closeButton,testID:"marker-provenance-close",children:jsxRuntime.jsx(m,{style:n.closeGlyph,children:"\xD7"})})]}),jsxRuntime.jsxs(reactNative.View,{style:n.sheetBody,children:[jsxRuntime.jsxs(reactNative.View,{style:n.valueRow,children:[jsxRuntime.jsx(m,{style:n.sheetName,children:e.name}),jsxRuntime.jsx(m,{style:n.sheetValue,children:Tt(t.value,e.unit,t.qualitativeResult)})]}),t.reviewed?jsxRuntime.jsx(reactNative.View,{style:n.reviewed,accessibilityRole:"text",children:jsxRuntime.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:jsxRuntime.jsx(m,{style:n.unverified,accessibilityRole:"text",children:St.unverified}),o?jsxRuntime.jsx(reactNative.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:St.askA11y,style:[a.pill,a.pillAsk],testID:"marker-provenance-ask",children:jsxRuntime.jsx(m,{style:a.pillAskLabel,children:St.ask})}):null]})]})]})}i(ad,"MarkerProvenanceSheet");function Cs(){let e=V();return react.useMemo(()=>jf(e),[e])}i(Cs,"useStyles");function jf(e){let{color:t,space:r,radius:o,type:n,slots:a}=e,l=reactNative.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 reactNative.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]=react.useState($f),[l,c]=react.useState(false),[s,d]=react.useState(null),u=react.useMemo(()=>({}),[r,e,o]),[p,f]=react.useState(null),b=react.useCallback(()=>f(u),[u]),R=o!==null&&p!==u,v=react.useRef(false),w=react.useRef(t.newIdempotencyKey);w.current=t.newIdempotencyKey;let g=react.useCallback(()=>(w.current??Wf)(),[]),y=react.useCallback((S,E,C)=>{if(c(false),!S.ok){if(E(),_r(S.error)){b();return}d(pd(S.error,C));}},[b]),x=react.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=react.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=react.useCallback(()=>d(null),[]);return react.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]=react.useState(false),l=e.label.trim()||ct.detail;return jsxRuntime.jsxs(reactNative.View,{style:o.row,children:[jsxRuntime.jsx(reactNative.View,{style:o.main,children:r}),jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>a(true),accessibilityRole:"button",accessibilityLabel:ct.editA11y(l),hitSlop:6,style:o.editButton,testID:`fact-edit-open-${e.canonicalKey??e.key}`,children:jsxRuntime.jsx(reactNative.View,{style:o.pencil,accessibilityElementsHidden:true,importantForAccessibility:"no"})}),n?jsxRuntime.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]=react.useState(e.value??""),[d,u]=react.useState(null),[p,f]=react.useState(false);react.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 jsxRuntime.jsx(reactNative.Modal,{transparent:true,visible:true,animationType:"slide",onRequestClose:o,children:jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{behavior:"padding",style:n.backdrop,children:[jsxRuntime.jsx(reactNative.Pressable,{style:qo,accessibilityRole:"button",accessibilityLabel:ct.closeEditorA11y,onPress:o}),jsxRuntime.jsxs(reactNative.View,{style:n.sheet,accessibilityViewIsModal:true,testID:"fact-edit-sheet",children:[jsxRuntime.jsx(reactNative.View,{style:n.handle}),jsxRuntime.jsxs(reactNative.View,{style:n.header,children:[jsxRuntime.jsxs(reactNative.View,{style:n.headerText,children:[jsxRuntime.jsx(m,{style:n.title,accessibilityRole:"header",children:ct.title(t)}),jsxRuntime.jsx(m,{style:[n.helper,R?n.helperError:null],accessibilityLiveRegion:"polite",children:R??ct.helper})]}),jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:ct.close,onPress:o,hitSlop:12,style:n.closeButton,testID:"fact-edit-close",children:jsxRuntime.jsx(m,{style:n.closeGlyph,children:"\xD7"})})]}),jsxRuntime.jsx(m,{style:a.fieldLabel,children:e.label}),jsxRuntime.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?jsxRuntime.jsxs(reactNative.View,{style:n.confirmBlock,testID:"fact-edit-confirm-remove",children:[jsxRuntime.jsx(m,{style:n.confirmText,children:ct.confirmRemove}),jsxRuntime.jsxs(reactNative.View,{style:n.confirmRow,children:[jsxRuntime.jsx(X,{label:v?ct.removing:ct.removeConfirm,kind:"danger",busy:v,onPress:g,style:n.confirmButton,testID:"fact-edit-remove-confirm"}),jsxRuntime.jsx(X,{label:ct.keep,kind:"outline",disabled:v,onPress:()=>f(false),style:n.confirmButton,testID:"fact-edit-remove-cancel"})]})]}):jsxRuntime.jsxs(reactNative.View,{style:n.actions,children:[jsxRuntime.jsx(X,{label:v?ct.saving:ct.save,busy:v,disabled:!b,onPress:w,testID:"fact-edit-save"}),jsxRuntime.jsx(reactNative.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:jsxRuntime.jsx(m,{style:n.removeText,children:ct.remove})})]})]})]})})}i(ng,"FactEditSheet");function bd(){let e=V();return react.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 reactNative.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=react.useMemo(()=>l?Es(e.entities,l.overlay):e.entities,[e.entities,l]),f=react.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=react.useMemo(()=>gd(p),[p]),R=Object.values(e.documents),v=i((g,y,x)=>a?jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>{let h=g();a(h.prompt,h.entityRef);},accessibilityRole:"button",accessibilityLabel:y,style:[s.pill,s.pillAsk,d.ask],testID:x,children:jsxRuntime.jsx(m,{style:s.pillAskLabel,children:y})}):null,"ask"),w=l!==void 0&&l.available;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(reactNative.View,{style:d.sections,children:[t&&t.conflicts.length>0?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-conflicts",children:[jsxRuntime.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 jsxRuntime.jsxs(reactNative.View,{style:[d.conflictCard,{borderColor:s.chipTones[y.tone].fg.color}],accessibilityRole:"summary",children:[jsxRuntime.jsxs(reactNative.View,{style:d.conflictHead,children:[jsxRuntime.jsx(m,{style:d.conflictTitle,children:y.label}),jsxRuntime.jsx(kt,{label:x,tone:y.tone})]}),jsxRuntime.jsx(m,{style:s.rowDetail,children:Z.conflictSub}),g.candidates.map((h,P)=>jsxRuntime.jsxs(reactNative.View,{style:d.candidate,children:[jsxRuntime.jsx(m,{style:s.rowTitle,children:h.value}),jsxRuntime.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?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-completeness",children:[jsxRuntime.jsx(At,{title:Z.whatsOnFile}),jsxRuntime.jsxs(reactNative.View,{style:s.card,children:[jsxRuntime.jsx(reactNative.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])=>jsxRuntime.jsx(reactNative.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:jsxRuntime.jsx(m,{style:[d.coverageText,y?s.chipTones.positive.fg:{color:s.rowMuted.color}],children:g})},g))}),jsxRuntime.jsxs(reactNative.View,{style:d.metaRow,children:[jsxRuntime.jsx(m,{style:d.metaText,children:Z.documentsOnFile(t.completeness.documentsIngested)}),t.completeness.documentsInReview>0?jsxRuntime.jsx(kt,{label:Z.inReviewChip(t.completeness.documentsInReview),tone:"warning"}):null,_s(t.completeness.heldTotal,t.completeness.entitiesPendingReview)>0?jsxRuntime.jsx(reactNative.View,{accessible:true,accessibilityRole:"text",accessibilityLabel:Z.beingVerifiedA11y(_s(t.completeness.heldTotal,t.completeness.entitiesPendingReview)),children:jsxRuntime.jsx(kt,{label:Z.beingVerified(_s(t.completeness.heldTotal,t.completeness.entitiesPendingReview)),tone:"warning"})}):null]}),t.completeness.earliestRecordAt||t.completeness.latestRecordAt?jsxRuntime.jsx(reactNative.View,{style:d.metaRow,children:jsxRuntime.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?jsxRuntime.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?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-documents",children:[jsxRuntime.jsx(At,{title:Z.documents,count:R.length}),jsxRuntime.jsx(reactNative.View,{style:s.card,children:R.map((g,y)=>{let x=g.title?.trim()||Z.uploadedDocument,h=g.receivedAt?J(g.receivedAt):null,P=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(reactNative.View,{style:s.rowMain,children:[jsxRuntime.jsx(m,{style:s.rowTitle,children:x}),h?jsxRuntime.jsx(m,{style:s.rowDetail,children:h}):null]}),n?jsxRuntime.jsx(rr,{}):null]});return n?jsxRuntime.jsx(reactNative.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):jsxRuntime.jsx(reactNative.View,{style:[s.row,y>0?s.rowDivider:null],children:P},g.docId)})})]}):null,e.identity.length>0?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-identity",children:[jsxRuntime.jsx(At,{title:Z.identity}),jsxRuntime.jsx(reactNative.View,{style:s.card,children:e.identity.map((g,y)=>jsxRuntime.jsxs(reactNative.View,{style:[s.row,y>0?s.rowDivider:null],children:[jsxRuntime.jsx(m,{style:d.identityLabel,children:g.label}),jsxRuntime.jsx(m,{style:d.identityValue,children:g.value})]},`${y}:${g.label}`))})]}):null,e.forwardLooking.length>0?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-upcoming",children:[jsxRuntime.jsx(At,{title:Z.upcomingCare,count:e.forwardLooking.length}),jsxRuntime.jsx(reactNative.View,{style:s.card,children:e.forwardLooking.map((g,y)=>{let x=On(g.dueAt,u);return jsxRuntime.jsxs(reactNative.View,{style:[s.row,y>0?s.rowDivider:null],children:[jsxRuntime.jsxs(reactNative.View,{style:s.rowMain,children:[jsxRuntime.jsx(m,{style:s.rowTitle,children:g.title}),g.detail?jsxRuntime.jsx(m,{style:s.rowDetail,children:g.detail}):null]}),x?jsxRuntime.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?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-vaccination",children:[jsxRuntime.jsx(At,{title:jr("vaccination"),count:b.reduce((g,y)=>g+y.items.length,0)}),b.map(g=>jsxRuntime.jsxs(reactNative.View,{style:d.vaccineGroup,testID:`records-vaccine-group-${g.year}`,children:[jsxRuntime.jsx(m,{style:d.vaccineYear,accessibilityRole:"header",children:g.year.toUpperCase()}),jsxRuntime.jsx(reactNative.View,{style:s.card,children:g.items.map((y,x)=>{let h=jsxRuntime.jsxs(reactNative.View,{style:[s.row,x>0?s.rowDivider:null],children:[jsxRuntime.jsxs(reactNative.View,{style:s.rowMain,children:[jsxRuntime.jsx(m,{style:s.rowTitle,children:y.name}),y.detail?jsxRuntime.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}`)]}),jsxRuntime.jsx(kt,{label:y.statusLabel,tone:fd[y.tone]})]});return w&&Oo(y.entity)&&l?jsxRuntime.jsx(Ts,{entity:y.entity,factEdit:l,children:h},y.key):jsxRuntime.jsx(reactNative.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 jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:`record-section-${g}`,children:[jsxRuntime.jsx(At,{title:x,count:y.length}),jsxRuntime.jsx(reactNative.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=jsxRuntime.jsxs(reactNative.View,{style:[s.row,P>0?s.rowDivider:null],children:[jsxRuntime.jsxs(reactNative.View,{style:s.rowMain,children:[jsxRuntime.jsx(m,{style:s.rowTitle,children:h.label}),E?jsxRuntime.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?jsxRuntime.jsx(kt,{label:ur(h.status)}):null]});return w&&Oo(h)&&l?jsxRuntime.jsx(Ts,{entity:h,factEdit:l,children:C},h.key):jsxRuntime.jsx(reactNative.View,{children:C},h.key)})})]},g)}),t&&t.physicalExams.length>0?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-exams",children:[jsxRuntime.jsx(At,{title:Z.physicalExams,count:t.physicalExams.length}),t.physicalExams.map(g=>jsxRuntime.jsxs(reactNative.View,{style:s.card,children:[jsxRuntime.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 jsxRuntime.jsxs(reactNative.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:[jsxRuntime.jsxs(reactNative.View,{style:s.rowMain,children:[jsxRuntime.jsx(m,{style:s.rowTitle,children:qr(y.system)}),h&&y.finding?jsxRuntime.jsx(m,{style:s.rowDetail,children:y.finding}):null]}),jsxRuntime.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?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-notes",children:[jsxRuntime.jsx(At,{title:Z.visitNotes,count:t.clinicianNotes.length}),t.clinicianNotes.map(g=>jsxRuntime.jsxs(reactNative.View,{style:s.card,children:[jsxRuntime.jsx(m,{style:[s.rowTitle,d.cardTitle],accessibilityRole:"header",children:g.observedOn?J(g.observedOn):be.visitNote}),g.sections.map((y,x)=>jsxRuntime.jsxs(reactNative.View,{style:[d.noteSection,x>0?s.rowDivider:null],children:[jsxRuntime.jsx(m,{style:d.noteLabel,children:Qr(y.section)}),jsxRuntime.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?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-labs",children:[jsxRuntime.jsx(At,{title:Z.labResults,count:t.labResults.length}),jsxRuntime.jsx(reactNative.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 jsxRuntime.jsxs(reactNative.View,{style:[s.row,y>0?s.rowDivider:null],children:[jsxRuntime.jsxs(reactNative.View,{style:s.rowMain,children:[jsxRuntime.jsx(m,{style:s.rowTitle,children:g.name}),jsxRuntime.jsx(m,{style:s.rowValue,children:Tt(g.latest.value,g.latest.unit,g.latest.qualitativeResult)}),h?jsxRuntime.jsx(m,{style:s.rowDetail,children:h}):null]}),jsxRuntime.jsx(kt,{label:x.label,tone:Co(g.latest.status)})]},g.markerId)})})]}):null,t&&t.encounters.length>0?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-visits",children:[jsxRuntime.jsx(At,{title:Z.visits,count:t.encounters.length}),jsxRuntime.jsx(reactNative.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 jsxRuntime.jsx(reactNative.View,{style:[s.row,y>0?s.rowDivider:null],children:jsxRuntime.jsxs(reactNative.View,{style:s.rowMain,children:[jsxRuntime.jsx(m,{style:s.rowTitle,children:g.type?ur(g.type):be.visit}),x?jsxRuntime.jsx(m,{style:s.rowDetail,children:x}):null]})},g.encounterId)})})]}):null]}),jsxRuntime.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 react.useMemo(()=>sg(e),[e])}i(ig,"useLocalStyles");function sg(e){let{color:t,space:r,radius:o,type:n}=e,a=reactNative.StyleSheet.hairlineWidth;return reactNative.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]=react.useState(""),[l,c]=react.useState(false),[s,d]=react.useState(null),[u,p]=react.useState(false),[f,b]=react.useState(null),R=react.useRef(false),v=react.useRef(false),w=react.useRef(0);react.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 jsxRuntime.jsx(reactNative.View,{style:t.container,accessibilityRole:"summary",children:r.map((o,n)=>jsxRuntime.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 jsxRuntime.jsxs(reactNative.View,{style:r.row,accessible:true,accessibilityRole:"text",accessibilityLabel:n.join(", "),testID:`records-timeline-${e.key}`,children:[jsxRuntime.jsxs(reactNative.View,{style:r.railColumn,children:[jsxRuntime.jsx(Ig,{state:e.state,styles:r}),t?null:jsxRuntime.jsx(reactNative.View,{style:[r.connector,e.state==="done"&&r.connectorDone],accessibilityElementsHidden:true,importantForAccessibility:"no"})]}),jsxRuntime.jsxs(reactNative.View,{style:r.body,children:[jsxRuntime.jsxs(reactNative.View,{style:r.titleRow,children:[jsxRuntime.jsx(m,{style:[r.title,e.state==="current"&&r.titleCurrent,e.state==="failed"&&r.titleFailed,e.state==="upcoming"&&r.titleUpcoming],children:e.title}),o?jsxRuntime.jsx(m,{style:r.date,children:o}):null]}),e.detail?jsxRuntime.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"?jsxRuntime.jsx(reactNative.View,{style:[t.dot,t.dotDone],accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsxRuntime.jsx(m,{tier:"badge",style:[t.glyph,t.glyphOnBrand],children:"\u2713"})}):e==="failed"?jsxRuntime.jsx(reactNative.View,{style:[t.dot,t.dotFailed],accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsxRuntime.jsx(m,{tier:"badge",style:t.glyph,children:"!"})}):e==="current"?jsxRuntime.jsx(reactNative.View,{style:[t.dot,t.dotCurrent],accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsxRuntime.jsx(reactNative.View,{style:t.dotCurrentCore})}):jsxRuntime.jsx(reactNative.View,{style:[t.dot,t.dotUpcoming],accessibilityElementsHidden:true,importantForAccessibility:"no"})}i(Ig,"TimelineDot");function Dg(){let e=V();return react.useMemo(()=>Ag(e),[e])}i(Dg,"useStyles");function Ag(e){let{color:t,type:r}=e,{size:o}=r;return reactNative.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.brand,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 jsxRuntime.jsx(Vg,{onGrant:t});case "consent_unavailable":return jsxRuntime.jsx(qg,{});case "session_required":return jsxRuntime.jsx(zg,{});case "withheld":return jsxRuntime.jsx(Fg,{});case "pet_not_found":case "error":return jsxRuntime.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 jsxRuntime.jsxs(reactNative.View,{style:t.timeline,testID:"records-upload-queue",children:[a!==null?jsxRuntime.jsx(m,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",style:t.errorText,children:a}):null,o.length>0?jsxRuntime.jsx(reactNative.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 jsxRuntime.jsxs(reactNative.View,{style:t.uploadRow,testID:`records-upload-file-${l.status}`,children:[jsxRuntime.jsxs(reactNative.View,{style:t.uploadRowHead,children:[jsxRuntime.jsx(m,{style:t.rowLabel,children:l.name??""}),jsxRuntime.jsx(m,{style:t.rowValue,children:xd(l)})]}),l.status==="uploading"?jsxRuntime.jsx(reactNative.View,{style:t.progressTrack,accessibilityRole:"progressbar",accessibilityValue:{min:0,max:100,now:c},children:jsxRuntime.jsx(reactNative.View,{style:[t.progressFill,{width:`${c}%`}]})}):null,l.status==="failed"&&l.error?jsxRuntime.jsx(m,{style:t.timelineMeta,children:l.error.displayMessage}):null]},l.key)})}):null]})}i(Pd,"UploadQueue");function Vg({onGrant:e}){let t=zn();return jsxRuntime.jsx(reactNative.View,{style:t.centered,accessible:true,accessibilityRole:"alert",accessibilityLabel:ye.consentRequired,children:jsxRuntime.jsx(reactNative.Pressable,{onPress:e,accessibilityRole:"button",accessibilityLabel:ye.allow,style:t.primaryButton,children:jsxRuntime.jsx(m,{style:t.primaryLabel,children:ye.allow})})})}i(Vg,"ConsentRequiredState");function Vs({label:e,glyph:t}){let r=zn();return react.useEffect(()=>{reactNative.AccessibilityInfo.announceForAccessibility?.(e);},[e]),jsxRuntime.jsxs(reactNative.View,{style:r.centered,accessible:true,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:e,children:[jsxRuntime.jsx(reactNative.View,{style:t==="withheld"?r.withheldGlyph:r.emptyGlyph}),jsxRuntime.jsx(m,{style:r.errorText,children:e})]})}i(Vs,"AlertState");function qg(){return jsxRuntime.jsx(Vs,{label:ye.consentRequired,glyph:"empty"})}i(qg,"ConsentUnavailableState");function zg(){return jsxRuntime.jsx(Vs,{label:ye.sessionRequired,glyph:"empty"})}i(zg,"SessionRequiredState");function Fg(){return jsxRuntime.jsx(Vs,{label:ye.recordUnavailable,glyph:"withheld"})}i(Fg,"WithheldState");function Ng({error:e,onRetry:t}){let r=zn();return react.useEffect(()=>{reactNative.AccessibilityInfo.announceForAccessibility?.(e.displayMessage);},[e.displayMessage]),jsxRuntime.jsxs(reactNative.View,{style:r.centered,accessible:true,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",children:[jsxRuntime.jsx(m,{style:r.errorText,children:e.displayMessage}),e.retryable?jsxRuntime.jsx(reactNative.Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:ye.retry,style:r.primaryButton,children:jsxRuntime.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 jsxRuntime.jsxs(reactNative.View,{style:r.callCard,accessibilityRole:"summary",children:[jsxRuntime.jsx(m,{style:r.timelineLabel,children:Ln.heading}),jsxRuntime.jsx(m,{style:r.timelineMeta,children:o}),jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>{reactNative.Linking?.openURL?.(e.dial);},accessibilityRole:"button",accessibilityLabel:Ln.callAt(e.phone),style:r.linkButton,testID:"records-call-clinic",children:jsxRuntime.jsx(m,{style:r.linkLabel,children:Ln.call})})]})}i(Id,"ClinicCallCard");function zn(){let e=V();return react.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,reactNative.StyleSheet.hairlineWidth),u=at(a.recordCard),p=i((y,x)=>Math.round(y*x),"lh"),f=reactNative.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 reactNative.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 jsxRuntime.jsx(Ve,{capability:"records",style:t,...r?{renderPending:r}:{},...Fe(o.onBack,Ye),children:jsxRuntime.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=react.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=jsxRuntime.jsx(mo,{testID:"records-list-loading"}):d.status==="error"&&u.length===0?f=jsxRuntime.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=jsxRuntime.jsx(Ue,{variant:"no_requests",testID:"records-list-empty"}):f=jsxRuntime.jsx(reactNative.ScrollView,{contentContainerStyle:s.list,testID:"records-list-results",children:u.map(b=>jsxRuntime.jsx(jg,{request:b,onOpen:o?()=>o({name:"request",requestId:b.id}):void 0,onAsk:p?()=>p(b):void 0},b.id))}),jsxRuntime.jsxs(reactNative.View,{style:[c.root,l],children:[jsxRuntime.jsx(Ke,{title:ft.title,onBack:n,testID:"records-list-header"}),u.length>0?jsxRuntime.jsx(m,{style:s.subtitle,testID:"records-list-subtitle",children:ft.subtitle(t)}):null,jsxRuntime.jsx(reactNative.View,{style:c.body,children:f}),o?jsxRuntime.jsxs(reactNative.View,{style:s.footer,children:[jsxRuntime.jsx(X,{label:ft.requestRecords,accessibilityLabel:ft.requestRecordsA11y,onPress:()=>o({name:"clinicPicker"}),testID:"records-list-new"}),jsxRuntime.jsx(X,{label:ft.uploadOwn,kind:"outline",accessibilityLabel:ft.uploadOwnA11y,onPress:()=>o({name:"upload"}),testID:"records-list-upload-own"})]}):null,jsxRuntime.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=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactNative.View,{style:[n.bubble,o.chipTones[l].bg],accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxRuntime.jsxs(reactNative.View,{style:n.copy,children:[jsxRuntime.jsx(m,{style:n.source,numberOfLines:1,children:a.source}),jsxRuntime.jsx(m,{style:n.meta,numberOfLines:1,children:a.meta}),jsxRuntime.jsx(reactNative.View,{accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsxRuntime.jsx(kt,{label:a.status,tone:l})})]}),t?jsxRuntime.jsx(rr,{}):null]});return jsxRuntime.jsxs(reactNative.View,{style:n.row,testID:`records-request-row-${e.id}`,children:[t?jsxRuntime.jsx(reactNative.Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:a.a11yLabel,style:n.rowInner,testID:`records-request-open-${e.id}`,children:c}):jsxRuntime.jsx(reactNative.View,{style:n.rowInner,accessible:true,accessibilityLabel:a.a11yLabel,children:c}),t&&vs(null,e)!==null?jsxRuntime.jsx(X,{label:Ze.cardTitle,onPress:t,testID:`records-request-resume-upload-${e.id}`}):null,r?jsxRuntime.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:jsxRuntime.jsxs(reactNative.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:a.a11yLabel,style:n.card,testID:"records-requests-status",children:[jsxRuntime.jsx(reactNative.View,{style:[n.cardBubble,a.processing?n.cardBubbleProcessing:null],accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxRuntime.jsxs(reactNative.View,{style:n.cardText,children:[jsxRuntime.jsx(m,{style:n.cardTitle,children:a.title}),jsxRuntime.jsx(m,{style:n.cardSubtitle,children:a.subtitle})]}),jsxRuntime.jsx(rr,{})]})}i(Fn,"RecordsRequestsStatusCard");function zs(){let e=V();return react.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 reactNative.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 jsxRuntime.jsx(Ve,{capability:"records",style:t,...r?{renderPending:r}:{},...Fe(o.onBack,Ye),children:jsxRuntime.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]=react.useState(null),v=react.useCallback((O,se)=>R({marker:O,point:se}),[]),w=react.useMemo(()=>Hr(o,u.consent),[o,u.consent]),g=react.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=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p.markers?.summary?jsxRuntime.jsx(reactNative.View,{style:s.inset,children:jsxRuntime.jsx(td,{summary:p.markers.summary,onAsk:ve,testID:"dashboard-marker-summary"})}):null,jsxRuntime.jsx(m,{style:s.lead,children:yt.lead(t)}),jsxRuntime.jsx(sd,{markers:h,onPointPress:v,onAsk:ie})]}),L=i(O=>n?jsxRuntime.jsxs(reactNative.View,{style:[s.inset,d.actions],children:[O?jsxRuntime.jsx(Wo,{label:yt.viewFullRecord,onPress:()=>n({name:"record"}),testID:"dashboard-full-record-action"}):null,jsxRuntime.jsx(Wo,{label:yt.viewTimeline,onPress:()=>n({name:"timeline"}),testID:"dashboard-timeline-action"}),jsxRuntime.jsx(Wo,{label:ft.allRequests,onPress:()=>n({name:"requests"}),testID:"dashboard-requests-action"})]}):null,"actions"),B=i(O=>n?jsxRuntime.jsxs(reactNative.View,{style:[O?s.inset:null,d.addActions],testID:"dashboard-actions",children:[x?jsxRuntime.jsx(X,{label:$t.requestFromClinic,accessibilityLabel:$t.requestFromClinicA11y(t),onPress:()=>n({name:"clinicPicker"}),style:d.addCta,testID:"dashboard-actions-clinic"}):null,jsxRuntime.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"?jsxRuntime.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=jsxRuntime.jsx(po,{testID:"dashboard-loading"});break;case "record":H=jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:s.contentTight,testID:"dashboard-record",children:[P?D:p.status==="error"?jsxRuntime.jsx(reactNative.View,{style:[s.inset,d.actions],children:jsxRuntime.jsx(Wo,{label:yt.retryMarkers,onPress:$,testID:"dashboard-markers-retry"})}):null,jsxRuntime.jsx(reactNative.View,{style:s.inset,children:u.record?jsxRuntime.jsx(Mo,{record:u.record,depth:ce,petName:t,showLabs:!P,onNavigate:n,onAsk:l}):null}),jsxRuntime.jsx(reactNative.View,{style:s.inset,children:jsxRuntime.jsx(Fn,{requests:C,petName:t,activeOnly:true,onOpen:I})}),B(true),L(true)]});break;case "error":H=jsxRuntime.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=jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:s.content,testID:"dashboard-in-progress",children:[E?jsxRuntime.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,jsxRuntime.jsx(Fn,{requests:C,petName:t,onOpen:I}),B(false),jsxRuntime.jsx(Tr,{disclaimer:j})]});break;case "none":H=jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:s.content,testID:"dashboard-request-prompt",children:[jsxRuntime.jsxs(reactNative.View,{style:d.promptCard,children:[jsxRuntime.jsxs(reactNative.View,{style:d.promptHeader,children:[jsxRuntime.jsx(reactNative.View,{style:d.promptGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxRuntime.jsx(m,{style:d.promptTitle,children:$t.title(t)})]}),jsxRuntime.jsx(m,{style:d.promptBody,children:$t.body}),n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(X,{label:$t.requestFromClinic,accessibilityLabel:$t.requestFromClinicA11y(t),onPress:()=>n({name:"clinicPicker"}),style:d.promptCta,testID:"dashboard-request-prompt-clinic"}),jsxRuntime.jsx(X,{label:$t.uploadDocument,kind:"outline",accessibilityLabel:$t.uploadDocumentA11y(t),onPress:()=>n({name:"upload"}),style:d.promptCtaSecondary,testID:"dashboard-request-prompt-upload"})]}):null]}),jsxRuntime.jsx(Fn,{requests:C,petName:t,onOpen:I}),jsxRuntime.jsx(Tr,{disclaimer:j})]});break;case "labs_only":H=jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:s.contentTight,testID:"dashboard-labs-only",children:[D,jsxRuntime.jsx(reactNative.View,{style:s.inset,children:jsxRuntime.jsx(Fn,{requests:C,petName:t,activeOnly:true,onOpen:I})}),B(true),jsxRuntime.jsx(reactNative.View,{style:s.inset,children:jsxRuntime.jsx(Tr,{disclaimer:j})}),L(false)]});break;default:H=vr(q);}return jsxRuntime.jsxs(reactNative.View,{style:[s.root,c],children:[jsxRuntime.jsx(Ke,{title:yt.title,onBack:a,testID:"dashboard-header",right:n?jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>n({name:"timeline"}),accessibilityRole:"button",accessibilityLabel:yt.openTimeline,hitSlop:12,style:d.headerButton,testID:"dashboard-timeline-link",children:jsxRuntime.jsx(zl,{})}):void 0}),jsxRuntime.jsx(reactNative.View,{style:s.body,children:H}),jsxRuntime.jsx(ad,{marker:b?.marker??null,point:b?.point??null,onClose:()=>R(null),onAsk:T}),jsxRuntime.jsx(qe,{})]})}i(Xg,"DashboardBody");function Wo({label:e,onPress:t,testID:r}){let o=Bs();return jsxRuntime.jsxs(reactNative.Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:e,style:o.actionRow,testID:r,children:[jsxRuntime.jsxs(reactNative.View,{style:o.actionLeft,children:[jsxRuntime.jsx(reactNative.View,{style:o.actionIcon,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxRuntime.jsx(m,{style:o.actionLabel,children:e})]}),jsxRuntime.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=jsxRuntime.jsxs(reactNative.View,{style:a.inProgressInner,children:[jsxRuntime.jsxs(reactNative.View,{style:a.inProgressHead,children:[jsxRuntime.jsx(m,{style:a.inProgressTitle,children:l}),r?jsxRuntime.jsx(rr,{}):null]}),jsxRuntime.jsx(jo,{request:e}),c.length>0?jsxRuntime.jsx(reactNative.View,{style:n.statusCard,children:jsxRuntime.jsx(m,{style:n.statusText,children:c})}):null]});return jsxRuntime.jsxs(reactNative.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?jsxRuntime.jsx(reactNative.Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:kr.openA11y(t,c),testID:"dashboard-in-progress-open",children:s}):s,o?jsxRuntime.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 react.useMemo(()=>Zg(e),[e])}i(Bs,"useLocalStyles");function Zg(e){let{color:t,space:r,radius:o,type:n}=e,a=reactNative.StyleSheet.hairlineWidth,l=r.xxl+r.md;return reactNative.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 jsxRuntime.jsx(Bd,{state:o,style:t,onBack:r,header:jsxRuntime.jsx(Ke,{title:be.timeline,onBack:yn(r),testID:"timeline-header"}),loading:jsxRuntime.jsx(Ql,{testID:"timeline-loading"}),empty:jsxRuntime.jsx(Ue,{variant:"no_records",testID:"timeline-empty"}),render:n=>jsxRuntime.jsx(ub,{timeline:n})})}i(Nd,"EverfurRecordsTimeline");function Md({petRef:e,docId:t,style:r,onBack:o}){let n=react.useCallback((c,s)=>c.getDocumentContributions(s,t),[t]),a=Yt(e,n,lb,t),l=a.value?.document?.title?.trim()||be.uploadedDocument;return jsxRuntime.jsx(Bd,{state:a,style:r,onBack:o,header:jsxRuntime.jsx(Ke,{title:l,onBack:yn(o),testID:"contributions-header"}),empty:jsxRuntime.jsx(Ue,{variant:"no_records",testID:"contributions-empty"}),render:c=>jsxRuntime.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 jsxRuntime.jsx(Ve,{capability:"records",style:t,...Fe(yn(l),Ye),children:jsxRuntime.jsxs(reactNative.View,{style:[c.container,t],children:[r??null,jsxRuntime.jsx(reactNative.View,{style:c.body,children:cb(e,a,c,o,n)}),jsxRuntime.jsx(qe,{})]})})}i(Bd,"DepthSurface");function cb(e,t,r,o,n){switch(e.status){case "loading":return o??jsxRuntime.jsx(db,{styles:r});case "empty":return n??jsxRuntime.jsx(reactNative.View,{style:r.centered,accessible:true,accessibilityRole:"summary",accessibilityLabel:ye.empty,children:jsxRuntime.jsx(reactNative.View,{style:r.emptyGlyph})});case "error":return e.error?jsxRuntime.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]=react.useState(false);return react.useEffect(()=>{let o=setTimeout(()=>r(true),ib);return ()=>clearTimeout(o)},[]),jsxRuntime.jsx(reactNative.View,{style:e.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:ye.loading,children:t?jsxRuntime.jsx(reactNative.ActivityIndicator,{}):null})}i(db,"LoadingState");function ub({timeline:e}){let t=Hs(),r=qd(e);return jsxRuntime.jsxs(reactNative.ScrollView,{style:t.list,contentContainerStyle:t.timelineContent,accessibilityLabel:be.timeline,children:[e.disclaimer.length>0?jsxRuntime.jsx(reactNative.View,{style:t.timelineBand,accessible:true,accessibilityRole:"text",accessibilityLabel:yt.important(e.disclaimer),children:jsxRuntime.jsx(m,{style:t.timelineBandText,children:e.disclaimer})}):null,r.map((o,n)=>jsxRuntime.jsxs(reactNative.View,{children:[n>0?jsxRuntime.jsx(reactNative.View,{style:t.timelineSeparator}):null,jsxRuntime.jsxs(reactNative.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:[jsxRuntime.jsx(reactNative.View,{style:t.timelineBubble,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxRuntime.jsxs(reactNative.View,{style:t.timelineBody,children:[jsxRuntime.jsxs(reactNative.View,{style:t.topLine,children:[jsxRuntime.jsx(m,{style:t.timelineKind,children:o.kindLabel}),jsxRuntime.jsx(m,{style:t.date,children:o.date})]}),jsxRuntime.jsx(m,{style:t.timelineTitle,children:o.title}),o.detail?jsxRuntime.jsx(m,{style:t.rowDetail,children:o.detail}):null]})]})]},o.key))]})}i(ub,"TimelineBody");function pb({view:e}){let t=Hs();return jsxRuntime.jsxs(reactNative.ScrollView,{style:t.list,contentContainerStyle:t.listContent,accessibilityLabel:ye.records,children:[e.document?.receivedAt?jsxRuntime.jsx(m,{style:t.rowDetail,children:J(e.document.receivedAt)}):null,jsxRuntime.jsx(reactNative.View,{style:t.card,children:e.contributions.map(r=>jsxRuntime.jsxs(reactNative.View,{style:t.row,accessible:true,accessibilityRole:"text",children:[jsxRuntime.jsx(m,{style:t.rowTitle,children:r.label}),jsxRuntime.jsx(m,{style:t.rowValue,children:Yr(r.value,r.unit)}),r.observedAt?jsxRuntime.jsx(m,{style:t.rowDetail,children:J(r.observedAt)}):null]},r.key))})]})}i(pb,"ContributionsBody");function Hs(){let e=V();return react.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=reactNative.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 reactNative.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]=react.useState(null),[c,s]=react.useState(true),[d,u]=react.useState(null),[p,f]=react.useState(null),b=p===true,[R,v]=react.useState({}),[w,g]=react.useState(false),[y,x]=react.useState(null),[h,P]=react.useState(false),[S,E]=react.useState(false),C=Wn(e),I=react.useRef(0),F=react.useRef(true),q=react.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]);react.useEffect(()=>(F.current=true,q(),()=>{F.current=false,I.current+=1;}),[q]);let j=react.useRef(C);react.useEffect(()=>{j.current!==C&&(j.current=C,v({}),E(true),q());},[C,q]);let $=react.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=react.useCallback(async D=>{x(D);let L=await r.revokeShare(e,D);return F.current&&(x(null),q()),L},[r,e,q]),oe=react.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=react.useCallback(()=>{E(false),q();},[q]),ie=react.useMemo(()=>Wl(a??[],R,n()),[a,R,n]),T=c?"loading":d!==null?"error":ie.length===0?"empty":"populated";return react.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=react.useMemo(()=>({}),[t,e,r]),[n,a]=react.useState({scope:o,lit:null});react.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 react.useMemo(()=>({lit:l}),[l])}i(js,"useRecordsDepthProbe");function $s(e){let t=yr(),o=js(e).lit===true,[n,a]=react.useState(false),[l,c]=react.useState(null),s=react.useRef(true);react.useEffect(()=>(s.current=true,()=>{s.current=false;}),[]);let d=react.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 react.useMemo(()=>({preparing:n,available:o,error:l,pdfLink:d}),[n,o,l,d])}i($s,"useRecordPdfLink");async function $d(e){await reactNative.Share.share({message:ae.shareMessage(e),url:e});}i($d,"shareLinkViaOs");async function Qo(e){await reactNative.Share.share(reactNative.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 jsxRuntime.jsx(Ve,{capability:"records",style:t,...r?{renderPending:r}:{},...Fe(o.onBack,Ye),children:jsxRuntime.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=react.useMemo(()=>Hr(o,u.consent),[o,u.consent]),R=react.useMemo(()=>nn(u,o),[u,o]),v=p.value!==null&&!p.value.withheld&&p.value.available?p.value:null,w=u.record,[g,y]=react.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=jsxRuntime.jsx(reactNative.View,{style:s.centered,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:yt.loading,testID:"record-document-loading",children:jsxRuntime.jsx(reactNative.ActivityIndicator,{color:d.color.brandInk})});else if(u.status==="error"){let S=Pr(u,b);h=S.kind==="error"||S.kind==="pet_not_found"?jsxRuntime.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=jsxRuntime.jsx(reactNative.View,{style:s.centered,testID:"record-document-empty",children:jsxRuntime.jsx(m,{style:s.emptyText,children:It.empty})}):(P=true,h=jsxRuntime.jsx(xb,{record:w,depth:v,petName:t,wordmark:d.meta.displayName}));return jsxRuntime.jsxs(reactNative.View,{style:[c.root,s.root,l],children:[jsxRuntime.jsx(Ke,{title:It.title,variant:"document",onBack:n,testID:"record-document-header",right:f.available&&P?jsxRuntime.jsx(reactNative.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?jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:d.color.brandInk}):jsxRuntime.jsx(Ml,{})}):void 0}),f.error?jsxRuntime.jsx(m,{style:[c.errorText,s.inset],accessibilityRole:"alert",children:f.error.displayMessage}):g?jsxRuntime.jsx(m,{style:[c.errorText,s.inset],accessibilityRole:"alert",testID:"record-document-share-failed",children:ae.toasts.pdfShareSheet}):null,jsxRuntime.jsx(reactNative.View,{style:c.body,children:h}),jsxRuntime.jsx(qe,{})]})}i(wb,"DocumentBody");function xb({record:e,depth:t,petName:r,wordmark:o}){let n=Kd(),a=react.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)=>jsxRuntime.jsxs(reactNative.View,{style:n.section,testID:u,children:[jsxRuntime.jsxs(reactNative.View,{style:n.sectionHeader,children:[jsxRuntime.jsx(m,{style:n.sectionTitle,accessibilityRole:"header",children:s}),jsxRuntime.jsx(reactNative.View,{style:n.rule})]}),jsxRuntime.jsx(reactNative.View,{children:d})]},u),"section");return jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:n.page,showsVerticalScrollIndicator:false,testID:"record-document",children:[jsxRuntime.jsxs(reactNative.View,{style:n.letterhead,children:[jsxRuntime.jsx(m,{style:n.wordmark,children:o}),jsxRuntime.jsx(m,{style:n.docTitle,children:It.docTitle}),jsxRuntime.jsx(m,{style:n.petName,children:r?.trim()||It.namelessPet}),jsxRuntime.jsx(m,{style:n.generated,children:It.generated(e.generatedAt)})]}),e.identity.length>0?c(It.identity,e.identity.map((s,d)=>jsxRuntime.jsxs(reactNative.View,{style:[n.row,d>0?n.rowDivider:null],children:[jsxRuntime.jsx(m,{style:n.rowLabel,children:s.label}),jsxRuntime.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 jsxRuntime.jsxs(reactNative.View,{style:[n.row,u.outOfRange?n.rowFlag:null,d>0?n.rowDivider:null],children:[jsxRuntime.jsxs(reactNative.View,{style:n.rowMain,children:[jsxRuntime.jsx(m,{style:n.rowLabel,children:s.name}),jsxRuntime.jsxs(m,{style:n.rowMeta,children:[p?It.ref(p):It.noRange,s.latest.at?` \xB7 ${J(s.latest.at)}`:""]})]}),jsxRuntime.jsxs(reactNative.View,{style:n.rowRight,children:[f!=="-"?jsxRuntime.jsx(m,{style:[n.rowValue,u.outOfRange?n.rowValueAlert:null],children:f}):null,jsxRuntime.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 jsxRuntime.jsx(reactNative.View,{style:[n.row,p>0?n.rowDivider:null],children:jsxRuntime.jsxs(reactNative.View,{style:n.rowMain,children:[jsxRuntime.jsx(m,{style:n.rowLabel,children:u.label}),f?jsxRuntime.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 jsxRuntime.jsxs(reactNative.View,{style:[n.row,d>0?n.rowDivider:null],children:[jsxRuntime.jsxs(reactNative.View,{style:n.rowMain,children:[jsxRuntime.jsx(m,{style:n.rowLabel,children:s.title}),s.detail?jsxRuntime.jsx(m,{style:n.rowMeta,children:s.detail}):null]}),u?jsxRuntime.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)=>jsxRuntime.jsxs(reactNative.View,{style:[n.block,d>0?n.rowDivider:null],children:[s.observedOn?jsxRuntime.jsx(m,{style:n.blockDate,children:J(s.observedOn)}):null,s.systems.filter(u=>u.finding).map(u=>jsxRuntime.jsxs(reactNative.View,{style:n.fieldRow,children:[jsxRuntime.jsx(m,{style:n.fieldLabel,children:qr(u.system)}),jsxRuntime.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)=>jsxRuntime.jsxs(reactNative.View,{style:[n.block,d>0?n.rowDivider:null],children:[s.observedOn?jsxRuntime.jsx(m,{style:n.blockDate,children:J(s.observedOn)}):null,s.sections.filter(u=>u.text).map((u,p)=>jsxRuntime.jsxs(reactNative.View,{style:n.noteSection,children:[jsxRuntime.jsx(m,{style:n.noteLabel,children:Qr(u.section)}),jsxRuntime.jsx(m,{style:n.noteBody,children:u.text})]},`${u.section}-${p}`))]},s.noteId)),"record-document-notes"):null,e.disclaimer.length>0?jsxRuntime.jsx(reactNative.View,{style:n.disclaimer,children:jsxRuntime.jsx(m,{style:n.disclaimerText,children:e.disclaimer})}):null]})}i(xb,"RecordDocument");function Kd(){let e=V();return react.useMemo(()=>Cb(e),[e])}i(Kd,"useLocalStyles");function Cb(e){let{color:t,space:r,radius:o,type:n}=e,a=reactNative.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 reactNative.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.brand,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]=react.useState(null),[u,p]=react.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 jsxRuntime.jsx(reactNative.Modal,{transparent:true,visible:true,animationType:"slide",onRequestClose:t,children:jsxRuntime.jsxs(reactNative.View,{style:a.backdrop,children:[jsxRuntime.jsx(reactNative.Pressable,{style:qo,accessibilityRole:"button",accessibilityLabel:ae.closeSheetA11y,onPress:t}),jsxRuntime.jsxs(reactNative.View,{style:a.sheet,accessibilityViewIsModal:true,testID:"share-record-sheet",children:[jsxRuntime.jsx(reactNative.View,{style:a.handle}),jsxRuntime.jsxs(reactNative.View,{style:a.header,children:[jsxRuntime.jsxs(reactNative.View,{style:a.headerText,children:[jsxRuntime.jsx(m,{style:a.title,accessibilityRole:"header",children:ae.title}),jsxRuntime.jsx(m,{style:a.helper,children:ae.helper})]}),jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:ae.close,onPress:t,hitSlop:12,style:a.closeButton,testID:"share-record-close",children:jsxRuntime.jsx(m,{style:a.closeGlyph,children:"\xD7"})})]}),jsxRuntime.jsxs(reactNative.ScrollView,{style:a.scroll,contentContainerStyle:a.body,showsVerticalScrollIndicator:false,children:[jsxRuntime.jsxs(reactNative.View,{style:a.actions,children:[r?jsxRuntime.jsx(X,{label:ae.viewDocument,onPress:()=>{t(),r({name:"document"});},testID:"share-view-document"}):null,f?jsxRuntime.jsx(X,{label:c.creating?ae.creatingLink:ae.createLink,kind:"outline",busy:c.creating,onPress:R,testID:"share-create-link"}):null,f?jsxRuntime.jsx(X,{label:c.preparingPdf?ae.preparingPdf:ae.downloadPdf,kind:"outline",busy:c.preparingPdf,onPress:v,testID:"share-download-pdf"}):null]}),c.consentRequired?jsxRuntime.jsxs(reactNative.View,{style:a.stateCard,testID:"share-consent-off",children:[jsxRuntime.jsx(m,{style:a.stateTitle,accessibilityRole:"header",children:ae.consentOffTitle}),jsxRuntime.jsx(m,{style:a.stateBody,children:ae.consentOffBody}),jsxRuntime.jsx(X,{label:ae.retry,kind:"outline",onPress:c.refresh,testID:"share-consent-retry"})]}):null,s?jsxRuntime.jsx(m,{style:a.notice,accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"share-notice",children:s}):null,Ud(c)?jsxRuntime.jsxs(reactNative.View,{style:a.section,children:[jsxRuntime.jsx(m,{style:a.sectionLabel,accessibilityRole:"header",children:ae.activeLinks}),c.status==="loading"?jsxRuntime.jsx(Jl,{testID:"share-record-loading"}):c.status==="error"?jsxRuntime.jsxs(reactNative.View,{style:a.stateCard,testID:"share-record-error",children:[jsxRuntime.jsx(m,{style:a.stateTitle,children:ae.errorTitle}),jsxRuntime.jsx(m,{style:a.stateBody,children:ae.errorBody}),jsxRuntime.jsx(X,{label:ae.retry,kind:"outline",onPress:c.refresh,testID:"share-record-retry"})]}):c.rows.length===0?jsxRuntime.jsxs(reactNative.View,{style:a.stateCard,testID:"share-record-empty",children:[jsxRuntime.jsx(m,{style:a.stateTitle,children:ae.emptyTitle}),jsxRuntime.jsx(m,{style:a.stateBody,children:ae.emptyBody})]}):jsxRuntime.jsx(reactNative.View,{style:a.list,children:c.rows.map(y=>jsxRuntime.jsxs(reactNative.View,{style:a.row,testID:`share-row-${y.shareId}`,children:[jsxRuntime.jsxs(reactNative.View,{accessible:true,accessibilityRole:"text",accessibilityLabel:y.a11yLabel,children:[jsxRuntime.jsxs(reactNative.View,{style:a.statusLine,children:[jsxRuntime.jsx(reactNative.View,{style:[a.statusDot,{backgroundColor:y.active?a.active.color:a.inactive.color}],accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxRuntime.jsx(m,{style:a.status,children:y.statusLabel}),jsxRuntime.jsx(m,{style:a.expiry,children:y.expiryLabel})]}),y.createdLabel?jsxRuntime.jsx(m,{style:a.created,children:y.createdLabel}):null]}),y.shareUrl!==null&&!n?jsxRuntime.jsx(m,{selectable:true,style:a.url,testID:`share-url-${y.shareId}`,children:y.shareUrl}):null,u===y.shareId?jsxRuntime.jsxs(reactNative.View,{style:a.confirm,testID:`share-revoke-confirm-${y.shareId}`,children:[jsxRuntime.jsx(m,{style:a.confirmText,children:ae.confirmTurnOff}),jsxRuntime.jsxs(reactNative.View,{style:a.rowActions,children:[jsxRuntime.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}`}),jsxRuntime.jsx(X,{label:ae.keep,kind:"outline",disabled:c.revokingId===y.shareId,onPress:()=>p(null),testID:`share-revoke-cancel-${y.shareId}`})]})]}):jsxRuntime.jsxs(reactNative.View,{style:a.rowActions,children:[n?jsxRuntime.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,jsxRuntime.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]}),jsxRuntime.jsx(reactNative.View,{style:l.inset})]})]})})}i(Zd,"ShareSheet");function Tb(){let e=V();return react.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=reactNative.StyleSheet.hairlineWidth,c=i((s,d,u,p="regular")=>({...k(e,p),fontSize:s,lineHeight:Math.round(s*d),color:u}),"text");return reactNative.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 jsxRuntime.jsx(Ve,{capability:"records",style:t,...r?{renderPending:r}:{},...Fe(o.onBack,Ye),children:jsxRuntime.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]=react.useState(false),y=react.useMemo(()=>Hr(o,f.consent),[o,f.consent]),x=react.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=jsxRuntime.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"?jsxRuntime.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=jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:u.content,testID:"everfur-record-empty",children:[jsxRuntime.jsx(Ue,{variant:"no_records",message:I>0?Z.inReview(I):void 0}),jsxRuntime.jsx(Tr,{disclaimer:P?.disclaimer??""})]});}else C=jsxRuntime.jsx(reactNative.ScrollView,{contentContainerStyle:p.content,testID:"everfur-record",children:jsxRuntime.jsx(Mo,{record:P,depth:h,petName:t,onNavigate:n,onAsk:l,factEdit:R})});return jsxRuntime.jsxs(reactNative.View,{style:[u.root,d],children:[jsxRuntime.jsx(Ke,{title:Z.title,onBack:a,testID:"everfur-record-header",right:E||n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n?jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>n({name:"clinicBatch"}),accessibilityRole:"button",accessibilityLabel:Z.requestClinicsA11y,hitSlop:8,style:p.share,testID:"everfur-record-request-clinics",children:jsxRuntime.jsx(Nl,{})}):null,E?jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>g(true),accessibilityRole:"button",accessibilityLabel:Z.shareA11y,hitSlop:8,style:p.share,testID:"everfur-record-share",children:jsxRuntime.jsx(Fl,{})}):null]}):void 0}),jsxRuntime.jsx(reactNative.View,{style:u.body,children:C}),w?jsxRuntime.jsx(Zd,{petRef:e,onClose:()=>g(false),onNavigate:n,...c?{onOpenUrl:c}:{},...s?{onCopy:s}:{}}):null,jsxRuntime.jsx(qe,{})]})}i(Ob,"RecordBody");function Lb(){let e=V();return react.useMemo(()=>Vb(e),[e])}i(Lb,"useLocalStyles");function Vb(e){let{space:t,radius:r}=e;return reactNative.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]=react.useState(false),a=react.useCallback(()=>{n(true),e().finally(()=>n(false));},[e]);return jsxRuntime.jsx(reactNative.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 jsxRuntime.jsx(Ve,{capability:"records",style:t,...r?{renderPending:r}:{},...Fe(o.onBack,Ye),children:jsxRuntime.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 jsxRuntime.jsxs(reactNative.View,{style:[s.root,c],children:[jsxRuntime.jsx(Ke,{title:"",onBack:l,testID:"upload-header"}),jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:d.content,testID:"upload-screen",children:[jsxRuntime.jsxs(reactNative.View,{style:d.header,children:[jsxRuntime.jsx(reactNative.View,{style:d.iconBubble,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxRuntime.jsx(m,{style:d.title,accessibilityRole:"header",children:Ze.title(t)}),jsxRuntime.jsx(m,{style:d.subtitle,children:Ze.subtitle(t)})]}),jsxRuntime.jsx(Js,{records:p,requestId:null,onPickDocument:o,canUpload:f,onDone:a?b=>a({name:"request",requestId:b}):void 0})]}),jsxRuntime.jsx(qe,{})]})}i(Ub,"UploadBody");function Js({records:e,requestId:t,onPickDocument:r,canUpload:o,onDone:n}){let a=me(),l=au(),[c,s]=react.useState(null),[d,u]=react.useState(0),p=react.useRef(t),f=react.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=react.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=react.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=react.useCallback(()=>{g(f.current);},[g]);return jsxRuntime.jsxs(reactNative.View,{style:l.card,testID:"records-upload-card",children:[jsxRuntime.jsx(m,{style:l.cardTitle,accessibilityRole:"header",children:Ze.cardTitle}),jsxRuntime.jsx(m,{style:l.cardSubtitle,children:Ze.cardSubtitle}),c?jsxRuntime.jsx(reactNative.View,{style:a.errorBanner,accessibilityRole:"alert",children:jsxRuntime.jsx(m,{style:a.errorText,children:c})}):null,jsxRuntime.jsx(Pd,{records:e}),e.isUploading?jsxRuntime.jsx(reactNative.View,{style:l.uploadingRow,children:jsxRuntime.jsx(m,{style:l.progressText,children:Ze.uploading(R,b.length)})}):w?jsxRuntime.jsxs(reactNative.View,{style:l.settled,children:[R>0?jsxRuntime.jsx(m,{style:l.success,accessibilityRole:"alert",children:Ze.received(R)}):null,v>0?jsxRuntime.jsx(X,{label:Ze.retryFailed(v),kind:"link",accessibilityLabel:Ze.retryFailedA11y(v),onPress:x,testID:"records-upload-retry-failed"}):null,jsxRuntime.jsxs(reactNative.View,{style:l.settledActions,children:[jsxRuntime.jsx(X,{label:Ze.addMore,kind:"link",accessibilityLabel:Ze.addMoreA11y,disabled:!o,onPress:y,testID:"records-upload-another"}),n&&p.current!==null&&R>0?jsxRuntime.jsx(X,{label:Ze.done,accessibilityLabel:Ze.doneA11y,onPress:()=>n(p.current),testID:"records-upload-done"}):null]})]}):jsxRuntime.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 react.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 reactNative.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:reactNative.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 jsxRuntime.jsx(Ve,{capability:"records",style:t,...r?{renderPending:r}:{},...Fe(o.onBack,Ye),children:jsxRuntime.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=jsxRuntime.jsx(mo,{testID:"records-request-loading"}):b.status==="error"&&b.error?y=jsxRuntime.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=jsxRuntime.jsx(Ue,{variant:"no_requests",testID:"records-request-missing"}):p===null?y=jsxRuntime.jsx(Ue,{variant:"error",testID:"records-request-error"}):y=jsxRuntime.jsx(Jb,{request:R,records:b,canUpload:v,onPickDocument:o,onNavigate:a,nowMs:s,refreshControl:g},JSON.stringify([p,f,R.id])),jsxRuntime.jsxs(reactNative.View,{style:[d.root,c],children:[jsxRuntime.jsx(Ke,{title:w,onBack:l,testID:"records-request-header"}),jsxRuntime.jsx(reactNative.KeyboardAvoidingView,{behavior:"padding",style:d.body,children:y}),jsxRuntime.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]=react.useState(null),[b,R]=react.useState(false),[v,w]=react.useState(null),g=react.useRef(true);react.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 jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:s.content,keyboardShouldPersistTaps:"handled",refreshControl:l,testID:`records-request-${y.id}`,children:[jsxRuntime.jsx(jo,{request:y}),y.status==="awaiting_upload"?jsxRuntime.jsx(Js,{records:t,requestId:y.id,onPickDocument:o,canUpload:r}):null,y.statusLabel.length>0?jsxRuntime.jsx(reactNative.View,{style:c.statusCard,accessibilityRole:"summary",children:jsxRuntime.jsx(m,{style:c.statusText,children:y.statusLabel})}):null,F&&!C?jsxRuntime.jsx(reactNative.View,{style:c.infoNote,accessibilityRole:"summary",children:jsxRuntime.jsx(m,{style:c.infoNoteText,children:F})}):y.wireStatus==="awaiting_response"&&!C?jsxRuntime.jsx(reactNative.View,{style:c.infoNote,accessibilityRole:"summary",children:jsxRuntime.jsx(m,{style:c.infoNoteText,children:he.awaitingNote})}):null,C?jsxRuntime.jsx(reactNative.View,{style:c.cautionNote,accessibilityRole:"summary",testID:"records-request-waiting-banner",children:jsxRuntime.jsx(m,{style:c.cautionNoteText,children:he.waitingBanner(I)})}):null,h&&n?jsxRuntime.jsx(X,{label:he.viewRecords,onPress:()=>n({name:"dashboard"}),style:s.readyCta,testID:"records-request-view-dashboard"}):null,j?jsxRuntime.jsxs(reactNative.View,{style:[s.failureCard,S?s.failureCritical:s.failureCaution],accessibilityRole:"summary",testID:"records-failure-card",children:[jsxRuntime.jsx(m,{style:[s.failureTitle,S?s.failureTitleCritical:s.failureTitleCaution],children:il(y)}),y.canUpdateClinicEmail!==true&&y.canRetrySend!==true?jsxRuntime.jsx(m,{style:c.rowDetail,children:he.nextStep}):null,y.canUpdateClinicEmail===true?jsxRuntime.jsxs(reactNative.View,{style:s.emailBlock,children:[jsxRuntime.jsx(m,{style:c.fieldLabel,children:zt.email}),jsxRuntime.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?jsxRuntime.jsx(m,{style:c.errorText,accessibilityRole:"alert",children:he.errors.invalidEmail}):null,jsxRuntime.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?jsxRuntime.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?jsxRuntime.jsx(m,{style:c.rowDetail,children:zt.retryHint}):null,oe&&(p==="email"||p==="retry")?jsxRuntime.jsx(reactNative.View,{style:c.errorBanner,accessibilityRole:"alert",children:jsxRuntime.jsx(m,{style:c.errorText,children:oe})}):null]}):null,(S||E)&&n?jsxRuntime.jsx(X,{label:he.tryAnotherClinic,kind:"outline",accessibilityLabel:he.tryAnotherClinicA11y,onPress:()=>n({name:"clinicPicker"}),testID:"records-request-try-another-clinic"}):null,q!==null?jsxRuntime.jsxs(reactNative.View,{style:s.callBlock,children:[jsxRuntime.jsx(Id,{call:q,prompt:y.statusLabel}),y.canRetrySend===true?jsxRuntime.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,$?jsxRuntime.jsxs(reactNative.View,{style:s.block,children:[jsxRuntime.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"}),jsxRuntime.jsx(m,{style:c.muted,children:he.convertHint}),oe&&p==="convert"?jsxRuntime.jsx(reactNative.View,{style:c.errorBanner,accessibilityRole:"alert",children:jsxRuntime.jsx(m,{style:c.errorText,children:oe})}):null]}):null,ce?jsxRuntime.jsxs(reactNative.View,{style:s.block,children:[jsxRuntime.jsx(X,{label:b?he.freshUploadStarting:he.freshUpload,kind:S||E?"outline":"primary",busy:b,onPress:ie,testID:"records-upload-own-fresh"}),v?jsxRuntime.jsx(reactNative.View,{style:c.errorBanner,accessibilityRole:"alert",children:jsxRuntime.jsx(m,{style:c.errorText,children:v})}):null]}):null,oe&&p==="revoke"?jsxRuntime.jsx(reactNative.View,{style:c.errorBanner,accessibilityRole:"alert",children:jsxRuntime.jsx(m,{style:c.errorText,children:oe})}):null,y.canRevoke===true?u.confirmingRevoke?jsxRuntime.jsxs(reactNative.View,{style:s.block,testID:"records-revoke-confirm",children:[jsxRuntime.jsx(m,{style:s.confirmTitle,accessibilityRole:"header",children:zt.cancelQuestion}),jsxRuntime.jsx(m,{style:c.bodyText,children:zt.cancelConsequence}),jsxRuntime.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"}),jsxRuntime.jsx(X,{label:zt.keepRequest,kind:"outline",disabled:u.busy,onPress:u.keepRequest,testID:"records-revoke-keep"})]}):jsxRuntime.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 react.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 reactNative.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]=react.useReducer(vi,u,Xn),h=Jn(y),P=y.stack.length;react.useEffect(()=>{let j=i(()=>P<=1?false:(x({type:"pop"}),true),"onBackPress"),$=reactNative.BackHandler.addEventListener("hardwareBackPress",j);return ()=>{$.remove();}},[P]);let S=react.useCallback(j=>x({type:"navigate",screen:j}),[]),E=react.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 jsxRuntime.jsx(Ms,{petRef:t,...C,...I,...q,style:f});case "request":return jsxRuntime.jsx(ea,{petRef:t,requestId:h.requestId,...C,...I,...F,...q,style:f});case "timeline":return jsxRuntime.jsx(Nd,{petRef:t,...C,style:f});case "record":return jsxRuntime.jsx(Ks,{petRef:t,...C,...I,...q,style:f});case "document":return jsxRuntime.jsx(Ws,{petRef:t,...C,...I,...q,style:f});case "contributions":return jsxRuntime.jsx(Md,{petRef:t,docId:h.docId,...C,style:f});case "clinicPicker":return jsxRuntime.jsx(Wi,{petRef:t,...C,...n?{controller:n}:{},...o?{recordsController:o}:{},style:f});case "clinicBatch":return jsxRuntime.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 jsxRuntime.jsx(bs,{petRef:t,clinic:h.clinic,...C,...s!==void 0?{ownerName:s}:{},...d?{onCaptureSignature:d}:{},...n?{controller:n}:{},style:f});case "upload":return jsxRuntime.jsx(Xs,{petRef:t,...C,...o?{controller:o}:{},...F,...q,style:f});case "requests":return jsxRuntime.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 jsxRuntime.jsx(Ve,{capability:"recordsClinic",...Fe(e.onClose,K.cancel),children:t===null?jsxRuntime.jsx(m,{accessibilityRole:"alert",children:ye.sessionRequired}):jsxRuntime.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]=react.useState(null),n=react.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)=>jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:p,accessibilityState:{disabled:b},disabled:b,onPress:f,style:[s,{justifyContent:"center",opacity:b?.5:1}],children:jsxRuntime.jsx(m,{style:d,children:p})}),"button");return jsxRuntime.jsxs(reactNative.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:[jsxRuntime.jsx(m,{accessibilityRole:"header",style:[d,{...k(c,"bold"),fontSize:c.type.size.heading}],children:K.title}),jsxRuntime.jsx(m,{style:d,children:e.petName}),a.created?jsxRuntime.jsx(m,{accessibilityLiveRegion:"polite",style:d,children:a.created.statusLabel||ye.records}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(m,{style:d,children:K.ownerName}),jsxRuntime.jsx(He,{accessibilityLabel:K.ownerName,style:s,value:a.ownerName,maxLength:200,editable:!a.busy,autoComplete:"name",onChangeText:a.setOwnerName}),jsxRuntime.jsx(m,{style:d,children:K.clinic}),jsxRuntime.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&&jsxRuntime.jsx(m,{accessibilityLiveRegion:"polite",style:d,children:ye.loading}),a.recent.length>0&&jsxRuntime.jsx(m,{accessibilityRole:"header",style:d,testID:"records-clinic-recent-label",children:K.recentlyUsed}),a.recent.map(p=>jsxRuntime.jsx(reactNative.View,{children:u([p.name,p.address,p.phone].filter(Boolean).join(", "),()=>a.selectClinic(p),a.busy)},`recent-${p.id}`)),a.clinics.map(p=>jsxRuntime.jsx(reactNative.View,{children:u([p.name,p.address,p.phone].filter(Boolean).join(", "),()=>a.selectClinic(p),a.busy)},p.id)),a.needsEmail&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(m,{style:d,children:K.email}),jsxRuntime.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})]}),jsxRuntime.jsx(m,{accessibilityRole:"header",style:d,children:K.scopeHeading}),a.copy?jsxRuntime.jsx(m,{style:d,children:a.query.trim()&&a.ownerName.trim()?a.scope??N("internalError").displayMessage:ye.consentRequired}):!a.error&&jsxRuntime.jsx(m,{accessibilityLiveRegion:"polite",style:d,children:ye.loading}),!e.onCaptureSignature&&jsxRuntime.jsx(Mr,{onChange:o,disabled:a.busy}),!l&&jsxRuntime.jsx(m,{accessibilityRole:"alert",style:d,children:K.missingSignature}),a.error&&jsxRuntime.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),jsxRuntime.jsx(qe,{})]})}i(uh,"ClinicRequestBody");
|
|
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]=react.useState("draw"),[a,l]=react.useState(""),[c,s]=react.useState([]),[d,u]=react.useState(0),p=react.useRef([]),f=react.useRef(null),b=d>0?Xr.width/d:1,R=react.useRef(b);R.current=b;let v=react.useRef(t);v.current=t,react.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=react.useMemo(()=>reactNative.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=react.useCallback(()=>{v.current||(p.current=[],f.current=null,s([]),l(""));},[]),h=react.useCallback(()=>{x(),n(S=>S==="draw"?"type":"draw");},[x]),P=i(S=>u(S.nativeEvent.layout.width),"onLayout");return jsxRuntime.jsxs(reactNative.View,{style:r.container,testID:"records-signature-pad",children:[jsxRuntime.jsx(m,{style:r.label,children:o==="draw"?K.draw:K.type}),o==="type"?jsxRuntime.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,jsxRuntime.jsx(reactNative.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"?jsxRuntime.jsx(m,{style:r.typedPreview,numberOfLines:1,adjustsFontSizeToFit:true,children:a.trim()}):Ty(c,b).map(S=>{let E=S.length+vo;return jsxRuntime.jsx(reactNative.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)})}),jsxRuntime.jsxs(reactNative.View,{style:r.actions,children:[jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:K.clear,accessibilityState:{disabled:t},disabled:t,onPress:x,style:r.button,children:jsxRuntime.jsx(m,{style:r.buttonLabel,children:K.clear})}),jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:o==="draw"?K.toType:K.toDraw,accessibilityState:{disabled:t},disabled:t,onPress:h,style:r.button,children:jsxRuntime.jsx(m,{style:r.buttonLabel,children:o==="draw"?K.toType:K.toDraw})})]})]})}i(Mr,"SignaturePad");function Py(){let e=V();return react.useMemo(()=>Iy(e),[e])}i(Py,"useStyles");function Iy(e){let{color:t,space:r,radius:o,type:n}=e;return reactNative.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 jsxRuntime.jsx(Ve,{capability:"recordsClinic",...Fe(e.onClose,K.cancel),children:t===null?jsxRuntime.jsx(m,{accessibilityRole:"alert",children:ye.sessionRequired}):jsxRuntime.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]=react.useState(null),l=react.useCallback(async()=>n===null?null:{signaturePngBase64:n},[n]),c=react.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)=>jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:x,accessibilityState:{disabled:y},disabled:y,onPress:g,style:[p,{justifyContent:"center",opacity:y?.5:1}],children:jsxRuntime.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 jsxRuntime.jsxs(reactNative.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:[jsxRuntime.jsx(m,{accessibilityRole:"header",style:[f,{...k(u,"bold"),fontSize:u.type.size.heading}],children:s.outcome?Me.resultTitle:Me.title}),jsxRuntime.jsx(m,{style:f,children:e.petName}),s.outcome?jsxRuntime.jsxs(reactNative.View,{style:{gap:u.space.sm},testID:"records-batch-result",children:[jsxRuntime.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)}),jsxRuntime.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 jsxRuntime.jsxs(reactNative.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:[jsxRuntime.jsx(m,{style:f,children:y}),jsxRuntime.jsx(m,{style:b,children:x}),w.created&&w.request?.statusLabel?jsxRuntime.jsx(m,{style:b,children:w.request.statusLabel}):null,!w.created&&w.failureReason?jsxRuntime.jsx(m,{style:b,children:w.failureReason}):null]},w.idempotencyKey)}),s.group?jsxRuntime.jsx(m,{accessibilityLiveRegion:"polite",style:f,children:Me.responded(s.group.responded,s.group.total)}):null,s.group?.members.map(w=>w.statusLabel?jsxRuntime.jsx(m,{style:b,children:[w.clinicName,w.statusLabel].filter(Boolean).join(": ")},w.id):null)]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(m,{style:f,children:K.ownerName}),jsxRuntime.jsx(He,{accessibilityLabel:K.ownerName,style:p,value:s.ownerName,maxLength:200,editable:!s.busy,autoComplete:"name",onChangeText:s.setOwnerName}),s.drafts.map(w=>jsxRuntime.jsxs(reactNative.View,{style:{gap:u.space.xs},testID:`records-batch-draft-${w.key}`,children:[jsxRuntime.jsx(m,{style:f,children:kn(w)}),Sn(w)?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(m,{style:b,children:w.email.trim()?w.email:Me.emailToAdd}),jsxRuntime.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)),jsxRuntime.jsx(m,{style:f,children:s.atCap?Me.atCap:Me.addClinic}),!s.atCap&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.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&&jsxRuntime.jsx(m,{accessibilityLiveRegion:"polite",style:f,children:ye.loading}),s.recent.length>0&&jsxRuntime.jsx(m,{accessibilityRole:"header",style:f,children:K.recentlyUsed}),s.recent.map(w=>jsxRuntime.jsx(reactNative.View,{children:R([w.name,w.address,w.phone].filter(Boolean).join(", "),()=>s.addClinic(w),s.busy)},`recent-${w.id}`)),s.clinics.map(w=>jsxRuntime.jsx(reactNative.View,{children:R([w.name,w.address,w.phone].filter(Boolean).join(", "),()=>s.addClinic(w),s.busy)},w.id))]}),jsxRuntime.jsx(m,{accessibilityRole:"header",style:f,children:K.scopeHeading}),s.copy?jsxRuntime.jsx(m,{style:f,children:s.drafts.length>0&&s.ownerName.trim()?s.scopeText??N("internalError").displayMessage:ye.consentRequired}):!s.error&&jsxRuntime.jsx(m,{accessibilityLiveRegion:"polite",style:f,children:ye.loading}),!e.onCaptureSignature&&jsxRuntime.jsx(Mr,{onChange:a,disabled:s.busy}),!d&&jsxRuntime.jsx(m,{accessibilityRole:"alert",style:f,children:K.missingSignature}),s.error&&jsxRuntime.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),jsxRuntime.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=zod.z.string().nullish(),wo=zod.z.number().nullish(),Vy=zod.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:zod.z.boolean().nullish()}),qy=zod.z.object({collected_at:Ae,at:Ae,value:wo,unit:Ae,qualitative_result:Ae,status:Ae}),zy=zod.z.object({marker_id:zod.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:zod.z.array(Vy).optional()}),Fy=zod.z.object({total_markers:zod.z.number().int().nonnegative(),in_range_count:zod.z.number().int().nonnegative(),out_of_range_count:zod.z.number().int().nonnegative(),unknown_count:zod.z.number().int().nonnegative()}),Ny=zod.z.object({markers:zod.z.array(zy).optional(),summary:Fy.nullish(),disclaimer:zod.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=zod.z.string().min(1).refine(e=>e.startsWith("https://")),Hy=zod.z.object({source_doc_id:zod.z.string().min(1),file_name:zod.z.string().nullish(),doc_format:zod.z.string().nullish(),byte_size:zod.z.number().int().nonnegative().nullish(),received_at:zod.z.string().nullish(),download_url:By,expires_in_seconds:zod.z.number().int().nonnegative().nullish()}),Uy=zod.z.object({items:zod.z.array(zod.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=zod.z.string().min(1).refine(e=>e.startsWith("https://")),Pn=zod.z.string().nullish(),$y=zod.z.object({share_id:zod.z.string().min(1),share_url:zod.z.string().min(1),expires_at:Pn}),Wy=zod.z.object({shares:zod.z.array(zod.z.object({share_id:zod.z.string().min(1),expires_at:Pn,created_at:Pn,view_count:zod.z.number().int().nonnegative().nullish(),last_viewed_at:Pn})).optional()}),Gy=zod.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=zod.z.object({signatures:zod.z.array(zod.z.object({signature_id:zod.z.string().min(1),preview_url:zod.z.string().min(1).refine(e=>e.startsWith("https://")),created_at:zod.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=zod.z.string().nullish(),In=zod.z.number().nullish(),Qy=zod.z.object({at:U,value:In,unit:U,qualitative_result:U,ref_low:In,ref_high:In,status:U,doc_id:U}),Xy=zod.z.object({marker_id:zod.z.string(),name:zod.z.string(),loinc_code:U,unit:U,panel:U,meaning:U,latest:zod.z.object({at:U,value:In,unit:U,qualitative_result:U,status:U}).nullish(),trajectory:U,points:zod.z.array(Qy).optional()}),Jy=zod.z.object({encounter_id:zod.z.string(),date:U,type:U,clinic_name:U,veterinarian:U,doc_id:U}),Zy=zod.z.object({note_id:zod.z.string(),encounter_id:U,observed_on:U,sections:zod.z.array(zod.z.object({section:zod.z.string(),text:zod.z.string()})).optional()}),ef=zod.z.object({exam_id:zod.z.string(),encounter_id:U,observed_on:U,doc_id:U,systems:zod.z.record(zod.z.object({finding_status:U,finding:U})).optional()}),tf=zod.z.object({has_lab_history:zod.z.boolean().optional(),has_vaccination_history:zod.z.boolean().optional(),has_weight_history:zod.z.boolean().optional(),has_vitals_history:zod.z.boolean().optional(),has_physical_exam_history:zod.z.boolean().optional(),has_procedure_history:zod.z.boolean().optional(),has_genetic_history:zod.z.boolean().optional(),has_reproductive_history:zod.z.boolean().optional(),has_parasite_prevention_history:zod.z.boolean().optional(),earliest_record_at:U,latest_record_at:U,documents_ingested:zod.z.number().int().nonnegative().optional(),documents_in_review:zod.z.number().int().nonnegative().optional(),entities_pending_review:zod.z.record(zod.z.number().int().nonnegative()).optional(),held_total:zod.z.number().int().nonnegative().optional()}),rf=zod.z.object({conflict_id:zod.z.string(),entity_type:zod.z.string(),field:U,severity:U,candidates:zod.z.array(zod.z.object({value:zod.z.string(),source_doc_id:U,doc_id:U,collected_at:U})).optional()}),nf=zod.z.object({lab_results:zod.z.array(Xy).optional(),encounters:zod.z.array(Jy).optional(),clinician_notes:zod.z.array(Zy).optional(),physical_exams:zod.z.array(ef).optional(),completeness:tf.nullish(),conflicts:zod.z.array(rf).optional()}),of=zod.z.object({visits:zod.z.array(zod.z.object({visit_id:zod.z.string(),visit_date:U,veterinarian:U,summary:U,doc_id:U})),vaccines:zod.z.array(zod.z.object({vaccine_id:zod.z.string(),product:U,lot:U,administered_on:U,expires_on:U,doc_id:U})),weights:zod.z.array(zod.z.object({weight_id:zod.z.string(),observed_on:U,weight_kg:In,doc_id:U})),medications:zod.z.array(zod.z.object({medication_id:zod.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:zod.z.string().optional()}),sf=zod.z.object({document:oi,contributions:zod.z.array(ni),contribution_count:zod.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 react.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=react.useMemo(()=>({}),[n,e,o,l]),[s,d]=react.useState({scope:c,value:null,error:null,loading:true}),u=react.useRef(0),p=react.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]);react.useEffect(()=>(p(),()=>{u.current+=1;}),[p]);let f=s.scope===c?s:{value:null,error:null,loading:true},b=react.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 react.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 react.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]=react.useState(false),[u,p]=react.useState(e.ownerName),[f,b]=react.useState(t.email),[R,v]=react.useState(false),[w,g]=react.useState(null),[y,x]=react.useState(null),[h,P]=react.useState(0),[S,E]=react.useState(null),[C,I]=react.useState(false),[F,q]=react.useState(null),[j,$]=react.useState([]),[ce,oe]=react.useState(null),[ve,ie]=react.useState(false),T=react.useRef(false),D=react.useRef(true),L=react.useRef(lr()),B=react.useRef(null);react.useEffect(()=>(D.current=true,()=>{D.current=false,B.current=null;}),[r]),react.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]),react.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=react.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=react.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 jsxRuntime.jsx(Ve,{capability:"recordsClinic",style:e.style,...Fe(e.onBack,Ye),children:t===null?jsxRuntime.jsx(m,{accessibilityRole:"alert",children:ye.sessionRequired}):jsxRuntime.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]=react.useState(null),[g,y]=react.useState("draw"),x=react.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=react.useRef(h);P.current=h;let S=react.useCallback(C=>{w(C),P.current.setSigned(C!==null);},[]),E=h.busy;return jsxRuntime.jsxs(reactNative.View,{style:[u.root,d],children:[jsxRuntime.jsx(Ke,{title:h.title,onBack:s,testID:"records-consent-header"}),jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{behavior:"padding",style:u.body,children:[jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:p.content,keyboardShouldPersistTaps:"handled",testID:"records-consent",children:[jsxRuntime.jsxs(reactNative.View,{style:p.scopeCard,accessibilityRole:"summary",children:[jsxRuntime.jsx(m,{style:p.scopeHeading,accessibilityRole:"header",children:ue.scopeHeading}),jsxRuntime.jsx(m,{style:p.scopeBody,children:ue.scopeBody}),jsxRuntime.jsx(reactNative.View,{style:p.bullets,children:ue.whatWeDo.map(C=>jsxRuntime.jsxs(reactNative.View,{style:p.bulletRow,children:[jsxRuntime.jsx(m,{style:p.check,children:"\u2713"}),jsxRuntime.jsx(m,{style:p.bulletText,children:C})]},C))}),jsxRuntime.jsx(reactNative.View,{style:p.retentionRow,children:jsxRuntime.jsx(m,{style:p.retentionText,children:ue.retentionNote})}),h.copy&&h.scope?jsxRuntime.jsx(m,{style:p.serverScope,testID:"records-consent-scope",children:h.scope}):h.copyError?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(m,{style:u.errorText,accessibilityRole:"alert",children:h.copyError.displayMessage}),jsxRuntime.jsx(X,{label:ye.retry,kind:"outline",onPress:h.retryCopy,testID:"records-consent-copy-retry"})]}):jsxRuntime.jsx(m,{style:u.muted,accessibilityLiveRegion:"polite",children:ye.loading})]}),jsxRuntime.jsxs(reactNative.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:[jsxRuntime.jsx(reactNative.View,{style:[p.box,h.authorized?p.boxChecked:null],accessibilityElementsHidden:true,importantForAccessibility:"no",children:h.authorized?jsxRuntime.jsx(m,{style:p.boxCheck,children:"\u2713"}):null}),jsxRuntime.jsx(m,{style:p.toggleLabel,children:ue.authorizeLabel(t,h.clinicName)})]}),jsxRuntime.jsxs(reactNative.View,{style:p.block,children:[jsxRuntime.jsx(m,{style:u.fieldLabel,children:ue.fullName}),jsxRuntime.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?jsxRuntime.jsxs(reactNative.View,{style:p.block,testID:"records-consent-email-block",children:[h.directoryClinicNoEmail?jsxRuntime.jsx(reactNative.View,{style:u.cautionNote,testID:"records-consent-no-email-note",children:jsxRuntime.jsx(m,{style:u.cautionNoteText,children:ue.noEmailNote(t,h.clinicName)})}):null,jsxRuntime.jsx(m,{style:u.fieldLabel,children:ue.emailLabel}),jsxRuntime.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?jsxRuntime.jsx(m,{style:u.errorText,accessibilityRole:"alert",children:h.emailError}):null,jsxRuntime.jsx(m,{style:u.muted,testID:"records-consent-review-note",children:ue.newClinicDirectSendNote})]}):null,n?null:jsxRuntime.jsxs(reactNative.View,{style:p.signatureBlock,children:[h.signatures.length>0?jsxRuntime.jsxs(reactNative.View,{style:p.block,children:[jsxRuntime.jsx(m,{style:u.fieldLabel,children:ue.reuseSignature}),jsxRuntime.jsx(reactNative.ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,contentContainerStyle:p.gallery,children:h.signatures.map(C=>{let I=h.reuseSignatureId===C.signatureId;return jsxRuntime.jsx(reactNative.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:jsxRuntime.jsx(reactNative.Image,{source:{uri:C.previewUrl},style:p.tileImage,resizeMode:"contain",accessibilityIgnoresInvertColors:true})},C.signatureId)})}),jsxRuntime.jsx(m,{style:u.muted,children:ue.reuseHint})]}):null,jsxRuntime.jsx(reactNative.View,{style:p.signatureHeader,children:jsxRuntime.jsx(m,{style:u.fieldLabel,children:g==="type"?ue.signType:ue.signDraw})}),jsxRuntime.jsx(Mr,{onChange:S,disabled:E}),jsxRuntime.jsx(reactNative.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:jsxRuntime.jsx(m,{style:p.modeToggleText,children:g==="draw"?ue.toType:ue.toDraw})}),jsxRuntime.jsx(m,{style:u.muted,children:ue.signatureHint(h.clinicName)})]}),h.error?jsxRuntime.jsx(reactNative.View,{style:u.errorBanner,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",children:jsxRuntime.jsx(m,{style:u.errorText,children:h.error})}):null,h.created?jsxRuntime.jsx(m,{accessibilityLiveRegion:"polite",style:u.bodyText,children:h.created.statusLabel||ye.records}):null]}),jsxRuntime.jsx(reactNative.View,{style:p.footer,children:jsxRuntime.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"})})]}),jsxRuntime.jsx(qe,{})]})}i(xf,"ConsentBody");function Cf(){let e=V();return react.useMemo(()=>Ef(e),[e])}i(Cf,"useLocalStyles");function Ef(e){let{color:t,space:r,radius:o,type:n}=e,a=reactNative.StyleSheet.hairlineWidth,l=i((c,s,d,u="regular")=>({...k(e,u),fontSize:c,lineHeight:Math.round(c*s),color:d}),"text");return reactNative.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=react.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 jsxRuntime.jsxs(reactNative.View,{style:o.card,accessibilityRole:"summary",testID:r,children:[jsxRuntime.jsx(m,{style:o.title,children:jt.title}),jsxRuntime.jsx(reactNative.View,{style:o.ringRow,accessible:true,accessibilityRole:"image",accessibilityLabel:jt.a11y(a,l,c,s),children:jsxRuntime.jsxs(reactNative.View,{style:o.ringWrap,children:[jsxRuntime.jsx(reactNative.View,{style:o.track}),d===null?null:d.map(p=>jsxRuntime.jsx(Vf,{segment:p,styles:o},p.key)),jsxRuntime.jsxs(reactNative.View,{style:o.center,pointerEvents:"none",children:[jsxRuntime.jsx(m,{style:o.centerCount,children:a}),jsxRuntime.jsx(m,{style:o.centerLabel,children:a===1?jt.marker:jt.markers})]})]})}),u||d===null?jsxRuntime.jsxs(reactNative.View,{style:o.badges,children:[jsxRuntime.jsx(xs,{count:c,label:jt.outOfRange,color:n.color.danger,styles:o}),jsxRuntime.jsx(xs,{count:l,label:jt.inRange,color:n.color.success,styles:o}),s>0?jsxRuntime.jsx(xs,{count:s,label:jt.noRange,color:n.color.text.muted,styles:o}):null]}):null,jsxRuntime.jsx(m,{style:o.subtitle,children:jt.subtitle}),t?jsxRuntime.jsx(reactNative.Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:jt.askA11y,style:o.ask,testID:"marker-summary-ask",children:jsxRuntime.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)=>jsxRuntime.jsx(reactNative.View,{style:[t.piece,{transform:[{rotate:`${o.start}deg`}]}],pointerEvents:"none",testID:`marker-ring-${e.key}`,children:jsxRuntime.jsx(reactNative.View,{style:t.window,children:jsxRuntime.jsx(reactNative.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 jsxRuntime.jsx(reactNative.View,{style:[o.badge,{borderColor:r}],children:jsxRuntime.jsx(m,{style:[o.badgeText,{color:r}],children:`${e} ${t}`})})}i(xs,"Badge");function qf(){let e=V();return react.useMemo(()=>zf(e),[e])}i(qf,"useStyles");function zf(e){let{color:t,space:r,radius:o,type:n,slots:a}=e,l=reactNative.StyleSheet.hairlineWidth,c=at(a.recordCard);return reactNative.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=react.useMemo(()=>rd(e),[e]),u=e.latest?Tt(e.latest.value,e.unit,e.latest.qualitativeResult):null;return jsxRuntime.jsx(reactNative.View,{style:[n.page,t!==void 0?{width:t}:null],testID:`marker-card-${e.markerId}`,children:jsxRuntime.jsxs(reactNative.View,{style:n.card,children:[jsxRuntime.jsxs(reactNative.View,{style:n.headerRow,children:[jsxRuntime.jsxs(reactNative.View,{style:n.nameColumn,children:[jsxRuntime.jsx(m,{style:n.markerName,numberOfLines:2,children:e.name}),e.unit?jsxRuntime.jsx(m,{style:n.unit,children:e.unit}):null]}),jsxRuntime.jsx(reactNative.View,{accessible:true,accessibilityRole:"text",accessibilityLabel:dr.status(l.label),children:jsxRuntime.jsx(kt,{label:l.label,tone:c})})]}),e.latest&&u!==null?jsxRuntime.jsxs(reactNative.View,{style:n.latestRow,children:[jsxRuntime.jsx(m,{style:[n.latestValue,l.outOfRange?n.latestValueDanger:null],accessibilityLabel:dr.latestA11y(u,l.label,J(e.latest.at)),children:u}),jsxRuntime.jsx(m,{style:n.latestDate,children:J(e.latest.at)})]}):null,s?jsxRuntime.jsx(m,{style:n.trajectory,accessibilityRole:"text",children:s}):null,d!==null?jsxRuntime.jsxs(reactNative.View,{style:n.chartWrap,children:[jsxRuntime.jsxs(reactNative.View,{style:n.plot,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:[d.band?jsxRuntime.jsx(reactNative.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=>jsxRuntime.jsx(reactNative.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))]}),jsxRuntime.jsx(reactNative.View,{style:n.a11yTable,accessibilityRole:"summary",accessibilityLabel:dr.readingsA11y(e.name),children:e.points.map((p,f)=>jsxRuntime.jsx(reactNative.View,{accessibilityRole:"text",accessibilityLabel:Nc(e,p)},f))}),jsxRuntime.jsx(m,{style:e.points.length===1?n.singleHint:n.tapHint,children:e.points.length===1?dr.singleHint:dr.tapHint})]}):jsxRuntime.jsx(reactNative.View,{style:n.emptyBody,accessibilityRole:"text",children:jsxRuntime.jsx(m,{style:n.emptyText,children:dr.empty})}),o?jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>o(e),accessibilityRole:"button",accessibilityLabel:dr.askA11y(e.name),style:[a.pill,a.pillAsk],testID:`marker-ask-${e.markerId}`,children:jsxRuntime.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]=react.useState(0),[l,c]=react.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 jsxRuntime.jsxs(reactNative.View,{style:o.carousel,onLayout:s,testID:"marker-carousel",children:[jsxRuntime.jsx(reactNative.ScrollView,{horizontal:true,pagingEnabled:true,showsHorizontalScrollIndicator:false,onMomentumScrollEnd:d,snapToAlignment:"start",children:e.map(p=>jsxRuntime.jsx(Uf,{marker:p,width:n>0?n:void 0,onPointPress:t,onAsk:r},p.markerId))}),jsxRuntime.jsxs(reactNative.View,{style:o.footer,accessible:true,accessibilityRole:"adjustable",accessibilityLabel:Mi.a11y(u?.name??null,l,e.length),children:[jsxRuntime.jsx(reactNative.View,{style:o.dots,children:e.map((p,f)=>jsxRuntime.jsx(reactNative.View,{style:[o.dot,f===l?o.dotActive:null]},p.markerId))}),jsxRuntime.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)=>jsxRuntime.jsxs(reactNative.View,{style:n.detailRow,accessible:true,accessibilityRole:"text",accessibilityLabel:`${c}: ${s}`,children:[jsxRuntime.jsx(m,{style:n.detailLabel,children:c}),jsxRuntime.jsx(m,{style:n.detailValue,children:s})]},c),"row");return jsxRuntime.jsxs(reactNative.Modal,{transparent:true,visible:true,animationType:"slide",onRequestClose:r,children:[jsxRuntime.jsx(reactNative.Pressable,{style:n.backdrop,onPress:r,accessibilityRole:"button",accessibilityLabel:St.close}),jsxRuntime.jsxs(reactNative.View,{style:n.sheet,accessibilityViewIsModal:true,testID:"marker-provenance-sheet",children:[jsxRuntime.jsx(reactNative.View,{style:n.handle}),jsxRuntime.jsxs(reactNative.View,{style:n.sheetHeader,children:[jsxRuntime.jsx(m,{style:n.sheetTitle,accessibilityRole:"header",children:St.title}),jsxRuntime.jsx(reactNative.Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:St.close,hitSlop:10,style:n.closeButton,testID:"marker-provenance-close",children:jsxRuntime.jsx(m,{style:n.closeGlyph,children:"\xD7"})})]}),jsxRuntime.jsxs(reactNative.View,{style:n.sheetBody,children:[jsxRuntime.jsxs(reactNative.View,{style:n.valueRow,children:[jsxRuntime.jsx(m,{style:n.sheetName,children:e.name}),jsxRuntime.jsx(m,{style:n.sheetValue,children:Tt(t.value,e.unit,t.qualitativeResult)})]}),t.reviewed?jsxRuntime.jsx(reactNative.View,{style:n.reviewed,accessibilityRole:"text",children:jsxRuntime.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:jsxRuntime.jsx(m,{style:n.unverified,accessibilityRole:"text",children:St.unverified}),o?jsxRuntime.jsx(reactNative.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:St.askA11y,style:[a.pill,a.pillAsk],testID:"marker-provenance-ask",children:jsxRuntime.jsx(m,{style:a.pillAskLabel,children:St.ask})}):null]})]})]})}i(ad,"MarkerProvenanceSheet");function Cs(){let e=V();return react.useMemo(()=>jf(e),[e])}i(Cs,"useStyles");function jf(e){let{color:t,space:r,radius:o,type:n,slots:a}=e,l=reactNative.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 reactNative.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]=react.useState($f),[l,c]=react.useState(false),[s,d]=react.useState(null),u=react.useMemo(()=>({}),[r,e,o]),[p,f]=react.useState(null),b=react.useCallback(()=>f(u),[u]),R=o!==null&&p!==u,v=react.useRef(false),w=react.useRef(t.newIdempotencyKey);w.current=t.newIdempotencyKey;let g=react.useCallback(()=>(w.current??Wf)(),[]),y=react.useCallback((S,E,C)=>{if(c(false),!S.ok){if(E(),_r(S.error)){b();return}d(pd(S.error,C));}},[b]),x=react.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=react.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=react.useCallback(()=>d(null),[]);return react.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]=react.useState(false),l=e.label.trim()||ct.detail;return jsxRuntime.jsxs(reactNative.View,{style:o.row,children:[jsxRuntime.jsx(reactNative.View,{style:o.main,children:r}),jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>a(true),accessibilityRole:"button",accessibilityLabel:ct.editA11y(l),hitSlop:6,style:o.editButton,testID:`fact-edit-open-${e.canonicalKey??e.key}`,children:jsxRuntime.jsx(reactNative.View,{style:o.pencil,accessibilityElementsHidden:true,importantForAccessibility:"no"})}),n?jsxRuntime.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]=react.useState(e.value??""),[d,u]=react.useState(null),[p,f]=react.useState(false);react.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 jsxRuntime.jsx(reactNative.Modal,{transparent:true,visible:true,animationType:"slide",onRequestClose:o,children:jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{behavior:"padding",style:n.backdrop,children:[jsxRuntime.jsx(reactNative.Pressable,{style:qo,accessibilityRole:"button",accessibilityLabel:ct.closeEditorA11y,onPress:o}),jsxRuntime.jsxs(reactNative.View,{style:n.sheet,accessibilityViewIsModal:true,testID:"fact-edit-sheet",children:[jsxRuntime.jsx(reactNative.View,{style:n.handle}),jsxRuntime.jsxs(reactNative.View,{style:n.header,children:[jsxRuntime.jsxs(reactNative.View,{style:n.headerText,children:[jsxRuntime.jsx(m,{style:n.title,accessibilityRole:"header",children:ct.title(t)}),jsxRuntime.jsx(m,{style:[n.helper,R?n.helperError:null],accessibilityLiveRegion:"polite",children:R??ct.helper})]}),jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:ct.close,onPress:o,hitSlop:12,style:n.closeButton,testID:"fact-edit-close",children:jsxRuntime.jsx(m,{style:n.closeGlyph,children:"\xD7"})})]}),jsxRuntime.jsx(m,{style:a.fieldLabel,children:e.label}),jsxRuntime.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?jsxRuntime.jsxs(reactNative.View,{style:n.confirmBlock,testID:"fact-edit-confirm-remove",children:[jsxRuntime.jsx(m,{style:n.confirmText,children:ct.confirmRemove}),jsxRuntime.jsxs(reactNative.View,{style:n.confirmRow,children:[jsxRuntime.jsx(X,{label:v?ct.removing:ct.removeConfirm,kind:"danger",busy:v,onPress:g,style:n.confirmButton,testID:"fact-edit-remove-confirm"}),jsxRuntime.jsx(X,{label:ct.keep,kind:"outline",disabled:v,onPress:()=>f(false),style:n.confirmButton,testID:"fact-edit-remove-cancel"})]})]}):jsxRuntime.jsxs(reactNative.View,{style:n.actions,children:[jsxRuntime.jsx(X,{label:v?ct.saving:ct.save,busy:v,disabled:!b,onPress:w,testID:"fact-edit-save"}),jsxRuntime.jsx(reactNative.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:jsxRuntime.jsx(m,{style:n.removeText,children:ct.remove})})]})]})]})})}i(ng,"FactEditSheet");function bd(){let e=V();return react.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 reactNative.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=react.useMemo(()=>l?Es(e.entities,l.overlay):e.entities,[e.entities,l]),f=react.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=react.useMemo(()=>gd(p),[p]),R=Object.values(e.documents),v=i((g,y,x)=>a?jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>{let h=g();a(h.prompt,h.entityRef);},accessibilityRole:"button",accessibilityLabel:y,style:[s.pill,s.pillAsk,d.ask],testID:x,children:jsxRuntime.jsx(m,{style:s.pillAskLabel,children:y})}):null,"ask"),w=l!==void 0&&l.available;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(reactNative.View,{style:d.sections,children:[t&&t.conflicts.length>0?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-conflicts",children:[jsxRuntime.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 jsxRuntime.jsxs(reactNative.View,{style:[d.conflictCard,{borderColor:s.chipTones[y.tone].fg.color}],accessibilityRole:"summary",children:[jsxRuntime.jsxs(reactNative.View,{style:d.conflictHead,children:[jsxRuntime.jsx(m,{style:d.conflictTitle,children:y.label}),jsxRuntime.jsx(kt,{label:x,tone:y.tone})]}),jsxRuntime.jsx(m,{style:s.rowDetail,children:Z.conflictSub}),g.candidates.map((h,P)=>jsxRuntime.jsxs(reactNative.View,{style:d.candidate,children:[jsxRuntime.jsx(m,{style:s.rowTitle,children:h.value}),jsxRuntime.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?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-completeness",children:[jsxRuntime.jsx(At,{title:Z.whatsOnFile}),jsxRuntime.jsxs(reactNative.View,{style:s.card,children:[jsxRuntime.jsx(reactNative.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])=>jsxRuntime.jsx(reactNative.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:jsxRuntime.jsx(m,{style:[d.coverageText,y?s.chipTones.positive.fg:{color:s.rowMuted.color}],children:g})},g))}),jsxRuntime.jsxs(reactNative.View,{style:d.metaRow,children:[jsxRuntime.jsx(m,{style:d.metaText,children:Z.documentsOnFile(t.completeness.documentsIngested)}),t.completeness.documentsInReview>0?jsxRuntime.jsx(kt,{label:Z.inReviewChip(t.completeness.documentsInReview),tone:"warning"}):null,_s(t.completeness.heldTotal,t.completeness.entitiesPendingReview)>0?jsxRuntime.jsx(reactNative.View,{accessible:true,accessibilityRole:"text",accessibilityLabel:Z.beingVerifiedA11y(_s(t.completeness.heldTotal,t.completeness.entitiesPendingReview)),children:jsxRuntime.jsx(kt,{label:Z.beingVerified(_s(t.completeness.heldTotal,t.completeness.entitiesPendingReview)),tone:"warning"})}):null]}),t.completeness.earliestRecordAt||t.completeness.latestRecordAt?jsxRuntime.jsx(reactNative.View,{style:d.metaRow,children:jsxRuntime.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?jsxRuntime.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?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-documents",children:[jsxRuntime.jsx(At,{title:Z.documents,count:R.length}),jsxRuntime.jsx(reactNative.View,{style:s.card,children:R.map((g,y)=>{let x=g.title?.trim()||Z.uploadedDocument,h=g.receivedAt?J(g.receivedAt):null,P=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(reactNative.View,{style:s.rowMain,children:[jsxRuntime.jsx(m,{style:s.rowTitle,children:x}),h?jsxRuntime.jsx(m,{style:s.rowDetail,children:h}):null]}),n?jsxRuntime.jsx(rr,{}):null]});return n?jsxRuntime.jsx(reactNative.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):jsxRuntime.jsx(reactNative.View,{style:[s.row,y>0?s.rowDivider:null],children:P},g.docId)})})]}):null,e.identity.length>0?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-identity",children:[jsxRuntime.jsx(At,{title:Z.identity}),jsxRuntime.jsx(reactNative.View,{style:s.card,children:e.identity.map((g,y)=>jsxRuntime.jsxs(reactNative.View,{style:[s.row,y>0?s.rowDivider:null],children:[jsxRuntime.jsx(m,{style:d.identityLabel,children:g.label}),jsxRuntime.jsx(m,{style:d.identityValue,children:g.value})]},`${y}:${g.label}`))})]}):null,e.forwardLooking.length>0?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-upcoming",children:[jsxRuntime.jsx(At,{title:Z.upcomingCare,count:e.forwardLooking.length}),jsxRuntime.jsx(reactNative.View,{style:s.card,children:e.forwardLooking.map((g,y)=>{let x=On(g.dueAt,u);return jsxRuntime.jsxs(reactNative.View,{style:[s.row,y>0?s.rowDivider:null],children:[jsxRuntime.jsxs(reactNative.View,{style:s.rowMain,children:[jsxRuntime.jsx(m,{style:s.rowTitle,children:g.title}),g.detail?jsxRuntime.jsx(m,{style:s.rowDetail,children:g.detail}):null]}),x?jsxRuntime.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?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-vaccination",children:[jsxRuntime.jsx(At,{title:jr("vaccination"),count:b.reduce((g,y)=>g+y.items.length,0)}),b.map(g=>jsxRuntime.jsxs(reactNative.View,{style:d.vaccineGroup,testID:`records-vaccine-group-${g.year}`,children:[jsxRuntime.jsx(m,{style:d.vaccineYear,accessibilityRole:"header",children:g.year.toUpperCase()}),jsxRuntime.jsx(reactNative.View,{style:s.card,children:g.items.map((y,x)=>{let h=jsxRuntime.jsxs(reactNative.View,{style:[s.row,x>0?s.rowDivider:null],children:[jsxRuntime.jsxs(reactNative.View,{style:s.rowMain,children:[jsxRuntime.jsx(m,{style:s.rowTitle,children:y.name}),y.detail?jsxRuntime.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}`)]}),jsxRuntime.jsx(kt,{label:y.statusLabel,tone:fd[y.tone]})]});return w&&Oo(y.entity)&&l?jsxRuntime.jsx(Ts,{entity:y.entity,factEdit:l,children:h},y.key):jsxRuntime.jsx(reactNative.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 jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:`record-section-${g}`,children:[jsxRuntime.jsx(At,{title:x,count:y.length}),jsxRuntime.jsx(reactNative.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=jsxRuntime.jsxs(reactNative.View,{style:[s.row,P>0?s.rowDivider:null],children:[jsxRuntime.jsxs(reactNative.View,{style:s.rowMain,children:[jsxRuntime.jsx(m,{style:s.rowTitle,children:h.label}),E?jsxRuntime.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?jsxRuntime.jsx(kt,{label:ur(h.status)}):null]});return w&&Oo(h)&&l?jsxRuntime.jsx(Ts,{entity:h,factEdit:l,children:C},h.key):jsxRuntime.jsx(reactNative.View,{children:C},h.key)})})]},g)}),t&&t.physicalExams.length>0?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-exams",children:[jsxRuntime.jsx(At,{title:Z.physicalExams,count:t.physicalExams.length}),t.physicalExams.map(g=>jsxRuntime.jsxs(reactNative.View,{style:s.card,children:[jsxRuntime.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 jsxRuntime.jsxs(reactNative.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:[jsxRuntime.jsxs(reactNative.View,{style:s.rowMain,children:[jsxRuntime.jsx(m,{style:s.rowTitle,children:qr(y.system)}),h&&y.finding?jsxRuntime.jsx(m,{style:s.rowDetail,children:y.finding}):null]}),jsxRuntime.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?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-notes",children:[jsxRuntime.jsx(At,{title:Z.visitNotes,count:t.clinicianNotes.length}),t.clinicianNotes.map(g=>jsxRuntime.jsxs(reactNative.View,{style:s.card,children:[jsxRuntime.jsx(m,{style:[s.rowTitle,d.cardTitle],accessibilityRole:"header",children:g.observedOn?J(g.observedOn):be.visitNote}),g.sections.map((y,x)=>jsxRuntime.jsxs(reactNative.View,{style:[d.noteSection,x>0?s.rowDivider:null],children:[jsxRuntime.jsx(m,{style:d.noteLabel,children:Qr(y.section)}),jsxRuntime.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?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-labs",children:[jsxRuntime.jsx(At,{title:Z.labResults,count:t.labResults.length}),jsxRuntime.jsx(reactNative.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 jsxRuntime.jsxs(reactNative.View,{style:[s.row,y>0?s.rowDivider:null],children:[jsxRuntime.jsxs(reactNative.View,{style:s.rowMain,children:[jsxRuntime.jsx(m,{style:s.rowTitle,children:g.name}),jsxRuntime.jsx(m,{style:s.rowValue,children:Tt(g.latest.value,g.latest.unit,g.latest.qualitativeResult)}),h?jsxRuntime.jsx(m,{style:s.rowDetail,children:h}):null]}),jsxRuntime.jsx(kt,{label:x.label,tone:Co(g.latest.status)})]},g.markerId)})})]}):null,t&&t.encounters.length>0?jsxRuntime.jsxs(reactNative.View,{style:s.section,testID:"record-section-visits",children:[jsxRuntime.jsx(At,{title:Z.visits,count:t.encounters.length}),jsxRuntime.jsx(reactNative.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 jsxRuntime.jsx(reactNative.View,{style:[s.row,y>0?s.rowDivider:null],children:jsxRuntime.jsxs(reactNative.View,{style:s.rowMain,children:[jsxRuntime.jsx(m,{style:s.rowTitle,children:g.type?ur(g.type):be.visit}),x?jsxRuntime.jsx(m,{style:s.rowDetail,children:x}):null]})},g.encounterId)})})]}):null]}),jsxRuntime.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 react.useMemo(()=>sg(e),[e])}i(ig,"useLocalStyles");function sg(e){let{color:t,space:r,radius:o,type:n}=e,a=reactNative.StyleSheet.hairlineWidth;return reactNative.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]=react.useState(""),[l,c]=react.useState(false),[s,d]=react.useState(null),[u,p]=react.useState(false),[f,b]=react.useState(null),R=react.useRef(false),v=react.useRef(false),w=react.useRef(0);react.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 jsxRuntime.jsx(reactNative.View,{style:t.container,accessibilityRole:"summary",children:r.map((o,n)=>jsxRuntime.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 jsxRuntime.jsxs(reactNative.View,{style:r.row,accessible:true,accessibilityRole:"text",accessibilityLabel:n.join(", "),testID:`records-timeline-${e.key}`,children:[jsxRuntime.jsxs(reactNative.View,{style:r.railColumn,children:[jsxRuntime.jsx(Ig,{state:e.state,styles:r}),t?null:jsxRuntime.jsx(reactNative.View,{style:[r.connector,e.state==="done"&&r.connectorDone],accessibilityElementsHidden:true,importantForAccessibility:"no"})]}),jsxRuntime.jsxs(reactNative.View,{style:r.body,children:[jsxRuntime.jsxs(reactNative.View,{style:r.titleRow,children:[jsxRuntime.jsx(m,{style:[r.title,e.state==="current"&&r.titleCurrent,e.state==="failed"&&r.titleFailed,e.state==="upcoming"&&r.titleUpcoming],children:e.title}),o?jsxRuntime.jsx(m,{style:r.date,children:o}):null]}),e.detail?jsxRuntime.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"?jsxRuntime.jsx(reactNative.View,{style:[t.dot,t.dotDone],accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsxRuntime.jsx(m,{tier:"badge",style:[t.glyph,t.glyphOnBrand],children:"\u2713"})}):e==="failed"?jsxRuntime.jsx(reactNative.View,{style:[t.dot,t.dotFailed],accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsxRuntime.jsx(m,{tier:"badge",style:t.glyph,children:"!"})}):e==="current"?jsxRuntime.jsx(reactNative.View,{style:[t.dot,t.dotCurrent],accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsxRuntime.jsx(reactNative.View,{style:t.dotCurrentCore})}):jsxRuntime.jsx(reactNative.View,{style:[t.dot,t.dotUpcoming],accessibilityElementsHidden:true,importantForAccessibility:"no"})}i(Ig,"TimelineDot");function Dg(){let e=V();return react.useMemo(()=>Ag(e),[e])}i(Dg,"useStyles");function Ag(e){let{color:t,type:r}=e,{size:o}=r;return reactNative.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 jsxRuntime.jsx(Vg,{onGrant:t});case "consent_unavailable":return jsxRuntime.jsx(qg,{});case "session_required":return jsxRuntime.jsx(zg,{});case "withheld":return jsxRuntime.jsx(Fg,{});case "pet_not_found":case "error":return jsxRuntime.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 jsxRuntime.jsxs(reactNative.View,{style:t.timeline,testID:"records-upload-queue",children:[a!==null?jsxRuntime.jsx(m,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",style:t.errorText,children:a}):null,o.length>0?jsxRuntime.jsx(reactNative.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 jsxRuntime.jsxs(reactNative.View,{style:t.uploadRow,testID:`records-upload-file-${l.status}`,children:[jsxRuntime.jsxs(reactNative.View,{style:t.uploadRowHead,children:[jsxRuntime.jsx(m,{style:t.rowLabel,children:l.name??""}),jsxRuntime.jsx(m,{style:t.rowValue,children:xd(l)})]}),l.status==="uploading"?jsxRuntime.jsx(reactNative.View,{style:t.progressTrack,accessibilityRole:"progressbar",accessibilityValue:{min:0,max:100,now:c},children:jsxRuntime.jsx(reactNative.View,{style:[t.progressFill,{width:`${c}%`}]})}):null,l.status==="failed"&&l.error?jsxRuntime.jsx(m,{style:t.timelineMeta,children:l.error.displayMessage}):null]},l.key)})}):null]})}i(Pd,"UploadQueue");function Vg({onGrant:e}){let t=zn();return jsxRuntime.jsx(reactNative.View,{style:t.centered,accessible:true,accessibilityRole:"alert",accessibilityLabel:ye.consentRequired,children:jsxRuntime.jsx(reactNative.Pressable,{onPress:e,accessibilityRole:"button",accessibilityLabel:ye.allow,style:t.primaryButton,children:jsxRuntime.jsx(m,{style:t.primaryLabel,children:ye.allow})})})}i(Vg,"ConsentRequiredState");function Vs({label:e,glyph:t}){let r=zn();return react.useEffect(()=>{reactNative.AccessibilityInfo.announceForAccessibility?.(e);},[e]),jsxRuntime.jsxs(reactNative.View,{style:r.centered,accessible:true,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:e,children:[jsxRuntime.jsx(reactNative.View,{style:t==="withheld"?r.withheldGlyph:r.emptyGlyph}),jsxRuntime.jsx(m,{style:r.errorText,children:e})]})}i(Vs,"AlertState");function qg(){return jsxRuntime.jsx(Vs,{label:ye.consentRequired,glyph:"empty"})}i(qg,"ConsentUnavailableState");function zg(){return jsxRuntime.jsx(Vs,{label:ye.sessionRequired,glyph:"empty"})}i(zg,"SessionRequiredState");function Fg(){return jsxRuntime.jsx(Vs,{label:ye.recordUnavailable,glyph:"withheld"})}i(Fg,"WithheldState");function Ng({error:e,onRetry:t}){let r=zn();return react.useEffect(()=>{reactNative.AccessibilityInfo.announceForAccessibility?.(e.displayMessage);},[e.displayMessage]),jsxRuntime.jsxs(reactNative.View,{style:r.centered,accessible:true,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",children:[jsxRuntime.jsx(m,{style:r.errorText,children:e.displayMessage}),e.retryable?jsxRuntime.jsx(reactNative.Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:ye.retry,style:r.primaryButton,children:jsxRuntime.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 jsxRuntime.jsxs(reactNative.View,{style:r.callCard,accessibilityRole:"summary",children:[jsxRuntime.jsx(m,{style:r.timelineLabel,children:Ln.heading}),jsxRuntime.jsx(m,{style:r.timelineMeta,children:o}),jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>{reactNative.Linking?.openURL?.(e.dial);},accessibilityRole:"button",accessibilityLabel:Ln.callAt(e.phone),style:r.linkButton,testID:"records-call-clinic",children:jsxRuntime.jsx(m,{style:r.linkLabel,children:Ln.call})})]})}i(Id,"ClinicCallCard");function zn(){let e=V();return react.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,reactNative.StyleSheet.hairlineWidth),u=at(a.recordCard),p=i((y,x)=>Math.round(y*x),"lh"),f=reactNative.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 reactNative.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 jsxRuntime.jsx(Ve,{capability:"records",style:t,...r?{renderPending:r}:{},...Fe(o.onBack,Ye),children:jsxRuntime.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=react.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=jsxRuntime.jsx(mo,{testID:"records-list-loading"}):d.status==="error"&&u.length===0?f=jsxRuntime.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=jsxRuntime.jsx(Ue,{variant:"no_requests",testID:"records-list-empty"}):f=jsxRuntime.jsx(reactNative.ScrollView,{contentContainerStyle:s.list,testID:"records-list-results",children:u.map(b=>jsxRuntime.jsx(jg,{request:b,onOpen:o?()=>o({name:"request",requestId:b.id}):void 0,onAsk:p?()=>p(b):void 0},b.id))}),jsxRuntime.jsxs(reactNative.View,{style:[c.root,l],children:[jsxRuntime.jsx(Ke,{title:ft.title,onBack:n,testID:"records-list-header"}),u.length>0?jsxRuntime.jsx(m,{style:s.subtitle,testID:"records-list-subtitle",children:ft.subtitle(t)}):null,jsxRuntime.jsx(reactNative.View,{style:c.body,children:f}),o?jsxRuntime.jsxs(reactNative.View,{style:s.footer,children:[jsxRuntime.jsx(X,{label:ft.requestRecords,accessibilityLabel:ft.requestRecordsA11y,onPress:()=>o({name:"clinicPicker"}),testID:"records-list-new"}),jsxRuntime.jsx(X,{label:ft.uploadOwn,kind:"outline",accessibilityLabel:ft.uploadOwnA11y,onPress:()=>o({name:"upload"}),testID:"records-list-upload-own"})]}):null,jsxRuntime.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=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactNative.View,{style:[n.bubble,o.chipTones[l].bg],accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxRuntime.jsxs(reactNative.View,{style:n.copy,children:[jsxRuntime.jsx(m,{style:n.source,numberOfLines:1,children:a.source}),jsxRuntime.jsx(m,{style:n.meta,numberOfLines:1,children:a.meta}),jsxRuntime.jsx(reactNative.View,{accessibilityElementsHidden:true,importantForAccessibility:"no",children:jsxRuntime.jsx(kt,{label:a.status,tone:l})})]}),t?jsxRuntime.jsx(rr,{}):null]});return jsxRuntime.jsxs(reactNative.View,{style:n.row,testID:`records-request-row-${e.id}`,children:[t?jsxRuntime.jsx(reactNative.Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:a.a11yLabel,style:n.rowInner,testID:`records-request-open-${e.id}`,children:c}):jsxRuntime.jsx(reactNative.View,{style:n.rowInner,accessible:true,accessibilityLabel:a.a11yLabel,children:c}),t&&vs(null,e)!==null?jsxRuntime.jsx(X,{label:Ze.cardTitle,onPress:t,testID:`records-request-resume-upload-${e.id}`}):null,r?jsxRuntime.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:jsxRuntime.jsxs(reactNative.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:a.a11yLabel,style:n.card,testID:"records-requests-status",children:[jsxRuntime.jsx(reactNative.View,{style:[n.cardBubble,a.processing?n.cardBubbleProcessing:null],accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxRuntime.jsxs(reactNative.View,{style:n.cardText,children:[jsxRuntime.jsx(m,{style:n.cardTitle,children:a.title}),jsxRuntime.jsx(m,{style:n.cardSubtitle,children:a.subtitle})]}),jsxRuntime.jsx(rr,{})]})}i(Fn,"RecordsRequestsStatusCard");function zs(){let e=V();return react.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 reactNative.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 jsxRuntime.jsx(Ve,{capability:"records",style:t,...r?{renderPending:r}:{},...Fe(o.onBack,Ye),children:jsxRuntime.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]=react.useState(null),v=react.useCallback((O,se)=>R({marker:O,point:se}),[]),w=react.useMemo(()=>Hr(o,u.consent),[o,u.consent]),g=react.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=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p.markers?.summary?jsxRuntime.jsx(reactNative.View,{style:s.inset,children:jsxRuntime.jsx(td,{summary:p.markers.summary,onAsk:ve,testID:"dashboard-marker-summary"})}):null,jsxRuntime.jsx(m,{style:s.lead,children:yt.lead(t)}),jsxRuntime.jsx(sd,{markers:h,onPointPress:v,onAsk:ie})]}),L=i(O=>n?jsxRuntime.jsxs(reactNative.View,{style:[s.inset,d.actions],children:[O?jsxRuntime.jsx(Wo,{label:yt.viewFullRecord,onPress:()=>n({name:"record"}),testID:"dashboard-full-record-action"}):null,jsxRuntime.jsx(Wo,{label:yt.viewTimeline,onPress:()=>n({name:"timeline"}),testID:"dashboard-timeline-action"}),jsxRuntime.jsx(Wo,{label:ft.allRequests,onPress:()=>n({name:"requests"}),testID:"dashboard-requests-action"})]}):null,"actions"),B=i(O=>n?jsxRuntime.jsxs(reactNative.View,{style:[O?s.inset:null,d.addActions],testID:"dashboard-actions",children:[x?jsxRuntime.jsx(X,{label:$t.requestFromClinic,accessibilityLabel:$t.requestFromClinicA11y(t),onPress:()=>n({name:"clinicPicker"}),style:d.addCta,testID:"dashboard-actions-clinic"}):null,jsxRuntime.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"?jsxRuntime.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=jsxRuntime.jsx(po,{testID:"dashboard-loading"});break;case "record":H=jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:s.contentTight,testID:"dashboard-record",children:[P?D:p.status==="error"?jsxRuntime.jsx(reactNative.View,{style:[s.inset,d.actions],children:jsxRuntime.jsx(Wo,{label:yt.retryMarkers,onPress:$,testID:"dashboard-markers-retry"})}):null,jsxRuntime.jsx(reactNative.View,{style:s.inset,children:u.record?jsxRuntime.jsx(Mo,{record:u.record,depth:ce,petName:t,showLabs:!P,onNavigate:n,onAsk:l}):null}),jsxRuntime.jsx(reactNative.View,{style:s.inset,children:jsxRuntime.jsx(Fn,{requests:C,petName:t,activeOnly:true,onOpen:I})}),B(true),L(true)]});break;case "error":H=jsxRuntime.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=jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:s.content,testID:"dashboard-in-progress",children:[E?jsxRuntime.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,jsxRuntime.jsx(Fn,{requests:C,petName:t,onOpen:I}),B(false),jsxRuntime.jsx(Tr,{disclaimer:j})]});break;case "none":H=jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:s.content,testID:"dashboard-request-prompt",children:[jsxRuntime.jsxs(reactNative.View,{style:d.promptCard,children:[jsxRuntime.jsxs(reactNative.View,{style:d.promptHeader,children:[jsxRuntime.jsx(reactNative.View,{style:d.promptGlyph,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxRuntime.jsx(m,{style:d.promptTitle,children:$t.title(t)})]}),jsxRuntime.jsx(m,{style:d.promptBody,children:$t.body}),n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(X,{label:$t.requestFromClinic,accessibilityLabel:$t.requestFromClinicA11y(t),onPress:()=>n({name:"clinicPicker"}),style:d.promptCta,testID:"dashboard-request-prompt-clinic"}),jsxRuntime.jsx(X,{label:$t.uploadDocument,kind:"outline",accessibilityLabel:$t.uploadDocumentA11y(t),onPress:()=>n({name:"upload"}),style:d.promptCtaSecondary,testID:"dashboard-request-prompt-upload"})]}):null]}),jsxRuntime.jsx(Fn,{requests:C,petName:t,onOpen:I}),jsxRuntime.jsx(Tr,{disclaimer:j})]});break;case "labs_only":H=jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:s.contentTight,testID:"dashboard-labs-only",children:[D,jsxRuntime.jsx(reactNative.View,{style:s.inset,children:jsxRuntime.jsx(Fn,{requests:C,petName:t,activeOnly:true,onOpen:I})}),B(true),jsxRuntime.jsx(reactNative.View,{style:s.inset,children:jsxRuntime.jsx(Tr,{disclaimer:j})}),L(false)]});break;default:H=vr(q);}return jsxRuntime.jsxs(reactNative.View,{style:[s.root,c],children:[jsxRuntime.jsx(Ke,{title:yt.title,onBack:a,testID:"dashboard-header",right:n?jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>n({name:"timeline"}),accessibilityRole:"button",accessibilityLabel:yt.openTimeline,hitSlop:12,style:d.headerButton,testID:"dashboard-timeline-link",children:jsxRuntime.jsx(zl,{})}):void 0}),jsxRuntime.jsx(reactNative.View,{style:s.body,children:H}),jsxRuntime.jsx(ad,{marker:b?.marker??null,point:b?.point??null,onClose:()=>R(null),onAsk:T}),jsxRuntime.jsx(qe,{})]})}i(Xg,"DashboardBody");function Wo({label:e,onPress:t,testID:r}){let o=Bs();return jsxRuntime.jsxs(reactNative.Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:e,style:o.actionRow,testID:r,children:[jsxRuntime.jsxs(reactNative.View,{style:o.actionLeft,children:[jsxRuntime.jsx(reactNative.View,{style:o.actionIcon,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxRuntime.jsx(m,{style:o.actionLabel,children:e})]}),jsxRuntime.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=jsxRuntime.jsxs(reactNative.View,{style:a.inProgressInner,children:[jsxRuntime.jsxs(reactNative.View,{style:a.inProgressHead,children:[jsxRuntime.jsx(m,{style:a.inProgressTitle,children:l}),r?jsxRuntime.jsx(rr,{}):null]}),jsxRuntime.jsx(jo,{request:e}),c.length>0?jsxRuntime.jsx(reactNative.View,{style:n.statusCard,children:jsxRuntime.jsx(m,{style:n.statusText,children:c})}):null]});return jsxRuntime.jsxs(reactNative.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?jsxRuntime.jsx(reactNative.Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:kr.openA11y(t,c),testID:"dashboard-in-progress-open",children:s}):s,o?jsxRuntime.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 react.useMemo(()=>Zg(e),[e])}i(Bs,"useLocalStyles");function Zg(e){let{color:t,space:r,radius:o,type:n}=e,a=reactNative.StyleSheet.hairlineWidth,l=r.xxl+r.md;return reactNative.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 jsxRuntime.jsx(Bd,{state:o,style:t,onBack:r,header:jsxRuntime.jsx(Ke,{title:be.timeline,onBack:yn(r),testID:"timeline-header"}),loading:jsxRuntime.jsx(Ql,{testID:"timeline-loading"}),empty:jsxRuntime.jsx(Ue,{variant:"no_records",testID:"timeline-empty"}),render:n=>jsxRuntime.jsx(ub,{timeline:n})})}i(Nd,"EverfurRecordsTimeline");function Md({petRef:e,docId:t,style:r,onBack:o}){let n=react.useCallback((c,s)=>c.getDocumentContributions(s,t),[t]),a=Yt(e,n,lb,t),l=a.value?.document?.title?.trim()||be.uploadedDocument;return jsxRuntime.jsx(Bd,{state:a,style:r,onBack:o,header:jsxRuntime.jsx(Ke,{title:l,onBack:yn(o),testID:"contributions-header"}),empty:jsxRuntime.jsx(Ue,{variant:"no_records",testID:"contributions-empty"}),render:c=>jsxRuntime.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 jsxRuntime.jsx(Ve,{capability:"records",style:t,...Fe(yn(l),Ye),children:jsxRuntime.jsxs(reactNative.View,{style:[c.container,t],children:[r??null,jsxRuntime.jsx(reactNative.View,{style:c.body,children:cb(e,a,c,o,n)}),jsxRuntime.jsx(qe,{})]})})}i(Bd,"DepthSurface");function cb(e,t,r,o,n){switch(e.status){case "loading":return o??jsxRuntime.jsx(db,{styles:r});case "empty":return n??jsxRuntime.jsx(reactNative.View,{style:r.centered,accessible:true,accessibilityRole:"summary",accessibilityLabel:ye.empty,children:jsxRuntime.jsx(reactNative.View,{style:r.emptyGlyph})});case "error":return e.error?jsxRuntime.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]=react.useState(false);return react.useEffect(()=>{let o=setTimeout(()=>r(true),ib);return ()=>clearTimeout(o)},[]),jsxRuntime.jsx(reactNative.View,{style:e.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:ye.loading,children:t?jsxRuntime.jsx(reactNative.ActivityIndicator,{}):null})}i(db,"LoadingState");function ub({timeline:e}){let t=Hs(),r=qd(e);return jsxRuntime.jsxs(reactNative.ScrollView,{style:t.list,contentContainerStyle:t.timelineContent,accessibilityLabel:be.timeline,children:[e.disclaimer.length>0?jsxRuntime.jsx(reactNative.View,{style:t.timelineBand,accessible:true,accessibilityRole:"text",accessibilityLabel:yt.important(e.disclaimer),children:jsxRuntime.jsx(m,{style:t.timelineBandText,children:e.disclaimer})}):null,r.map((o,n)=>jsxRuntime.jsxs(reactNative.View,{children:[n>0?jsxRuntime.jsx(reactNative.View,{style:t.timelineSeparator}):null,jsxRuntime.jsxs(reactNative.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:[jsxRuntime.jsx(reactNative.View,{style:t.timelineBubble,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxRuntime.jsxs(reactNative.View,{style:t.timelineBody,children:[jsxRuntime.jsxs(reactNative.View,{style:t.topLine,children:[jsxRuntime.jsx(m,{style:t.timelineKind,children:o.kindLabel}),jsxRuntime.jsx(m,{style:t.date,children:o.date})]}),jsxRuntime.jsx(m,{style:t.timelineTitle,children:o.title}),o.detail?jsxRuntime.jsx(m,{style:t.rowDetail,children:o.detail}):null]})]})]},o.key))]})}i(ub,"TimelineBody");function pb({view:e}){let t=Hs();return jsxRuntime.jsxs(reactNative.ScrollView,{style:t.list,contentContainerStyle:t.listContent,accessibilityLabel:ye.records,children:[e.document?.receivedAt?jsxRuntime.jsx(m,{style:t.rowDetail,children:J(e.document.receivedAt)}):null,jsxRuntime.jsx(reactNative.View,{style:t.card,children:e.contributions.map(r=>jsxRuntime.jsxs(reactNative.View,{style:t.row,accessible:true,accessibilityRole:"text",children:[jsxRuntime.jsx(m,{style:t.rowTitle,children:r.label}),jsxRuntime.jsx(m,{style:t.rowValue,children:Yr(r.value,r.unit)}),r.observedAt?jsxRuntime.jsx(m,{style:t.rowDetail,children:J(r.observedAt)}):null]},r.key))})]})}i(pb,"ContributionsBody");function Hs(){let e=V();return react.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=reactNative.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 reactNative.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]=react.useState(null),[c,s]=react.useState(true),[d,u]=react.useState(null),[p,f]=react.useState(null),b=p===true,[R,v]=react.useState({}),[w,g]=react.useState(false),[y,x]=react.useState(null),[h,P]=react.useState(false),[S,E]=react.useState(false),C=Wn(e),I=react.useRef(0),F=react.useRef(true),q=react.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]);react.useEffect(()=>(F.current=true,q(),()=>{F.current=false,I.current+=1;}),[q]);let j=react.useRef(C);react.useEffect(()=>{j.current!==C&&(j.current=C,v({}),E(true),q());},[C,q]);let $=react.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=react.useCallback(async D=>{x(D);let L=await r.revokeShare(e,D);return F.current&&(x(null),q()),L},[r,e,q]),oe=react.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=react.useCallback(()=>{E(false),q();},[q]),ie=react.useMemo(()=>Wl(a??[],R,n()),[a,R,n]),T=c?"loading":d!==null?"error":ie.length===0?"empty":"populated";return react.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=react.useMemo(()=>({}),[t,e,r]),[n,a]=react.useState({scope:o,lit:null});react.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 react.useMemo(()=>({lit:l}),[l])}i(js,"useRecordsDepthProbe");function $s(e){let t=yr(),o=js(e).lit===true,[n,a]=react.useState(false),[l,c]=react.useState(null),s=react.useRef(true);react.useEffect(()=>(s.current=true,()=>{s.current=false;}),[]);let d=react.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 react.useMemo(()=>({preparing:n,available:o,error:l,pdfLink:d}),[n,o,l,d])}i($s,"useRecordPdfLink");async function $d(e){await reactNative.Share.share({message:ae.shareMessage(e),url:e});}i($d,"shareLinkViaOs");async function Qo(e){await reactNative.Share.share(reactNative.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 jsxRuntime.jsx(Ve,{capability:"records",style:t,...r?{renderPending:r}:{},...Fe(o.onBack,Ye),children:jsxRuntime.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=react.useMemo(()=>Hr(o,u.consent),[o,u.consent]),R=react.useMemo(()=>nn(u,o),[u,o]),v=p.value!==null&&!p.value.withheld&&p.value.available?p.value:null,w=u.record,[g,y]=react.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=jsxRuntime.jsx(reactNative.View,{style:s.centered,accessible:true,accessibilityRole:"progressbar",accessibilityLabel:yt.loading,testID:"record-document-loading",children:jsxRuntime.jsx(reactNative.ActivityIndicator,{color:d.color.brandInk})});else if(u.status==="error"){let S=Pr(u,b);h=S.kind==="error"||S.kind==="pet_not_found"?jsxRuntime.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=jsxRuntime.jsx(reactNative.View,{style:s.centered,testID:"record-document-empty",children:jsxRuntime.jsx(m,{style:s.emptyText,children:It.empty})}):(P=true,h=jsxRuntime.jsx(xb,{record:w,depth:v,petName:t,wordmark:d.meta.displayName}));return jsxRuntime.jsxs(reactNative.View,{style:[c.root,s.root,l],children:[jsxRuntime.jsx(Ke,{title:It.title,variant:"document",onBack:n,testID:"record-document-header",right:f.available&&P?jsxRuntime.jsx(reactNative.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?jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:d.color.brandInk}):jsxRuntime.jsx(Ml,{})}):void 0}),f.error?jsxRuntime.jsx(m,{style:[c.errorText,s.inset],accessibilityRole:"alert",children:f.error.displayMessage}):g?jsxRuntime.jsx(m,{style:[c.errorText,s.inset],accessibilityRole:"alert",testID:"record-document-share-failed",children:ae.toasts.pdfShareSheet}):null,jsxRuntime.jsx(reactNative.View,{style:c.body,children:h}),jsxRuntime.jsx(qe,{})]})}i(wb,"DocumentBody");function xb({record:e,depth:t,petName:r,wordmark:o}){let n=Kd(),a=react.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)=>jsxRuntime.jsxs(reactNative.View,{style:n.section,testID:u,children:[jsxRuntime.jsxs(reactNative.View,{style:n.sectionHeader,children:[jsxRuntime.jsx(m,{style:n.sectionTitle,accessibilityRole:"header",children:s}),jsxRuntime.jsx(reactNative.View,{style:n.rule})]}),jsxRuntime.jsx(reactNative.View,{children:d})]},u),"section");return jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:n.page,showsVerticalScrollIndicator:false,testID:"record-document",children:[jsxRuntime.jsxs(reactNative.View,{style:n.letterhead,children:[jsxRuntime.jsx(m,{style:n.wordmark,children:o}),jsxRuntime.jsx(m,{style:n.docTitle,children:It.docTitle}),jsxRuntime.jsx(m,{style:n.petName,children:r?.trim()||It.namelessPet}),jsxRuntime.jsx(m,{style:n.generated,children:It.generated(e.generatedAt)})]}),e.identity.length>0?c(It.identity,e.identity.map((s,d)=>jsxRuntime.jsxs(reactNative.View,{style:[n.row,d>0?n.rowDivider:null],children:[jsxRuntime.jsx(m,{style:n.rowLabel,children:s.label}),jsxRuntime.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 jsxRuntime.jsxs(reactNative.View,{style:[n.row,u.outOfRange?n.rowFlag:null,d>0?n.rowDivider:null],children:[jsxRuntime.jsxs(reactNative.View,{style:n.rowMain,children:[jsxRuntime.jsx(m,{style:n.rowLabel,children:s.name}),jsxRuntime.jsxs(m,{style:n.rowMeta,children:[p?It.ref(p):It.noRange,s.latest.at?` \xB7 ${J(s.latest.at)}`:""]})]}),jsxRuntime.jsxs(reactNative.View,{style:n.rowRight,children:[f!=="-"?jsxRuntime.jsx(m,{style:[n.rowValue,u.outOfRange?n.rowValueAlert:null],children:f}):null,jsxRuntime.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 jsxRuntime.jsx(reactNative.View,{style:[n.row,p>0?n.rowDivider:null],children:jsxRuntime.jsxs(reactNative.View,{style:n.rowMain,children:[jsxRuntime.jsx(m,{style:n.rowLabel,children:u.label}),f?jsxRuntime.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 jsxRuntime.jsxs(reactNative.View,{style:[n.row,d>0?n.rowDivider:null],children:[jsxRuntime.jsxs(reactNative.View,{style:n.rowMain,children:[jsxRuntime.jsx(m,{style:n.rowLabel,children:s.title}),s.detail?jsxRuntime.jsx(m,{style:n.rowMeta,children:s.detail}):null]}),u?jsxRuntime.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)=>jsxRuntime.jsxs(reactNative.View,{style:[n.block,d>0?n.rowDivider:null],children:[s.observedOn?jsxRuntime.jsx(m,{style:n.blockDate,children:J(s.observedOn)}):null,s.systems.filter(u=>u.finding).map(u=>jsxRuntime.jsxs(reactNative.View,{style:n.fieldRow,children:[jsxRuntime.jsx(m,{style:n.fieldLabel,children:qr(u.system)}),jsxRuntime.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)=>jsxRuntime.jsxs(reactNative.View,{style:[n.block,d>0?n.rowDivider:null],children:[s.observedOn?jsxRuntime.jsx(m,{style:n.blockDate,children:J(s.observedOn)}):null,s.sections.filter(u=>u.text).map((u,p)=>jsxRuntime.jsxs(reactNative.View,{style:n.noteSection,children:[jsxRuntime.jsx(m,{style:n.noteLabel,children:Qr(u.section)}),jsxRuntime.jsx(m,{style:n.noteBody,children:u.text})]},`${u.section}-${p}`))]},s.noteId)),"record-document-notes"):null,e.disclaimer.length>0?jsxRuntime.jsx(reactNative.View,{style:n.disclaimer,children:jsxRuntime.jsx(m,{style:n.disclaimerText,children:e.disclaimer})}):null]})}i(xb,"RecordDocument");function Kd(){let e=V();return react.useMemo(()=>Cb(e),[e])}i(Kd,"useLocalStyles");function Cb(e){let{color:t,space:r,radius:o,type:n}=e,a=reactNative.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 reactNative.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]=react.useState(null),[u,p]=react.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 jsxRuntime.jsx(reactNative.Modal,{transparent:true,visible:true,animationType:"slide",onRequestClose:t,children:jsxRuntime.jsxs(reactNative.View,{style:a.backdrop,children:[jsxRuntime.jsx(reactNative.Pressable,{style:qo,accessibilityRole:"button",accessibilityLabel:ae.closeSheetA11y,onPress:t}),jsxRuntime.jsxs(reactNative.View,{style:a.sheet,accessibilityViewIsModal:true,testID:"share-record-sheet",children:[jsxRuntime.jsx(reactNative.View,{style:a.handle}),jsxRuntime.jsxs(reactNative.View,{style:a.header,children:[jsxRuntime.jsxs(reactNative.View,{style:a.headerText,children:[jsxRuntime.jsx(m,{style:a.title,accessibilityRole:"header",children:ae.title}),jsxRuntime.jsx(m,{style:a.helper,children:ae.helper})]}),jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:ae.close,onPress:t,hitSlop:12,style:a.closeButton,testID:"share-record-close",children:jsxRuntime.jsx(m,{style:a.closeGlyph,children:"\xD7"})})]}),jsxRuntime.jsxs(reactNative.ScrollView,{style:a.scroll,contentContainerStyle:a.body,showsVerticalScrollIndicator:false,children:[jsxRuntime.jsxs(reactNative.View,{style:a.actions,children:[r?jsxRuntime.jsx(X,{label:ae.viewDocument,onPress:()=>{t(),r({name:"document"});},testID:"share-view-document"}):null,f?jsxRuntime.jsx(X,{label:c.creating?ae.creatingLink:ae.createLink,kind:"outline",busy:c.creating,onPress:R,testID:"share-create-link"}):null,f?jsxRuntime.jsx(X,{label:c.preparingPdf?ae.preparingPdf:ae.downloadPdf,kind:"outline",busy:c.preparingPdf,onPress:v,testID:"share-download-pdf"}):null]}),c.consentRequired?jsxRuntime.jsxs(reactNative.View,{style:a.stateCard,testID:"share-consent-off",children:[jsxRuntime.jsx(m,{style:a.stateTitle,accessibilityRole:"header",children:ae.consentOffTitle}),jsxRuntime.jsx(m,{style:a.stateBody,children:ae.consentOffBody}),jsxRuntime.jsx(X,{label:ae.retry,kind:"outline",onPress:c.refresh,testID:"share-consent-retry"})]}):null,s?jsxRuntime.jsx(m,{style:a.notice,accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"share-notice",children:s}):null,Ud(c)?jsxRuntime.jsxs(reactNative.View,{style:a.section,children:[jsxRuntime.jsx(m,{style:a.sectionLabel,accessibilityRole:"header",children:ae.activeLinks}),c.status==="loading"?jsxRuntime.jsx(Jl,{testID:"share-record-loading"}):c.status==="error"?jsxRuntime.jsxs(reactNative.View,{style:a.stateCard,testID:"share-record-error",children:[jsxRuntime.jsx(m,{style:a.stateTitle,children:ae.errorTitle}),jsxRuntime.jsx(m,{style:a.stateBody,children:ae.errorBody}),jsxRuntime.jsx(X,{label:ae.retry,kind:"outline",onPress:c.refresh,testID:"share-record-retry"})]}):c.rows.length===0?jsxRuntime.jsxs(reactNative.View,{style:a.stateCard,testID:"share-record-empty",children:[jsxRuntime.jsx(m,{style:a.stateTitle,children:ae.emptyTitle}),jsxRuntime.jsx(m,{style:a.stateBody,children:ae.emptyBody})]}):jsxRuntime.jsx(reactNative.View,{style:a.list,children:c.rows.map(y=>jsxRuntime.jsxs(reactNative.View,{style:a.row,testID:`share-row-${y.shareId}`,children:[jsxRuntime.jsxs(reactNative.View,{accessible:true,accessibilityRole:"text",accessibilityLabel:y.a11yLabel,children:[jsxRuntime.jsxs(reactNative.View,{style:a.statusLine,children:[jsxRuntime.jsx(reactNative.View,{style:[a.statusDot,{backgroundColor:y.active?a.active.color:a.inactive.color}],accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxRuntime.jsx(m,{style:a.status,children:y.statusLabel}),jsxRuntime.jsx(m,{style:a.expiry,children:y.expiryLabel})]}),y.createdLabel?jsxRuntime.jsx(m,{style:a.created,children:y.createdLabel}):null]}),y.shareUrl!==null&&!n?jsxRuntime.jsx(m,{selectable:true,style:a.url,testID:`share-url-${y.shareId}`,children:y.shareUrl}):null,u===y.shareId?jsxRuntime.jsxs(reactNative.View,{style:a.confirm,testID:`share-revoke-confirm-${y.shareId}`,children:[jsxRuntime.jsx(m,{style:a.confirmText,children:ae.confirmTurnOff}),jsxRuntime.jsxs(reactNative.View,{style:a.rowActions,children:[jsxRuntime.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}`}),jsxRuntime.jsx(X,{label:ae.keep,kind:"outline",disabled:c.revokingId===y.shareId,onPress:()=>p(null),testID:`share-revoke-cancel-${y.shareId}`})]})]}):jsxRuntime.jsxs(reactNative.View,{style:a.rowActions,children:[n?jsxRuntime.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,jsxRuntime.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]}),jsxRuntime.jsx(reactNative.View,{style:l.inset})]})]})})}i(Zd,"ShareSheet");function Tb(){let e=V();return react.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=reactNative.StyleSheet.hairlineWidth,c=i((s,d,u,p="regular")=>({...k(e,p),fontSize:s,lineHeight:Math.round(s*d),color:u}),"text");return reactNative.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 jsxRuntime.jsx(Ve,{capability:"records",style:t,...r?{renderPending:r}:{},...Fe(o.onBack,Ye),children:jsxRuntime.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]=react.useState(false),y=react.useMemo(()=>Hr(o,f.consent),[o,f.consent]),x=react.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=jsxRuntime.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"?jsxRuntime.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=jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:u.content,testID:"everfur-record-empty",children:[jsxRuntime.jsx(Ue,{variant:"no_records",message:I>0?Z.inReview(I):void 0}),jsxRuntime.jsx(Tr,{disclaimer:P?.disclaimer??""})]});}else C=jsxRuntime.jsx(reactNative.ScrollView,{contentContainerStyle:p.content,testID:"everfur-record",children:jsxRuntime.jsx(Mo,{record:P,depth:h,petName:t,onNavigate:n,onAsk:l,factEdit:R})});return jsxRuntime.jsxs(reactNative.View,{style:[u.root,d],children:[jsxRuntime.jsx(Ke,{title:Z.title,onBack:a,testID:"everfur-record-header",right:E||n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n?jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>n({name:"clinicBatch"}),accessibilityRole:"button",accessibilityLabel:Z.requestClinicsA11y,hitSlop:8,style:p.share,testID:"everfur-record-request-clinics",children:jsxRuntime.jsx(Nl,{})}):null,E?jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>g(true),accessibilityRole:"button",accessibilityLabel:Z.shareA11y,hitSlop:8,style:p.share,testID:"everfur-record-share",children:jsxRuntime.jsx(Fl,{})}):null]}):void 0}),jsxRuntime.jsx(reactNative.View,{style:u.body,children:C}),w?jsxRuntime.jsx(Zd,{petRef:e,onClose:()=>g(false),onNavigate:n,...c?{onOpenUrl:c}:{},...s?{onCopy:s}:{}}):null,jsxRuntime.jsx(qe,{})]})}i(Ob,"RecordBody");function Lb(){let e=V();return react.useMemo(()=>Vb(e),[e])}i(Lb,"useLocalStyles");function Vb(e){let{space:t,radius:r}=e;return reactNative.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]=react.useState(false),a=react.useCallback(()=>{n(true),e().finally(()=>n(false));},[e]);return jsxRuntime.jsx(reactNative.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 jsxRuntime.jsx(Ve,{capability:"records",style:t,...r?{renderPending:r}:{},...Fe(o.onBack,Ye),children:jsxRuntime.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 jsxRuntime.jsxs(reactNative.View,{style:[s.root,c],children:[jsxRuntime.jsx(Ke,{title:"",onBack:l,testID:"upload-header"}),jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:d.content,testID:"upload-screen",children:[jsxRuntime.jsxs(reactNative.View,{style:d.header,children:[jsxRuntime.jsx(reactNative.View,{style:d.iconBubble,accessibilityElementsHidden:true,importantForAccessibility:"no"}),jsxRuntime.jsx(m,{style:d.title,accessibilityRole:"header",children:Ze.title(t)}),jsxRuntime.jsx(m,{style:d.subtitle,children:Ze.subtitle(t)})]}),jsxRuntime.jsx(Js,{records:p,requestId:null,onPickDocument:o,canUpload:f,onDone:a?b=>a({name:"request",requestId:b}):void 0})]}),jsxRuntime.jsx(qe,{})]})}i(Ub,"UploadBody");function Js({records:e,requestId:t,onPickDocument:r,canUpload:o,onDone:n}){let a=me(),l=au(),[c,s]=react.useState(null),[d,u]=react.useState(0),p=react.useRef(t),f=react.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=react.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=react.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=react.useCallback(()=>{g(f.current);},[g]);return jsxRuntime.jsxs(reactNative.View,{style:l.card,testID:"records-upload-card",children:[jsxRuntime.jsx(m,{style:l.cardTitle,accessibilityRole:"header",children:Ze.cardTitle}),jsxRuntime.jsx(m,{style:l.cardSubtitle,children:Ze.cardSubtitle}),c?jsxRuntime.jsx(reactNative.View,{style:a.errorBanner,accessibilityRole:"alert",children:jsxRuntime.jsx(m,{style:a.errorText,children:c})}):null,jsxRuntime.jsx(Pd,{records:e}),e.isUploading?jsxRuntime.jsx(reactNative.View,{style:l.uploadingRow,children:jsxRuntime.jsx(m,{style:l.progressText,children:Ze.uploading(R,b.length)})}):w?jsxRuntime.jsxs(reactNative.View,{style:l.settled,children:[R>0?jsxRuntime.jsx(m,{style:l.success,accessibilityRole:"alert",children:Ze.received(R)}):null,v>0?jsxRuntime.jsx(X,{label:Ze.retryFailed(v),kind:"link",accessibilityLabel:Ze.retryFailedA11y(v),onPress:x,testID:"records-upload-retry-failed"}):null,jsxRuntime.jsxs(reactNative.View,{style:l.settledActions,children:[jsxRuntime.jsx(X,{label:Ze.addMore,kind:"link",accessibilityLabel:Ze.addMoreA11y,disabled:!o,onPress:y,testID:"records-upload-another"}),n&&p.current!==null&&R>0?jsxRuntime.jsx(X,{label:Ze.done,accessibilityLabel:Ze.doneA11y,onPress:()=>n(p.current),testID:"records-upload-done"}):null]})]}):jsxRuntime.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 react.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 reactNative.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:reactNative.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 jsxRuntime.jsx(Ve,{capability:"records",style:t,...r?{renderPending:r}:{},...Fe(o.onBack,Ye),children:jsxRuntime.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=jsxRuntime.jsx(mo,{testID:"records-request-loading"}):b.status==="error"&&b.error?y=jsxRuntime.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=jsxRuntime.jsx(Ue,{variant:"no_requests",testID:"records-request-missing"}):p===null?y=jsxRuntime.jsx(Ue,{variant:"error",testID:"records-request-error"}):y=jsxRuntime.jsx(Jb,{request:R,records:b,canUpload:v,onPickDocument:o,onNavigate:a,nowMs:s,refreshControl:g},JSON.stringify([p,f,R.id])),jsxRuntime.jsxs(reactNative.View,{style:[d.root,c],children:[jsxRuntime.jsx(Ke,{title:w,onBack:l,testID:"records-request-header"}),jsxRuntime.jsx(reactNative.KeyboardAvoidingView,{behavior:"padding",style:d.body,children:y}),jsxRuntime.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]=react.useState(null),[b,R]=react.useState(false),[v,w]=react.useState(null),g=react.useRef(true);react.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 jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:s.content,keyboardShouldPersistTaps:"handled",refreshControl:l,testID:`records-request-${y.id}`,children:[jsxRuntime.jsx(jo,{request:y}),y.status==="awaiting_upload"?jsxRuntime.jsx(Js,{records:t,requestId:y.id,onPickDocument:o,canUpload:r}):null,y.statusLabel.length>0?jsxRuntime.jsx(reactNative.View,{style:c.statusCard,accessibilityRole:"summary",children:jsxRuntime.jsx(m,{style:c.statusText,children:y.statusLabel})}):null,F&&!C?jsxRuntime.jsx(reactNative.View,{style:c.infoNote,accessibilityRole:"summary",children:jsxRuntime.jsx(m,{style:c.infoNoteText,children:F})}):y.wireStatus==="awaiting_response"&&!C?jsxRuntime.jsx(reactNative.View,{style:c.infoNote,accessibilityRole:"summary",children:jsxRuntime.jsx(m,{style:c.infoNoteText,children:he.awaitingNote})}):null,C?jsxRuntime.jsx(reactNative.View,{style:c.cautionNote,accessibilityRole:"summary",testID:"records-request-waiting-banner",children:jsxRuntime.jsx(m,{style:c.cautionNoteText,children:he.waitingBanner(I)})}):null,h&&n?jsxRuntime.jsx(X,{label:he.viewRecords,onPress:()=>n({name:"dashboard"}),style:s.readyCta,testID:"records-request-view-dashboard"}):null,j?jsxRuntime.jsxs(reactNative.View,{style:[s.failureCard,S?s.failureCritical:s.failureCaution],accessibilityRole:"summary",testID:"records-failure-card",children:[jsxRuntime.jsx(m,{style:[s.failureTitle,S?s.failureTitleCritical:s.failureTitleCaution],children:il(y)}),y.canUpdateClinicEmail!==true&&y.canRetrySend!==true?jsxRuntime.jsx(m,{style:c.rowDetail,children:he.nextStep}):null,y.canUpdateClinicEmail===true?jsxRuntime.jsxs(reactNative.View,{style:s.emailBlock,children:[jsxRuntime.jsx(m,{style:c.fieldLabel,children:zt.email}),jsxRuntime.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?jsxRuntime.jsx(m,{style:c.errorText,accessibilityRole:"alert",children:he.errors.invalidEmail}):null,jsxRuntime.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?jsxRuntime.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?jsxRuntime.jsx(m,{style:c.rowDetail,children:zt.retryHint}):null,oe&&(p==="email"||p==="retry")?jsxRuntime.jsx(reactNative.View,{style:c.errorBanner,accessibilityRole:"alert",children:jsxRuntime.jsx(m,{style:c.errorText,children:oe})}):null]}):null,(S||E)&&n?jsxRuntime.jsx(X,{label:he.tryAnotherClinic,kind:"outline",accessibilityLabel:he.tryAnotherClinicA11y,onPress:()=>n({name:"clinicPicker"}),testID:"records-request-try-another-clinic"}):null,q!==null?jsxRuntime.jsxs(reactNative.View,{style:s.callBlock,children:[jsxRuntime.jsx(Id,{call:q,prompt:y.statusLabel}),y.canRetrySend===true?jsxRuntime.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,$?jsxRuntime.jsxs(reactNative.View,{style:s.block,children:[jsxRuntime.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"}),jsxRuntime.jsx(m,{style:c.muted,children:he.convertHint}),oe&&p==="convert"?jsxRuntime.jsx(reactNative.View,{style:c.errorBanner,accessibilityRole:"alert",children:jsxRuntime.jsx(m,{style:c.errorText,children:oe})}):null]}):null,ce?jsxRuntime.jsxs(reactNative.View,{style:s.block,children:[jsxRuntime.jsx(X,{label:b?he.freshUploadStarting:he.freshUpload,kind:S||E?"outline":"primary",busy:b,onPress:ie,testID:"records-upload-own-fresh"}),v?jsxRuntime.jsx(reactNative.View,{style:c.errorBanner,accessibilityRole:"alert",children:jsxRuntime.jsx(m,{style:c.errorText,children:v})}):null]}):null,oe&&p==="revoke"?jsxRuntime.jsx(reactNative.View,{style:c.errorBanner,accessibilityRole:"alert",children:jsxRuntime.jsx(m,{style:c.errorText,children:oe})}):null,y.canRevoke===true?u.confirmingRevoke?jsxRuntime.jsxs(reactNative.View,{style:s.block,testID:"records-revoke-confirm",children:[jsxRuntime.jsx(m,{style:s.confirmTitle,accessibilityRole:"header",children:zt.cancelQuestion}),jsxRuntime.jsx(m,{style:c.bodyText,children:zt.cancelConsequence}),jsxRuntime.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"}),jsxRuntime.jsx(X,{label:zt.keepRequest,kind:"outline",disabled:u.busy,onPress:u.keepRequest,testID:"records-revoke-keep"})]}):jsxRuntime.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 react.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 reactNative.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]=react.useReducer(vi,u,Xn),h=Jn(y),P=y.stack.length;react.useEffect(()=>{let j=i(()=>P<=1?false:(x({type:"pop"}),true),"onBackPress"),$=reactNative.BackHandler.addEventListener("hardwareBackPress",j);return ()=>{$.remove();}},[P]);let S=react.useCallback(j=>x({type:"navigate",screen:j}),[]),E=react.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 jsxRuntime.jsx(Ms,{petRef:t,...C,...I,...q,style:f});case "request":return jsxRuntime.jsx(ea,{petRef:t,requestId:h.requestId,...C,...I,...F,...q,style:f});case "timeline":return jsxRuntime.jsx(Nd,{petRef:t,...C,style:f});case "record":return jsxRuntime.jsx(Ks,{petRef:t,...C,...I,...q,style:f});case "document":return jsxRuntime.jsx(Ws,{petRef:t,...C,...I,...q,style:f});case "contributions":return jsxRuntime.jsx(Md,{petRef:t,docId:h.docId,...C,style:f});case "clinicPicker":return jsxRuntime.jsx(Wi,{petRef:t,...C,...n?{controller:n}:{},...o?{recordsController:o}:{},style:f});case "clinicBatch":return jsxRuntime.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 jsxRuntime.jsx(bs,{petRef:t,clinic:h.clinic,...C,...s!==void 0?{ownerName:s}:{},...d?{onCaptureSignature:d}:{},...n?{controller:n}:{},style:f});case "upload":return jsxRuntime.jsx(Xs,{petRef:t,...C,...o?{controller:o}:{},...F,...q,style:f});case "requests":return jsxRuntime.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 jsxRuntime.jsx(Ve,{capability:"recordsClinic",...Fe(e.onClose,K.cancel),children:t===null?jsxRuntime.jsx(m,{accessibilityRole:"alert",children:ye.sessionRequired}):jsxRuntime.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]=react.useState(null),n=react.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)=>jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:p,accessibilityState:{disabled:b},disabled:b,onPress:f,style:[s,{justifyContent:"center",opacity:b?.5:1}],children:jsxRuntime.jsx(m,{style:d,children:p})}),"button");return jsxRuntime.jsxs(reactNative.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:[jsxRuntime.jsx(m,{accessibilityRole:"header",style:[d,{...k(c,"bold"),fontSize:c.type.size.heading}],children:K.title}),jsxRuntime.jsx(m,{style:d,children:e.petName}),a.created?jsxRuntime.jsx(m,{accessibilityLiveRegion:"polite",style:d,children:a.created.statusLabel||ye.records}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(m,{style:d,children:K.ownerName}),jsxRuntime.jsx(He,{accessibilityLabel:K.ownerName,style:s,value:a.ownerName,maxLength:200,editable:!a.busy,autoComplete:"name",onChangeText:a.setOwnerName}),jsxRuntime.jsx(m,{style:d,children:K.clinic}),jsxRuntime.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&&jsxRuntime.jsx(m,{accessibilityLiveRegion:"polite",style:d,children:ye.loading}),a.recent.length>0&&jsxRuntime.jsx(m,{accessibilityRole:"header",style:d,testID:"records-clinic-recent-label",children:K.recentlyUsed}),a.recent.map(p=>jsxRuntime.jsx(reactNative.View,{children:u([p.name,p.address,p.phone].filter(Boolean).join(", "),()=>a.selectClinic(p),a.busy)},`recent-${p.id}`)),a.clinics.map(p=>jsxRuntime.jsx(reactNative.View,{children:u([p.name,p.address,p.phone].filter(Boolean).join(", "),()=>a.selectClinic(p),a.busy)},p.id)),a.needsEmail&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(m,{style:d,children:K.email}),jsxRuntime.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})]}),jsxRuntime.jsx(m,{accessibilityRole:"header",style:d,children:K.scopeHeading}),a.copy?jsxRuntime.jsx(m,{style:d,children:a.query.trim()&&a.ownerName.trim()?a.scope??N("internalError").displayMessage:ye.consentRequired}):!a.error&&jsxRuntime.jsx(m,{accessibilityLiveRegion:"polite",style:d,children:ye.loading}),!e.onCaptureSignature&&jsxRuntime.jsx(Mr,{onChange:o,disabled:a.busy}),!l&&jsxRuntime.jsx(m,{accessibilityRole:"alert",style:d,children:K.missingSignature}),a.error&&jsxRuntime.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),jsxRuntime.jsx(qe,{})]})}i(uh,"ClinicRequestBody");
|
|
4
4
|
exports.EverfurClinicPicker=Wi;exports.EverfurClinicRequest=dh;exports.EverfurClinicRequestBatch=ls;exports.EverfurRecordDetail=Ks;exports.EverfurRecordDocument=Ws;exports.EverfurRecords=sh;exports.EverfurRecordsConsent=bs;exports.EverfurRecordsDashboard=Ms;exports.EverfurRecordsFlow=lu;exports.EverfurRecordsRequest=ea;exports.EverfurRecordsRequests=qs;exports.EverfurRecordsUpload=Xs;exports.RECORDS_CLINIC_BATCH_MAX=Gr;exports.RECORDS_TERMINAL=wa;exports.REQUEST_TIMELINE_TITLES=qn;exports.SignaturePad=Mr;exports.applyFactOverlay=Es;exports.buildRequestTimeline=Ds;exports.currentRecordsScreen=Jn;exports.deriveRecordsDashboardState=ki;exports.initialRecordsNav=Xn;exports.isFactEditable=Oo;exports.isTerminalStatus=br;exports.pickPetRecordsRequest=ro;exports.popRecordsNav=Zn;exports.pushRecordsNav=bi;exports.recordsDenialReasonOf=hr;exports.recordsNavReducer=vi;exports.registerRnSignature=Ki;exports.replaceRecordsNav=hi;exports.resetRecordsNav=Ri;exports.selectClinicCall=_o;exports.selectDashboardView=Ti;exports.selectPrimaryLabel=Ur;exports.selectRequestList=ws;exports.selectRequestTitle=To;exports.transitionRecordsNav=Ua;exports.useEverfurRecords=st;exports.useEverfurRecordsClinic=Ut;exports.useEverfurRecordsClinicBatch=Ai;exports.useRecordFactEdit=Ss;exports.useRecordPdfLink=$s;exports.useRecordShares=Us;exports.useRecordsMarkers=ys;
|