@everfur/sdk 0.5.3 → 0.5.5
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 +109 -0
- package/README.md +8 -8
- package/dist/{Chat-a6If51cF.d.cts → Chat-BBnXSZQG.d.cts} +20 -3
- package/dist/{Chat-CNRZEu92.d.ts → Chat-BzvoUe9L.d.ts} +20 -3
- package/dist/{DepthViews-zhn3Rk5Z.d.ts → DepthViews-BYEgUxDQ.d.ts} +1 -1
- package/dist/{DepthViews-Bfv2DTUl.d.ts → DepthViews-CsVphyQL.d.ts} +1 -1
- package/dist/{DepthViews-Cl4AoL3X.d.cts → DepthViews-D-pleytA.d.cts} +1 -1
- package/dist/{DepthViews-kURiusNd.d.cts → DepthViews-DKbfq4bX.d.cts} +1 -1
- package/dist/animations/index.d.cts +3 -3
- package/dist/animations/index.d.ts +3 -3
- package/dist/{attachments-CHgc11hT.d.cts → attachments-BcD6K0IF.d.cts} +5 -5
- package/dist/{attachments-TXOhN36S.d.ts → attachments-CFK3WPF4.d.ts} +5 -5
- package/dist/{attachments-affGN_Uv.d.cts → attachments-CieUG7nB.d.cts} +2 -2
- package/dist/{attachments-5_p7kE38.d.ts → attachments-DorefS77.d.ts} +2 -2
- package/dist/{bookingCopy-BQ7Pg7qg.d.ts → bookingCopy-BUTs_nKf.d.ts} +2 -2
- package/dist/{bookingCopy-BpZvZO1S.d.cts → bookingCopy-Cl3RZ_k2.d.cts} +2 -2
- package/dist/{casesRepository-YCI0OVwl.d.ts → casesRepository-C29WolRA.d.ts} +1 -1
- package/dist/{casesRepository-z2JAFlKA.d.cts → casesRepository-Ct5MO1mM.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 +2 -2
- package/dist/client/index.d.cts +6 -6
- package/dist/client/index.d.ts +6 -6
- package/dist/client/index.js +2 -2
- package/dist/{config-Bkbqkjb0.d.cts → config-BBeF3kv5.d.cts} +1 -1
- package/dist/{config-BXVgTLCh.d.ts → config-Dl8Iqs1i.d.ts} +1 -1
- package/dist/consent/index.d.cts +5 -5
- package/dist/consent/index.d.ts +5 -5
- package/dist/{context-ChPrlKhy.d.cts → context-DGZrfVkE.d.cts} +5 -5
- package/dist/{context-BVpOBDMe.d.ts → context-DXj75_Lo.d.ts} +5 -5
- package/dist/{copy-Be2H2i-D.d.cts → copy-CQHEQwW7.d.cts} +2 -2
- package/dist/{copy-SxmZ-Eps.d.ts → copy-CSbMmuCV.d.ts} +2 -2
- package/dist/core/index.cjs +7 -7
- package/dist/core/index.d.cts +15 -13
- package/dist/core/index.d.ts +15 -13
- package/dist/core/index.js +7 -7
- package/dist/{depth-Dne8Qoss.d.cts → depth-Bb2yphTT.d.cts} +2 -2
- package/dist/{depth-By8dFpLA.d.ts → depth-DRzDoKeE.d.ts} +2 -2
- package/dist/{entitlementRepository-Big-K_In.d.ts → entitlementRepository-S4bU03Ld.d.ts} +9 -2
- package/dist/{entitlementRepository-BmghvtGT.d.cts → entitlementRepository-lwXYn-lq.d.cts} +9 -2
- package/dist/{identity-AuoeDRTh.d.ts → identity-C0r18khM.d.ts} +1 -1
- package/dist/{identity-Z0yj-fC_.d.cts → identity-d2lu16uc.d.cts} +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +12 -12
- package/dist/index.d.ts +12 -12
- 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-DfXGYmMk.d.cts → pets-BZ0384Do.d.cts} +1 -1
- package/dist/{pets-FD-5nMXr.d.ts → pets-CJdq4rRX.d.ts} +1 -1
- package/dist/{petsRepository-CsvreWlY.d.cts → petsRepository-BHooDwb1.d.cts} +1 -1
- package/dist/{petsRepository-BaTOwJ5L.d.ts → petsRepository-DE8scL1O.d.ts} +1 -1
- package/dist/{ports-Dof7AQjk.d.cts → ports-CcUYur16.d.cts} +4 -4
- package/dist/{ports-DNIvfzBP.d.ts → ports-DWL3Nl3j.d.ts} +4 -4
- package/dist/records/depth/index.d.cts +7 -7
- package/dist/records/depth/index.d.ts +7 -7
- package/dist/records/index.d.cts +9 -9
- package/dist/records/index.d.ts +9 -9
- package/dist/{requestFunnel-CJC_q4BZ.d.ts → requestFunnel-C5LPty-S.d.ts} +2 -2
- package/dist/{requestFunnel-DrigK6q_.d.cts → requestFunnel-TtUvlQS1.d.cts} +2 -2
- package/dist/{runtimeTypes-Doj95Gll.d.cts → runtimeTypes-BbLoCs-9.d.cts} +12 -4
- package/dist/{runtimeTypes-BiqMY6pC.d.ts → runtimeTypes-CiJ6Y_wP.d.ts} +12 -4
- 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 +2 -2
- package/dist/server/index.d.cts +3 -3
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +2 -2
- 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/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/rn/index.d.cts +7 -7
- package/dist/testing/rn/index.d.ts +7 -7
- package/dist/testing/web/index.d.cts +7 -7
- package/dist/testing/web/index.d.ts +7 -7
- package/dist/{timelineRows-CHeqZRpM.d.cts → timelineRows-BZ4YqN5G.d.cts} +1 -1
- package/dist/{timelineRows-BHA0gIKH.d.ts → timelineRows-Bv7nr5Oz.d.ts} +1 -1
- package/dist/{useRecordsDepth-ChhS4c6r.d.cts → useRecordsDepth-BYVOh123.d.cts} +1 -1
- package/dist/{useRecordsDepth-CG63cXFZ.d.ts → useRecordsDepth-DuylsLXR.d.ts} +1 -1
- package/dist/{view-2pXv8ex7.d.cts → view-Cqtik97G.d.cts} +2 -2
- package/dist/{view-BKy44Q-3.d.ts → view-Uv0dWIQH.d.ts} +2 -2
- package/dist/web/consent/index.d.cts +5 -5
- package/dist/web/consent/index.d.ts +5 -5
- package/dist/web/index.cjs +10 -10
- package/dist/web/index.d.cts +14 -14
- package/dist/web/index.d.ts +14 -14
- package/dist/web/index.js +10 -10
- package/dist/web/notifications/index.d.cts +3 -3
- package/dist/web/notifications/index.d.ts +3 -3
- package/dist/web/records/depth/index.d.cts +7 -7
- package/dist/web/records/depth/index.d.ts +7 -7
- 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 +9 -8
- package/dist/web/televet/booking/index.d.ts +9 -8
- package/dist/web/televet/booking/index.js +2 -2
- package/package.json +5 -4
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
'use strict';var react=require('react'),reactNativeSafeAreaContext=require('react-native-safe-area-context'),zod=require('zod'),vh=require('react-native-sse'),reactNative=require('react-native'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var vh__default=/*#__PURE__*/_interopDefault(vh);var ff=Object.defineProperty;var i=(e,t)=>ff(e,"name",{value:t,configurable:true});function Re(e){for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let n=e.charCodeAt(t+1);if(!(n>=56320&&n<=57343))return true;t+=1;}else if(r>=56320&&r<=57343)return true}return false}i(Re,"hasLoneSurrogate");function st(e){return [...e].length}i(st,"serverLength");function L(e,t){return Object.freeze(t===void 0?{ok:true,value:e}:{ok:true,value:e,warning:t})}i(L,"ok");function v(e){return Object.freeze({ok:false,error:e})}i(v,"err");function mf(e){return e.ok}i(mf,"isOk");function yf(e){return !e.ok}i(yf,"isErr");var Mr=class Mr extends Error{constructor(t){super(`${t.code}: ${t.displayMessage}`),this.name="EverfurThrownError",this.error=t,this.code=t.code,this.category=t.category,Object.setPrototypeOf(this,Mr.prototype);}};i(Mr,"EverfurThrownError");var Fr=Mr;function gf(e){if(e.ok)return e.value;throw new Fr(e.error)}i(gf,"unwrap");var Lr=class Lr extends Error{constructor(t,r){super(r),this.name="EverfurConfigError",this.kind=t,Object.setPrototypeOf(this,Lr.prototype);}};i(Lr,"EverfurConfigError");var Q=Lr;var ss=128,as=128,ls=/[\u0000-\u001F\u007F]/,hf=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function bf(e){let t=e,r=st(t);if(r===0||r>as)throw new Q("invalid-argument",`petRef must be 1..${as} characters`);if(ls.test(t))throw new Q("invalid-argument","petRef must be printable (no control characters)");return t}i(bf,"petRef");function vf(e){let t=e,r=st(t);if(r===0||r>ss)throw new Q("invalid-argument",`userRef must be 1..${ss} characters`);if(t.includes("@"))throw new Q("invalid-argument","userRef must not contain '@'");if(ls.test(t))throw new Q("invalid-argument","userRef must be printable (no control characters)");return t}i(vf,"userRef");function Ef(e){if(!hf.test(e))throw new Q("invalid-argument","conversationId must be a UUID");return e}i(Ef,"conversationId");var zn=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(zn.map(e=>e.wireCode));var Cf=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"}),ds=Object.freeze(zn.map(e=>Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:Cf[e.wireCode]}))),Rf=new Map(ds.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),Sf=Object.freeze(["http_envelope",...[...new Set(ds.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function Dr(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let n of [t??"http_envelope",...Sf]){let o=Rf.get(n+r);if(o)return o}}i(Dr,"contractErrorFor");function Tf(e){return e.envelope==="sse_frame"?`/errors#sse-${e.wireCode}`:e.envelope==="oauth_error"?`/errors#oauth-${e.wireCode}`:`/errors#${e.wireCode}`}i(Tf,"contractDocUrl");function cs(e){return null}i(cs,"publishedDocUrl");var Pf=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 jn(e){return Pf[e]}i(jn,"categoryFor");function Oe(e){let t=Dr(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),n=r.replace(/[^A-Z0-9]/g,"");if(n==="AUTHREJECTED")return "authRejected";if(r.startsWith("AUTH"))return "authExpired";switch(n){case "DAILYQUOTAEXCEEDED":case "QUOTAEXCEEDED":return "quotaExceeded";case "RATELIMITED":case "TOOMANYREQUESTS":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(Oe,"fromWire");function ps(e){return e===401?"authExpired":e===403?"accessDenied":e===404?"conversationNotFound":e===409?"idempotencyConflict":e===421?"unknown":e===429?"rateLimited":e===400||e===422?"unknown":e>=500?"internalError":"unknown"}i(ps,"fromHttpStatus");var kf=new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function Be(e){return kf.has(e)}i(Be,"isAutoRetryable");var xf=new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function Wn(e){return Be(e)||xf.has(e)}i(Wn,"isRetryableCode");function Nr(e,t=false){return t||Be(e)}i(Nr,"shouldRetry");var _f=500,Gn=8e3,Jt=4;function Ur(e,t=Math.random){let r=Math.max(0,e),n=Math.min(_f*2**r,Gn);return Math.floor(t()*n)}i(Ur,"backoffDelayMs");function fs(e){return e==="conversationNotFound"}i(fs,"canRecreateOnNotFound");var wf=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 Ft(e){return wf[e]}i(Ft,"userFacingError");function ms(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false});}i(ms,"defineHidden");var If=/^[a-z][a-z0-9_]{0,63}$/;function D(e,t){let r=Dr(t?.wireCode,t?.wireEnvelope),n={code:e,category:jn(e),retryable:t?.retryable??Wn(e),displayMessage:Ft(e)};if(t?.httpStatus!==void 0&&(n.httpStatus=t.httpStatus),t?.requestId&&(n.requestId=t.requestId),typeof t?.reasonCode=="string"&&If.test(t.reasonCode)&&(n.reasonCode=t.reasonCode),r);return t?.wireMessage&&ms(n,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&ms(n,"raw",t.raw),Object.freeze(n)}i(D,"makeEverfurError");var Af="file",Kn="multipart upload failed";function Vr(e){let t;try{t=new FormData;for(let[r,n]of Object.entries(e.fields))t.append(r,n);t.append(Af,e.file);}catch{return Promise.reject(new Error(Kn))}return e.fetch!==void 0?Mf(e.fetch,e.url,t,e.signal):Ff(e.url,t,e.signal)}i(Vr,"postRnMultipart");function Of(e){return e>=200&&e<300}i(Of,"stored");function Ff(e,t,r){return new Promise((n,o)=>{let s=globalThis.XMLHttpRequest;if(typeof s!="function"||r?.aborted===true){o(new Error(Kn));return}let a=null,l=i(()=>{a!==null&&r?.removeEventListener("abort",a);},"release"),u=i(()=>{l(),o(new Error(Kn));},"fail");try{let d=new s;d.open("POST",e),d.withCredentials=!1,d.onload=()=>{l(),n(Of(d.status));},d.onerror=u,d.ontimeout=u,d.onabort=u,r!==void 0&&(a=i(()=>{try{d.abort();}finally{u();}},"onAbort"),r.addEventListener("abort",a,{once:!0})),d.send(t);}catch{u();}})}i(Ff,"postWithXhr");function Mf(e,t,r,n){return Promise.resolve().then(()=>e(t,{method:"POST",body:r,credentials:"omit",...n?{signal:n}:{}})).then(o=>o.ok)}i(Mf,"postWithFetch");var Lf="document.pdf",Df="records upload: the file handle has no uri",Nf="records upload failed";function Uf(e={}){return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(Df));let{signal:o,onProgress:s}=n,a=i(()=>Promise.reject(new Error(Nf)),"failed");return o?.aborted===true?a():Vr({url:t.upload_url,fields:t.upload_fields,file:{uri:r.uri,name:Lf,type:"application/pdf"},signal:o,fetch:e.fetch}).then(l=>{if(!l)return a();s?.(1);},a)}})}i(Uf,"createRnRecordsUploadTransport");var Hr=Object.freeze({track(){},trackExpectedFailure(){}});var ys=Object.freeze({shouldRetry(e,t){return Be(e)&&t<Jt},maxAttempts(){return Jt}});var gs=Object.freeze({isAvailable:false,async capture(){return Promise.reject(new Error("CameraPort is unavailable; check isAvailable before calling capture"))}});function Qe(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}i(Qe,"assertNever");function hs(e,t,r=null){return Object.freeze({kind:"accepted",streamId:e,lastEventId:t,serverRequestId:r,terminal:false})}i(hs,"acceptedFrame");function bs(e,t=null){return Object.freeze({kind:"heartbeat",lastEventId:e,serverRequestId:t,terminal:false})}i(bs,"heartbeatFrame");function vs(e,t,r=null){return Object.freeze({kind:"delta",delta:e,lastEventId:t,serverRequestId:r,terminal:false})}i(vs,"deltaFrame");function Es(e,t=null){return Object.freeze({kind:"done",terminal:true,conversationId:e.conversationId,messageId:e.messageId,title:e.title,followUpQuestions:Object.freeze([...e.followUpQuestions]),citations:Object.freeze([...e.citations]),citationStatus:e.citationStatus,urgencyLevel:e.urgencyLevel,urgencyReason:e.urgencyReason,urgencyProvided:e.urgencyProvided??e.urgencyLevel!==null,resultId:e.resultId,lastEventId:e.lastEventId,serverRequestId:t})}i(Es,"doneFrame");function pe(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(pe,"errorFrame");function Cs(e,t,r=null){return Object.freeze({kind:"analysisStarted",requestId:e,lastEventId:t,serverRequestId:r,terminal:false})}i(Cs,"analysisStartedFrame");function Rs(e,t=null){return Object.freeze({kind:"analysisComplete",terminal:false,resultId:e.resultId,analysisType:e.analysisType,modelVersion:e.modelVersion,confidence:e.confidence,detections:Object.freeze([...e.detections]),interpretation:e.interpretation,lastEventId:e.lastEventId,serverRequestId:t})}i(Rs,"analysisCompleteFrame");function Ss(e,t,r=null){return Object.freeze({kind:"unknown",raw:{...e},lastEventId:t,serverRequestId:r,terminal:false})}i(Ss,"unknownFrame");function Ts(e,t,r){let n=null,o=null,s=false,a=i(()=>o||(o=(async()=>{try{let l=await t(),u=typeof l=="string"?l:l?.token;if(typeof u!="string"||u.length===0)throw new Q("invalid-argument","TokenProvider returned an empty token");return n=u,r?.(typeof l=="string"?null:Bf(l.expiresAt)),u}finally{o=null;}})(),o),"load");return {userRef:e,async currentToken(l){if(s)throw new Q("not-initialized","This identity was cleared (sign-out); mint a new one.");return l?.forceRefresh&&(n=null),n!==null?n:a()},hasToken(){return !s&&n!==null},clear(){s=true,n=null;}}}i(Ts,"createIdentityProvider");function Bf(e){if(e===void 0)return null;let t=typeof e=="number"?e<1e11?e*1e3:e:new Date(e).getTime();return Number.isFinite(t)?t:null}i(Bf,"expiryMs");function $n(){let e=new Uint8Array(16),t=globalThis.crypto;if(typeof t?.getRandomValues=="function")t.getRandomValues(e);else for(let n=0;n<e.length;n+=1)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let r=[];for(let n=0;n<e.length;n+=1)r.push(e[n].toString(16).padStart(2,"0"));return r.slice(0,4).join("")+"-"+r.slice(4,6).join("")+"-"+r.slice(6,8).join("")+"-"+r.slice(8,10).join("")+"-"+r.slice(10,16).join("")}i($n,"newSessionId");function zf(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(zf,"authHeaders");function er(e,t){return {...e,headers:{...jf(e.headers),...zf(t)}}}i(er,"withAuthHeaders");function jf(e){if(!e)return {};let t={};for(let[r,n]of Object.entries(e)){let o=r.toLowerCase();o==="authorization"||o==="x-everfur-partner-key"||(t[r]=n);}return t}i(jf,"stripAuthHeaders");async function Ps(e,t){if(t.mode==="anonymous")return t.transport.request(er(e,{mode:"anonymous",publishableKey:t.publishableKey,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));let r;try{r=await t.identity.currentToken();}catch{return v(qn())}let n=await t.transport.request(er(e,{mode:"personalized",token:r,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(n.ok||n.error.httpStatus!==401)return n;let o;try{o=await t.identity.currentToken({forceRefresh:!0});}catch{return v(qn())}let s=await t.transport.request(er(e,{mode:"personalized",token:o,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return !s.ok&&s.error.httpStatus===401?v(qn(s.error.httpStatus)):s}i(Ps,"authedSend");function qn(e){return D("authRejected",{retryable:false,...e!==void 0?{httpStatus:e}:{}})}i(qn,"authRejectedError");var ks=`
|
|
1
|
+
'use strict';var react=require('react'),reactNativeSafeAreaContext=require('react-native-safe-area-context'),zod=require('zod'),_h=require('react-native-sse'),reactNative=require('react-native'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var _h__default=/*#__PURE__*/_interopDefault(_h);var Rf=Object.defineProperty;var i=(e,t)=>Rf(e,"name",{value:t,configurable:true});function Re(e){for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let n=e.charCodeAt(t+1);if(!(n>=56320&&n<=57343))return true;t+=1;}else if(r>=56320&&r<=57343)return true}return false}i(Re,"hasLoneSurrogate");function at(e){return [...e].length}i(at,"serverLength");function L(e,t){return Object.freeze(t===void 0?{ok:true,value:e}:{ok:true,value:e,warning:t})}i(L,"ok");function E(e){return Object.freeze({ok:false,error:e})}i(E,"err");function Sf(e){return e.ok}i(Sf,"isOk");function Tf(e){return !e.ok}i(Tf,"isErr");var Lr=class Lr extends Error{constructor(t){super(`${t.code}: ${t.displayMessage}`),this.name="EverfurThrownError",this.error=t,this.code=t.code,this.category=t.category,Object.setPrototypeOf(this,Lr.prototype);}};i(Lr,"EverfurThrownError");var Mr=Lr;function Pf(e){if(e.ok)return e.value;throw new Mr(e.error)}i(Pf,"unwrap");var Dr=class Dr extends Error{constructor(t,r){super(r),this.name="EverfurConfigError",this.kind=t,Object.setPrototypeOf(this,Dr.prototype);}};i(Dr,"EverfurConfigError");var Q=Dr;var fs=128,ms=128,ys=/[\u0000-\u001F\u007F]/,kf=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function xf(e){let t=e,r=at(t);if(r===0||r>ms)throw new Q("invalid-argument",`petRef must be 1..${ms} characters`);if(ys.test(t))throw new Q("invalid-argument","petRef must be printable (no control characters)");return t}i(xf,"petRef");function _f(e){let t=e,r=at(t);if(r===0||r>fs)throw new Q("invalid-argument",`userRef must be 1..${fs} characters`);if(t.includes("@"))throw new Q("invalid-argument","userRef must not contain '@'");if(ys.test(t))throw new Q("invalid-argument","userRef must be printable (no control characters)");return t}i(_f,"userRef");function wf(e){if(!kf.test(e))throw new Q("invalid-argument","conversationId must be a UUID");return e}i(wf,"conversationId");var Kn=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(Kn.map(e=>e.wireCode));var If=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"}),hs=Object.freeze(Kn.map(e=>Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:If[e.wireCode]}))),Af=new Map(hs.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),Of=Object.freeze(["http_envelope",...[...new Set(hs.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function Nr(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let n of [t??"http_envelope",...Of]){let o=Af.get(n+r);if(o)return o}}i(Nr,"contractErrorFor");function Ff(e){return e.envelope==="sse_frame"?`/errors#sse-${e.wireCode}`:e.envelope==="oauth_error"?`/errors#oauth-${e.wireCode}`:`/errors#${e.wireCode}`}i(Ff,"contractDocUrl");function bs(e){return null}i(bs,"publishedDocUrl");var Mf=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 qn(e){return Mf[e]}i(qn,"categoryFor");function Oe(e){let t=Nr(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),n=r.replace(/[^A-Z0-9]/g,"");if(n==="AUTHREJECTED")return "authRejected";if(r.startsWith("AUTH"))return "authExpired";switch(n){case "DAILYQUOTAEXCEEDED":case "QUOTAEXCEEDED":return "quotaExceeded";case "RATELIMITED":case "TOOMANYREQUESTS":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(Oe,"fromWire");function vs(e){return e===401?"authExpired":e===403?"accessDenied":e===404?"conversationNotFound":e===409?"idempotencyConflict":e===421?"unknown":e===429?"rateLimited":e===400||e===422?"unknown":e>=500?"internalError":"unknown"}i(vs,"fromHttpStatus");var Lf=new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function Be(e){return Lf.has(e)}i(Be,"isAutoRetryable");var Df=new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function $n(e){return Be(e)||Df.has(e)}i($n,"isRetryableCode");function Ur(e,t=false){return t||Be(e)}i(Ur,"shouldRetry");var Nf=500,Yn=8e3,Zt=4;function Vr(e,t=Math.random){let r=Math.max(0,e),n=Math.min(Nf*2**r,Yn);return Math.floor(t()*n)}i(Vr,"backoffDelayMs");function Es(e){return e==="conversationNotFound"}i(Es,"canRecreateOnNotFound");var Uf=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 Ft(e){return Uf[e]}i(Ft,"userFacingError");function Cs(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false});}i(Cs,"defineHidden");var Vf=/^[a-z][a-z0-9_]{0,63}$/;function D(e,t){let r=Nr(t?.wireCode,t?.wireEnvelope),n={code:e,category:qn(e),retryable:t?.retryable??$n(e),displayMessage:Ft(e)};if(t?.httpStatus!==void 0&&(n.httpStatus=t.httpStatus),t?.requestId&&(n.requestId=t.requestId),typeof t?.reasonCode=="string"&&Vf.test(t.reasonCode)&&(n.reasonCode=t.reasonCode),r);return t?.wireMessage&&Cs(n,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&Cs(n,"raw",t.raw),Object.freeze(n)}i(D,"makeEverfurError");var Hf="file",Xn="multipart upload failed";function Hr(e){let t;try{t=new FormData;for(let[r,n]of Object.entries(e.fields))t.append(r,n);t.append(Hf,e.file);}catch{return Promise.reject(new Error(Xn))}return e.fetch!==void 0?jf(e.fetch,e.url,t,e.signal):zf(e.url,t,e.signal)}i(Hr,"postRnMultipart");function Bf(e){return e>=200&&e<300}i(Bf,"stored");function zf(e,t,r){return new Promise((n,o)=>{let s=globalThis.XMLHttpRequest;if(typeof s!="function"||r?.aborted===true){o(new Error(Xn));return}let a=null,l=i(()=>{a!==null&&r?.removeEventListener("abort",a);},"release"),u=i(()=>{l(),o(new Error(Xn));},"fail");try{let d=new s;d.open("POST",e),d.withCredentials=!1,d.onload=()=>{l(),n(Bf(d.status));},d.onerror=u,d.ontimeout=u,d.onabort=u,r!==void 0&&(a=i(()=>{try{d.abort();}finally{u();}},"onAbort"),r.addEventListener("abort",a,{once:!0})),d.send(t);}catch{u();}})}i(zf,"postWithXhr");function jf(e,t,r,n){return Promise.resolve().then(()=>e(t,{method:"POST",body:r,credentials:"omit",...n?{signal:n}:{}})).then(o=>o.ok)}i(jf,"postWithFetch");var Wf="document.pdf",Gf="records upload: the file handle has no uri",Kf="records upload failed";function qf(e={}){return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(Gf));let{signal:o,onProgress:s}=n,a=i(()=>Promise.reject(new Error(Kf)),"failed");return o?.aborted===true?a():Hr({url:t.upload_url,fields:t.upload_fields,file:{uri:r.uri,name:Wf,type:"application/pdf"},signal:o,fetch:e.fetch}).then(l=>{if(!l)return a();s?.(1);},a)}})}i(qf,"createRnRecordsUploadTransport");var Br=Object.freeze({track(){},trackExpectedFailure(){}});var Rs=Object.freeze({shouldRetry(e,t){return Be(e)&&t<Zt},maxAttempts(){return Zt}});var Ss=Object.freeze({isAvailable:false,async capture(){return Promise.reject(new Error("CameraPort is unavailable; check isAvailable before calling capture"))}});function Ze(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}i(Ze,"assertNever");function Ts(e,t,r=null){return Object.freeze({kind:"accepted",streamId:e,lastEventId:t,serverRequestId:r,terminal:false})}i(Ts,"acceptedFrame");function Ps(e,t=null){return Object.freeze({kind:"heartbeat",lastEventId:e,serverRequestId:t,terminal:false})}i(Ps,"heartbeatFrame");function ks(e,t,r=null){return Object.freeze({kind:"delta",delta:e,lastEventId:t,serverRequestId:r,terminal:false})}i(ks,"deltaFrame");function xs(e,t=null){return Object.freeze({kind:"done",terminal:true,conversationId:e.conversationId,messageId:e.messageId,title:e.title,followUpQuestions:Object.freeze([...e.followUpQuestions]),citations:Object.freeze([...e.citations]),citationStatus:e.citationStatus,urgencyLevel:e.urgencyLevel,urgencyReason:e.urgencyReason,urgencyProvided:e.urgencyProvided??e.urgencyLevel!==null,resultId:e.resultId,lastEventId:e.lastEventId,serverRequestId:t})}i(xs,"doneFrame");function de(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(de,"errorFrame");function _s(e,t,r=null){return Object.freeze({kind:"analysisStarted",requestId:e,lastEventId:t,serverRequestId:r,terminal:false})}i(_s,"analysisStartedFrame");function ws(e,t=null){return Object.freeze({kind:"analysisComplete",terminal:false,resultId:e.resultId,analysisType:e.analysisType,modelVersion:e.modelVersion,confidence:e.confidence,detections:Object.freeze([...e.detections]),interpretation:e.interpretation,lastEventId:e.lastEventId,serverRequestId:t})}i(ws,"analysisCompleteFrame");function Is(e,t,r=null){return Object.freeze({kind:"unknown",raw:{...e},lastEventId:t,serverRequestId:r,terminal:false})}i(Is,"unknownFrame");function As(e,t,r){let n=null,o=null,s=false,a=i(()=>o||(o=(async()=>{try{let l=await t(),u=typeof l=="string"?l:l?.token;if(typeof u!="string"||u.length===0)throw new Q("invalid-argument","TokenProvider returned an empty token");return n=u,r?.(typeof l=="string"?null:Xf(l.expiresAt)),u}finally{o=null;}})(),o),"load");return {userRef:e,async currentToken(l){if(s)throw new Q("not-initialized","This identity was cleared (sign-out); mint a new one.");return l?.forceRefresh&&(n=null),n!==null?n:a()},hasToken(){return !s&&n!==null},clear(){s=true,n=null;}}}i(As,"createIdentityProvider");function Xf(e){if(e===void 0)return null;let t=typeof e=="number"?e<1e11?e*1e3:e:new Date(e).getTime();return Number.isFinite(t)?t:null}i(Xf,"expiryMs");function Zn(){let e=new Uint8Array(16),t=globalThis.crypto;if(typeof t?.getRandomValues=="function")t.getRandomValues(e);else for(let n=0;n<e.length;n+=1)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let r=[];for(let n=0;n<e.length;n+=1)r.push(e[n].toString(16).padStart(2,"0"));return r.slice(0,4).join("")+"-"+r.slice(4,6).join("")+"-"+r.slice(6,8).join("")+"-"+r.slice(8,10).join("")+"-"+r.slice(10,16).join("")}i(Zn,"newSessionId");function Qf(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(Qf,"authHeaders");function Jt(e,t){return {...e,headers:{...Zf(e.headers),...Qf(t)}}}i(Jt,"withAuthHeaders");function Zf(e){if(!e)return {};let t={};for(let[r,n]of Object.entries(e)){let o=r.toLowerCase();o==="authorization"||o==="x-everfur-partner-key"||(t[r]=n);}return t}i(Zf,"stripAuthHeaders");async function Os(e,t){if(t.mode==="anonymous")return t.transport.request(Jt(e,{mode:"anonymous",publishableKey:t.publishableKey,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));let r;try{r=await t.identity.currentToken();}catch{return E(Qn())}let n=await t.transport.request(Jt(e,{mode:"personalized",token:r,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(n.ok||n.error.httpStatus!==401)return n;let o;try{o=await t.identity.currentToken({forceRefresh:!0});}catch{return E(Qn())}let s=await t.transport.request(Jt(e,{mode:"personalized",token:o,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return !s.ok&&s.error.httpStatus===401?E(Qn(s.error.httpStatus)):s}i(Os,"authedSend");function Qn(e){return D("authRejected",{retryable:false,...e!==void 0?{httpStatus:e}:{}})}i(Qn,"authRejectedError");var Fs=`
|
|
2
2
|
|
|
3
|
-
`,
|
|
3
|
+
`,Jf=1048576,em=zod.z.record(zod.z.string(),zod.z.unknown()),tm=["emergency","schedule_soon","home_care"];async function*zr(e,t=null){let r=null,n=i(()=>(r!==null||(r=typeof t=="function"?t():t),r),"requestIdNow"),o=new TextDecoder("utf-8"),s="",a=0,l=false;for await(let u of e){for(s+=o.decode(u,{stream:true});;){let d=s.indexOf(Fs,a);if(d===-1)break;let c=s.slice(0,d);s=s.slice(d+Fs.length),a=0;let p=Ms(c,n());if(p!==null&&(p.kind==="delta"&&(l=true),yield p,p.terminal))return}if(a=s.length>0?s.length-1:0,s.length>Jf){yield de({code:l?"CHAT_STREAM_INCOMPLETE":"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:n()});return}}if(s+=o.decode(),s.trim().length>0){let u=Ms(s,n());if(u!==null&&(u.kind==="delta"&&(l=true),yield u,u.terminal))return}yield de({code:l?"CHAT_STREAM_INCOMPLETE":"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:n()});}i(zr,"parseSse");function Ms(e,t){let r=null,n=[];for(let a of e.split(`
|
|
4
4
|
`)){let l=a.replace(/\s+$/,"");l.length===0||l.startsWith(":")||(l.startsWith("id:")?r=l.slice(3).trim():l.startsWith("data:")&&n.push(l.slice(5).replace(/^ /,"")));}if(n.length===0)return null;let o;try{o=JSON.parse(n.join(`
|
|
5
|
-
`));}catch{return null}if(typeof o!="object"||o===null||Array.isArray(o))return null;let s=
|
|
5
|
+
`));}catch{return null}if(typeof o!="object"||o===null||Array.isArray(o))return null;let s=em.safeParse(o);return s.success?rm(s.data,r,t):null}i(Ms,"parseBlock");function rm(e,t,r){let n=e.type,o=e.event;if(n==="error"||"error"in e)return de({code:le(e.code)??"unknown",retryable:e.retryable===true,wireMessage:le(e.error),synthesized:false,lastEventId:t,serverRequestId:r});if(n==="done"||e.done===true)return xs({conversationId:le(e.conversation_id)??"",messageId:le(e.message_id),title:le(e.title),followUpQuestions:im(e.follow_up_questions),citations:Ls(e.citations),citationStatus:le(e.citation_status),urgencyLevel:Ds(e.urgency_level),urgencyReason:le(e.urgency_reason),urgencyProvided:om(e),resultId:le(e.result_id),lastEventId:t},r);if(n==="accepted"||e.status==="reasoning")return Ts(le(e.stream_id),t,r);if(n==="heartbeat"||e.heartbeat===true)return Ps(t,r);if(n==="text.delta"||"delta"in e||"token"in e){let s=le(e.delta)??le(e.token)??"";return ks(s,t,r)}return o==="analysis_started"?_s(le(e.request_id),t,r):o==="analysis_complete"?ws({resultId:le(e.result_id),analysisType:le(e.analysis_type),modelVersion:le(e.model_version),confidence:nm(e.confidence),detections:Ls(e.detections),interpretation:le(e.interpretation),lastEventId:t},r):Is(e,t,r)}i(rm,"frameFromWire");function le(e){return typeof e=="string"?e:null}i(le,"asString");function nm(e){return typeof e=="number"&&Number.isFinite(e)?e:null}i(nm,"asNumber");function Ds(e){return typeof e=="string"&&tm.includes(e)?e:null}i(Ds,"asUrgency");function om(e){if(!Object.prototype.hasOwnProperty.call(e,"urgency_level"))return false;let t=e.urgency_level;return t===null||Ds(t)!==null}i(om,"urgencySlotProvided");function im(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?t:String(t)):[]}i(im,"asStringList");function sm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(sm,"isPlainObject");function Ls(e){return Array.isArray(e)?e.filter(sm):[]}i(Ls,"asMapList");var am="0.5.5",eo="react-native",lm="2026-09-19",jr="EVERFUR_API_BASE_URL";function er(e,t){return Object.freeze({ok:false,failure:Object.freeze({reason:e,message:t})})}i(er,"configFailure");function to(e){let t=typeof e=="string"?e.trim():"";return t.length===0?{reason:"missing-publishable-key",message:"publishableKey is required"}:/^sk[_-]/i.test(t)?{reason:"secret-key-as-publishable-key",message:"publishableKey looks like a SECRET key (sk_...). A device must never hold a partner secret key: use the pk_ publishable key here, and keep the secret key on your server."}:null}i(to,"checkPublishableKey");function Ns(e,t){let r=to(e?.publishableKey);if(r!==null)return Object.freeze({ok:false,failure:r});let n=e.publishableKey.trim(),o=um(e.apiBaseUrl);if(!o.ok)return o;let s=e.contractVersion?.trim()||lm;return Object.freeze({ok:true,config:Object.freeze({publishableKey:n,apiBaseUrl:o.value,contractVersion:s,sdkVersion:am,platform:t?.platform??eo,debug:e.debug===true})})}i(Ns,"tryResolveClientConfig");function um(e){let t=e?.trim(),r=t&&t.length>0?t:hm(jr);return r?ym(r):er("missing-api-base-url",`apiBaseUrl is required: pass config.apiBaseUrl or set ${jr}. The SDK never ships a hardcoded host.`)}i(um,"tryResolveApiBaseUrl");function Us(e){return {"X-Everfur-SDK-Version":e.sdkVersion,"X-Everfur-SDK-Platform":e.platform,"X-Everfur-Contract":e.contractVersion}}i(Us,"buildBaseHeaders");var dm=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/;function cm(e){return e.slice(e.lastIndexOf("@")+1).replace(/:\d+$/,"").toLowerCase()}i(cm,"hostOf");function pm(e){return e.length===0||e.includes("@")?false:e.startsWith("[")&&e.endsWith("]")?true:!e.includes(":")}i(pm,"isPrintableHost");function fm(e,t){let r=e.indexOf("://");return r<0||e.slice(r+3).includes("@")?false:pm(t)}i(fm,"canEchoOrigin");function mm(e,t){return `${e}://${t}`}i(mm,"safeOrigin");function ym(e){let t=e.trim(),r=dm.exec(t);if(r===null||r[2]===void 0||r[2].length===0)return er("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let n=(r[1]??"").toLowerCase(),o=cm(r[2]);if(o.length===0)return er("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let s=fm(t,o)?`: ${mm(n,o)}`:"";if(n!=="https"){if(!(n==="http"&&gm(o)))return n==="http"?er("insecure-api-base-url",`apiBaseUrl must use https (cleartext http is only allowed for localhost)${s}`):er("unsupported-api-base-url-scheme",`apiBaseUrl must be http(s)${s}`)}let a=t.endsWith("/")?t.slice(0,-1):t;return Object.freeze({ok:true,value:a})}i(ym,"normalizeBaseUrl");function gm(e){let t=e.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="[::1]"||t==="::1"}i(gm,"isLoopbackHost");function hm(e){let r=globalThis.process?.env?.[e];return typeof r=="string"&&r.trim().length>0?r.trim():void 0}i(hm,"readEnv");var bm=3e4,zs="x-request-id";async function*Vs(e){if(!e)return;let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;n&&n.length>0&&(yield n);}}finally{await t.cancel?.();}}i(Vs,"fetchByteSource");function vm(e){let t=new TextEncoder,r=Cm(),n=false,o=i(u=>{let d="";u.lastEventId&&(d+=`id: ${u.lastEventId}
|
|
6
6
|
`);let c=u.data??"";for(let p of c.split(`
|
|
7
7
|
`))d+=`data: ${p}
|
|
8
8
|
`;d+=`
|
|
9
|
-
`,r.push(t.encode(d));},"onMessage"),s=i(()=>{l(),r.end();},"onDone"),a=i(u=>{let d=typeof u.xhrStatus=="number"?u.xhrStatus:0;if(d>=400){let c=
|
|
9
|
+
`,r.push(t.encode(d));},"onMessage"),s=i(()=>{l(),r.end();},"onDone"),a=i(u=>{let d=typeof u.xhrStatus=="number"?u.xhrStatus:0;if(d>=400){let c=Gs(d),p=Be(Oe(c));r.push(t.encode(`data: ${JSON.stringify({type:"error",code:c,retryable:p})}
|
|
10
10
|
|
|
11
|
-
`));}l(),r.end();},"onError");e.addEventListener("message",o),e.addEventListener("done",s),e.addEventListener("error",a);function l(){if(!n){n=true,e.removeEventListener("message",o),e.removeEventListener("done",s),e.removeEventListener("error",a);try{e.close();}catch{}}}return i(l,"cleanup"),pm(r.source,l)}i(cm,"eventSourceByteSource");async function*pm(e,t){try{yield*e;}finally{t();}}i(pm,"sourceWithCleanup");function fm(){let e=[],t=false,r=null,n=i(()=>{if(r){let s=r;r=null,s();}},"signal");async function*o(){for(;;){let s=e.shift();if(s!==void 0){yield s;continue}if(t)return;await new Promise(a=>{r=a;});}}return i(o,"gen"),{source:o(),push:i(s=>{e.push(s),n();},"push"),end:i(()=>{t=true,n();},"end")}}i(fm,"createByteQueue");async function mm(e,t){let r=t.fetchImpl??Hs(),n=Bs(t.config.apiBaseUrl,e.path,e.query),o=zs(t.config,e.headers,"application/json",e.body!==void 0&&e.multipart===void 0),s=Em(dm),a=Cm(s.signal,e.signal),l;try{l=await r(n,js({...e,signal:a},o));}catch(d){return v(Qn(d))}finally{s.cancel();}let u=await Ws(l);return l.ok?L(u):v(hm(l.status,u,Us(l)))}i(mm,"requestJson");function Ns(e){return {request:i(t=>mm(t,e),"request"),stream:i((t,r)=>ym(vm(t,r),e),"stream")}}i(Ns,"createHttpTransport");async function*ym(e,t){let r=Bs(t.config.apiBaseUrl,e.path,e.query),n=zs(t.config,e.headers,"text/event-stream",e.body!==void 0&&e.multipart===void 0);if(t.eventSourceFactory){let l=t.eventSourceFactory(r,gm(e,n));yield*Br(cm(l),()=>bm(l));return}let o=t.fetchImpl??Hs(),s;try{s=await o(r,js(e,n));}catch(l){yield Ms("",true,$s(l));return}let a=Us(s);if(!s.ok){let l=await Ws(s),u=Gs(l)??Vs(s.status),d=qs(l)||Be(Oe(u));yield Ms(u,d,Ks(l),a);return}if(s.body){yield*Br(Fs(s.body),a);return}yield*Br(Fs(null),a);}i(ym,"streamFrames");function gm(e,t){return {method:e.method,headers:t,pollingInterval:0,...e.body!==void 0?{body:JSON.stringify(e.body)}:{}}}i(gm,"buildEventSourceInit");function hm(e,t,r){let n=Gs(t),o=n?Oe(n):ps(e),s=Ks(t);return D(o,{httpStatus:e,...qs(t)?{retryable:true}:{},...r?{requestId:r}:{},...n?{wireCode:n}:{},...Ls(t)?{reasonCode:Ls(t)}:{},...s?{wireMessage:s}:{},...t!=null?{raw:t}:{}})}i(hm,"errorFromResponse");function Qn(e){return D("internalError",{retryable:true,wireMessage:$s(e)})}i(Qn,"networkError");function Us(e){let t=e.headers.get(Ds);return typeof t=="string"&&t.length>0?t:null}i(Us,"requestIdOf");function bm(e){if(typeof e.getResponseHeader!="function")return null;let t;try{t=e.getResponseHeader(Ds);}catch{return null}return typeof t=="string"&&t.length>0?t:null}i(bm,"eventSourceRequestId");function Vs(e){return e===401?"AUTH_EXPIRED":e===403?"ACCESS_DENIED":e===404?"NOT_FOUND":e===409?"IDEMPOTENCY_CONFLICT":e===421?"MISDIRECTED_REQUEST":e===429?"RATE_LIMITED":e===400||e===422?"INVALID_REQUEST":e===503||e>=500?"INTERNAL_ERROR":""}i(Vs,"statusToWireCode");function Ms(e,t,r,n=null){return pe({code:e,retryable:t,wireMessage:r,synthesized:true,lastEventId:null,serverRequestId:n})}i(Ms,"syntheticErrorFrame");function Hs(){let e=globalThis.fetch;if(typeof e!="function")throw new Q("missing-peer-dependency","global fetch is unavailable; provide config.transport or an injected fetch implementation");return e}i(Hs,"getGlobalFetch");function Bs(e,t,r){let n=t.startsWith("/")?t:`/${t}`,o=`${e}${n}`;if(r){let s=Object.entries(r).filter(a=>a[1]!==void 0).map(([a,l])=>`${encodeURIComponent(a)}=${encodeURIComponent(String(l))}`).join("&");s&&(o+=`?${s}`);}return o}i(Bs,"buildUrl");function zs(e,t,r,n){let o={...Os(e),accept:r};return n&&(o["content-type"]="application/json"),t&&Object.assign(o,t),o}i(zs,"mergeHeaders");function js(e,t){let r={method:e.method,headers:t};return e.multipart!==void 0?r.body=e.multipart:e.body!==void 0&&(r.body=JSON.stringify(e.body)),e.signal&&(r.signal=e.signal),r}i(js,"buildInit");function vm(e,t){return e.signal?e:{...e,signal:t}}i(vm,"withSignal");function Em(e){let t=new AbortController,r=setTimeout(()=>t.abort(),e);return {signal:t.signal,cancel:i(()=>clearTimeout(r),"cancel")}}i(Em,"timeoutSignal");function Cm(e,t){if(!t)return e;let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),r.signal;let n=i(()=>r.abort(),"onAbort");return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),r.signal}i(Cm,"mergeAbortSignals");async function Ws(e){try{return await e.json()}catch{return null}}i(Ws,"safeJson");function Ls(e){let t=e,r=t?.error?.reason_code??t?.reason_code;return typeof r=="string"&&r.length>0?r:null}i(Ls,"extractReasonCode");function Gs(e){let t=e,r=t?.error?.code??t?.code;return typeof r=="string"&&r.length>0?r:null}i(Gs,"extractWireCode");function Ks(e){let t=e,r=t?.error?.message??t?.message;return typeof r=="string"&&r.length>0?r:null}i(Ks,"extractWireMessage");function qs(e){let t=e;return t?.error?.retryable===true||t?.retryable===true}i(qs,"extractRetryable");function $s(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}i($s,"describeCause");var Rm=3e4,Sm=Gn*2,Tm="idempotency-key",Pm=new Set(["POST","PUT","PATCH","DELETE"]),km=Object.freeze({onEvent(){}}),xm=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function _m(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}i(_m,"seededIdempotencyKey");function xe(e){let t=e.observer??km,r=e.timers??xm,n=e.rng??Math.random,o=e.sleep??((f,y)=>zm(f,r,y)),s=e.maxAttempts??Jt,a=e.unaryTimeoutMs??Rm,l=e.newIdempotencyKey??Im(),u=i(f=>{try{t.onEvent(f);}catch{}},"emit");async function d(f,y,m){let w=m?.maxAttempts,b=Math.max(1,w??s),R=m?.idempotent??Pm.has(y.method),I=m?.idempotencyKey===void 0?null:_m(m.idempotencyKey),P=R?I??l():null,x=wm(y,P),g=0;for(;;){let _=i(j=>Object.freeze({call:f,method:y.method,path:y.path,attempt:g,...P?{idempotencyKey:P}:{},...j}),"stamp");u(_({phase:"attempt"}));let F=Hm(a,r),M=Bm(F.signal,y.signal),E;try{E=await Ps({...x,signal:M.signal},e.auth);}catch(j){E=v(Qn(j));}finally{M.dispose(),F.cancel();}if(E.ok)return u(_({phase:"settled",ok:true,reason:"ok"})),E;let k=E.error,T=Om(k,g,{maxAttempts:b,rng:n,now:r.now(),aborted:y.signal?.aborted===true,...w!==void 0?{perCallMaxAttempts:w}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),V={ok:false,code:k.code,reason:T.reason,...k.httpStatus!==void 0?{httpStatus:k.httpStatus}:{},...k.requestId!==void 0?{requestId:k.requestId}:{}};if(!T.retry)return u(_({phase:"settled",...V})),v(k);if(u(_({phase:"retry",...V,delayMs:T.delayMs})),await o(T.delayMs,y.signal),y.signal?.aborted===true)return u(_({phase:"settled",...V,reason:"aborted"})),v(k);g+=1;}}i(d,"send");async function c(f){return er(f,await Vm(e.auth))}i(c,"authorize");async function*p(f,y,m){u(Object.freeze({call:f,phase:"stream.open",method:y.method,path:y.path,attempt:0}));try{yield*e.auth.transport.stream(y,m);}catch{yield pe({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:null});}}return i(p,"stream"),Object.freeze({send:d,authorize:c,stream:p})}i(xe,"createRequestFunnel");function wm(e,t){let r={};for(let[n,o]of Object.entries(e.headers??{}))n.toLowerCase()!==Tm&&(r[n]=o);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}i(wm,"assembleHeaders");function Im(){let e=0;return ()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}i(Im,"defaultIdempotencyKeyFactory");var Am=10;function Om(e,t,r){if(r.aborted)return {retry:false,reason:"aborted"};let n=Fm(e);if(n==="quota")return {retry:false,reason:"daily-quota-exhausted"};if(n!=="burst"&&!Be(e.code))return {retry:false,reason:"terminal-code"};let o=n==="burst"?"burst-throttle":"retryable-code";if(i(()=>{if(r.policy===void 0)return false;try{return !r.policy.shouldRetry(e.code,t)}catch{return false}},"policyVetoedRetry")())return {retry:false,reason:"terminal-code"};let a=i(()=>{if(r.policy===void 0)return null;let d;try{d=r.policy.maxAttempts(e.code);}catch{return null}return typeof d!="number"||!Number.isFinite(d)?null:Math.max(1,Math.min(Am,Math.floor(d)))},"policyCeiling"),l=r.perCallMaxAttempts??a()??r.maxAttempts;if(t+1>=l)return {retry:false,reason:"attempts-exhausted"};let u=Mm(e,r.now);return u!==null?u>Sm?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:o,delayMs:u}:{retry:true,reason:o,delayMs:Ur(t,r.rng)}}i(Om,"decideRetry");function Fm(e){let t=e.code==="unknown"?Oe(Um(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}i(Fm,"throttleKind");function Mm(e,t){let r=Dm(e.raw);if(r!==null){let o=r-t;return o>0?o:0}let n=Lm(e.raw);return n===null?null:Math.round(n*1e3)}i(Mm,"retryOverrideMs");function Lm(e){for(let t of Zn(e)){let r=t.retry_after_seconds;if(typeof r=="number"&&Number.isFinite(r)&&r>=0)return r}return null}i(Lm,"findRetryAfterSeconds");function Dm(e){for(let t of Zn(e)){let r=t.resets_at,n=Nm(r);if(n!==null)return n}return null}i(Dm,"findResetsAt");function Zn(e){if(!Ys(e))return [];let t=[e];for(let r of ["error","detail"]){let n=e[r];Ys(n)&&t.push(n);}return t}i(Zn,"candidateScopes");function Nm(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(Nm,"parseInstantMs");function Um(e){for(let t of Zn(e)){let r=t.code;if(typeof r=="string"&&r.length>0)return r}return null}i(Um,"rawWireCode");function Ys(e){return typeof e=="object"&&e!==null}i(Ys,"isRecord");async function Vm(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(Vm,"resolveDeviceAuth");function Hm(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return {signal:r.signal,cancel:i(()=>t.clearTimeout(n),"cancel")}}i(Hm,"boundedSignal");function Bm(e,t){let r=i(()=>{},"noop");if(!t)return {signal:e,dispose:r};let n=new AbortController;if(e.aborted||t.aborted)return n.abort(),{signal:n.signal,dispose:r};let o=i(()=>n.abort(),"onAbort");return e.addEventListener("abort",o,{once:true}),t.addEventListener("abort",o,{once:true}),{signal:n.signal,dispose:i(()=>{e.removeEventListener("abort",o),t.removeEventListener("abort",o);},"dispose")}}i(Bm,"mergeSignals");function zm(e,t,r){return e<=0||r?.aborted===true?Promise.resolve():new Promise(n=>{let o=t.setTimeout(()=>{r?.removeEventListener("abort",s),n();},e),s=i(()=>{t.clearTimeout(o),n();},"onAbort");r?.addEventListener("abort",s,{once:true});})}i(zm,"delayAbortable");var zr=Object.freeze(["better","same","worse"]),eo=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Xs(e){return v(D("validationFailed",{retryable:false,wireMessage:e}))}i(Xs,"invalid");function Jn(){return v(D("internalError",{retryable:false}))}i(Jn,"malformed");function Qs(e){return typeof e!="string"||e.trim().length===0?D("validationFailed",{retryable:false,wireMessage:"pet_ref must not be blank"}):Re(e)?D("validationFailed",{retryable:false,wireMessage:"pet_ref contains an unpaired surrogate and cannot be encoded"}):`/widget/v1/pets/${encodeURIComponent(e)}/cases`}i(Qs,"petPath");var ze=i(e=>typeof e=="string"?e:null,"str"),Zs=i(e=>typeof e=="number"&&Number.isFinite(e)?e:null,"count");function Js(e){if(typeof e!="object"||e===null)return null;let t=e,r=ze(t.case_id),n=ze(t.status);if(r===null||n===null)return null;let o=ze(t.last_response);return Object.freeze({caseId:r,status:n,bodyLocation:ze(t.body_location),lastResponse:o!==null&&zr.includes(o)?o:null,checkInDueAt:ze(t.check_in_due_at),openedAt:ze(t.opened_at),resolvedAt:ze(t.resolved_at),resolutionText:ze(t.resolution_text),checkinAskCount:Zs(t.checkin_ask_count),checkinAnswerCount:Zs(t.checkin_answer_count)})}i(Js,"caseFromWire");function ea(e){return {async list(t,r){let n=Qs(t);if(typeof n!="string")return v(n);let o=await e.send("cases.list",{method:"GET",path:n,...r?.signal?{signal:r.signal}:{}});if(!o.ok)return v(o.error);let s=typeof o.value=="object"&&o.value!==null?o.value.cases:null;if(!Array.isArray(s))return Jn();let a=s.map(Js);return a.every(l=>l!==null)?L(Object.freeze(a)):Jn()},async checkin(t,r,n,o){let s=Qs(t);if(typeof s!="string")return v(s);if(typeof r!="string"||!eo.test(r))return Xs("case_id must be a UUID");if(!zr.includes(n))return Xs("response must be one of better, same, worse");let a=await e.send("cases.checkin",{method:"POST",path:`${s}/${r}/checkin`,body:{response:n},...o?.signal?{signal:o.signal}:{}});if(!a.ok)return v(a.error);let l=typeof a.value=="object"&&a.value!==null?a.value:{},u=Js(l.case);return u===null?Jn():L(Object.freeze({case:u,ctaDeepLink:ze(l.cta_deep_link)}))}}}i(ea,"createCasesRepositoryOver");var ta=Object.freeze({async presignedPut(){return Promise.reject(new Error("UploadPort is unavailable; no presigned-upload adapter was injected"))}});var ra=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function Wr(e,t,r){return new Promise(n=>{if(t.aborted){n();return}let o={handle:void 0},s=i(()=>{r.clearTimeout(o.handle),t.removeEventListener("abort",s),n();},"done");o.handle=r.setTimeout(s,e),t.addEventListener("abort",s,{once:true});})}i(Wr,"delayAbortable");function Gr(e,t){if(!t)return e;let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),r.signal;let n=i(()=>r.abort(),"onAbort");return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),r.signal}i(Gr,"mergeSignals");var to=class to{constructor(t){this.listeners=new Set;this.epoch=0;this.inFlight=null;this.snapshot=Object.freeze({...t});}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t);}}getSnapshot(){return this.snapshot}patch(t){this.snapshot=Object.freeze({...this.snapshot,...t});for(let r of this.listeners)r();}beginOperation(t){this.inFlight?.abort();let r=new AbortController;this.inFlight=r;let n=this.epoch;return {signal:t?Gr(r.signal,t):r.signal,epoch:n,settle:i(()=>{this.inFlight===r&&(this.inFlight=null);},"settle")}}alive(t){return t===this.epoch}rescope(){this.epoch+=1,this.inFlight?.abort(),this.inFlight=null;}dispose(){this.epoch+=1,this.inFlight?.abort(),this.inFlight=null,this.listeners.clear();}};i(to,"MediaStore");var jr=to;function no(e,t,r){return Object.freeze({id:e,role:"user",text:t,createdAt:r,pending:true})}i(no,"makeUser");function oo(e,t,r){return Object.freeze({id:e,role:"assistant",text:t,createdAt:r})}i(oo,"makeAssistant");function nr(e){return Object.freeze({id:e.id,role:e.role,text:e.text,createdAt:e.createdAt})}i(nr,"stripPending");function na(e,t){let r={id:e.id,role:e.role,text:e.text+t,createdAt:e.createdAt};return e.citations&&(r.citations=e.citations),e.responseId&&(r.responseId=e.responseId),Object.freeze(r)}i(na,"appendText");function io(e,t){let r={id:t.messageId?t.messageId:e.id,role:"assistant",text:e.text,createdAt:e.createdAt};return t.citations.length>0&&(r.citations=t.citations),t.messageId&&(r.responseId=t.messageId),r.urgencyLevel=t.urgencyLevel,r.urgencyReason=t.urgencyReason,r.urgencyProvided=t.urgencyProvided,Object.freeze(r)}i(io,"finalizeAssistant");function oa(e){return Object.freeze({status:e.status,messages:Object.freeze([...e.messages]),conversationId:e.conversationId,error:e.error,isStreaming:e.isStreaming,isBootstrapping:e.isBootstrapping,suggestedPrompts:Object.freeze([...e.suggestedPrompts]),unreadCount:e.unreadCount})}i(oa,"freezeSnapshot");function U(e,t,r){return D(e,{retryable:t,...r?{wireMessage:r}:{}})}i(U,"makeError");function so(e){let t=Oe(e.code);return D(t,{retryable:e.retryable||Nr(t),wireCode:e.code,wireEnvelope:"sse_frame",...e.serverRequestId?{requestId:e.serverRequestId}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},raw:e})}i(so,"errorFromFrame");function Fe(e){return pe({code:jm(e.code),retryable:e.retryable,wireMessage:e.wireMessage??null,synthesized:true,lastEventId:null,serverRequestId:e.requestId??null})}i(Fe,"synthErrorFrame");function jm(e){switch(e){case "authExpired":return "AUTH_EXPIRED";case "authRejected":return "AuthorizationException";case "sessionRequired":return "session_required";case "accessDenied":return "ACCESS_DENIED";case "paymentRequired":return "TIER_UPGRADE_REQUIRED";case "quotaExceeded":return "QUOTA_EXCEEDED";case "rateLimited":return "RATE_LIMITED";case "validationFailed":return "ValidationException";case "sdkUpdateRequired":return "invalidRequest";case "conflict":return "ConflictException";case "idempotencyConflict":return "IDEMPOTENCY_CONFLICT";case "idempotencyInFlight":return "IDEMPOTENCY_KEY_IN_FLIGHT";case "conversationNotFound":return "CONVERSATION_NOT_FOUND";case "petNotFound":return "PET_NOT_FOUND";case "resourceNotFound":return "ResourceNotFoundException";case "streamTimeout":return "STREAM_TIMEOUT";case "mediaUploadFailed":return "MEDIA_UPLOAD_FAILED";case "moderationBlocked":return "MODERATION_BLOCKED";case "upstreamLlmTimeout":return "UPSTREAM_LLM_TIMEOUT";case "internalError":return "INTERNAL_ERROR";case "notImplemented":return "NotImplementedException";case "serviceUnavailable":return "ServiceUnavailableException";case "streamIncomplete":return "STREAM_INCOMPLETE";case "unknown":return "UNKNOWN";default:return Qe(e)}}i(jm,"canonicalWireCode");function ia(e){let t=Array.isArray(e)?e:ro(e)&&Array.isArray(e.categories)?e.categories:[],r=[];for(let n of t){if(!ro(n))continue;let o=rr(n.category)??rr(n.title)??"",s=Wm(n.prompts??n.questions);o.length===0&&s.length===0||r.push(Object.freeze({category:o,prompts:Object.freeze(s)}));}return Object.freeze(r)}i(ia,"parsePromptCategories");function ao(e){let t=new Set,r=[];for(let n of e)for(let o of n.prompts){let s=o.trim();s.length===0||t.has(s)||(t.add(s),r.push(s));}return r}i(ao,"flattenPrompts");function ro(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(ro,"isPlainObject");function rr(e){return typeof e=="string"?e:null}i(rr,"asStr");function Wm(e){if(!Array.isArray(e))return [];let t=[];for(let r of e)if(typeof r=="string")t.push(r);else if(ro(r)){let n=rr(r.text)??rr(r.prompt)??rr(r.title);n!==null&&t.push(n);}return t}i(Wm,"asPromptTextList");function sa(){let e=0;return ()=>`m-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,8)}`}i(sa,"defaultIdFactory");function aa(){let e=0;return ()=>`chat-send-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,10)}`}i(aa,"defaultIdempotencyFactory");var ua={setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")};async function*da(e,t,r,n){let o=e[Symbol.asyncIterator](),s=la(t.overallMs,n),a=la(t.idleMs,n),l=qm(r);try{for(;;){if(r.aborted)return;let u=o.next().then(p=>({tag:"next",value:p}),()=>({tag:"streamError"})),d=await Promise.race([u,a.promise.then(()=>({tag:"idle"})),s.promise.then(()=>({tag:"overall"})),l.then(()=>({tag:"abort"}))]);if(d.tag==="abort")return;if(d.tag==="streamError"){if(r.aborted)return;yield Km();return}if(d.tag==="idle"||d.tag==="overall"){yield Gm();return}let c=d.value;if(c.done||(a.reset(t.idleMs),yield c.value,c.value.terminal))return}}finally{a.cancel(),s.cancel(),Promise.resolve(o.return?.(void 0)).catch(()=>{});}}i(da,"withWatchdog");function Gm(){return pe({code:"STREAM_TIMEOUT",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}i(Gm,"synthTimeoutFrame");function Km(){return pe({code:"STREAM_INCOMPLETE",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}i(Km,"synthStreamErrorFrame");function la(e,t){let r=i(()=>{},"resolveFn"),n=new Promise(s=>{r=s;}),o=t.setTimeout(()=>r(),e);return {promise:n,reset(s){t.clearTimeout(o),o=t.setTimeout(()=>r(),s);},cancel(){t.clearTimeout(o);}}}i(la,"deadline");function qm(e){return new Promise(t=>{if(e.aborted){t();return}e.addEventListener("abort",()=>t(),{once:true});})}i(qm,"abortPromise");var $m="checkin",Ym=/^\d{4}-\d{2}-\d{2}$/,Kr="watching";function ca(e){return e.status!=null&&e.status!==Kr}i(ca,"isCheckinSettled");function pa(e){let{askCount:t,answerCount:r}=e;return typeof t!="number"||!Number.isFinite(t)||typeof r!="number"||!Number.isFinite(r)||t<=0?true:r>=t}i(pa,"isLiveAskAnswered");function lo(e){if(typeof e!="string")return null;let t=e.split(":");if(t.length!==3)return null;let[r,n,o]=t;return r!==$m||n===void 0||o===void 0||!eo.test(n)||!Ym.test(o)?null:{caseId:n,dueDay:o}}i(lo,"parseCheckinOrigin");function fa(e){return lo(e)?.caseId??null}i(fa,"parseCheckinOriginRef");function uo(e,t){if(e?.limit!==void 0&&(!Number.isInteger(e.limit)||e.limit<1||e.limit>t))return v(D("validationFailed"));let r=[];for(let[n,o]of [["cursor",e?.cursor],["pet_ref",e?.petRef]])if(o!==void 0){if(typeof o!="string"||o.length===0||Re(o))return v(D("validationFailed"));r.push(`${n}=${encodeURIComponent(o)}`);}return e?.limit!==void 0&&r.push(`limit=${e.limit}`),L(r.length?`?${r.join("&")}`:"")}i(uo,"historyQuery");function sr(e){return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}i(sr,"validConversationId");function ir(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}i(ir,"object");function ma(e){return e==null||typeof e=="string"&&e.length>0&&!Re(e)}i(ma,"cursor");function or(){return v(D("internalError",{retryable:false}))}i(or,"malformed");function ya(e){let t=ir(e);if(!t||!Array.isArray(t.conversations)||!ma(t.next_cursor))return or();let r=[];for(let n of t.conversations){let o=ir(n);if(!o||typeof o.conversation_id!="string"||!sr(o.conversation_id)||!(o.title==null||typeof o.title=="string")||typeof o.created_at!="string"||typeof o.updated_at!="string")return or();let s=o.unread_message_count;if(!(s==null||Number.isInteger(s)&&s>=0))return or();r.push(Object.freeze({id:o.conversation_id,title:o.title??null,createdAt:o.created_at,updatedAt:o.updated_at,unreadCount:s??null}));}return L(Object.freeze({conversations:Object.freeze(r),nextCursor:t.next_cursor??null}))}i(ya,"mapConversationPage");function ga(e){let t=ir(e);if(!t||!Array.isArray(t.messages)||!ma(t.next_cursor))return or();let r=[],n=new Set;for(let o of t.messages){let s=ir(o);if(!s||typeof s.message_id!="string"||!sr(s.message_id)||typeof s.role!="string"||typeof s.content!="string"||typeof s.created_at!="string")return or();if(s.role!=="user"&&s.role!=="assistant"||n.has(s.message_id))continue;n.add(s.message_id);let a=typeof s.proactive_origin_ref=="string"?s.proactive_origin_ref:null,l=s.role==="assistant"?fa(a):null;r.push(Object.freeze({id:s.message_id,role:s.role,text:s.content,createdAt:s.created_at,...s.role==="assistant"?{responseId:s.message_id}:{},...s.urgency_level!==void 0?{urgencyLevel:Xm(s.urgency_level)}:{},...Array.isArray(s.citations)?{citations:Qm(s.citations)}:{},...a!==null?{proactiveOriginRef:a}:{},...l!==null?{checkin:Object.freeze({caseId:l,answer:null,resolutionText:null,status:null})}:{}}));}return L(Object.freeze({messages:Object.freeze(r),nextCursor:t.next_cursor??null}))}i(ga,"mapMessagePage");function Xm(e){return e==="emergency"||e==="schedule_soon"||e==="home_care"?e:null}i(Xm,"normalizeUrgency");function Qm(e){let t=["source_name","source_abbrev","section","authority_tier","doi","url","title","year","study_type","journal","excerpt","monograph_chunk_id"];return Object.freeze(e.flatMap(r=>{let n=ir(r);if(!n||typeof n.source_name!="string"||typeof n.authority_tier!="string")return [];let o={};for(let s of t){let a=n[s];(typeof a=="string"||a===null)&&(o[s]=a);}return [Object.freeze(o)]}))}i(Qm,"historyCitations");var co=Object.freeze(["helpful","neutral","not_helpful","wrong","outdated","dangerous","unclear"]),Mt=4e3;var Lt=4e3;function ha(e){return e===void 0?null:!Array.isArray(e)||e.length>5?{reason:"too_many_images",error:U("validationFailed",false,`image_s3_keys accepts at most ${5} keys`)}:e.some(t=>typeof t!="string"||t.trim().length===0)?{reason:"bad_image_key",error:U("validationFailed",false,"image_s3_keys must be non-empty strings")}:null}i(ha,"validateImageKeys");function fo(e){let t=typeof e=="string"?e:"";if(t.trim().length===0)return {reason:"empty",error:U("validationFailed",false,"message is empty or whitespace-only")};let r=[...t].length;return r>Lt?{reason:"too_long",error:U("validationFailed",false,`message is ${r} characters; the server accepts at most ${Lt}`)}:null}i(fo,"validateMessageText");function ba(e){return e==="emergency"||e==="schedule_soon"||e==="home_care"?e:null}i(ba,"urgencyTier");async function*ar(e){yield e;}i(ar,"singleFrameStream");async function*va(){}i(va,"emptyStream");var Zm=6e4,Jm=18e4,ey=24,ty=512,ry=false;function Ea(e){return new mo(e)}i(Ea,"createChatController");var yo=class yo extends jr{constructor(r){super(oa({status:"idle",messages:[],conversationId:r.initialConversationId??null,error:null,isStreaming:false,isBootstrapping:false,suggestedPrompts:[],unreadCount:null}));this.handlerTeardowns=new Set;this.lastTurn=null;this.unadoptedCreate=null;this.lastResponseIdValue=null;this.historyGeneration=0;this.disposed=false;this.bootstrapPrompts=[];this.scopePrompts=[];this.replyPrompts=null;this.unreadByConversation=new Map;this.classifiedMessageIds=new Set;this.pendingDelta="";this.flushHandle=null;this.auth=r.auth,this.funnel=r.funnel??xe({auth:r.auth,...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}),this.petRef=r.petRef??null,this.cases=ea(this.funnel),this.telemetry=r.telemetry??Hr,this.errorPolicy=r.errorPolicy??ys,this.timers=r.timers??ua,this.rng=r.rng??Math.random,this.newId=r.newId??sa(),this.makeIdempotencyKey=r.makeIdempotencyKey??aa(),this.budget={idleMs:r.budget?.idleMs??Zm,overallMs:r.budget?.overallMs??Jm};}patch(r){if(r.messages!==void 0){let n=Object.freeze([...r.messages]);super.patch({...r,messages:n});return}super.patch(r);}send(r,n,o){let s=n??{};if(this.disposed||this.snapshot.isBootstrapping){let u=U(this.disposed?"accessDenied":"internalError",!this.disposed);return o?(o.onError(u),()=>{}):ar(Fe(u))}let a=fo(r)??ha(s.imageS3Keys);if(a!==null)return this.telemetry.track("chat.send.rejected",{reason:a.reason}),this.patch({status:"error",isStreaming:false,error:a.error}),o?(o.onError(a.error),()=>{}):ar(Fe(a.error));if(o)return this.driveWithHandlers(r,s,o);let l=this.beginTurn(r,s);return this.runTurn(l,s.signal)}askEverfur(r,n){if(this.disposed)return ar(Fe(U("accessDenied",false)));let o=fo(r);return o!==null?(this.telemetry.track("chat.send.rejected",{reason:o.reason}),ar(Fe(o.error))):(this.resetThread(),this.send(r,n??{}))}retryLast(){let r=this.lastTurn;if(r===null){let s=this.snapshot.conversationId;return s!==null&&this.snapshot.status==="error"?this.retryHistory(s):va()}r.assistantMessageId=null,r.sawDelta=false,r.conversationIdOverride=null,this.discardPendingDelta();let o=this.snapshot.messages.some(s=>s.id===r.userMessageId)?this.snapshot.messages:[...this.snapshot.messages,no(r.userMessageId,r.text,this.stamp())];return this.patch({error:null,stopped:false,messages:o}),this.runTurn(r,void 0)}stop(){this.inFlight?.abort(),this.inFlight=null,this.discardPendingDelta(),this.telemetry.track("chat.cancel",{});let r=this.snapshot.messages.some(o=>o.role==="user"&&o.pending===true),n=r?this.snapshot.messages.map(o=>o.pending===true?nr(o):o):this.snapshot.messages;(this.snapshot.status==="streaming"||r)&&this.patch({status:"idle",isStreaming:false,reconnecting:false,...r?{messages:n,stopped:true}:{}});}rescope(){this.resetThread(),this.scopePrompts=[],this.unreadByConversation.clear(),this.classifiedMessageIds.clear(),this.reflectUnreadDot();}resetThread(r=[]){super.rescope(),this.historyGeneration+=1,this.unadoptedCreate=null,this.lastTurn=null,this.lastResponseIdValue=null,this.bootstrapPrompts=r,this.replyPrompts=null,this.discardPendingDelta(),this.patch({status:"idle",isStreaming:false,messages:[],conversationId:null,error:null,suggestedPrompts:r,historyCursor:null,isLoadingHistory:false,isBootstrapping:false,unreadCount:null,stopped:false,reconnecting:false});}newConversation(){this.disposed||this.resetThread(this.scopePrompts);}dispose(){this.rescope(),this.disposed=true,this.unadoptedCreate=null,this.discardPendingDelta();for(let r of this.handlerTeardowns)r();this.handlerTeardowns.clear(),super.dispose();}adoptConversation(r){this.disposed||(this.unadoptedCreate=null,this.snapshot.conversationId!==r&&this.patch({conversationId:r}));}adoptPrompts(r){if(this.disposed)return;let n=Object.freeze(ao(r));this.bootstrapPrompts=n,this.scopePrompts=n,this.replyPrompts===null&&(n.length===0&&this.snapshot.suggestedPrompts.length===0||this.patch({suggestedPrompts:n}));}async listConversations(r){return this.listConversationsWith(r)}async listConversationsWith(r,n){let o=uo(r,100);if(!o.ok)return o;let s=this.epoch;if(this.disposed)return v(U("accessDenied",false));let a=await this.authedUnary("chat.listConversations",{method:"GET",path:`/widget/v1/conversations${o.value}`},r?.signal,n);if(!this.alive(s)||this.disposed)return v(U("accessDenied",false));if(!a.ok)return a;let l=ya(a.value);if(l.ok){for(let c of l.value.conversations)c.unreadCount!==null&&this.unreadByConversation.set(c.id,c.unreadCount);let u=this.snapshot.conversationId,d=u===null?void 0:this.unreadByConversation.get(u);d!==void 0&&d!==this.snapshot.unreadCount&&this.patch({unreadCount:d}),this.reflectUnreadDot();}return l}reflectUnreadDot(){let r=false;for(let n of this.unreadByConversation.values())if(n>0){r=true;break}r!==(this.snapshot.hasUnreadThreads??false)&&this.patch({hasUnreadThreads:r});}async openCheckin(r){if(this.disposed)return v(U("accessDenied",false));let n=r?.conversationId??null;if(n!==null){let u=await this.resumeConversation(n);return u.ok?L(n):v(u.error)}let o=r?.petRef??this.petRef,s=await this.listConversations({...o===null?{}:{petRef:o},limit:1});if(!s.ok)return v(s.error);let a=s.value.conversations[0];if(a===void 0)return L(null);let l=await this.resumeConversation(a.id);return l.ok?L(a.id):v(l.error)}async markRead(r){if(this.disposed)return v(U("accessDenied",false));let n=this.snapshot.conversationId;if(n===null)return L(void 0);let o=this.epoch,s=await this.authedUnary("chat.markRead",{method:"POST",path:`/widget/v1/conversations/${n}/read`},r?.signal);return !this.alive(o)||this.disposed?v(U("accessDenied",false)):s.ok?(this.unreadByConversation.set(n,0),this.snapshot.conversationId===n&&this.snapshot.unreadCount!==0&&this.patch({unreadCount:0}),this.reflectUnreadDot(),L(void 0)):v(s.error)}async submitFeedback(r,n,o,s){if(this.disposed)return v(U("accessDenied",false));if(typeof r!="string"||r.trim().length===0||Re(r))return v(U("validationFailed",false,"feedback needs the server message id of an assistant reply"));if(!co.includes(n))return v(U("validationFailed",false,`feedback_type must be one of ${co.join(", ")}`));let a=typeof o=="string"?o.trim():"";if([...a].length>Mt)return v(U("validationFailed",false,`notes is over ${Mt} characters`));let l={feedback_type:n};a.length>0&&(l.notes=a);let u=this.epoch,d=await this.authedUnary("chat.submitFeedback",{method:"POST",path:`/widget/v1/messages/${encodeURIComponent(r)}/feedback`,body:l},s?.signal);if(!this.alive(u)||this.disposed)return v(U("accessDenied",false));if(!d.ok)return v(d.error);let c=d.value?.feedback_id;return L(Object.freeze({feedbackId:typeof c=="string"?c:""}))}async answerCheckin(r,n,o){if(this.disposed)return v(U("accessDenied",false));let s=o?.petRef??this.petRef;if(s===null)return v(U("validationFailed",false,"a check-in needs the pet the case belongs to"));let a=this.epoch,l=await this.cases.checkin(s,r,n,o?.signal?{signal:o.signal}:{});if(!this.alive(a)||this.disposed)return v(U("accessDenied",false));if(!l.ok)return l;let u=l.value.case.openedAt,d=Object.freeze({caseId:r,answer:n,resolutionText:l.value.case.resolutionText,status:l.value.case.status??null,...u!==null?{openedAt:u}:{}}),c=i(p=>p.checkin?.caseId===r,"carries");return this.snapshot.messages.some(c)&&this.patch({messages:this.snapshot.messages.map(p=>c(p)?Object.freeze({...p,checkin:d}):p)}),l}async getMessages(r,n){if(!sr(r))return v(U("validationFailed",false));let o=uo(n,200);if(!o.ok)return o;let s=this.epoch;if(this.disposed)return v(U("accessDenied",false));let a=await this.authedUnary("chat.getMessages",{method:"GET",path:`/widget/v1/conversations/${r}/messages${o.value}`},n?.signal);return !this.alive(s)||this.disposed?v(U("accessDenied",false)):a.ok?ga(a.value):a}async resumeConversation(r){if(this.disposed)return v(U("accessDenied",false));if(!sr(r))return v(U("validationFailed",false));this.resetThread();let n=this.historyGeneration;this.patch({conversationId:r,isBootstrapping:true,isLoadingHistory:true});let o=await this.getMessages(r);if(n!==this.historyGeneration||this.disposed)return v(U("accessDenied",false));if(!o.ok)return this.patch({status:"error",error:o.error,isBootstrapping:false,isLoadingHistory:false}),o;let s=this.unreadByConversation.get(r)??null;return this.patch({messages:o.value.messages,historyCursor:o.value.nextCursor,isBootstrapping:false,isLoadingHistory:false,unreadCount:s}),this.stampCheckinStatuses(n),s!==null&&s>0&&this.markRead(),L(void 0)}async stampCheckinStatuses(r){let n=this.petRef;if(n===null||!this.snapshot.messages.some(d=>d.checkin!==void 0&&d.checkin.status===null))return;let o=await this.cases.list(n);if(!o.ok||r!==this.historyGeneration||this.disposed)return;let s=new Set(o.value.filter(d=>d.status===Kr).map(d=>d.caseId)),a=new Map(o.value.map(d=>[d.caseId,d])),l=false,u=this.snapshot.messages.map(d=>{let c=d.checkin;if(c===void 0||c.status!==null)return d;l=true;let p=a.get(c.caseId),f=c.openedAt??p?.openedAt??null,y=s.has(c.caseId),m=p!==void 0&&(!y||pa({askCount:p.checkinAskCount,answerCount:p.checkinAnswerCount}))?p.lastResponse:null;return Object.freeze({...d,checkin:Object.freeze({...c,status:y?Kr:p?.status??"resolved",answer:c.answer??m,resolutionText:c.resolutionText??p?.resolutionText??null,...f!==null?{openedAt:f}:{}})})});l&&this.patch({messages:u});}async refreshActiveThread(){if(this.disposed)return v(U("accessDenied",false));let r=this.snapshot.conversationId;if(r===null||this.snapshot.isStreaming)return L(void 0);let n=this.historyGeneration,o=await this.getMessages(r);if(n!==this.historyGeneration||this.disposed)return v(U("accessDenied",false));if(!o.ok)return v(o.error);let s=new Set(this.snapshot.messages.map(l=>l.id)),a=o.value.messages.filter(l=>!s.has(l.id));return a.length>0&&this.patch({messages:[...this.snapshot.messages,...a]}),await this.listConversationsWith({...this.petRef===null?{}:{petRef:this.petRef},limit:1},{maxAttempts:1}),L(void 0)}async loadOlderMessages(){if(this.disposed)return v(U("accessDenied",false));let r=this.snapshot.conversationId,n=this.snapshot.historyCursor;if(!r||!n||this.snapshot.isLoadingHistory)return L(void 0);let o=this.historyGeneration;this.patch({isLoadingHistory:true});let s=await this.getMessages(r,{cursor:n});if(o!==this.historyGeneration||this.disposed)return v(U("accessDenied",false));if(this.patch({isLoadingHistory:false}),!s.ok)return s;let a=new Set(this.snapshot.messages.map(u=>u.id)),l=s.value.messages.filter(u=>!a.has(u.id));return this.patch({messages:[...l,...this.snapshot.messages],historyCursor:s.value.nextCursor===n?null:s.value.nextCursor}),L(void 0)}async*retryHistory(r){let n=await this.resumeConversation(r);n.ok||(yield Fe(n.error));}async primeConversation(r){if(this.disposed)return v(U("accessDenied",false));let n=r?.petRef??null,o={petRef:n,settled:this.primeBounded(n)};this.unadoptedCreate=o;let s=await o.settled;return this.disposed?v(U("accessDenied",false)):(!s.ok&&this.unadoptedCreate===o&&(this.unadoptedCreate=null),s)}async primeBounded(r){let n=await this.headThreadWithUnread(r);if(n!==null&&!this.snapshot.isStreaming&&this.snapshot.conversationId===null&&(await this.resumeConversation(n)).ok)return L(n);let o=this.snapshot.conversationId;return o!==null?L(o):this.createConversationBounded(r)}async headThreadWithUnread(r){let n=await this.listConversationsWith({...r===null?{}:{petRef:r},limit:1},{maxAttempts:1});if(!n.ok)return null;let o=n.value.conversations[0];return o===void 0||o.unreadCount===null||o.unreadCount<=0?null:o.id}async createConversation(r){let n=this.epoch;if(this.disposed)return v(U("accessDenied",false));let o=r?.petRef??null,s={petRef:o,settled:this.createConversationBounded(o)};this.unadoptedCreate=s;let a=await s.settled;return !this.alive(n)||this.disposed?v(U("accessDenied",false)):(!a.ok&&this.unadoptedCreate===s&&(this.unadoptedCreate=null),a)}async createConversationBounded(r,n){let o={method:"POST",path:"/widget/v1/conversations",body:r?{pet_ref:r}:{}},s=await this.authedUnary("chat.createConversation",o,n,{maxAttempts:1});if(!s.ok)return v(s.error);let a=s.value?.conversation_id??s.value?.id;return typeof a!="string"||a.length===0?v(U("internalError",true)):L(a)}async getPrompts(r){let n=this.epoch;if(this.disposed)return v(U("accessDenied",false));let o=r?.petRef??null;if(o!==null&&Re(o))return v(D("validationFailed",{retryable:false,wireMessage:"pet_ref contains an unpaired surrogate and cannot be encoded"}));let s=o!==null?`?pet_ref=${encodeURIComponent(o)}`:"",a=await this.authedUnary("chat.getPrompts",{method:"GET",path:`/widget/v1/suggested-prompts${s}`});return !this.alive(n)||this.disposed?v(U("accessDenied",false)):a.ok?L(ia(a.value)):v(a.error)}async authedUnary(r,n,o,s){return this.funnel.send(r,o?{...n,signal:o}:n,s)}driveWithHandlers(r,n,o){let s=new AbortController,a=Gr(s.signal,n.signal),l=this.beginTurn(r,n),u=this.runTurn(l,a),d=false,c=i(()=>{d||(d=true,s.abort(),this.handlerTeardowns.delete(c));},"teardown");return this.handlerTeardowns.add(c),(async()=>{for await(let p of u){if(d)break;o.onFrame(p),p.kind==="done"&&o.onDone(this.lastResponseIdValue);}!d&&this.snapshot.status==="error"&&this.snapshot.error!==null&&o.onError(this.snapshot.error),this.handlerTeardowns.delete(c);})(),c}beginTurn(r,n){let o={epoch:this.epoch,text:r,petRef:n.petRef??null,imageS3Keys:Object.freeze([...n.imageS3Keys??[]]),idempotencyKey:n.idempotencyKey??this.makeIdempotencyKey(),userMessageId:this.newId(),assistantMessageId:null,sawDelta:false,conversationIdOverride:n.conversationId??null};return this.patch({error:null,stopped:false,reconnecting:false,messages:[...this.snapshot.messages,no(o.userMessageId,r,this.stamp())]}),o}async*runTurn(r,n){let o=this.beginOperation(n);r.epoch=o.epoch,this.patch({status:"streaming",isStreaming:true,error:null}),this.lastTurn=r;let s=0,a=false,l=false;try{for(;;){if(o.signal.aborted||!this.alive(o.epoch))return;let u=r.conversationIdOverride===null&&this.snapshot.conversationId===null,d=u?this.unadoptedCreate:null;if(d!==null&&(r.petRef===null||r.petRef===d.petRef)){let b=await d.settled;if(o.signal.aborted||!this.alive(o.epoch))return;b.ok&&this.snapshot.conversationId===null&&this.adoptConversation(b.value);}if(u&&this.snapshot.conversationId===null){let b=await this.createConversationBounded(r.petRef,o.signal);if(o.signal.aborted||!this.alive(o.epoch))return;if(!b.ok){yield*this.emitTerminal(r,b.error,Fe(b.error));return}this.adoptConversation(b.value);}let c=r.conversationIdOverride??this.snapshot.conversationId;if(c===null){let b=U("internalError",!0);yield*this.emitTerminal(r,b,Fe(b));return}this.clearAssistantInProgress(r);let p=new AbortController,f=Gr(o.signal,p.signal),y=null;try{let b;try{b=await this.funnel.authorize(this.buildSendRequest(r,c));}catch{let I=this.authRejected();yield*this.emitTerminal(r,I,Fe(I));return}if(o.signal.aborted||!this.alive(o.epoch))return;let R=this.funnel.stream("chat.send",b,f);for await(let I of da(R,this.budget,f,this.timers)){if(!this.alive(o.epoch))return;if(I.kind==="error"&&I.terminal){y=I;break}if(this.applyFrame(I,r),yield I,I.terminal){o.settle();return}}}finally{p.abort();}if(o.signal.aborted||!this.alive(o.epoch))return;if(y===null){if(this.snapshot.status==="complete")return;let b=U("streamIncomplete",!0);yield*this.emitTerminal(r,b,Fe(b));return}let m=Oe(y.code);if(m==="authExpired"&&this.auth.mode==="personalized"&&!l){l=!0,this.telemetry.track("chat.auth.refresh",{});let b=await this.tryForceRefresh();if(o.signal.aborted||!this.alive(o.epoch))return;if(!b){let R=this.authRejected();yield*this.emitTerminal(r,R,y);return}this.patch({reconnecting:!0});continue}if(m==="authExpired"){this.telemetry.track("chat.auth.rejected",{});let b=this.authRejected();yield*this.emitTerminal(r,b,y);return}if(m==="accessDenied"){this.telemetry.track("chat.access_denied",{}),yield*this.emitTerminal(r,so(y),y);return}if(fs(m)&&!a){a=!0,this.telemetry.track("chat.conv.recreate",{}),this.adoptConversation(null),r.conversationIdOverride=null,this.patch({reconnecting:!0});continue}let w=y.retryable&&Nr(m,!0);if(ry&&w&&s+1<this.errorPolicy.maxAttempts(m));yield*this.emitTerminal(r,so(y),y);return}}finally{o.settle();}}*emitTerminal(r,n,o){this.applyError(r,n),yield o;}applyFrame(r,n){switch(r.kind){case "accepted":this.snapshot.isStreaming||this.patch({status:"streaming",isStreaming:true});return;case "heartbeat":return;case "delta":this.applyDelta(r.delta,n);return;case "done":this.applyDone(r,n);return;case "analysisStarted":case "analysisComplete":return;case "unknown":this.telemetry.track("chat.frame.unknown",{});return;case "error":return;default:return Qe(r)}}stamp(){return new Date(this.timers.now()).toISOString()}applyDelta(r,n){if(n.assistantMessageId===null){let o=this.newId();n.assistantMessageId=o,n.sawDelta=true;let s=this.snapshot.messages.map(a=>a.id===n.userMessageId&&a.pending===true?nr(a):a);this.patch({status:"streaming",isStreaming:true,messages:[...s,oo(o,r,this.stamp())]});return}if(this.pendingDelta+=r,this.pendingDelta.length>=ty){this.flushPendingDelta(n);return}this.scheduleDeltaFlush(n);}scheduleDeltaFlush(r){if(this.flushHandle!==null)return;let n=this.epoch;this.flushHandle=this.timers.setTimeout(()=>{if(this.flushHandle=null,!this.alive(n)){this.pendingDelta="";return}this.flushPendingDelta(r);},ey);}flushPendingDelta(r){if(this.clearFlushTimer(),this.pendingDelta.length===0)return;let n=this.pendingDelta;this.pendingDelta="";let o=r.assistantMessageId;if(o===null)return;let s=this.snapshot.messages.map(a=>a.id===o?na(a,n):a);this.patch({messages:s});}discardPendingDelta(){this.clearFlushTimer(),this.pendingDelta="";}clearFlushTimer(){this.flushHandle!==null&&(this.timers.clearTimeout(this.flushHandle),this.flushHandle=null);}applyDone(r,n){this.flushPendingDelta(n),this.lastResponseIdValue=r.messageId?r.messageId:null;let o=r.conversationId?r.conversationId:this.snapshot.conversationId,s;if(n.assistantMessageId!==null)s=this.snapshot.messages.map(l=>l.id===n.assistantMessageId?io(l,r):l);else {let l=this.newId();n.assistantMessageId=l,n.sawDelta=true,s=[...this.snapshot.messages.map(d=>d.id===n.userMessageId&&d.pending===true?nr(d):d),io(oo(l,"",this.stamp()),r)];}let a=ao([{category:"",prompts:r.followUpQuestions}]);this.replyPrompts=a.length>0?Object.freeze(a):null,this.patch({status:"complete",isStreaming:false,error:null,conversationId:o,messages:s,suggestedPrompts:this.replyPrompts??this.bootstrapPrompts,reconnecting:false}),!r.urgencyProvided&&o!==null&&this.classifyTurn(o,this.lastResponseIdValue);}async classifyTurn(r,n){if(n===null||this.disposed)return;let o=String(n);if(this.classifiedMessageIds.has(o))return;this.classifiedMessageIds.add(o);let s=this.epoch,a=this.historyGeneration,l=await this.authedUnary("chat.classifyUrgency",{method:"POST",path:`/widget/v1/conversations/${r}/classify`});if(!l.ok||!this.alive(s)||this.disposed||a!==this.historyGeneration||this.snapshot.conversationId!==r)return;let u=ba(l.value?.urgency),d=typeof l.value?.reason=="string"?l.value.reason:null,c=i(p=>p.responseId===n,"carries");this.snapshot.messages.some(c)&&this.patch({messages:this.snapshot.messages.map(p=>c(p)?Object.freeze({...p,urgencyLevel:u,urgencyReason:d,urgencyProvided:true}):p)});}applyError(r,n){this.flushPendingDelta(r);let o=this.snapshot.messages.map(s=>s.id===r.userMessageId&&s.pending===true?nr(s):s);this.patch({status:"error",isStreaming:false,error:n,messages:o,reconnecting:false});try{this.errorPolicy.onExpectedFailure?.(n);}catch{}}clearAssistantInProgress(r){if(this.discardPendingDelta(),r.assistantMessageId===null)return;let n=r.assistantMessageId;r.assistantMessageId=null,r.sawDelta=false;let o=this.snapshot.messages.filter(s=>s.id!==n);o.length!==this.snapshot.messages.length&&this.patch({messages:o});}buildSendRequest(r,n){let o={message:r.text};return r.imageS3Keys.length>0&&(o.image_s3_keys=r.imageS3Keys),{method:"POST",path:`/widget/v1/conversations/${n}/messages`,body:o,headers:{"Idempotency-Key":r.idempotencyKey}}}async tryForceRefresh(){if(this.auth.mode!=="personalized")return false;try{return await this.auth.identity.currentToken({forceRefresh:!0}),!0}catch{return false}}authRejected(){return U("authRejected",false)}};i(yo,"ChatControllerImpl");var mo=yo;async function Sa(e,t){let{controller:r}=t,n=e.petRef??null,o=e.resumeConversationId??null,s=[],a=false,l=false,u=false,d=null,c=null,p=o?r.resumeConversation(o).then(x=>x.ok?L(o):x):r.primeConversation(n?{petRef:n}:void 0),f=r.getPrompts(n!==null?{petRef:n}:void 0),[y,m]=await Promise.all([p,f]),w=null;if(y.ok)w=y.value,s.push(y.value),r.getSnapshot().conversationId===null&&r.adoptConversation(y.value);else {let x=y.error;c=x,Ca(x)?(l=true,d=x):(Ra(x)&&(a=true),u=true);}let b=[];m.ok?b=m.value:R(m.error);function R(x){Ca(x)?(l=true,d===null&&(d=x)):Ra(x)&&(a=true);}i(R,"recordAuthSignals");let I=d!==null?d.displayMessage:null;return Object.freeze({conversationId:w,petRef:n,suggestedPrompts:b,error:I,warning:I===null&&w===null&&u?ny:null,cause:d??c,diagnostics:Object.freeze({candidateConversationIds:Object.freeze([...s]),sawForbidden:a,sawUnauthorized:l,sawConversationInitFailure:u})})}i(Sa,"bootstrapChat");var ny="Chat is ready. Your first message will start the conversation.";function Ca(e){return e.httpStatus===401||e.code==="authExpired"||e.code==="authRejected"}i(Ca,"isUnauthorized");function Ra(e){return e.httpStatus===403||e.code==="accessDenied"}i(Ra,"isForbidden");var go=Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function Ta(e){return e!==go}i(Ta,"isUploadTransportAvailable");var oy=Object.freeze(["image/jpeg","image/jpg","image/png","image/heic","image/heif","image/webp"]);var qr=10*1024*1024,$r=5,lr=120,iy="/widget/v1/uploads/initiate";function sy(e){return typeof e=="string"&&oy.includes(e.trim().toLowerCase())}i(sy,"isAttachmentMime");function ho(e){if(!e)return "attachment";let t=e.replace(/[\\/]+/g," ").replace(/[\x00-\x1f\x7f"]/g,"").replace(/\s+/g," ").trim();if(!t)return "attachment";if(t.length<=lr)return t;let r=t.lastIndexOf(".");if(r===-1||r===t.length-1)return t.slice(0,lr);let n=t.slice(r);return n.length>=lr?t.slice(0,lr):`${t.slice(0,r).slice(0,lr-n.length)}${n}`}i(ho,"sanitizeFilename");function bo(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}i(bo,"formatBytes");var ur=i(e=>Object.freeze({ok:true,value:e}),"ok"),_e=i(e=>Object.freeze({ok:false,error:e}),"err");function oe(e,t,r,n){return Object.freeze({code:e,retryable:t,filename:r,...n??{}})}i(oe,"failure");function ay(e){if(typeof e.sizeBytes=="number"&&Number.isFinite(e.sizeBytes)&&e.sizeBytes>=0)return e.sizeBytes;let t=e.blob;return t!==void 0&&typeof t.size=="number"&&Number.isFinite(t.size)?t.size:null}i(ay,"attachmentSize");function ly(e){let t=ho(e.name),r=typeof e.mimeType=="string"?e.mimeType.trim().toLowerCase():"";if(!sy(r))return _e(oe("unsupported_type",false,t));let n=ay(e);return n===null?_e(oe("unknown",false,t)):n>qr?_e(oe("too_large",false,t,{sizeBytes:n})):ur(Object.freeze({file:e,filename:t,contentType:r,sizeBytes:n}))}i(ly,"validateAttachment");function uy(e){if(typeof e!="object"||e===null)return null;let t=e,r=i(d=>typeof d=="string"&&d.length>0?d:null,"str"),n=i(d=>typeof d=="number"&&Number.isFinite(d)?d:null,"num"),o=r(t.upload_id),s=r(t.upload_url),a=r(t.s3_key);if(o===null||s===null||a===null)return null;let l={},u=t.upload_fields;if(typeof u=="object"&&u!==null)for(let[d,c]of Object.entries(u))typeof c=="string"&&(l[d]=c);return Object.freeze({upload_id:o,upload_url:s,upload_fields:Object.freeze(l),expires_in_seconds:n(t.expires_in_seconds)??0,max_content_length:n(t.max_content_length)??qr,s3_key:a,purpose:r(t.purpose)})}i(uy,"parsePolicy");function dy(e,t){let r=e.httpStatus;switch(e.code){case "quotaExceeded":return oe("quota_exceeded",false,t,{cause:e});case "rateLimited":return oe("rate_limited",true,t,{cause:e});case "idempotencyConflict":case "idempotencyInFlight":return oe("idempotency_conflict",true,t,{cause:e});case "validationFailed":return oe("unsupported_type",false,t,{cause:e});case "serviceUnavailable":case "streamTimeout":return oe("network",true,t,{cause:e});default:return r===429?oe("rate_limited",true,t,{cause:e}):r===503?oe("network",true,t,{cause:e}):r===void 0?oe("network",true,t,{cause:e}):oe("server",e.retryable,t,{httpStatus:r,cause:e})}}i(dy,"initiateFailure");async function cy(e,t,r){let n=await e.send("chat.attachments.initiate",{method:"POST",path:iy,body:{filename:t.filename,content_type:t.contentType,file_size:t.sizeBytes},...r?.signal?{signal:r.signal}:{}});if(!n.ok)return _e(dy(n.error,t.filename));let o=uy(n.value);return o===null?_e(oe("server",false,t.filename)):ur(o)}i(cy,"initiateAttachmentUpload");async function py(e,t,r,n){let o=i(()=>n?.signal?.aborted===true,"cancelled");if(o())return _e(oe("cancelled",true,r.filename));try{return await e.postMultipart(t,r.file,{...n?.signal?{signal:n.signal}:{},...n?.onProgress?{onProgress:n.onProgress}:{}}),ur(void 0)}catch{return o()?_e(oe("cancelled",true,r.filename)):_e(oe("server",true,r.filename))}}i(py,"uploadAttachmentBytes");var fy=2,my=3,yy=Object.freeze([1e3,2e3,4e3]),Pa=0;function gy(){return Pa+=1,`attachment-${Pa}`}i(gy,"defaultNewId");function ka(e){let t=Math.max(1,e.concurrency??fy),r=Math.max(1,e.maxAttempts??my),n=e.backoffMs??yy,o=Math.max(1,e.maxPerMessage??$r),s=e.timers??ra,a=e.newId??gy,l=Ta(e.transport),u=new Map,d=[],c=[],p=new Set,f=new Set,y=Object.freeze({attachments:Object.freeze([])}),m=false,w=i(()=>{y=Object.freeze({attachments:Object.freeze(d.flatMap(g=>{let _=u.get(g);return _===void 0?[]:[_.state]}))});for(let g of f)g();},"publish"),b=i((g,_)=>{g.state=Object.freeze({...g.state,..._}),w();},"patch"),R=i(()=>{for(;!m&&p.size<t&&c.length>0;){let g=c.shift(),_=u.get(g);_!==void 0&&(p.add(g),I(_).finally(()=>{p.delete(g),R();}));}},"pump"),I=i(async g=>{let{attachment:_}=g;for(;g.attempts<r;){if(m||g.controller.signal.aborted)return;g.attempts+=1;let F=g.controller.signal;b(g,{status:"uploading",error:null,progress:0});let M=await cy(e.funnel,_,{signal:F});if(m||F.aborted)return;let E;if(!M.ok)E=_e(M.error);else {let j=await py(e.transport,M.value,_,{signal:F,onProgress:i(G=>{!F.aborted&&g.state.status==="uploading"&&b(g,{progress:hy(G)});},"onProgress")});if(m||F.aborted)return;E=j.ok?ur(M.value.s3_key):_e(j.error);}if(E.ok){b(g,{status:"uploaded",s3Key:E.value,error:null,progress:1});return}let k=E.error,T=k.retryable&&g.attempts<r;if(b(g,{status:T?"uploading":"failed",error:k,progress:0}),!T)return;let V=n[Math.min(g.attempts-1,n.length-1)]??0;await Wr(V,F,s);}},"run"),P=i(g=>{c.push(g.state.id),R();},"enqueue"),x={available:l,subscribe(g){return f.add(g),()=>{f.delete(g);}},getSnapshot:i(()=>y,"getSnapshot"),get uploading(){return y.attachments.some(g=>g.status==="uploading")},get s3Keys(){return y.attachments.flatMap(g=>g.status==="uploaded"&&g.s3Key!==null?[g.s3Key]:[])},add(g){let _=ly(g);if(!_.ok)return _;if(m||d.length>=o)return _e(oe("too_many",false,_.value.filename));let F=a(),M={attachment:_.value,controller:new AbortController,attempts:0,state:Object.freeze({id:F,filename:_.value.filename,previewUri:g.uri,contentType:_.value.contentType,sizeBytes:_.value.sizeBytes,status:"uploading",s3Key:null,error:null,progress:0})};return u.set(F,M),d.push(F),w(),P(M),ur(M.state)},retry(g){let _=u.get(g);_===void 0||m||_.state.status!=="failed"||(_.controller=new AbortController,_.attempts=0,b(_,{status:"uploading",error:null,progress:0,s3Key:null}),P(_));},remove(g){let _=u.get(g);if(_===void 0)return;_.controller.abort(),u.delete(g);let F=d.indexOf(g);F>=0&&d.splice(F,1);let M=c.indexOf(g);M>=0&&c.splice(M,1),w();},clear(){for(let g of [...d])x.remove(g);},dispose(){m=true;for(let g of u.values())g.controller.abort();u.clear(),d.length=0,c.length=0,f.clear(),y=Object.freeze({attachments:Object.freeze([])});}};return x}i(ka,"createAttachmentQueue");function hy(e){return Number.isNaN(e)||e<0?0:e>1?1:e}i(hy,"clamp");var xa=Object.freeze({dog:"dog",canine:"dog",k9:"dog",puppy:"dog",cat:"cat",feline:"cat",kitten:"cat"});function dr(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.prototype.hasOwnProperty.call(xa,t)?xa[t]:null}i(dr,"canonicalPetSpecies");var _a=50,by=128,vo=120,wa=120,vy=2e3,Ia=120,Ey=80,Fa=new Set(["male","female","unknown"]),Ma=new Set(["day","month","year"]),La=new Set(["low","medium","high","athletic"]),Da=new Set(["indoor","outdoor","both"]),Na=new Set(["mild","moderate","severe"]),Cy=/^(\d{4})-(\d{2})-(\d{2})$/,Ua=[["sex","sex"],["spayedNeutered","spayed_neutered"],["birthDate","birth_date"],["birthDatePrecision","birth_date_precision"],["activityLevel","activity_level"],["indoorOutdoor","indoor_outdoor"],["foodBrand","food_brand"],["foodType","food_type"],["microchipId","microchip_id"]],Va=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];Object.freeze([...Ua,...Va].map(([e])=>e));function Ry(e){let t=Cy.exec(e);if(t===null)return false;let[r,n,o]=[Number(t[1]),Number(t[2]),Number(t[3])],s=new Date(Date.UTC(r,n-1,o));return s.getUTCFullYear()===r&&s.getUTCMonth()===n-1&&s.getUTCDate()===o}i(Ry,"isRealDate");var pr=i(e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,"oneOf"),Sy=i((e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,"boolean"),Xr=i((e,t)=>typeof t=="string"&&Ry(t)?null:`${e} must be a real date written YYYY-MM-DD`,"date"),Me=i((e,t={})=>(r,n)=>{if(typeof n!="string")return `${r} must be a string`;if(Re(n))return `${r} contains an unpaired surrogate and cannot be encoded`;let o=t.trimmed?n.trim():n;if(t.required&&o.length===0)return `${r} is required and must not be blank`;let s=st(o);return s<=e?null:`${r} is ${s} characters; the server accepts at most ${e}`},"text"),Ty={sex:pr(Fa),spayedNeutered:Sy,birthDate:Xr,birthDatePrecision:pr(Ma),activityLevel:pr(La),indoorOutdoor:pr(Da),foodBrand:Me(Ia),foodType:Me(Ia),microchipId:Me(Ey)},Eo=["ref","ref",false,Me(by,{required:true,trimmed:true})],Co=["notes","notes",false,Me(vy,{trimmed:true})],Aa=[Eo,["name","name",true,Me(vo,{required:true,trimmed:true})],["dose","dose",false,Me(wa,{trimmed:true})],["frequency","frequency",false,Me(wa,{trimmed:true})],["startDate","start_date",false,Xr],["endDate","end_date",false,Xr],Co],Py={allergies:[Eo,["allergen","allergen",true,Me(vo,{required:true,trimmed:true})],["severity","severity",false,pr(Na)],Co],medications:Aa,supplements:Aa,conditions:[Eo,["conditionName","condition_name",true,Me(vo,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,Xr],Co]};function ky(e,t,r){let n=`${e}[${t}]`;if(typeof r!="object"||r===null||Array.isArray(r))return {error:`${n} must be an object`};let o=r,s={};for(let[u,d,c,p]of Py[e]){let f=o[u];if(f==null){if(c)return {error:`${n}.${u} is required`};f===null&&(s[d]=null);continue}let y=p(`${n}.${u}`,f);if(y!==null)return {error:y};s[d]=f;}let a=s.start_date,l=s.end_date;return typeof a=="string"&&typeof l=="string"&&l<a?{error:`${n}.endDate must not be before startDate`}:{item:s}}i(ky,"itemToWire");function xy(e,t){if(!Array.isArray(t))return {error:`${e} must be an array (send [] to clear it)`};if(t.length>_a)return {error:`${e} has ${t.length} items; the server accepts at most ${_a}`};let r=[],n=new Set;for(let o=0;o<t.length;o+=1){let s=ky(e,o,t[o]);if("error"in s)return s;let a=s.item.ref;if(typeof a=="string"){let l=a.trim();if(n.has(l))return {error:`${e}: ref ${JSON.stringify(l)} is used twice; a ref names one item`};n.add(l);}r.push(s.item);}return {items:r}}i(xy,"listToWire");function Ha(e,t){let r=e,n={};for(let[a,l]of Ua){let u=r[a];if(u!==void 0){if(u!==null){let d=Ty[a](a,u);if(d!==null)return {error:d}}n[l]=u;}}let o=r.birthDate!==void 0,s=r.birthDatePrecision!==void 0;if(o!==s||o&&r.birthDate===null!=(r.birthDatePrecision===null))return {error:"birthDate and birthDatePrecision must be sent together, both set or both null"};for(let[a,l]of Va){let u=r[a];if(u===void 0)continue;let d=xy(a,u);if("error"in d)return d;n[l]=d.items;}return Object.keys(n).length>0&&t!==void 0&&dr(t)===null?{error:"health fields need a pet Everfur reads as a dog or a cat (dog, canine, k9, puppy, cat, feline, kitten)"}:{body:n}}i(Ha,"petHealthToWire");var ee=i(e=>typeof e=="string"?e:null,"str"),cr=i((e,t)=>typeof t=="string"&&e.has(t)?t:null,"pick"),_y=i(e=>typeof e=="boolean"?e:null,"bool");function Yr(e,t){return Array.isArray(e)?Object.freeze(e.flatMap(r=>{if(typeof r!="object"||r===null||Array.isArray(r))return [];let n=t(r);return n===null?[]:[n]})):Object.freeze([])}i(Yr,"itemsFromWire");function Oa(e){let t=ee(e.name);return t===null||t.length===0?null:Object.freeze({ref:ee(e.ref),name:t,dose:ee(e.dose),frequency:ee(e.frequency),startDate:ee(e.start_date),endDate:ee(e.end_date),notes:ee(e.notes)})}i(Oa,"medicationFromWire");function Ba(e){let t=e.profile_version;return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:cr(Fa,e.sex),spayedNeutered:_y(e.spayed_neutered),birthDate:ee(e.birth_date),birthDatePrecision:cr(Ma,e.birth_date_precision),activityLevel:cr(La,e.activity_level),indoorOutdoor:cr(Da,e.indoor_outdoor),foodBrand:ee(e.food_brand),foodType:ee(e.food_type),microchipId:ee(e.microchip_id),allergies:Yr(e.allergies,r=>{let n=ee(r.allergen);return n===null||n.length===0?null:Object.freeze({ref:ee(r.ref),allergen:n,severity:cr(Na,r.severity),notes:ee(r.notes)})}),medications:Yr(e.medications,Oa),supplements:Yr(e.supplements,Oa),conditions:Yr(e.conditions,r=>{let n=ee(r.condition_name);return n===null||n.length===0?null:Object.freeze({ref:ee(r.ref),conditionName:n,diagnosedDate:ee(r.diagnosed_date),notes:ee(r.notes)})})})}i(Ba,"petHealthFromWire");var Wa=100,Ga=50,Ka=100,qa=50,$a=500,wy=128,Iy=6e4;function De(e){return D("validationFailed",{retryable:false,wireMessage:e})}i(De,"invalid");function at(e,t,r){if(typeof t!="string")return De(`${e} must be a string`);let n=st(t);return n<=r?null:De(`${e} is ${n} characters; the server accepts at most ${r}`)}i(at,"checkString");function Qr(e,t,r){return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=r?null:De(`${e} must be a finite number between 0 and ${r}`)}i(Qr,"outOfRange");function za(e,t){if(typeof e!="string")return De("pet_ref must be a string");if(e.trim().length===0)return De("pet_ref must not be blank");if(Re(e))return De("pet_ref contains an unpaired surrogate and cannot be encoded");if(t!=null&&typeof t!="object")return De("profile must be an object");let r=[at("pet_ref",e,wy)];return t?.name!==void 0&&r.push(at("name",t.name,Wa)),t?.species!==void 0&&r.push(at("species",t.species,Ga)),t?.breed!==void 0&&r.push(at("breed",t.breed,Ka)),t?.ageYears!==void 0&&r.push(Qr("age_years",t.ageYears,qa)),t?.weightKg!==void 0&&r.push(Qr("weight_kg",t.weightKg,$a)),r.find(n=>n!==null)??null}i(za,"validate");function Ya(e,t){let r=Ha(e,t);return "error"in r?{error:De(r.error)}:r}i(Ya,"healthToWire");function Ay(e){if(typeof e!="object"||e===null)return {error:De("patch must be an object")};let t=e,r=[["name","name",s=>at("name",s,Wa)],["species","species",s=>at("species",s,Ga)],["breed","breed",s=>at("breed",s,Ka)],["ageYears","age_years",s=>Qr("age_years",s,qa)],["weightKg","weight_kg",s=>Qr("weight_kg",s,$a)]],n={};for(let[s,a,l]of r){let u=t[s];if(u!==void 0){if(u!==null){let d=l(u);if(d!==null)return {error:d}}n[a]=u;}}let o=Ya(t,t.species);return "error"in o?o:(Object.assign(n,o.body),Object.keys(n).length===0?{error:De("patch must change at least one field")}:{body:n})}i(Ay,"patchToWire");function Oy(e){if(e==null)return {body:{}};let t=Ya(e,e.species);return "error"in t?t:{body:{...e.name!==void 0?{name:e.name}:{},...e.species!==void 0?{species:e.species}:{},...e.breed!==void 0?{breed:e.breed}:{},...e.ageYears!==void 0?{age_years:e.ageYears}:{},...e.weightKg!==void 0?{weight_kg:e.weightKg}:{},...t.body}}}i(Oy,"toWire");var Le=i(e=>typeof e=="string"?e:null,"str"),Zr=i(e=>typeof e=="number"&&Number.isFinite(e)?e:null,"num");function ja(e,t){let r=typeof e=="object"&&e!==null?e:{};return Object.freeze({petRef:Le(r.pet_ref)??t,name:Le(r.name),species:Le(r.species),breed:Le(r.breed),ageYears:Zr(r.age_years),weightKg:Zr(r.weight_kg)})}i(ja,"fromWire");function Xa(e){if(typeof e!="object"||e===null)return null;let t=e,r=Le(t.pet_ref);return r===null||r.length===0?null:Object.freeze({petId:Le(t.pet_id),petRef:r,name:Le(t.name),species:Le(t.species),breed:Le(t.breed),ageYears:Zr(t.age_years),weightKg:Zr(t.weight_kg),updatedAt:Le(t.updated_at)})}i(Xa,"widgetPetFromWire");function Fy(e){let t=Xa(e);return t===null?null:Object.freeze({...t,...Ba(e)})}i(Fy,"widgetPetProfileFromWire");function My(e){let t=Array.isArray(e)?e:typeof e=="object"&&e!==null&&Array.isArray(e.pets)?e.pets:[];return Object.freeze(t.flatMap(r=>{let n=Xa(r);return n===null?[]:[n]}))}i(My,"petListFromWire");function Ze(e){return Ly(xe({auth:e}),xe({auth:e,unaryTimeoutMs:Iy}))}i(Ze,"createPetsRepository");function Ly(e,t=e){let r=i((o,s)=>s?{...o,signal:s}:o,"withSignal"),n=i(o=>za(o,void 0)??`/widget/v1/pets/${encodeURIComponent(o)}`,"petPath");return {async list(o){let s=await e.send("pets.list",r({method:"GET",path:"/widget/v1/pets"},o?.signal));return s.ok?L(My(s.value)):v(s.error)},async registerPet(o,s,a){let l=za(o,s);if(l!==null)return v(l);let u=Oy(s);if("error"in u)return v(u.error);let c={method:"POST",path:`/widget/v1/pets/${encodeURIComponent(o)}`,body:u.body},p=await e.send("pets.registerPet",a?.signal?{...c,signal:a.signal}:c);return p.ok?L(ja(p.value,o)):v(p.error)},async updatePet(o,s,a){let l=n(o);if(typeof l!="string")return v(l);let u=Ay(s);if("error"in u)return v(u.error);let d=await e.send("pets.updatePet",r({method:"PATCH",path:l,body:u.body},a?.signal));return d.ok?L(ja(d.value,o)):v(d.error)},async getPetProfile(o,s){let a=n(o);if(typeof a!="string")return v(a);let l=await e.send("pets.getPetProfile",r({method:"GET",path:`${a}/profile`},s?.signal));if(!l.ok)return v(l.error);let u=Fy(l.value);return u===null?v(D("internalError",{retryable:false,httpStatus:502,wireMessage:"the pet profile response carried no pet_ref"})):L(u)},async deletePet(o,s){let a=n(o);if(typeof a!="string")return v(a);let l=await e.send("pets.deletePet",r({method:"DELETE",path:a},s?.signal));return l.ok?L(void 0):v(l.error)},async eraseUserData(o){let s=await t.send("pets.eraseUserData",r({method:"DELETE",path:"/widget/v1/me"},o?.signal),{maxAttempts:1});return s.ok?L(void 0):v(s.error)}}}i(Ly,"createPetsRepositoryOver");var So=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 Dy(e){return So[e]}i(Dy,"requires");function Qa(e,t){let r=Object.freeze({reason:t,level:e,recoverable:false}),n=[],o=new Set;for(let s of Object.keys(So))for(let a of So[s])o.has(a)||(o.add(a),n.push(Object.freeze({resource:a,granted:false,disabled:r})));return Object.freeze(n)}i(Qa,"deniedDecisionsFor");function Za(e,t,r){let n=Dy(e),o=new Map;for(let l of t)o.set(l.resource,l);if(r?.isPending===true&&n.some(l=>!o.has(l)))return Ro({name:e,enabled:false,isPending:true,limits:{}});let s=Ny(n,o);return n.filter(l=>o.get(l)?.granted!==true).length===0?Ro({name:e,enabled:true,isPending:false,limits:s}):Ro({name:e,enabled:false,isPending:false,limits:s,disabled:Uy(n,o)})}i(Za,"decideCapability");function Ny(e,t){let r={};for(let n of e){let o=t.get(n)?.limits;if(o)for(let[s,a]of Object.entries(o)){let l=r[s];r[s]=l===void 0?a:Math.min(l,a);}}return r}i(Ny,"mergeLimits");function Uy(e,t){for(let r of e){let n=t.get(r)?.disabled;if(n)return Object.freeze({reason:n.reason,level:n.level,recoverable:n.recoverable})}return Object.freeze({reason:Ft("accessDenied"),level:"user_entitlement",recoverable:false})}i(Uy,"disabledFor");function Ro(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(Ro,"freezeDecision");function ye(e){let t=ie(e);return t===null?null:Hy(t)}i(ye,"parseColor");function ie(e){if(typeof e=="number")return Ja(e);if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;if(t.startsWith("#"))return To(t.slice(1));if(t.toLowerCase().startsWith("0x"))return To(t.slice(2));if(t.toLowerCase().startsWith("rgb"))return Vy(t);if(/^[0-9a-fA-F]+$/.test(t)){let r=To(t);if(r!==null)return r}return /^\d+$/.test(t)?Ja(Number.parseInt(t,10)):null}i(ie,"toRgba");function To(e){let t=e.trim();if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===3)return {r:Po(t[0]),g:Po(t[1]),b:Po(t[2]),a:1};if(t.length===6)return {r:lt(t,0),g:lt(t,2),b:lt(t,4),a:1};if(t.length===8){let r=lt(t,0);return {r:lt(t,2),g:lt(t,4),b:lt(t,6),a:r/255}}return null}i(To,"fromHex");function Vy(e){let t=e.indexOf("("),r=e.indexOf(")");if(t<0||r<0||r<t)return null;let n=e.slice(t+1,r).split(",").map(u=>u.trim());if(n.length<3)return null;let o=ko(Number(n[0])),s=ko(Number(n[1])),a=ko(Number(n[2]));if(o===null||s===null||a===null)return null;let l=1;if(n.length>=4){let u=Number(n[3]);if(!Number.isFinite(u))return null;l=Math.min(1,Math.max(0,u));}return {r:o,g:s,b:a,a:l}}i(Vy,"fromRgbFunc");function Ja(e){if(!Number.isFinite(e))return null;let t=Math.trunc(e)>>>0,r=t>>>24&255;return {r:t>>>16&255,g:t>>>8&255,b:t&255,a:r===0?1:r/255}}i(Ja,"argbIntToRgba");function lt(e,t){return Number.parseInt(e.slice(t,t+2),16)}i(lt,"byte");function Po(e){return Number.parseInt(`${e??"0"}${e??"0"}`,16)}i(Po,"dup");function ko(e){return Number.isFinite(e)?Math.min(255,Math.max(0,Math.round(e))):null}i(ko,"clampByte");function Hy(e){if(e.a>=1)return dt(e.r,e.g,e.b);let t=Math.round(e.a*1e3)/1e3;return `rgba(${e.r},${e.g},${e.b},${t})`}i(Hy,"normalizeRgba");function dt(e,t,r){return `#${xo(e)}${xo(t)}${xo(r)}`.toUpperCase()}i(dt,"rgbToHex");function xo(e){return e.toString(16).padStart(2,"0")}i(xo,"hex2");var By="#111111",Dt="#FFFFFF",Jr="#000000";function tl(e){let t=ie(e);if(t===null)return Dt;let r=ut(t),n=ut({r:17,g:17,b:17}),o=ut({r:255,g:255,b:255});return Io(r,o)>=Io(r,n)?Dt:By}i(tl,"readableOn");function fr(e,t){let r=tl(e);return ue(r,e)>=t?r:ue(Dt,e)>=ue(Jr,e)?Dt:Jr}i(fr,"legibleOn");function mr(e){let t=i(r=>e.reduce((n,o)=>Math.min(n,ue(r,o)),Number.POSITIVE_INFINITY),"worst");return t(Dt)>=t(Jr)?Dt:Jr}i(mr,"poleForGrounds");function ut(e){let t=_o(e.r/255),r=_o(e.g/255),n=_o(e.b/255);return .2126*t+.7152*r+.0722*n}i(ut,"relativeLuminance");function _o(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}i(_o,"linearize");function Io(e,t){let r=Math.max(e,t),n=Math.min(e,t);return (r+.05)/(n+.05)}i(Io,"luminanceContrast");function ue(e,t){let r=ie(e),n=ie(t);if(r===null||n===null)return 1;let o=n.a>=1?n:{...n},s=r.a>=1?r:rl(r,o);return Io(ut(s),ut(o))}i(ue,"contrastRatio");function rl(e,t){let r=e.a,n=i((o,s)=>Math.round(o*r+s*(1-r)),"mix");return {r:n(e.r,t.r),g:n(e.g,t.g),b:n(e.b,t.b),a:1}}i(rl,"composite");function ct(e,t){let r=ie(e),n=ie(t);if(r===null||n===null)return null;let o=r.a>=1?r:rl(r,{...n});return dt(o.r,o.g,o.b)}i(ct,"flattenOnto");function nl(e,t){let r=ie(e);if(r===null)return null;let n=Math.min(1,Math.max(0,t));return `rgba(${r.r}, ${r.g}, ${r.b}, ${n})`}i(nl,"withAlpha");var el=.05;function Je(e,t,r,n){let o=t[0];if(o===void 0)return r;let s=i(d=>t.every(c=>ue(d,c)>=n),"reads");if(ie(e)===null)return r;if(s(e))return e;let a=ct(e,o),l=a===null?null:ie(a),u=ie(r);if(l===null||u===null)return r;for(let d=1;d<1/el;d+=1){let c=d*el,p=i((y,m)=>Math.round(y+(m-y)*c),"mix"),f=dt(p(l.r,u.r),p(l.g,u.g),p(l.b,u.b));if(s(f))return f}return r}i(Je,"pushToContrast");function ol(e,t,r){let n=e/255,o=t/255,s=r/255,a=Math.max(n,o,s),l=Math.min(n,o,s),u=(a+l)/2;if(a===l)return {h:0,s:0,l:u};let d=a-l,c=d/(1-Math.abs(2*u-1)),p;return a===n?(p=(o-s)/d*60,p<0&&(p=p+360)):a===o?p=((s-n)/d+2)*60:p=((n-o)/d+4)*60,{h:p,s:c,l:u}}i(ol,"rgbToHsl");function Ao(e){let{h:t,s:r,l:n}=e,o=(1-Math.abs(2*n-1))*r,s=t/60,a=o*(1-Math.abs(s%2-1)),l=n-o/2,u=Math.floor(s)%6,d=[[o,a,0],[a,o,0],[0,o,a],[0,a,o],[a,0,o],[o,0,a]],[c,p,f]=d[u];return {r:wo(c+l),g:wo(p+l),b:wo(f+l)}}i(Ao,"hslToRgb");function wo(e){return Math.min(255,Math.max(0,Math.floor(e*255+.5)))}i(wo,"channel");function je(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.keys(e))je(e[t]);}return e}i(je,"deepFreeze");var tn=Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3}),sl={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},al={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},il={nano:8,small:9,micro:10,tiny:11,caption:12,bodyTight:13,body:14,subtitle:16,heading:18,verdict:24},zy={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},jy={regular:"400",medium:"500",bold:"700"},Wy={eyebrow:1,monoWide:.9,headerBrand:-0.42,tight:-0.35},Oo=0,pt="System",Ne="monospace",Gy=["content","heading","control","compact","badge"];function Ky(e){let t={};for(let r of Gy)t[r]=e;return t}i(Ky,"authoredTierSizes");function ll(){return {family:pt,mono:Ne,fontUrl:null,families:{regular:pt,medium:pt,bold:pt,mono:Ne,monoMedium:Ne,monoBold:Ne},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:il,tierSizes:Ky(il),lineHeight:zy,weight:jy,letterSpacing:Wy,scale:1,maxScale:Oo,scaleCaps:tn}}i(ll,"baseType");var ul={},ft=Object.freeze({standard:Object.freeze([.2,0,0,1]),emphasized:Object.freeze([.2,.8,.2,1]),exit:Object.freeze([.4,0,1,1])});function en(e){return `cubic-bezier(${e.join(", ")})`}i(en,"cssCubicBezier");var dl={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:en(ft.standard),emphasized:en(ft.emphasized),exit:en(ft.exit)},reducedMotion:false},qy={brand:"#10462E",brandSoft:"rgba(16,70,46,0.10)",brandSofter:"rgba(16,70,46,0.15)",brandBorder:"rgba(16,70,46,0.18)",borderHairlineGreen:"rgba(16,70,46,0.25)",brandBorderStrong:"rgba(16,70,46,0.55)",brandInk:"#10462E",linkInk:"#10462E",surface:"#FFFFFF",surfaceCream:"#FDFBF8",surfaceSubtle:"#EFE9E3",background:"#FFFFFF",borderRingCream:"#D8D2C8",chatGround:"#FFFFFF",composerFill:"#FDFBF8",composerBorder:"rgba(16,70,46,0.75)",shadow:"#0B3421",text:{primary:"#111111",secondary:"#0E462E",muted:"#6E6660",placeholder:"rgba(61,61,61,0.75)",onBrand:"#FFFFFF",metaCool:"#3D3D3D",timestamp:"rgba(61,61,61,0.75)"},primary:"#10462E",onPrimary:"#FFFFFF",accent:"#10462E",onAccent:"#FFFFFF",accentEdge:"#07C168",success:"#07C168",danger:"#B91C1C",errorRed:"#FF1B00",warningStrong:"#A45610",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.12)",badgeBgCaution:"rgba(217,130,29,0.14)",badgeBgCritical:"rgba(185,28,28,0.12)",badgeBgNeutral:"rgba(110,102,96,0.12)",bubbleUser:"#10462E",bubbleAssistant:"#FFFFFF",skeleton:"#EFE9E3",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)"},mt=je({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:qy,space:sl,radius:al,type:ll(),motion:dl,slots:ul}),$y={brand:"#6BD39A",brandSoft:"rgba(107,211,154,0.12)",brandSofter:"rgba(107,211,154,0.18)",brandBorder:"rgba(107,211,154,0.22)",borderHairlineGreen:"rgba(107,211,154,0.28)",brandBorderStrong:"rgba(107,211,154,0.55)",brandInk:"#6BD39A",linkInk:"#6BD39A",surface:"#1C1F23",surfaceCream:"#23272C",surfaceSubtle:"#23272C",background:"#15171A",borderRingCream:"#3A3F45",chatGround:"#1C1F23",composerFill:"#23272C",composerBorder:"rgba(107,211,154,0.75)",shadow:"#000000",text:{primary:"#F5F3F0",secondary:"#A9E4C4",muted:"#9A938C",placeholder:"rgba(255,255,255,0.55)",onBrand:"#0E1F17",metaCool:"#C9C9C9",timestamp:"rgba(245,243,240,0.7)"},primary:"#6BD39A",onPrimary:"#0E1F17",accent:"#6BD39A",onAccent:"#0E1F17",accentEdge:"#34D888",success:"#07C168",danger:"#F87171",errorRed:"#FF6B5B",warningStrong:"#F0A35E",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.18)",badgeBgCaution:"rgba(217,130,29,0.20)",badgeBgCritical:"rgba(185,28,28,0.22)",badgeBgNeutral:"rgba(255,255,255,0.10)",bubbleUser:"#6BD39A",bubbleAssistant:"#1C1F23",skeleton:"#23272C",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)"},rn=je({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:$y,space:sl,radius:al,type:ll(),motion:dl,slots:ul});var Yy="#23272C",cl=4.5,Xy=.6,Fo=.9,Qy=.02,Zy="#FFFFFF",Jy="#111111";function eg(e){return ue(e,Yy)>=cl&&Math.max(ue(e,Zy),ue(e,Jy))>=cl}i(eg,"readsOnDark");function ml(e){let t=ie(e);if(t===null)return null;let{h:r,s:n,l:o}=ol(t.r,t.g,t.b),s=Math.min(Math.max(o,Xy),Fo);for(let l=0;;l+=1){let u=s+l*Qy;if(u>Fo)break;let d=Ao({h:r,s:n,l:u}),c=dt(d.r,d.g,d.b);if(eg(c))return c}let a=Ao({h:r,s:n,l:Fo});return dt(a.r,a.g,a.b)}i(ml,"deriveDarkVariant");var tg=7,pl=.05,rg="#000000",ng="#FFFFFF";function og(e,t,r,n){let o=ct(e,t);if(o===null)return r;if(ue(o,t)>=n)return o;let s=ie(o),a=ie(r);if(s===null||a===null)return r;for(let l=1;l<1/pl;l+=1){let u=l*pl,d=i((p,f)=>Math.round(p+(f-p)*u),"mix"),c=dt(d(s.r,a.r),d(s.g,a.g),d(s.b,a.b));if(ue(c,t)>=n)return c}return r}i(og,"pushContrast");function ig(e,t){let r=[e.surface,e.surfaceCream,e.surfaceSubtle,e.background,e.chatGround,e.composerFill],n=r[0],o=fl(n);for(let s of r){let a=fl(s);(t?a>o:a<o)&&(n=s,o=a);}return n}i(ig,"hardestGround");function fl(e){let t=ie(e);return t===null?0:ut(t)}i(fl,"luminanceOf");function et(e,t){return ct(e,t)??ye(e)??t}i(et,"solid");function yl(e){let t=e.color,r=e.brightness==="dark",n=r?ng:rg,o=ig(t,r),s=i(l=>og(l,o,n,tg),"text"),a={...t,brandSoft:et(t.brandSoft,t.surface),brandSofter:et(t.brandSofter,t.surface),brandBorder:s(t.brandBorder),borderHairlineGreen:s(t.borderHairlineGreen),brandBorderStrong:s(t.brandBorderStrong),brandInk:s(t.brandInk),linkInk:s(t.linkInk),borderRingCream:s(t.borderRingCream),composerBorder:s(t.composerBorder),text:{primary:s(t.text.primary),secondary:s(t.text.secondary),muted:s(t.text.muted),placeholder:s(t.text.placeholder),onBrand:t.text.onBrand,metaCool:s(t.text.metaCool),timestamp:s(t.text.timestamp)},badgeBgPositive:et(t.badgeBgPositive,t.surface),badgeBgCaution:et(t.badgeBgCaution,t.surface),badgeBgCritical:et(t.badgeBgCritical,t.surface),badgeBgNeutral:et(t.badgeBgNeutral,t.surface),checkupCardLowRiskBg:et(t.checkupCardLowRiskBg,t.surface),checkupCardConcernBg:et(t.checkupCardConcernBg,t.surface)};return je({...e,highContrast:true,color:a})}i(yl,"deriveHighContrast");var yt=Object.freeze(["composerInput","sendButton","userBubble","assistantBubble","recordCard","vetVisitButton","primaryButton","link"]),sg=Object.freeze(["backgroundColor","borderColor","borderRadius","textColor"]),we=4.5,ag=Object.freeze({});function lg(e){return yt.includes(e)}i(lg,"isSlotName");function ug(e){let t=typeof e=="number"?e:typeof e=="string"?Number(e.trim()):Number.NaN;return Number.isFinite(t)?Math.max(0,t):null}i(ug,"parseRadius");function gl(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t={},r=false;for(let[n,o]of Object.entries(e)){if(!lg(n)||o===null||typeof o!="object")continue;let s=dg(o);s!==null&&(t[n]=s,r=true);}return r?Object.freeze(t):null}i(gl,"parseThemeSlots");function nn(e,t,r){return e[t]!==void 0?e[t]:e[r]}i(nn,"pick");function dg(e){let t={},r=ye(nn(e,"background_color","backgroundColor"));r!==null&&(t.backgroundColor=r);let n=ye(nn(e,"border_color","borderColor"));n!==null&&(t.borderColor=n);let o=ug(nn(e,"border_radius","borderRadius"));o!==null&&(t.borderRadius=o);let s=ye(nn(e,"text_color","textColor"));return s!==null&&(t.textColor=s),Object.keys(t).length===0?null:Object.freeze(t)}i(dg,"parseSlot");function hl(e,t){return t===null||Object.keys(t).length===0?e??ag:e===null||Object.keys(e).length===0?t:Object.freeze({...e,...t})}i(hl,"mergeThemeSlots");var Mo=3;function cg(e,t){return e===void 0?t:t.length===0?[e]:t.map(r=>ct(e,r)??r)}i(cg,"seatsOf");function pg(e,t){let r=mr(e);return e.every(n=>ue(r,n)>=t)}i(pg,"someInkReads");function fg(e,t){let r=t[0];return r===void 0?null:ct(e,r)}i(fg,"collapseUnsatisfiableFill");function mg(e){let t=fr(e[0],we);return e.every(r=>ue(t,r)>=we)?t:mr(e)}i(mg,"inkFor");function bl(e,t){let r=false,n={};for(let o of yt){let s=e[o];if(s===void 0)continue;let a=s.backgroundColor,l=t?.[o]??[],u=cg(a,l),d={...s},c=false;if(a!==void 0&&u.length>1&&!pg(u,we)){let p=fg(a,l);p!==null&&(d.backgroundColor=p,u=[p],c=true);}if(u.length>0){let p=s.textColor;if(a!==void 0)(p===void 0||u.some(f=>ue(p,f)<we))&&(d.textColor=mg(u),c=true);else if(p!==void 0){let f=Je(p,u,mr(u),we);f!==p&&(d.textColor=f,c=true);}if(s.borderColor!==void 0){let f=Je(s.borderColor,u,mr(u),Mo);f!==s.borderColor&&(d.borderColor=f,c=true);}}n[o]=c?Object.freeze(d):s,r=r||c;}return r?Object.freeze(n):e}i(bl,"guardSlotContrast");var Cl=Object.freeze(["display_name","logo_url","logo_url_dark","primary_color","accent_color","primary_color_dark","accent_color_dark","brightness","color_scheme","font_family","font_url","fonts","font_urls","chat_placeholder","surface_style","radius_scale","accessibility_max_font_scale","slots"]),yr="slots.",Rl=Object.freeze([1,2]);function on(e){return Object.keys(e).every(t=>t==="schemaVersion"||(e[t]??null)===null)}i(on,"isEmptyBranding");function Sl(e){let t=e?.schemaVersion??null;return t===null||Rl.includes(t)}i(Sl,"isKnownBrandingSchema");function Tl(e){return new Set(["hide_powered_by",...e?.lockedFields??[]])}i(Tl,"lockedFieldsOf");function yg(e){return e==="hide_powered_by"||Cl.includes(e)?true:e.startsWith(yr)&&yt.includes(e.slice(yr.length))}i(yg,"isThemeLockName");function We(e){if(e===null||typeof e!="object")return null;let t=e,r={displayName:gt($(t,"display_name","displayName")),logoUrl:gt($(t,"logo_url","logoUrl")),primaryColor:ye($(t,"primary_color","primaryColor")),accentColor:ye($(t,"accent_color","accentColor")),brightness:vg($(t,"brightness","color_scheme","colorScheme")),fontFamily:gt($(t,"font_family","fontFamily")),fontUrl:gt($(t,"font_url","fontUrl")),fonts:vl($(t,"fonts")),fontUrls:vl($(t,"font_urls","fontUrls")),placeholder:gt($(t,"chat_placeholder","placeholder","chatPlaceholder")),hidePoweredBy:gg($(t,"hide_powered_by","hidePoweredBy")),primaryColorDark:ye($(t,"primary_color_dark","primaryColorDark")),accentColorDark:ye($(t,"accent_color_dark","accentColorDark")),surfaceStyle:El($(t,"surface_style","surfaceStyle"),hg),radiusScale:El($(t,"radius_scale","radiusScale"),bg),logoUrlDark:gt($(t,"logo_url_dark","logoUrlDark")),slots:gl($(t,"slots")),accessibilityMaxFontScale:Cg($(t,"accessibility_max_font_scale","accessibilityMaxFontScale")),lockedFields:Sg($(t,"locked_fields","lockedFields")),schemaVersion:Rg($(t,"schema_version","schemaVersion"))};return on(r)?null:Object.freeze(r)}i(We,"parseClientBranding");function gg(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true")return true;if(t==="false")return false}return null}i(gg,"parseBool");function $(e,...t){for(let r of t)if(Object.prototype.hasOwnProperty.call(e,r)){let n=e[r];if(n!==void 0)return n}}i($,"pick");function gt(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}i(gt,"parseNonEmptyString");var gr=["regular","medium","bold","mono","monoMedium","monoBold"];function vl(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let n of gr){let o=gt($(t,n));o!==null&&(r[n]=o);}return Object.keys(r).length===0?null:Object.freeze(r)}i(vl,"parseFaceMap");var hg=["white","cream","subtle"],bg=["sharp","default","round"];function El(e,t){if(typeof e!="string")return null;let r=e.trim().toLowerCase();return t.includes(r)?r:null}i(El,"parseEnum");function vg(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t==="light"||t==="dark"||t==="auto"?t:null}i(vg,"parseBrightness");function Pl(e){let t=typeof e=="number"?e:typeof e=="string"?Number(e.trim()):Number.NaN;return Number.isFinite(t)&&(typeof e!="string"||e.trim().length>0)?t:null}i(Pl,"parseNumber");var Eg=1,kl=3.1;function Cg(e){let t=Pl(e);return t===null?null:t<=0?0:Math.min(kl,Math.max(Eg,t))}i(Cg,"parseMaxFontScale");function Rg(e){if(e==null)return null;let t=Pl(e);return t!==null&&Number.isInteger(t)&&t>=1?t:0}i(Rg,"parseSchemaVersion");function Lo(e){let t=e.trim();return t.startsWith(yr)?t:t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase()}i(Lo,"toWireName");function Sg(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(typeof r!="string")continue;let n=Lo(r);yg(n)&&!t.includes(n)&&t.push(n);}return t.length===0?null:Object.freeze(t)}i(Sg,"parseLockedFields");function Do(e){if(e===null)return null;let t=e.trim();return t.length===0?null:/^https:\/\/\S+$/i.test(t)?t:null}i(Do,"hardenHttpsUrl");function xl(e,t){if(t===null||on(t))return e;let r=(t.brightness==="light"||t.brightness==="dark")&&t.brightness!==e.brightness?t.brightness==="dark"?rn:mt:e,n=r.brightness==="dark"?rn:mt,o=r.brightness==="dark",s=o?t.primaryColorDark??_l(t.primaryColor):t.primaryColor,a=o?t.accentColorDark??_l(t.accentColor):t.accentColor,l=s??r.color.primary,u=a??r.color.accent,d=s!==null&&_g(t,l,n,o),c=d?n.color.primary:l,p=s!==null&&!d?ie(c):null,f=i(w=>Math.round(w+(255-w)*.4),"lift"),y=p!==null?{brand:c,bubbleUser:c,brandInk:c,text:{...r.color.text,secondary:c},brandSoft:`rgba(${p.r}, ${p.g}, ${p.b}, 0.10)`,brandSofter:`rgba(${p.r}, ${p.g}, ${p.b}, 0.15)`,brandBorder:`rgba(${p.r}, ${p.g}, ${p.b}, 0.20)`,borderHairlineGreen:`rgba(${p.r}, ${p.g}, ${p.b}, 0.28)`,brandBorderStrong:`rgba(${p.r}, ${p.g}, ${p.b}, 0.55)`,composerBorder:`rgba(${p.r}, ${p.g}, ${p.b}, 0.75)`,accentEdge:`rgb(${f(p.r)}, ${f(p.g)}, ${f(p.b)})`}:d?wg(n,r.color.text):{},m={brightness:r.brightness,highContrast:r.highContrast,meta:{displayName:t.displayName??r.meta.displayName,logoUrl:(o?t.logoUrlDark??t.logoUrl:t.logoUrl)??r.meta.logoUrl,placeholder:t.placeholder??r.meta.placeholder,hidePoweredBy:t.hidePoweredBy??r.meta.hidePoweredBy},color:{...r.color,...y,...xg(t.surfaceStyle??null,n),primary:c,accent:u,onPrimary:r.color.onPrimary,onAccent:r.color.onAccent},space:r.space,radius:Ag(t.radiusScale??null,r.radius,n),type:{...r.type,...kg(r.type,t),maxScale:t.accessibilityMaxFontScale??r.type.maxScale},motion:r.motion,slots:hl(r.slots,t.slots??null)};return je(m)}i(xl,"withServerBranding");var Tg={regular:["regular"],medium:["medium","regular"],bold:["bold","medium","regular"],mono:["mono"],monoMedium:["monoMedium","mono"],monoBold:["monoBold","monoMedium","mono"]},Pg=[["regular","medium","bold"],["mono","monoMedium","monoBold"]];function No(e){return e==="mono"||e==="monoMedium"||e==="monoBold"}i(No,"isMonoFace");function kg(e,t){let r=t.fonts??{},n=t.fontUrls??{},o={...e.families},s={...e.namedFaces},a={...e.fontUrls};for(let l of gr){let u=Tg[l].map(p=>r[p]).find(p=>p!==void 0),d=No(l)?null:t.fontFamily;u!==void 0?(o[l]=u,s[l]=true):d!==null&&(o[l]=d,s[l]=false);let c=n[l]??(l==="regular"?t.fontUrl:null)??null;c!==null?a[l]=c:u!==void 0&&delete a[l];}for(let l of Pg)for(let u of l)s[u]&&l.some(d=>d!==u&&o[d]===o[u])&&(s[u]=false);return {family:o.regular,mono:o.mono,fontUrl:a.regular??null,families:o,namedFaces:s,fontUrls:a}}i(kg,"mergeFaces");function _l(e){return e===null?null:ml(e)}i(_l,"darkVariantOf");function xg(e,t){if(e===null)return {};let r=t.color;return {chatGround:e==="white"?r.surface:e==="subtle"?r.surfaceSubtle:r.surfaceCream}}i(xg,"surfaceOf");function wl(e,t){return e==null?false:ye(e)===ye(t)}i(wl,"sameColor");function _g(e,t,r,n){return wl(t,r.color.primary)?true:n&&(e.primaryColorDark??null)===null&&wl(e.primaryColor,mt.color.primary)}i(_g,"isCompiledPrimary");function wg(e,t){let r=e.color;return {text:{...t,secondary:r.text.secondary},brand:r.brand,bubbleUser:r.bubbleUser,brandInk:r.brandInk,brandSoft:r.brandSoft,brandSofter:r.brandSofter,brandBorder:r.brandBorder,borderHairlineGreen:r.borderHairlineGreen,brandBorderStrong:r.brandBorderStrong,composerBorder:r.composerBorder,accentEdge:r.accentEdge}}i(wg,"compiledBrandFamily");var Ig={sharp:.5,default:1,round:1.5};function Ag(e,t,r){if(e===null)return t;let n=Ig[e],o=r.radius,s=i(a=>Math.round(a*n),"s");return {tile:s(o.tile),xs:s(o.xs),sm:s(o.sm),md:s(o.md),lg:s(o.lg),xl:s(o.xl),pill:o.pill}}i(Ag,"radiusOf");var Og="Everfur",Fg=.5;function Uo(e){let t=e?.branding??null,r=Sl(t)?t:null,n=Ug(e?.clientOverride??null,Tl(r)),o=e?.colorScheme==="dark"?"dark":"light",s=n?.brightness??r?.brightness??"light",u=xl((s==="auto"?o:s)==="dark"?rn:mt,Il(r)),d=xl(u,Il(n));return Xg(d,e)}i(Uo,"resolveTheme");function Mg(e,t,r){return Uo({...r,branding:We(t),clientOverride:We(e)})}i(Mg,"previewTheme");function Lg(e){return e==="placeholder"?"chat_placeholder":Lo(e)}i(Lg,"wireNameOf");var Dg={brightness:["color_scheme"],fontUrl:["font_family"],fonts:["font_family"],fontUrls:["font_url","font_family"],primaryColorDark:["primary_color"],accentColorDark:["accent_color"],logoUrlDark:["logo_url"]};function Ng(e,t){return t.has(Lg(e))?true:(Dg[e]??[]).some(r=>t.has(r))}i(Ng,"isLocked");function Ug(e,t){if(e===null)return null;let r=false,n={...e};for(let a of Object.keys(e))(e[a]??null)!==null&&(Ng(a,t)||a==="lockedFields")&&(n[a]=null,r=true);let o=n.slots??null;if(o!==null){let a={},l=false;for(let u of yt){let d=o[u];d!==void 0&&(t.has(`${yr}${u}`)?l=true:a[u]=d);}l&&(n.slots=Object.keys(a).length===0?null:Object.freeze(a),r=true);}if(!r)return e;let s=Object.freeze(n);return on(s)?null:s}i(Ug,"withoutFields");function Il(e){return e===null||e.brightness===null?e:Object.freeze({...e,brightness:null})}i(Il,"withoutBrightness");function Vg(e,t){if(t===1)return e;let r={};for(let[n,o]of Object.entries(e))r[n]=Math.round(o*t*10)/10;return r}i(Vg,"scaledSizes");function Hg(e){return e===void 0||!Number.isFinite(e)?1:Math.max(Fg,e)}i(Hg,"effectiveScale");var Al=["content","heading","control","compact","badge"];function Bg(e){if(!(e>0))return tn;let t={};for(let r of Al){let n=tn[r];t[r]=n===0?0:Math.min(n,e);}return t}i(Bg,"tierCaps");function zg(e,t){return t>0?Math.min(e,t):e}i(zg,"capped");function jg(e,t,r,n){let o={};for(let s of Al)o[s]=n?Vg(e,zg(t,r[s])):e;return o}i(jg,"sizesByTier");function Wg(e){return e==="dark"?"#FFFFFF":"#000000"}i(Wg,"inkPole");function Gg(e){return [e.surface,e.surfaceCream,e.surfaceSubtle,e.background,e.chatGround,e.composerFill]}i(Gg,"textGrounds");function Kg(e){return [e.surface,e.surfaceCream,e.background,e.chatGround,e.composerFill]}i(Kg,"controlGrounds");function Ol(e){return [e.chatGround,e.surface,e.surfaceCream]}i(Ol,"linkGrounds");function qg(e){return {composerInput:[e.composerFill],sendButton:[e.composerFill],userBubble:[e.bubbleUser],assistantBubble:[e.chatGround,e.surfaceCream],recordCard:[e.surface],vetVisitButton:[e.primary],primaryButton:[e.brand],link:Ol(e)}}i(qg,"slotGrounds");function $g(e,t){try{let r=e(t);return r===!0||r===!1?r:null}catch{return null}}i($g,"registration");function Yg(e,t){let r=t?.isFontRegistered,n=t?.platformMonoFamily?.trim()||null;if(r===void 0&&n===null)return {family:e.family,mono:e.mono,families:e.families,namedFaces:e.namedFaces};let o={...e.families},s={...e.namedFaces};for(let a of gr)!(o[a]===pt||o[a]===Ne)&&r!==void 0&&$g(r,o[a])===false&&(o[a]=No(a)?Ne:pt,s[a]=false),n!==null&&No(a)&&o[a]===Ne&&(o[a]=n);return {family:o.regular,mono:o.mono,families:o,namedFaces:s}}i(Yg,"platformFaces");function Xg(e,t){let r=e.color.primary,n=e.color.accent,o=e.meta.displayName.trim().length===0?Og:e.meta.displayName,s=Do(e.meta.logoUrl),a={};for(let P of gr){let x=e.type.fontUrls[P];x!==void 0&&(a[P]=Do(x));}let l=a.regular??null,d=t?.reducedMotion===true?{duration:{instant:0,fast:0,normal:0,slow:0},spring:{gentle:{damping:100,stiffness:1e3}},easing:e.motion.easing,reducedMotion:true}:e.motion,c=Number.isFinite(e.type.maxScale)?e.type.maxScale:Oo,p=Hg(t?.textScale),f=Bg(c),y=jg(e.type.size,p,f,t?.scaleTypeSizes===true),m=e.color,w=Wg(e.brightness),b=Gg(m),R={...m,primary:r,accent:n,onPrimary:fr(r,we),onAccent:fr(n,we),brandInk:Je(m.brandInk,b,w,we),linkInk:Je(e.slots.link?.textColor??n,Ol(m),w,we),text:{...m.text,secondary:Je(m.text.secondary,b,w,we)},brandBorderStrong:Je(m.brandBorderStrong,Kg(m),w,Mo)},I={brightness:e.brightness,highContrast:false,meta:{displayName:o,logoUrl:s,placeholder:e.meta.placeholder,hidePoweredBy:e.meta.hidePoweredBy},color:R,space:e.space,radius:e.radius,type:{...e.type,...Yg(e.type,t),fontUrl:l,fontUrls:a,size:y.content,tierSizes:y,scale:p,maxScale:c,scaleCaps:f},motion:d,slots:bl(e.slots,qg(R))};return t?.highContrast===true?yl(je(I)):je(I)}i(Xg,"finalize");var Fl="/widget/v1/entitlements",Qg=304,Zg=Object.freeze({kind:"notModified"});async function Ll(e,t={},r=xe({auth:e})){let n=await r.send("entitlements.fetch",eh(t));return n.ok?th(n.value):n.error.httpStatus===Qg?Zg:{kind:"failed",error:n.error}}i(Ll,"fetchEntitlements");var Jg=64;function eh(e){let t={};return Vo(e.cachedRevision)&&(t["if-none-match"]=`"${e.cachedRevision}"`),e.region&&e.region.length<=Jg?{method:"GET",path:Fl,headers:t,query:{region:e.region}}:{method:"GET",path:Fl,headers:t}}i(eh,"buildRequest");function th(e){if(e===null||typeof e!="object"||!Vo(e.revision))return Ml();let t=typeof e.region=="string"?e.region:"",r=Vo(e.ttl_seconds)?e.ttl_seconds:0;return Object.freeze({kind:"updated",revision:e.revision,region:t,ttlSeconds:r,decisions:nh(e.capabilities),branding:rh(e)})}i(th,"parseUpdated");function rh(e){let t=We(e.branding);if(t!==null)return t;let r=e.render_hints;if(r!==null&&typeof r=="object"){let n=We(r.branding);return n!==null?n:We(r)}return null}i(rh,"parseBranding");function nh(e){if(e===null||typeof e!="object")return Object.freeze([]);let t=[];for(let[r,n]of Object.entries(e))oh(n)&&t.push(Object.freeze({resource:r,granted:true}));return Object.freeze(t)}i(nh,"mapCapabilities");function oh(e){return typeof e=="object"&&e!==null&&e.enabled===true}i(oh,"isEnabled");function Ml(){return {kind:"failed",error:D("internalError",{retryable:true,wireMessage:"malformed entitlements response"})}}i(Ml,"malformed");function Vo(e){return typeof e=="number"&&Number.isFinite(e)}i(Vo,"isFiniteNumber");var ih=30;function Dl(e){let t=e.scheduler??sh,r=e.resolve??Ll,n=Math.max(1,e.floorSeconds??ih),o=e.rng??Math.random,s=i(()=>n+o()*n,"jitteredFloorSeconds"),a=false,l=false,u=null,d=null,c=n,p=0,f=i(()=>{u!==null&&(t.clear(u),u=null);},"clearTimer"),y=i(R=>{l||!a||(c=Math.max(n,R),u=t.set(()=>{u=null,b();},c*1e3));},"schedule"),m=null,w=i(async()=>{if(l)return null;let R=p;e.onFetch?.();let I=e.region?{cachedRevision:d,region:e.region}:{cachedRevision:d},P;try{P=await r(e.authFor(),I);}catch(x){return e.telemetry?.track("sdk.entitlements.poll_error",{reason:ah(x)}),!l&&R===p&&(e.onSettled?.(),y(s())),null}if(l||R!==p)return null;switch(P.kind){case "updated":d=P.revision,e.update(P.decisions,P.branding??null),y(P.ttlSeconds);break;case "notModified":y(c);break;case "failed":e.telemetry?.track("sdk.entitlements.poll_failed",{code:P.error.code}),y(s());break;default:y(s());}return e.onSettled?.(),P},"tick"),b=i(()=>{let R=w().finally(()=>{m===R&&(m=null);});return m=R,R},"run");return {start(){a||l||(a=true,b());},prime(){return l?Promise.resolve(null):m??b()},stop(){l||(l=true,p++,f());},refresh(){l||!a||(p++,d=null,f(),b());}}}i(Dl,"createEntitlementPoller");var sh={set(e,t){let r=setTimeout(e,t);return r.unref?.(),r},clear(e){clearTimeout(e);}};function ah(e){return e instanceof Error?e.message:"poll failed"}i(ah,"describe");var Nl="everfur.notifications.device";var lh=3e3,Ul=Object.freeze([Nl]);function Vl(e){let{leaving:t,identity:r,hooks:n,telemetry:o}=e;if(t===null||r===null||n.size===0)return null;let s=Object.freeze({userRef:t.userRef,auth:e.graceAuth()}),a=[...n].map(d=>{try{return Promise.resolve(d(s))}catch(c){return Promise.reject(c)}}),l=i((d,c)=>{try{o.track("sdk.logout.hookFailed",{reason:d,count:c,totalCount:a.length});}catch{}},"report"),u=Promise.allSettled(a).then(d=>{let c=d.filter(p=>p.status==="rejected").length;c>0&&l("failed",c);});return new Promise(d=>{let c=false,p=i(()=>{c||(c=true,clearTimeout(f),d());},"finish"),f=setTimeout(()=>{c||l("timeout",a.length),p();},lh);u.then(p,p);})}i(Vl,"startBeforeLogoutHooks");function Hl(e){let{leaving:t,identity:r,transport:n,sessionId:o}=e,s=r.currentToken();s.catch(()=>{});let a={userRef:t.userRef,currentToken:i(()=>s,"currentToken"),hasToken:i(()=>true,"hasToken"),clear:i(()=>{},"clear")};return {mode:"personalized",transport:n,identity:a,userRef:t.userRef,sessionId:o}}i(Hl,"graceAuth");async function Bl(e,t){if(Ul.length===0)return;let r=await Promise.allSettled(Ul.map(o=>e.removeItem(o))),n=r.filter(o=>o.status==="rejected").length;n>0&&t.track("sdk.logout.sweepPartialFailure",{failedCount:n,totalCount:r.length});}i(Bl,"sweepPerUserKv");function uh(){return Object.freeze([Object.freeze({resource:"chat.message.create",granted:true})])}i(uh,"compiledDefaultDecisions");function Ho(e=uh){let t=new Set,r=Object.freeze({decisions:e(),isPending:false,branding:null}),n=i(()=>{for(let o of t)o();},"emit");return {subscribe(o){return t.add(o),()=>{t.delete(o);}},getSnapshot(){return r},set(o){r=Object.freeze({decisions:Object.freeze([...o.decisions]),isPending:o.isPending,branding:o.branding??null}),n();},reset(){r=Object.freeze({decisions:e(),isPending:false,branding:null}),n();},setPending(o){r.isPending!==o&&(r=Object.freeze({...r,isPending:o}),n());}}}i(Ho,"createEntitlementStore");function Bo(e){return D("validationFailed",{retryable:false,wireMessage:`Everfur SDK is not configured: ${e.message}`})}i(Bo,"notConfiguredError");function zl(e,t){let r={publishableKey:e.publishableKey,...e.apiBaseUrl!==void 0?{apiBaseUrl:e.apiBaseUrl}:{},...e.contractVersion!==void 0?{contractVersion:e.contractVersion}:{},...e.debug!==void 0?{debug:e.debug}:{}};return As(r,t===void 0?void 0:{platform:t})}i(zl,"tryResolveClient");function jl(e){return Object.freeze({track(t,r){try{e.track(t,r);}catch{}},trackExpectedFailure(t,r){try{e.trackExpectedFailure(t,r);}catch{}}})}i(jl,"guardTelemetry");function Wl(e,t){try{t.trackExpectedFailure("sdk.config.invalid",{reason:e.reason});}catch{}globalThis.console?.error?.(`[everfur] SDK disabled: ${e.message}
|
|
12
|
-
[everfur] Every Everfur capability will render its off-state until this is fixed. If the value is set in your environment, note that babel-preset-expo inlines only EXPO_PUBLIC_* variables into a release bundle.`);}i(Wl,"reportConfigFailure");function zo(e){return Object.freeze({request(){return Promise.resolve(v(Bo(e)))},stream(t,r){let n=pe({code:"sdk_not_configured",retryable:false,wireMessage:`Everfur SDK is not configured: ${e.message}`,synthesized:true,lastEventId:null});return {async*[Symbol.asyncIterator](){r.aborted||(yield n);}}}})}i(zo,"refusingTransport");function Gl(){let e=new Map;return {async getItem(t){return e.get(t)??null},async setItem(t,r){e.set(t,r);},async removeItem(t){e.delete(t);},async keys(t){return [...e.keys()].filter(r=>r.startsWith(t))}}}i(Gl,"createInMemoryKv");var Kl=Object.freeze({clearMemoryCache(){},clearDiskCache(){}});function Yl(e,t){return new Wo(e,t)}i(Yl,"createEverfurRuntime");var dh=6e4,Go=class Go{constructor(t,r){this.sessionId=$n();this.entries=new Map;this.destroyers=new Map;this.epoch=0;this.disposed=false;this.verdictSettled=false;this.refreshTimer=null;this.bootstraps=new WeakMap;this.prepared=null;this.beforeLogoutHooks=new Set;this.pendingBeforeLogout=null;this.leavingSessionId=null;let n=t.config;if(n.secureStore!==void 0&&n.secureStore.isAvailable===true)throw new Q("invalid-argument","config.secureStore is not yet consumable: SDK token persistence is unimplemented. Omit secureStore to keep memory-only tokens (SPEC-10 \xA75.3).");this.telemetry=n.telemetry?jl(n.telemetry):Hr;let o=typeof n?.publishableKey=="string"?n.publishableKey.trim():"",s=Xn(n?.publishableKey),a=n.transport!==void 0,l,u=typeof n.apiBaseUrl=="string"&&n.apiBaseUrl.trim().length>0?n.apiBaseUrl.trim():null;if(s!==null)l=zo(s);else if(n.transport!==void 0)l=n.transport;else {let c=zl(n,r?.platform);c.ok?(u=c.config.apiBaseUrl,l=Ns({config:c.config,...r?.eventSourceFactory?{eventSourceFactory:r.eventSourceFactory}:{}})):(s=c.failure,l=zo(c.failure));}this.configFailure=s,this.publishableKey=s===null?o:"",this.transport=l,s!==null&&Wl(s,this.telemetry),this.errorPolicy=n.errorPolicy,this.camera=n.camera??gs,this.upload=n.upload??ta,this.uploadTransport=n.uploadTransport??go,this.imageCache=n.imageCache??Kl,this.kv=n.storage??Gl(),this.currentUser=t.user??null,this.identity=this.buildIdentity(t.user??null),this.activePet=t.activePet,this.store=s===null?Ho():Ho(()=>Qa("sdk_config",Ft("accessDenied"))),this.services={authFor:i(c=>this.buildAuth(c),"authFor"),telemetry:this.telemetry,errorPolicy:this.errorPolicy,camera:this.camera,upload:this.upload,uploadTransport:this.uploadTransport,imageCache:this.imageCache,kv:this.kv,apiBaseUrl:u},this.registry={services:this.services,acquireChat:i(c=>this.acquireInternal("chat",jo(c),()=>this.buildChatController(c),ql),"acquireChat"),releaseChat:i(c=>this.releaseInternal(c),"releaseChat"),peekChat:i(c=>this.entries.get(`${this.epoch}|chat|${jo(c)}`)?.controller??null,"peekChat"),acquire:i((c,p,f,y)=>this.acquireInternal(c,p,f,y),"acquire"),release:i(c=>this.releaseInternal(c),"release")},this.entitlements=this.store;let d=s===null&&(r?.startEntitlementPolling??!a);this.poller=s===null?this.buildPoller(r?.pollScheduler):null,d&&this.poller?.start();}get isDisposed(){return this.disposed}get scopeEpoch(){return this.epoch}buildIdentity(t){if(t===null)return null;let r=Ts(t.userRef,t.getToken,n=>this.armTokenRefresh(r,n));return r}armTokenRefresh(t,r){if(this.clearTokenRefresh(),r===null||this.disposed||t!==this.identity)return;let n=r-Date.now();if(n<=0)return;let o=Math.max(n-dh,n/2);this.refreshTimer=setTimeout(()=>{this.refreshTimer=null,!(this.disposed||t!==this.identity)&&t.currentToken({forceRefresh:true}).catch(()=>{});},o),this.refreshTimer.unref?.();}clearTokenRefresh(){this.refreshTimer!==null&&clearTimeout(this.refreshTimer),this.refreshTimer=null;}buildPoller(t){return Dl({authFor:i(()=>this.buildAuth(this.currentUser?.userRef??null),"authFor"),update:i((r,n)=>this.updateEntitlements({decisions:r,isPending:false,branding:n}),"update"),onFetch:i(()=>{this.verdictSettled||this.store.setPending(true);},"onFetch"),onSettled:i(()=>{this.verdictSettled=true,this.store.setPending(false);},"onSettled"),telemetry:this.telemetry,...t?{scheduler:t}:{}})}acquireInternal(t,r,n,o,s=false){let a=`${this.epoch}|${t}|${r}`,l=this.entries.get(a);if(l)return s||(l.warm?l.warm=false:l.refCount+=1),l.controller;let u=n();return this.entries.set(a,{controller:u,refCount:1,warm:s}),this.destroyers.set(u,o),u}releaseInternal(t){for(let[r,n]of this.entries)if(n.controller===t){n.refCount-=1,n.refCount<=0&&(this.runDestroyer(t),this.entries.delete(r));return}}runDestroyer(t){let r=this.destroyers.get(t);this.destroyers.delete(t),r&&r(t);}buildChatController(t){let r=Ea({auth:this.buildAuth(t.userRef),telemetry:this.telemetry,...this.errorPolicy?{errorPolicy:this.errorPolicy}:{},initialConversationId:t.conversationId,petRef:t.petRef});return this.runBootstrap(r,t),r}runBootstrap(t,r){let n={};r.petRef!==null&&(n.petRef=r.petRef),r.conversationId!==null&&(n.resumeConversationId=r.conversationId);let o=Sa(n,{controller:t});return o.then(s=>t.adoptPrompts(s.suggestedPrompts)).catch(()=>{}),this.bootstraps.set(t,o),o}buildAuth(t){return this.identity!==null&&this.currentUser!==null?{mode:"personalized",transport:this.transport,identity:this.identity,userRef:this.currentUser.userRef,sessionId:this.sessionId}:{mode:"anonymous",transport:this.transport,publishableKey:this.publishableKey,userRef:this.currentUser===null?null:t,sessionId:this.sessionId}}setUser(t){if(this.disposed)return;let r=t?.userRef??null,n=this.currentUser?.userRef??null;if(r===n){this.currentUser=t,t&&this.identity===null&&(this.identity=this.buildIdentity(t));return}this.pendingBeforeLogout=this.beforeLogoutSettlement(),this.identity?.clear(),this.clearTokenRefresh(),this.currentUser=t,this.identity=this.buildIdentity(t),this.rescopeAll();}async logout(){if(this.disposed)return;let t=this.currentUser===null;this.leavingSessionId=this.sessionId,this.sessionId=$n(),this.setUser(null),this.leavingSessionId=null,t&&this.rescopeAll();let r=this.pendingBeforeLogout;this.pendingBeforeLogout=null,r!==null&&await r,await Bl(this.kv,this.telemetry);}onBeforeLogout(t){return this.disposed?()=>{}:(this.beforeLogoutHooks.add(t),()=>{this.beforeLogoutHooks.delete(t);})}beforeLogoutSettlement(){let t=this.currentUser,r=this.identity;return Vl({leaving:t,identity:r,hooks:this.beforeLogoutHooks,telemetry:this.telemetry,graceAuth:i(()=>Hl({leaving:t,identity:r,transport:this.transport,sessionId:this.leavingSessionId??this.sessionId}),"graceAuth")})}async registerPet(t,r){return this.withPets("registerPet",n=>r===void 0?n.registerPet(t):n.registerPet(t,r))}updatePet(t,r){return this.withPets("updatePet",n=>n.updatePet(t,r))}deletePet(t){return this.withPets("deletePet",r=>r.deletePet(t))}eraseUserData(){return this.withPets("eraseUserData",t=>t.eraseUserData())}async withPets(t,r){return this.disposed?v($l(t)):r(Ze(this.buildAuth(this.currentUser?.userRef??null)))}prepare(t){let r=t?.petRef??null,n=`${this.epoch}|${this.currentUser?.userRef??""}|${r??""}`,o=this.prepared;if(o!==null&&o.key===n&&(o.result===null||o.result.status==="ready"))return o.promise;let s={key:n,result:null,promise:this.runPrepare(r).then(a=>(s.result=a,a))};return this.prepared=s,s.promise}async runPrepare(t){let r=Date.now(),n=this.configFailure,o=this.disposed?$l("prepare"):n===null?null:Bo(n),s=this.identity,[a,l,u]=await Promise.all([o?v(o):s===null?L(void 0):s.currentToken().then(()=>L(void 0),()=>v(D("authRejected",{retryable:false}))),o?v(o):this.primeEntitlements(),t===null?void 0:o?v(o):this.primeChat(t)]),d=a.ok?l.ok&&(u?.ok??true)?"ready":"partial":"failed",c=Date.now()-r;try{this.telemetry.track("sdk.prepare.timing",{durationMs:c,status:d});}catch{}return Object.freeze({status:d,durationMs:c,session:a,entitlements:l,...u?{chat:u}:{}})}async primeEntitlements(){let t=await this.poller?.prime();return t?t.kind==="failed"?v(t.error):L(void 0):v(D("internalError",{retryable:true}))}async primeChat(t){let r={userRef:this.currentUser?.userRef??null,petRef:t,conversationId:null},n=this.acquireInternal("chat",jo(r),()=>this.buildChatController(r),ql,true),o=await this.bootstraps.get(n);return o?.cause&&n.getSnapshot().conversationId===null&&(o=await this.runBootstrap(n,r)),o?.cause?v(o.cause):L(void 0)}setActivePet(t){if(this.disposed)return;let r=t??null;r!==this.activePet&&(this.activePet=r,this.rescopeAll());}updateEntitlements(t){this.disposed||this.configFailure===null&&this.store.set(t);}open(t){this.telemetry.track("sdk.open",{capability:t});}dispose(){this.disposed||(this.disposed=true,this.epoch+=1,this.poller?.stop(),this.identity?.clear(),this.clearTokenRefresh(),this.disposeAllControllers());}rescopeAll(){this.epoch+=1,this.disposeAllControllers(),this.store.reset(),this.verdictSettled=false,this.poller?.refresh();}disposeAllControllers(){for(let t of this.entries.values())this.runDestroyer(t.controller);this.entries.clear(),this.destroyers.clear();}};i(Go,"EverfurRuntimeImpl");var Wo=Go;function jo(e){return `${e.userRef??""}|${e.petRef??""}|${e.conversationId??""}`}i(jo,"chatScopeKey");function ql(e){e.dispose();}i(ql,"disposeChat");function $l(e){return D("validationFailed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}i($l,"disposedError");var Xl=Symbol.for("@everfur/sdk#EverfurContext@v1"),Ql=globalThis,sn=Ql[Xl]??(Ql[Xl]=react.createContext(null));sn.displayName??="EverfurContext";function Y(){let e=react.useContext(sn);if(e===null)throw new Q("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}i(Y,"useEverfurContext");function Zl(){return Y().handle}i(Zl,"useEverfur");var Jl=Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),eu=globalThis,hr=eu[Jl]??(eu[Jl]=react.createContext(mt));hr.displayName??="EverfurThemeContext";function O(){return react.useContext(hr)}i(O,"useEverfurTheme");function an(e){let{runtime:t}=Y(),r=t.entitlements,n=react.useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot),o=e.seams.useColorScheme(),s=e.seams.useReducedMotion(),a=e.seams.useTextScale(),l=e.seams.useHighContrast(),u=e.seams.scaleTypeSizes,d=e.seams.platformMonoFamily?.(),c=e.seams.isFontRegistered,p=e.clientTheme?hh(e.clientTheme):"",f=react.useMemo(()=>e.clientTheme?We(e.clientTheme):null,[p]),y=n.branding??null,m=react.useMemo(()=>Uo({branding:y,clientOverride:f,colorScheme:o,reducedMotion:s,textScale:a,scaleTypeSizes:u,highContrast:l,...d===void 0?{}:{platformMonoFamily:d},...c===void 0?{}:{isFontRegistered:c}}),[y,f,o,s,a,u,l,d,c]);return e.seams.useResolvedTheme?.(m),react.createElement(hr.Provider,{value:m},e.children)}i(an,"EverfurThemeProviderCore");function hh(e){try{return JSON.stringify(e)}catch{return Object.keys(e).join("&")}}i(hh,"stableKey");function iu(e){let{config:t,user:r,activePet:n,theme:o,warmUp:s,children:a,seams:l}=e,u=`${t?.publishableKey??""}|${t?.apiBaseUrl??""}|${t?.contractVersion??""}`,d=react.useRef(null),c=react.useRef(null),[p,f]=react.useReducer(T=>T+1,0),y=react.useRef(null),m=react.useRef(void 0),w=r?.userRef??null;m.current!==w&&(m.current!==void 0&&(y.current=null),m.current=w);let b=y.current!==null?y.current.user:r??null,R=react.useRef(null),I=react.useRef(void 0),P=n??null;I.current!==P&&(I.current!==void 0&&(R.current=null),I.current=P);let x=R.current!==null?R.current.pet:n??null;(d.current===null||d.current.key!==u||d.current.runtime.isDisposed)&&(d.current!==null&&!d.current.runtime.isDisposed&&(c.current=d.current.runtime),d.current={key:u,runtime:Yl({config:l.withDefaults?l.withDefaults(t):t,user:b,activePet:x,theme:o??null},{platform:l.platform,...l.eventSourceFactory?{eventSourceFactory:l.eventSourceFactory}:{}})});let g=d.current.runtime,_=react.useRef(null);react.useEffect(()=>{let T=d.current?.runtime;T===void 0||!T.isDisposed||_.current!==T&&(_.current=T,f());}),react.useEffect(()=>{let T=c.current;T!==null&&(c.current=null,T.dispose());});let F=b?.userRef??null;react.useLayoutEffect(()=>{g.setUser(b);},[g,F]),react.useLayoutEffect(()=>{g.setActivePet(x);},[g,x]),react.useEffect(()=>()=>g.dispose(),[g]),react.useEffect(()=>{s==="onMount"&&g.prepare(x===null?{}:{petRef:x});},[g,s,F,x]);let M=react.useMemo(()=>({setUser:i(T=>{y.current={user:T},g.setUser(T),f();},"setUser"),setActivePet:i(T=>{R.current={pet:T},g.setActivePet(T),f();},"setActivePet"),open:i(T=>g.open(T),"open"),prepare:i(T=>g.prepare(T),"prepare"),registerPet:i((T,V)=>g.registerPet(T,V),"registerPet"),updatePet:i((T,V)=>g.updatePet(T,V),"updatePet"),deletePet:i(T=>g.deletePet(T),"deletePet"),eraseUserData:i(()=>g.eraseUserData(),"eraseUserData"),logout:i(()=>{y.current={user:null};let T=g.logout();return f(),T},"logout")}),[g,f]),E=react.useMemo(()=>({runtime:g,handle:M,userRef:F,activePet:x,scopeEpoch:g.scopeEpoch}),[g,M,F,x,p]),k=react.createElement(an,{clientTheme:o??null,seams:l.theme,children:a});return react.createElement(sn.Provider,{value:E},l.wrap?l.wrap(k):k)}i(iu,"EverfurProviderCore");var Eh=2;function Ch(e,t){let r=e?._xhr;if(!r||typeof r.getResponseHeader!="function"||typeof r.readyState=="number"&&r.readyState<Eh)return null;let n;try{n=r.getResponseHeader(t);}catch{return null}return typeof n=="string"&&n.length>0?n:null}i(Ch,"readEventSourceResponseHeader");function su(){let e=vh__default.default;return (t,r)=>{let n=new e(t,{method:r.method,headers:r.headers,pollingInterval:r.pollingInterval??0,...r.body!==void 0?{body:r.body}:{}});return Object.assign(n,{getResponseHeader:i(o=>Ch(n,o),"getResponseHeader")})}}i(su,"createRnEventSourceFactory");function Ph(){let e=reactNative.useColorScheme();return e==="dark"?"dark":e==="light"?"light":null}i(Ph,"useRnColorScheme");function kh(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(kh,"isThenable");function xh(){let[e,t]=react.useState(false);return react.useEffect(()=>{let r=true,n=reactNative.AccessibilityInfo?.isReduceMotionEnabled;if(typeof n=="function"){let s=n.call(reactNative.AccessibilityInfo);s!=null&&typeof s.then=="function"&&s.then(a=>{r&&t(a===true);},()=>{});}let o=reactNative.AccessibilityInfo?.addEventListener?.("reduceMotionChanged",s=>t(s===true));return ()=>{r=false,o?.remove?.();}},[]),e}i(xh,"useRnReducedMotion");function uu(){let e=reactNative.PixelRatio?.getFontScale;if(typeof e!="function")return 1;try{let t=e.call(reactNative.PixelRatio);return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1}catch{return 1}}i(uu,"readFontScale");function _h(e){let t=reactNative.Dimensions?.addEventListener;if(typeof t!="function")return ()=>{};let r=t.call(reactNative.Dimensions,"change",e);return ()=>r?.remove?.()}i(_h,"subscribeFontScale");function wh(){return react.useSyncExternalStore(_h,uu,uu)}i(wh,"useRnTextScale");function fu(){try{let e=reactNative.Platform?.OS;return typeof e=="string"?e:null}catch{return null}}i(fu,"platformOS");function Ih(){return fu()==="android"?{query:"isHighTextContrastEnabled",event:"highTextContrastChanged"}:{query:"isDarkerSystemColorsEnabled",event:"darkerSystemColorsChanged"}}i(Ih,"contrastSignal");function Ah(){let[e,t]=react.useState(false);return react.useEffect(()=>{let r=true,{query:n,event:o}=Ih(),a=reactNative.AccessibilityInfo?.[n];if(typeof a!="function")return ()=>{};try{let d=a.call(reactNative.AccessibilityInfo);kh(d)&&Promise.resolve(d).then(c=>{r&&t(c===!0);},()=>{});}catch{}let l=reactNative.AccessibilityInfo?.addEventListener,u=typeof l=="function"?l.call(reactNative.AccessibilityInfo,o,d=>t(d===true)):void 0;return ()=>{r=false,u?.remove?.();}},[]),e}i(Ah,"useRnHighContrast");function Oh(){return fu()==="ios"?"Menlo":Ne}i(Oh,"rnPlatformMonoFamily");function Fh(){return globalThis.__DEV__!==false}i(Fh,"isDevelopment");var du=new Set;function Mh(e){if(!Fh()||du.has(e))return;du.add(e);let t=globalThis.console;try{t?.warn?.(`[everfur] The theme names the font face "${e}", which this app has not registered; the SDK renders the platform font at that weight instead. Register the font file (expo-font or your native font assets) or name a registered face.`);}catch{}}i(Mh,"warnUnregisteredFace");function Lh(e){let t=globalThis.expo?.modules?.ExpoFontLoader,r=t?.getLoadedFonts;if(typeof r!="function")return null;let n;try{n=r.call(t);}catch{return null}if(!Array.isArray(n)||n.length===0)return null;let o=n.includes(e);return o||Mh(e),o}i(Lh,"rnIsFontRegistered");var un=Object.freeze({useColorScheme:Ph,useReducedMotion:xh,useTextScale:wh,useHighContrast:Ah,scaleTypeSizes:false,platformMonoFamily:Oh,isFontRegistered:Lh});function Nh(e){return react.createElement(reactNativeSafeAreaContext.SafeAreaProvider,null,e)}i(Nh,"wrapInSafeArea");var Uh=Object.freeze({platform:"react-native",eventSourceFactory:su(),wrap:Nh,theme:un});function Vh(e){return react.createElement(iu,{...e,seams:Uh})}i(Vh,"EverfurProvider");function Nt(e){let{runtime:t}=Y(),r=t.entitlements,n=react.useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot);return react.useMemo(()=>Za(e,n.decisions,{isPending:n.isPending}),[e,n])}i(Nt,"useCapability");function Gh(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}i(Gh,"tierMultiplier");function C({tier:e="content",...t}){let{type:r}=O(),n=Gh(r,e);return react.createElement(reactNative.Text,n===void 0?t:{maxFontSizeMultiplier:n,...t})}i(C,"Text");var Ut=react.forwardRef(i(function(t,r){return react.createElement(reactNative.TextInput,{...t,...r===null?{}:{ref:r}})},"TextInput"));var Kh=Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function S(e,t){let r=e.type,n=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:n}:{fontFamily:n,fontWeight:r.weight[Kh[t]]}}i(S,"face");var qo=class qo extends react.Component{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey};}static getDerivedStateFromError(){return {failed:true}}static getDerivedStateFromProps(r,n){return Object.is(r.resetKey,n.key)?null:{failed:false,key:r.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};i(qo,"HostRenderBoundary");var Ko=qo;function $h({render:e}){return e()}i($h,"RenderHost");function vt({render:e,fallback:t,resetKey:r}){return react.createElement(Ko,{fallback:t,resetKey:r,children:react.createElement($h,{render:e})})}i(vt,"HostRender");var Yh=48;function Xh(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}i(Xh,"selectView");function Xo(e){let{capability:t,children:r,renderDisabled:n,renderPending:o,style:s}=e,a=Nt(t),l=react.useMemo(()=>Xh(a),[a]);switch(l){case "enabled":return r;case "pending":return o?jsxRuntime.jsx(vt,{render:o,fallback:jsxRuntime.jsx(bu,{capability:t,style:s})}):jsxRuntime.jsx(bu,{capability:t,style:s});case "disabled":return n?jsxRuntime.jsx(vt,{render:()=>n(a),fallback:jsxRuntime.jsx(vu,{decision:a,style:s}),resetKey:a}):jsxRuntime.jsx(vu,{decision:a,style:s});default:return Qe(l)}}i(Xo,"CapabilityGate");function bu({capability:e,style:t}){let r=O(),n=react.useMemo(()=>Eu(r),[r]);return jsxRuntime.jsx(reactNative.View,{style:[n.offstate,t],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${e}`,children:jsxRuntime.jsx(reactNative.View,{style:n.skeletonBar})})}i(bu,"PendingSkeleton");function vu({decision:e,style:t}){let r=O(),n=react.useMemo(()=>Eu(r),[r]),o=e.disabled?.reason??"";return jsxRuntime.jsx(reactNative.View,{style:[n.offstate,t],accessible:true,accessibilityRole:"text",accessibilityLabel:o,children:o.length>0?jsxRuntime.jsx(C,{style:n.offstateText,children:o}):null})}i(vu,"OffState");function Eu(e){let{color:t,space:r,radius:n,type:o}=e;return reactNative.StyleSheet.create({offstate:{minHeight:Yh,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},offstateText:{...S(e,"regular"),fontSize:o.size.body,lineHeight:Math.round(o.size.body*o.lineHeight.normal),color:t.text.muted},skeletonBar:{height:r.md,borderRadius:n.xs,backgroundColor:t.brandSofter}})}i(Eu,"makeStyles");var h=Object.freeze({placeholder:"Ask me anything!",send:"Send",stop:"Stop",retry:"Try again",followUps:"Helpful follow-ups",poweredBy:"powered by everfur",senderUser:"You",senderAssistant:"Assistant",typing:"Assistant is typing",loading:"Loading",empty:"No messages yet",transcript:"Conversation",emptyTitle:"What can we help {petName} with today?",emptyTitlePetFallback:"your pet",copied:"Copied",copyUserMessage:"Copy your message",copyAssistantMessage:"Copy assistant message",feedbackHelpful:"Helpful",feedbackNeutral:"Neutral",feedbackNotHelpful:"Not helpful",feedbackTitle:"What went wrong?",feedbackSubtitle:"Your feedback helps make answers more reliable.",feedbackReasonInaccurate:"Inaccurate",feedbackReasonOutdated:"Out of date",feedbackReasonUnsafe:"Unsafe advice",feedbackReasonUnclear:"Confusing or unclear",feedbackReasonOther:"Something else",feedbackNotesPlaceholder:"Add details (optional)",feedbackSubmit:"Submit feedback",feedbackSkip:"Skip",feedbackSkipA11y:"Skip feedback",feedbackThanks:"Thanks for the feedback",feedbackFailed:"Couldn't send feedback. Please try again.",turnFailedTitle:"Message failed",turnRetry:"Retry",turnUnreachableTitle:"Couldn't reach this chat",turnStartNewChat:"Start a new chat",reconnecting:"Reconnecting\u2026",turnStoppedTitle:"Response stopped",turnStoppedBody:"You stopped this response before it finished. Tap retry to try again.",sourceSingular:"source",sourcePlural:"sources",showSources:"Show",hideSources:"Hide",openSource:"Open source",urgencyGeneralReason:"Just general info about {petName}. Nothing here needs action right now.",findVet:"Find a vet",findVetA11y:"Find a vet near you",showLatestVetAlert:"Show latest vet alert",dismissBanner:"Dismiss {label} banner",openMenu:"Open menu",openMenuUnread:"Open menu, unread chats",yourPets:"Your Pets",yourPet:"Your pet",switchActivePet:"Switch active pet, {name}",petCurrentlyActive:"{name}, currently active",switchToPet:"Switch to {name}",activePrefix:"Active \xB7 ",close:"Close",addAnotherPet:"Add another pet",addPet:"Add a pet",attachmentPhoto:"Photo",attachmentCamera:"Camera",closeAttachmentPicker:"Close attachment picker",addAttachment:"Add attachment, {used} of {total} used",attachmentsFull:"Attachments full, {used} of {total} used",retryUpload:"Retry uploading {filename}",removeAttachment:"Remove {filename}",previewAttachment:"Preview {filename}",closePreview:"Close preview",attachedImage:"Attached image: {filename}, opens a full-screen preview",attachmentTooLarge:"Files must be under {max}. {filename} is {size}.",attachmentTooMany:"You can attach up to {max} files per message.",attachmentUnsupported:"{filename} isn't a supported file type yet.",attachmentNetwork:"Couldn't reach the server. Check your connection and try again.",attachmentServer:"Upload failed{status}. Please try again.",attachmentCancelled:"Upload cancelled.",attachmentRateLimited:"Slow down. Please wait a moment and try again.",attachmentQuota:"Daily image limit reached. Try again tomorrow.",attachmentConflict:"Something went wrong. Tap to retry.",attachmentUnknown:"Something went wrong. Please try again.",attachmentsFailedBlocked:"Some attachments failed to upload. Remove or retry them before sending.",dictate:"Dictate a message",stopDictation:"Stop dictation",listening:"Listening",micBlocked:"Microphone access is blocked. Allow it in your browser settings to dictate.",noSpeech:"We didn't catch that. Tap the mic and try again.",dictationUnavailable:"Voice typing isn't available right now."});function K(e,t){return e.replace(/\{(\w+)\}/g,(r,n)=>{let o=t[n];return o===void 0?r:String(o)})}i(K,"fillCopy");var Qo=Object.freeze([Object.freeze({key:"inaccurate",label:h.feedbackReasonInaccurate,feedbackType:"wrong"}),Object.freeze({key:"outdated",label:h.feedbackReasonOutdated,feedbackType:"outdated"}),Object.freeze({key:"unsafe",label:h.feedbackReasonUnsafe,feedbackType:"dangerous"}),Object.freeze({key:"unclear",label:h.feedbackReasonUnclear,feedbackType:"unclear"}),Object.freeze({key:"other",label:h.feedbackReasonOther,feedbackType:"not_helpful"})]),Cu=Object.freeze([Object.freeze({sentiment:"up",label:h.feedbackHelpful}),Object.freeze({sentiment:"neutral",label:h.feedbackNeutral}),Object.freeze({sentiment:"down",label:h.feedbackNotHelpful})]);function Qh(e){switch(e){case "up":return "helpful";case "neutral":return "neutral";case "down":return "not_helpful"}}i(Qh,"sentimentToFeedbackType");function Ru(e,t){if(e==="down"&&t!==null){let r=Qo.find(n=>n.key===t);if(r!==void 0)return r.feedbackType}return Qh(e)}i(Ru,"feedbackTypeFor");var tb=Object.freeze({status:"idle",messages:Object.freeze([]),conversationId:null,error:null,isStreaming:false,isBootstrapping:true,suggestedPrompts:Object.freeze([]),unreadCount:null});function br(e){let{runtime:t,userRef:r,activePet:n,scopeEpoch:o}=Y(),s=e?.petRef??n??null,a=e?.conversationId??null,l=react.useMemo(()=>({runtime:t,userRef:r,petRef:s,conversationId:a,scopeEpoch:o}),[t,r,s,a,o]),[u,d]=react.useState(null),c=u?.scope===l?u.controller:t.registry.peekChat({userRef:r,petRef:s,conversationId:a}),p=react.useRef(null);react.useEffect(()=>{let E=t.registry.acquireChat({userRef:r,petRef:s,conversationId:a});return p.current=E,d({scope:l,controller:E}),()=>{p.current=null,d(k=>k?.controller===E?null:k),t.registry.releaseChat(E);}},[t,r,s,a,o,l]);let f=react.useCallback(E=>c?c.subscribe(E):rb,[c]),y=react.useCallback(()=>c?c.getSnapshot():tb,[c]),m=react.useSyncExternalStore(f,y,y),w=react.useCallback((E,k)=>c&&p.current===c&&!c.getSnapshot().isBootstrapping?Jo(c,c.send(E,k?.imageS3Keys===void 0?{}:{imageS3Keys:k.imageS3Keys}),()=>p.current===c):Promise.resolve(ei()),[c]),b=react.useCallback(E=>c&&p.current===c&&!c.getSnapshot().isBootstrapping?Jo(c,c.askEverfur(E),()=>p.current===c):Promise.resolve(ei()),[c]),R=react.useCallback(()=>c&&p.current===c?Jo(c,c.retryLast(),()=>p.current===c):Promise.resolve(ei()),[c]),I=react.useCallback(()=>{c&&p.current===c&&c.stop();},[c]),P=react.useCallback(()=>{c&&p.current===c&&c.newConversation();},[c]),[x,g]=react.useState({controller:null,byMessage:{}}),_=x.controller===c?x.byMessage:nb,F=react.useCallback(async(E,k,T,V)=>{if(!c||p.current!==c)return v(D("accessDenied"));let j=String(E),G=x.controller===c?x.byMessage[j]:void 0;if(G===k&&T==null)return g(de=>{let ke={...de.controller===c?de.byMessage:{}};return delete ke[j],{controller:c,byMessage:ke}}),L(Object.freeze({feedbackId:""}));g(de=>({controller:c,byMessage:{...de.controller===c?de.byMessage:{},[j]:k}}));let ne=await c.submitFeedback(E,Ru(k,T??null),V??null);return p.current!==c?v(D("accessDenied")):(ne.ok||g(de=>{let ke={...de.controller===c?de.byMessage:{}};return G===void 0?delete ke[j]:ke[j]=G,{controller:c,byMessage:ke}}),ne)},[c,x]),M=react.useMemo(()=>{let E=i(async k=>{if(!c||p.current!==c)return v(D("accessDenied"));let T=await k(c);return p.current===c?T:v(D("accessDenied"))},"run");return {listConversations:i(k=>E(T=>T.listConversations({...s?{petRef:s}:{},...k})),"listConversations"),getMessages:i((k,T)=>E(V=>V.getMessages(k,T)),"getMessages"),resumeConversation:i(k=>E(T=>T.resumeConversation(k)),"resumeConversation"),loadOlderMessages:i(()=>E(k=>k.loadOlderMessages()),"loadOlderMessages"),markRead:i(()=>E(k=>k.markRead()),"markRead"),refreshActiveThread:i(()=>E(k=>k.refreshActiveThread()),"refreshActiveThread"),answerCheckin:i((k,T)=>E(V=>V.answerCheckin(k,T)),"answerCheckin"),openCheckin:i(k=>E(T=>T.openCheckin(k)),"openCheckin")}},[c,s]);return react.useMemo(()=>({status:m.status,messages:m.messages,conversationId:m.conversationId,petRef:s,error:m.error,isStreaming:m.isStreaming,isBootstrapping:m.isBootstrapping,historyCursor:m.historyCursor??null,isLoadingHistory:m.isLoadingHistory??false,stopped:m.stopped??false,reconnecting:m.reconnecting??false,...M,suggestedPrompts:m.suggestedPrompts,unreadCount:m.unreadCount,hasUnreadThreads:m.hasUnreadThreads??false,newConversation:P,sentimentByMessage:_,feedback:F,send:w,askEverfur:b,retryLast:R,stop:I}),[m,s,w,b,R,I,M,P,_,F])}i(br,"useEverfurChat");var rb=i(()=>{},"NOOP_UNSUBSCRIBE"),nb=Object.freeze({});async function Jo(e,t,r){for await(let o of t);if(!r())return v(D("accessDenied"));let n=e.getSnapshot();return n.status==="error"&&n.error!==null?v(n.error):L(ob(n.messages))}i(Jo,"driveToResult");function ob(e){for(let t=e.length-1;t>=0;t-=1){let r=e[t];if(r&&r.role==="assistant"&&r.responseId!==void 0)return r.responseId}return null}i(ob,"lastAssistantResponseId");function ei(){return v(D("internalError",{retryable:true}))}i(ei,"notReadyError");function ku(e){switch(e.code){case "too_large":return K(h.attachmentTooLarge,{max:bo(qr),filename:e.filename,size:bo(e.sizeBytes??0)});case "too_many":return K(h.attachmentTooMany,{max:$r});case "unsupported_type":return K(h.attachmentUnsupported,{filename:e.filename});case "network":return h.attachmentNetwork;case "server":return K(h.attachmentServer,{status:e.httpStatus?` (${e.httpStatus})`:""});case "cancelled":return h.attachmentCancelled;case "rate_limited":return h.attachmentRateLimited;case "quota_exceeded":return h.attachmentQuota;case "idempotency_conflict":return h.attachmentConflict;case "unknown":return h.attachmentUnknown}}i(ku,"attachmentErrorMessage");function xu(e,t){return K(e>=t?h.attachmentsFull:h.addAttachment,{used:e,total:t})}i(xu,"attachControlLabel");var lb=Object.freeze({attachments:Object.freeze([])});function dn(e={}){let{runtime:t,userRef:r,scopeEpoch:n}=Y(),o=e.maxPerMessage??$r,s=react.useCallback(()=>{let{services:g}=t.registry;return ka({funnel:xe({auth:g.authFor(r),...g.errorPolicy?{errorPolicy:g.errorPolicy}:{}}),transport:e.transport??g.uploadTransport,maxPerMessage:o})},[t,r,n,o,e.transport]),a=react.useMemo(()=>e.queue??s(),[e.queue,s]),l=react.useRef(new WeakSet),[u,d]=react.useState(null),c=u!==null&&u.of===a?u.queue:a;react.useEffect(()=>{if(c!==e.queue){if(l.current.has(c)){d({of:a,queue:s()});return}return ()=>{c.dispose(),l.current.add(c);}}},[c,a,s,e.queue]);let p=react.useSyncExternalStore(c.subscribe,c.getSnapshot,()=>lb),[f,y]=react.useState(null),m=react.useCallback(g=>{let F=(Array.isArray(g)?g:[g]).map(E=>c.add(E)),M=F.find(E=>!E.ok);return M!==void 0&&!M.ok&&y(M.error),F},[c,y]),w=react.useCallback(g=>c.retry(g),[c]),b=react.useCallback(g=>c.remove(g),[c]),R=react.useCallback(()=>c.clear(),[c]),I=react.useCallback(()=>y(null),[y]),P=p.attachments.some(g=>g.status==="uploading"),x=p.attachments.some(g=>g.status==="failed");return react.useMemo(()=>({available:c.available,attachments:p.attachments,maxPerMessage:o,uploading:P,failed:x,blocked:P||x,s3Keys:p.attachments.flatMap(g=>g.status==="uploaded"&&g.s3Key!==null?[g.s3Key]:[]),rejected:f,add:m,retry:w,remove:b,clear:R,dismissRejected:I}),[c.available,p,o,P,x,f,m,w,b,R,I])}i(dn,"useChatAttachments");var cb="pet_not_registered";function Iu(e){return e!=null&&e.reasonCode===cb}i(Iu,"isPetNotRegistered");var pb=Object.freeze({status:"idle",error:null,registered:null,retry:i(()=>{},"retry")});function Au(e,t,r){let{runtime:n,userRef:o,scopeEpoch:s}=Y(),a=react.useCallback(()=>Ze(n.registry.services.authFor(o)),[n,o,s]),l=react.useMemo(()=>t===void 0?null:ri(t),[t]),[u,d]=react.useState({key:null,status:"idle",error:null,registered:null}),c=react.useRef(0),p=react.useRef(r);p.current=r;let f=e===null||l===null?null:`${String(o)}|${s}|${e}|${l}`,y=react.useCallback(()=>{if(e===null||t===void 0||f===null)return;let w=++c.current;d({key:f,status:"registering",error:null,registered:null}),a().registerPet(e,t).then(b=>{w===c.current&&(b.ok?(d({key:f,status:"registered",error:null,registered:b.value}),p.current?.()):d({key:f,status:"failed",error:b.error,registered:null}));});},[a,e,f]);react.useEffect(()=>{if(f===null){c.current+=1;return}return y(),()=>{c.current+=1;}},[f,y]);let m=react.useCallback(()=>{u.status==="failed"&&y();},[u.status,y]);return react.useMemo(()=>f===null?pb:u.key!==f?{status:"registering",error:null,registered:null,retry:m}:{status:u.status,error:u.error,registered:u.registered,retry:m},[f,u,m])}i(Au,"useChatPetRegistration");function ri(e){return e===null||typeof e!="object"?JSON.stringify(e)??"undefined":Array.isArray(e)?`[${e.map(ri).join(",")}]`:`{${Object.entries(e).filter(([,r])=>r!==void 0).sort(([r],[n])=>r<n?-1:r>n?1:0).map(([r,n])=>`${JSON.stringify(r)}:${ri(n)}`).join(",")}}`}i(ri,"stableKey");var ni=Object.freeze({});function Fu(e){let[t,r]=react.useState(ni),n=react.useRef(null),o=react.useRef([]);o.current=e.map(a=>a.id),react.useEffect(()=>{if(e.length===0){n.current=null,r(u=>u===ni?u:ni);return}let a=n.current;if(a===null)return;let l=e.find(u=>u.role==="user"&&!a.known.has(u.id));l!==void 0&&(n.current=null,r(u=>({...u,[l.id]:a.images})));},[e]);let s=react.useCallback(a=>{n.current=a.length===0?null:{images:a,known:new Set(o.current)};},[]);return react.useMemo(()=>({byMessage:t,stage:s}),[t,s])}i(Fu,"useSentImages");var bb=500;function oi(e){if(!e)return null;let t=e.replace(/[\u0000-\u001F\u007F-\u009F\u200E\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g," ").replace(/\s+/g," ").trim();return t?t.slice(0,bb):null}i(oi,"sanitizeSeedPrompt");function Lu(e,t,r){let n=oi(r),o=react.useRef(e);o.current=e;let s=react.useRef(null);react.useEffect(()=>{if(n===null||t||s.current===n)return;let a=o.current;a!==void 0&&(s.current=n,Promise.resolve(a(n)).catch(()=>{}));},[n,t]);}i(Lu,"useInitialAsk");function vb(e,t,r){if(e==="announced")return false;let n=r.lastRefresh;return n===null||n.conversationId!==t?false:r.now-n.at<15e3}i(vb,"isCoalesced");function Du(e,t){let r=t.activeConversationId;return r===null||r.length===0?{action:"skip",reason:"no_thread"}:t.isTurnInFlight?{action:"defer",reason:"turn_in_flight"}:t.isOffline?{action:"defer",reason:"offline"}:vb(e,r,t)?{action:"skip",reason:"coalesced"}:{action:"refresh",conversationId:r}}i(Du,"decideChatRefresh");function ii(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e);}catch{}}i(ii,"reportHostFailure");function Eb(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(Eb,"isThenable");function q(e,...t){if(typeof e=="function")try{let r=e(...t);return Eb(r)&&Promise.resolve(r).then(void 0,ii),r}catch(r){ii(r);return}}i(q,"callHost");var Nu=new WeakMap;function Uu(e){if(typeof e!="function")return;let t=Nu.get(e);if(t!==void 0)return t;let r=i((...n)=>{q(e,...n);},"guarded");return Nu.set(e,r),r}i(Uu,"guardHost");function Ht(e,...t){let r;try{r=e(...t);}catch(n){return ii(n),Promise.resolve({ok:false,error:n})}return Promise.resolve(r).then(n=>({ok:true,value:n}),n=>({ok:false,error:n}))}i(Ht,"callHostAsync");function Hu(e,t){let r=react.useRef(t);r.current=t;let n=react.useRef(null),o=react.useRef(null),s=e?.isOffline===void 0?false:q(()=>e.isOffline?.()===!0)===true,a=react.useRef(()=>{});a.current=l=>{let{conversationId:u,isTurnInFlight:d,refresh:c}=r.current,p=Du(l,{activeConversationId:u,isTurnInFlight:d,isOffline:s,lastRefresh:n.current,now:Date.now()});if(p.action!=="skip"){if(p.action==="defer"){o.current!=="announced"&&(o.current=l);return}o.current=null,n.current={conversationId:p.conversationId,at:Date.now()},c!==void 0&&Promise.resolve(c()).catch(()=>{});}},react.useEffect(()=>{if(t.isTurnInFlight||s)return;let l=o.current;l!==null&&a.current(l);},[t.isTurnInFlight,s]),react.useEffect(()=>{if(e===void 0)return;let l=[],u=i((d,c)=>{if(d===void 0)return;let p=q(()=>d(()=>{a.current(c);}));typeof p=="function"&&l.push(p);},"subscribe");return u(e.onForeground?.bind(e),"foreground"),u(e.onOnline?.bind(e),"foreground"),u(e.onAnnounced?.bind(e),"announced"),()=>{for(let d of l)q(d);}},[e]);}i(Hu,"useChatLifecycle");function Rb(e){if(e===void 0)return null;let t=e.conversationId??"",r=e.petRef??"";return t===""&&r===""?null:`${String(t)}|${String(r)}`}i(Rb,"targetKey");function zu(e,t){let r=Rb(t),n=react.useRef({openCheckin:e,target:t});n.current={openCheckin:e,target:t};let o=react.useRef(null);react.useEffect(()=>{if(r===null||o.current===r)return;o.current=r;let{openCheckin:s,target:a}=n.current;s===void 0||a===void 0||Promise.resolve(s(a)).catch(()=>{});},[r]);}i(zu,"useCheckinTarget");function Gu(e,t,r){let[n,o]=react.useState({send:e,conversationId:t,text:r??"",seeded:r??null}),s=n.send===e&&(n.conversationId===null||n.conversationId===t);react.useEffect(()=>{o(l=>{let u=l.send===e&&(l.conversationId===null||l.conversationId===t),d=u?l.text:"",c=u?l.seeded:null,p=r!=null&&r!==c&&d.length===0;return {send:e,conversationId:t,text:p?r:d,seeded:p?r:c}});},[e,t,r]);let a=react.useCallback(l=>o(u=>({send:e,conversationId:t,text:l,seeded:u.seeded})),[e,t]);return [s?n.text:"",a]}i(Gu,"useChatDraft");function Ku(e,t,r,n){let o=react.useRef({draft:r,setDraft:n});o.current={draft:r,setDraft:n};let s=react.useRef(null),[a,l]=react.useState(null);react.useEffect(()=>{if(e===void 0)return;let u=`${t??""}`;if(s.current===u)return;s.current=u;let d=true;return (async()=>{let c=await Ht(()=>e.read(t));if(!d)return;let p=c.ok&&typeof c.value=="string"?c.value:"";p.length>0&&o.current.draft.length===0&&o.current.setDraft(p),l(u);})(),()=>{d=false;}},[e,t]),react.useEffect(()=>{e===void 0||a!==`${t??""}`||q(()=>e.write(t,r));},[e,t,r,a]);}i(Ku,"usePersistedDraft");var Z=Object.freeze({heading:"Chat History",empty:"No chats yet",emptyBody:"Start a new conversation to see it here.",noMatch:"No matching chats",noMatchBody:"Try a different title or start a new conversation.",loading:"Loading your chats\u2026",loadFailed:"Couldn\u2019t load your chats",loadingMore:"Loading more\u2026",untitled:"New conversation",newConversation:"New conversation",newChat:"New chat",search:"Search",retry:"Try again",retryA11y:"Retry loading chats",close:"Close",closeA11y:"Close history",more:"Load more",earlier:"Load earlier messages",loadingEarlier:"Loading earlier messages\u2026",openConversation:"Open conversation",unreadPrefix:"Unread. "});function pn(e){let t=e?.replace(/\s+/g," ").trim();return t||Z.untitled}i(pn,"conversationTitle");function $u(e){return `${e.unreadCount!==null&&e.unreadCount>0?Z.unreadPrefix:""}${Z.openConversation} ${pn(e.title)}`}i($u,"openConversationLabel");function qu(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').toLowerCase().trim().replace(/\s+/g," ")}i(qu,"normalizeForSearch");function _b(e,t){let r=qu(t);if(r.length===0)return e;let n=[[],[],[]];for(let o of e){let s=qu(pn(o.title)),a=s.indexOf(r);if(a<0)continue;let l=a===0?0:s.charAt(a-1)===" "?1:2;n[l]?.push(o);}return n.flat()}i(_b,"filterConversations");function li(e){return {scope:e,rows:[],cursor:null,loading:false,loadingMore:false,error:null}}i(li,"fresh");function Yu(e){let[t,r]=react.useState(false),[n,o]=react.useState(""),s=e.listConversations,a=react.useRef(0),[l,u]=react.useState(()=>li(s)),d=l.scope===s?l:li(s);react.useEffect(()=>(a.current+=1,r(false),o(""),u(li(s)),()=>{a.current+=1;}),[s]);let c=react.useCallback(async P=>{let x=++a.current,g=P!==void 0;u(F=>({...F,scope:s,loading:!g,loadingMore:g,error:null}));let _=await e.listConversations(P?{cursor:P}:void 0);if(x===a.current){if(!_.ok){u(F=>({...F,loading:false,loadingMore:false,error:_.error.displayMessage}));return}u(F=>{let M=P&&F.scope===s?F.rows:[],E=new Set(M.map(k=>k.id));return {scope:s,loading:false,loadingMore:false,error:null,rows:[...M,..._.value.conversations.filter(k=>!E.has(k.id))],cursor:_.value.nextCursor===P?null:_.value.nextCursor}});}},[e.listConversations,s]),p=i(()=>{r(true),o(""),c();},"show"),f=i(()=>{a.current+=1,r(false);},"close"),y=i(async P=>{let x=++a.current;u(_=>({..._,loading:true,error:null}));let g=await e.resumeConversation(P);x===a.current&&(u(_=>({..._,loading:false,error:g.ok?null:g.error.displayMessage})),g.ok&&r(false));},"resume"),m=i(async()=>{let P=a.current,x=await e.loadOlderMessages();P===a.current&&!x.ok&&u(g=>({...g,error:x.error.displayMessage}));},"earlier"),w=i(()=>{e.newConversation(),a.current+=1,r(false);},"newConversation"),b=i(()=>{d.cursor===null||d.loading||d.loadingMore||n.trim().length>0||c(d.cursor);},"loadMore"),R=react.useMemo(()=>_b(d.rows,n),[d.rows,n]),I=n.trim().length>0;return {...d,open:t,show:p,close:f,load:c,resume:y,earlier:m,newConversation:w,loadMore:b,query:n,setQuery:o,searching:I,filtered:R,emptyKind:d.rows.length===0?"empty":"noMatch"}}i(Yu,"useHistoryPanel");var fn="#111111",mn="#FFFFFF",Ab=Object.freeze({emergency:Object.freeze({level:"emergency",label:"Vet care now",borderColor:"#FCA5A5",backgroundColor:"#FEF2F2",textColor:"#991B1B",reasonColor:fn,pillColor:mn,showsVetAction:true}),schedule_soon:Object.freeze({level:"schedule_soon",label:"Vet care suggested soon",borderColor:"#FCD34D",backgroundColor:"#FFFBEB",textColor:"#92400E",reasonColor:fn,pillColor:mn,showsVetAction:true}),home_care:Object.freeze({level:"home_care",label:"Monitor at home",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:fn,pillColor:mn,showsVetAction:false}),general:Object.freeze({level:"general",label:"Good to know",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:fn,pillColor:mn,showsVetAction:false})});function Ob(e){return `${e.messageId}:${e.level}:${e.reason??""}`}i(Ob,"urgencySignature");function Fb(e){return K(h.urgencyGeneralReason,{petName:e?.trim()||h.emptyTitlePetFallback})}i(Fb,"generalUrgencyReason");function Zu(e,t){for(let r=e.length-1;r>=0;r-=1){let n=e[r];if(n?.role!=="assistant"||n.responseId===void 0)continue;let o=n.urgencyLevel;return o?{messageId:n.id,level:o,reason:n.urgencyReason??null}:n.urgencyProvided===true?{messageId:n.id,level:"general",reason:Fb(t)}:null}return null}i(Zu,"latestUrgencySource");function Ju(e){let t=e===null?null:Ob(e),[r,n]=react.useState(null),[o,s]=react.useState(false);react.useEffect(()=>s(false),[t]);let l=e!==null&&(o||!(r!==null&&r===t)),u=e===null?null:Ab[e.level],d=e!==null&&!l&&e.level!=="general",c=react.useCallback(()=>{t!==null&&n(t),s(false);},[t]),p=react.useCallback(()=>s(true),[]);return react.useMemo(()=>({source:e,tier:u,signature:t,showBanner:l,showCompactIcon:d,showVetAction:l&&u!==null&&u.showsVetAction,dismissLabel:u===null?null:K(h.dismissBanner,{label:u.label}),dismiss:c,expand:p}),[e,u,t,l,d,c,p])}i(Ju,"useUrgencySurface");function ed(e){return e.isBootstrapping?"loading":e.status==="error"&&e.error&&e.messages.length===0?"error":e.messages.length===0?"empty":"populated"}i(ed,"selectView");function Mb(e){return e.code==="accessDenied"||e.code==="conversationNotFound"}i(Mb,"needsNewConversation");function td(e){if(e.messages.length===0)return null;let t=e.status==="error"?e.error:null;if(t!==null){let r=Mb(t);return {tone:"error",title:r?h.turnUnreachableTitle:h.turnFailedTitle,body:t.displayMessage,actionLabel:r?h.turnStartNewChat:h.turnRetry,action:r?"startNew":"retry"}}return e.stopped===true?{tone:"neutral",title:h.turnStoppedTitle,body:h.turnStoppedBody,actionLabel:h.turnRetry,action:"retry"}:null}i(td,"turnNotice");function rd(e,t){let r=e[e.length-1];return t&&(r===void 0||r.role==="user")}i(rd,"awaitingAssistant");function nd(e,t){let r={};return e!==void 0&&(r.petRef=e),t!==void 0&&(r.conversationId=t),r}i(nd,"buildChatOpts");var vr=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 sd(e){let t=O(),r=react.useMemo(()=>Nb(t),[t]);return jsxRuntime.jsxs(reactNative.View,{style:[r.container,e.style],accessible:true,accessibilityRole:"text",accessibilityLabel:`${vr.title}. ${vr.body}`,children:[jsxRuntime.jsx(C,{style:r.title,children:vr.title}),jsxRuntime.jsx(C,{style:r.body,children:vr.body})]})}i(sd,"ClinicalDisclaimer");function Nb(e){let{color:t,space:r,type:n}=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:{...S(e,"bold"),fontSize:n.size.caption,lineHeight:Math.round(n.size.caption*n.lineHeight.snug),color:t.text.secondary,letterSpacing:n.letterSpacing.eyebrow},body:{...S(e,"regular"),fontSize:n.size.caption,lineHeight:Math.round(n.size.caption*n.lineHeight.snug),color:t.text.muted}})}i(Nb,"makeStyles");var se={pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"};function te(e){return {width:e,height:e,alignItems:"center",justifyContent:"center"}}i(te,"box");function fe(e,t){return t??Math.max(1.5,Math.round(e/11*10)/10)}i(fe,"stroke");function ad({size:e,color:t,strokeWidth:r}){let n=fe(e,r),o={width:e*.82,height:n,borderRadius:n,backgroundColor:t};return jsxRuntime.jsxs(reactNative.View,{style:[te(e),{gap:e*.22}],...se,children:[jsxRuntime.jsx(reactNative.View,{style:o}),jsxRuntime.jsx(reactNative.View,{style:o}),jsxRuntime.jsx(reactNative.View,{style:o})]})}i(ad,"MenuGlyph");function ld({size:e,color:t,strokeWidth:r,rotate:n}){let o=fe(e,r),s=e*.78;return jsxRuntime.jsxs(reactNative.View,{style:[te(e),{transform:[{rotate:n}]}],...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:s,height:o,borderRadius:o,backgroundColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:o,height:s,borderRadius:o,backgroundColor:t}})]})}i(ld,"Cross");function ud(e){return jsxRuntime.jsx(ld,{...e,rotate:"0deg"})}i(ud,"PlusGlyph");function Et(e){return jsxRuntime.jsx(ld,{...e,rotate:"45deg"})}i(Et,"CloseGlyph");function rt({size:e,color:t,strokeWidth:r}){let n=fe(e,r);return jsxRuntime.jsx(reactNative.View,{style:te(e),...se,children:jsxRuntime.jsx(reactNative.View,{style:{width:e*.36,height:e*.66,marginTop:-e*.14,borderBottomWidth:n,borderRightWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})})}i(rt,"CheckGlyph");var Hb={down:{rotate:"45deg",marginTop:-0.4,marginLeft:0},up:{rotate:"225deg",marginTop:.4,marginLeft:0},right:{rotate:"-45deg",marginTop:0,marginLeft:-0.4}};function yn({size:e,color:t,strokeWidth:r,direction:n}){let o=fe(e,r),s=e*.46,a=Hb[n];return jsxRuntime.jsx(reactNative.View,{style:te(e),...se,children:jsxRuntime.jsx(reactNative.View,{style:{width:s,height:s,borderRightWidth:o,borderBottomWidth:o,borderColor:t,marginTop:s*a.marginTop,marginLeft:s*a.marginLeft,transform:[{rotate:a.rotate}]}})})}i(yn,"ChevronGlyph");function dd({size:e,color:t,strokeWidth:r}){let n=fe(e,r),o={width:e*.42,height:e*.7,borderWidth:n,borderColor:t,borderRadius:n};return jsxRuntime.jsxs(reactNative.View,{style:[te(e),{flexDirection:"row",gap:1}],...se,children:[jsxRuntime.jsx(reactNative.View,{style:[o,{borderTopLeftRadius:e*.2}]}),jsxRuntime.jsx(reactNative.View,{style:[o,{borderTopRightRadius:e*.2}]})]})}i(dd,"BookGlyph");function cd({size:e,color:t,strokeWidth:r}){let n=fe(e,r),o=e*.5;return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:e*.78,height:n,borderRadius:n,backgroundColor:t,transform:[{rotate:"-45deg"}]}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.16,right:e*.16,width:o,height:o,borderTopWidth:n,borderRightWidth:n,borderColor:t}})]})}i(cd,"ArrowUpRightGlyph");function pd({size:e,color:t,strokeWidth:r}){let n=fe(e,r),o=e*.6,s={position:"absolute",width:o,height:o,borderWidth:n,borderColor:t,borderRadius:e*.14};return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,children:[jsxRuntime.jsx(reactNative.View,{style:[s,{top:0,left:0}]}),jsxRuntime.jsx(reactNative.View,{style:[s,{bottom:0,right:0}]})]})}i(pd,"CopyGlyph");function gn({size:e,color:t,strokeWidth:r,active:n,rotate:o}){let s=fe(e,r),a=n?t:"transparent";return jsxRuntime.jsxs(reactNative.View,{style:[te(e),{transform:[{rotate:o}]}],...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.08,left:e*.12,width:e*.62,height:e*.5,borderWidth:s,borderColor:t,backgroundColor:a,borderRadius:e*.12,borderTopLeftRadius:e*.04}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.04,left:e*.4,width:e*.3,height:e*.5,borderWidth:s,borderColor:t,backgroundColor:a,borderRadius:e*.15,transform:[{rotate:"-20deg"}]}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.08,left:0,width:e*.2,height:e*.5,borderWidth:s,borderColor:t,backgroundColor:a,borderRadius:e*.05}})]})}i(gn,"ThumbGlyph");function fd({size:e,color:t,strokeWidth:r}){let n=fe(e,r);return jsxRuntime.jsxs(reactNative.View,{style:[te(e),{borderRadius:e/2,borderWidth:n,borderColor:t}],...se,children:[jsxRuntime.jsx(reactNative.View,{style:{width:n,height:n,borderRadius:n,backgroundColor:t,marginBottom:e*.1}}),jsxRuntime.jsx(reactNative.View,{style:{width:n,height:e*.34,borderRadius:n,backgroundColor:t}})]})}i(fd,"InfoGlyph");function md({size:e,color:t,strokeWidth:r}){let n=fe(e,r),o=e*.34;return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.06,width:o,height:o,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.1,width:n,height:e*.56,borderRadius:n,backgroundColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:0,width:e*.84,height:e*.3,borderBottomWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderBottomLeftRadius:n,borderBottomRightRadius:n}})]})}i(md,"UploadGlyph");function yd({size:e,color:t,strokeWidth:r}){let n=fe(e,r);return jsxRuntime.jsxs(reactNative.View,{style:[te(e),{borderWidth:n,borderColor:t,borderRadius:e*.14,overflow:"hidden"}],...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.16,left:e*.18,width:e*.16,height:e*.16,borderRadius:e,backgroundColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:-e*.3,right:-e*.1,width:e*.7,height:e*.7,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}i(yd,"PhotoGlyph");function gd({size:e,color:t,strokeWidth:r}){let n=fe(e,r);return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.08,width:e*.34,height:e*.2,borderTopWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderTopLeftRadius:n,borderTopRightRadius:n}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.22,width:e*.92,height:e*.66,borderWidth:n,borderColor:t,borderRadius:e*.16,alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx(reactNative.View,{style:{width:e*.3,height:e*.3,borderRadius:e,borderWidth:n,borderColor:t}})})]})}i(gd,"CameraGlyph");function hd({size:e,color:t,strokeWidth:r}){let n=fe(e,r),o=e*.66;return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:0,left:0,width:o,height:o,borderRadius:o,borderWidth:n,borderColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.02,right:e*.02,width:n,height:e*.4,borderRadius:n,backgroundColor:t,transform:[{rotate:"-45deg"}]}})]})}i(hd,"SearchGlyph");function bd({size:e,color:t,strokeWidth:r}){let n=fe(e,r);return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:e*.3,height:e*.82,borderWidth:n,borderColor:t,borderRadius:n,transform:[{rotate:"45deg"}]}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:0,left:0,width:e*.4,height:n,borderRadius:n,backgroundColor:t}})]})}i(bd,"EditGlyph");function vd({size:e,color:t,strokeWidth:r}){let n=fe(e,r),o=e*.62;return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:0,width:o,height:o,borderRadius:o,borderWidth:n,borderColor:t,alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx(reactNative.View,{style:{width:n*1.4,height:n*1.4,borderRadius:n,backgroundColor:t}})}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.04,width:o*.5,height:o*.5,borderRightWidth:n,borderBottomWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}i(vd,"MapPinGlyph");function Ed({size:e,color:t,testID:r}){let n=e*.36;return jsxRuntime.jsx(reactNative.View,{style:te(e),testID:r,...se,children:jsxRuntime.jsx(reactNative.View,{style:{width:0,height:0,marginLeft:e*.12,borderLeftWidth:e*.78,borderTopWidth:n,borderBottomWidth:n,borderLeftColor:t,borderTopColor:"transparent",borderBottomColor:"transparent",transform:[{rotate:"-45deg"}]}})})}i(Ed,"SendGlyph");function Cd({size:e,color:t,testID:r}){return jsxRuntime.jsx(reactNative.View,{style:te(e),testID:r,...se,children:jsxRuntime.jsx(reactNative.View,{style:{width:e*.5,height:e*.5,backgroundColor:t}})})}i(Cd,"StopGlyph");function hn({size:e,strokeWidth:t,color:r,children:n}){return jsxRuntime.jsx(reactNative.View,{style:[te(e),{borderRadius:e/2,borderWidth:t??reactNative.StyleSheet.hairlineWidth,borderColor:r}],children:n})}i(hn,"Ring");var Er=Object.freeze({standard:ft.standard,emphasized:ft.emphasized,exit:ft.exit,outQuad:Object.freeze([.25,.46,.45,.94])});var Rd=Object.freeze({layoutMs:220,messageInMs:200,bannerInMs:220,bannerOutMs:160,iconInMs:180,iconOutMs:120,followUpInMs:180,followUpStaggerMs:70,citationsInMs:220,citationsRisePx:6,drawerMs:220,pressScale:.97,pressMs:140,revealTickMs:24,revealDivisor:12,dotsCycleMs:520,dotsMinOpacity:.44,dotsLiftPx:3.5,dotsStagger:Object.freeze([0,.18,.36]),copiedMs:1500,uploadFlashMs:600,reduced:false}),Bb=Object.freeze({...Rd,layoutMs:0,messageInMs:0,bannerInMs:0,bannerOutMs:0,iconInMs:0,iconOutMs:0,followUpInMs:0,followUpStaggerMs:0,citationsInMs:0,citationsRisePx:0,drawerMs:0,pressScale:1,pressMs:0,revealTickMs:0,dotsCycleMs:0,dotsMinOpacity:1,dotsLiftPx:0,reduced:true});function Sd(e){return e.motion.reducedMotion?Bb:Rd}i(Sd,"chatMotion");function bn(e,t){return Math.max(0,t)*e.followUpStaggerMs}i(bn,"followUpDelayMs");function Td(e,t,r){if(e.reduced||t>=r)return r;let n=Math.max(1,Math.ceil((r-t)/e.revealDivisor));return Math.min(r,t+n)}i(Td,"nextRevealLength");function X(){let e=O();return Sd(e)}i(X,"useChatMotion");var qb=8;function kd(e,t,r){return ((1-3*r+3*t)*e+(3*r-6*t))*e*e+3*t*e}i(kd,"bezierComponent");function $b(e,t,r){return 3*(1-3*r+3*t)*e*e+2*(3*r-6*t)*e+3*t}i($b,"bezierSlope");function vn(e){let[t,r,n,o]=e;return s=>{if(s<=0)return 0;if(s>=1)return 1;let a=s;for(let l=0;l<qb;l+=1){let u=$b(a,t,n);if(u===0)break;a-=(kd(a,t,n)-s)/u;}return kd(Math.min(1,Math.max(0,a)),r,o)}}i(vn,"bezierEasing");var ui=vn(Er.standard),Yb=vn(Er.outQuad);function fi(e){let t=react.useRef(null);return t.current===null&&(t.current=new reactNative.Animated.Value(e)),t.current}i(fi,"useAnimatedValue");function Ct(e,t={}){let r=t.risePx??0,n=t.delayMs??0,o=fi(e>0?0:1);return react.useEffect(()=>{if(e<=0)return;let s=reactNative.Animated.timing(o,{toValue:1,duration:e,easing:Yb,useNativeDriver:true}),a=n>0?reactNative.Animated.sequence([reactNative.Animated.delay(n),s]):s;return a.start(),()=>a.stop()},[o,e,n]),react.useMemo(()=>({opacity:o,transform:[{translateY:o.interpolate({inputRange:[0,1],outputRange:[r,0]})}]}),[o,r])}i(Ct,"useFadeIn");function mi({visible:e,inMs:t,outMs:r,style:n,children:o}){let[s,a]=react.useState(e),l=fi(e&&t<=0?1:0);return react.useEffect(()=>{if(e){a(true);let d=reactNative.Animated.timing(l,{toValue:1,duration:Math.max(0,t),easing:ui,useNativeDriver:true});return d.start(),()=>d.stop()}if(!s)return;if(r<=0){a(false);return}let u=reactNative.Animated.timing(l,{toValue:0,duration:r,easing:ui,useNativeDriver:true});return u.start(({finished:d})=>{d&&a(false);}),()=>u.stop()},[e,s,t,r,l]),!s&&!e?null:jsxRuntime.jsx(reactNative.Animated.View,{style:[n,{opacity:l}],children:o})}i(mi,"FadePresence");var Xb=12;function B({style:e,containerStyle:t,children:r,onPressIn:n,onPressOut:o,hitSlop:s,...a}){let l=X(),u=fi(1),d=react.useCallback(c=>{l.pressMs<=0||l.pressScale===1||reactNative.Animated.timing(u,{toValue:c,duration:l.pressMs,easing:ui,useNativeDriver:true}).start();},[u,l.pressMs,l.pressScale]);return jsxRuntime.jsx(reactNative.Pressable,{...a,hitSlop:s??Xb,style:t,onPressIn:c=>{d(l.pressScale),n?.(c);},onPressOut:c=>{d(1),o?.(c);},children:jsxRuntime.jsx(reactNative.Animated.View,{style:[e,{transform:[{scale:u}]}],children:r})})}i(B,"PressScale");function wd(e,t,r){let n=t&&r.revealTickMs>0,[o,s]=react.useState(0),a=react.useRef(e);return a.current=e,react.useEffect(()=>{if(!n)return;let l=setInterval(()=>{s(u=>Td(r,u,a.current.length));},r.revealTickMs);return ()=>clearInterval(l)},[n,r]),n?e.slice(0,Math.min(o,e.length)):e}i(wd,"useRevealedText");var xd=false;function Qb(e){e.layoutMs<=0||(xd||(xd=true,reactNative.Platform.OS==="android"&&typeof reactNative.UIManager.setLayoutAnimationEnabledExperimental=="function"&&reactNative.UIManager.setLayoutAnimationEnabledExperimental(true)),reactNative.LayoutAnimation.configureNext({duration:e.layoutMs,create:{type:"easeInEaseOut",property:"opacity"},update:{type:"easeInEaseOut"},delete:{type:"easeInEaseOut",property:"opacity"}}));}i(Qb,"animateLayout");function Cr(e,t){let r=react.useRef(e);r.current!==e&&(r.current=e,Qb(t));}i(Cr,"useAnimateLayoutOn");var yi=36,ov=22,iv=12,sv=12,av=16,lv="#000",uv="rgba(0,0,0,0.45)";function Id({uri:e,label:t,onClose:r}){let n=O(),o=reactNativeSafeAreaContext.useSafeAreaInsets();return e===null?null:jsxRuntime.jsxs(reactNative.Modal,{visible:true,animationType:n.motion.reducedMotion?"none":"fade",transparent:false,statusBarTranslucent:true,onRequestClose:r,children:[jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:h.closePreview,style:En.backdrop,onPress:r,children:jsxRuntime.jsx(reactNative.Image,{source:{uri:e},style:En.image,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,accessibilityIgnoresInvertColors:true})}),jsxRuntime.jsx(reactNative.View,{pointerEvents:"box-none",style:[En.closeWrap,{top:o.top+sv}],children:jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:h.closePreview,hitSlop:iv,style:En.closeButton,onPress:r,children:jsxRuntime.jsx(Et,{size:ov,color:n.color.surface,strokeWidth:2})})})]})}i(Id,"AttachmentImageLightbox");var En=reactNative.StyleSheet.create({backdrop:{flex:1,backgroundColor:lv,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"},closeWrap:{position:"absolute",right:av},closeButton:{width:yi,height:yi,borderRadius:yi/2,backgroundColor:uv,alignItems:"center",justifyContent:"center"}});var Cn=12,mv=80,gi=44,Ad=22,yv=.14,gv=18,hv=8,Od=Object.freeze({photo:h.attachmentPhoto,camera:h.attachmentCamera});function Fd({sources:e,full:t,onPick:r,onClose:n}){let o=O(),s=react.useMemo(()=>bv(o),[o]);return jsxRuntime.jsxs(reactNative.View,{style:s.anchor,pointerEvents:"box-none",children:[jsxRuntime.jsx(reactNative.Pressable,{style:s.dismissLayer,accessibilityRole:"button",accessibilityLabel:h.closeAttachmentPicker,onPress:n}),jsxRuntime.jsxs(reactNative.View,{style:s.bubble,children:[jsxRuntime.jsx(reactNative.View,{style:s.tilesRow,children:e.map(a=>jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:Od[a],accessibilityState:{disabled:t},disabled:t,containerStyle:s.tile,style:s.tileInner,onPress:()=>r(a),children:[jsxRuntime.jsx(reactNative.View,{style:s.tileIconWrap,children:a==="photo"?jsxRuntime.jsx(yd,{size:Ad,color:o.color.brandInk,strokeWidth:1.5}):jsxRuntime.jsx(gd,{size:Ad,color:o.color.brandInk,strokeWidth:1.5})}),jsxRuntime.jsx(C,{tier:"control",style:s.tileLabel,children:Od[a]})]},a))}),jsxRuntime.jsx(reactNative.View,{style:s.tail}),jsxRuntime.jsx(reactNative.View,{style:s.tailFill})]})]})}i(Fd,"AttachmentPickerPopover");function bv(e){let t=e.color,r=e.radius;return reactNative.StyleSheet.create({anchor:{position:"absolute",left:0,right:0,bottom:"100%",paddingHorizontal:8,paddingBottom:10,alignItems:"flex-start"},dismissLayer:{position:"absolute",left:-1e3,right:-1e3,top:-2e3,bottom:0},bubble:{backgroundColor:t.surfaceCream,borderRadius:r.lg,borderWidth:1,borderColor:t.brandBorderStrong,paddingHorizontal:6,paddingVertical:8,shadowColor:t.shadow,shadowOpacity:yv,shadowRadius:gv,shadowOffset:{width:0,height:hv},elevation:8},tilesRow:{flexDirection:"row",alignItems:"stretch"},tile:{minWidth:mv,borderRadius:r.md},tileInner:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:10,paddingVertical:8,gap:6},tileIconWrap:{width:gi,height:gi,borderRadius:gi/2,backgroundColor:t.brandSoft,alignItems:"center",justifyContent:"center"},tileLabel:{...S(e,"medium"),fontSize:12,lineHeight:14,color:t.text.primary},tail:{position:"absolute",left:24,bottom:-Cn/2,width:Cn,height:Cn,backgroundColor:t.surfaceCream,borderRightWidth:1,borderBottomWidth:1,borderColor:t.brandBorderStrong,transform:[{rotate:"45deg"}]},tailFill:{position:"absolute",left:22,bottom:0,width:Cn+4,height:2,backgroundColor:t.surfaceCream}})}i(bv,"makeStyles");var Se=Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});var Ld=56,Dd=12,Cv=14,Rv=10,Sv=.45,Tv="rgba(7,193,104,0.55)",Pv="rgba(185,28,28,0.55)",kv=200,xv=300,Wd=20,bi=22,_v=12,wv="rgba(0,0,0,0.78)",Nd=220,Ud=100,Vd="rgba(255,255,255,0.15)";function Gd({attachments:e,rejected:t,uploadFailed:r=false,onRetry:n,onRemove:o,onPreview:s}){let a=O(),l=react.useMemo(()=>qd(a),[a]);return e.length===0&&t===null?null:jsxRuntime.jsxs(reactNative.View,{style:l.strip,children:[e.length>0?jsxRuntime.jsx(reactNative.View,{style:l.cards,children:e.map(u=>jsxRuntime.jsx(Iv,{row:u,styles:l,onRetry:n,onRemove:o,onPreview:s},u.id))}):null,r?jsxRuntime.jsx(C,{style:l.rejected,accessibilityRole:"alert",children:h.attachmentsFailedBlocked}):null,t!==null?jsxRuntime.jsx(C,{style:l.rejected,accessibilityRole:"alert",children:ku(t)}):null]})}i(Gd,"AttachmentStrip");function Iv({row:e,styles:t,onRetry:r,onRemove:n,onPreview:o}){let s=O(),a=e.status==="uploading",l=e.status==="failed",u=e.status==="uploaded",d=react.useRef(e.status),[c,p]=react.useState(false);return react.useEffect(()=>{let f=d.current;d.current=e.status,e.status==="uploaded"&&f==="uploading"&&p(true);},[e.status]),jsxRuntime.jsxs(reactNative.View,{style:t.card,children:[jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:u?"button":"image",accessibilityLabel:u?K(h.previewAttachment,{filename:e.filename}):e.filename,accessibilityState:{busy:a,disabled:!u},disabled:!u,style:t.thumbHit,onPress:()=>o(e),children:jsxRuntime.jsxs(reactNative.View,{style:t.thumb,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:e.previewUri},style:t.thumbImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true}),a?jsxRuntime.jsx(reactNative.View,{style:t.uploadingOverlay,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:s.color.surface})}):null,c?jsxRuntime.jsx(Av,{styles:t,onDone:()=>p(false)}):null]})}),l?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:K(h.retryUpload,{filename:e.filename}),style:t.failedOverlay,onPress:()=>r(e.id),children:jsxRuntime.jsx(reactNative.View,{style:t.failedInner,children:jsxRuntime.jsx(Et,{size:Wd,color:s.color.surface,strokeWidth:2})})}):null,jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:K(h.removeAttachment,{filename:e.filename}),hitSlop:6,containerStyle:t.removeSlot,style:t.removeButton,onPress:()=>n(e.id),children:jsxRuntime.jsx(Et,{size:_v,color:s.color.surface,strokeWidth:1.5})})]})}i(Iv,"PreviewCard");function Av({styles:e,onDone:t}){let r=O(),n=X(),o=react.useRef(null);o.current===null&&(o.current=new reactNative.Animated.Value(0));let s=o.current;return react.useEffect(()=>{let a=reactNative.Animated.sequence([reactNative.Animated.timing(s,{toValue:1,duration:kv,useNativeDriver:true}),reactNative.Animated.delay(n.uploadFlashMs),reactNative.Animated.timing(s,{toValue:0,duration:xv,useNativeDriver:true})]);return a.start(({finished:l})=>{l&&t();}),()=>a.stop()},[s,n.uploadFlashMs,t]),jsxRuntime.jsx(reactNative.Animated.View,{pointerEvents:"none",style:[e.successOverlay,{opacity:s}],children:jsxRuntime.jsx(rt,{size:Wd,color:r.color.surface,strokeWidth:2})})}i(Av,"SuccessFlash");function Kd({images:e,onPreview:t}){let r=O(),n=react.useMemo(()=>qd(r),[r]);if(e.length===0)return null;let o=e.length===1;return jsxRuntime.jsx(reactNative.View,{style:o?n.sentSingle:n.sentGrid,children:e.map((s,a)=>jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:K(h.attachedImage,{filename:s.filename}),onPress:()=>t(s),children:jsxRuntime.jsx(reactNative.Image,{source:{uri:s.uri},style:o?n.singleImage:n.gridImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true})},`${s.uri}-${a}`))})}i(Kd,"SentImages");function qd(e){let t=e.color,r=e.type;return reactNative.StyleSheet.create({strip:{gap:6,paddingBottom:8},cards:{flexDirection:"row",flexWrap:"wrap",gap:8},card:{width:Ld,height:Ld,overflow:"visible"},thumbHit:{width:"100%",height:"100%"},thumb:{width:"100%",height:"100%",borderRadius:Dd,overflow:"hidden",backgroundColor:t.composerFill,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},thumbImage:{width:"100%",height:"100%"},uploadingOverlay:{...Se,alignItems:"center",justifyContent:"center",backgroundColor:nl(e.color.brandInk,Sv)??e.color.brandSofter},successOverlay:{...Se,alignItems:"center",justifyContent:"center",backgroundColor:Tv},failedOverlay:{...Se,borderRadius:Dd,overflow:"hidden"},failedInner:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:Pv},removeSlot:{position:"absolute",top:4,right:4},removeButton:{width:bi,height:bi,borderRadius:bi/2,backgroundColor:wv,borderWidth:1.5,borderColor:t.surface,alignItems:"center",justifyContent:"center"},rejected:{...S(e,"regular"),fontSize:r.size.caption,lineHeight:r.size.caption*r.lineHeight.normal,color:t.danger},sentSingle:{marginBottom:6},sentGrid:{flexDirection:"row",flexWrap:"wrap",gap:6,marginBottom:6},singleImage:{width:Nd,height:Nd,borderRadius:Cv,backgroundColor:Vd},gridImage:{width:Ud,height:Ud,borderRadius:Rv,backgroundColor:Vd}})}i(qd,"makeStyles");var Ov="chat attachment upload: the file handle has no uri",Fv="chat attachment upload failed";function Mv(e){return {uri:e.uri,name:ho(e.name),type:e.mimeType}}i(Mv,"filePartOf");function $d(e={}){return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(Ov));let{signal:o,onProgress:s}=n,a=i(()=>Promise.reject(new Error(Fv)),"failed");return o?.aborted===true?a():Vr({url:t.upload_url,fields:t.upload_fields,file:Mv(r),signal:o,fetch:e.fetch}).then(l=>{if(!l)return a();s?.(1);},a)}})}i($d,"createRnChatAttachmentTransport");function Rn(){let{runtime:e,userRef:t,activePet:r,scopeEpoch:n}=Y(),o=react.useMemo(()=>Ze(e.registry.services.authFor(t)),[e,t,n]),[s,a]=react.useState({repository:o,pets:[],loading:true,error:null}),l=s.repository===o?s:{pets:[],loading:true,error:null},u=react.useRef(0),d=react.useCallback(async()=>{let p=++u.current;a(y=>({...y,repository:o,loading:true,error:null,pets:y.repository===o?y.pets:[]}));let f=await o.list();p===u.current&&a(f.ok?{repository:o,pets:f.value,loading:false,error:null}:y=>({repository:o,pets:y.repository===o?y.pets:[],loading:false,error:f.error}));},[o]);react.useEffect(()=>(d(),()=>{u.current+=1;}),[d]);let c=react.useMemo(()=>r===null?null:l.pets.find(p=>p.petRef===r)??null,[r,l.pets]);return react.useMemo(()=>({pets:l.pets,activePet:c,loading:l.loading,error:l.error,refresh:d}),[l.pets,l.loading,l.error,c,d])}i(Rn,"useEverfurPets");function Yd(e,t){if(t!==null){let r=e.find(n=>n.petRef===t);if(r!==void 0)return r}return e[0]??null}i(Yd,"headerPetOf");function me(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(me,"slotBox");function Ri(e){return e===void 0||e.backgroundColor!==void 0?e:e.borderRadius===void 0?void 0:{borderRadius:e.borderRadius}}i(Ri,"ownGroundSlot");function Ie(e){return e?.textColor===void 0?{}:{color:e.textColor}}i(Ie,"slotText");var Xd=Object.freeze({visitButton:"Talk to a vet"});var Qd=Symbol.for("@everfur/sdk/televet");function Ke(){let e=globalThis,t=e[Qd];if(t!==void 0)return t;let r={presenter:null,snapshot:Object.freeze({request:null,serial:0,activeHost:null}),hosts:[],nextHost:1,listeners:new Set,dailyRegistered:false};return e[Qd]=r,r}i(Ke,"televetGlobal");function Sn(e){let t=Ke();t.snapshot=Object.freeze({...t.snapshot,...e});for(let r of [...t.listeners])try{r();}catch{}}i(Sn,"publish");function Zd(e){let t=Ke().presenter;if(t===null)return "absent";try{return t(e)===!1?"declined":"presented"}catch(r){return console.warn("[everfur] Your registerEverfurTelevetFlow presenter threw; the in-app visit opened instead.",r),"threw"}}i(Zd,"callTelevetPresenter");function Jd(e){let t=Ke();return t.listeners.add(e),()=>{t.listeners.delete(e);}}i(Jd,"subscribeTelevetExperience");function Si(){return Ke().snapshot}i(Si,"televetExperienceSnapshot");function Vv(){return Ke().hosts.length>0}i(Vv,"hasTelevetHost");function ec(e){if(!Vv())return false;let t=Object.freeze({...e});return Sn({request:t,serial:Ke().snapshot.serial+1}),true}i(ec,"presentTelevetExperience");function Ti(){Ke().snapshot.request!==null&&Sn({request:null});}i(Ti,"dismissTelevetExperience");function tc(){let e=Ke(),t=e.nextHost;return e.nextHost+=1,e.hosts=[...e.hosts,t],Sn({activeHost:e.hosts[0]??null}),t}i(tc,"claimTelevetHost");function rc(e){let t=Ke();t.hosts=t.hosts.filter(n=>n!==e);let r=t.hosts[0]??null;Sn(r===null?{activeHost:r,request:null}:{activeHost:r});}i(rc,"releaseTelevetHost");var nc=false;function Tn(e,t){return t!==void 0?(q(t,e),"onStartInApp"):Zd(e)==="presented"?"presenter":ec(e)?"experience":(nc||(nc=true,console.warn("[everfur] A vet visit had nowhere to open: mount <EverfurTelevetHost /> in your EverfurProvider, or pass prefer: 'redirect'.")),null)}i(Tn,"openVetVisitInApp");function sc(e){let t=null;return ()=>{if(t!==null)return t;let r=e();return t=r,r.then(void 0,()=>{t===r&&(t=null);}),r}}i(sc,"memoizeTelevetLoader");function ac(e){let[t,r]=react.useState(null);react.useEffect(()=>{let d=tc();return r(d),()=>{rc(d);}},[]);let n=react.useSyncExternalStore(Jd,Si,Si),s=t!==null&&n.activeHost===t?n.request:null,[a,l]=react.useState(null),u=s!==null&&a===null;return react.useEffect(()=>{if(!u)return;let d=true;return e().then(c=>{d&&l(()=>c);},c=>{d&&(console.warn("[everfur] The in-app vet visit could not load its screens.",c),Ti());}),()=>{d=false;}},[u,e]),s===null||a===null?null:{module:a,request:s,serial:n.serial,dismiss:Ti}}i(ac,"useTelevetExperienceHost");var Bv=sc(()=>import('@everfur/sdk/televet/booking'));function Sr(){let e=ac(Bv);if(e===null)return null;let{EverfurTelevetModal:t}=e.module;return jsxRuntime.jsx(t,{request:e.request,onClose:e.dismiss},e.serial)}i(Sr,"EverfurTelevetHost");var Pi=Object.freeze(["visit","join","summary","messages"]);function ki(e){return typeof e=="string"&&Pi.includes(e)}i(ki,"isVetVisitIntent");var jv="/widget/v1/televet/handoffs",Wv="/widget/v1/televet/availability",Gv="/widget/v1/televet/chat-entry",Kv=/^[a-z0-9][a-z0-9_-]{0,39}$/,qv=/^[A-Za-z0-9_-]{22}$/;var lc=32,uc=128,dc=64;function _i(e){let t=e.httpStatus;switch(e.code){case "sessionRequired":return "sessionRequired";case "authExpired":case "authRejected":return "authRejected";case "sdkUpdateRequired":return "sdkUpdateRequired";case "validationFailed":return "invalidRequest";case "rateLimited":case "quotaExceeded":return "rateLimited";}return t===void 0?e.code==="internalError"?"network":"unknown":t===429?"rateLimited":t===404?"unavailable":t===403?"accessDenied":t===401?"authRejected":t===400||t===422?"invalidRequest":t>=500?"serverError":"unknown"}i(_i,"vetVisitErrorReasonOf");function cc(e){return v(D("validationFailed",{retryable:false,wireMessage:e}))}i(cc,"invalid");function xi(e){return v(D("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}i(xi,"unusable");function $v(e,t){let r={};e!==void 0&&(r.pet_ref=e);let n=t?.returnTo;if(n!=null){if(typeof n!="string"||!Kv.test(n))return {ok:false,message:"returnTo must be a registered return destination key"};r.return_to=n;}let o=t?.entry;if(o!=null){if(o!=="chat"||e===void 0)return {ok:false,message:"entry 'chat' needs the pet the chat is about"};r.entry=o;}let s=t?.visitRef,a=t?.intent,l=s!=null;if(l){let u=typeof s=="string"?s.trim():"";if(u.length<1||[...u].length>dc)return {ok:false,message:`visitRef must be 1..${dc} characters`};r.visit_ref=u;}if(a!=null){if(!l)return {ok:false,message:"intent needs the visitRef it opens"};if(!ki(a))return {ok:false,message:`intent must be one of ${Pi.join(", ")}`};r.intent=a;}return {ok:true,body:r}}i($v,"handoffBody");function Yv(e){if(typeof e!="object"||e===null)return null;let{visit_ref:t,intent:r}=e;return typeof t!="string"||t.length===0||!ki(r)?null:Object.freeze({visitRef:t,intent:r})}i(Yv,"parseVisitEcho");function fc(e){let t=e.funnel??xe({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e.telemetry,n=i(o=>(pc(r,"televet.visit.handoff_failed",{reason:_i(o)}),v(o)),"failed");return {async createHandoff(o,s){let a;if(o!=null){let b=typeof o=="string"?[...o].length:0;if(b<1||b>uc)return n(D("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${uc} characters`}));a=o;}let l=$v(a,s);if(!l.ok){let b=cc(l.message);return b.ok?b:n(b.error)}let u=l.body,d=await t.send("televet.visit.handoff",{method:"POST",path:jv,body:u},{idempotent:false,maxAttempts:1});if(!d.ok)return n(d.error);let c=Xv(d.value),p=u.return_to!==void 0,f=p?d.value?.flow_id:void 0;if(p&&(typeof f!="string"||!qv.test(f))){let b=xi("the handoff response carried no usable return flow id");return b.ok?b:n(b.error)}let y=u.visit_ref!==void 0,m=y?Yv(d.value?.visit):null;if(y&&m===null){let b=xi("the handoff response did not confirm the visit it opens");return b.ok?b:n(b.error)}let w=c===null?null:Object.freeze({...c,...p?{flowId:f}:{},...m!==null?{visit:m}:{}});return w===null?n(D("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(pc(r,"televet.visit.handoff_created",{pet_scoped:u.pet_ref!==void 0}),L(w))},async checkAvailability(o){if(typeof o!="string"||o.length>lc)return cc(`state must be at most ${lc} characters`);let s=await t.send("televet.visit.availability",{method:"POST",path:Wv,body:{state:o}},{idempotent:false,maxAttempts:1});if(!s.ok)return v(s.error);let a=s.value?.available;return typeof a!="boolean"?xi("the availability response carried no usable answer"):L(Object.freeze({available:a}))},async chatEntryOpen(){try{let o=await t.send("televet.visit.chat_entry",{method:"GET",path:Gv},{maxAttempts:1});return o.ok&&o.value?.open===!0}catch{return false}}}}i(fc,"createVetVisitController");function Xv(e){if(typeof e!="object"||e===null)return null;let{url:t,expires_at:r}=e;return typeof t!="string"||typeof r!="string"||r.length===0||!eE(t)?null:Object.freeze({url:t,expiresAt:r})}i(Xv,"parseHandoff");var Qv=new Set(["localhost","127.0.0.1","[::1]"]),Zv=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,Jv=/[\s\u0000-\u001f\u007f]/;function eE(e){if(Jv.test(e))return false;let t=Zv.exec(e);if(t===null)return false;let r=(t[1]??"").toLowerCase(),n=t[2]??"";if(n.length===0||n.includes("@"))return false;let o=n.replace(/:\d+$/,"").toLowerCase(),s=r==="https",a=r==="http"&&Qv.has(o);if(!s&&!a)return false;let l=e.indexOf("#");if(l<0)return false;let u=e.slice(l);return u.startsWith("#h=")&&u.length>3}i(eE,"isOpenableVisitUrl");function pc(e,t,r){if(e)try{e.track(t,r);}catch{}}i(pc,"safeTrack");var wi=Object.freeze({status:"idle",error:null,errorReason:null});function rE(e,t,r){let{usState:n,chat:o,scope:s}=r,a=t&&(n!==null||o),l=`${n??""}|${o?"chat":""}`,[u,d]=react.useState(null);if(react.useEffect(()=>{if(!a)return;let p=true,f=e.current;return d(null),i(async()=>{try{if(o&&!(f.chatEntryOpen&&await f.chatEntryOpen()))return !1;if(n===null)return !0;if(!f.checkAvailability)return !1;let m=await f.checkAvailability(n);return m.ok&&m.value.available}catch{return false}},"ask")().then(m=>{p&&d({key:l,open:m});}),()=>{p=false;}},[a,l,n,o,s,e]),!a)return null;let c=u!==null&&u.key===l;return {open:c&&u.open,pending:!c}}i(rE,"usePreflight");var nE=Object.freeze({status:"opening",error:null,errorReason:null});function gc(e,t={}){let{runtime:r,userRef:n,scopeEpoch:o}=Y(),s=Nt("televet"),a=s.enabled&&n!==null,l=t.usState??null,u=t.entry==="chat",d=t.petRef??null,c=t.prefer==="redirect",p=react.useMemo(()=>{if(t.controller)return t.controller;let{services:T}=r.registry;return fc({auth:T.authFor(n),telemetry:T.telemetry,...T.errorPolicy?{errorPolicy:T.errorPolicy}:{}})},[r,n,o,t.controller]),f=react.useRef(p);f.current=p;let y=react.useMemo(()=>({runtime:r,userRef:n,scopeEpoch:o}),[r,n,o]),m=rE(f,a,{usState:l,chat:u,scope:y}),w=a&&(m===null||m.open)&&(!u||d!==null),b=t.returnTo??null,[R,I]=react.useState(wi),P=react.useRef(null),x=react.useRef({runtime:r,userRef:n,scopeEpoch:o});x.current={runtime:r,userRef:n,scopeEpoch:o};let g=react.useRef(p);g.current=p;let _=react.useRef(w);_.current=w;let F=react.useCallback((T,V)=>{if(P.current)return P.current;let j=i((ce,it)=>(I({status:ce==="cancelled"?"idle":"error",error:it,errorReason:ce==="cancelled"?null:ce}),Object.freeze({opened:false,reason:ce,error:it})),"fail");if(!_.current)return Promise.resolve(j("unavailable",null));let G=e.prepare();if(!G.ok)return Promise.resolve(j(G.reason,null));let ne=x.current,de=g.current;I(nE);let Yt=(async()=>{let ce,it={...b!==null?{returnTo:b}:{},...u?{entry:"chat"}:{},...V!==null?{visitRef:V.visitRef}:{},...V!==null&&V.intent!==null&&V.intent!==void 0?{intent:V.intent}:{}},Ar=Object.keys(it).length===0?void 0:it,Xt=T===void 0?d:T;try{ce=await(Ar===void 0?de.createHandoff(Xt):de.createHandoff(Xt,Ar));}catch{return e.abandon(G.value),j("unknown",null)}let It=x.current;if(It.runtime!==ne.runtime||It.userRef!==ne.userRef||It.scopeEpoch!==ne.scopeEpoch)return e.abandon(G.value),j("cancelled",null);if(!ce.ok)return e.abandon(G.value),j(_i(ce.error),ce.error);let At=await e.finish(G.value,ce.value);return At!==null?j(At,null):(I(wi),Object.freeze(ce.value.flowId===void 0?{opened:true}:{opened:true,flowId:ce.value.flowId}))})().finally(()=>{P.current===Yt&&(P.current=null);});return P.current=Yt,Yt},[e,d,b,u]),M=react.useCallback((T,V)=>{if(!_.current)return I({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(Object.freeze({opened:false,reason:"unavailable",error:null}));let j=T===void 0?d:T,G={...j!==null?{petRef:j}:{},...l!==null?{usState:l}:{},...V!==null?{visitRef:V.visitRef,intent:V.intent}:{}};return Tn(G)===null?(I({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(Object.freeze({opened:false,reason:"unavailable",error:null}))):(I(wi),Promise.resolve(Object.freeze({opened:true})))},[d,l]),E=react.useCallback(T=>c?F(T,null):M(T,null),[c,F,M]),k=react.useCallback((T,V)=>c?F(void 0,{visitRef:T,intent:V??null}):M(void 0,{visitRef:T,intent:V??null}),[c,F,M]);return {available:w,isPending:s.isPending||(m?.pending??false),status:R.status,error:R.error,errorReason:R.errorReason,open:E,openVisit:k}}i(gc,"useVetVisitWith");var sE=i(e=>reactNative.Linking.openURL(e),"defaultOpenUrl");function kn(e={}){let{openUrl:t,...r}=e,n=react.useMemo(()=>{let o=t??sE;return {prepare:i(()=>({ok:true,value:null}),"prepare"),async finish(s,a){try{return await o(a.url),null}catch{return "openFailed"}},abandon:i(()=>{},"abandon")}},[t]);return gc(n,r)}i(kn,"useVetVisit");var hc=44,cE=.6;function jt(e){let{petRef:t,label:r,openUrl:n,onOpened:o,onError:s,style:a,labelStyle:l,controller:u,returnTo:d,usState:c,entry:p,visitRef:f,intent:y,onStartInApp:m,prefer:w}=e,b=w==="redirect",R=kn({...d!==void 0?{returnTo:d}:{},...c!==void 0?{usState:c}:{},...p!==void 0?{entry:p}:{},...t!==void 0?{petRef:t}:{},...n!==void 0?{openUrl:n}:{},...u!==void 0?{controller:u}:{},prefer:b?"redirect":"in-app"}),I=O(),P=react.useMemo(()=>pE(I),[I]),x=react.useRef(false);if(!R.available)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[null,jsxRuntime.jsx(Sr,{})]});let g=R.status==="opening",_=r??Xd.visitButton;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactNative.Pressable,{onPress:i(()=>{if(!(g||x.current)){if(!b){let M={...t!==void 0?{petRef:t}:{},...c!==void 0?{usState:c}:{},...f!=null?{visitRef:f,intent:y??null}:{}};Tn(M,m)===null&&q(s,"unavailable",null);return}x.current=true,(f==null?R.open():R.openVisit(f,y??null)).then(M=>{M.opened?q(o,M.flowId??null):M.reason!=="cancelled"&&q(s,M.reason,M.error);}).finally(()=>{x.current=false;});}},"onPress"),accessibilityRole:"button",accessibilityLabel:_,accessibilityState:{busy:g,disabled:g},style:[P.button,g?P.busy:null,a],children:jsxRuntime.jsx(C,{style:[P.label,l],children:_})}),jsxRuntime.jsx(Sr,{})]})}i(jt,"VetVisitButton");function pE(e){let{color:t,space:r,radius:n,type:o,slots:s}=e;return reactNative.StyleSheet.create({button:{minHeight:hc,minWidth:hc,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.primary,...me(s.vetVisitButton)},busy:{opacity:cE},label:{...S(e,"medium"),color:t.onPrimary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.snug,...Ie(s.vetVisitButton)}})}i(pE,"makeStyles");function Ii(e){return dr(e)==="cat"?"cat":"dog"}i(Ii,"speciesOf");function Ai(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:Math.floor(e)}i(Ai,"petAgeYears");function Cc(e){let t=Ai(e.ageYears),r=Ii(e.species)==="cat"?"Cat":"Dog";if(t==null)return r;let n=t===1?"1 yr":`${t} yrs`;return `${r} \xB7 ${n}`}i(Cc,"formatPetMeta");var Ec=Object.freeze([Object.freeze({background:"#ffbdbd",foreground:"#6d1d14"}),Object.freeze({background:"#a0c4f6",foreground:"#0b3a73"}),Object.freeze({background:"#fbc558",foreground:"#10462e"}),Object.freeze({background:"#bde7c5",foreground:"#0e3b22"}),Object.freeze({background:"#dcc7f4",foreground:"#3a1d6a"}),Object.freeze({background:"#ffd8a8",foreground:"#5a2a04"})]);function fE(e){let t=0;for(let r=0;r<e.length;r+=1)t=t*31+e.charCodeAt(r)>>>0;return Ec[t%Ec.length]}i(fE,"pickInitialsPalette");function Oi(e){let t=(e??"").trim();return (Array.from(t)[0]??"?").toUpperCase()}i(Oi,"getInitial");function Rc(e){return {...fE(e.petRef),initial:Oi(e.name)}}i(Rc,"petInitials");function hE(e){return Math.max(12,Math.round(e*.42))}i(hE,"letterSize");function Pr({pet:e,size:t,ringStroke:r}){let n=O(),o=react.useMemo(()=>bE(n),[n]),s=t-r*2,a=e===null?null:Rc(e),l=hE(s);return jsxRuntime.jsx(hn,{size:t,strokeWidth:r,color:n.color.success,children:jsxRuntime.jsx(reactNative.View,{style:[o.disc,{width:s,height:s,borderRadius:s/2},a===null?o.discEmpty:{backgroundColor:a.background}],children:jsxRuntime.jsx(C,{tier:"badge",style:[o.letter,{fontSize:l,lineHeight:Math.round(l*1.2),color:a===null?n.color.text.muted:a.foreground}],children:a===null?Oi(null):a.initial})})})}i(Pr,"PetDisc");function bE(e){return reactNative.StyleSheet.create({disc:{alignItems:"center",justifyContent:"center",overflow:"hidden"},discEmpty:{backgroundColor:e.color.brandSoft},letter:{...S(e,"bold"),textAlign:"center",includeFontPadding:false}})}i(bE,"makeStyles");var Mi=48,Pc=2,TE=320,PE="80%",kE="rgba(17,17,17,0.45)",xE=18,Sc=22,_E=12,Tc=.4,wE=44;function Li(e){return e?.name?.trim()||h.yourPet}i(Li,"petDisplayName");function kc({visible:e,pets:t,activePetRef:r,onSelect:n,onAddPet:o=null,onClose:s}){let a=O(),l=react.useMemo(()=>IE(a),[a]);return e?jsxRuntime.jsx(reactNative.Modal,{visible:true,transparent:true,animationType:a.motion.reducedMotion?"none":"fade",onRequestClose:s,children:jsxRuntime.jsxs(reactNative.View,{style:l.root,children:[jsxRuntime.jsx(reactNative.Pressable,{style:Se,onPress:s,accessibilityRole:"button",accessibilityLabel:h.close,children:jsxRuntime.jsx(reactNative.View,{style:l.backdrop})}),jsxRuntime.jsxs(reactNative.View,{style:l.panel,accessibilityViewIsModal:true,children:[jsxRuntime.jsx(C,{tier:"heading",style:l.title,accessibilityRole:"header",children:h.yourPets}),jsxRuntime.jsx(reactNative.ScrollView,{style:l.list,contentContainerStyle:l.listContent,showsVerticalScrollIndicator:true,children:t.map(u=>{let d=u.petRef===r,c=Li(u),p=Cc(u);return jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:K(d?h.petCurrentlyActive:h.switchToPet,{name:c}),accessibilityState:{selected:d},style:[l.row,d?l.rowActive:null],onPress:()=>n(u.petRef),children:[jsxRuntime.jsx(Pr,{pet:u,size:Mi,ringStroke:Pc}),jsxRuntime.jsxs(reactNative.View,{style:l.copy,children:[jsxRuntime.jsx(C,{style:l.name,numberOfLines:1,children:c}),jsxRuntime.jsx(C,{tier:"compact",style:l.meta,numberOfLines:1,children:d?`${h.activePrefix}${p}`:p})]}),d?jsxRuntime.jsx(rt,{size:xE,color:a.color.brandInk}):null]},u.petRef)})}),o!==null?jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:h.addAnotherPet,style:l.addRow,onPress:o,children:[jsxRuntime.jsx(reactNative.View,{style:l.addDisc,children:jsxRuntime.jsx(C,{tier:"control",style:l.addPlus,children:"+"})}),jsxRuntime.jsx(C,{style:l.addLabel,children:h.addAnotherPet})]}):null,jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:h.close,containerStyle:l.closeSlot,style:l.closeButton,onPress:s,children:jsxRuntime.jsx(C,{tier:"control",style:l.closeText,children:h.close})})]})]})}):null}i(kc,"PetSwitcherSheet");function IE(e){let t=e.color,r=e.radius;return reactNative.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{flex:1,backgroundColor:kE},panel:{backgroundColor:t.surface,paddingHorizontal:20,paddingTop:20,paddingBottom:32,borderTopLeftRadius:Sc,borderTopRightRadius:Sc,gap:14,maxHeight:PE},title:{...S(e,"bold"),fontSize:18,lineHeight:22,color:t.brandInk},list:{maxHeight:TE,flexShrink:1},listContent:{gap:10},addRow:{flexDirection:"row",alignItems:"center",gap:12,minHeight:wE,paddingHorizontal:8},addDisc:{width:Mi,height:Mi,borderRadius:r.pill,alignItems:"center",justifyContent:"center",borderWidth:Pc,borderStyle:"dashed",borderColor:t.brandBorder,backgroundColor:t.surfaceCream},addPlus:{...S(e,"bold"),fontSize:20,lineHeight:22,color:t.brandInk},addLabel:{...S(e,"bold"),fontSize:15,lineHeight:20,color:t.text.primary},row:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:r.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface},rowActive:{borderColor:t.brandInk,backgroundColor:t.brandSoft},copy:{flex:1,gap:2},name:{...S(e,"bold"),fontSize:15,lineHeight:18,color:t.text.primary},meta:{...S(e,"monoBold"),fontSize:11,lineHeight:13,color:t.text.muted,textTransform:"uppercase",letterSpacing:Tc},closeSlot:{alignSelf:"flex-end"},closeButton:{paddingHorizontal:18,paddingVertical:10,borderRadius:_E,backgroundColor:t.brandSoft},closeText:{...S(e,"bold"),color:t.brandInk,fontSize:13,lineHeight:16,letterSpacing:Tc}})}i(IE,"makeStyles");var FE=44,_n=36,ME=22,Di=9,LE=1.5,_c=6,St=35,wn=1.75,Ni=12.4,DE=.5,NE=8,UE=28,VE=160;function Vi(e,t){return Yd(e,t)}i(Vi,"headerPet");function Ic({pets:e,petRef:t,historyUnread:r,onOpenHistory:n,onPetChange:o,onAddPet:s,vet:a}){let l=O(),u=react.useMemo(()=>BE(l),[l]),[d,c]=react.useState(false),p=Vi(e.pets,t),f=e.pets.length>=2,y=t??p?.petRef??null,m=Li(p),w=i(R=>{c(false),e.setActivePet(R),q(o,R);},"select"),b=s===void 0?null:()=>{c(false),q(s);};return jsxRuntime.jsxs(reactNative.View,{style:u.row,children:[jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:r?h.openMenuUnread:h.openMenu,containerStyle:u.iconSlot,style:u.iconButton,onPress:n,children:[jsxRuntime.jsx(ad,{size:ME,color:l.color.text.primary,strokeWidth:2}),r?jsxRuntime.jsx(reactNative.View,{style:u.unreadDot,pointerEvents:"none"}):null]}),jsxRuntime.jsx(reactNative.View,{style:u.center,pointerEvents:"box-none",children:jsxRuntime.jsx(HE,{logoUrl:l.meta.logoUrl,name:l.meta.displayName,styles:u})}),y===null?null:jsxRuntime.jsx(jt,{entry:"chat",petRef:y,...a?.returnTo!==void 0?{returnTo:a.returnTo}:{},...a?.usState!==void 0?{usState:a.usState}:{},...a?.prefer!==void 0?{prefer:a.prefer}:{},style:u.vetEntry,labelStyle:u.vetEntryLabel}),jsxRuntime.jsx(reactNative.View,{style:u.right,children:f?jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:K(h.switchActivePet,{name:m}),containerStyle:u.avatarSlot,style:u.avatarWrap,onPress:()=>c(true),children:[jsxRuntime.jsx(Pr,{pet:p,size:St,ringStroke:wn}),jsxRuntime.jsx(reactNative.View,{style:u.addBadge,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:jsxRuntime.jsx(ud,{size:NE,color:l.color.brandInk,strokeWidth:2})})]}):e.loading&&p===null?jsxRuntime.jsx(reactNative.View,{style:u.avatarWrap,accessible:true,accessibilityLabel:h.yourPet,children:jsxRuntime.jsx(hn,{size:St,strokeWidth:wn,color:l.color.success,children:jsxRuntime.jsx(reactNative.View,{style:u.placeholderDisc})})}):jsxRuntime.jsx(reactNative.View,{style:u.avatarWrap,accessible:true,accessibilityRole:"image",accessibilityLabel:p===null?h.yourPet:m,children:jsxRuntime.jsx(Pr,{pet:p,size:St,ringStroke:wn})})}),jsxRuntime.jsx(kc,{visible:d,pets:e.pets,activePetRef:p?.petRef??null,onSelect:w,onAddPet:b,onClose:()=>c(false)})]})}i(Ic,"ChatHeader");function HE({logoUrl:e,name:t,styles:r}){let[n,o]=react.useState(null);return e===null||n===e?null:jsxRuntime.jsx(reactNative.View,{style:r.logoBar,children:jsxRuntime.jsx(reactNative.Image,{source:{uri:e},style:r.logo,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,onError:()=>o(e)})})}i(HE,"BrandLogo");function BE(e){let t=e.color,r=St-wn*2;return reactNative.StyleSheet.create({vetEntry:{minHeight:FE,justifyContent:"center",paddingHorizontal:12,borderRadius:e.radius.pill,backgroundColor:t.surfaceCream,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},vetEntryLabel:{...S(e,"bold"),color:t.brandInk,fontSize:e.type.size.caption},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingVertical:10,backgroundColor:t.surface},iconSlot:{borderRadius:_n/2},iconButton:{width:_n,height:_n,borderRadius:_n/2,alignItems:"center",justifyContent:"center"},unreadDot:{position:"absolute",top:_c,right:_c,width:Di,height:Di,borderRadius:Di,backgroundColor:t.danger,borderWidth:LE,borderColor:t.surface},center:{...Se,alignItems:"center",justifyContent:"center"},logoBar:{alignItems:"center",paddingHorizontal:e.space.lg},logo:{height:UE,width:VE},right:{alignItems:"flex-end"},avatarSlot:{borderRadius:St/2},avatarWrap:{width:St,height:St,position:"relative"},placeholderDisc:{width:r,height:r,borderRadius:r/2,backgroundColor:t.brandSoft},addBadge:{position:"absolute",bottom:0,right:0,width:Ni,height:Ni,borderRadius:Ni/2,borderWidth:DE,borderColor:t.success,backgroundColor:t.surface,alignItems:"center",justifyContent:"center"}})}i(BE,"makeStyles");var Fc=44,KE="rgba(17,17,17,0.55)",Mc=26,qE=36,Lc=4,Hi=20,Bi=38,$E=18,YE=12;function Dc({visible:e,onSubmit:t,onSkip:r}){let n=O(),o=react.useMemo(()=>XE(n),[n]),[s,a]=react.useState(null),[l,u]=react.useState(""),[d,c]=react.useState(false),[p,f]=react.useState(false),y=i(()=>{a(null),u(""),c(false),f(false);},"reset"),m=i(()=>{d||(y(),r());},"skip"),w=i(async()=>{if(d)return;c(true),f(false);let R=l.trim();await t(s,R.length>0?R:null)?y():(c(false),f(true));},"submit");if(!e)return null;let b=[...l].length>Mt;return jsxRuntime.jsx(reactNative.Modal,{visible:true,transparent:true,animationType:n.motion.reducedMotion?"none":"slide",onRequestClose:m,children:jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{behavior:reactNative.Platform.OS==="ios"?"padding":void 0,style:o.root,children:[jsxRuntime.jsx(reactNative.Pressable,{style:o.scrim,onPress:m,accessibilityRole:"button",accessibilityLabel:h.feedbackSkipA11y}),jsxRuntime.jsxs(reactNative.View,{style:o.sheet,accessibilityViewIsModal:true,accessibilityLiveRegion:"polite",children:[jsxRuntime.jsx(reactNative.View,{style:o.handle}),jsxRuntime.jsxs(reactNative.View,{style:o.header,children:[jsxRuntime.jsx(reactNative.View,{style:o.iconBadge,children:jsxRuntime.jsx(gn,{size:$E,color:n.color.brandInk,active:false,rotate:"180deg"})}),jsxRuntime.jsxs(reactNative.View,{style:o.headerText,children:[jsxRuntime.jsx(C,{tier:"heading",style:o.title,accessibilityRole:"header",children:h.feedbackTitle}),jsxRuntime.jsx(C,{style:o.subtitle,children:h.feedbackSubtitle})]})]}),jsxRuntime.jsx(reactNative.View,{style:o.options,children:Qo.map(R=>{let I=s===R.key;return jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:R.label,accessibilityState:{selected:I},style:[o.option,I?o.optionSelected:null],onPress:()=>a(P=>P===R.key?null:R.key),children:[jsxRuntime.jsx(C,{style:[o.optionLabel,I?o.optionLabelSelected:null],children:R.label}),jsxRuntime.jsx(reactNative.View,{style:[o.radio,I?o.radioSelected:null],children:I?jsxRuntime.jsx(rt,{size:YE,color:n.color.surface,strokeWidth:2}):null})]},R.key)})}),jsxRuntime.jsxs(reactNative.View,{style:o.inputWrap,children:[jsxRuntime.jsx(Ut,{style:o.input,placeholder:h.feedbackNotesPlaceholder,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:h.feedbackNotesPlaceholder,value:l,onChangeText:u,multiline:true,editable:!d}),l.length>0?jsxRuntime.jsx(C,{tier:"compact",style:[o.counter,b?o.counterOver:null],children:`${[...l].length}/${Mt}`}):null]}),p?jsxRuntime.jsx(C,{style:o.failed,accessibilityRole:"alert",children:h.feedbackFailed}):null,jsxRuntime.jsxs(reactNative.View,{style:o.actions,children:[jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:h.feedbackSubmit,accessibilityState:{busy:d,disabled:d||b},disabled:d||b,style:[o.submit,d||b?o.submitDisabled:null],onPress:()=>{w();},children:jsxRuntime.jsx(C,{tier:"control",style:o.submitLabel,children:h.feedbackSubmit})}),jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:h.feedbackSkipA11y,hitSlop:8,onPress:m,style:o.skip,children:jsxRuntime.jsx(C,{tier:"control",style:o.skipLabel,children:h.feedbackSkip})})]})]})]})})}i(Dc,"FeedbackReasons");function XE(e){let t=e.color,r=e.type,n=e.radius,o=e.slots;return reactNative.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},scrim:{...Se,backgroundColor:KE},sheet:{backgroundColor:t.surface,borderTopLeftRadius:Mc,borderTopRightRadius:Mc,paddingHorizontal:22,paddingTop:12,paddingBottom:34,gap:14},handle:{alignSelf:"center",width:qE,height:Lc,borderRadius:Lc/2,backgroundColor:t.brandBorder,marginBottom:2},header:{flexDirection:"row",alignItems:"center",gap:12},iconBadge:{width:Bi,height:Bi,borderRadius:Bi/2,alignItems:"center",justifyContent:"center",backgroundColor:t.brandSoft},headerText:{flex:1,gap:2},title:{...S(e,"bold"),fontSize:20,lineHeight:28,color:t.text.primary,letterSpacing:r.letterSpacing.tight},subtitle:{...S(e,"regular"),fontSize:r.size.body,lineHeight:r.size.body*r.lineHeight.relaxed,color:t.text.muted},options:{gap:8},option:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:14,paddingVertical:13,borderRadius:n.md,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder,backgroundColor:t.surface},optionSelected:{borderColor:t.brandInk,backgroundColor:t.brandSoft},optionLabel:{...S(e,"medium"),fontSize:r.size.body,color:t.text.primary},optionLabelSelected:{color:t.brandInk},radio:{width:Hi,height:Hi,borderRadius:Hi/2,borderWidth:2,borderColor:t.brandBorderStrong,alignItems:"center",justifyContent:"center"},radioSelected:{borderColor:t.brandInk,backgroundColor:t.brandInk},inputWrap:{gap:4},input:{minHeight:72,maxHeight:132,borderRadius:n.md,borderWidth:1,borderColor:t.brandBorderStrong,paddingHorizontal:14,paddingTop:12,paddingBottom:12,...S(e,"regular"),fontSize:r.size.body,color:t.text.primary,textAlignVertical:"top"},counter:{...S(e,"mono"),alignSelf:"flex-end",fontSize:r.size.caption,letterSpacing:.3,color:t.text.placeholder},counterOver:{color:t.danger},failed:{...S(e,"regular"),fontSize:r.size.caption,lineHeight:r.size.caption*r.lineHeight.normal,color:t.danger},actions:{gap:10,alignItems:"center"},submit:{alignSelf:"stretch",minHeight:Fc,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.xl,borderRadius:n.pill,backgroundColor:t.brand,...me(o.primaryButton)},submitDisabled:{opacity:.6},submitLabel:{...S(e,"medium"),fontSize:r.size.body,color:t.onPrimary,...Ie(o.primaryButton)},skip:{minHeight:Fc,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},skipLabel:{...S(e,"medium"),fontSize:r.size.body,color:t.text.muted}})}i(XE,"makeStyles");var cC=.88,pC=420,fC=58,mC="rgba(17,17,17,0.28)",yC=.08,gC=.1,hC=.08,bC=.18,vC=.78,EC=.7,zi=36,CC=10,RC=14,SC=12,TC=16,PC=14,ji=8,kC=1.5,xC=.5,_C=vn(Er.standard);function wC(e){return Math.min(Math.round(e*cC),pC)}i(wC,"drawerPanelWidth");function Nc({chat:e,history:t}){let[r,n]=react.useState(t.open),o=react.useCallback(()=>n(false),[]);return t.open&&!r&&n(true),r?jsxRuntime.jsx(IC,{chat:e,history:t,onHidden:o}):null}i(Nc,"HistoryDrawer");function IC({chat:e,history:t,onHidden:r}){let n=O(),o=react.useMemo(()=>OC(n),[n]),s=X(),a=reactNativeSafeAreaContext.useSafeAreaInsets(),{width:l}=reactNative.useWindowDimensions(),u=wC(l),d=t.open,c=react.useRef(null);c.current===null&&(c.current=new reactNative.Animated.Value(s.drawerMs<=0&&d?1:0));let p=c.current;react.useEffect(()=>{if(!d&&s.drawerMs<=0){r();return}let R=reactNative.Animated.timing(p,{toValue:d?1:0,duration:s.drawerMs,easing:_C,useNativeDriver:true});return R.start(({finished:I})=>{I&&!d&&r();}),()=>R.stop()},[d,p,s.drawerMs,r]);let f=p.interpolate({inputRange:[0,1],outputRange:[-u,0]}),y=t.filtered,m=t.rows.length===0,w=m&&t.loading?jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,accessibilityLabel:Z.loading,accessibilityState:{busy:true},children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{color:n.color.onPrimary}),jsxRuntime.jsx(C,{style:o.emptyBody,children:Z.loading})]}):m&&t.error!==null?jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,children:[jsxRuntime.jsx(C,{style:o.emptyTitle,accessibilityRole:"alert",children:Z.loadFailed}),jsxRuntime.jsx(C,{style:o.emptyBody,children:t.error}),jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:Z.retryA11y,containerStyle:o.retrySlot,style:o.retryButton,onPress:()=>{t.load();},children:jsxRuntime.jsx(C,{tier:"control",style:o.retryText,children:Z.retry})})]}):jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,children:[jsxRuntime.jsx(C,{style:o.emptyTitle,children:t.emptyKind==="empty"?Z.empty:Z.noMatch}),jsxRuntime.jsx(C,{style:o.emptyBody,children:t.emptyKind==="empty"?Z.emptyBody:Z.noMatchBody})]}),b=!t.searching&&t.loadingMore?jsxRuntime.jsx(reactNative.View,{style:o.loadMoreFooter,children:jsxRuntime.jsx(C,{style:o.loadMoreLabel,children:Z.loadingMore})}):null;return jsxRuntime.jsx(reactNative.Modal,{visible:true,transparent:true,animationType:"none",onRequestClose:t.close,children:jsxRuntime.jsxs(reactNative.View,{style:o.root,children:[jsxRuntime.jsx(reactNative.Pressable,{style:Se,onPress:t.close,accessibilityRole:"button",accessibilityLabel:Z.closeA11y,children:jsxRuntime.jsx(reactNative.Animated.View,{style:[o.backdrop,{opacity:p}]})}),jsxRuntime.jsx(reactNative.Animated.View,{style:[o.panel,{width:u,paddingTop:Math.max(fC,a.top+n.space.md),transform:[{translateX:f}]}],accessibilityViewIsModal:true,children:jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{style:o.keyboardAvoider,behavior:reactNative.Platform.OS==="ios"?"padding":"height",children:[jsxRuntime.jsxs(reactNative.View,{style:o.searchRow,children:[jsxRuntime.jsxs(reactNative.View,{style:o.searchPill,children:[jsxRuntime.jsx(hd,{size:PC,color:n.color.text.muted,strokeWidth:1.5}),jsxRuntime.jsx(Ut,{value:t.query,onChangeText:R=>t.setQuery(R.replace(/^\s+/,"")),style:o.searchInput,placeholder:Z.search,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:Z.search,autoCorrect:false,autoCapitalize:"none",returnKeyType:"search"})]}),jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:Z.newConversation,style:o.newButton,onPress:t.newConversation,children:jsxRuntime.jsx(bd,{size:TC,color:n.color.text.primary,strokeWidth:1.5})})]}),jsxRuntime.jsx(C,{tier:"heading",style:o.heading,accessibilityRole:"header",children:Z.heading}),t.error!==null&&!m?jsxRuntime.jsx(reactNative.View,{style:o.errorCard,children:jsxRuntime.jsx(C,{style:o.errorText,accessibilityRole:"alert",children:t.error})}):null,jsxRuntime.jsx(reactNative.FlatList,{data:y,keyExtractor:R=>R.id,renderItem:({item:R})=>jsxRuntime.jsx(AC,{row:R,active:R.id===e.conversationId,disabled:t.loading,styles:o,onPress:()=>{t.resume(R.id);}}),contentContainerStyle:y.length===0?o.listEmpty:o.list,keyboardShouldPersistTaps:"handled",ListEmptyComponent:w,ListFooterComponent:b,onEndReached:t.loadMore,onEndReachedThreshold:xC})]})})]})})}i(IC,"DrawerModal");function AC({row:e,active:t,disabled:r,styles:n,onPress:o}){let s=e.unreadCount!==null&&e.unreadCount>0;return jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:$u(e),accessibilityState:{selected:t,disabled:r},disabled:r,style:[n.item,t?n.itemActive:null],onPress:o,children:jsxRuntime.jsxs(reactNative.View,{style:n.itemRow,children:[jsxRuntime.jsx(C,{style:[n.itemTitle,s?n.itemTitleUnread:null],numberOfLines:1,children:pn(e.title)}),s?jsxRuntime.jsx(reactNative.View,{style:n.unreadDot}):null]})})}i(AC,"Row");function On(e,t){if(!/^#[0-9a-f]{6}$/i.test(e))return "transparent";let r=Math.round(Math.min(1,Math.max(0,t))*255);return `${e}${r.toString(16).padStart(2,"0").toUpperCase()}`}i(On,"inkWash");function OC(e){let t=e.color,r=e.slots,n=t.onPrimary;return reactNative.StyleSheet.create({root:{flex:1},backdrop:{flex:1,backgroundColor:mC},panel:{position:"absolute",left:0,top:0,bottom:0,backgroundColor:t.brand,paddingHorizontal:16,borderRightWidth:.5,borderRightColor:t.brandBorder,gap:12},keyboardAvoider:{flex:1,gap:12},searchRow:{flexDirection:"row",alignItems:"center",gap:10},searchPill:{flex:1,flexDirection:"row",alignItems:"center",gap:8,borderRadius:e.radius.pill,backgroundColor:t.surface,paddingHorizontal:14,paddingVertical:10,borderWidth:1,borderColor:On(n,gC)},searchInput:{...S(e,"regular"),flex:1,fontSize:13,lineHeight:16,color:t.text.primary,padding:0},newButton:{width:zi,height:zi,borderRadius:zi/2,alignItems:"center",justifyContent:"center",backgroundColor:t.surface},heading:{...S(e,"bold"),fontSize:14,lineHeight:17,color:n,marginTop:4},list:{gap:10,paddingBottom:28},listEmpty:{flexGrow:1},item:{paddingVertical:12,paddingHorizontal:4,borderRadius:CC},itemActive:{backgroundColor:On(n,yC)},itemRow:{flexDirection:"row",alignItems:"center",gap:8},itemTitle:{...S(e,"regular"),flex:1,fontSize:14,lineHeight:18,color:n},itemTitleUnread:S(e,"bold"),unreadDot:{width:ji,height:ji,borderRadius:ji/2,backgroundColor:t.danger,borderWidth:kC,borderColor:n},errorCard:{borderRadius:SC,borderWidth:.5,borderColor:t.danger,backgroundColor:t.surface,padding:12},errorText:{...S(e,"regular"),fontSize:11,lineHeight:16,color:t.danger},emptyCard:{borderRadius:RC,padding:14,gap:6,backgroundColor:On(n,hC),borderWidth:.5,borderColor:On(n,bC)},emptyTitle:{...S(e,"bold"),fontSize:12,lineHeight:15,color:n},emptyBody:{...S(e,"regular"),fontSize:11,lineHeight:17,color:n,opacity:vC},retrySlot:{marginTop:8,alignSelf:"flex-start"},retryButton:{borderRadius:e.radius.pill,paddingHorizontal:14,paddingVertical:7,borderWidth:1,borderColor:n,...me(r.primaryButton)},retryText:{...S(e,"bold"),fontSize:12,lineHeight:15,color:n,...Ie(r.primaryButton)},loadMoreFooter:{paddingVertical:14,alignItems:"center"},loadMoreLabel:{...S(e,"regular"),fontSize:11,lineHeight:14,color:n,opacity:EC}})}i(OC,"makeStyles");function Uc(e,t){let r={entry:"chat",petRef:e};return t?.returnTo!==void 0&&(r.returnTo=t.returnTo),t?.usState!==void 0&&(r.usState=t.usState),t?.prefer!==void 0&&(r.prefer=t.prefer),r}i(Uc,"chatVetVisitOptions");var DC=16,NC=.75,Wi=12,Vc=15,UC=18,Fn=22,VC=14,HC=8,BC=20,zC=10,jC=13;function Bc({surface:e,petRef:t,renderVetAction:r,onFindVet:n,vet:o}){let s=O(),a=react.useMemo(()=>WC(s),[s]),l=X(),u=e.tier,d=e.source;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(mi,{visible:e.showBanner&&u!==null,inMs:l.bannerInMs,outMs:l.bannerOutMs,style:a.pinned,children:u!==null&&d!==null?jsxRuntime.jsxs(reactNative.View,{accessibilityRole:"alert",style:[a.card,{borderColor:u.borderColor,backgroundColor:u.backgroundColor}],children:[jsxRuntime.jsx(C,{tier:"compact",style:[a.label,{color:u.textColor}],children:u.label}),d.reason!==null?jsxRuntime.jsx(C,{style:[a.reason,{color:u.reasonColor}],children:d.reason}):null,e.showVetAction?r!==void 0?jsxRuntime.jsx(vt,{render:()=>r(u.level),fallback:jsxRuntime.jsx(Hc,{tier:u,petRef:t,onFindVet:n,vet:o,styles:a}),resetKey:u.level}):jsxRuntime.jsx(Hc,{tier:u,petRef:t,onFindVet:n,vet:o,styles:a}):null,e.dismissLabel!==null?jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:e.dismissLabel,hitSlop:HC,containerStyle:a.closeSlot,style:a.closeButton,onPress:e.dismiss,children:jsxRuntime.jsx(Et,{size:VC,color:u.textColor,strokeWidth:1.5})}):null]}):null}),jsxRuntime.jsx(mi,{visible:e.showCompactIcon,inMs:l.iconInMs,outMs:l.iconOutMs,style:a.indicatorRow,children:jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:h.showLatestVetAlert,hitSlop:zC,onPress:e.expand,children:jsxRuntime.jsx(fd,{size:BC,color:s.color.text.muted,strokeWidth:2})})})]})}i(Bc,"UrgencyBanner");function Hc({tier:e,petRef:t,onFindVet:r,vet:n,styles:o}){let s=O(),a=kn(Uc(t,n)),l=a.status==="opening",u=a.available?()=>{a.open();}:r!==void 0?()=>{q(r,e.level);}:null;if(u===null)return null;let d=Ri(s.slots.vetVisitButton)?.textColor??e.textColor;return jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:h.findVetA11y,accessibilityState:{busy:l},containerStyle:o.findVetSlot,style:[o.findVetButton,{borderColor:e.borderColor,backgroundColor:e.pillColor},o.findVetSlotBox,l?o.findVetBusy:null],onPress:u,children:[jsxRuntime.jsx(vd,{size:jC,color:d,strokeWidth:1.5}),jsxRuntime.jsx(C,{tier:"control",style:[o.findVetLabel,{color:d}],children:h.findVet})]})}i(Hc,"VetAction");function WC(e){let t=Ri(e.slots.vetVisitButton);return reactNative.StyleSheet.create({pinned:{marginTop:0,marginBottom:4,paddingHorizontal:e.space.lg},card:{borderRadius:DC,borderWidth:NC,paddingHorizontal:14,paddingVertical:8,gap:2},label:{...S(e,"monoBold"),fontSize:Wi,lineHeight:Vc},reason:{...S(e,"regular"),fontSize:Wi,lineHeight:UC,paddingRight:Fn},findVetSlot:{alignSelf:"flex-start",marginTop:6},findVetButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:e.radius.pill,borderWidth:1},findVetSlotBox:{...me(t,1)},findVetBusy:{opacity:.6},findVetLabel:{...S(e,"monoBold"),fontSize:Wi,lineHeight:Vc},closeSlot:{position:"absolute",top:6,right:6},closeButton:{width:Fn,height:Fn,borderRadius:Fn/2,alignItems:"center",justifyContent:"center"},indicatorRow:{alignItems:"flex-end",paddingHorizontal:16,paddingTop:2,paddingBottom:4}})}i(WC,"makeStyles");function zc(){let e=Rn(),{handle:t}=Y(),r=react.useCallback(n=>t.setActivePet(n),[t]);return react.useMemo(()=>({...e,setActivePet:r}),[e,r])}i(zc,"useChatPets");var Xc=300,Qc=3e3,Wc=120,Gt=44,YC=120,XC="86%",Gc=15,Kc=22,Mn=.5,QC=.04,ZC=8,JC=2,eR=1,tR=.6,rR=22,nR=48,qc=1.25,oR=14,iR=18,sR=6,aR=14,lR=.04,uR=12,dR=2,cR=2,$c=36,pR=20,Wt=36,Kt=(Gt-Wt)/2,Zc=24,Jc=22,fR=.4,Ln=30,ep=20,mR=.4,yR=480,gR=8,Yc=14,hR=10,bR=14,vR=12,ER=13,CR=18,RR="12%";function Ee(){let e=O(),t=react.useMemo(()=>SR(e),[e]);return {theme:e,styles:t}}i(Ee,"useChatTheme");function SR(e){let t=e.color,r=e.space,n=e.radius,o=e.type,s=e.slots;return reactNative.StyleSheet.create({container:{flex:1,minHeight:Wc,backgroundColor:t.chatGround},body:{flex:1},centered:{minHeight:Wc,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl},emptyContent:{flexGrow:1,alignItems:"center",justifyContent:"flex-start",paddingTop:RR,paddingHorizontal:r.lg,paddingBottom:r.lg,minHeight:yR,gap:18},errorText:{...S(e,"regular"),fontSize:o.size.subtitle,lineHeight:o.size.subtitle*o.lineHeight.snug,color:t.danger,textAlign:"center",marginBottom:r.md},retryButton:{minHeight:Gt,minWidth:Gt,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.brand,...me(s.primaryButton)},retryLabel:{...S(e,"medium"),color:t.onPrimary,fontSize:o.size.body,...Ie(s.primaryButton)},setupNotice:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm,paddingHorizontal:r.lg,paddingVertical:r.sm,backgroundColor:t.surfaceCream},setupNoticeText:{...S(e,"regular"),color:t.danger,fontSize:o.size.caption,flexShrink:1},turnNotice:{gap:r.xs,padding:r.md,borderRadius:n.lg,backgroundColor:t.surfaceCream,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder,alignItems:"flex-start"},turnNoticeError:{borderColor:t.danger},turnNoticeTitle:{...S(e,"bold"),color:t.text.primary,fontSize:o.size.body},turnNoticeTitleError:{color:t.danger},turnNoticeBody:{...S(e,"regular"),color:t.text.secondary,fontSize:o.size.caption,lineHeight:o.size.caption*o.lineHeight.normal},turnNoticeAction:{minHeight:Gt,justifyContent:"center"},turnNoticeActionLabel:{...S(e,"medium"),color:t.brandInk,fontSize:o.size.body},setupNoticeAction:{...S(e,"medium"),color:t.brandInk,fontSize:o.size.caption},reconnectingCaption:{...S(e,"medium"),color:t.text.secondary,fontSize:o.size.caption,lineHeight:o.size.caption*o.lineHeight.normal,textTransform:"uppercase",letterSpacing:.5},list:{flex:1},listContent:{padding:r.lg,gap:r.md},rowBlock:{gap:r.sm},rowBlockUser:{},rowBlockAssistant:{paddingRight:r.xl},row:{flexDirection:"row"},rowUser:{justifyContent:"flex-end"},rowAssistant:{justifyContent:"flex-start"},bubble:{maxWidth:XC},bubbleUser:{padding:Gc,backgroundColor:t.bubbleUser,borderRadius:n.xl,borderBottomRightRadius:n.sm,borderWidth:Mn,borderColor:t.accentEdge,shadowColor:t.brand,shadowOpacity:QC,shadowRadius:ZC,shadowOffset:{width:0,height:JC},elevation:eR,...me(s.userBubble,Mn)},bubbleAssistant:s.assistantBubble?.backgroundColor===void 0?{...me(s.assistantBubble,Mn)}:{padding:Gc,borderRadius:n.xl,...me(s.assistantBubble,Mn)},bubblePending:{opacity:tR},bubbleTextUser:{...S(e,"medium"),color:t.onPrimary,fontSize:o.size.body,lineHeight:Kc,...Ie(s.userBubble)},bubbleTextAssistant:{...S(e,"medium"),color:t.text.primary,fontSize:o.size.body,lineHeight:Kc,...Ie(s.assistantBubble)},bubbleBold:S(e,"bold"),bubbleItalic:{fontStyle:"italic"},bubbleCode:S(e,"mono"),followUps:{alignSelf:"stretch",marginTop:r.sm,gap:gR},followUpSlot:{alignSelf:"stretch",borderRadius:Yc},followUpRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:vR,paddingVertical:hR,paddingHorizontal:bR,borderRadius:Yc,backgroundColor:t.brandSoft},followUpText:{...S(e,"medium"),flex:1,color:t.text.primary,fontSize:ER,lineHeight:CR},composerOuter:{position:"relative"},composer:{marginHorizontal:r.md,marginTop:r.xs,marginBottom:r.sm,minHeight:nR,justifyContent:"center",paddingLeft:oR,paddingRight:iR,paddingVertical:sR,backgroundColor:t.composerFill,borderWidth:qc,borderColor:t.composerBorder,borderRadius:rR,shadowColor:t.shadow,shadowOpacity:lR,shadowRadius:uR,shadowOffset:{width:0,height:dR},elevation:cR,...me(s.composerInput,qc)},composerRow:{flexDirection:"row",alignItems:"center",gap:aR,minHeight:$c},attachControl:{width:Ln,height:Ln,alignItems:"center",justifyContent:"center"},attachControlDisabled:{opacity:mR},input:{flex:1,minHeight:$c,maxHeight:YC,paddingHorizontal:0,paddingVertical:0,...S(e,"regular"),fontSize:o.size.body,lineHeight:pR,color:t.text.primary,...Ie(s.composerInput)},sendControl:{minHeight:Wt,minWidth:Wt,alignItems:"center",justifyContent:"center"},sendDisc:{width:Wt,height:Wt,borderRadius:Wt/2,alignItems:"center",justifyContent:"center",...me(s.sendButton)},sendControlDisabled:{opacity:fR},poweredBy:{...S(e,"regular"),color:t.text.muted,fontSize:o.size.micro,textAlign:"center",paddingBottom:r.xs}})}i(SR,"makeStyles");var TR=Object.freeze({kind:"live"}),PR=Object.freeze({kind:"folded"});function Ki(e){if(e.role!=="assistant"||e.checkin===void 0)return null;let t=e.checkin.caseId,r=lo(e.proactiveOriginRef);return {caseId:t,dueDay:r!==null&&r.caseId===t?r.dueDay:""}}i(Ki,"askOf");function rp(e){let t=new Map,r=new Map;for(let o of e){let s=Ki(o);if(s===null)continue;let a=r.get(s.caseId);(a===void 0||s.dueDay>=a.dueDay)&&r.set(s.caseId,{messageId:o.id,dueDay:s.dueDay});}if(r.size===0)return t;let n=null;for(let o of e){let s=Ki(o);if(s===null){n=null;continue}if(r.get(s.caseId)?.messageId===o.id){t.set(o.id,TR),n=null;continue}if(n!==null&&n.caseId===s.caseId){n.days.push(s.dueDay),t.set(o.id,PR);continue}let a=[s.dueDay];n={id:o.id,caseId:s.caseId,days:a},t.set(o.id,{kind:"past",runDueDays:a});}return t}i(rp,"placeCheckins");var tp=864e5,kR=365;function Dn(e,t){if(typeof e!="string"||typeof t!="string")return null;let r=Date.parse(e),n=Date.parse(t);if(Number.isNaN(r)||Number.isNaN(n))return null;let o=Math.floor(n/tp)-Math.floor(r/tp);return o<1||o>kR?null:o}i(Dn,"checkinDayNumber");function np(e){return Ki(e)?.dueDay||null}i(np,"checkinDueDay");var Te=Object.freeze({eyebrow:"Checking in",logged:"Logged",findVet:"Find a vet now",day:"Day {day}",daySeparator:" \xB7 ",answers:Object.freeze({better:"Better",same:"Same",worse:"Worse"})}),op=Object.freeze(zr.map(e=>Object.freeze({answer:e,label:Te.answers[e]})));function ip(e,t){let[r,n]=react.useState(null),[o,s]=react.useState(null),[a,l]=react.useState(null),u=react.useCallback(c=>{t!==null&&(n(c),s(null),t(e.caseId,c).then(p=>{n(null),p.ok?l(c):s(p.error);}));},[t,e.caseId]),d=a??e.answer;return {answer:d,answerable:!ca(e),escalated:d==="worse",pending:r,error:o,choose:u}}i(ip,"useCheckinCard");var lp=44,wR=.6;function dp({message:e,checkin:t,onAnswer:r,petRef:n,onFindVet:o,vet:s,onLayout:a}){let l=O(),u=react.useMemo(()=>IR(l),[l]),d=ip(t,r),c=d.answer!==null||d.pending!==null,p=r!==null&&d.answerable,f=Dn(t.openedAt,np(e));return jsxRuntime.jsxs(reactNative.View,{style:u.card,accessibilityLabel:Te.eyebrow,onLayout:a,children:[jsxRuntime.jsxs(reactNative.View,{style:u.head,children:[jsxRuntime.jsx(C,{tier:"compact",style:u.eyebrow,children:Te.eyebrow}),f!==null?jsxRuntime.jsx(C,{tier:"compact",style:u.headDay,children:K(Te.day,{day:f})}):null]}),jsxRuntime.jsx(C,{style:u.question,accessibilityRole:"text",children:e.text}),p?jsxRuntime.jsx(reactNative.View,{style:[u.row,d.pending?u.rowPending:null],children:op.map(({answer:y,label:m})=>{let w=(d.pending??d.answer)===y;return jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>d.choose(y),disabled:c,accessibilityRole:"button",accessibilityLabel:m,accessibilityState:{selected:w,disabled:c,busy:d.pending===y},style:[u.pill,w?u.pillSelected:null],children:jsxRuntime.jsx(C,{tier:"control",style:[u.pillLabel,w?u.pillLabelSelected:null],children:m})},y)})}):null,d.answer!==null?jsxRuntime.jsx(C,{style:u.logged,children:Te.logged}):null,d.escalated?o!==void 0?jsxRuntime.jsx(reactNative.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:Te.findVet,style:u.findVet,children:jsxRuntime.jsx(C,{tier:"control",style:u.findVetLabel,children:Te.findVet})}):n?jsxRuntime.jsx(jt,{entry:"chat",petRef:n,label:Te.findVet,...s?.returnTo!==void 0?{returnTo:s.returnTo}:{},...s?.usState!==void 0?{usState:s.usState}:{},...s?.prefer!==void 0?{prefer:s.prefer}:{},style:u.findVet,labelStyle:u.findVetLabel}):null:null,t.resolutionText?jsxRuntime.jsx(C,{style:u.resolution,children:t.resolutionText}):null,d.error?jsxRuntime.jsx(C,{style:u.error,accessibilityRole:"alert",children:d.error.displayMessage}):null]})}i(dp,"CheckinCard");function IR(e){let t=e.color,r=e.space,n=e.radius,o=e.type;return reactNative.StyleSheet.create({card:{maxWidth:"92%",padding:r.md,gap:r.sm,borderRadius:n.lg,backgroundColor:t.brandSoft,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},head:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},eyebrow:{...S(e,"regular"),color:t.text.secondary,fontSize:o.size.caption,letterSpacing:o.letterSpacing.eyebrow,textTransform:"uppercase"},headDay:{...S(e,"bold"),color:t.text.primary,fontSize:o.size.caption,letterSpacing:o.letterSpacing.eyebrow,textTransform:"uppercase"},question:{...S(e,"regular"),color:t.text.primary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.normal},row:{flexDirection:"row",gap:r.sm,marginTop:r.xs},rowPending:{opacity:wR},pill:{flex:1,minHeight:lp,alignItems:"center",justifyContent:"center",paddingHorizontal:r.md,borderRadius:n.pill,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface},pillSelected:{backgroundColor:t.brand,borderColor:t.brand},pillLabel:{...S(e,"regular"),color:t.text.primary,fontSize:o.size.body},pillLabelSelected:{color:t.onPrimary},logged:{...S(e,"regular"),color:t.text.secondary,fontSize:o.size.caption},resolution:{...S(e,"regular"),color:t.text.primary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.normal},error:{...S(e,"regular"),color:t.danger,fontSize:o.size.caption},findVet:{alignSelf:"stretch",minHeight:lp,alignItems:"center",justifyContent:"center",borderRadius:n.pill,borderWidth:1.5,borderColor:t.brandBorder,backgroundColor:t.surface},findVetLabel:{...S(e,"bold"),color:t.brandInk,fontSize:o.size.body}})}i(IR,"makeStyles");var FR=1.5,MR=3;function pp({text:e,runDueDays:t,openedAt:r,onLayout:n}){let o=O(),s=react.useMemo(()=>LR(o),[o]),a=t.map(u=>Dn(r,u)).filter(u=>u!==null),l=t.length>1;return l&&a.length===0?null:jsxRuntime.jsxs(reactNative.View,{style:s.row,onLayout:n,children:[jsxRuntime.jsx(reactNative.View,{style:s.rule,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"}),jsxRuntime.jsxs(reactNative.View,{style:s.body,children:[a.length>0?jsxRuntime.jsx(C,{tier:"compact",style:s.days,children:a.map(u=>K(Te.day,{day:u})).join(Te.daySeparator)}):null,l?null:jsxRuntime.jsx(C,{style:s.question,accessibilityRole:"text",children:e})]})]})}i(pp,"CheckinPastAsk");function LR(e){let t=e.color,r=e.space,n=e.type;return reactNative.StyleSheet.create({row:{flexDirection:"row",paddingVertical:r.xs},rule:{width:FR,borderRadius:1,backgroundColor:t.borderHairlineGreen,marginRight:r.md},body:{flex:1,gap:MR},days:{...S(e,"monoMedium"),fontSize:n.size.nano,letterSpacing:n.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase"},question:{...S(e,"regular"),fontSize:n.size.bodyTight,lineHeight:n.size.bodyTight*n.lineHeight.normal,color:t.text.muted}})}i(LR,"makeStyles");var DR=Object.freeze({TIER_1:"#07C168",TIER_2:"#27A9FF",TIER_3:"#FBC558"}),fp="#C8BEB4";function NR(e){return e?DR[e.toUpperCase()]??fp:fp}i(NR,"tierColor");function UR(e){if(!e)return null;let t=/^tier[_\s-]?(\d+)$/i.exec(e.trim());return t?`Tier ${t[1]}`:e}i(UR,"tierLabel");function He(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}i(He,"text");function VR(e){let t=He(e);return t!==null&&/^https:\/\/\S+$/i.test(t)?t:null}i(VR,"httpsUrl");function HR(e,t){let r=He(e.source_name)??He(e.sourceName),n=He(e.section),o=He(e.authority_tier)??He(e.authorityTier),s=UR(o),a=r??He(e.title)??`Source ${t+1}`,l=He(e.monograph_chunk_id)??He(e.chunkId),u=[n,s].filter(d=>d!==null).join(" \xB7 ");return Object.freeze({title:a,sourceName:r,section:n,authorityTier:o,tierLabel:s,meta:u.length===0?null:u,url:VR(e.url),excerpt:He(e.excerpt),tierColor:NR(o),key:`${a}-${l??"none"}-${t}`})}i(HR,"toCitationCard");function mp(e){return e===void 0||e.length===0?BR:Object.freeze(e.map((t,r)=>HR(t,r)))}i(mp,"toCitationCards");var BR=Object.freeze([]);function Qi(e){return e===1?`1 ${h.sourceSingular}`:`${e} ${h.sourcePlural}`}i(Qi,"sourcesLabel");function yp(e,t){return `${t?h.hideSources:h.showSources} ${Qi(e)}`}i(yp,"sourcesToggleLabel");function gp(e){return [e.url!==null?`${h.openSource}: ${e.title}`:e.title,e.meta,e.excerpt].filter(t=>t!==null&&t.length>0).join(". ")}i(gp,"citationA11yLabel");var KR=244,bp=8,vp=13,qR=14,$R=.3,YR=-0.24,XR=22,QR=10,ZR=15;function Ep({citations:e,onOpenUrl:t}){let r=O(),n=react.useMemo(()=>tS(r),[r]),o=react.useMemo(()=>mp(e),[e]),[s,a]=react.useState(false);if(o.length===0)return null;let l=o.length;return jsxRuntime.jsxs(reactNative.View,{style:n.block,children:[jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:yp(l,s),accessibilityState:{expanded:s},containerStyle:n.toggleSlot,style:n.togglePill,onPress:()=>a(u=>!u),children:[jsxRuntime.jsx(dd,{size:vp,color:r.color.brandInk,strokeWidth:1.5}),jsxRuntime.jsx(C,{tier:"compact",style:n.toggleLabel,children:Qi(l)}),jsxRuntime.jsx(yn,{size:vp,color:r.color.brandInk,strokeWidth:1.5,direction:s?"up":"down"})]}),s?jsxRuntime.jsx(JR,{cards:o,styles:n,open:t}):null]})}i(Ep,"CitationCards");function JR({cards:e,styles:t,open:r}){let n=X(),o=Ct(n.citationsInMs,{risePx:n.citationsRisePx});return jsxRuntime.jsx(reactNative.Animated.View,{style:o,children:jsxRuntime.jsx(reactNative.ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,contentContainerStyle:t.row,children:e.map(s=>jsxRuntime.jsx(eS,{card:s,styles:t,open:r},s.key))})})}i(JR,"Deck");function eS({card:e,styles:t,open:r}){let n=O(),o=e.url!==null&&r!==void 0,s=gp(o?e:{...e,url:null}),a=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(reactNative.View,{style:t.cardHeader,children:[jsxRuntime.jsx(reactNative.View,{style:[t.tierDot,{backgroundColor:e.tierColor}]}),jsxRuntime.jsx(C,{style:[t.cardTitle,o?t.cardTitleLink:null],numberOfLines:2,children:e.title}),o?jsxRuntime.jsx(cd,{size:qR,color:n.color.linkInk,strokeWidth:1.5}):null]}),e.meta!==null?jsxRuntime.jsx(C,{tier:"compact",style:t.cardMeta,numberOfLines:1,children:e.meta}):null,e.excerpt!==null?jsxRuntime.jsx(C,{style:t.cardExcerpt,numberOfLines:3,children:e.excerpt}):null]});if(e.url!==null&&r!==void 0){let l=e.url;return jsxRuntime.jsx(B,{accessibilityRole:"link",accessibilityLabel:s,style:t.card,onPress:()=>r(l),children:a})}return jsxRuntime.jsx(reactNative.View,{accessible:true,accessibilityRole:"text",accessibilityLabel:s,style:t.card,children:a})}i(eS,"Card");function tS(e){let t=e.color,r=e.space,n=e.radius,o=e.type.size;return reactNative.StyleSheet.create({block:{gap:r.sm},toggleSlot:{alignSelf:"flex-start",borderRadius:n.pill},togglePill:{flexDirection:"row",alignItems:"center",gap:r.xs+2,paddingHorizontal:r.md,paddingVertical:r.xs+2,borderRadius:n.pill,backgroundColor:t.brandSoft},toggleLabel:{...S(e,"monoBold"),fontSize:o.micro,lineHeight:o.micro,letterSpacing:$R,color:t.brandInk,textTransform:"uppercase"},row:{gap:r.sm,paddingRight:r.xl,paddingTop:r.xs},card:{width:KR,borderRadius:n.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,padding:r.md,gap:r.xs+2},cardHeader:{flexDirection:"row",alignItems:"center",gap:r.sm},tierDot:{width:bp,height:bp,borderRadius:n.pill},cardTitle:{...S(e,"bold"),flex:1,fontSize:o.bodyTight,lineHeight:XR,color:t.text.primary,letterSpacing:YR},cardTitleLink:{color:t.linkInk},cardMeta:{...S(e,"monoMedium"),fontSize:o.nano,lineHeight:QR,letterSpacing:e.type.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase"},cardExcerpt:{...S(e,"regular"),fontSize:o.tiny,lineHeight:ZR,color:t.text.muted}})}i(tS,"makeStyles");function Cp(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}i(Cp,"formatMessageTime");var _r=15,aS=15,lS=6,uS=Object.freeze({up:"0deg",neutral:"270deg",down:"180deg"});function kp({message:e,onCopy:t,sentiment:r=null,onSentiment:n,thanks:o=false}){let s=O(),a=react.useMemo(()=>dS(s),[s]),l=X(),u=e.role==="user",d=react.useMemo(()=>Cp(e.createdAt),[e.createdAt]),c=t!==void 0&&e.text.length>0,p=!u&&n!==void 0&&e.responseId!==void 0,[f,y]=react.useState(false),m=react.useRef(null);react.useEffect(()=>()=>{m.current&&clearTimeout(m.current);},[]);let w=i(()=>{t!==void 0&&(Ht(t,e.text),y(true),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{y(false),m.current=null;},l.copiedMs));},"copy");return d===null&&!c&&!p?null:jsxRuntime.jsxs(reactNative.View,{style:a.wrap,children:[jsxRuntime.jsxs(reactNative.View,{style:[a.row,u?a.rowUser:a.rowAssistant],children:[d!==null?jsxRuntime.jsx(C,{tier:"compact",style:a.timestamp,children:d}):null,c?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:f?h.copied:u?h.copyUserMessage:h.copyAssistantMessage,hitSlop:aS,onPress:w,style:a.iconHit,children:f?jsxRuntime.jsx(rt,{size:_r,color:s.color.success,strokeWidth:2}):jsxRuntime.jsx(pd,{size:_r,color:s.color.text.timestamp,strokeWidth:1.5})}):null,p?Cu.map(({sentiment:b,label:R})=>jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:R,accessibilityState:{selected:r===b},hitSlop:lS,onPress:()=>n?.(b),style:a.iconHit,children:jsxRuntime.jsx(gn,{size:_r,color:s.color.sentiment[b],active:r===b,rotate:uS[b],strokeWidth:1.5})},b)):null]}),o?jsxRuntime.jsx(C,{style:a.thanks,accessibilityLiveRegion:"polite",children:h.feedbackThanks}):null]})}i(kp,"MessageFooter");function dS(e){let t=e.type;return reactNative.StyleSheet.create({wrap:{gap:4},row:{flexDirection:"row",alignItems:"center",gap:10,paddingTop:6},rowAssistant:{alignSelf:"flex-start"},rowUser:{alignSelf:"flex-end"},timestamp:{...S(e,"monoMedium"),fontSize:t.size.nano,lineHeight:t.size.nano+2,color:e.color.text.timestamp,textAlign:"center"},iconHit:{width:_r,height:_r,alignItems:"center",justifyContent:"center"},thanks:{...S(e,"regular"),fontSize:t.size.caption,lineHeight:t.size.caption*t.lineHeight.normal,color:e.color.text.secondary}})}i(dS,"makeStyles");var xp="#10462E",_p="#000000",cS="#83E0B4",pS=Object.freeze([Object.freeze({id:"breed-health-miss",intent:"send",label:"What {breed} health issue do owners miss most?",fallbackLabel:"What {species} health issue do owners miss most?",background:"#A0C4F6",borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),Object.freeze({id:"attention-at-age",intent:"send",label:"What changes should I expect at {ageYears} years old?",fallbackLabel:"What changes should I expect as my {species} ages?",background:cS,borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),Object.freeze({id:"early-pain-signs",intent:"send",label:"What are early signs of pain?",background:"#FBC558",borderColor:xp,brandEdge:true,borderWidth:1}),Object.freeze({id:"vet-prep",intent:"vet_report",label:"Help me prep for {petName}\u2019s vet visit.",background:"#FFBDBD",borderColor:"#6D1D14",borderWidth:1.25})]),fS=/\s*-\s*(?:small|medium|large|giant|toy)\s*$/i;function mS(e){return e==null?e:e.replace(fS,"").trim()}i(mS,"formatBreedForPrompt");var yS=new Set(["","?","-","--",".","n/a","na","none","null","nil","unknown","unspecified","unsure","not sure","not specified","not applicable","no idea","dunno","idk","tbd","other","i dont know","i don't know","dont know","don't know","do not know","i do not know","not known","no clue"]);function gS(e){let t=String(e??"").replace(/\s+/gu," ").trim().toLowerCase().replace(/\u2019/g,"'");return yS.has(t)}i(gS,"isUninformativeBreed");function hS(e){return e==="cat"?"Domestic Short Hair Mix":"Mixed Breed"}i(hS,"unspecifiedBreedLabel");function bS(e,t){return gS(e)?hS(t):String(e).replace(/\s+/gu," ").trim()}i(bS,"resolveBreedLabel");function wp(e){let t=e?.name?.trim()||h.emptyTitlePetFallback;return K(h.emptyTitle,{petName:t})}i(wp,"emptyStateTitle");function Ip(e,t=xp){let r=Ii(e?.species),n=r==="cat"?"my cat":"my dog",o=e?.name?.trim()||null,s=o||n,a=bS(mS(e?.breed),r)||null,l=Ai(e?.ageYears),u=l===null?null:String(l);return Object.freeze(pS.map(d=>{let c=d.label.includes("{breed}"),p=d.label.includes("{ageYears}"),y=d.fallbackLabel!==void 0&&(c&&!a||p&&!u)&&d.fallbackLabel?d.fallbackLabel:d.label,m=K(y,{petName:s,breed:a??n,species:r,ageYears:u??""}),w=!o&&y.startsWith("{petName}")?m.charAt(0).toUpperCase()+m.slice(1):m;return Object.freeze({id:d.id,intent:d.intent,label:w,background:d.background,borderColor:d.brandEdge===true?t:d.borderColor,borderWidth:d.borderWidth})}))}i(Ip,"resolveQuickPrompts");var ES=36,Fp=4,CS=340;function Mp({pet:e,petRef:t,onSend:r,onVetPrep:n,vet:o}){let s=O(),a=react.useMemo(()=>SS(s),[s]),l=react.useMemo(()=>Ip(e,s.color.brandInk),[e,s.color.brandInk]),u=wp(e);return jsxRuntime.jsxs(reactNative.View,{style:a.block,children:[jsxRuntime.jsx(C,{tier:"heading",style:a.title,accessibilityRole:"header",children:u}),jsxRuntime.jsx(reactNative.View,{style:a.list,children:l.map((d,c)=>jsxRuntime.jsx(RS,{prompt:d,index:c,petRef:t,onSend:r,onVetPrep:n,vet:o,pet:e,styles:a},d.id))})]})}i(Mp,"QuickPrompts");function RS({prompt:e,index:t,pet:r,petRef:n,onSend:o,onVetPrep:s,vet:a,styles:l}){let u=X(),d=Ct(u.followUpInMs,{delayMs:bn(u,t)}),c={backgroundColor:e.background,borderColor:e.borderColor,borderWidth:e.borderWidth};return e.intent==="vet_report"?s!==void 0?jsxRuntime.jsx(reactNative.Animated.View,{style:d,children:jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:Fp,style:[l.chip,c],onPress:()=>{q(s,r);},children:jsxRuntime.jsx(C,{tier:"compact",style:l.chipLabel,children:e.label})})}):n===null?null:jsxRuntime.jsx(reactNative.Animated.View,{style:d,children:jsxRuntime.jsx(jt,{entry:"chat",petRef:n,label:e.label,...a?.returnTo!==void 0?{returnTo:a.returnTo}:{},...a?.usState!==void 0?{usState:a.usState}:{},...a?.prefer!==void 0?{prefer:a.prefer}:{},style:[l.chip,c],labelStyle:l.chipLabel})}):jsxRuntime.jsx(reactNative.Animated.View,{style:d,children:jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:Fp,style:[l.chip,c],onPress:()=>o(e.label),children:jsxRuntime.jsx(C,{tier:"compact",style:l.chipLabel,children:e.label})})})}i(RS,"Chip");function SS(e){let t=e.color;return reactNative.StyleSheet.create({block:{gap:18,alignItems:"center",width:"100%"},title:{...S(e,"bold"),fontSize:28,lineHeight:34,color:t.text.primary,letterSpacing:-0.8,textAlign:"center",maxWidth:CS},list:{width:"100%",gap:12,alignItems:"center"},chip:{borderRadius:e.radius.pill,paddingHorizontal:14,paddingVertical:9,minHeight:ES,minWidth:0,alignItems:"center",justifyContent:"center",maxWidth:"100%"},chipLabel:{...S(e,"bold"),fontSize:12,lineHeight:14,color:_p,textAlign:"center"}})}i(SS,"makeStyles");var Ji=/\*\*([^*]+?)\*\*|\*([^*]+?)\*|`([^`]+?)`/g;function Lp(e){return e.includes("*")||e.includes("`")}i(Lp,"hasInlineMarkup");function Dp(e){let t=[],r=0;Ji.lastIndex=0;for(let n=Ji.exec(e);n!==null;n=Ji.exec(e)){n.index>r&&t.push({kind:"text",text:e.slice(r,n.index)});let o=n[1],s=n[2],a=n[3];o!==void 0?t.push({kind:"bold",text:o}):s!==void 0?t.push({kind:"italic",text:s}):a!==void 0&&t.push({kind:"code",text:a}),r=n.index+n[0].length;}return r<e.length&&t.push({kind:"text",text:e.slice(r)}),t}i(Dp,"tokenizeInlineMarkdown");function Np(e,t){return Lp(e)?Dp(e).map((r,n)=>{switch(r.kind){case "bold":return jsxRuntime.jsx(C,{style:t.bold,children:r.text},n);case "italic":return t.italic?jsxRuntime.jsx(C,{style:t.italic,children:r.text},n):r.text;case "code":return t.code?jsxRuntime.jsx(C,{style:t.code,children:r.text},n):r.text;default:return r.text}}):e}i(Np,"renderInlineMarkdown");var Hp=6,jp=520,wS=Math.round(jp*.18),Bp=.44,IS=.5,zp=[0,.5,1],AS=[0,1,2];function Wp(){let e=O(),t=react.useMemo(()=>FS(e),[e]),r=!e.motion.reducedMotion;return jsxRuntime.jsx(reactNative.View,{style:t.card,accessible:true,accessibilityRole:"text",accessibilityLabel:h.typing,accessibilityLiveRegion:"polite",accessibilityState:{busy:true},children:AS.map(n=>r?jsxRuntime.jsx(OS,{index:n,style:t.dot},n):jsxRuntime.jsx(reactNative.View,{style:[t.dot,t.dotStatic]},n))})}i(Wp,"TypingIndicator");function OS({index:e,style:t}){let r=react.useRef(new reactNative.Animated.Value(0)).current;react.useEffect(()=>{let s=reactNative.Animated.sequence([reactNative.Animated.delay(e*wS),reactNative.Animated.loop(reactNative.Animated.timing(r,{toValue:1,duration:jp,useNativeDriver:true}))]);return s.start(),()=>s.stop()},[r,e]);let n=r.interpolate({inputRange:zp,outputRange:[Bp,1,Bp]}),o=r.interpolate({inputRange:zp,outputRange:[0,-3.5,0]});return jsxRuntime.jsx(reactNative.Animated.View,{style:[t,{opacity:n,transform:[{translateY:o}]}]})}i(OS,"AnimatedDot");function FS(e){let t=e.color,r=e.space,n=e.radius;return reactNative.StyleSheet.create({card:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:r.xs,paddingHorizontal:r.md,paddingVertical:r.sm,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},dot:{width:Hp,height:Hp,borderRadius:n.pill,backgroundColor:t.brand},dotStatic:{opacity:IS}})}i(FS,"makeStyles");function Gp(e,t,r){let n=e-r,o=t!=null?Math.min(n,t):n;return Math.max(0,o)}i(Gp,"resolveTurnScrollTarget");function Kp(e){let t=e.length-1,r=e[t];if(r===void 0||r.role!=="assistant")return null;let n=e[t-1];return {assistantIndex:t,userIndex:n!==void 0&&n.role==="user"?t-1:null}}i(Kp,"latestTurn");function qp(e,t,r){let n=Math.max(0,r),o=e===null?n:Math.min(Math.max(0,e),n);return o>t+1?o:null}i(qp,"nextFollowOffset");function $p(e,t){let r=react.useRef(null),n=react.useRef(true),o=react.useRef(t),s=react.useRef(0),a=react.useRef(0),l=react.useRef(0),u=react.useRef(new Map),d=Kp(e),c=d===null?null:e[d.assistantIndex]?.id??null,p=d===null||d.userIndex===null?null:e[d.userIndex]?.id??null,f=react.useCallback(()=>{let P=r.current;if(P===null||!n.current||a.current===0)return;let x=null;if(c!==null){let _=u.current.get(c);if(_===void 0)return;let F=p===null?null:u.current.get(p)??null;x=Gp(_,F,96);}let g=qp(x,s.current,l.current-a.current);g!==null&&(s.current=g,P.scrollTo({y:g,animated:false}));},[c,p]);react.useEffect(()=>{t&&!o.current&&(n.current=true),o.current=t,f();},[e,t,f]);let y=react.useCallback(P=>{a.current=P.nativeEvent.layout.height,f();},[f]),m=react.useCallback((P,x)=>{l.current=x,a.current>0&&(s.current=Math.min(s.current,Math.max(0,x-a.current))),f();},[f]),w=react.useCallback(P=>{s.current=P.nativeEvent.contentOffset.y;},[]),b=react.useCallback(()=>{n.current=false;},[]),R=react.useCallback(P=>{let{contentOffset:x,contentSize:g,layoutMeasurement:_}=P.nativeEvent;s.current=x.y,n.current=g.height-x.y-_.height<=24;},[]),I=react.useCallback(P=>x=>{u.current.set(P,x.nativeEvent.layout.y),(P===c||P===p)&&f();},[c,p,f]);return {ref:r,onLayout:y,onContentSizeChange:m,onScroll:w,onScrollBeginDrag:b,onScrollEnd:R,rowLayout:I}}i($p,"useThreadFollow");function Jp(e,t,r){switch(e){case "loading":return r.renderPending?jsxRuntime.jsx(vt,{render:r.renderPending,fallback:jsxRuntime.jsx(Xp,{})}):jsxRuntime.jsx(Xp,{});case "empty":return jsxRuntime.jsx(BS,{pet:r.shownPet,petRef:t.petRef,prompts:t.suggestedPrompts,onSelectPrompt:r.onSelectPrompt,onVetPrep:r.onVetPrep,vet:r.vet});case "error":return jsxRuntime.jsx(jS,{error:t.error,onRetry:t.retryLast,onAddPet:r.onAddPet});case "populated":return jsxRuntime.jsx(WS,{messages:t.messages,prompts:t.suggestedPrompts,onSelectPrompt:r.onSelectPrompt,isStreaming:t.isStreaming,onAnswerCheckin:t.petRef?t.answerCheckin:null,onCopy:r.onCopy,sentimentByMessage:t.sentimentByMessage,onSentiment:r.onSentiment,thanksFor:r.thanksFor,imagesByMessage:r.imagesByMessage,onPreview:r.onPreview,notice:r.notice,reconnecting:t.reconnecting===true,onRetry:t.retryLast,onStartNew:t.newConversation,petRef:t.petRef,onFindVet:r.onCheckinFindVet,vet:r.vet,onOpenUrl:r.onOpenUrl});default:return Qe(e)}}i(Jp,"renderView");function Xp(){let{theme:e,styles:t}=Ee(),[r,n]=react.useState(false);return react.useEffect(()=>{let o=setTimeout(()=>n(true),Xc);return ()=>clearTimeout(o)},[]),jsxRuntime.jsx(reactNative.View,{style:t.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:h.loading,children:r?jsxRuntime.jsx(reactNative.ActivityIndicator,{color:e.color.brandInk}):null})}i(Xp,"LoadingState");function BS({pet:e,petRef:t,prompts:r,onSelectPrompt:n,onVetPrep:o,vet:s}){let{styles:a}=Ee();return jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:a.emptyContent,keyboardShouldPersistTaps:"handled",accessibilityLabel:h.empty,children:[jsxRuntime.jsx(Mp,{pet:e,petRef:t,onSend:n,onVetPrep:o,vet:s}),jsxRuntime.jsx(ef,{prompts:r,onSelectPrompt:n})]})}i(BS,"EmptyState");function ef({prompts:e,onSelectPrompt:t}){let{styles:r}=Ee();return e.length===0?null:jsxRuntime.jsx(reactNative.View,{style:r.followUps,children:e.map((n,o)=>jsxRuntime.jsx(zS,{prompt:n,index:o,onSelectPrompt:t},n))})}i(ef,"FollowUps");function zS({prompt:e,index:t,onSelectPrompt:r}){let{theme:n,styles:o}=Ee(),s=X(),a=Ct(s.followUpInMs,{delayMs:bn(s,t)});return jsxRuntime.jsx(reactNative.Animated.View,{style:a,children:jsxRuntime.jsxs(B,{onPress:()=>r(e),accessibilityRole:"button",accessibilityLabel:e,containerStyle:o.followUpSlot,style:o.followUpRow,children:[jsxRuntime.jsx(C,{style:o.followUpText,children:e}),jsxRuntime.jsx(yn,{size:$S,color:n.color.brandInk,direction:"right"})]})})}i(zS,"FollowUpRow");function jS({error:e,onRetry:t,onAddPet:r}){let{styles:n}=Ee(),o=Iu(e)?Uu(r):void 0;return jsxRuntime.jsxs(reactNative.View,{style:n.centered,accessible:true,accessibilityRole:"alert",children:[jsxRuntime.jsx(C,{style:n.errorText,children:e.displayMessage}),o!==void 0?jsxRuntime.jsx(reactNative.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:h.addPet,style:n.retryButton,children:jsxRuntime.jsx(C,{tier:"control",style:n.retryLabel,children:h.addPet})}):null,e.retryable?jsxRuntime.jsx(reactNative.Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:h.retry,style:n.retryButton,children:jsxRuntime.jsx(C,{tier:"control",style:n.retryLabel,children:h.retry})}):null]})}i(jS,"ErrorState");function WS({messages:e,prompts:t,onSelectPrompt:r,isStreaming:n,onAnswerCheckin:o,onCopy:s,sentimentByMessage:a,onSentiment:l,thanksFor:u,imagesByMessage:d,onPreview:c,notice:p,reconnecting:f,onRetry:y,onStartNew:m,petRef:w,onFindVet:b,vet:R,onOpenUrl:I}){let{styles:P}=Ee(),x=X();Cr(e.length,x);let g=react.useMemo(()=>rp(e),[e]),_=rd(e,n),F=e[e.length-1],M=react.useMemo(()=>e.filter(k=>!(k.checkin&&g.get(k.id)?.kind==="folded")),[e,g]),E=$p(M,n);return jsxRuntime.jsxs(reactNative.ScrollView,{ref:E.ref,style:P.list,contentContainerStyle:P.listContent,accessibilityLabel:h.transcript,keyboardShouldPersistTaps:"handled",onLayout:E.onLayout,onContentSizeChange:E.onContentSizeChange,onScroll:E.onScroll,scrollEventThrottle:qS,onScrollBeginDrag:E.onScrollBeginDrag,onScrollEndDrag:E.onScrollEnd,onMomentumScrollEnd:E.onScrollEnd,children:[e.map(k=>{let T=k.checkin?g.get(k.id):void 0;return T?.kind==="folded"?null:T?.kind==="past"?jsxRuntime.jsx(pp,{text:k.text,runDueDays:T.runDueDays,openedAt:k.checkin?.openedAt,onLayout:E.rowLayout(k.id)},k.id):k.checkin&&T!==void 0?jsxRuntime.jsx(dp,{message:k,checkin:k.checkin,onAnswer:o,petRef:w,onFindVet:b,vet:R,onLayout:E.rowLayout(k.id)},k.id):jsxRuntime.jsx(YS,{onLayout:E.rowLayout(k.id),message:k,revealing:n&&k===F&&k.role==="assistant",onCopy:s,sentiment:k.responseId===void 0?null:a[String(k.responseId)]??null,onSentiment:l,thanks:u!==null&&k.responseId!==void 0&&String(k.responseId)===u,images:d[k.id]??KS,onPreview:c,onOpenUrl:I},k.id)}),f?jsxRuntime.jsx(C,{tier:"compact",style:P.reconnectingCaption,accessibilityRole:"text",children:h.reconnecting}):null,_?jsxRuntime.jsx(Wp,{}):null,p!==null?jsxRuntime.jsx(GS,{notice:p,onRetry:y,onStartNew:m}):null,n?null:jsxRuntime.jsx(ef,{prompts:t,onSelectPrompt:r})]})}i(WS,"PopulatedState");function GS({notice:e,onRetry:t,onStartNew:r}){let{styles:n}=Ee(),o=e.tone==="error";return jsxRuntime.jsxs(reactNative.View,{style:[n.turnNotice,o?n.turnNoticeError:null],accessible:true,accessibilityRole:"alert",children:[jsxRuntime.jsx(C,{tier:"control",style:[n.turnNoticeTitle,o?n.turnNoticeTitleError:null],children:e.title}),jsxRuntime.jsx(C,{tier:"compact",style:n.turnNoticeBody,children:e.body}),jsxRuntime.jsx(reactNative.Pressable,{onPress:e.action==="startNew"?r:t,accessibilityRole:"button",accessibilityLabel:e.actionLabel,hitSlop:Kt,style:n.turnNoticeAction,children:jsxRuntime.jsx(C,{tier:"control",style:n.turnNoticeActionLabel,children:e.actionLabel})})]})}i(GS,"TurnNoticeCard");var KS=Object.freeze([]),qS=16,$S=14;function YS({message:e,revealing:t,onCopy:r,sentiment:n,onSentiment:o,thanks:s,images:a,onPreview:l,onOpenUrl:u,onLayout:d}){let{styles:c}=Ee(),p=X(),f=Ct(p.messageInMs),y=wd(e.text,t,p),m=e.role==="user",w=m?h.senderUser:h.senderAssistant,b=react.useCallback(I=>o(e,I),[o,e]),R=e.pending!==true;return jsxRuntime.jsxs(reactNative.Animated.View,{style:[c.rowBlock,m?c.rowBlockUser:c.rowBlockAssistant,f],onLayout:d,children:[jsxRuntime.jsx(reactNative.View,{style:[c.row,m?c.rowUser:c.rowAssistant],accessible:true,accessibilityRole:"text",accessibilityLabel:`${w}: ${e.text}`,accessibilityState:e.pending===true?{busy:true}:void 0,children:jsxRuntime.jsxs(reactNative.View,{style:[c.bubble,m?c.bubbleUser:c.bubbleAssistant,e.pending?c.bubblePending:null],children:[m&&a.length>0?jsxRuntime.jsx(Kd,{images:a,onPreview:I=>l({uri:I.uri,label:I.filename})}):null,jsxRuntime.jsx(C,{style:m?c.bubbleTextUser:c.bubbleTextAssistant,children:m?e.text:Np(y,{bold:c.bubbleBold,italic:c.bubbleItalic,code:c.bubbleCode})})]})}),!m&&!t?jsxRuntime.jsx(Ep,{citations:e.citations,onOpenUrl:u}):null,R?jsxRuntime.jsx(kp,{message:e,onCopy:r,sentiment:n,onSentiment:e.responseId===void 0?void 0:b,thanks:s}):null]})}i(YS,"MessageRow");var eT=Object.freeze(["photo"]),tT=1;function rf(e){let{style:t,renderPending:r}=e;return jsxRuntime.jsx(Xo,{capability:"chat",style:t,...r?{renderPending:r}:{},children:jsxRuntime.jsx(rT,{...e})})}i(rf,"EverfurChat");function rT({petRef:e,conversationId:t,style:r,renderPending:n,onCopy:o,onPetChange:s,onVetPrep:a,onFindVet:l,renderVetAction:u,attachments:d,pet:c,onAddPet:p,checkinTarget:f,initialAsk:y,composerSeed:m,lifecycle:w,draftStore:b,vetReturnTo:R,vetUsState:I,vetPrefer:P,onOpenUrl:x}){let{theme:g,styles:_}=Ee(),F=X(),M=react.useMemo(()=>nd(e,t),[e,t]),E=br(M),k=ed(E),T=zc(),V=Yu(E),j=reactNativeSafeAreaContext.useSafeAreaInsets(),G=td(E),ne=react.useMemo(()=>l===void 0?void 0:()=>{q(l,"emergency");},[l]),de=react.useMemo(()=>R===void 0&&I===void 0&&P===void 0?void 0:{returnTo:R,usState:I,prefer:P},[R,I,P]),ke=Vi(T.pets,E.petRef),Yt=react.useMemo(()=>Zu(E.messages,ke?.name??null),[E.messages,ke?.name]),ce=Ju(Yt);Cr(ce.showBanner,F),zu(E.openCheckin,f),Lu(E.askEverfur,E.isBootstrapping,y);let it=react.useMemo(()=>oi(m),[m]);Hu(w,{conversationId:E.conversationId===null?null:String(E.conversationId),isTurnInFlight:E.isStreaming,refresh:E.refreshActiveThread});let Ar=(E.hasUnreadThreads??false)||V.rows.some(Ce=>Ce.unreadCount!==null&&Ce.unreadCount>0)||(E.unreadCount??0)>0,Xt=Fu(E.messages),[It,At]=react.useState(null),of=react.useCallback(()=>At(null),[]),[Qt,Bn]=react.useState(null),[sf,ns]=react.useState(null),Ot=react.useRef(null);react.useEffect(()=>()=>{Ot.current&&clearTimeout(Ot.current);},[]);let os=react.useCallback(Ce=>{ns(String(Ce)),Ot.current&&clearTimeout(Ot.current),Ot.current=setTimeout(()=>{ns(null),Ot.current=null;},Qc);},[]),af=react.useCallback((Ce,Or)=>{let Zt=Ce.responseId;if(Zt===void 0)return;let pf=E.sentimentByMessage[String(Zt)];E.feedback(Zt,Or),Or==="down"&&pf!=="down"&&Bn(Zt);},[E]),lf=react.useCallback(async(Ce,Or)=>Qt===null||!(await E.feedback(Qt,"down",Ce??"other",Or)).ok?false:(Bn(null),os(Qt),true),[E,Qt,os]),uf=react.useCallback(()=>Bn(null),[]),df=react.useCallback(Ce=>{E.send(Ce);},[E.send]),cf=react.useMemo(()=>x===void 0?void 0:Ce=>{q(x,Ce,"citation");},[x]),is={send:E.send,stop:E.stop,isStreaming:E.isStreaming,conversationId:E.conversationId,seed:it,draftStore:b,onStage:Xt.stage,onPreview:At};return jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{style:[_.container,{paddingTop:j.top},r],behavior:reactNative.Platform.OS==="ios"?"padding":void 0,children:[jsxRuntime.jsx(Ic,{pets:T,petRef:E.petRef,historyUnread:Ar,onOpenHistory:V.show,onPetChange:s,onAddPet:p,vet:de}),c!==void 0?jsxRuntime.jsx(nT,{petRef:e??null,pet:c,onRegistered:T.refresh}):null,jsxRuntime.jsx(Bc,{surface:ce,petRef:E.petRef,renderVetAction:u,onFindVet:l,vet:de}),jsxRuntime.jsx(reactNative.View,{style:_.body,children:Jp(k,E,{notice:G,vet:de,onCheckinFindVet:ne,onSelectPrompt:df,renderPending:n,shownPet:ke,onVetPrep:a,onCopy:o,onSentiment:af,thanksFor:sf,imagesByMessage:Xt.byMessage,onPreview:At,onAddPet:p,onOpenUrl:cf})}),d!==void 0?jsxRuntime.jsx(oT,{...is,attachments:d}):jsxRuntime.jsx(nf,{...is,attachments:null}),jsxRuntime.jsx(sd,{}),g.meta.hidePoweredBy?null:jsxRuntime.jsx(C,{tier:"compact",style:_.poweredBy,accessibilityRole:"text",accessibilityLabel:h.poweredBy,children:h.poweredBy}),jsxRuntime.jsx(Nc,{chat:E,history:V}),jsxRuntime.jsx(Dc,{visible:Qt!==null,onSubmit:lf,onSkip:uf}),jsxRuntime.jsx(Id,{uri:It?.uri??null,label:It?.label??"",onClose:of}),jsxRuntime.jsx(Sr,{})]})}i(rT,"ChatBody");function nT({petRef:e,pet:t,onRegistered:r}){let{styles:n}=Ee(),o=Au(e,t,r);return o.status!=="failed"||o.error===null?null:jsxRuntime.jsxs(reactNative.View,{style:n.setupNotice,accessible:true,accessibilityRole:"alert",children:[jsxRuntime.jsx(C,{tier:"compact",style:n.setupNoticeText,children:o.error.displayMessage}),jsxRuntime.jsx(reactNative.Pressable,{onPress:o.retry,accessibilityRole:"button",accessibilityLabel:h.retry,hitSlop:Kt,children:jsxRuntime.jsx(C,{tier:"control",style:n.setupNoticeAction,children:h.retry})})]})}i(nT,"PetSetupNotice");function oT({attachments:e,...t}){let r=react.useMemo(()=>$d(),[]),n=dn({maxPerMessage:e.maxPerMessage??tT,transport:r}),o=react.useMemo(()=>({state:n,sources:e.sources??eT,pick:e.pick}),[n,e.sources,e.pick]);return jsxRuntime.jsx(nf,{...t,attachments:o})}i(oT,"ComposerWithAttachments");function nf({send:e,stop:t,isStreaming:r,conversationId:n,attachments:o,seed:s,draftStore:a,onStage:l,onPreview:u}){let{theme:d,styles:c}=Ee(),p=X(),[f,y]=Gu(e,n,s);Ku(a,n===null?null:String(n),f,y);let[m,w]=react.useState(false),[b,R]=react.useState(false);react.useEffect(()=>{R(false);},[n]);let I=d.meta.placeholder??h.placeholder,P=o?.state.uploading??false,x=o?.state.failed??false,g=P||x,_=o?.state.attachments??iT;Cr(_.length,p);let F=react.useCallback(()=>{if(f.trim().length===0||g||[...f].length>Lt)return;let G=o?.state.s3Keys??sT;o!==null&&G.length>0?(l(o.state.attachments.filter(ne=>ne.status==="uploaded").map(ne=>({uri:ne.previewUri,filename:ne.filename}))),e(f,{imageS3Keys:G}),o.state.clear()):e(f),y(""),R(false);},[f,e,g,o,l]),M=react.useCallback(()=>{t();},[t]),E=react.useCallback(G=>{w(false),o!==null&&(R(false),o.state.dismissRejected(),Ht(o.pick,G).then(ne=>{if(!ne.ok){R(true);return}ne.value!==null&&o.state.add(ne.value);}));},[o]),T=react.useMemo(()=>[...f].length>Lt,[f])||g,V=o!==null&&_.length>=o.state.maxPerMessage,j=d.slots.sendButton?.textColor??d.color.brandInk;return jsxRuntime.jsxs(reactNative.View,{style:c.composerOuter,children:[o!==null&&m?jsxRuntime.jsx(Fd,{sources:o.sources,full:V,onPick:E,onClose:()=>w(false)}):null,jsxRuntime.jsxs(reactNative.View,{style:c.composer,children:[o!==null?jsxRuntime.jsx(Gd,{attachments:_,rejected:b?aT:o.state.rejected,uploadFailed:x,onRetry:o.state.retry,onRemove:o.state.remove,onPreview:G=>u({uri:G.previewUri,label:G.filename})}):null,jsxRuntime.jsxs(reactNative.View,{style:c.composerRow,children:[o!==null?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:xu(_.length,o.state.maxPerMessage),accessibilityState:{disabled:V,expanded:m},disabled:V,hitSlop:(Gt-Ln)/2,style:[c.attachControl,V?c.attachControlDisabled:null],onPress:()=>w(G=>!G),children:jsxRuntime.jsx(md,{size:ep,color:V?d.color.text.muted:d.color.brandInk,strokeWidth:1.75})}):null,jsxRuntime.jsx(Ut,{style:c.input,value:f,onChangeText:y,placeholder:I,placeholderTextColor:d.slots.composerInput?.textColor??d.color.text.placeholder,accessibilityLabel:I,onSubmitEditing:F,returnKeyType:"send",blurOnSubmit:false,multiline:true,editable:true}),r?jsxRuntime.jsx(reactNative.Pressable,{onPress:M,accessibilityRole:"button",accessibilityLabel:h.stop,hitSlop:Kt,style:c.sendControl,children:jsxRuntime.jsx(reactNative.View,{style:c.sendDisc,testID:"everfur-stop-disc",children:jsxRuntime.jsx(Cd,{size:Jc,color:j,testID:"everfur-stop-glyph"})})}):jsxRuntime.jsx(reactNative.Pressable,{onPress:F,disabled:T,accessibilityRole:"button",accessibilityLabel:h.send,accessibilityState:{disabled:T,busy:P},hitSlop:Kt,style:[c.sendControl,T?c.sendControlDisabled:null],children:jsxRuntime.jsx(reactNative.View,{style:c.sendDisc,testID:"everfur-send-disc",children:jsxRuntime.jsx(Ed,{size:Zc,color:j,testID:"everfur-send-glyph"})})})]})]})]})}i(nf,"Composer");var iT=Object.freeze([]),sT=Object.freeze([]),aT=Object.freeze({code:"unknown",retryable:true,filename:""});function pT(e){let{runtime:t,userRef:r,scopeEpoch:n}=Y(),o=react.useMemo(()=>Ze(t.registry.services.authFor(r)),[t,r,n]),s=react.useMemo(()=>({repository:o,petRef:e}),[o,e]),[a,l]=react.useState({key:s,profile:null,loading:e!==null,error:null}),u=a.key===s?a:{profile:null,loading:e!==null,error:null},d=react.useRef(0),c=react.useCallback(async()=>{let p=++d.current;if(s.petRef===null){l({key:s,profile:null,loading:false,error:null});return}l(y=>({key:s,profile:y.key===s?y.profile:null,loading:true,error:null}));let f=await s.repository.getPetProfile(s.petRef);p===d.current&&l(f.ok?{key:s,profile:f.value,loading:false,error:null}:{key:s,profile:null,loading:false,error:f.error});},[s]);return react.useEffect(()=>(c(),()=>{d.current+=1;}),[c]),react.useMemo(()=>({profile:u.profile,loading:u.loading,error:u.error,refresh:c}),[u.profile,u.loading,u.error,c])}i(pT,"useEverfurPetProfile");function mT(e){return react.createElement(an,{clientTheme:e.clientTheme??null,seams:un,children:e.children})}i(mT,"EverfurThemeProvider");exports.CapabilityGate=Xo;exports.EverfurChat=rf;exports.EverfurConfigError=Q;exports.EverfurProvider=Vh;exports.EverfurThemeProvider=mT;exports.EverfurThrownError=Fr;exports.THEME_SLOT_KEYS=sg;exports.THEME_SLOT_NAMES=yt;exports.canonicalPetSpecies=dr;exports.categoryFor=jn;exports.conversationId=Ef;exports.createRnRecordsUploadTransport=Uf;exports.face=S;exports.isErr=yf;exports.isOk=mf;exports.isRetryableCode=Wn;exports.petRef=bf;exports.previewTheme=Mg;exports.unwrap=gf;exports.useCapability=Nt;exports.useChatAttachments=dn;exports.useEverfur=Zl;exports.useEverfurChat=br;exports.useEverfurPetProfile=pT;exports.useEverfurPets=Rn;exports.useEverfurTheme=O;exports.userFacingError=Ft;exports.userRef=vf;
|
|
11
|
+
`));}l(),r.end();},"onError");e.addEventListener("message",o),e.addEventListener("done",s),e.addEventListener("error",a);function l(){if(!n){n=true,e.removeEventListener("message",o),e.removeEventListener("done",s),e.removeEventListener("error",a);try{e.close();}catch{}}}return i(l,"cleanup"),Em(r.source,l)}i(vm,"eventSourceByteSource");async function*Em(e,t){try{yield*e;}finally{t();}}i(Em,"sourceWithCleanup");function Cm(){let e=[],t=false,r=null,n=i(()=>{if(r){let s=r;r=null,s();}},"signal");async function*o(){for(;;){let s=e.shift();if(s!==void 0){yield s;continue}if(t)return;await new Promise(a=>{r=a;});}}return i(o,"gen"),{source:o(),push:i(s=>{e.push(s),n();},"push"),end:i(()=>{t=true,n();},"end")}}i(Cm,"createByteQueue");async function Rm(e,t){let r=t.fetchImpl??Ks(),n=qs(t.config.apiBaseUrl,e.path,e.query),o=$s(t.config,e.headers,"application/json",e.body!==void 0&&e.multipart===void 0),s=_m(bm),a=wm(s.signal,e.signal),l;try{l=await r(n,Ys({...e,signal:a},o));}catch(d){return E(ro(d))}finally{s.cancel();}let u=await Xs(l);return l.ok?L(u):E(Pm(l.status,u,Ws(l)))}i(Rm,"requestJson");function js(e){return {request:i(t=>Rm(t,e),"request"),stream:i((t,r)=>Sm(xm(t,r),e),"stream")}}i(js,"createHttpTransport");async function*Sm(e,t){let r=qs(t.config.apiBaseUrl,e.path,e.query),n=$s(t.config,e.headers,"text/event-stream",e.body!==void 0&&e.multipart===void 0);if(t.eventSourceFactory){let l=t.eventSourceFactory(r,Tm(e,n));yield*zr(vm(l),()=>km(l));return}let o=t.fetchImpl??Ks(),s;try{s=await o(r,Ys(e,n));}catch(l){yield Hs("",true,ea(l));return}let a=Ws(s);if(!s.ok){let l=await Xs(s),u=Qs(l)??Gs(s.status),d=Js(l)||Be(Oe(u));yield Hs(u,d,Zs(l),a);return}if(s.body){yield*zr(Vs(s.body),a);return}yield*zr(Vs(null),a);}i(Sm,"streamFrames");function Tm(e,t){return {method:e.method,headers:t,pollingInterval:0,...e.body!==void 0?{body:JSON.stringify(e.body)}:{}}}i(Tm,"buildEventSourceInit");function Pm(e,t,r){let n=Qs(t),o=n?Oe(n):vs(e),s=Zs(t);return D(o,{httpStatus:e,...Js(t)?{retryable:true}:{},...r?{requestId:r}:{},...n?{wireCode:n}:{},...Bs(t)?{reasonCode:Bs(t)}:{},...s?{wireMessage:s}:{},...t!=null?{raw:t}:{}})}i(Pm,"errorFromResponse");function ro(e){return D("internalError",{retryable:true,wireMessage:ea(e)})}i(ro,"networkError");function Ws(e){let t=e.headers.get(zs);return typeof t=="string"&&t.length>0?t:null}i(Ws,"requestIdOf");function km(e){if(typeof e.getResponseHeader!="function")return null;let t;try{t=e.getResponseHeader(zs);}catch{return null}return typeof t=="string"&&t.length>0?t:null}i(km,"eventSourceRequestId");function Gs(e){return e===401?"AUTH_EXPIRED":e===403?"ACCESS_DENIED":e===404?"NOT_FOUND":e===409?"IDEMPOTENCY_CONFLICT":e===421?"MISDIRECTED_REQUEST":e===429?"RATE_LIMITED":e===400||e===422?"INVALID_REQUEST":e===503||e>=500?"INTERNAL_ERROR":""}i(Gs,"statusToWireCode");function Hs(e,t,r,n=null){return de({code:e,retryable:t,wireMessage:r,synthesized:true,lastEventId:null,serverRequestId:n})}i(Hs,"syntheticErrorFrame");function Ks(){let e=globalThis.fetch;if(typeof e!="function")throw new Q("missing-peer-dependency","global fetch is unavailable; provide config.transport or an injected fetch implementation");return e}i(Ks,"getGlobalFetch");function qs(e,t,r){let n=t.startsWith("/")?t:`/${t}`,o=`${e}${n}`;if(r){let s=Object.entries(r).filter(a=>a[1]!==void 0).map(([a,l])=>`${encodeURIComponent(a)}=${encodeURIComponent(String(l))}`).join("&");s&&(o+=`?${s}`);}return o}i(qs,"buildUrl");function $s(e,t,r,n){let o={...Us(e),accept:r};return n&&(o["content-type"]="application/json"),t&&Object.assign(o,t),o}i($s,"mergeHeaders");function Ys(e,t){let r={method:e.method,headers:t};return e.multipart!==void 0?r.body=e.multipart:e.body!==void 0&&(r.body=JSON.stringify(e.body)),e.signal&&(r.signal=e.signal),r}i(Ys,"buildInit");function xm(e,t){return e.signal?e:{...e,signal:t}}i(xm,"withSignal");function _m(e){let t=new AbortController,r=setTimeout(()=>t.abort(),e);return {signal:t.signal,cancel:i(()=>clearTimeout(r),"cancel")}}i(_m,"timeoutSignal");function wm(e,t){if(!t)return e;let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),r.signal;let n=i(()=>r.abort(),"onAbort");return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),r.signal}i(wm,"mergeAbortSignals");async function Xs(e){try{return await e.json()}catch{return null}}i(Xs,"safeJson");function Bs(e){let t=e,r=t?.error?.reason_code??t?.reason_code;return typeof r=="string"&&r.length>0?r:null}i(Bs,"extractReasonCode");function Qs(e){let t=e,r=t?.error?.code??t?.code;return typeof r=="string"&&r.length>0?r:null}i(Qs,"extractWireCode");function Zs(e){let t=e,r=t?.error?.message??t?.message;return typeof r=="string"&&r.length>0?r:null}i(Zs,"extractWireMessage");function Js(e){let t=e;return t?.error?.retryable===true||t?.retryable===true}i(Js,"extractRetryable");function ea(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}i(ea,"describeCause");var Im=3e4,Am=Yn*2,Om="idempotency-key",Fm=new Set(["POST","PUT","PATCH","DELETE"]),Mm=Object.freeze({onEvent(){}}),Lm=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function Dm(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}i(Dm,"seededIdempotencyKey");function xe(e){let t=e.observer??Mm,r=e.timers??Lm,n=e.rng??Math.random,o=e.sleep??((f,m)=>Xm(f,r,m)),s=e.maxAttempts??Zt,a=e.unaryTimeoutMs??Im,l=e.newIdempotencyKey??Um(),u=i(f=>{try{t.onEvent(f);}catch{}},"emit");async function d(f,m,y){let x=y?.maxAttempts,b=Math.max(1,x??s),C=y?.idempotent??Fm.has(m.method),_=y?.idempotencyKey===void 0?null:Dm(y.idempotencyKey),P=C?_??l():null,k=Nm(m,P),g=0;for(;;){let w=i(j=>Object.freeze({call:f,method:m.method,path:m.path,attempt:g,...P?{idempotencyKey:P}:{},...j}),"stamp");u(w({phase:"attempt"}));let O=$m(a,r),M=Ym(O.signal,m.signal),I;try{I=await Os({...k,signal:M.signal},e.auth);}catch(j){I=E(ro(j));}finally{M.dispose(),O.cancel();}if(I.ok)return u(w({phase:"settled",ok:true,reason:"ok"})),I;let v=I.error,T=Hm(v,g,{maxAttempts:b,rng:n,now:r.now(),aborted:m.signal?.aborted===true,...x!==void 0?{perCallMaxAttempts:x}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),V={ok:false,code:v.code,reason:T.reason,...v.httpStatus!==void 0?{httpStatus:v.httpStatus}:{},...v.requestId!==void 0?{requestId:v.requestId}:{}};if(!T.retry)return u(w({phase:"settled",...V})),E(v);if(u(w({phase:"retry",...V,delayMs:T.delayMs})),await o(T.delayMs,m.signal),m.signal?.aborted===true)return u(w({phase:"settled",...V,reason:"aborted"})),E(v);g+=1;}}i(d,"send");async function c(f){return Jt(f,await qm(e.auth))}i(c,"authorize");async function*p(f,m,y){u(Object.freeze({call:f,phase:"stream.open",method:m.method,path:m.path,attempt:0}));try{yield*e.auth.transport.stream(m,y);}catch{yield de({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null,serverRequestId:null});}}return i(p,"stream"),Object.freeze({send:d,authorize:c,stream:p})}i(xe,"createRequestFunnel");function Nm(e,t){let r={};for(let[n,o]of Object.entries(e.headers??{}))n.toLowerCase()!==Om&&(r[n]=o);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}i(Nm,"assembleHeaders");function Um(){let e=0;return ()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}i(Um,"defaultIdempotencyKeyFactory");var Vm=10;function Hm(e,t,r){if(r.aborted)return {retry:false,reason:"aborted"};let n=Bm(e);if(n==="quota")return {retry:false,reason:"daily-quota-exhausted"};if(n!=="burst"&&!Be(e.code))return {retry:false,reason:"terminal-code"};let o=n==="burst"?"burst-throttle":"retryable-code";if(i(()=>{if(r.policy===void 0)return false;try{return !r.policy.shouldRetry(e.code,t)}catch{return false}},"policyVetoedRetry")())return {retry:false,reason:"terminal-code"};let a=i(()=>{if(r.policy===void 0)return null;let d;try{d=r.policy.maxAttempts(e.code);}catch{return null}return typeof d!="number"||!Number.isFinite(d)?null:Math.max(1,Math.min(Vm,Math.floor(d)))},"policyCeiling"),l=r.perCallMaxAttempts??a()??r.maxAttempts;if(t+1>=l)return {retry:false,reason:"attempts-exhausted"};let u=zm(e,r.now);return u!==null?u>Am?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:o,delayMs:u}:{retry:true,reason:o,delayMs:Vr(t,r.rng)}}i(Hm,"decideRetry");function Bm(e){let t=e.code==="unknown"?Oe(Km(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}i(Bm,"throttleKind");function zm(e,t){let r=Wm(e.raw);if(r!==null){let o=r-t;return o>0?o:0}let n=jm(e.raw);return n===null?null:Math.round(n*1e3)}i(zm,"retryOverrideMs");function jm(e){for(let t of no(e)){let r=t.retry_after_seconds;if(typeof r=="number"&&Number.isFinite(r)&&r>=0)return r}return null}i(jm,"findRetryAfterSeconds");function Wm(e){for(let t of no(e)){let r=t.resets_at,n=Gm(r);if(n!==null)return n}return null}i(Wm,"findResetsAt");function no(e){if(!ta(e))return [];let t=[e];for(let r of ["error","detail"]){let n=e[r];ta(n)&&t.push(n);}return t}i(no,"candidateScopes");function Gm(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(Gm,"parseInstantMs");function Km(e){for(let t of no(e)){let r=t.code;if(typeof r=="string"&&r.length>0)return r}return null}i(Km,"rawWireCode");function ta(e){return typeof e=="object"&&e!==null}i(ta,"isRecord");async function qm(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(qm,"resolveDeviceAuth");function $m(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return {signal:r.signal,cancel:i(()=>t.clearTimeout(n),"cancel")}}i($m,"boundedSignal");function Ym(e,t){let r=i(()=>{},"noop");if(!t)return {signal:e,dispose:r};let n=new AbortController;if(e.aborted||t.aborted)return n.abort(),{signal:n.signal,dispose:r};let o=i(()=>n.abort(),"onAbort");return e.addEventListener("abort",o,{once:true}),t.addEventListener("abort",o,{once:true}),{signal:n.signal,dispose:i(()=>{e.removeEventListener("abort",o),t.removeEventListener("abort",o);},"dispose")}}i(Ym,"mergeSignals");function Xm(e,t,r){return e<=0||r?.aborted===true?Promise.resolve():new Promise(n=>{let o=t.setTimeout(()=>{r?.removeEventListener("abort",s),n();},e),s=i(()=>{t.clearTimeout(o),n();},"onAbort");r?.addEventListener("abort",s,{once:true});})}i(Xm,"delayAbortable");var Wr=Object.freeze(["better","same","worse"]),io=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ra(e){return E(D("validationFailed",{retryable:false,wireMessage:e}))}i(ra,"invalid");function oo(){return E(D("internalError",{retryable:false}))}i(oo,"malformed");function na(e){return typeof e!="string"||e.trim().length===0?D("validationFailed",{retryable:false,wireMessage:"pet_ref must not be blank"}):Re(e)?D("validationFailed",{retryable:false,wireMessage:"pet_ref contains an unpaired surrogate and cannot be encoded"}):`/widget/v1/pets/${encodeURIComponent(e)}/cases`}i(na,"petPath");var ze=i(e=>typeof e=="string"?e:null,"str"),oa=i(e=>typeof e=="number"&&Number.isFinite(e)?e:null,"count");function ia(e){if(typeof e!="object"||e===null)return null;let t=e,r=ze(t.case_id),n=ze(t.status);if(r===null||n===null)return null;let o=ze(t.last_response);return Object.freeze({caseId:r,status:n,bodyLocation:ze(t.body_location),lastResponse:o!==null&&Wr.includes(o)?o:null,checkInDueAt:ze(t.check_in_due_at),openedAt:ze(t.opened_at),resolvedAt:ze(t.resolved_at),resolutionText:ze(t.resolution_text),checkinAskCount:oa(t.checkin_ask_count),checkinAnswerCount:oa(t.checkin_answer_count)})}i(ia,"caseFromWire");function sa(e){return {async list(t,r){let n=na(t);if(typeof n!="string")return E(n);let o=await e.send("cases.list",{method:"GET",path:n,...r?.signal?{signal:r.signal}:{}});if(!o.ok)return E(o.error);let s=typeof o.value=="object"&&o.value!==null?o.value.cases:null;if(!Array.isArray(s))return oo();let a=s.map(ia);return a.every(l=>l!==null)?L(Object.freeze(a)):oo()},async checkin(t,r,n,o){let s=na(t);if(typeof s!="string")return E(s);if(typeof r!="string"||!io.test(r))return ra("case_id must be a UUID");if(!Wr.includes(n))return ra("response must be one of better, same, worse");let a=await e.send("cases.checkin",{method:"POST",path:`${s}/${r}/checkin`,body:{response:n},...o?.signal?{signal:o.signal}:{}});if(!a.ok)return E(a.error);let l=typeof a.value=="object"&&a.value!==null?a.value:{},u=ia(l.case);return u===null?oo():L(Object.freeze({case:u,ctaDeepLink:ze(l.cta_deep_link)}))}}}i(sa,"createCasesRepositoryOver");var aa=Object.freeze({async presignedPut(){return Promise.reject(new Error("UploadPort is unavailable; no presigned-upload adapter was injected"))}});var la=Object.freeze({setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")});function Kr(e,t,r){return new Promise(n=>{if(t.aborted){n();return}let o={handle:void 0},s=i(()=>{r.clearTimeout(o.handle),t.removeEventListener("abort",s),n();},"done");o.handle=r.setTimeout(s,e),t.addEventListener("abort",s,{once:true});})}i(Kr,"delayAbortable");function qr(e,t){if(!t)return e;let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),r.signal;let n=i(()=>r.abort(),"onAbort");return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),r.signal}i(qr,"mergeSignals");var so=class so{constructor(t){this.listeners=new Set;this.epoch=0;this.inFlight=null;this.snapshot=Object.freeze({...t});}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t);}}getSnapshot(){return this.snapshot}patch(t){this.snapshot=Object.freeze({...this.snapshot,...t});for(let r of this.listeners)r();}beginOperation(t){this.inFlight?.abort();let r=new AbortController;this.inFlight=r;let n=this.epoch;return {signal:t?qr(r.signal,t):r.signal,epoch:n,settle:i(()=>{this.inFlight===r&&(this.inFlight=null);},"settle")}}alive(t){return t===this.epoch}rescope(){this.epoch+=1,this.inFlight?.abort(),this.inFlight=null;}dispose(){this.epoch+=1,this.inFlight?.abort(),this.inFlight=null,this.listeners.clear();}};i(so,"MediaStore");var Gr=so;function lo(e,t,r){return Object.freeze({id:e,role:"user",text:t,createdAt:r,pending:true})}i(lo,"makeUser");function uo(e,t,r){return Object.freeze({id:e,role:"assistant",text:t,createdAt:r})}i(uo,"makeAssistant");function rr(e){return Object.freeze({id:e.id,role:e.role,text:e.text,createdAt:e.createdAt})}i(rr,"stripPending");function ua(e,t){let r={id:e.id,role:e.role,text:e.text+t,createdAt:e.createdAt};return e.citations&&(r.citations=e.citations),e.responseId&&(r.responseId=e.responseId),Object.freeze(r)}i(ua,"appendText");function co(e,t){let r={id:t.messageId?t.messageId:e.id,role:"assistant",text:e.text,createdAt:e.createdAt};return t.citations.length>0&&(r.citations=t.citations),t.messageId&&(r.responseId=t.messageId),r.urgencyLevel=t.urgencyLevel,r.urgencyReason=t.urgencyReason,r.urgencyProvided=t.urgencyProvided,Object.freeze(r)}i(co,"finalizeAssistant");function da(e){return Object.freeze({status:e.status,messages:Object.freeze([...e.messages]),conversationId:e.conversationId,error:e.error,isStreaming:e.isStreaming,isBootstrapping:e.isBootstrapping,suggestedPrompts:Object.freeze([...e.suggestedPrompts]),unreadCount:e.unreadCount})}i(da,"freezeSnapshot");function U(e,t,r){return D(e,{retryable:t,...r?{wireMessage:r}:{}})}i(U,"makeError");function po(e){let t=Oe(e.code);return D(t,{retryable:e.retryable||Ur(t),wireCode:e.code,wireEnvelope:"sse_frame",...e.serverRequestId?{requestId:e.serverRequestId}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},raw:e})}i(po,"errorFromFrame");function Fe(e){return de({code:Qm(e.code),retryable:e.retryable,wireMessage:e.wireMessage??null,synthesized:true,lastEventId:null,serverRequestId:e.requestId??null})}i(Fe,"synthErrorFrame");function Qm(e){switch(e){case "authExpired":return "AUTH_EXPIRED";case "authRejected":return "AuthorizationException";case "sessionRequired":return "session_required";case "accessDenied":return "ACCESS_DENIED";case "paymentRequired":return "TIER_UPGRADE_REQUIRED";case "quotaExceeded":return "QUOTA_EXCEEDED";case "rateLimited":return "RATE_LIMITED";case "validationFailed":return "ValidationException";case "sdkUpdateRequired":return "invalidRequest";case "conflict":return "ConflictException";case "idempotencyConflict":return "IDEMPOTENCY_CONFLICT";case "idempotencyInFlight":return "IDEMPOTENCY_KEY_IN_FLIGHT";case "conversationNotFound":return "CONVERSATION_NOT_FOUND";case "petNotFound":return "PET_NOT_FOUND";case "resourceNotFound":return "ResourceNotFoundException";case "streamTimeout":return "STREAM_TIMEOUT";case "mediaUploadFailed":return "MEDIA_UPLOAD_FAILED";case "moderationBlocked":return "MODERATION_BLOCKED";case "upstreamLlmTimeout":return "UPSTREAM_LLM_TIMEOUT";case "internalError":return "INTERNAL_ERROR";case "notImplemented":return "NotImplementedException";case "serviceUnavailable":return "ServiceUnavailableException";case "streamIncomplete":return "STREAM_INCOMPLETE";case "unknown":return "UNKNOWN";default:return Ze(e)}}i(Qm,"canonicalWireCode");function ca(e){let t=Array.isArray(e)?e:ao(e)&&Array.isArray(e.categories)?e.categories:[],r=[];for(let n of t){if(!ao(n))continue;let o=tr(n.category)??tr(n.title)??"",s=Zm(n.prompts??n.questions);o.length===0&&s.length===0||r.push(Object.freeze({category:o,prompts:Object.freeze(s)}));}return Object.freeze(r)}i(ca,"parsePromptCategories");function fo(e){let t=new Set,r=[];for(let n of e)for(let o of n.prompts){let s=o.trim();s.length===0||t.has(s)||(t.add(s),r.push(s));}return r}i(fo,"flattenPrompts");function ao(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(ao,"isPlainObject");function tr(e){return typeof e=="string"?e:null}i(tr,"asStr");function Zm(e){if(!Array.isArray(e))return [];let t=[];for(let r of e)if(typeof r=="string")t.push(r);else if(ao(r)){let n=tr(r.text)??tr(r.prompt)??tr(r.title);n!==null&&t.push(n);}return t}i(Zm,"asPromptTextList");function pa(){let e=0;return ()=>`m-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,8)}`}i(pa,"defaultIdFactory");function fa(){let e=0;return ()=>`chat-send-${Date.now().toString(36)}-${(e++).toString(36)}-${Math.random().toString(36).slice(2,10)}`}i(fa,"defaultIdempotencyFactory");var ya={setTimeout:i((e,t)=>setTimeout(e,t),"setTimeout"),clearTimeout:i(e=>clearTimeout(e),"clearTimeout"),now:i(()=>Date.now(),"now")};async function*ga(e,t,r,n){let o=e[Symbol.asyncIterator](),s=ma(t.overallMs,n),a=ma(t.idleMs,n),l=ty(r);try{for(;;){if(r.aborted)return;let u=o.next().then(p=>({tag:"next",value:p}),()=>({tag:"streamError"})),d=await Promise.race([u,a.promise.then(()=>({tag:"idle"})),s.promise.then(()=>({tag:"overall"})),l.then(()=>({tag:"abort"}))]);if(d.tag==="abort")return;if(d.tag==="streamError"){if(r.aborted)return;yield ey();return}if(d.tag==="idle"||d.tag==="overall"){yield Jm();return}let c=d.value;if(c.done||(a.reset(t.idleMs),yield c.value,c.value.terminal))return}}finally{a.cancel(),s.cancel(),Promise.resolve(o.return?.(void 0)).catch(()=>{});}}i(ga,"withWatchdog");function Jm(){return de({code:"STREAM_TIMEOUT",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}i(Jm,"synthTimeoutFrame");function ey(){return de({code:"STREAM_INCOMPLETE",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}i(ey,"synthStreamErrorFrame");function ma(e,t){let r=i(()=>{},"resolveFn"),n=new Promise(s=>{r=s;}),o=t.setTimeout(()=>r(),e);return {promise:n,reset(s){t.clearTimeout(o),o=t.setTimeout(()=>r(),s);},cancel(){t.clearTimeout(o);}}}i(ma,"deadline");function ty(e){return new Promise(t=>{if(e.aborted){t();return}e.addEventListener("abort",()=>t(),{once:true});})}i(ty,"abortPromise");var ry="checkin",ny=/^\d{4}-\d{2}-\d{2}$/,$r="watching";function ha(e){return e.status!=null&&e.status!==$r}i(ha,"isCheckinSettled");function ba(e){let{askCount:t,answerCount:r}=e;return typeof t!="number"||!Number.isFinite(t)||typeof r!="number"||!Number.isFinite(r)||t<=0?true:r>=t}i(ba,"isLiveAskAnswered");function mo(e){if(typeof e!="string")return null;let t=e.split(":");if(t.length!==3)return null;let[r,n,o]=t;return r!==ry||n===void 0||o===void 0||!io.test(n)||!ny.test(o)?null:{caseId:n,dueDay:o}}i(mo,"parseCheckinOrigin");function va(e){return mo(e)?.caseId??null}i(va,"parseCheckinOriginRef");function yo(e,t){if(e?.limit!==void 0&&(!Number.isInteger(e.limit)||e.limit<1||e.limit>t))return E(D("validationFailed"));let r=[];for(let[n,o]of [["cursor",e?.cursor],["pet_ref",e?.petRef]])if(o!==void 0){if(typeof o!="string"||o.length===0||Re(o))return E(D("validationFailed"));r.push(`${n}=${encodeURIComponent(o)}`);}return e?.limit!==void 0&&r.push(`limit=${e.limit}`),L(r.length?`?${r.join("&")}`:"")}i(yo,"historyQuery");function ir(e){return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}i(ir,"validConversationId");function or(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}i(or,"object");function Ea(e){return e==null||typeof e=="string"&&e.length>0&&!Re(e)}i(Ea,"cursor");function nr(){return E(D("internalError",{retryable:false}))}i(nr,"malformed");function Ca(e){let t=or(e);if(!t||!Array.isArray(t.conversations)||!Ea(t.next_cursor))return nr();let r=[];for(let n of t.conversations){let o=or(n);if(!o||typeof o.conversation_id!="string"||!ir(o.conversation_id)||!(o.title==null||typeof o.title=="string")||typeof o.created_at!="string"||typeof o.updated_at!="string")return nr();let s=o.unread_message_count;if(!(s==null||Number.isInteger(s)&&s>=0))return nr();r.push(Object.freeze({id:o.conversation_id,title:o.title??null,createdAt:o.created_at,updatedAt:o.updated_at,unreadCount:s??null}));}return L(Object.freeze({conversations:Object.freeze(r),nextCursor:t.next_cursor??null}))}i(Ca,"mapConversationPage");function Ra(e){let t=or(e);if(!t||!Array.isArray(t.messages)||!Ea(t.next_cursor))return nr();let r=[],n=new Set;for(let o of t.messages){let s=or(o);if(!s||typeof s.message_id!="string"||!ir(s.message_id)||typeof s.role!="string"||typeof s.content!="string"||typeof s.created_at!="string")return nr();if(s.role!=="user"&&s.role!=="assistant"||n.has(s.message_id))continue;n.add(s.message_id);let a=typeof s.proactive_origin_ref=="string"?s.proactive_origin_ref:null,l=s.role==="assistant"?va(a):null;r.push(Object.freeze({id:s.message_id,role:s.role,text:s.content,createdAt:s.created_at,...s.role==="assistant"?{responseId:s.message_id}:{},...s.urgency_level!==void 0?{urgencyLevel:oy(s.urgency_level)}:{},...Array.isArray(s.citations)?{citations:iy(s.citations)}:{},...a!==null?{proactiveOriginRef:a}:{},...l!==null?{checkin:Object.freeze({caseId:l,answer:null,resolutionText:null,status:null})}:{}}));}return L(Object.freeze({messages:Object.freeze(r),nextCursor:t.next_cursor??null}))}i(Ra,"mapMessagePage");function oy(e){return e==="emergency"||e==="schedule_soon"||e==="home_care"?e:null}i(oy,"normalizeUrgency");function iy(e){let t=["source_name","source_abbrev","section","authority_tier","doi","url","title","year","study_type","journal","excerpt","monograph_chunk_id"];return Object.freeze(e.flatMap(r=>{let n=or(r);if(!n||typeof n.source_name!="string"||typeof n.authority_tier!="string")return [];let o={};for(let s of t){let a=n[s];(typeof a=="string"||a===null)&&(o[s]=a);}return [Object.freeze(o)]}))}i(iy,"historyCitations");var go=Object.freeze(["helpful","neutral","not_helpful","wrong","outdated","dangerous","unclear"]),Mt=4e3;var Lt=4e3;function Sa(e){return e===void 0?null:!Array.isArray(e)||e.length>5?{reason:"too_many_images",error:U("validationFailed",false,`image_s3_keys accepts at most ${5} keys`)}:e.some(t=>typeof t!="string"||t.trim().length===0)?{reason:"bad_image_key",error:U("validationFailed",false,"image_s3_keys must be non-empty strings")}:null}i(Sa,"validateImageKeys");function bo(e){let t=typeof e=="string"?e:"";if(t.trim().length===0)return {reason:"empty",error:U("validationFailed",false,"message is empty or whitespace-only")};let r=[...t].length;return r>Lt?{reason:"too_long",error:U("validationFailed",false,`message is ${r} characters; the server accepts at most ${Lt}`)}:null}i(bo,"validateMessageText");function Ta(e){return e==="emergency"||e==="schedule_soon"||e==="home_care"?e:null}i(Ta,"urgencyTier");async function*sr(e){yield e;}i(sr,"singleFrameStream");async function*Pa(){}i(Pa,"emptyStream");var sy=6e4,ay=18e4,ly=24,uy=512,dy=false;function ka(e){return new vo(e)}i(ka,"createChatController");var Eo=class Eo extends Gr{constructor(r){super(da({status:"idle",messages:[],conversationId:r.initialConversationId??null,error:null,isStreaming:false,isBootstrapping:false,suggestedPrompts:[],unreadCount:null}));this.handlerTeardowns=new Set;this.lastTurn=null;this.unadoptedCreate=null;this.lastResponseIdValue=null;this.historyGeneration=0;this.disposed=false;this.bootstrapPrompts=[];this.scopePrompts=[];this.replyPrompts=null;this.unreadByConversation=new Map;this.classifiedMessageIds=new Set;this.pendingDelta="";this.flushHandle=null;this.auth=r.auth,this.funnel=r.funnel??xe({auth:r.auth,...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}),this.petRef=r.petRef??null,this.cases=sa(this.funnel),this.telemetry=r.telemetry??Br,this.errorPolicy=r.errorPolicy??Rs,this.timers=r.timers??ya,this.rng=r.rng??Math.random,this.newId=r.newId??pa(),this.makeIdempotencyKey=r.makeIdempotencyKey??fa(),this.budget={idleMs:r.budget?.idleMs??sy,overallMs:r.budget?.overallMs??ay};}patch(r){if(r.messages!==void 0){let n=Object.freeze([...r.messages]);super.patch({...r,messages:n});return}super.patch(r);}send(r,n,o){let s=n??{};if(this.disposed||this.snapshot.isBootstrapping){let u=U(this.disposed?"accessDenied":"internalError",!this.disposed);return o?(o.onError(u),()=>{}):sr(Fe(u))}let a=bo(r)??Sa(s.imageS3Keys);if(a!==null)return this.telemetry.track("chat.send.rejected",{reason:a.reason}),this.patch({status:"error",isStreaming:false,error:a.error}),o?(o.onError(a.error),()=>{}):sr(Fe(a.error));if(o)return this.driveWithHandlers(r,s,o);let l=this.beginTurn(r,s);return this.runTurn(l,s.signal)}askEverfur(r,n){if(this.disposed)return sr(Fe(U("accessDenied",false)));let o=bo(r);return o!==null?(this.telemetry.track("chat.send.rejected",{reason:o.reason}),sr(Fe(o.error))):(this.resetThread(),this.send(r,n??{}))}retryLast(){let r=this.lastTurn;if(r===null){let s=this.snapshot.conversationId;return s!==null&&this.snapshot.status==="error"?this.retryHistory(s):Pa()}r.assistantMessageId=null,r.sawDelta=false,r.conversationIdOverride=null,this.discardPendingDelta();let o=this.snapshot.messages.some(s=>s.id===r.userMessageId)?this.snapshot.messages:[...this.snapshot.messages,lo(r.userMessageId,r.text,this.stamp())];return this.patch({error:null,stopped:false,messages:o}),this.runTurn(r,void 0)}stop(){this.inFlight?.abort(),this.inFlight=null,this.discardPendingDelta(),this.telemetry.track("chat.cancel",{});let r=this.snapshot.messages.some(o=>o.role==="user"&&o.pending===true),n=r?this.snapshot.messages.map(o=>o.pending===true?rr(o):o):this.snapshot.messages;(this.snapshot.status==="streaming"||r)&&this.patch({status:"idle",isStreaming:false,reconnecting:false,...r?{messages:n,stopped:true}:{}});}rescope(){this.resetThread(),this.scopePrompts=[],this.unreadByConversation.clear(),this.classifiedMessageIds.clear(),this.reflectUnreadDot();}resetThread(r=[]){super.rescope(),this.historyGeneration+=1,this.unadoptedCreate=null,this.lastTurn=null,this.lastResponseIdValue=null,this.bootstrapPrompts=r,this.replyPrompts=null,this.discardPendingDelta(),this.patch({status:"idle",isStreaming:false,messages:[],conversationId:null,error:null,suggestedPrompts:r,historyCursor:null,isLoadingHistory:false,isBootstrapping:false,unreadCount:null,stopped:false,reconnecting:false});}newConversation(){this.disposed||this.resetThread(this.scopePrompts);}dispose(){this.rescope(),this.disposed=true,this.unadoptedCreate=null,this.discardPendingDelta();for(let r of this.handlerTeardowns)r();this.handlerTeardowns.clear(),super.dispose();}adoptConversation(r){this.disposed||(this.unadoptedCreate=null,this.snapshot.conversationId!==r&&this.patch({conversationId:r}));}adoptPrompts(r){if(this.disposed)return;let n=Object.freeze(fo(r));this.bootstrapPrompts=n,this.scopePrompts=n,this.replyPrompts===null&&(n.length===0&&this.snapshot.suggestedPrompts.length===0||this.patch({suggestedPrompts:n}));}async listConversations(r){return this.listConversationsWith(r)}async listConversationsWith(r,n){let o=yo(r,100);if(!o.ok)return o;let s=this.epoch;if(this.disposed)return E(U("accessDenied",false));let a=await this.authedUnary("chat.listConversations",{method:"GET",path:`/widget/v1/conversations${o.value}`},r?.signal,n);if(!this.alive(s)||this.disposed)return E(U("accessDenied",false));if(!a.ok)return a;let l=Ca(a.value);if(l.ok){for(let c of l.value.conversations)c.unreadCount!==null&&this.unreadByConversation.set(c.id,c.unreadCount);let u=this.snapshot.conversationId,d=u===null?void 0:this.unreadByConversation.get(u);d!==void 0&&d!==this.snapshot.unreadCount&&this.patch({unreadCount:d}),this.reflectUnreadDot();}return l}reflectUnreadDot(){let r=false;for(let n of this.unreadByConversation.values())if(n>0){r=true;break}r!==(this.snapshot.hasUnreadThreads??false)&&this.patch({hasUnreadThreads:r});}async openCheckin(r){if(this.disposed)return E(U("accessDenied",false));let n=r?.conversationId??null;if(n!==null){let u=await this.resumeConversation(n);return u.ok?L(n):E(u.error)}let o=r?.petRef??this.petRef,s=await this.listConversations({...o===null?{}:{petRef:o},limit:1});if(!s.ok)return E(s.error);let a=s.value.conversations[0];if(a===void 0)return L(null);let l=await this.resumeConversation(a.id);return l.ok?L(a.id):E(l.error)}async markRead(r){if(this.disposed)return E(U("accessDenied",false));let n=this.snapshot.conversationId;if(n===null)return L(void 0);let o=this.epoch,s=await this.authedUnary("chat.markRead",{method:"POST",path:`/widget/v1/conversations/${n}/read`},r?.signal);return !this.alive(o)||this.disposed?E(U("accessDenied",false)):s.ok?(this.unreadByConversation.set(n,0),this.snapshot.conversationId===n&&this.snapshot.unreadCount!==0&&this.patch({unreadCount:0}),this.reflectUnreadDot(),L(void 0)):E(s.error)}async submitFeedback(r,n,o,s){if(this.disposed)return E(U("accessDenied",false));if(typeof r!="string"||r.trim().length===0||Re(r))return E(U("validationFailed",false,"feedback needs the server message id of an assistant reply"));if(!go.includes(n))return E(U("validationFailed",false,`feedback_type must be one of ${go.join(", ")}`));let a=typeof o=="string"?o.trim():"";if([...a].length>Mt)return E(U("validationFailed",false,`notes is over ${Mt} characters`));let l={feedback_type:n};a.length>0&&(l.notes=a);let u=this.epoch,d=await this.authedUnary("chat.submitFeedback",{method:"POST",path:`/widget/v1/messages/${encodeURIComponent(r)}/feedback`,body:l},s?.signal);if(!this.alive(u)||this.disposed)return E(U("accessDenied",false));if(!d.ok)return E(d.error);let c=d.value?.feedback_id;return L(Object.freeze({feedbackId:typeof c=="string"?c:""}))}async answerCheckin(r,n,o){if(this.disposed)return E(U("accessDenied",false));let s=o?.petRef??this.petRef;if(s===null)return E(U("validationFailed",false,"a check-in needs the pet the case belongs to"));let a=this.epoch,l=await this.cases.checkin(s,r,n,o?.signal?{signal:o.signal}:{});if(!this.alive(a)||this.disposed)return E(U("accessDenied",false));if(!l.ok)return l;let u=l.value.case.openedAt,d=Object.freeze({caseId:r,answer:n,resolutionText:l.value.case.resolutionText,status:l.value.case.status??null,...u!==null?{openedAt:u}:{}}),c=i(p=>p.checkin?.caseId===r,"carries");return this.snapshot.messages.some(c)&&this.patch({messages:this.snapshot.messages.map(p=>c(p)?Object.freeze({...p,checkin:d}):p)}),l}async getMessages(r,n){if(!ir(r))return E(U("validationFailed",false));let o=yo(n,200);if(!o.ok)return o;let s=this.epoch;if(this.disposed)return E(U("accessDenied",false));let a=await this.authedUnary("chat.getMessages",{method:"GET",path:`/widget/v1/conversations/${r}/messages${o.value}`},n?.signal);return !this.alive(s)||this.disposed?E(U("accessDenied",false)):a.ok?Ra(a.value):a}async resumeConversation(r){if(this.disposed)return E(U("accessDenied",false));if(!ir(r))return E(U("validationFailed",false));this.resetThread();let n=this.historyGeneration;this.patch({conversationId:r,isBootstrapping:true,isLoadingHistory:true});let o=await this.getMessages(r);if(n!==this.historyGeneration||this.disposed)return E(U("accessDenied",false));if(!o.ok)return this.patch({status:"error",error:o.error,isBootstrapping:false,isLoadingHistory:false}),o;let s=this.unreadByConversation.get(r)??null;return this.patch({messages:o.value.messages,historyCursor:o.value.nextCursor,isBootstrapping:false,isLoadingHistory:false,unreadCount:s}),this.stampCheckinStatuses(n),s!==null&&s>0&&this.markRead(),L(void 0)}async stampCheckinStatuses(r){let n=this.petRef;if(n===null||!this.snapshot.messages.some(d=>d.checkin!==void 0&&d.checkin.status===null))return;let o=await this.cases.list(n);if(!o.ok||r!==this.historyGeneration||this.disposed)return;let s=new Set(o.value.filter(d=>d.status===$r).map(d=>d.caseId)),a=new Map(o.value.map(d=>[d.caseId,d])),l=false,u=this.snapshot.messages.map(d=>{let c=d.checkin;if(c===void 0||c.status!==null)return d;l=true;let p=a.get(c.caseId),f=c.openedAt??p?.openedAt??null,m=s.has(c.caseId),y=p!==void 0&&(!m||ba({askCount:p.checkinAskCount,answerCount:p.checkinAnswerCount}))?p.lastResponse:null;return Object.freeze({...d,checkin:Object.freeze({...c,status:m?$r:p?.status??"resolved",answer:c.answer??y,resolutionText:c.resolutionText??p?.resolutionText??null,...f!==null?{openedAt:f}:{}})})});l&&this.patch({messages:u});}async refreshActiveThread(){if(this.disposed)return E(U("accessDenied",false));let r=this.snapshot.conversationId;if(r===null||this.snapshot.isStreaming)return L(void 0);let n=this.historyGeneration,o=await this.getMessages(r);if(n!==this.historyGeneration||this.disposed)return E(U("accessDenied",false));if(!o.ok)return E(o.error);let s=new Set(this.snapshot.messages.map(l=>l.id)),a=o.value.messages.filter(l=>!s.has(l.id));return a.length>0&&this.patch({messages:[...this.snapshot.messages,...a]}),await this.listConversationsWith({...this.petRef===null?{}:{petRef:this.petRef},limit:1},{maxAttempts:1}),L(void 0)}async loadOlderMessages(){if(this.disposed)return E(U("accessDenied",false));let r=this.snapshot.conversationId,n=this.snapshot.historyCursor;if(!r||!n||this.snapshot.isLoadingHistory)return L(void 0);let o=this.historyGeneration;this.patch({isLoadingHistory:true});let s=await this.getMessages(r,{cursor:n});if(o!==this.historyGeneration||this.disposed)return E(U("accessDenied",false));if(this.patch({isLoadingHistory:false}),!s.ok)return s;let a=new Set(this.snapshot.messages.map(u=>u.id)),l=s.value.messages.filter(u=>!a.has(u.id));return this.patch({messages:[...l,...this.snapshot.messages],historyCursor:s.value.nextCursor===n?null:s.value.nextCursor}),L(void 0)}async*retryHistory(r){let n=await this.resumeConversation(r);n.ok||(yield Fe(n.error));}async primeConversation(r){if(this.disposed)return E(U("accessDenied",false));let n=r?.petRef??null,o={petRef:n,settled:this.primeBounded(n)};this.unadoptedCreate=o;let s=await o.settled;return this.disposed?E(U("accessDenied",false)):(!s.ok&&this.unadoptedCreate===o&&(this.unadoptedCreate=null),s)}async primeBounded(r){let n=await this.headThreadWithUnread(r);if(n!==null&&!this.snapshot.isStreaming&&this.snapshot.conversationId===null&&(await this.resumeConversation(n)).ok)return L(n);let o=this.snapshot.conversationId;return o!==null?L(o):this.createConversationBounded(r)}async headThreadWithUnread(r){let n=await this.listConversationsWith({...r===null?{}:{petRef:r},limit:1},{maxAttempts:1});if(!n.ok)return null;let o=n.value.conversations[0];return o===void 0||o.unreadCount===null||o.unreadCount<=0?null:o.id}async createConversation(r){let n=this.epoch;if(this.disposed)return E(U("accessDenied",false));let o=r?.petRef??null,s={petRef:o,settled:this.createConversationBounded(o)};this.unadoptedCreate=s;let a=await s.settled;return !this.alive(n)||this.disposed?E(U("accessDenied",false)):(!a.ok&&this.unadoptedCreate===s&&(this.unadoptedCreate=null),a)}async createConversationBounded(r,n){let o={method:"POST",path:"/widget/v1/conversations",body:r?{pet_ref:r}:{}},s=await this.authedUnary("chat.createConversation",o,n,{maxAttempts:1});if(!s.ok)return E(s.error);let a=s.value?.conversation_id??s.value?.id;return typeof a!="string"||a.length===0?E(U("internalError",true)):L(a)}async getPrompts(r){let n=this.epoch;if(this.disposed)return E(U("accessDenied",false));let o=r?.petRef??null;if(o!==null&&Re(o))return E(D("validationFailed",{retryable:false,wireMessage:"pet_ref contains an unpaired surrogate and cannot be encoded"}));let s=o!==null?`?pet_ref=${encodeURIComponent(o)}`:"",a=await this.authedUnary("chat.getPrompts",{method:"GET",path:`/widget/v1/suggested-prompts${s}`});return !this.alive(n)||this.disposed?E(U("accessDenied",false)):a.ok?L(ca(a.value)):E(a.error)}async authedUnary(r,n,o,s){return this.funnel.send(r,o?{...n,signal:o}:n,s)}driveWithHandlers(r,n,o){let s=new AbortController,a=qr(s.signal,n.signal),l=this.beginTurn(r,n),u=this.runTurn(l,a),d=false,c=i(()=>{d||(d=true,s.abort(),this.handlerTeardowns.delete(c));},"teardown");return this.handlerTeardowns.add(c),(async()=>{for await(let p of u){if(d)break;o.onFrame(p),p.kind==="done"&&o.onDone(this.lastResponseIdValue);}!d&&this.snapshot.status==="error"&&this.snapshot.error!==null&&o.onError(this.snapshot.error),this.handlerTeardowns.delete(c);})(),c}beginTurn(r,n){let o={epoch:this.epoch,text:r,petRef:n.petRef??null,imageS3Keys:Object.freeze([...n.imageS3Keys??[]]),idempotencyKey:n.idempotencyKey??this.makeIdempotencyKey(),userMessageId:this.newId(),assistantMessageId:null,sawDelta:false,conversationIdOverride:n.conversationId??null};return this.patch({error:null,stopped:false,reconnecting:false,messages:[...this.snapshot.messages,lo(o.userMessageId,r,this.stamp())]}),o}async*runTurn(r,n){let o=this.beginOperation(n);r.epoch=o.epoch,this.patch({status:"streaming",isStreaming:true,error:null}),this.lastTurn=r;let s=0,a=false,l=false;try{for(;;){if(o.signal.aborted||!this.alive(o.epoch))return;let u=r.conversationIdOverride===null&&this.snapshot.conversationId===null,d=u?this.unadoptedCreate:null;if(d!==null&&(r.petRef===null||r.petRef===d.petRef)){let b=await d.settled;if(o.signal.aborted||!this.alive(o.epoch))return;b.ok&&this.snapshot.conversationId===null&&this.adoptConversation(b.value);}if(u&&this.snapshot.conversationId===null){let b=await this.createConversationBounded(r.petRef,o.signal);if(o.signal.aborted||!this.alive(o.epoch))return;if(!b.ok){yield*this.emitTerminal(r,b.error,Fe(b.error));return}this.adoptConversation(b.value);}let c=r.conversationIdOverride??this.snapshot.conversationId;if(c===null){let b=U("internalError",!0);yield*this.emitTerminal(r,b,Fe(b));return}this.clearAssistantInProgress(r);let p=new AbortController,f=qr(o.signal,p.signal),m=null;try{let b;try{b=await this.funnel.authorize(this.buildSendRequest(r,c));}catch{let _=this.authRejected();yield*this.emitTerminal(r,_,Fe(_));return}if(o.signal.aborted||!this.alive(o.epoch))return;let C=this.funnel.stream("chat.send",b,f);for await(let _ of ga(C,this.budget,f,this.timers)){if(!this.alive(o.epoch))return;if(_.kind==="error"&&_.terminal){m=_;break}if(this.applyFrame(_,r),yield _,_.terminal){o.settle();return}}}finally{p.abort();}if(o.signal.aborted||!this.alive(o.epoch))return;if(m===null){if(this.snapshot.status==="complete")return;let b=U("streamIncomplete",!0);yield*this.emitTerminal(r,b,Fe(b));return}let y=Oe(m.code);if(y==="authExpired"&&this.auth.mode==="personalized"&&!l){l=!0,this.telemetry.track("chat.auth.refresh",{});let b=await this.tryForceRefresh();if(o.signal.aborted||!this.alive(o.epoch))return;if(!b){let C=this.authRejected();yield*this.emitTerminal(r,C,m);return}this.patch({reconnecting:!0});continue}if(y==="authExpired"){this.telemetry.track("chat.auth.rejected",{});let b=this.authRejected();yield*this.emitTerminal(r,b,m);return}if(y==="accessDenied"){this.telemetry.track("chat.access_denied",{}),yield*this.emitTerminal(r,po(m),m);return}if(Es(y)&&!a){a=!0,this.telemetry.track("chat.conv.recreate",{}),this.adoptConversation(null),r.conversationIdOverride=null,this.patch({reconnecting:!0});continue}let x=m.retryable&&Ur(y,!0);if(dy&&x&&s+1<this.errorPolicy.maxAttempts(y));yield*this.emitTerminal(r,po(m),m);return}}finally{o.settle();}}*emitTerminal(r,n,o){this.applyError(r,n),yield o;}applyFrame(r,n){switch(r.kind){case "accepted":this.snapshot.isStreaming||this.patch({status:"streaming",isStreaming:true});return;case "heartbeat":return;case "delta":this.applyDelta(r.delta,n);return;case "done":this.applyDone(r,n);return;case "analysisStarted":case "analysisComplete":return;case "unknown":this.telemetry.track("chat.frame.unknown",{});return;case "error":return;default:return Ze(r)}}stamp(){return new Date(this.timers.now()).toISOString()}applyDelta(r,n){if(n.assistantMessageId===null){let o=this.newId();n.assistantMessageId=o,n.sawDelta=true;let s=this.snapshot.messages.map(a=>a.id===n.userMessageId&&a.pending===true?rr(a):a);this.patch({status:"streaming",isStreaming:true,messages:[...s,uo(o,r,this.stamp())]});return}if(this.pendingDelta+=r,this.pendingDelta.length>=uy){this.flushPendingDelta(n);return}this.scheduleDeltaFlush(n);}scheduleDeltaFlush(r){if(this.flushHandle!==null)return;let n=this.epoch;this.flushHandle=this.timers.setTimeout(()=>{if(this.flushHandle=null,!this.alive(n)){this.pendingDelta="";return}this.flushPendingDelta(r);},ly);}flushPendingDelta(r){if(this.clearFlushTimer(),this.pendingDelta.length===0)return;let n=this.pendingDelta;this.pendingDelta="";let o=r.assistantMessageId;if(o===null)return;let s=this.snapshot.messages.map(a=>a.id===o?ua(a,n):a);this.patch({messages:s});}discardPendingDelta(){this.clearFlushTimer(),this.pendingDelta="";}clearFlushTimer(){this.flushHandle!==null&&(this.timers.clearTimeout(this.flushHandle),this.flushHandle=null);}applyDone(r,n){this.flushPendingDelta(n),this.lastResponseIdValue=r.messageId?r.messageId:null;let o=r.conversationId?r.conversationId:this.snapshot.conversationId,s;if(n.assistantMessageId!==null)s=this.snapshot.messages.map(l=>l.id===n.assistantMessageId?co(l,r):l);else {let l=this.newId();n.assistantMessageId=l,n.sawDelta=true,s=[...this.snapshot.messages.map(d=>d.id===n.userMessageId&&d.pending===true?rr(d):d),co(uo(l,"",this.stamp()),r)];}let a=fo([{category:"",prompts:r.followUpQuestions}]);this.replyPrompts=a.length>0?Object.freeze(a):null,this.patch({status:"complete",isStreaming:false,error:null,conversationId:o,messages:s,suggestedPrompts:this.replyPrompts??this.bootstrapPrompts,reconnecting:false}),!r.urgencyProvided&&o!==null&&this.classifyTurn(o,this.lastResponseIdValue);}async classifyTurn(r,n){if(n===null||this.disposed)return;let o=String(n);if(this.classifiedMessageIds.has(o))return;this.classifiedMessageIds.add(o);let s=this.epoch,a=this.historyGeneration,l=await this.authedUnary("chat.classifyUrgency",{method:"POST",path:`/widget/v1/conversations/${r}/classify`});if(!l.ok||!this.alive(s)||this.disposed||a!==this.historyGeneration||this.snapshot.conversationId!==r)return;let u=Ta(l.value?.urgency),d=typeof l.value?.reason=="string"?l.value.reason:null,c=i(p=>p.responseId===n,"carries");this.snapshot.messages.some(c)&&this.patch({messages:this.snapshot.messages.map(p=>c(p)?Object.freeze({...p,urgencyLevel:u,urgencyReason:d,urgencyProvided:true}):p)});}applyError(r,n){this.flushPendingDelta(r);let o=this.snapshot.messages.map(s=>s.id===r.userMessageId&&s.pending===true?rr(s):s);this.patch({status:"error",isStreaming:false,error:n,messages:o,reconnecting:false});try{this.errorPolicy.onExpectedFailure?.(n);}catch{}}clearAssistantInProgress(r){if(this.discardPendingDelta(),r.assistantMessageId===null)return;let n=r.assistantMessageId;r.assistantMessageId=null,r.sawDelta=false;let o=this.snapshot.messages.filter(s=>s.id!==n);o.length!==this.snapshot.messages.length&&this.patch({messages:o});}buildSendRequest(r,n){let o={message:r.text};return r.imageS3Keys.length>0&&(o.image_s3_keys=r.imageS3Keys),{method:"POST",path:`/widget/v1/conversations/${n}/messages`,body:o,headers:{"Idempotency-Key":r.idempotencyKey}}}async tryForceRefresh(){if(this.auth.mode!=="personalized")return false;try{return await this.auth.identity.currentToken({forceRefresh:!0}),!0}catch{return false}}authRejected(){return U("authRejected",false)}};i(Eo,"ChatControllerImpl");var vo=Eo;async function wa(e,t){let{controller:r}=t,n=e.petRef??null,o=e.resumeConversationId??null,s=[],a=false,l=false,u=false,d=null,c=null,p=o?r.resumeConversation(o).then(k=>k.ok?L(o):k):r.primeConversation(n?{petRef:n}:void 0),f=r.getPrompts(n!==null?{petRef:n}:void 0),[m,y]=await Promise.all([p,f]),x=null;if(m.ok)x=m.value,s.push(m.value),r.getSnapshot().conversationId===null&&r.adoptConversation(m.value);else {let k=m.error;c=k,xa(k)?(l=true,d=k):(_a(k)&&(a=true),u=true);}let b=[];y.ok?b=y.value:C(y.error);function C(k){xa(k)?(l=true,d===null&&(d=k)):_a(k)&&(a=true);}i(C,"recordAuthSignals");let _=d!==null?d.displayMessage:null;return Object.freeze({conversationId:x,petRef:n,suggestedPrompts:b,error:_,warning:_===null&&x===null&&u?cy:null,cause:d??c,diagnostics:Object.freeze({candidateConversationIds:Object.freeze([...s]),sawForbidden:a,sawUnauthorized:l,sawConversationInitFailure:u})})}i(wa,"bootstrapChat");var cy="Chat is ready. Your first message will start the conversation.";function xa(e){return e.httpStatus===401||e.code==="authExpired"||e.code==="authRejected"}i(xa,"isUnauthorized");function _a(e){return e.httpStatus===403||e.code==="accessDenied"}i(_a,"isForbidden");var Co=Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function Ia(e){return e!==Co}i(Ia,"isUploadTransportAvailable");var py=Object.freeze(["image/jpeg","image/jpg","image/png","image/heic","image/heif","image/webp"]);var Yr=10*1024*1024,Xr=5,ar=120,fy="/widget/v1/uploads/initiate";function my(e){return typeof e=="string"&&py.includes(e.trim().toLowerCase())}i(my,"isAttachmentMime");function Ro(e){if(!e)return "attachment";let t=e.replace(/[\\/]+/g," ").replace(/[\x00-\x1f\x7f"]/g,"").replace(/\s+/g," ").trim();if(!t)return "attachment";if(t.length<=ar)return t;let r=t.lastIndexOf(".");if(r===-1||r===t.length-1)return t.slice(0,ar);let n=t.slice(r);return n.length>=ar?t.slice(0,ar):`${t.slice(0,r).slice(0,ar-n.length)}${n}`}i(Ro,"sanitizeFilename");function So(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}i(So,"formatBytes");var lr=i(e=>Object.freeze({ok:true,value:e}),"ok"),_e=i(e=>Object.freeze({ok:false,error:e}),"err");function oe(e,t,r,n){return Object.freeze({code:e,retryable:t,filename:r,...n??{}})}i(oe,"failure");function yy(e){if(typeof e.sizeBytes=="number"&&Number.isFinite(e.sizeBytes)&&e.sizeBytes>=0)return e.sizeBytes;let t=e.blob;return t!==void 0&&typeof t.size=="number"&&Number.isFinite(t.size)?t.size:null}i(yy,"attachmentSize");function gy(e){let t=Ro(e.name),r=typeof e.mimeType=="string"?e.mimeType.trim().toLowerCase():"";if(!my(r))return _e(oe("unsupported_type",false,t));let n=yy(e);return n===null?_e(oe("unknown",false,t)):n>Yr?_e(oe("too_large",false,t,{sizeBytes:n})):lr(Object.freeze({file:e,filename:t,contentType:r,sizeBytes:n}))}i(gy,"validateAttachment");function hy(e){if(typeof e!="object"||e===null)return null;let t=e,r=i(d=>typeof d=="string"&&d.length>0?d:null,"str"),n=i(d=>typeof d=="number"&&Number.isFinite(d)?d:null,"num"),o=r(t.upload_id),s=r(t.upload_url),a=r(t.s3_key);if(o===null||s===null||a===null)return null;let l={},u=t.upload_fields;if(typeof u=="object"&&u!==null)for(let[d,c]of Object.entries(u))typeof c=="string"&&(l[d]=c);return Object.freeze({upload_id:o,upload_url:s,upload_fields:Object.freeze(l),expires_in_seconds:n(t.expires_in_seconds)??0,max_content_length:n(t.max_content_length)??Yr,s3_key:a,purpose:r(t.purpose)})}i(hy,"parsePolicy");function by(e,t){let r=e.httpStatus;switch(e.code){case "quotaExceeded":return oe("quota_exceeded",false,t,{cause:e});case "rateLimited":return oe("rate_limited",true,t,{cause:e});case "idempotencyConflict":case "idempotencyInFlight":return oe("idempotency_conflict",true,t,{cause:e});case "validationFailed":return oe("unsupported_type",false,t,{cause:e});case "serviceUnavailable":case "streamTimeout":return oe("network",true,t,{cause:e});default:return r===429?oe("rate_limited",true,t,{cause:e}):r===503?oe("network",true,t,{cause:e}):r===void 0?oe("network",true,t,{cause:e}):oe("server",e.retryable,t,{httpStatus:r,cause:e})}}i(by,"initiateFailure");async function vy(e,t,r){let n=await e.send("chat.attachments.initiate",{method:"POST",path:fy,body:{filename:t.filename,content_type:t.contentType,file_size:t.sizeBytes},...r?.signal?{signal:r.signal}:{}});if(!n.ok)return _e(by(n.error,t.filename));let o=hy(n.value);return o===null?_e(oe("server",false,t.filename)):lr(o)}i(vy,"initiateAttachmentUpload");async function Ey(e,t,r,n){let o=i(()=>n?.signal?.aborted===true,"cancelled");if(o())return _e(oe("cancelled",true,r.filename));try{return await e.postMultipart(t,r.file,{...n?.signal?{signal:n.signal}:{},...n?.onProgress?{onProgress:n.onProgress}:{}}),lr(void 0)}catch{return o()?_e(oe("cancelled",true,r.filename)):_e(oe("server",true,r.filename))}}i(Ey,"uploadAttachmentBytes");var Cy=2,Ry=3,Sy=Object.freeze([1e3,2e3,4e3]),Aa=0;function Ty(){return Aa+=1,`attachment-${Aa}`}i(Ty,"defaultNewId");function Oa(e){let t=Math.max(1,e.concurrency??Cy),r=Math.max(1,e.maxAttempts??Ry),n=e.backoffMs??Sy,o=Math.max(1,e.maxPerMessage??Xr),s=e.timers??la,a=e.newId??Ty,l=Ia(e.transport),u=new Map,d=[],c=[],p=new Set,f=new Set,m=Object.freeze({attachments:Object.freeze([])}),y=false,x=i(()=>{m=Object.freeze({attachments:Object.freeze(d.flatMap(g=>{let w=u.get(g);return w===void 0?[]:[w.state]}))});for(let g of f)g();},"publish"),b=i((g,w)=>{g.state=Object.freeze({...g.state,...w}),x();},"patch"),C=i(()=>{for(;!y&&p.size<t&&c.length>0;){let g=c.shift(),w=u.get(g);w!==void 0&&(p.add(g),_(w).finally(()=>{p.delete(g),C();}));}},"pump"),_=i(async g=>{let{attachment:w}=g;for(;g.attempts<r;){if(y||g.controller.signal.aborted)return;g.attempts+=1;let O=g.controller.signal;b(g,{status:"uploading",error:null,progress:0});let M=await vy(e.funnel,w,{signal:O});if(y||O.aborted)return;let I;if(!M.ok)I=_e(M.error);else {let j=await Ey(e.transport,M.value,w,{signal:O,onProgress:i(W=>{!O.aborted&&g.state.status==="uploading"&&b(g,{progress:Py(W)});},"onProgress")});if(y||O.aborted)return;I=j.ok?lr(M.value.s3_key):_e(j.error);}if(I.ok){b(g,{status:"uploaded",s3Key:I.value,error:null,progress:1});return}let v=I.error,T=v.retryable&&g.attempts<r;if(b(g,{status:T?"uploading":"failed",error:v,progress:0}),!T)return;let V=n[Math.min(g.attempts-1,n.length-1)]??0;await Kr(V,O,s);}},"run"),P=i(g=>{c.push(g.state.id),C();},"enqueue"),k={available:l,subscribe(g){return f.add(g),()=>{f.delete(g);}},getSnapshot:i(()=>m,"getSnapshot"),get uploading(){return m.attachments.some(g=>g.status==="uploading")},get s3Keys(){return m.attachments.flatMap(g=>g.status==="uploaded"&&g.s3Key!==null?[g.s3Key]:[])},add(g){let w=gy(g);if(!w.ok)return w;if(y||d.length>=o)return _e(oe("too_many",false,w.value.filename));let O=a(),M={attachment:w.value,controller:new AbortController,attempts:0,state:Object.freeze({id:O,filename:w.value.filename,previewUri:g.uri,contentType:w.value.contentType,sizeBytes:w.value.sizeBytes,status:"uploading",s3Key:null,error:null,progress:0})};return u.set(O,M),d.push(O),x(),P(M),lr(M.state)},retry(g){let w=u.get(g);w===void 0||y||w.state.status!=="failed"||(w.controller=new AbortController,w.attempts=0,b(w,{status:"uploading",error:null,progress:0,s3Key:null}),P(w));},remove(g){let w=u.get(g);if(w===void 0)return;w.controller.abort(),u.delete(g);let O=d.indexOf(g);O>=0&&d.splice(O,1);let M=c.indexOf(g);M>=0&&c.splice(M,1),x();},clear(){for(let g of [...d])k.remove(g);},dispose(){y=true;for(let g of u.values())g.controller.abort();u.clear(),d.length=0,c.length=0,f.clear(),m=Object.freeze({attachments:Object.freeze([])});}};return k}i(Oa,"createAttachmentQueue");function Py(e){return Number.isNaN(e)||e<0?0:e>1?1:e}i(Py,"clamp");var Fa=Object.freeze({dog:"dog",canine:"dog",k9:"dog",puppy:"dog",cat:"cat",feline:"cat",kitten:"cat"});function ur(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.prototype.hasOwnProperty.call(Fa,t)?Fa[t]:null}i(ur,"canonicalPetSpecies");var Ma=50,ky=128,To=120,La=120,xy=2e3,Da=120,_y=80,Va=new Set(["male","female","unknown"]),Ha=new Set(["day","month","year"]),Ba=new Set(["low","medium","high","athletic"]),za=new Set(["indoor","outdoor","both"]),ja=new Set(["mild","moderate","severe"]),wy=/^(\d{4})-(\d{2})-(\d{2})$/,Wa=[["sex","sex"],["spayedNeutered","spayed_neutered"],["birthDate","birth_date"],["birthDatePrecision","birth_date_precision"],["activityLevel","activity_level"],["indoorOutdoor","indoor_outdoor"],["foodBrand","food_brand"],["foodType","food_type"],["microchipId","microchip_id"]],Ga=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];Object.freeze([...Wa,...Ga].map(([e])=>e));function Iy(e){let t=wy.exec(e);if(t===null)return false;let[r,n,o]=[Number(t[1]),Number(t[2]),Number(t[3])],s=new Date(Date.UTC(r,n-1,o));return s.getUTCFullYear()===r&&s.getUTCMonth()===n-1&&s.getUTCDate()===o}i(Iy,"isRealDate");var cr=i(e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,"oneOf"),Ay=i((e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,"boolean"),Zr=i((e,t)=>typeof t=="string"&&Iy(t)?null:`${e} must be a real date written YYYY-MM-DD`,"date"),Me=i((e,t={})=>(r,n)=>{if(typeof n!="string")return `${r} must be a string`;if(Re(n))return `${r} contains an unpaired surrogate and cannot be encoded`;let o=t.trimmed?n.trim():n;if(t.required&&o.length===0)return `${r} is required and must not be blank`;let s=at(o);return s<=e?null:`${r} is ${s} characters; the server accepts at most ${e}`},"text"),Oy={sex:cr(Va),spayedNeutered:Ay,birthDate:Zr,birthDatePrecision:cr(Ha),activityLevel:cr(Ba),indoorOutdoor:cr(za),foodBrand:Me(Da),foodType:Me(Da),microchipId:Me(_y)},Po=["ref","ref",false,Me(ky,{required:true,trimmed:true})],ko=["notes","notes",false,Me(xy,{trimmed:true})],Na=[Po,["name","name",true,Me(To,{required:true,trimmed:true})],["dose","dose",false,Me(La,{trimmed:true})],["frequency","frequency",false,Me(La,{trimmed:true})],["startDate","start_date",false,Zr],["endDate","end_date",false,Zr],ko],Fy={allergies:[Po,["allergen","allergen",true,Me(To,{required:true,trimmed:true})],["severity","severity",false,cr(ja)],ko],medications:Na,supplements:Na,conditions:[Po,["conditionName","condition_name",true,Me(To,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,Zr],ko]};function My(e,t,r){let n=`${e}[${t}]`;if(typeof r!="object"||r===null||Array.isArray(r))return {error:`${n} must be an object`};let o=r,s={};for(let[u,d,c,p]of Fy[e]){let f=o[u];if(f==null){if(c)return {error:`${n}.${u} is required`};f===null&&(s[d]=null);continue}let m=p(`${n}.${u}`,f);if(m!==null)return {error:m};s[d]=f;}let a=s.start_date,l=s.end_date;return typeof a=="string"&&typeof l=="string"&&l<a?{error:`${n}.endDate must not be before startDate`}:{item:s}}i(My,"itemToWire");function Ly(e,t){if(!Array.isArray(t))return {error:`${e} must be an array (send [] to clear it)`};if(t.length>Ma)return {error:`${e} has ${t.length} items; the server accepts at most ${Ma}`};let r=[],n=new Set;for(let o=0;o<t.length;o+=1){let s=My(e,o,t[o]);if("error"in s)return s;let a=s.item.ref;if(typeof a=="string"){let l=a.trim();if(n.has(l))return {error:`${e}: ref ${JSON.stringify(l)} is used twice; a ref names one item`};n.add(l);}r.push(s.item);}return {items:r}}i(Ly,"listToWire");function Ka(e,t){let r=e,n={};for(let[a,l]of Wa){let u=r[a];if(u!==void 0){if(u!==null){let d=Oy[a](a,u);if(d!==null)return {error:d}}n[l]=u;}}let o=r.birthDate!==void 0,s=r.birthDatePrecision!==void 0;if(o!==s||o&&r.birthDate===null!=(r.birthDatePrecision===null))return {error:"birthDate and birthDatePrecision must be sent together, both set or both null"};for(let[a,l]of Ga){let u=r[a];if(u===void 0)continue;let d=Ly(a,u);if("error"in d)return d;n[l]=d.items;}return Object.keys(n).length>0&&t!==void 0&&ur(t)===null?{error:"health fields need a pet Everfur reads as a dog or a cat (dog, canine, k9, puppy, cat, feline, kitten)"}:{body:n}}i(Ka,"petHealthToWire");var ee=i(e=>typeof e=="string"?e:null,"str"),dr=i((e,t)=>typeof t=="string"&&e.has(t)?t:null,"pick"),Dy=i(e=>typeof e=="boolean"?e:null,"bool");function Qr(e,t){return Array.isArray(e)?Object.freeze(e.flatMap(r=>{if(typeof r!="object"||r===null||Array.isArray(r))return [];let n=t(r);return n===null?[]:[n]})):Object.freeze([])}i(Qr,"itemsFromWire");function Ua(e){let t=ee(e.name);return t===null||t.length===0?null:Object.freeze({ref:ee(e.ref),name:t,dose:ee(e.dose),frequency:ee(e.frequency),startDate:ee(e.start_date),endDate:ee(e.end_date),notes:ee(e.notes)})}i(Ua,"medicationFromWire");function qa(e){let t=e.profile_version;return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:dr(Va,e.sex),spayedNeutered:Dy(e.spayed_neutered),birthDate:ee(e.birth_date),birthDatePrecision:dr(Ha,e.birth_date_precision),activityLevel:dr(Ba,e.activity_level),indoorOutdoor:dr(za,e.indoor_outdoor),foodBrand:ee(e.food_brand),foodType:ee(e.food_type),microchipId:ee(e.microchip_id),allergies:Qr(e.allergies,r=>{let n=ee(r.allergen);return n===null||n.length===0?null:Object.freeze({ref:ee(r.ref),allergen:n,severity:dr(ja,r.severity),notes:ee(r.notes)})}),medications:Qr(e.medications,Ua),supplements:Qr(e.supplements,Ua),conditions:Qr(e.conditions,r=>{let n=ee(r.condition_name);return n===null||n.length===0?null:Object.freeze({ref:ee(r.ref),conditionName:n,diagnosedDate:ee(r.diagnosed_date),notes:ee(r.notes)})})})}i(qa,"petHealthFromWire");var Xa=100,Qa=50,Za=100,Ja=50,el=500,Ny=128,Uy=6e4;function De(e){return D("validationFailed",{retryable:false,wireMessage:e})}i(De,"invalid");function lt(e,t,r){if(typeof t!="string")return De(`${e} must be a string`);let n=at(t);return n<=r?null:De(`${e} is ${n} characters; the server accepts at most ${r}`)}i(lt,"checkString");function Jr(e,t,r){return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=r?null:De(`${e} must be a finite number between 0 and ${r}`)}i(Jr,"outOfRange");function $a(e,t){if(typeof e!="string")return De("pet_ref must be a string");if(e.trim().length===0)return De("pet_ref must not be blank");if(Re(e))return De("pet_ref contains an unpaired surrogate and cannot be encoded");if(t!=null&&typeof t!="object")return De("profile must be an object");let r=[lt("pet_ref",e,Ny)];return t?.name!==void 0&&r.push(lt("name",t.name,Xa)),t?.species!==void 0&&r.push(lt("species",t.species,Qa)),t?.breed!==void 0&&r.push(lt("breed",t.breed,Za)),t?.ageYears!==void 0&&r.push(Jr("age_years",t.ageYears,Ja)),t?.weightKg!==void 0&&r.push(Jr("weight_kg",t.weightKg,el)),r.find(n=>n!==null)??null}i($a,"validate");function tl(e,t){let r=Ka(e,t);return "error"in r?{error:De(r.error)}:r}i(tl,"healthToWire");function Vy(e){if(typeof e!="object"||e===null)return {error:De("patch must be an object")};let t=e,r=[["name","name",s=>lt("name",s,Xa)],["species","species",s=>lt("species",s,Qa)],["breed","breed",s=>lt("breed",s,Za)],["ageYears","age_years",s=>Jr("age_years",s,Ja)],["weightKg","weight_kg",s=>Jr("weight_kg",s,el)]],n={};for(let[s,a,l]of r){let u=t[s];if(u!==void 0){if(u!==null){let d=l(u);if(d!==null)return {error:d}}n[a]=u;}}let o=tl(t,t.species);return "error"in o?o:(Object.assign(n,o.body),Object.keys(n).length===0?{error:De("patch must change at least one field")}:{body:n})}i(Vy,"patchToWire");function Hy(e){if(e==null)return {body:{}};let t=tl(e,e.species);return "error"in t?t:{body:{...e.name!==void 0?{name:e.name}:{},...e.species!==void 0?{species:e.species}:{},...e.breed!==void 0?{breed:e.breed}:{},...e.ageYears!==void 0?{age_years:e.ageYears}:{},...e.weightKg!==void 0?{weight_kg:e.weightKg}:{},...t.body}}}i(Hy,"toWire");var Le=i(e=>typeof e=="string"?e:null,"str"),en=i(e=>typeof e=="number"&&Number.isFinite(e)?e:null,"num");function Ya(e,t){let r=typeof e=="object"&&e!==null?e:{};return Object.freeze({petRef:Le(r.pet_ref)??t,name:Le(r.name),species:Le(r.species),breed:Le(r.breed),ageYears:en(r.age_years),weightKg:en(r.weight_kg)})}i(Ya,"fromWire");function rl(e){if(typeof e!="object"||e===null)return null;let t=e,r=Le(t.pet_ref);return r===null||r.length===0?null:Object.freeze({petId:Le(t.pet_id),petRef:r,name:Le(t.name),species:Le(t.species),breed:Le(t.breed),ageYears:en(t.age_years),weightKg:en(t.weight_kg),updatedAt:Le(t.updated_at)})}i(rl,"widgetPetFromWire");function By(e){let t=rl(e);return t===null?null:Object.freeze({...t,...qa(e)})}i(By,"widgetPetProfileFromWire");function zy(e){let t=Array.isArray(e)?e:typeof e=="object"&&e!==null&&Array.isArray(e.pets)?e.pets:[];return Object.freeze(t.flatMap(r=>{let n=rl(r);return n===null?[]:[n]}))}i(zy,"petListFromWire");function Je(e){return jy(xe({auth:e}),xe({auth:e,unaryTimeoutMs:Uy}))}i(Je,"createPetsRepository");function jy(e,t=e){let r=i((o,s)=>s?{...o,signal:s}:o,"withSignal"),n=i(o=>$a(o,void 0)??`/widget/v1/pets/${encodeURIComponent(o)}`,"petPath");return {async list(o){let s=await e.send("pets.list",r({method:"GET",path:"/widget/v1/pets"},o?.signal));return s.ok?L(zy(s.value)):E(s.error)},async registerPet(o,s,a){let l=$a(o,s);if(l!==null)return E(l);let u=Hy(s);if("error"in u)return E(u.error);let c={method:"POST",path:`/widget/v1/pets/${encodeURIComponent(o)}`,body:u.body},p=await e.send("pets.registerPet",a?.signal?{...c,signal:a.signal}:c);return p.ok?L(Ya(p.value,o)):E(p.error)},async updatePet(o,s,a){let l=n(o);if(typeof l!="string")return E(l);let u=Vy(s);if("error"in u)return E(u.error);let d=await e.send("pets.updatePet",r({method:"PATCH",path:l,body:u.body},a?.signal));return d.ok?L(Ya(d.value,o)):E(d.error)},async getPetProfile(o,s){let a=n(o);if(typeof a!="string")return E(a);let l=await e.send("pets.getPetProfile",r({method:"GET",path:`${a}/profile`},s?.signal));if(!l.ok)return E(l.error);let u=By(l.value);return u===null?E(D("internalError",{retryable:false,httpStatus:502,wireMessage:"the pet profile response carried no pet_ref"})):L(u)},async deletePet(o,s){let a=n(o);if(typeof a!="string")return E(a);let l=await e.send("pets.deletePet",r({method:"DELETE",path:a},s?.signal));return l.ok?L(void 0):E(l.error)},async eraseUserData(o){let s=await t.send("pets.eraseUserData",r({method:"DELETE",path:"/widget/v1/me"},o?.signal),{maxAttempts:1});return s.ok?L(void 0):E(s.error)}}}i(jy,"createPetsRepositoryOver");var _o=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 Wy(e){return _o[e]}i(Wy,"requires");function nl(e,t){let r=Object.freeze({reason:t,level:e,recoverable:false}),n=[],o=new Set;for(let s of Object.keys(_o))for(let a of _o[s])o.has(a)||(o.add(a),n.push(Object.freeze({resource:a,granted:false,disabled:r})));return Object.freeze(n)}i(nl,"deniedDecisionsFor");function ol(e,t,r){let n=Wy(e),o=new Map;for(let l of t)o.set(l.resource,l);if(r?.isPending===true&&n.some(l=>!o.has(l)))return xo({name:e,enabled:false,isPending:true,limits:{}});let s=Gy(n,o);return n.filter(l=>o.get(l)?.granted!==true).length===0?xo({name:e,enabled:true,isPending:false,limits:s}):xo({name:e,enabled:false,isPending:false,limits:s,disabled:Ky(n,o)})}i(ol,"decideCapability");function Gy(e,t){let r={};for(let n of e){let o=t.get(n)?.limits;if(o)for(let[s,a]of Object.entries(o)){let l=r[s];r[s]=l===void 0?a:Math.min(l,a);}}return r}i(Gy,"mergeLimits");function Ky(e,t){for(let r of e){let n=t.get(r)?.disabled;if(n)return Object.freeze({reason:n.reason,level:n.level,recoverable:n.recoverable})}return Object.freeze({reason:Ft("accessDenied"),level:"user_entitlement",recoverable:false})}i(Ky,"disabledFor");function xo(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(xo,"freezeDecision");function me(e){let t=ie(e);return t===null?null:$y(t)}i(me,"parseColor");function ie(e){if(typeof e=="number")return il(e);if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;if(t.startsWith("#"))return wo(t.slice(1));if(t.toLowerCase().startsWith("0x"))return wo(t.slice(2));if(t.toLowerCase().startsWith("rgb"))return qy(t);if(/^[0-9a-fA-F]+$/.test(t)){let r=wo(t);if(r!==null)return r}return /^\d+$/.test(t)?il(Number.parseInt(t,10)):null}i(ie,"toRgba");function wo(e){let t=e.trim();if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===3)return {r:Io(t[0]),g:Io(t[1]),b:Io(t[2]),a:1};if(t.length===6)return {r:ut(t,0),g:ut(t,2),b:ut(t,4),a:1};if(t.length===8){let r=ut(t,0);return {r:ut(t,2),g:ut(t,4),b:ut(t,6),a:r/255}}return null}i(wo,"fromHex");function qy(e){let t=e.indexOf("("),r=e.indexOf(")");if(t<0||r<0||r<t)return null;let n=e.slice(t+1,r).split(",").map(u=>u.trim());if(n.length<3)return null;let o=Ao(Number(n[0])),s=Ao(Number(n[1])),a=Ao(Number(n[2]));if(o===null||s===null||a===null)return null;let l=1;if(n.length>=4){let u=Number(n[3]);if(!Number.isFinite(u))return null;l=Math.min(1,Math.max(0,u));}return {r:o,g:s,b:a,a:l}}i(qy,"fromRgbFunc");function il(e){if(!Number.isFinite(e))return null;let t=Math.trunc(e)>>>0,r=t>>>24&255;return {r:t>>>16&255,g:t>>>8&255,b:t&255,a:r===0?1:r/255}}i(il,"argbIntToRgba");function ut(e,t){return Number.parseInt(e.slice(t,t+2),16)}i(ut,"byte");function Io(e){return Number.parseInt(`${e??"0"}${e??"0"}`,16)}i(Io,"dup");function Ao(e){return Number.isFinite(e)?Math.min(255,Math.max(0,Math.round(e))):null}i(Ao,"clampByte");function $y(e){if(e.a>=1)return ct(e.r,e.g,e.b);let t=Math.round(e.a*1e3)/1e3;return `rgba(${e.r},${e.g},${e.b},${t})`}i($y,"normalizeRgba");function ct(e,t,r){return `#${Oo(e)}${Oo(t)}${Oo(r)}`.toUpperCase()}i(ct,"rgbToHex");function Oo(e){return e.toString(16).padStart(2,"0")}i(Oo,"hex2");var Yy="#111111",Dt="#FFFFFF",tn="#000000";function al(e){let t=ie(e);if(t===null)return Dt;let r=dt(t),n=dt({r:17,g:17,b:17}),o=dt({r:255,g:255,b:255});return Lo(r,o)>=Lo(r,n)?Dt:Yy}i(al,"readableOn");function pr(e,t){let r=al(e);return ue(r,e)>=t?r:ue(Dt,e)>=ue(tn,e)?Dt:tn}i(pr,"legibleOn");function fr(e){let t=i(r=>e.reduce((n,o)=>Math.min(n,ue(r,o)),Number.POSITIVE_INFINITY),"worst");return t(Dt)>=t(tn)?Dt:tn}i(fr,"poleForGrounds");function dt(e){let t=Fo(e.r/255),r=Fo(e.g/255),n=Fo(e.b/255);return .2126*t+.7152*r+.0722*n}i(dt,"relativeLuminance");function Fo(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}i(Fo,"linearize");function Lo(e,t){let r=Math.max(e,t),n=Math.min(e,t);return (r+.05)/(n+.05)}i(Lo,"luminanceContrast");function ue(e,t){let r=ie(e),n=ie(t);if(r===null||n===null)return 1;let o=n.a>=1?n:{...n},s=r.a>=1?r:ll(r,o);return Lo(dt(s),dt(o))}i(ue,"contrastRatio");function ll(e,t){let r=e.a,n=i((o,s)=>Math.round(o*r+s*(1-r)),"mix");return {r:n(e.r,t.r),g:n(e.g,t.g),b:n(e.b,t.b),a:1}}i(ll,"composite");function pt(e,t){let r=ie(e),n=ie(t);if(r===null||n===null)return null;let o=r.a>=1?r:ll(r,{...n});return ct(o.r,o.g,o.b)}i(pt,"flattenOnto");function ul(e,t){let r=ie(e);if(r===null)return null;let n=Math.min(1,Math.max(0,t));return `rgba(${r.r}, ${r.g}, ${r.b}, ${n})`}i(ul,"withAlpha");var sl=.05;function et(e,t,r,n){let o=t[0];if(o===void 0)return r;let s=i(d=>t.every(c=>ue(d,c)>=n),"reads");if(ie(e)===null)return r;if(s(e))return e;let a=pt(e,o),l=a===null?null:ie(a),u=ie(r);if(l===null||u===null)return r;for(let d=1;d<1/sl;d+=1){let c=d*sl,p=i((m,y)=>Math.round(m+(y-m)*c),"mix"),f=ct(p(l.r,u.r),p(l.g,u.g),p(l.b,u.b));if(s(f))return f}return r}i(et,"pushToContrast");function dl(e,t,r){let n=e/255,o=t/255,s=r/255,a=Math.max(n,o,s),l=Math.min(n,o,s),u=(a+l)/2;if(a===l)return {h:0,s:0,l:u};let d=a-l,c=d/(1-Math.abs(2*u-1)),p;return a===n?(p=(o-s)/d*60,p<0&&(p=p+360)):a===o?p=((s-n)/d+2)*60:p=((n-o)/d+4)*60,{h:p,s:c,l:u}}i(dl,"rgbToHsl");function Do(e){let{h:t,s:r,l:n}=e,o=(1-Math.abs(2*n-1))*r,s=t/60,a=o*(1-Math.abs(s%2-1)),l=n-o/2,u=Math.floor(s)%6,d=[[o,a,0],[a,o,0],[0,o,a],[0,a,o],[a,0,o],[o,0,a]],[c,p,f]=d[u];return {r:Mo(c+l),g:Mo(p+l),b:Mo(f+l)}}i(Do,"hslToRgb");function Mo(e){return Math.min(255,Math.max(0,Math.floor(e*255+.5)))}i(Mo,"channel");function je(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.keys(e))je(e[t]);}return e}i(je,"deepFreeze");var nn=Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3}),pl={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},fl={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},cl={nano:8,small:9,micro:10,tiny:11,caption:12,bodyTight:13,body:14,subtitle:16,heading:18,verdict:24},Xy={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},Qy={regular:"400",medium:"500",bold:"700"},Zy={eyebrow:1,monoWide:.9,headerBrand:-0.42,tight:-0.35},No=0,ft="System",Ne="monospace",Jy=["content","heading","control","compact","badge"];function eg(e){let t={};for(let r of Jy)t[r]=e;return t}i(eg,"authoredTierSizes");function ml(){return {family:ft,mono:Ne,fontUrl:null,families:{regular:ft,medium:ft,bold:ft,mono:Ne,monoMedium:Ne,monoBold:Ne},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:cl,tierSizes:eg(cl),lineHeight:Xy,weight:Qy,letterSpacing:Zy,scale:1,maxScale:No,scaleCaps:nn}}i(ml,"baseType");var yl={},mt=Object.freeze({standard:Object.freeze([.2,0,0,1]),emphasized:Object.freeze([.2,.8,.2,1]),exit:Object.freeze([.4,0,1,1])});function rn(e){return `cubic-bezier(${e.join(", ")})`}i(rn,"cssCubicBezier");var gl={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:rn(mt.standard),emphasized:rn(mt.emphasized),exit:rn(mt.exit)},reducedMotion:false},tg={brand:"#10462E",brandSoft:"rgba(16,70,46,0.10)",brandSofter:"rgba(16,70,46,0.15)",brandBorder:"rgba(16,70,46,0.18)",borderHairlineGreen:"rgba(16,70,46,0.25)",brandBorderStrong:"rgba(16,70,46,0.55)",brandInk:"#10462E",linkInk:"#10462E",surface:"#FFFFFF",surfaceCream:"#FDFBF8",surfaceSubtle:"#EFE9E3",background:"#FFFFFF",borderRingCream:"#D8D2C8",chatGround:"#FFFFFF",composerFill:"#FDFBF8",composerBorder:"rgba(16,70,46,0.75)",shadow:"#0B3421",text:{primary:"#111111",secondary:"#0E462E",muted:"#6E6660",placeholder:"rgba(61,61,61,0.75)",onBrand:"#FFFFFF",metaCool:"#3D3D3D",timestamp:"rgba(61,61,61,0.75)"},primary:"#10462E",onPrimary:"#FFFFFF",accent:"#10462E",onAccent:"#FFFFFF",accentEdge:"#07C168",success:"#07C168",danger:"#B91C1C",errorRed:"#FF1B00",warningStrong:"#A45610",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.12)",badgeBgCaution:"rgba(217,130,29,0.14)",badgeBgCritical:"rgba(185,28,28,0.12)",badgeBgNeutral:"rgba(110,102,96,0.12)",bubbleUser:"#10462E",bubbleAssistant:"#FFFFFF",skeleton:"#EFE9E3",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)"},yt=je({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:tg,space:pl,radius:fl,type:ml(),motion:gl,slots:yl}),rg={brand:"#6BD39A",brandSoft:"rgba(107,211,154,0.12)",brandSofter:"rgba(107,211,154,0.18)",brandBorder:"rgba(107,211,154,0.22)",borderHairlineGreen:"rgba(107,211,154,0.28)",brandBorderStrong:"rgba(107,211,154,0.55)",brandInk:"#6BD39A",linkInk:"#6BD39A",surface:"#1C1F23",surfaceCream:"#23272C",surfaceSubtle:"#23272C",background:"#15171A",borderRingCream:"#3A3F45",chatGround:"#1C1F23",composerFill:"#23272C",composerBorder:"rgba(107,211,154,0.75)",shadow:"#000000",text:{primary:"#F5F3F0",secondary:"#A9E4C4",muted:"#9A938C",placeholder:"rgba(255,255,255,0.55)",onBrand:"#0E1F17",metaCool:"#C9C9C9",timestamp:"rgba(245,243,240,0.7)"},primary:"#6BD39A",onPrimary:"#0E1F17",accent:"#6BD39A",onAccent:"#0E1F17",accentEdge:"#34D888",success:"#07C168",danger:"#F87171",errorRed:"#FF6B5B",warningStrong:"#F0A35E",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.18)",badgeBgCaution:"rgba(217,130,29,0.20)",badgeBgCritical:"rgba(185,28,28,0.22)",badgeBgNeutral:"rgba(255,255,255,0.10)",bubbleUser:"#6BD39A",bubbleAssistant:"#1C1F23",skeleton:"#23272C",scanButtonPink:"#FFC3BC",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)"},on=je({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false},color:rg,space:pl,radius:fl,type:ml(),motion:gl,slots:yl});var ng="#23272C",hl=4.5,og=.6,Uo=.9,ig=.02,sg="#FFFFFF",ag="#111111";function lg(e){return ue(e,ng)>=hl&&Math.max(ue(e,sg),ue(e,ag))>=hl}i(lg,"readsOnDark");function El(e){let t=ie(e);if(t===null)return null;let{h:r,s:n,l:o}=dl(t.r,t.g,t.b),s=Math.min(Math.max(o,og),Uo);for(let l=0;;l+=1){let u=s+l*ig;if(u>Uo)break;let d=Do({h:r,s:n,l:u}),c=ct(d.r,d.g,d.b);if(lg(c))return c}let a=Do({h:r,s:n,l:Uo});return ct(a.r,a.g,a.b)}i(El,"deriveDarkVariant");var ug=7,bl=.05,dg="#000000",cg="#FFFFFF";function pg(e,t,r,n){let o=pt(e,t);if(o===null)return r;if(ue(o,t)>=n)return o;let s=ie(o),a=ie(r);if(s===null||a===null)return r;for(let l=1;l<1/bl;l+=1){let u=l*bl,d=i((p,f)=>Math.round(p+(f-p)*u),"mix"),c=ct(d(s.r,a.r),d(s.g,a.g),d(s.b,a.b));if(ue(c,t)>=n)return c}return r}i(pg,"pushContrast");function fg(e,t){let r=[e.surface,e.surfaceCream,e.surfaceSubtle,e.background,e.chatGround,e.composerFill],n=r[0],o=vl(n);for(let s of r){let a=vl(s);(t?a>o:a<o)&&(n=s,o=a);}return n}i(fg,"hardestGround");function vl(e){let t=ie(e);return t===null?0:dt(t)}i(vl,"luminanceOf");function tt(e,t){return pt(e,t)??me(e)??t}i(tt,"solid");function Cl(e){let t=e.color,r=e.brightness==="dark",n=r?cg:dg,o=fg(t,r),s=i(l=>pg(l,o,n,ug),"text"),a={...t,brandSoft:tt(t.brandSoft,t.surface),brandSofter:tt(t.brandSofter,t.surface),brandBorder:s(t.brandBorder),borderHairlineGreen:s(t.borderHairlineGreen),brandBorderStrong:s(t.brandBorderStrong),brandInk:s(t.brandInk),linkInk:s(t.linkInk),borderRingCream:s(t.borderRingCream),composerBorder:s(t.composerBorder),text:{primary:s(t.text.primary),secondary:s(t.text.secondary),muted:s(t.text.muted),placeholder:s(t.text.placeholder),onBrand:t.text.onBrand,metaCool:s(t.text.metaCool),timestamp:s(t.text.timestamp)},badgeBgPositive:tt(t.badgeBgPositive,t.surface),badgeBgCaution:tt(t.badgeBgCaution,t.surface),badgeBgCritical:tt(t.badgeBgCritical,t.surface),badgeBgNeutral:tt(t.badgeBgNeutral,t.surface),checkupCardLowRiskBg:tt(t.checkupCardLowRiskBg,t.surface),checkupCardConcernBg:tt(t.checkupCardConcernBg,t.surface)};return je({...e,highContrast:true,color:a})}i(Cl,"deriveHighContrast");var gt=Object.freeze(["composerInput","sendButton","userBubble","assistantBubble","recordCard","vetVisitButton","primaryButton","link"]),mg=Object.freeze(["backgroundColor","borderColor","borderRadius","textColor"]),we=4.5,yg=Object.freeze({});function gg(e){return gt.includes(e)}i(gg,"isSlotName");function hg(e){let t=typeof e=="number"?e:typeof e=="string"?Number(e.trim()):Number.NaN;return Number.isFinite(t)?Math.max(0,t):null}i(hg,"parseRadius");function Rl(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t={},r=false;for(let[n,o]of Object.entries(e)){if(!gg(n)||o===null||typeof o!="object")continue;let s=bg(o);s!==null&&(t[n]=s,r=true);}return r?Object.freeze(t):null}i(Rl,"parseThemeSlots");function sn(e,t,r){return e[t]!==void 0?e[t]:e[r]}i(sn,"pick");function bg(e){let t={},r=me(sn(e,"background_color","backgroundColor"));r!==null&&(t.backgroundColor=r);let n=me(sn(e,"border_color","borderColor"));n!==null&&(t.borderColor=n);let o=hg(sn(e,"border_radius","borderRadius"));o!==null&&(t.borderRadius=o);let s=me(sn(e,"text_color","textColor"));return s!==null&&(t.textColor=s),Object.keys(t).length===0?null:Object.freeze(t)}i(bg,"parseSlot");function Sl(e,t){return t===null||Object.keys(t).length===0?e??yg:e===null||Object.keys(e).length===0?t:Object.freeze({...e,...t})}i(Sl,"mergeThemeSlots");var Vo=3;function vg(e,t){return e===void 0?t:t.length===0?[e]:t.map(r=>pt(e,r)??r)}i(vg,"seatsOf");function Eg(e,t){let r=fr(e);return e.every(n=>ue(r,n)>=t)}i(Eg,"someInkReads");function Cg(e,t){let r=t[0];return r===void 0?null:pt(e,r)}i(Cg,"collapseUnsatisfiableFill");function Rg(e){let t=pr(e[0],we);return e.every(r=>ue(t,r)>=we)?t:fr(e)}i(Rg,"inkFor");function Tl(e,t){let r=false,n={};for(let o of gt){let s=e[o];if(s===void 0)continue;let a=s.backgroundColor,l=t?.[o]??[],u=vg(a,l),d={...s},c=false;if(a!==void 0&&u.length>1&&!Eg(u,we)){let p=Cg(a,l);p!==null&&(d.backgroundColor=p,u=[p],c=true);}if(u.length>0){let p=s.textColor;if(a!==void 0)(p===void 0||u.some(f=>ue(p,f)<we))&&(d.textColor=Rg(u),c=true);else if(p!==void 0){let f=et(p,u,fr(u),we);f!==p&&(d.textColor=f,c=true);}if(s.borderColor!==void 0){let f=et(s.borderColor,u,fr(u),Vo);f!==s.borderColor&&(d.borderColor=f,c=true);}}n[o]=c?Object.freeze(d):s,r=r||c;}return r?Object.freeze(n):e}i(Tl,"guardSlotContrast");var xl=Object.freeze(["display_name","logo_url","logo_url_dark","primary_color","accent_color","primary_color_dark","accent_color_dark","brightness","color_scheme","font_family","font_url","fonts","font_urls","chat_placeholder","surface_style","radius_scale","accessibility_max_font_scale","slots"]),mr="slots.",_l=Object.freeze([1,2]);function an(e){return Object.keys(e).every(t=>t==="schemaVersion"||(e[t]??null)===null)}i(an,"isEmptyBranding");function wl(e){let t=e?.schemaVersion??null;return t===null||_l.includes(t)}i(wl,"isKnownBrandingSchema");function Il(e){return new Set(["hide_powered_by",...e?.lockedFields??[]])}i(Il,"lockedFieldsOf");function Sg(e){return e==="hide_powered_by"||xl.includes(e)?true:e.startsWith(mr)&>.includes(e.slice(mr.length))}i(Sg,"isThemeLockName");function We(e){if(e===null||typeof e!="object")return null;let t=e,r={displayName:ht($(t,"display_name","displayName")),logoUrl:ht($(t,"logo_url","logoUrl")),primaryColor:me($(t,"primary_color","primaryColor")),accentColor:me($(t,"accent_color","accentColor")),brightness:xg($(t,"brightness","color_scheme","colorScheme")),fontFamily:ht($(t,"font_family","fontFamily")),fontUrl:ht($(t,"font_url","fontUrl")),fonts:Pl($(t,"fonts")),fontUrls:Pl($(t,"font_urls","fontUrls")),placeholder:ht($(t,"chat_placeholder","placeholder","chatPlaceholder")),hidePoweredBy:Tg($(t,"hide_powered_by","hidePoweredBy")),primaryColorDark:me($(t,"primary_color_dark","primaryColorDark")),accentColorDark:me($(t,"accent_color_dark","accentColorDark")),surfaceStyle:kl($(t,"surface_style","surfaceStyle"),Pg),radiusScale:kl($(t,"radius_scale","radiusScale"),kg),logoUrlDark:ht($(t,"logo_url_dark","logoUrlDark")),slots:Rl($(t,"slots")),accessibilityMaxFontScale:wg($(t,"accessibility_max_font_scale","accessibilityMaxFontScale")),lockedFields:Ag($(t,"locked_fields","lockedFields")),schemaVersion:Ig($(t,"schema_version","schemaVersion"))};return an(r)?null:Object.freeze(r)}i(We,"parseClientBranding");function Tg(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true")return true;if(t==="false")return false}return null}i(Tg,"parseBool");function $(e,...t){for(let r of t)if(Object.prototype.hasOwnProperty.call(e,r)){let n=e[r];if(n!==void 0)return n}}i($,"pick");function ht(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}i(ht,"parseNonEmptyString");var yr=["regular","medium","bold","mono","monoMedium","monoBold"];function Pl(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let n of yr){let o=ht($(t,n));o!==null&&(r[n]=o);}return Object.keys(r).length===0?null:Object.freeze(r)}i(Pl,"parseFaceMap");var Pg=["white","cream","subtle"],kg=["sharp","default","round"];function kl(e,t){if(typeof e!="string")return null;let r=e.trim().toLowerCase();return t.includes(r)?r:null}i(kl,"parseEnum");function xg(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t==="light"||t==="dark"||t==="auto"?t:null}i(xg,"parseBrightness");function Al(e){let t=typeof e=="number"?e:typeof e=="string"?Number(e.trim()):Number.NaN;return Number.isFinite(t)&&(typeof e!="string"||e.trim().length>0)?t:null}i(Al,"parseNumber");var _g=1,Ol=3.1;function wg(e){let t=Al(e);return t===null?null:t<=0?0:Math.min(Ol,Math.max(_g,t))}i(wg,"parseMaxFontScale");function Ig(e){if(e==null)return null;let t=Al(e);return t!==null&&Number.isInteger(t)&&t>=1?t:0}i(Ig,"parseSchemaVersion");function Ho(e){let t=e.trim();return t.startsWith(mr)?t:t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase()}i(Ho,"toWireName");function Ag(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(typeof r!="string")continue;let n=Ho(r);Sg(n)&&!t.includes(n)&&t.push(n);}return t.length===0?null:Object.freeze(t)}i(Ag,"parseLockedFields");function Bo(e){if(e===null)return null;let t=e.trim();return t.length===0?null:/^https:\/\/\S+$/i.test(t)?t:null}i(Bo,"hardenHttpsUrl");function Fl(e,t){if(t===null||an(t))return e;let r=(t.brightness==="light"||t.brightness==="dark")&&t.brightness!==e.brightness?t.brightness==="dark"?on:yt:e,n=r.brightness==="dark"?on:yt,o=r.brightness==="dark",s=o?t.primaryColorDark??Ml(t.primaryColor):t.primaryColor,a=o?t.accentColorDark??Ml(t.accentColor):t.accentColor,l=s??r.color.primary,u=a??r.color.accent,d=s!==null&&Dg(t,l,n,o),c=d?n.color.primary:l,p=s!==null&&!d?ie(c):null,f=i(x=>Math.round(x+(255-x)*.4),"lift"),m=p!==null?{brand:c,bubbleUser:c,brandInk:c,text:{...r.color.text,secondary:c},brandSoft:`rgba(${p.r}, ${p.g}, ${p.b}, 0.10)`,brandSofter:`rgba(${p.r}, ${p.g}, ${p.b}, 0.15)`,brandBorder:`rgba(${p.r}, ${p.g}, ${p.b}, 0.20)`,borderHairlineGreen:`rgba(${p.r}, ${p.g}, ${p.b}, 0.28)`,brandBorderStrong:`rgba(${p.r}, ${p.g}, ${p.b}, 0.55)`,composerBorder:`rgba(${p.r}, ${p.g}, ${p.b}, 0.75)`,accentEdge:`rgb(${f(p.r)}, ${f(p.g)}, ${f(p.b)})`}:d?Ng(n,r.color.text):{},y={brightness:r.brightness,highContrast:r.highContrast,meta:{displayName:t.displayName??r.meta.displayName,logoUrl:(o?t.logoUrlDark??t.logoUrl:t.logoUrl)??r.meta.logoUrl,placeholder:t.placeholder??r.meta.placeholder,hidePoweredBy:t.hidePoweredBy??r.meta.hidePoweredBy},color:{...r.color,...m,...Lg(t.surfaceStyle??null,n),primary:c,accent:u,onPrimary:r.color.onPrimary,onAccent:r.color.onAccent},space:r.space,radius:Vg(t.radiusScale??null,r.radius,n),type:{...r.type,...Mg(r.type,t),maxScale:t.accessibilityMaxFontScale??r.type.maxScale},motion:r.motion,slots:Sl(r.slots,t.slots??null)};return je(y)}i(Fl,"withServerBranding");var Og={regular:["regular"],medium:["medium","regular"],bold:["bold","medium","regular"],mono:["mono"],monoMedium:["monoMedium","mono"],monoBold:["monoBold","monoMedium","mono"]},Fg=[["regular","medium","bold"],["mono","monoMedium","monoBold"]];function zo(e){return e==="mono"||e==="monoMedium"||e==="monoBold"}i(zo,"isMonoFace");function Mg(e,t){let r=t.fonts??{},n=t.fontUrls??{},o={...e.families},s={...e.namedFaces},a={...e.fontUrls};for(let l of yr){let u=Og[l].map(p=>r[p]).find(p=>p!==void 0),d=zo(l)?null:t.fontFamily;u!==void 0?(o[l]=u,s[l]=true):d!==null&&(o[l]=d,s[l]=false);let c=n[l]??(l==="regular"?t.fontUrl:null)??null;c!==null?a[l]=c:u!==void 0&&delete a[l];}for(let l of Fg)for(let u of l)s[u]&&l.some(d=>d!==u&&o[d]===o[u])&&(s[u]=false);return {family:o.regular,mono:o.mono,fontUrl:a.regular??null,families:o,namedFaces:s,fontUrls:a}}i(Mg,"mergeFaces");function Ml(e){return e===null?null:El(e)}i(Ml,"darkVariantOf");function Lg(e,t){if(e===null)return {};let r=t.color;return {chatGround:e==="white"?r.surface:e==="subtle"?r.surfaceSubtle:r.surfaceCream}}i(Lg,"surfaceOf");function Ll(e,t){return e==null?false:me(e)===me(t)}i(Ll,"sameColor");function Dg(e,t,r,n){return Ll(t,r.color.primary)?true:n&&(e.primaryColorDark??null)===null&&Ll(e.primaryColor,yt.color.primary)}i(Dg,"isCompiledPrimary");function Ng(e,t){let r=e.color;return {text:{...t,secondary:r.text.secondary},brand:r.brand,bubbleUser:r.bubbleUser,brandInk:r.brandInk,brandSoft:r.brandSoft,brandSofter:r.brandSofter,brandBorder:r.brandBorder,borderHairlineGreen:r.borderHairlineGreen,brandBorderStrong:r.brandBorderStrong,composerBorder:r.composerBorder,accentEdge:r.accentEdge}}i(Ng,"compiledBrandFamily");var Ug={sharp:.5,default:1,round:1.5};function Vg(e,t,r){if(e===null)return t;let n=Ug[e],o=r.radius,s=i(a=>Math.round(a*n),"s");return {tile:s(o.tile),xs:s(o.xs),sm:s(o.sm),md:s(o.md),lg:s(o.lg),xl:s(o.xl),pill:o.pill}}i(Vg,"radiusOf");var Hg="Everfur",Bg=.5;function jo(e){let t=e?.branding??null,r=wl(t)?t:null,n=Kg(e?.clientOverride??null,Il(r)),o=e?.colorScheme==="dark"?"dark":"light",s=n?.brightness??r?.brightness??"light",u=Fl((s==="auto"?o:s)==="dark"?on:yt,Dl(r)),d=Fl(u,Dl(n));return oh(d,e)}i(jo,"resolveTheme");function zg(e,t,r){return jo({...r,branding:We(t),clientOverride:We(e)})}i(zg,"previewTheme");function jg(e){return e==="placeholder"?"chat_placeholder":Ho(e)}i(jg,"wireNameOf");var Wg={brightness:["color_scheme"],fontUrl:["font_family"],fonts:["font_family"],fontUrls:["font_url","font_family"],primaryColorDark:["primary_color"],accentColorDark:["accent_color"],logoUrlDark:["logo_url"]};function Gg(e,t){return t.has(jg(e))?true:(Wg[e]??[]).some(r=>t.has(r))}i(Gg,"isLocked");function Kg(e,t){if(e===null)return null;let r=false,n={...e};for(let a of Object.keys(e))(e[a]??null)!==null&&(Gg(a,t)||a==="lockedFields")&&(n[a]=null,r=true);let o=n.slots??null;if(o!==null){let a={},l=false;for(let u of gt){let d=o[u];d!==void 0&&(t.has(`${mr}${u}`)?l=true:a[u]=d);}l&&(n.slots=Object.keys(a).length===0?null:Object.freeze(a),r=true);}if(!r)return e;let s=Object.freeze(n);return an(s)?null:s}i(Kg,"withoutFields");function Dl(e){return e===null||e.brightness===null?e:Object.freeze({...e,brightness:null})}i(Dl,"withoutBrightness");function qg(e,t){if(t===1)return e;let r={};for(let[n,o]of Object.entries(e))r[n]=Math.round(o*t*10)/10;return r}i(qg,"scaledSizes");function $g(e){return e===void 0||!Number.isFinite(e)?1:Math.max(Bg,e)}i($g,"effectiveScale");var Nl=["content","heading","control","compact","badge"];function Yg(e){if(!(e>0))return nn;let t={};for(let r of Nl){let n=nn[r];t[r]=n===0?0:Math.min(n,e);}return t}i(Yg,"tierCaps");function Xg(e,t){return t>0?Math.min(e,t):e}i(Xg,"capped");function Qg(e,t,r,n){let o={};for(let s of Nl)o[s]=n?qg(e,Xg(t,r[s])):e;return o}i(Qg,"sizesByTier");function Zg(e){return e==="dark"?"#FFFFFF":"#000000"}i(Zg,"inkPole");function Jg(e){return [e.surface,e.surfaceCream,e.surfaceSubtle,e.background,e.chatGround,e.composerFill]}i(Jg,"textGrounds");function eh(e){return [e.surface,e.surfaceCream,e.background,e.chatGround,e.composerFill]}i(eh,"controlGrounds");function Ul(e){return [e.chatGround,e.surface,e.surfaceCream]}i(Ul,"linkGrounds");function th(e){return {composerInput:[e.composerFill],sendButton:[e.composerFill],userBubble:[e.bubbleUser],assistantBubble:[e.chatGround,e.surfaceCream],recordCard:[e.surface],vetVisitButton:[e.primary],primaryButton:[e.brand],link:Ul(e)}}i(th,"slotGrounds");function rh(e,t){try{let r=e(t);return r===!0||r===!1?r:null}catch{return null}}i(rh,"registration");function nh(e,t){let r=t?.isFontRegistered,n=t?.platformMonoFamily?.trim()||null;if(r===void 0&&n===null)return {family:e.family,mono:e.mono,families:e.families,namedFaces:e.namedFaces};let o={...e.families},s={...e.namedFaces};for(let a of yr)!(o[a]===ft||o[a]===Ne)&&r!==void 0&&rh(r,o[a])===false&&(o[a]=zo(a)?Ne:ft,s[a]=false),n!==null&&zo(a)&&o[a]===Ne&&(o[a]=n);return {family:o.regular,mono:o.mono,families:o,namedFaces:s}}i(nh,"platformFaces");function oh(e,t){let r=e.color.primary,n=e.color.accent,o=e.meta.displayName.trim().length===0?Hg:e.meta.displayName,s=Bo(e.meta.logoUrl),a={};for(let P of yr){let k=e.type.fontUrls[P];k!==void 0&&(a[P]=Bo(k));}let l=a.regular??null,d=t?.reducedMotion===true?{duration:{instant:0,fast:0,normal:0,slow:0},spring:{gentle:{damping:100,stiffness:1e3}},easing:e.motion.easing,reducedMotion:true}:e.motion,c=Number.isFinite(e.type.maxScale)?e.type.maxScale:No,p=$g(t?.textScale),f=Yg(c),m=Qg(e.type.size,p,f,t?.scaleTypeSizes===true),y=e.color,x=Zg(e.brightness),b=Jg(y),C={...y,primary:r,accent:n,onPrimary:pr(r,we),onAccent:pr(n,we),brandInk:et(y.brandInk,b,x,we),linkInk:et(e.slots.link?.textColor??n,Ul(y),x,we),text:{...y.text,secondary:et(y.text.secondary,b,x,we)},brandBorderStrong:et(y.brandBorderStrong,eh(y),x,Vo)},_={brightness:e.brightness,highContrast:false,meta:{displayName:o,logoUrl:s,placeholder:e.meta.placeholder,hidePoweredBy:e.meta.hidePoweredBy},color:C,space:e.space,radius:e.radius,type:{...e.type,...nh(e.type,t),fontUrl:l,fontUrls:a,size:m.content,tierSizes:m,scale:p,maxScale:c,scaleCaps:f},motion:d,slots:Tl(e.slots,th(C))};return t?.highContrast===true?Cl(je(_)):je(_)}i(oh,"finalize");var Vl="/widget/v1/entitlements",ih=304,sh=Object.freeze({kind:"notModified"});async function Bl(e,t={},r=xe({auth:e})){let n=await r.send("entitlements.fetch",lh(t));return n.ok?uh(n.value):n.error.httpStatus===ih?sh:{kind:"failed",error:n.error}}i(Bl,"fetchEntitlements");var ah=64;function lh(e){let t={};return Wo(e.cachedRevision)&&(t["if-none-match"]=`"${e.cachedRevision}"`),e.region&&e.region.length<=ah?{method:"GET",path:Vl,headers:t,query:{region:e.region}}:{method:"GET",path:Vl,headers:t}}i(lh,"buildRequest");function uh(e){if(e===null||typeof e!="object"||!Wo(e.revision))return Hl();let t=typeof e.region=="string"?e.region:"",r=Wo(e.ttl_seconds)?e.ttl_seconds:0;return Object.freeze({kind:"updated",revision:e.revision,region:t,ttlSeconds:r,decisions:ch(e.capabilities),branding:dh(e),livemode:e.livemode!==false})}i(uh,"parseUpdated");function dh(e){let t=We(e.branding);if(t!==null)return t;let r=e.render_hints;if(r!==null&&typeof r=="object"){let n=We(r.branding);return n!==null?n:We(r)}return null}i(dh,"parseBranding");function ch(e){if(e===null||typeof e!="object")return Object.freeze([]);let t=[];for(let[r,n]of Object.entries(e))ph(n)&&t.push(Object.freeze({resource:r,granted:true}));return Object.freeze(t)}i(ch,"mapCapabilities");function ph(e){return typeof e=="object"&&e!==null&&e.enabled===true}i(ph,"isEnabled");function Hl(){return {kind:"failed",error:D("internalError",{retryable:true,wireMessage:"malformed entitlements response"})}}i(Hl,"malformed");function Wo(e){return typeof e=="number"&&Number.isFinite(e)}i(Wo,"isFiniteNumber");var fh=30;function zl(e){let t=e.scheduler??mh,r=e.resolve??Bl,n=Math.max(1,e.floorSeconds??fh),o=e.rng??Math.random,s=i(()=>n+o()*n,"jitteredFloorSeconds"),a=false,l=false,u=null,d=null,c=n,p=0,f=i(()=>{u!==null&&(t.clear(u),u=null);},"clearTimer"),m=i(C=>{l||!a||(c=Math.max(n,C),u=t.set(()=>{u=null,b();},c*1e3));},"schedule"),y=null,x=i(async()=>{if(l)return null;let C=p;e.onFetch?.();let _=e.region?{cachedRevision:d,region:e.region}:{cachedRevision:d},P;try{P=await r(e.authFor(),_);}catch(k){return e.telemetry?.track("sdk.entitlements.poll_error",{reason:yh(k)}),!l&&C===p&&(e.onSettled?.(),m(s())),null}if(l||C!==p)return null;switch(P.kind){case "updated":d=P.revision,e.update(P.decisions,P.branding??null,P.livemode!==false),m(P.ttlSeconds);break;case "notModified":m(c);break;case "failed":e.telemetry?.track("sdk.entitlements.poll_failed",{code:P.error.code}),m(s());break;default:m(s());}return e.onSettled?.(),P},"tick"),b=i(()=>{let C=x().finally(()=>{y===C&&(y=null);});return y=C,C},"run");return {start(){a||l||(a=true,b());},prime(){return l?Promise.resolve(null):y??b()},stop(){l||(l=true,p++,f());},refresh(){l||!a||(p++,d=null,f(),b());}}}i(zl,"createEntitlementPoller");var mh={set(e,t){let r=setTimeout(e,t);return r.unref?.(),r},clear(e){clearTimeout(e);}};function yh(e){return e instanceof Error?e.message:"poll failed"}i(yh,"describe");var jl="everfur.notifications.device";var gh=3e3,Wl=Object.freeze([jl]);function Gl(e){let{leaving:t,identity:r,hooks:n,telemetry:o}=e;if(t===null||r===null||n.size===0)return null;let s=Object.freeze({userRef:t.userRef,auth:e.graceAuth()}),a=[...n].map(d=>{try{return Promise.resolve(d(s))}catch(c){return Promise.reject(c)}}),l=i((d,c)=>{try{o.track("sdk.logout.hookFailed",{reason:d,count:c,totalCount:a.length});}catch{}},"report"),u=Promise.allSettled(a).then(d=>{let c=d.filter(p=>p.status==="rejected").length;c>0&&l("failed",c);});return new Promise(d=>{let c=false,p=i(()=>{c||(c=true,clearTimeout(f),d());},"finish"),f=setTimeout(()=>{c||l("timeout",a.length),p();},gh);u.then(p,p);})}i(Gl,"startBeforeLogoutHooks");function Kl(e){let{leaving:t,identity:r,transport:n,sessionId:o}=e,s=r.currentToken();s.catch(()=>{});let a={userRef:t.userRef,currentToken:i(()=>s,"currentToken"),hasToken:i(()=>true,"hasToken"),clear:i(()=>{},"clear")};return {mode:"personalized",transport:n,identity:a,userRef:t.userRef,sessionId:o}}i(Kl,"graceAuth");async function ql(e,t){if(Wl.length===0)return;let r=await Promise.allSettled(Wl.map(o=>e.removeItem(o))),n=r.filter(o=>o.status==="rejected").length;n>0&&t.track("sdk.logout.sweepPartialFailure",{failedCount:n,totalCount:r.length});}i(ql,"sweepPerUserKv");function hh(){return Object.freeze([Object.freeze({resource:"chat.message.create",granted:true})])}i(hh,"compiledDefaultDecisions");function Go(e=hh){let t=new Set,r=Object.freeze({decisions:e(),isPending:false,branding:null}),n=i(()=>{for(let o of t)o();},"emit");return {subscribe(o){return t.add(o),()=>{t.delete(o);}},getSnapshot(){return r},set(o){r=Object.freeze({decisions:Object.freeze([...o.decisions]),isPending:o.isPending,branding:o.branding??null,...o.livemode===false?{livemode:false}:{}}),n();},reset(){r=Object.freeze({decisions:e(),isPending:false,branding:null}),n();},setPending(o){r.isPending!==o&&(r=Object.freeze({...r,isPending:o}),n());}}}i(Go,"createEntitlementStore");function Ko(e){return D("validationFailed",{retryable:false,wireMessage:`Everfur SDK is not configured: ${e.message}`})}i(Ko,"notConfiguredError");function $l(e,t){let r={publishableKey:e.publishableKey,...e.apiBaseUrl!==void 0?{apiBaseUrl:e.apiBaseUrl}:{},...e.contractVersion!==void 0?{contractVersion:e.contractVersion}:{},...e.debug!==void 0?{debug:e.debug}:{}};return Ns(r,t===void 0?void 0:{platform:t})}i($l,"tryResolveClient");function Yl(e){return Object.freeze({track(t,r){try{e.track(t,r);}catch{}},trackExpectedFailure(t,r){try{e.trackExpectedFailure(t,r);}catch{}}})}i(Yl,"guardTelemetry");var bh=Object.freeze({"react-native":"If the value is set in your environment, note that babel-preset-expo inlines only EXPO_PUBLIC_* variables into a release bundle.",web:`If the value is set in your environment, note that a browser bundle does not expose ${jr} to the SDK at run time (bundlers inline only the variables your own code names), so pass apiBaseUrl in config.`});function Xl(e,t,r=eo){try{t.trackExpectedFailure("sdk.config.invalid",{reason:e.reason});}catch{}globalThis.console?.error?.(`[everfur] SDK disabled: ${e.message}
|
|
12
|
+
[everfur] Every Everfur capability will render its off-state until this is fixed. `+bh[r]);}i(Xl,"reportConfigFailure");function qo(e){return Object.freeze({request(){return Promise.resolve(E(Ko(e)))},stream(t,r){let n=de({code:"sdk_not_configured",retryable:false,wireMessage:`Everfur SDK is not configured: ${e.message}`,synthesized:true,lastEventId:null});return {async*[Symbol.asyncIterator](){r.aborted||(yield n);}}}})}i(qo,"refusingTransport");function Ql(){let e=new Map;return {async getItem(t){return e.get(t)??null},async setItem(t,r){e.set(t,r);},async removeItem(t){e.delete(t);},async keys(t){return [...e.keys()].filter(r=>r.startsWith(t))}}}i(Ql,"createInMemoryKv");var Zl=Object.freeze({clearMemoryCache(){},clearDiskCache(){}});function tu(e,t){return new Yo(e,t)}i(tu,"createEverfurRuntime");var vh=6e4,Xo=class Xo{constructor(t,r){this.sessionId=Zn();this.entries=new Map;this.destroyers=new Map;this.epoch=0;this.disposed=false;this.verdictSettled=false;this.refreshTimer=null;this.bootstraps=new WeakMap;this.prepared=null;this.beforeLogoutHooks=new Set;this.pendingBeforeLogout=null;this.leavingSessionId=null;let n=t.config;if(n.secureStore!==void 0&&n.secureStore.isAvailable===true)throw new Q("invalid-argument","config.secureStore is not yet consumable: SDK token persistence is unimplemented. Omit secureStore to keep memory-only tokens (SPEC-10 \xA75.3).");this.telemetry=n.telemetry?Yl(n.telemetry):Br;let o=typeof n?.publishableKey=="string"?n.publishableKey.trim():"",s=to(n?.publishableKey),a=n.transport!==void 0,l,u=typeof n.apiBaseUrl=="string"&&n.apiBaseUrl.trim().length>0?n.apiBaseUrl.trim():null;if(s!==null)l=qo(s);else if(n.transport!==void 0)l=n.transport;else {let c=$l(n,r?.platform);c.ok?(u=c.config.apiBaseUrl,l=js({config:c.config,...r?.eventSourceFactory?{eventSourceFactory:r.eventSourceFactory}:{}})):(s=c.failure,l=qo(c.failure));}this.configFailure=s,this.publishableKey=s===null?o:"",this.transport=l,s!==null&&Xl(s,this.telemetry,r?.platform),this.errorPolicy=n.errorPolicy,this.camera=n.camera??Ss,this.upload=n.upload??aa,this.uploadTransport=n.uploadTransport??Co,this.imageCache=n.imageCache??Zl,this.kv=n.storage??Ql(),this.currentUser=t.user??null,this.identity=this.buildIdentity(t.user??null),this.activePet=t.activePet,this.store=s===null?Go():Go(()=>nl("sdk_config",Ft("accessDenied"))),this.services={authFor:i(c=>this.buildAuth(c),"authFor"),telemetry:this.telemetry,errorPolicy:this.errorPolicy,camera:this.camera,upload:this.upload,uploadTransport:this.uploadTransport,imageCache:this.imageCache,kv:this.kv,apiBaseUrl:u},this.registry={services:this.services,acquireChat:i(c=>this.acquireInternal("chat",$o(c),()=>this.buildChatController(c),Jl),"acquireChat"),releaseChat:i(c=>this.releaseInternal(c),"releaseChat"),peekChat:i(c=>this.entries.get(`${this.epoch}|chat|${$o(c)}`)?.controller??null,"peekChat"),acquire:i((c,p,f,m)=>this.acquireInternal(c,p,f,m),"acquire"),release:i(c=>this.releaseInternal(c),"release")},this.entitlements=this.store;let d=s===null&&(r?.startEntitlementPolling??!a);this.poller=s===null?this.buildPoller(r?.pollScheduler):null,d&&this.poller?.start();}get isDisposed(){return this.disposed}get scopeEpoch(){return this.epoch}buildIdentity(t){if(t===null)return null;let r=As(t.userRef,t.getToken,n=>this.armTokenRefresh(r,n));return r}armTokenRefresh(t,r){if(this.clearTokenRefresh(),r===null||this.disposed||t!==this.identity)return;let n=r-Date.now();if(n<=0)return;let o=Math.max(n-vh,n/2);this.refreshTimer=setTimeout(()=>{this.refreshTimer=null,!(this.disposed||t!==this.identity)&&t.currentToken({forceRefresh:true}).catch(()=>{});},o),this.refreshTimer.unref?.();}clearTokenRefresh(){this.refreshTimer!==null&&clearTimeout(this.refreshTimer),this.refreshTimer=null;}buildPoller(t){return zl({authFor:i(()=>this.buildAuth(this.currentUser?.userRef??null),"authFor"),update:i((r,n,o)=>this.updateEntitlements({decisions:r,isPending:false,branding:n,...o===false?{livemode:o}:{}}),"update"),onFetch:i(()=>{this.verdictSettled||this.store.setPending(true);},"onFetch"),onSettled:i(()=>{this.verdictSettled=true,this.store.setPending(false);},"onSettled"),telemetry:this.telemetry,...t?{scheduler:t}:{}})}acquireInternal(t,r,n,o,s=false){let a=`${this.epoch}|${t}|${r}`,l=this.entries.get(a);if(l)return s||(l.warm?l.warm=false:l.refCount+=1),l.controller;let u=n();return this.entries.set(a,{controller:u,refCount:1,warm:s}),this.destroyers.set(u,o),u}releaseInternal(t){for(let[r,n]of this.entries)if(n.controller===t){n.refCount-=1,n.refCount<=0&&(this.runDestroyer(t),this.entries.delete(r));return}}runDestroyer(t){let r=this.destroyers.get(t);this.destroyers.delete(t),r&&r(t);}buildChatController(t){let r=ka({auth:this.buildAuth(t.userRef),telemetry:this.telemetry,...this.errorPolicy?{errorPolicy:this.errorPolicy}:{},initialConversationId:t.conversationId,petRef:t.petRef});return this.runBootstrap(r,t),r}runBootstrap(t,r){let n={};r.petRef!==null&&(n.petRef=r.petRef),r.conversationId!==null&&(n.resumeConversationId=r.conversationId);let o=wa(n,{controller:t});return o.then(s=>t.adoptPrompts(s.suggestedPrompts)).catch(()=>{}),this.bootstraps.set(t,o),o}buildAuth(t){return this.identity!==null&&this.currentUser!==null?{mode:"personalized",transport:this.transport,identity:this.identity,userRef:this.currentUser.userRef,sessionId:this.sessionId}:{mode:"anonymous",transport:this.transport,publishableKey:this.publishableKey,userRef:this.currentUser===null?null:t,sessionId:this.sessionId}}setUser(t){if(this.disposed)return;let r=t?.userRef??null,n=this.currentUser?.userRef??null;if(r===n){this.currentUser=t,t&&this.identity===null&&(this.identity=this.buildIdentity(t));return}this.pendingBeforeLogout=this.beforeLogoutSettlement(),this.identity?.clear(),this.clearTokenRefresh(),this.currentUser=t,this.identity=this.buildIdentity(t),this.rescopeAll();}async logout(){if(this.disposed)return;let t=this.currentUser===null;this.leavingSessionId=this.sessionId,this.sessionId=Zn(),this.setUser(null),this.leavingSessionId=null,t&&this.rescopeAll();let r=this.pendingBeforeLogout;this.pendingBeforeLogout=null,r!==null&&await r,await ql(this.kv,this.telemetry);}onBeforeLogout(t){return this.disposed?()=>{}:(this.beforeLogoutHooks.add(t),()=>{this.beforeLogoutHooks.delete(t);})}beforeLogoutSettlement(){let t=this.currentUser,r=this.identity;return Gl({leaving:t,identity:r,hooks:this.beforeLogoutHooks,telemetry:this.telemetry,graceAuth:i(()=>Kl({leaving:t,identity:r,transport:this.transport,sessionId:this.leavingSessionId??this.sessionId}),"graceAuth")})}async registerPet(t,r){return this.withPets("registerPet",n=>r===void 0?n.registerPet(t):n.registerPet(t,r))}updatePet(t,r){return this.withPets("updatePet",n=>n.updatePet(t,r))}deletePet(t){return this.withPets("deletePet",r=>r.deletePet(t))}eraseUserData(){return this.withPets("eraseUserData",t=>t.eraseUserData())}async withPets(t,r){return this.disposed?E(eu(t)):r(Je(this.buildAuth(this.currentUser?.userRef??null)))}prepare(t){let r=t?.petRef??null,n=`${this.epoch}|${this.currentUser?.userRef??""}|${r??""}`,o=this.prepared;if(o!==null&&o.key===n&&(o.result===null||o.result.status==="ready"))return o.promise;let s={key:n,result:null,promise:this.runPrepare(r).then(a=>(s.result=a,a))};return this.prepared=s,s.promise}async runPrepare(t){let r=Date.now(),n=this.configFailure,o=this.disposed?eu("prepare"):n===null?null:Ko(n),s=this.identity,[a,l,u]=await Promise.all([o?E(o):s===null?L(void 0):s.currentToken().then(()=>L(void 0),()=>E(D("authRejected",{retryable:false}))),o?E(o):this.primeEntitlements(),t===null?void 0:o?E(o):this.primeChat(t)]),d=a.ok?l.ok&&(u?.ok??true)?"ready":"partial":"failed",c=Date.now()-r;try{this.telemetry.track("sdk.prepare.timing",{durationMs:c,status:d});}catch{}return Object.freeze({status:d,durationMs:c,session:a,entitlements:l,...u?{chat:u}:{}})}async primeEntitlements(){let t=await this.poller?.prime();return t?t.kind==="failed"?E(t.error):L(void 0):E(D("internalError",{retryable:true}))}async primeChat(t){let r={userRef:this.currentUser?.userRef??null,petRef:t,conversationId:null},n=this.acquireInternal("chat",$o(r),()=>this.buildChatController(r),Jl,true),o=await this.bootstraps.get(n);return o?.cause&&n.getSnapshot().conversationId===null&&(o=await this.runBootstrap(n,r)),o?.cause?E(o.cause):L(void 0)}setActivePet(t){if(this.disposed)return;let r=t??null;r!==this.activePet&&(this.activePet=r,this.rescopeAll());}updateEntitlements(t){this.disposed||this.configFailure===null&&this.store.set(t);}open(t){this.telemetry.track("sdk.open",{capability:t});}dispose(){this.disposed||(this.disposed=true,this.epoch+=1,this.poller?.stop(),this.identity?.clear(),this.clearTokenRefresh(),this.disposeAllControllers());}rescopeAll(){this.epoch+=1,this.disposeAllControllers(),this.store.reset(),this.verdictSettled=false,this.poller?.refresh();}disposeAllControllers(){for(let t of this.entries.values())this.runDestroyer(t.controller);this.entries.clear(),this.destroyers.clear();}};i(Xo,"EverfurRuntimeImpl");var Yo=Xo;function $o(e){return `${e.userRef??""}|${e.petRef??""}|${e.conversationId??""}`}i($o,"chatScopeKey");function Jl(e){e.dispose();}i(Jl,"disposeChat");function eu(e){return D("validationFailed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}i(eu,"disposedError");var ru=Symbol.for("@everfur/sdk#EverfurContext@v1"),nu=globalThis,ln=nu[ru]??(nu[ru]=react.createContext(null));ln.displayName??="EverfurContext";function Y(){let e=react.useContext(ln);if(e===null)throw new Q("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}i(Y,"useEverfurContext");function ou(){return Y().handle}i(ou,"useEverfur");var iu=Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),su=globalThis,gr=su[iu]??(su[iu]=react.createContext(yt));gr.displayName??="EverfurThemeContext";function F(){return react.useContext(gr)}i(F,"useEverfurTheme");function un(e){let{runtime:t}=Y(),r=t.entitlements,n=react.useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot),o=e.seams.useColorScheme(),s=e.seams.useReducedMotion(),a=e.seams.useTextScale(),l=e.seams.useHighContrast(),u=e.seams.scaleTypeSizes,d=e.seams.platformMonoFamily?.(),c=e.seams.isFontRegistered,p=e.clientTheme?kh(e.clientTheme):"",f=react.useMemo(()=>e.clientTheme?We(e.clientTheme):null,[p]),m=n.branding??null,y=react.useMemo(()=>jo({branding:m,clientOverride:f,colorScheme:o,reducedMotion:s,textScale:a,scaleTypeSizes:u,highContrast:l,...d===void 0?{}:{platformMonoFamily:d},...c===void 0?{}:{isFontRegistered:c}}),[m,f,o,s,a,u,l,d,c]);return e.seams.useResolvedTheme?.(y),react.createElement(gr.Provider,{value:y},e.children)}i(un,"EverfurThemeProviderCore");function kh(e){try{return JSON.stringify(e)}catch{return Object.keys(e).join("&")}}i(kh,"stableKey");function cu(e){let{config:t,user:r,activePet:n,theme:o,warmUp:s,children:a,seams:l}=e,u=`${t?.publishableKey??""}|${t?.apiBaseUrl??""}|${t?.contractVersion??""}`,d=react.useRef(null),c=react.useRef(null),[p,f]=react.useReducer(T=>T+1,0),m=react.useRef(null),y=react.useRef(void 0),x=r?.userRef??null;y.current!==x&&(y.current!==void 0&&(m.current=null),y.current=x);let b=m.current!==null?m.current.user:r??null,C=react.useRef(null),_=react.useRef(void 0),P=n??null;_.current!==P&&(_.current!==void 0&&(C.current=null),_.current=P);let k=C.current!==null?C.current.pet:n??null;(d.current===null||d.current.key!==u||d.current.runtime.isDisposed)&&(d.current!==null&&!d.current.runtime.isDisposed&&(c.current=d.current.runtime),d.current={key:u,runtime:tu({config:l.withDefaults?l.withDefaults(t):t,user:b,activePet:k,theme:o??null},{platform:l.platform,...l.eventSourceFactory?{eventSourceFactory:l.eventSourceFactory}:{}})});let g=d.current.runtime,w=react.useRef(null);react.useEffect(()=>{let T=d.current?.runtime;T===void 0||!T.isDisposed||w.current!==T&&(w.current=T,f());}),react.useEffect(()=>{let T=c.current;T!==null&&(c.current=null,T.dispose());});let O=b?.userRef??null;react.useLayoutEffect(()=>{g.setUser(b);},[g,O]),react.useLayoutEffect(()=>{g.setActivePet(k);},[g,k]),react.useEffect(()=>()=>g.dispose(),[g]),react.useEffect(()=>{s==="onMount"&&g.prepare(k===null?{}:{petRef:k});},[g,s,O,k]);let M=react.useMemo(()=>({setUser:i(T=>{m.current={user:T},g.setUser(T),f();},"setUser"),setActivePet:i(T=>{C.current={pet:T},g.setActivePet(T),f();},"setActivePet"),open:i(T=>g.open(T),"open"),prepare:i(T=>g.prepare(T),"prepare"),registerPet:i((T,V)=>g.registerPet(T,V),"registerPet"),updatePet:i((T,V)=>g.updatePet(T,V),"updatePet"),deletePet:i(T=>g.deletePet(T),"deletePet"),eraseUserData:i(()=>g.eraseUserData(),"eraseUserData"),logout:i(()=>{m.current={user:null};let T=g.logout();return f(),T},"logout")}),[g,f]),I=react.useMemo(()=>({runtime:g,handle:M,userRef:O,activePet:k,scopeEpoch:g.scopeEpoch}),[g,M,O,k,p]),v=react.createElement(un,{clientTheme:o??null,seams:l.theme,children:a});return react.createElement(ln.Provider,{value:I},l.wrap?l.wrap(v):v)}i(cu,"EverfurProviderCore");var wh=2;function Ih(e,t){let r=e?._xhr;if(!r||typeof r.getResponseHeader!="function"||typeof r.readyState=="number"&&r.readyState<wh)return null;let n;try{n=r.getResponseHeader(t);}catch{return null}return typeof n=="string"&&n.length>0?n:null}i(Ih,"readEventSourceResponseHeader");function pu(){let e=_h__default.default;return (t,r)=>{let n=new e(t,{method:r.method,headers:r.headers,pollingInterval:r.pollingInterval??0,...r.body!==void 0?{body:r.body}:{}});return Object.assign(n,{getResponseHeader:i(o=>Ih(n,o),"getResponseHeader")})}}i(pu,"createRnEventSourceFactory");function Mh(){let e=reactNative.useColorScheme();return e==="dark"?"dark":e==="light"?"light":null}i(Mh,"useRnColorScheme");function Lh(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(Lh,"isThenable");function Dh(){let[e,t]=react.useState(false);return react.useEffect(()=>{let r=true,n=reactNative.AccessibilityInfo?.isReduceMotionEnabled;if(typeof n=="function"){let s=n.call(reactNative.AccessibilityInfo);s!=null&&typeof s.then=="function"&&s.then(a=>{r&&t(a===true);},()=>{});}let o=reactNative.AccessibilityInfo?.addEventListener?.("reduceMotionChanged",s=>t(s===true));return ()=>{r=false,o?.remove?.();}},[]),e}i(Dh,"useRnReducedMotion");function yu(){let e=reactNative.PixelRatio?.getFontScale;if(typeof e!="function")return 1;try{let t=e.call(reactNative.PixelRatio);return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1}catch{return 1}}i(yu,"readFontScale");function Nh(e){let t=reactNative.Dimensions?.addEventListener;if(typeof t!="function")return ()=>{};let r=t.call(reactNative.Dimensions,"change",e);return ()=>r?.remove?.()}i(Nh,"subscribeFontScale");function Uh(){return react.useSyncExternalStore(Nh,yu,yu)}i(Uh,"useRnTextScale");function vu(){try{let e=reactNative.Platform?.OS;return typeof e=="string"?e:null}catch{return null}}i(vu,"platformOS");function Vh(){return vu()==="android"?{query:"isHighTextContrastEnabled",event:"highTextContrastChanged"}:{query:"isDarkerSystemColorsEnabled",event:"darkerSystemColorsChanged"}}i(Vh,"contrastSignal");function Hh(){let[e,t]=react.useState(false);return react.useEffect(()=>{let r=true,{query:n,event:o}=Vh(),a=reactNative.AccessibilityInfo?.[n];if(typeof a!="function")return ()=>{};try{let d=a.call(reactNative.AccessibilityInfo);Lh(d)&&Promise.resolve(d).then(c=>{r&&t(c===!0);},()=>{});}catch{}let l=reactNative.AccessibilityInfo?.addEventListener,u=typeof l=="function"?l.call(reactNative.AccessibilityInfo,o,d=>t(d===true)):void 0;return ()=>{r=false,u?.remove?.();}},[]),e}i(Hh,"useRnHighContrast");function Bh(){return vu()==="ios"?"Menlo":Ne}i(Bh,"rnPlatformMonoFamily");function zh(){return globalThis.__DEV__!==false}i(zh,"isDevelopment");var gu=new Set;function jh(e){if(!zh()||gu.has(e))return;gu.add(e);let t=globalThis.console;try{t?.warn?.(`[everfur] The theme names the font face "${e}", which this app has not registered; the SDK renders the platform font at that weight instead. Register the font file (expo-font or your native font assets) or name a registered face.`);}catch{}}i(jh,"warnUnregisteredFace");function Wh(e){let t=globalThis.expo?.modules?.ExpoFontLoader,r=t?.getLoadedFonts;if(typeof r!="function")return null;let n;try{n=r.call(t);}catch{return null}if(!Array.isArray(n)||n.length===0)return null;let o=n.includes(e);return o||jh(e),o}i(Wh,"rnIsFontRegistered");var cn=Object.freeze({useColorScheme:Mh,useReducedMotion:Dh,useTextScale:Uh,useHighContrast:Hh,scaleTypeSizes:false,platformMonoFamily:Bh,isFontRegistered:Wh});function Kh(e){return react.createElement(reactNativeSafeAreaContext.SafeAreaProvider,null,e)}i(Kh,"wrapInSafeArea");var qh=Object.freeze({platform:"react-native",eventSourceFactory:pu(),wrap:Kh,theme:cn});function $h(e){return react.createElement(cu,{...e,seams:qh})}i($h,"EverfurProvider");function Nt(e){let{runtime:t}=Y(),r=t.entitlements,n=react.useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot);return react.useMemo(()=>ol(e,n.decisions,{isPending:n.isPending}),[e,n])}i(Nt,"useCapability");function eb(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}i(eb,"tierMultiplier");function R({tier:e="content",...t}){let{type:r}=F(),n=eb(r,e);return react.createElement(reactNative.Text,n===void 0?t:{maxFontSizeMultiplier:n,...t})}i(R,"Text");var Ut=react.forwardRef(i(function(t,r){return react.createElement(reactNative.TextInput,{...t,...r===null?{}:{ref:r}})},"TextInput"));var tb=Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function S(e,t){let r=e.type,n=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:n}:{fontFamily:n,fontWeight:r.weight[tb[t]]}}i(S,"face");var Zo=class Zo extends react.Component{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey};}static getDerivedStateFromError(){return {failed:true}}static getDerivedStateFromProps(r,n){return Object.is(r.resetKey,n.key)?null:{failed:false,key:r.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};i(Zo,"HostRenderBoundary");var Qo=Zo;function nb({render:e}){return e()}i(nb,"RenderHost");function Et({render:e,fallback:t,resetKey:r}){return react.createElement(Qo,{fallback:t,resetKey:r,children:react.createElement(nb,{render:e})})}i(Et,"HostRender");var ob=48;function ib(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}i(ib,"selectView");function ti(e){let{capability:t,children:r,renderDisabled:n,renderPending:o,style:s}=e,a=Nt(t),l=react.useMemo(()=>ib(a),[a]);switch(l){case "enabled":return r;case "pending":return o?jsxRuntime.jsx(Et,{render:o,fallback:jsxRuntime.jsx(Tu,{capability:t,style:s})}):jsxRuntime.jsx(Tu,{capability:t,style:s});case "disabled":return n?jsxRuntime.jsx(Et,{render:()=>n(a),fallback:jsxRuntime.jsx(Pu,{decision:a,style:s}),resetKey:a}):jsxRuntime.jsx(Pu,{decision:a,style:s});default:return Ze(l)}}i(ti,"CapabilityGate");function Tu({capability:e,style:t}){let r=F(),n=react.useMemo(()=>ku(r),[r]);return jsxRuntime.jsx(reactNative.View,{style:[n.offstate,t],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${e}`,children:jsxRuntime.jsx(reactNative.View,{style:n.skeletonBar})})}i(Tu,"PendingSkeleton");function Pu({decision:e,style:t}){let r=F(),n=react.useMemo(()=>ku(r),[r]),o=e.disabled?.reason??"";return jsxRuntime.jsx(reactNative.View,{style:[n.offstate,t],accessible:true,accessibilityRole:"text",accessibilityLabel:o,children:o.length>0?jsxRuntime.jsx(R,{style:n.offstateText,children:o}):null})}i(Pu,"OffState");function ku(e){let{color:t,space:r,radius:n,type:o}=e;return reactNative.StyleSheet.create({offstate:{minHeight:ob,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},offstateText:{...S(e,"regular"),fontSize:o.size.body,lineHeight:Math.round(o.size.body*o.lineHeight.normal),color:t.text.muted},skeletonBar:{height:r.md,borderRadius:n.xs,backgroundColor:t.brandSofter}})}i(ku,"makeStyles");var h=Object.freeze({placeholder:"Ask me anything!",send:"Send",stop:"Stop",retry:"Try again",followUps:"Helpful follow-ups",poweredBy:"powered by everfur",senderUser:"You",senderAssistant:"Assistant",typing:"Assistant is typing",loading:"Loading",empty:"No messages yet",transcript:"Conversation",emptyTitle:"What can we help {petName} with today?",emptyTitlePetFallback:"your pet",copied:"Copied",copyUserMessage:"Copy your message",copyAssistantMessage:"Copy assistant message",feedbackHelpful:"Helpful",feedbackNeutral:"Neutral",feedbackNotHelpful:"Not helpful",feedbackTitle:"What went wrong?",feedbackSubtitle:"Your feedback helps make answers more reliable.",feedbackReasonInaccurate:"Inaccurate",feedbackReasonOutdated:"Out of date",feedbackReasonUnsafe:"Unsafe advice",feedbackReasonUnclear:"Confusing or unclear",feedbackReasonOther:"Something else",feedbackNotesPlaceholder:"Add details (optional)",feedbackSubmit:"Submit feedback",feedbackSkip:"Skip",feedbackSkipA11y:"Skip feedback",feedbackThanks:"Thanks for the feedback",feedbackFailed:"Couldn't send feedback. Please try again.",turnFailedTitle:"Message failed",turnRetry:"Retry",turnUnreachableTitle:"Couldn't reach this chat",turnStartNewChat:"Start a new chat",reconnecting:"Reconnecting\u2026",turnStoppedTitle:"Response stopped",turnStoppedBody:"You stopped this response before it finished. Tap retry to try again.",sourceSingular:"source",sourcePlural:"sources",showSources:"Show",hideSources:"Hide",openSource:"Open source",urgencyGeneralReason:"Just general info about {petName}. Nothing here needs action right now.",findVet:"Find a vet",findVetA11y:"Find a vet near you",showLatestVetAlert:"Show latest vet alert",dismissBanner:"Dismiss {label} banner",openMenu:"Open menu",openMenuUnread:"Open menu, unread chats",yourPets:"Your Pets",yourPet:"Your pet",switchActivePet:"Switch active pet, {name}",petCurrentlyActive:"{name}, currently active",switchToPet:"Switch to {name}",activePrefix:"Active \xB7 ",close:"Close",addAnotherPet:"Add another pet",addPet:"Add a pet",attachmentPhoto:"Photo",attachmentCamera:"Camera",closeAttachmentPicker:"Close attachment picker",addAttachment:"Add attachment, {used} of {total} used",attachmentsFull:"Attachments full, {used} of {total} used",retryUpload:"Retry uploading {filename}",removeAttachment:"Remove {filename}",previewAttachment:"Preview {filename}",closePreview:"Close preview",attachedImage:"Attached image: {filename}, opens a full-screen preview",attachmentTooLarge:"Files must be under {max}. {filename} is {size}.",attachmentTooMany:"You can attach up to {max} files per message.",attachmentUnsupported:"{filename} isn't a supported file type yet.",attachmentNetwork:"Couldn't reach the server. Check your connection and try again.",attachmentServer:"Upload failed{status}. Please try again.",attachmentCancelled:"Upload cancelled.",attachmentRateLimited:"Slow down. Please wait a moment and try again.",attachmentQuota:"Daily image limit reached. Try again tomorrow.",attachmentConflict:"Something went wrong. Tap to retry.",attachmentUnknown:"Something went wrong. Please try again.",attachmentsFailedBlocked:"Some attachments failed to upload. Remove or retry them before sending.",dictate:"Dictate a message",stopDictation:"Stop dictation",listening:"Listening",micBlocked:"Microphone access is blocked. Allow it in your browser settings to dictate.",noSpeech:"We didn't catch that. Tap the mic and try again.",dictationUnavailable:"Voice typing isn't available right now."});function K(e,t){return e.replace(/\{(\w+)\}/g,(r,n)=>{let o=t[n];return o===void 0?r:String(o)})}i(K,"fillCopy");var ri=Object.freeze([Object.freeze({key:"inaccurate",label:h.feedbackReasonInaccurate,feedbackType:"wrong"}),Object.freeze({key:"outdated",label:h.feedbackReasonOutdated,feedbackType:"outdated"}),Object.freeze({key:"unsafe",label:h.feedbackReasonUnsafe,feedbackType:"dangerous"}),Object.freeze({key:"unclear",label:h.feedbackReasonUnclear,feedbackType:"unclear"}),Object.freeze({key:"other",label:h.feedbackReasonOther,feedbackType:"not_helpful"})]),xu=Object.freeze([Object.freeze({sentiment:"up",label:h.feedbackHelpful}),Object.freeze({sentiment:"neutral",label:h.feedbackNeutral}),Object.freeze({sentiment:"down",label:h.feedbackNotHelpful})]);function sb(e){switch(e){case "up":return "helpful";case "neutral":return "neutral";case "down":return "not_helpful"}}i(sb,"sentimentToFeedbackType");function _u(e,t){if(e==="down"&&t!==null){let r=ri.find(n=>n.key===t);if(r!==void 0)return r.feedbackType}return sb(e)}i(_u,"feedbackTypeFor");var db=Object.freeze({status:"idle",messages:Object.freeze([]),conversationId:null,error:null,isStreaming:false,isBootstrapping:true,suggestedPrompts:Object.freeze([]),unreadCount:null});function hr(e){let{runtime:t,userRef:r,activePet:n,scopeEpoch:o}=Y(),s=e?.petRef??n??null,a=e?.conversationId??null,l=react.useMemo(()=>({runtime:t,userRef:r,petRef:s,conversationId:a,scopeEpoch:o}),[t,r,s,a,o]),[u,d]=react.useState(null),c=u?.scope===l?u.controller:t.registry.peekChat({userRef:r,petRef:s,conversationId:a}),p=react.useRef(null);react.useEffect(()=>{let I=t.registry.acquireChat({userRef:r,petRef:s,conversationId:a});return p.current=I,d({scope:l,controller:I}),()=>{p.current=null,d(v=>v?.controller===I?null:v),t.registry.releaseChat(I);}},[t,r,s,a,o,l]);let f=react.useCallback(I=>c?c.subscribe(I):cb,[c]),m=react.useCallback(()=>c?c.getSnapshot():db,[c]),y=react.useSyncExternalStore(f,m,m),x=react.useCallback((I,v)=>c&&p.current===c&&!c.getSnapshot().isBootstrapping?oi(c,c.send(I,v?.imageS3Keys===void 0?{}:{imageS3Keys:v.imageS3Keys}),()=>p.current===c):Promise.resolve(ii()),[c]),b=react.useCallback(I=>c&&p.current===c&&!c.getSnapshot().isBootstrapping?oi(c,c.askEverfur(I),()=>p.current===c):Promise.resolve(ii()),[c]),C=react.useCallback(()=>c&&p.current===c?oi(c,c.retryLast(),()=>p.current===c):Promise.resolve(ii()),[c]),_=react.useCallback(()=>{c&&p.current===c&&c.stop();},[c]),P=react.useCallback(()=>{c&&p.current===c&&c.newConversation();},[c]),[k,g]=react.useState({controller:null,byMessage:{}}),w=k.controller===c?k.byMessage:pb,O=react.useCallback(async(I,v,T,V)=>{if(!c||p.current!==c)return E(D("accessDenied"));let j=String(I),W=k.controller===c?k.byMessage[j]:void 0;if(W===v&&T==null)return g(he=>{let ke={...he.controller===c?he.byMessage:{}};return delete ke[j],{controller:c,byMessage:ke}}),L(Object.freeze({feedbackId:""}));g(he=>({controller:c,byMessage:{...he.controller===c?he.byMessage:{},[j]:v}}));let ne=await c.submitFeedback(I,_u(v,T??null),V??null);return p.current!==c?E(D("accessDenied")):(ne.ok||g(he=>{let ke={...he.controller===c?he.byMessage:{}};return W===void 0?delete ke[j]:ke[j]=W,{controller:c,byMessage:ke}}),ne)},[c,k]),M=react.useMemo(()=>{let I=i(async v=>{if(!c||p.current!==c)return E(D("accessDenied"));let T=await v(c);return p.current===c?T:E(D("accessDenied"))},"run");return {listConversations:i(v=>I(T=>T.listConversations({...s?{petRef:s}:{},...v})),"listConversations"),getMessages:i((v,T)=>I(V=>V.getMessages(v,T)),"getMessages"),resumeConversation:i(v=>I(T=>T.resumeConversation(v)),"resumeConversation"),loadOlderMessages:i(()=>I(v=>v.loadOlderMessages()),"loadOlderMessages"),markRead:i(()=>I(v=>v.markRead()),"markRead"),refreshActiveThread:i(()=>I(v=>v.refreshActiveThread()),"refreshActiveThread"),answerCheckin:i((v,T)=>I(V=>V.answerCheckin(v,T)),"answerCheckin"),openCheckin:i(v=>I(T=>T.openCheckin(v)),"openCheckin")}},[c,s]);return react.useMemo(()=>({status:y.status,messages:y.messages,conversationId:y.conversationId,petRef:s,error:y.error,isStreaming:y.isStreaming,isBootstrapping:y.isBootstrapping,historyCursor:y.historyCursor??null,isLoadingHistory:y.isLoadingHistory??false,stopped:y.stopped??false,reconnecting:y.reconnecting??false,...M,suggestedPrompts:y.suggestedPrompts,unreadCount:y.unreadCount,hasUnreadThreads:y.hasUnreadThreads??false,newConversation:P,sentimentByMessage:w,feedback:O,send:x,askEverfur:b,retryLast:C,stop:_}),[y,s,x,b,C,_,M,P,w,O])}i(hr,"useEverfurChat");var cb=i(()=>{},"NOOP_UNSUBSCRIBE"),pb=Object.freeze({});async function oi(e,t,r){for await(let o of t);if(!r())return E(D("accessDenied"));let n=e.getSnapshot();return n.status==="error"&&n.error!==null?E(n.error):L(fb(n.messages))}i(oi,"driveToResult");function fb(e){for(let t=e.length-1;t>=0;t-=1){let r=e[t];if(r&&r.role==="assistant"&&r.responseId!==void 0)return r.responseId}return null}i(fb,"lastAssistantResponseId");function ii(){return E(D("internalError",{retryable:true}))}i(ii,"notReadyError");function Ou(e){switch(e.code){case "too_large":return K(h.attachmentTooLarge,{max:So(Yr),filename:e.filename,size:So(e.sizeBytes??0)});case "too_many":return K(h.attachmentTooMany,{max:Xr});case "unsupported_type":return K(h.attachmentUnsupported,{filename:e.filename});case "network":return h.attachmentNetwork;case "server":return K(h.attachmentServer,{status:e.httpStatus?` (${e.httpStatus})`:""});case "cancelled":return h.attachmentCancelled;case "rate_limited":return h.attachmentRateLimited;case "quota_exceeded":return h.attachmentQuota;case "idempotency_conflict":return h.attachmentConflict;case "unknown":return h.attachmentUnknown}}i(Ou,"attachmentErrorMessage");function Fu(e,t){return K(e>=t?h.attachmentsFull:h.addAttachment,{used:e,total:t})}i(Fu,"attachControlLabel");var hb=Object.freeze({attachments:Object.freeze([])});function pn(e={}){let{runtime:t,userRef:r,scopeEpoch:n}=Y(),o=e.maxPerMessage??Xr,s=react.useCallback(()=>{let{services:g}=t.registry;return Oa({funnel:xe({auth:g.authFor(r),...g.errorPolicy?{errorPolicy:g.errorPolicy}:{}}),transport:e.transport??g.uploadTransport,maxPerMessage:o})},[t,r,n,o,e.transport]),a=react.useMemo(()=>e.queue??s(),[e.queue,s]),l=react.useRef(new WeakSet),[u,d]=react.useState(null),c=u!==null&&u.of===a?u.queue:a;react.useEffect(()=>{if(c!==e.queue){if(l.current.has(c)){d({of:a,queue:s()});return}return ()=>{c.dispose(),l.current.add(c);}}},[c,a,s,e.queue]);let p=react.useSyncExternalStore(c.subscribe,c.getSnapshot,()=>hb),[f,m]=react.useState(null),y=react.useCallback(g=>{let O=(Array.isArray(g)?g:[g]).map(I=>c.add(I)),M=O.find(I=>!I.ok);return M!==void 0&&!M.ok&&m(M.error),O},[c,m]),x=react.useCallback(g=>c.retry(g),[c]),b=react.useCallback(g=>c.remove(g),[c]),C=react.useCallback(()=>c.clear(),[c]),_=react.useCallback(()=>m(null),[m]),P=p.attachments.some(g=>g.status==="uploading"),k=p.attachments.some(g=>g.status==="failed");return react.useMemo(()=>({available:c.available,attachments:p.attachments,maxPerMessage:o,uploading:P,failed:k,blocked:P||k,s3Keys:p.attachments.flatMap(g=>g.status==="uploaded"&&g.s3Key!==null?[g.s3Key]:[]),rejected:f,add:y,retry:x,remove:b,clear:C,dismissRejected:_}),[c.available,p,o,P,k,f,y,x,b,C,_])}i(pn,"useChatAttachments");var Eb="pet_not_registered";function Du(e){return e!=null&&e.reasonCode===Eb}i(Du,"isPetNotRegistered");var Cb=Object.freeze({status:"idle",error:null,registered:null,retry:i(()=>{},"retry")});function Nu(e,t,r){let{runtime:n,userRef:o,scopeEpoch:s}=Y(),a=react.useCallback(()=>Je(n.registry.services.authFor(o)),[n,o,s]),l=react.useMemo(()=>t===void 0?null:ai(t),[t]),[u,d]=react.useState({key:null,status:"idle",error:null,registered:null}),c=react.useRef(0),p=react.useRef(r);p.current=r;let f=e===null||l===null?null:`${String(o)}|${s}|${e}|${l}`,m=react.useCallback(()=>{if(e===null||t===void 0||f===null)return;let x=++c.current;d({key:f,status:"registering",error:null,registered:null}),a().registerPet(e,t).then(b=>{x===c.current&&(b.ok?(d({key:f,status:"registered",error:null,registered:b.value}),p.current?.()):d({key:f,status:"failed",error:b.error,registered:null}));});},[a,e,f]);react.useEffect(()=>{if(f===null){c.current+=1;return}return m(),()=>{c.current+=1;}},[f,m]);let y=react.useCallback(()=>{u.status==="failed"&&m();},[u.status,m]);return react.useMemo(()=>f===null?Cb:u.key!==f?{status:"registering",error:null,registered:null,retry:y}:{status:u.status,error:u.error,registered:u.registered,retry:y},[f,u,y])}i(Nu,"useChatPetRegistration");function ai(e){return e===null||typeof e!="object"?JSON.stringify(e)??"undefined":Array.isArray(e)?`[${e.map(ai).join(",")}]`:`{${Object.entries(e).filter(([,r])=>r!==void 0).sort(([r],[n])=>r<n?-1:r>n?1:0).map(([r,n])=>`${JSON.stringify(r)}:${ai(n)}`).join(",")}}`}i(ai,"stableKey");var li=Object.freeze({});function Vu(e){let[t,r]=react.useState(li),n=react.useRef(null),o=react.useRef([]);o.current=e.map(a=>a.id),react.useEffect(()=>{if(e.length===0){n.current=null,r(u=>u===li?u:li);return}let a=n.current;if(a===null)return;let l=e.find(u=>u.role==="user"&&!a.known.has(u.id));l!==void 0&&(n.current=null,r(u=>({...u,[l.id]:a.images})));},[e]);let s=react.useCallback(a=>{n.current=a.length===0?null:{images:a,known:new Set(o.current)};},[]);return react.useMemo(()=>({byMessage:t,stage:s}),[t,s])}i(Vu,"useSentImages");var xb=500;function ui(e){if(!e)return null;let t=e.replace(/[\u0000-\u001F\u007F-\u009F\u200E\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g," ").replace(/\s+/g," ").trim();return t?t.slice(0,xb):null}i(ui,"sanitizeSeedPrompt");function Bu(e,t,r){let n=ui(r),o=react.useRef(e);o.current=e;let s=react.useRef(null);react.useEffect(()=>{if(n===null||t||s.current===n)return;let a=o.current;a!==void 0&&(s.current=n,Promise.resolve(a(n)).catch(()=>{}));},[n,t]);}i(Bu,"useInitialAsk");function _b(e,t,r){if(e==="announced")return false;let n=r.lastRefresh;return n===null||n.conversationId!==t?false:r.now-n.at<15e3}i(_b,"isCoalesced");function zu(e,t){let r=t.activeConversationId;return r===null||r.length===0?{action:"skip",reason:"no_thread"}:t.isTurnInFlight?{action:"defer",reason:"turn_in_flight"}:t.isOffline?{action:"defer",reason:"offline"}:_b(e,r,t)?{action:"skip",reason:"coalesced"}:{action:"refresh",conversationId:r}}i(zu,"decideChatRefresh");function di(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e);}catch{}}i(di,"reportHostFailure");function wb(e){return (typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}i(wb,"isThenable");function q(e,...t){if(typeof e=="function")try{let r=e(...t);return wb(r)&&Promise.resolve(r).then(void 0,di),r}catch(r){di(r);return}}i(q,"callHost");var ju=new WeakMap;function Wu(e){if(typeof e!="function")return;let t=ju.get(e);if(t!==void 0)return t;let r=i((...n)=>{q(e,...n);},"guarded");return ju.set(e,r),r}i(Wu,"guardHost");function Ht(e,...t){let r;try{r=e(...t);}catch(n){return di(n),Promise.resolve({ok:false,error:n})}return Promise.resolve(r).then(n=>({ok:true,value:n}),n=>({ok:false,error:n}))}i(Ht,"callHostAsync");function Ku(e,t){let r=react.useRef(t);r.current=t;let n=react.useRef(null),o=react.useRef(null),s=e?.isOffline===void 0?false:q(()=>e.isOffline?.()===!0)===true,a=react.useRef(()=>{});a.current=l=>{let{conversationId:u,isTurnInFlight:d,refresh:c}=r.current,p=zu(l,{activeConversationId:u,isTurnInFlight:d,isOffline:s,lastRefresh:n.current,now:Date.now()});if(p.action!=="skip"){if(p.action==="defer"){o.current!=="announced"&&(o.current=l);return}o.current=null,n.current={conversationId:p.conversationId,at:Date.now()},c!==void 0&&Promise.resolve(c()).catch(()=>{});}},react.useEffect(()=>{if(t.isTurnInFlight||s)return;let l=o.current;l!==null&&a.current(l);},[t.isTurnInFlight,s]),react.useEffect(()=>{if(e===void 0)return;let l=[],u=i((d,c)=>{if(d===void 0)return;let p=q(()=>d(()=>{a.current(c);}));typeof p=="function"&&l.push(p);},"subscribe");return u(e.onForeground?.bind(e),"foreground"),u(e.onOnline?.bind(e),"foreground"),u(e.onAnnounced?.bind(e),"announced"),()=>{for(let d of l)q(d);}},[e]);}i(Ku,"useChatLifecycle");function Ab(e){if(e===void 0)return null;let t=e.conversationId??"",r=e.petRef??"";return t===""&&r===""?null:`${String(t)}|${String(r)}`}i(Ab,"targetKey");function $u(e,t){let r=Ab(t),n=react.useRef({openCheckin:e,target:t});n.current={openCheckin:e,target:t};let o=react.useRef(null);react.useEffect(()=>{if(r===null||o.current===r)return;o.current=r;let{openCheckin:s,target:a}=n.current;s===void 0||a===void 0||Promise.resolve(s(a)).catch(()=>{});},[r]);}i($u,"useCheckinTarget");function Qu(e,t,r){let[n,o]=react.useState({send:e,conversationId:t,text:r??"",seeded:r??null}),s=n.send===e&&(n.conversationId===null||n.conversationId===t);react.useEffect(()=>{o(l=>{let u=l.send===e&&(l.conversationId===null||l.conversationId===t),d=u?l.text:"",c=u?l.seeded:null,p=r!=null&&r!==c&&d.length===0;return {send:e,conversationId:t,text:p?r:d,seeded:p?r:c}});},[e,t,r]);let a=react.useCallback(l=>o(u=>({send:e,conversationId:t,text:l,seeded:u.seeded})),[e,t]);return [s?n.text:"",a]}i(Qu,"useChatDraft");function Zu(e,t,r,n){let o=react.useRef({draft:r,setDraft:n});o.current={draft:r,setDraft:n};let s=react.useRef(null),[a,l]=react.useState(null);react.useEffect(()=>{if(e===void 0)return;let u=`${t??""}`;if(s.current===u)return;s.current=u;let d=true;return (async()=>{let c=await Ht(()=>e.read(t));if(!d)return;let p=c.ok&&typeof c.value=="string"?c.value:"";p.length>0&&o.current.draft.length===0&&o.current.setDraft(p),l(u);})(),()=>{d=false;}},[e,t]),react.useEffect(()=>{e===void 0||a!==`${t??""}`||q(()=>e.write(t,r));},[e,t,r,a]);}i(Zu,"usePersistedDraft");var Z=Object.freeze({heading:"Chat History",empty:"No chats yet",emptyBody:"Start a new conversation to see it here.",noMatch:"No matching chats",noMatchBody:"Try a different title or start a new conversation.",loading:"Loading your chats\u2026",loadFailed:"Couldn\u2019t load your chats",loadingMore:"Loading more\u2026",untitled:"New conversation",newConversation:"New conversation",newChat:"New chat",search:"Search",retry:"Try again",retryA11y:"Retry loading chats",close:"Close",closeA11y:"Close history",more:"Load more",earlier:"Load earlier messages",loadingEarlier:"Loading earlier messages\u2026",openConversation:"Open conversation",unreadPrefix:"Unread. "});function mn(e){let t=e?.replace(/\s+/g," ").trim();return t||Z.untitled}i(mn,"conversationTitle");function ed(e){return `${e.unreadCount!==null&&e.unreadCount>0?Z.unreadPrefix:""}${Z.openConversation} ${mn(e.title)}`}i(ed,"openConversationLabel");function Ju(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').toLowerCase().trim().replace(/\s+/g," ")}i(Ju,"normalizeForSearch");function Nb(e,t){let r=Ju(t);if(r.length===0)return e;let n=[[],[],[]];for(let o of e){let s=Ju(mn(o.title)),a=s.indexOf(r);if(a<0)continue;let l=a===0?0:s.charAt(a-1)===" "?1:2;n[l]?.push(o);}return n.flat()}i(Nb,"filterConversations");function fi(e){return {scope:e,rows:[],cursor:null,loading:false,loadingMore:false,error:null}}i(fi,"fresh");function td(e){let[t,r]=react.useState(false),[n,o]=react.useState(""),s=e.listConversations,a=react.useRef(0),[l,u]=react.useState(()=>fi(s)),d=l.scope===s?l:fi(s);react.useEffect(()=>(a.current+=1,r(false),o(""),u(fi(s)),()=>{a.current+=1;}),[s]);let c=react.useCallback(async P=>{let k=++a.current,g=P!==void 0;u(O=>({...O,scope:s,loading:!g,loadingMore:g,error:null}));let w=await e.listConversations(P?{cursor:P}:void 0);if(k===a.current){if(!w.ok){u(O=>({...O,loading:false,loadingMore:false,error:w.error.displayMessage}));return}u(O=>{let M=P&&O.scope===s?O.rows:[],I=new Set(M.map(v=>v.id));return {scope:s,loading:false,loadingMore:false,error:null,rows:[...M,...w.value.conversations.filter(v=>!I.has(v.id))],cursor:w.value.nextCursor===P?null:w.value.nextCursor}});}},[e.listConversations,s]),p=i(()=>{r(true),o(""),c();},"show"),f=i(()=>{a.current+=1,r(false);},"close"),m=i(async P=>{let k=++a.current;u(w=>({...w,loading:true,error:null}));let g=await e.resumeConversation(P);k===a.current&&(u(w=>({...w,loading:false,error:g.ok?null:g.error.displayMessage})),g.ok&&r(false));},"resume"),y=i(async()=>{let P=a.current,k=await e.loadOlderMessages();P===a.current&&!k.ok&&u(g=>({...g,error:k.error.displayMessage}));},"earlier"),x=i(()=>{e.newConversation(),a.current+=1,r(false);},"newConversation"),b=i(()=>{d.cursor===null||d.loading||d.loadingMore||n.trim().length>0||c(d.cursor);},"loadMore"),C=react.useMemo(()=>Nb(d.rows,n),[d.rows,n]),_=n.trim().length>0;return {...d,open:t,show:p,close:f,load:c,resume:m,earlier:y,newConversation:x,loadMore:b,query:n,setQuery:o,searching:_,filtered:C,emptyKind:d.rows.length===0?"empty":"noMatch"}}i(td,"useHistoryPanel");var yn="#111111",gn="#FFFFFF",Hb=Object.freeze({emergency:Object.freeze({level:"emergency",label:"Vet care now",borderColor:"#FCA5A5",backgroundColor:"#FEF2F2",textColor:"#991B1B",reasonColor:yn,pillColor:gn,showsVetAction:true}),schedule_soon:Object.freeze({level:"schedule_soon",label:"Vet care suggested soon",borderColor:"#FCD34D",backgroundColor:"#FFFBEB",textColor:"#92400E",reasonColor:yn,pillColor:gn,showsVetAction:true}),home_care:Object.freeze({level:"home_care",label:"Monitor at home",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:yn,pillColor:gn,showsVetAction:false}),general:Object.freeze({level:"general",label:"Good to know",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:yn,pillColor:gn,showsVetAction:false})});function Bb(e){return `${e.messageId}:${e.level}:${e.reason??""}`}i(Bb,"urgencySignature");function zb(e){return K(h.urgencyGeneralReason,{petName:e?.trim()||h.emptyTitlePetFallback})}i(zb,"generalUrgencyReason");function od(e,t){for(let r=e.length-1;r>=0;r-=1){let n=e[r];if(n?.role!=="assistant"||n.responseId===void 0)continue;let o=n.urgencyLevel;return o?{messageId:n.id,level:o,reason:jb(n.urgencyReason)}:n.urgencyProvided===true?{messageId:n.id,level:"general",reason:zb(t)}:null}return null}i(od,"latestUrgencySource");function jb(e){return typeof e=="string"&&e.trim().length>0?e:null}i(jb,"shownReason");function id(e){let t=e===null?null:Bb(e),[r,n]=react.useState(null),[o,s]=react.useState(false);react.useEffect(()=>s(false),[t]);let l=e!==null&&(o||!(r!==null&&r===t)),u=e===null?null:Hb[e.level],d=e!==null&&!l&&e.level!=="general",c=react.useCallback(()=>{t!==null&&n(t),s(false);},[t]),p=react.useCallback(()=>s(true),[]);return react.useMemo(()=>({source:e,tier:u,signature:t,showBanner:l,showCompactIcon:d,showVetAction:l&&u!==null&&u.showsVetAction,dismissLabel:u===null?null:K(h.dismissBanner,{label:u.label}),dismiss:c,expand:p}),[e,u,t,l,d,c,p])}i(id,"useUrgencySurface");function sd(e){return e.isBootstrapping?"loading":e.status==="error"&&e.error&&e.messages.length===0?"error":e.messages.length===0?"empty":"populated"}i(sd,"selectView");function Wb(e){return e.code==="accessDenied"||e.code==="conversationNotFound"}i(Wb,"needsNewConversation");function ad(e){if(e.messages.length===0)return null;let t=e.status==="error"?e.error:null;if(t!==null){let r=Wb(t);return {tone:"error",title:r?h.turnUnreachableTitle:h.turnFailedTitle,body:t.displayMessage,actionLabel:r?h.turnStartNewChat:h.turnRetry,action:r?"startNew":"retry"}}return e.stopped===true?{tone:"neutral",title:h.turnStoppedTitle,body:h.turnStoppedBody,actionLabel:h.turnRetry,action:"retry"}:null}i(ad,"turnNotice");function ld(e,t){let r=e[e.length-1];return t&&(r===void 0||r.role==="user")}i(ld,"awaitingAssistant");function ud(e,t){let r={};return e!==void 0&&(r.petRef=e),t!==void 0&&(r.conversationId=t),r}i(ud,"buildChatOpts");var br=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 pd(e){let t=F(),r=react.useMemo(()=>qb(t),[t]);return jsxRuntime.jsxs(reactNative.View,{style:[r.container,e.style],accessible:true,accessibilityRole:"text",accessibilityLabel:`${br.title}. ${br.body}`,children:[jsxRuntime.jsx(R,{style:r.title,children:br.title}),jsxRuntime.jsx(R,{style:r.body,children:br.body})]})}i(pd,"ClinicalDisclaimer");function qb(e){let{color:t,space:r,type:n}=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:{...S(e,"bold"),fontSize:n.size.caption,lineHeight:Math.round(n.size.caption*n.lineHeight.snug),color:t.text.secondary,letterSpacing:n.letterSpacing.eyebrow},body:{...S(e,"regular"),fontSize:n.size.caption,lineHeight:Math.round(n.size.caption*n.lineHeight.snug),color:t.text.muted}})}i(qb,"makeStyles");var se={pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"};function te(e){return {width:e,height:e,alignItems:"center",justifyContent:"center"}}i(te,"box");function ce(e,t){return t??Math.max(1.5,Math.round(e/11*10)/10)}i(ce,"stroke");function fd({size:e,color:t,strokeWidth:r}){let n=ce(e,r),o={width:e*.82,height:n,borderRadius:n,backgroundColor:t};return jsxRuntime.jsxs(reactNative.View,{style:[te(e),{gap:e*.22}],...se,children:[jsxRuntime.jsx(reactNative.View,{style:o}),jsxRuntime.jsx(reactNative.View,{style:o}),jsxRuntime.jsx(reactNative.View,{style:o})]})}i(fd,"MenuGlyph");function md({size:e,color:t,strokeWidth:r,rotate:n}){let o=ce(e,r),s=e*.78;return jsxRuntime.jsxs(reactNative.View,{style:[te(e),{transform:[{rotate:n}]}],...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:s,height:o,borderRadius:o,backgroundColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:o,height:s,borderRadius:o,backgroundColor:t}})]})}i(md,"Cross");function yd(e){return jsxRuntime.jsx(md,{...e,rotate:"0deg"})}i(yd,"PlusGlyph");function Ct(e){return jsxRuntime.jsx(md,{...e,rotate:"45deg"})}i(Ct,"CloseGlyph");function nt({size:e,color:t,strokeWidth:r}){let n=ce(e,r);return jsxRuntime.jsx(reactNative.View,{style:te(e),...se,children:jsxRuntime.jsx(reactNative.View,{style:{width:e*.36,height:e*.66,marginTop:-e*.14,borderBottomWidth:n,borderRightWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})})}i(nt,"CheckGlyph");var Xb={down:{rotate:"45deg",marginTop:-0.4,marginLeft:0},up:{rotate:"225deg",marginTop:.4,marginLeft:0},right:{rotate:"-45deg",marginTop:0,marginLeft:-0.4}};function hn({size:e,color:t,strokeWidth:r,direction:n}){let o=ce(e,r),s=e*.46,a=Xb[n];return jsxRuntime.jsx(reactNative.View,{style:te(e),...se,children:jsxRuntime.jsx(reactNative.View,{style:{width:s,height:s,borderRightWidth:o,borderBottomWidth:o,borderColor:t,marginTop:s*a.marginTop,marginLeft:s*a.marginLeft,transform:[{rotate:a.rotate}]}})})}i(hn,"ChevronGlyph");function gd({size:e,color:t,strokeWidth:r}){let n=ce(e,r),o={width:e*.42,height:e*.7,borderWidth:n,borderColor:t,borderRadius:n};return jsxRuntime.jsxs(reactNative.View,{style:[te(e),{flexDirection:"row",gap:1}],...se,children:[jsxRuntime.jsx(reactNative.View,{style:[o,{borderTopLeftRadius:e*.2}]}),jsxRuntime.jsx(reactNative.View,{style:[o,{borderTopRightRadius:e*.2}]})]})}i(gd,"BookGlyph");function hd({size:e,color:t,strokeWidth:r}){let n=ce(e,r),o=e*.5;return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:e*.78,height:n,borderRadius:n,backgroundColor:t,transform:[{rotate:"-45deg"}]}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.16,right:e*.16,width:o,height:o,borderTopWidth:n,borderRightWidth:n,borderColor:t}})]})}i(hd,"ArrowUpRightGlyph");function bd({size:e,color:t,strokeWidth:r}){let n=ce(e,r),o=e*.6,s={position:"absolute",width:o,height:o,borderWidth:n,borderColor:t,borderRadius:e*.14};return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,children:[jsxRuntime.jsx(reactNative.View,{style:[s,{top:0,left:0}]}),jsxRuntime.jsx(reactNative.View,{style:[s,{bottom:0,right:0}]})]})}i(bd,"CopyGlyph");function bn({size:e,color:t,strokeWidth:r,active:n,rotate:o}){let s=ce(e,r),a=n?t:"transparent";return jsxRuntime.jsxs(reactNative.View,{style:[te(e),{transform:[{rotate:o}]}],...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.08,left:e*.12,width:e*.62,height:e*.5,borderWidth:s,borderColor:t,backgroundColor:a,borderRadius:e*.12,borderTopLeftRadius:e*.04}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.04,left:e*.4,width:e*.3,height:e*.5,borderWidth:s,borderColor:t,backgroundColor:a,borderRadius:e*.15,transform:[{rotate:"-20deg"}]}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.08,left:0,width:e*.2,height:e*.5,borderWidth:s,borderColor:t,backgroundColor:a,borderRadius:e*.05}})]})}i(bn,"ThumbGlyph");function vd({size:e,color:t,strokeWidth:r}){let n=ce(e,r);return jsxRuntime.jsxs(reactNative.View,{style:[te(e),{borderRadius:e/2,borderWidth:n,borderColor:t}],...se,children:[jsxRuntime.jsx(reactNative.View,{style:{width:n,height:n,borderRadius:n,backgroundColor:t,marginBottom:e*.1}}),jsxRuntime.jsx(reactNative.View,{style:{width:n,height:e*.34,borderRadius:n,backgroundColor:t}})]})}i(vd,"InfoGlyph");function Ed({size:e,color:t,strokeWidth:r}){let n=ce(e,r),o=e*.34;return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.06,width:o,height:o,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.1,width:n,height:e*.56,borderRadius:n,backgroundColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:0,width:e*.84,height:e*.3,borderBottomWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderBottomLeftRadius:n,borderBottomRightRadius:n}})]})}i(Ed,"UploadGlyph");function Cd({size:e,color:t,strokeWidth:r}){let n=ce(e,r);return jsxRuntime.jsxs(reactNative.View,{style:[te(e),{borderWidth:n,borderColor:t,borderRadius:e*.14,overflow:"hidden"}],...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.16,left:e*.18,width:e*.16,height:e*.16,borderRadius:e,backgroundColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:-e*.3,right:-e*.1,width:e*.7,height:e*.7,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}i(Cd,"PhotoGlyph");function Rd({size:e,color:t,strokeWidth:r}){let n=ce(e,r);return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.08,width:e*.34,height:e*.2,borderTopWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderTopLeftRadius:n,borderTopRightRadius:n}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:e*.22,width:e*.92,height:e*.66,borderWidth:n,borderColor:t,borderRadius:e*.16,alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx(reactNative.View,{style:{width:e*.3,height:e*.3,borderRadius:e,borderWidth:n,borderColor:t}})})]})}i(Rd,"CameraGlyph");function Sd({size:e,color:t,strokeWidth:r}){let n=ce(e,r),o=e*.66;return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:0,left:0,width:o,height:o,borderRadius:o,borderWidth:n,borderColor:t}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.02,right:e*.02,width:n,height:e*.4,borderRadius:n,backgroundColor:t,transform:[{rotate:"-45deg"}]}})]})}i(Sd,"SearchGlyph");function Td({size:e,color:t,strokeWidth:r}){let n=ce(e,r);return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",width:e*.3,height:e*.82,borderWidth:n,borderColor:t,borderRadius:n,transform:[{rotate:"45deg"}]}}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:0,left:0,width:e*.4,height:n,borderRadius:n,backgroundColor:t}})]})}i(Td,"EditGlyph");function Pd({size:e,color:t,strokeWidth:r}){let n=ce(e,r),o=e*.62;return jsxRuntime.jsxs(reactNative.View,{style:te(e),...se,children:[jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",top:0,width:o,height:o,borderRadius:o,borderWidth:n,borderColor:t,alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx(reactNative.View,{style:{width:n*1.4,height:n*1.4,borderRadius:n,backgroundColor:t}})}),jsxRuntime.jsx(reactNative.View,{style:{position:"absolute",bottom:e*.04,width:o*.5,height:o*.5,borderRightWidth:n,borderBottomWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}i(Pd,"MapPinGlyph");function kd({size:e,color:t,testID:r}){let n=e*.36;return jsxRuntime.jsx(reactNative.View,{style:te(e),testID:r,...se,children:jsxRuntime.jsx(reactNative.View,{style:{width:0,height:0,marginLeft:e*.12,borderLeftWidth:e*.78,borderTopWidth:n,borderBottomWidth:n,borderLeftColor:t,borderTopColor:"transparent",borderBottomColor:"transparent",transform:[{rotate:"-45deg"}]}})})}i(kd,"SendGlyph");function xd({size:e,color:t,testID:r}){return jsxRuntime.jsx(reactNative.View,{style:te(e),testID:r,...se,children:jsxRuntime.jsx(reactNative.View,{style:{width:e*.5,height:e*.5,backgroundColor:t}})})}i(xd,"StopGlyph");function vn({size:e,strokeWidth:t,color:r,children:n}){return jsxRuntime.jsx(reactNative.View,{style:[te(e),{borderRadius:e/2,borderWidth:t??reactNative.StyleSheet.hairlineWidth,borderColor:r}],children:n})}i(vn,"Ring");var vr=Object.freeze({standard:mt.standard,emphasized:mt.emphasized,exit:mt.exit,outQuad:Object.freeze([.25,.46,.45,.94])});var _d=Object.freeze({layoutMs:220,messageInMs:200,bannerInMs:220,bannerOutMs:160,iconInMs:180,iconOutMs:120,followUpInMs:180,followUpStaggerMs:70,citationsInMs:220,citationsRisePx:6,drawerMs:220,pressScale:.97,pressMs:140,revealTickMs:24,revealDivisor:12,dotsCycleMs:520,dotsMinOpacity:.44,dotsLiftPx:3.5,dotsStagger:Object.freeze([0,.18,.36]),copiedMs:1500,uploadFlashMs:600,reduced:false}),Qb=Object.freeze({..._d,layoutMs:0,messageInMs:0,bannerInMs:0,bannerOutMs:0,iconInMs:0,iconOutMs:0,followUpInMs:0,followUpStaggerMs:0,citationsInMs:0,citationsRisePx:0,drawerMs:0,pressScale:1,pressMs:0,revealTickMs:0,dotsCycleMs:0,dotsMinOpacity:1,dotsLiftPx:0,reduced:true});function wd(e){return e.motion.reducedMotion?Qb:_d}i(wd,"chatMotion");function En(e,t){return Math.max(0,t)*e.followUpStaggerMs}i(En,"followUpDelayMs");function Id(e,t,r){if(e.reduced||t>=r)return r;let n=Math.max(1,Math.ceil((r-t)/e.revealDivisor));return Math.min(r,t+n)}i(Id,"nextRevealLength");function X(){let e=F();return wd(e)}i(X,"useChatMotion");var nv=8;function Od(e,t,r){return ((1-3*r+3*t)*e+(3*r-6*t))*e*e+3*t*e}i(Od,"bezierComponent");function ov(e,t,r){return 3*(1-3*r+3*t)*e*e+2*(3*r-6*t)*e+3*t}i(ov,"bezierSlope");function Cn(e){let[t,r,n,o]=e;return s=>{if(s<=0)return 0;if(s>=1)return 1;let a=s;for(let l=0;l<nv;l+=1){let u=ov(a,t,n);if(u===0)break;a-=(Od(a,t,n)-s)/u;}return Od(Math.min(1,Math.max(0,a)),r,o)}}i(Cn,"bezierEasing");var mi=Cn(vr.standard),iv=Cn(vr.outQuad);function bi(e){let t=react.useRef(null);return t.current===null&&(t.current=new reactNative.Animated.Value(e)),t.current}i(bi,"useAnimatedValue");function Rt(e,t={}){let r=t.risePx??0,n=t.delayMs??0,o=bi(e>0?0:1);return react.useEffect(()=>{if(e<=0)return;let s=reactNative.Animated.timing(o,{toValue:1,duration:e,easing:iv,useNativeDriver:true}),a=n>0?reactNative.Animated.sequence([reactNative.Animated.delay(n),s]):s;return a.start(),()=>a.stop()},[o,e,n]),react.useMemo(()=>({opacity:o,transform:[{translateY:o.interpolate({inputRange:[0,1],outputRange:[r,0]})}]}),[o,r])}i(Rt,"useFadeIn");function vi({visible:e,inMs:t,outMs:r,style:n,children:o}){let[s,a]=react.useState(e),l=bi(e&&t<=0?1:0);return react.useEffect(()=>{if(e){a(true);let d=reactNative.Animated.timing(l,{toValue:1,duration:Math.max(0,t),easing:mi,useNativeDriver:true});return d.start(),()=>d.stop()}if(!s)return;if(r<=0){a(false);return}let u=reactNative.Animated.timing(l,{toValue:0,duration:r,easing:mi,useNativeDriver:true});return u.start(({finished:d})=>{d&&a(false);}),()=>u.stop()},[e,s,t,r,l]),!s&&!e?null:jsxRuntime.jsx(reactNative.Animated.View,{style:[n,{opacity:l}],children:o})}i(vi,"FadePresence");var sv=12;function B({style:e,containerStyle:t,children:r,onPressIn:n,onPressOut:o,hitSlop:s,...a}){let l=X(),u=bi(1),d=react.useCallback(c=>{l.pressMs<=0||l.pressScale===1||reactNative.Animated.timing(u,{toValue:c,duration:l.pressMs,easing:mi,useNativeDriver:true}).start();},[u,l.pressMs,l.pressScale]);return jsxRuntime.jsx(reactNative.Pressable,{...a,hitSlop:s??sv,style:t,onPressIn:c=>{d(l.pressScale),n?.(c);},onPressOut:c=>{d(1),o?.(c);},children:jsxRuntime.jsx(reactNative.Animated.View,{style:[e,{transform:[{scale:u}]}],children:r})})}i(B,"PressScale");function Ld(e,t,r){let n=t&&r.revealTickMs>0,[o,s]=react.useState(0),a=react.useRef(e);return a.current=e,react.useEffect(()=>{if(!n)return;let l=setInterval(()=>{s(u=>Id(r,u,a.current.length));},r.revealTickMs);return ()=>clearInterval(l)},[n,r]),n?e.slice(0,Math.min(o,e.length)):e}i(Ld,"useRevealedText");var Fd=false;function av(e){e.layoutMs<=0||(Fd||(Fd=true,reactNative.Platform.OS==="android"&&typeof reactNative.UIManager.setLayoutAnimationEnabledExperimental=="function"&&reactNative.UIManager.setLayoutAnimationEnabledExperimental(true)),reactNative.LayoutAnimation.configureNext({duration:e.layoutMs,create:{type:"easeInEaseOut",property:"opacity"},update:{type:"easeInEaseOut"},delete:{type:"easeInEaseOut",property:"opacity"}}));}i(av,"animateLayout");function Er(e,t){let r=react.useRef(e);r.current!==e&&(r.current=e,av(t));}i(Er,"useAnimateLayoutOn");var Ei=36,mv=22,yv=12,gv=12,hv=16,bv="#000",vv="rgba(0,0,0,0.45)";function Dd({uri:e,label:t,onClose:r}){let n=F(),o=reactNativeSafeAreaContext.useSafeAreaInsets();return e===null?null:jsxRuntime.jsxs(reactNative.Modal,{visible:true,animationType:n.motion.reducedMotion?"none":"fade",transparent:false,statusBarTranslucent:true,onRequestClose:r,children:[jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:h.closePreview,style:Rn.backdrop,onPress:r,children:jsxRuntime.jsx(reactNative.Image,{source:{uri:e},style:Rn.image,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,accessibilityIgnoresInvertColors:true})}),jsxRuntime.jsx(reactNative.View,{pointerEvents:"box-none",style:[Rn.closeWrap,{top:o.top+gv}],children:jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:h.closePreview,hitSlop:yv,style:Rn.closeButton,onPress:r,children:jsxRuntime.jsx(Ct,{size:mv,color:n.color.surface,strokeWidth:2})})})]})}i(Dd,"AttachmentImageLightbox");var Rn=reactNative.StyleSheet.create({backdrop:{flex:1,backgroundColor:bv,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"},closeWrap:{position:"absolute",right:hv},closeButton:{width:Ei,height:Ei,borderRadius:Ei/2,backgroundColor:vv,alignItems:"center",justifyContent:"center"}});var Sn=12,Tv=80,Ci=44,Nd=22,Pv=.14,kv=18,xv=8,Ud=Object.freeze({photo:h.attachmentPhoto,camera:h.attachmentCamera});function Vd({sources:e,full:t,onPick:r,onClose:n}){let o=F(),s=react.useMemo(()=>_v(o),[o]);return jsxRuntime.jsxs(reactNative.View,{style:s.anchor,pointerEvents:"box-none",children:[jsxRuntime.jsx(reactNative.Pressable,{style:s.dismissLayer,accessibilityRole:"button",accessibilityLabel:h.closeAttachmentPicker,onPress:n}),jsxRuntime.jsxs(reactNative.View,{style:s.bubble,children:[jsxRuntime.jsx(reactNative.View,{style:s.tilesRow,children:e.map(a=>jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:Ud[a],accessibilityState:{disabled:t},disabled:t,containerStyle:s.tile,style:s.tileInner,onPress:()=>r(a),children:[jsxRuntime.jsx(reactNative.View,{style:s.tileIconWrap,children:a==="photo"?jsxRuntime.jsx(Cd,{size:Nd,color:o.color.brandInk,strokeWidth:1.5}):jsxRuntime.jsx(Rd,{size:Nd,color:o.color.brandInk,strokeWidth:1.5})}),jsxRuntime.jsx(R,{tier:"control",style:s.tileLabel,children:Ud[a]})]},a))}),jsxRuntime.jsx(reactNative.View,{style:s.tail}),jsxRuntime.jsx(reactNative.View,{style:s.tailFill})]})]})}i(Vd,"AttachmentPickerPopover");function _v(e){let t=e.color,r=e.radius;return reactNative.StyleSheet.create({anchor:{position:"absolute",left:0,right:0,bottom:"100%",paddingHorizontal:8,paddingBottom:10,alignItems:"flex-start"},dismissLayer:{position:"absolute",left:-1e3,right:-1e3,top:-2e3,bottom:0},bubble:{backgroundColor:t.surfaceCream,borderRadius:r.lg,borderWidth:1,borderColor:t.brandBorderStrong,paddingHorizontal:6,paddingVertical:8,shadowColor:t.shadow,shadowOpacity:Pv,shadowRadius:kv,shadowOffset:{width:0,height:xv},elevation:8},tilesRow:{flexDirection:"row",alignItems:"stretch"},tile:{minWidth:Tv,borderRadius:r.md},tileInner:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:10,paddingVertical:8,gap:6},tileIconWrap:{width:Ci,height:Ci,borderRadius:Ci/2,backgroundColor:t.brandSoft,alignItems:"center",justifyContent:"center"},tileLabel:{...S(e,"medium"),fontSize:12,lineHeight:14,color:t.text.primary},tail:{position:"absolute",left:24,bottom:-Sn/2,width:Sn,height:Sn,backgroundColor:t.surfaceCream,borderRightWidth:1,borderBottomWidth:1,borderColor:t.brandBorderStrong,transform:[{rotate:"45deg"}]},tailFill:{position:"absolute",left:22,bottom:0,width:Sn+4,height:2,backgroundColor:t.surfaceCream}})}i(_v,"makeStyles");var Se=Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});var Bd=56,zd=12,Av=14,Ov=10,Fv=.45,Mv="rgba(7,193,104,0.55)",Lv="rgba(185,28,28,0.55)",Dv=200,Nv=300,Xd=20,Si=22,Uv=12,Vv="rgba(0,0,0,0.78)",jd=220,Wd=100,Gd="rgba(255,255,255,0.15)";function Qd({attachments:e,rejected:t,uploadFailed:r=false,onRetry:n,onRemove:o,onPreview:s}){let a=F(),l=react.useMemo(()=>Jd(a),[a]);return e.length===0&&t===null?null:jsxRuntime.jsxs(reactNative.View,{style:l.strip,children:[e.length>0?jsxRuntime.jsx(reactNative.View,{style:l.cards,children:e.map(u=>jsxRuntime.jsx(Hv,{row:u,styles:l,onRetry:n,onRemove:o,onPreview:s},u.id))}):null,r?jsxRuntime.jsx(R,{style:l.rejected,accessibilityRole:"alert",children:h.attachmentsFailedBlocked}):null,t!==null?jsxRuntime.jsx(R,{style:l.rejected,accessibilityRole:"alert",children:Ou(t)}):null]})}i(Qd,"AttachmentStrip");function Hv({row:e,styles:t,onRetry:r,onRemove:n,onPreview:o}){let s=F(),a=e.status==="uploading",l=e.status==="failed",u=e.status==="uploaded",d=react.useRef(e.status),[c,p]=react.useState(false);return react.useEffect(()=>{let f=d.current;d.current=e.status,e.status==="uploaded"&&f==="uploading"&&p(true);},[e.status]),jsxRuntime.jsxs(reactNative.View,{style:t.card,children:[jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:u?"button":"image",accessibilityLabel:u?K(h.previewAttachment,{filename:e.filename}):e.filename,accessibilityState:{busy:a,disabled:!u},disabled:!u,style:t.thumbHit,onPress:()=>o(e),children:jsxRuntime.jsxs(reactNative.View,{style:t.thumb,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:e.previewUri},style:t.thumbImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true}),a?jsxRuntime.jsx(reactNative.View,{style:t.uploadingOverlay,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:s.color.surface})}):null,c?jsxRuntime.jsx(Bv,{styles:t,onDone:()=>p(false)}):null]})}),l?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:K(h.retryUpload,{filename:e.filename}),style:t.failedOverlay,onPress:()=>r(e.id),children:jsxRuntime.jsx(reactNative.View,{style:t.failedInner,children:jsxRuntime.jsx(Ct,{size:Xd,color:s.color.surface,strokeWidth:2})})}):null,jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:K(h.removeAttachment,{filename:e.filename}),hitSlop:6,containerStyle:t.removeSlot,style:t.removeButton,onPress:()=>n(e.id),children:jsxRuntime.jsx(Ct,{size:Uv,color:s.color.surface,strokeWidth:1.5})})]})}i(Hv,"PreviewCard");function Bv({styles:e,onDone:t}){let r=F(),n=X(),o=react.useRef(null);o.current===null&&(o.current=new reactNative.Animated.Value(0));let s=o.current;return react.useEffect(()=>{let a=reactNative.Animated.sequence([reactNative.Animated.timing(s,{toValue:1,duration:Dv,useNativeDriver:true}),reactNative.Animated.delay(n.uploadFlashMs),reactNative.Animated.timing(s,{toValue:0,duration:Nv,useNativeDriver:true})]);return a.start(({finished:l})=>{l&&t();}),()=>a.stop()},[s,n.uploadFlashMs,t]),jsxRuntime.jsx(reactNative.Animated.View,{pointerEvents:"none",style:[e.successOverlay,{opacity:s}],children:jsxRuntime.jsx(nt,{size:Xd,color:r.color.surface,strokeWidth:2})})}i(Bv,"SuccessFlash");function Zd({images:e,onPreview:t}){let r=F(),n=react.useMemo(()=>Jd(r),[r]);if(e.length===0)return null;let o=e.length===1;return jsxRuntime.jsx(reactNative.View,{style:o?n.sentSingle:n.sentGrid,children:e.map((s,a)=>jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:K(h.attachedImage,{filename:s.filename}),onPress:()=>t(s),children:jsxRuntime.jsx(reactNative.Image,{source:{uri:s.uri},style:o?n.singleImage:n.gridImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true})},`${s.uri}-${a}`))})}i(Zd,"SentImages");function Jd(e){let t=e.color,r=e.type;return reactNative.StyleSheet.create({strip:{gap:6,paddingBottom:8},cards:{flexDirection:"row",flexWrap:"wrap",gap:8},card:{width:Bd,height:Bd,overflow:"visible"},thumbHit:{width:"100%",height:"100%"},thumb:{width:"100%",height:"100%",borderRadius:zd,overflow:"hidden",backgroundColor:t.composerFill,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},thumbImage:{width:"100%",height:"100%"},uploadingOverlay:{...Se,alignItems:"center",justifyContent:"center",backgroundColor:ul(e.color.brandInk,Fv)??e.color.brandSofter},successOverlay:{...Se,alignItems:"center",justifyContent:"center",backgroundColor:Mv},failedOverlay:{...Se,borderRadius:zd,overflow:"hidden"},failedInner:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:Lv},removeSlot:{position:"absolute",top:4,right:4},removeButton:{width:Si,height:Si,borderRadius:Si/2,backgroundColor:Vv,borderWidth:1.5,borderColor:t.surface,alignItems:"center",justifyContent:"center"},rejected:{...S(e,"regular"),fontSize:r.size.caption,lineHeight:r.size.caption*r.lineHeight.normal,color:t.danger},sentSingle:{marginBottom:6},sentGrid:{flexDirection:"row",flexWrap:"wrap",gap:6,marginBottom:6},singleImage:{width:jd,height:jd,borderRadius:Av,backgroundColor:Gd},gridImage:{width:Wd,height:Wd,borderRadius:Ov,backgroundColor:Gd}})}i(Jd,"makeStyles");var zv="chat attachment upload: the file handle has no uri",jv="chat attachment upload failed";function Wv(e){return {uri:e.uri,name:Ro(e.name),type:e.mimeType}}i(Wv,"filePartOf");function ec(e={}){return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(zv));let{signal:o,onProgress:s}=n,a=i(()=>Promise.reject(new Error(jv)),"failed");return o?.aborted===true?a():Hr({url:t.upload_url,fields:t.upload_fields,file:Wv(r),signal:o,fetch:e.fetch}).then(l=>{if(!l)return a();s?.(1);},a)}})}i(ec,"createRnChatAttachmentTransport");function Tn(){let{runtime:e,userRef:t,activePet:r,scopeEpoch:n}=Y(),o=react.useMemo(()=>Je(e.registry.services.authFor(t)),[e,t,n]),[s,a]=react.useState({repository:o,pets:[],loading:true,error:null}),l=s.repository===o?s:{pets:[],loading:true,error:null},u=react.useRef(0),d=react.useCallback(async()=>{let p=++u.current;a(m=>({...m,repository:o,loading:true,error:null,pets:m.repository===o?m.pets:[]}));let f=await o.list();p===u.current&&a(f.ok?{repository:o,pets:f.value,loading:false,error:null}:m=>({repository:o,pets:m.repository===o?m.pets:[],loading:false,error:f.error}));},[o]);react.useEffect(()=>(d(),()=>{u.current+=1;}),[d]);let c=react.useMemo(()=>r===null?null:l.pets.find(p=>p.petRef===r)??null,[r,l.pets]);return react.useMemo(()=>({pets:l.pets,activePet:c,loading:l.loading,error:l.error,refresh:d}),[l.pets,l.loading,l.error,c,d])}i(Tn,"useEverfurPets");function tc(e,t){if(t!==null){let r=e.find(n=>n.petRef===t);if(r!==void 0)return r}return e[0]??null}i(tc,"headerPetOf");function pe(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(pe,"slotBox");function xi(e){return e===void 0||e.backgroundColor!==void 0?e:e.borderRadius===void 0?void 0:{borderRadius:e.borderRadius}}i(xi,"ownGroundSlot");function Ie(e){return e?.textColor===void 0?{}:{color:e.textColor}}i(Ie,"slotText");var rc=Object.freeze({visitButton:"Talk to a vet"});var nc=Symbol.for("@everfur/sdk/televet");function Ke(){let e=globalThis,t=e[nc];if(t!==void 0)return t;let r={presenter:null,snapshot:Object.freeze({request:null,serial:0,activeHost:null}),hosts:[],nextHost:1,listeners:new Set,dailyRegistered:false};return e[nc]=r,r}i(Ke,"televetGlobal");function Pn(e){let t=Ke();t.snapshot=Object.freeze({...t.snapshot,...e});for(let r of [...t.listeners])try{r();}catch{}}i(Pn,"publish");function oc(e){let t=Ke().presenter;if(t===null)return "absent";try{return t(e)===!1?"declined":"presented"}catch(r){return console.warn("[everfur] Your registerEverfurTelevetFlow presenter threw; the in-app visit opened instead.",r),"threw"}}i(oc,"callTelevetPresenter");function ic(e){let t=Ke();return t.listeners.add(e),()=>{t.listeners.delete(e);}}i(ic,"subscribeTelevetExperience");function _i(){return Ke().snapshot}i(_i,"televetExperienceSnapshot");function Yv(){return Ke().hosts.length>0}i(Yv,"hasTelevetHost");function sc(e){if(!Yv())return false;let t=Object.freeze({...e});return Pn({request:t,serial:Ke().snapshot.serial+1}),true}i(sc,"presentTelevetExperience");function wi(){Ke().snapshot.request!==null&&Pn({request:null});}i(wi,"dismissTelevetExperience");function ac(){let e=Ke(),t=e.nextHost;return e.nextHost+=1,e.hosts=[...e.hosts,t],Pn({activeHost:e.hosts[0]??null}),t}i(ac,"claimTelevetHost");function lc(e){let t=Ke();t.hosts=t.hosts.filter(n=>n!==e);let r=t.hosts[0]??null;Pn(r===null?{activeHost:r,request:null}:{activeHost:r});}i(lc,"releaseTelevetHost");var uc=false;function kn(e,t){return t!==void 0?(q(t,e),"onStartInApp"):oc(e)==="presented"?"presenter":sc(e)?"experience":(uc||(uc=true,console.warn("[everfur] A vet visit had nowhere to open: mount <EverfurTelevetHost /> in your EverfurProvider, or pass prefer: 'redirect'.")),null)}i(kn,"openVetVisitInApp");function pc(e){let t=null;return ()=>{if(t!==null)return t;let r=e();return t=r,r.then(void 0,()=>{t===r&&(t=null);}),r}}i(pc,"memoizeTelevetLoader");function fc(e){let[t,r]=react.useState(null);react.useEffect(()=>{let d=ac();return r(d),()=>{lc(d);}},[]);let n=react.useSyncExternalStore(ic,_i,_i),s=t!==null&&n.activeHost===t?n.request:null,[a,l]=react.useState(null),u=s!==null&&a===null;return react.useEffect(()=>{if(!u)return;let d=true;return e().then(c=>{d&&l(()=>c);},c=>{d&&(console.warn("[everfur] The in-app vet visit could not load its screens.",c),wi());}),()=>{d=false;}},[u,e]),s===null||a===null?null:{module:a,request:s,serial:n.serial,dismiss:wi}}i(fc,"useTelevetExperienceHost");var Qv=pc(()=>import('@everfur/sdk/televet/booking'));function Rr(){let e=fc(Qv);if(e===null)return null;let{EverfurTelevetModal:t}=e.module;return jsxRuntime.jsx(t,{request:e.request,onClose:e.dismiss},e.serial)}i(Rr,"EverfurTelevetHost");var Ii=Object.freeze(["visit","join","summary","messages"]);function Ai(e){return typeof e=="string"&&Ii.includes(e)}i(Ai,"isVetVisitIntent");var Jv="/widget/v1/televet/handoffs",eE="/widget/v1/televet/availability",tE="/widget/v1/televet/chat-entry",rE=/^[a-z0-9][a-z0-9_-]{0,39}$/,nE=/^[A-Za-z0-9_-]{22}$/;var mc=32,yc=128,gc=64;function Fi(e){let t=e.httpStatus;switch(e.code){case "sessionRequired":return "sessionRequired";case "authExpired":case "authRejected":return "authRejected";case "sdkUpdateRequired":return "sdkUpdateRequired";case "validationFailed":return "invalidRequest";case "rateLimited":case "quotaExceeded":return "rateLimited";}return t===void 0?e.code==="internalError"?"network":"unknown":t===429?"rateLimited":t===404?"unavailable":t===403?"accessDenied":t===401?"authRejected":t===400||t===422?"invalidRequest":t>=500?"serverError":"unknown"}i(Fi,"vetVisitErrorReasonOf");function hc(e){return E(D("validationFailed",{retryable:false,wireMessage:e}))}i(hc,"invalid");function Oi(e){return E(D("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}i(Oi,"unusable");function oE(e,t){let r={};e!==void 0&&(r.pet_ref=e);let n=t?.returnTo;if(n!=null){if(typeof n!="string"||!rE.test(n))return {ok:false,message:"returnTo must be a registered return destination key"};r.return_to=n;}let o=t?.entry;if(o!=null){if(o!=="chat"||e===void 0)return {ok:false,message:"entry 'chat' needs the pet the chat is about"};r.entry=o;}let s=t?.visitRef,a=t?.intent,l=s!=null;if(l){let u=typeof s=="string"?s.trim():"";if(u.length<1||[...u].length>gc)return {ok:false,message:`visitRef must be 1..${gc} characters`};r.visit_ref=u;}if(a!=null){if(!l)return {ok:false,message:"intent needs the visitRef it opens"};if(!Ai(a))return {ok:false,message:`intent must be one of ${Ii.join(", ")}`};r.intent=a;}return {ok:true,body:r}}i(oE,"handoffBody");function iE(e){if(typeof e!="object"||e===null)return null;let{visit_ref:t,intent:r}=e;return typeof t!="string"||t.length===0||!Ai(r)?null:Object.freeze({visitRef:t,intent:r})}i(iE,"parseVisitEcho");function vc(e){let t=e.funnel??xe({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e.telemetry,n=i(o=>(bc(r,"televet.visit.handoff_failed",{reason:Fi(o)}),E(o)),"failed");return {async createHandoff(o,s){let a;if(o!=null){let b=typeof o=="string"?[...o].length:0;if(b<1||b>yc)return n(D("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${yc} characters`}));a=o;}let l=oE(a,s);if(!l.ok){let b=hc(l.message);return b.ok?b:n(b.error)}let u=l.body,d=await t.send("televet.visit.handoff",{method:"POST",path:Jv,body:u},{idempotent:false,maxAttempts:1});if(!d.ok)return n(d.error);let c=sE(d.value),p=u.return_to!==void 0,f=p?d.value?.flow_id:void 0;if(p&&(typeof f!="string"||!nE.test(f))){let b=Oi("the handoff response carried no usable return flow id");return b.ok?b:n(b.error)}let m=u.visit_ref!==void 0,y=m?iE(d.value?.visit):null;if(m&&y===null){let b=Oi("the handoff response did not confirm the visit it opens");return b.ok?b:n(b.error)}let x=c===null?null:Object.freeze({...c,...p?{flowId:f}:{},...y!==null?{visit:y}:{}});return x===null?n(D("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(bc(r,"televet.visit.handoff_created",{pet_scoped:u.pet_ref!==void 0}),L(x))},async checkAvailability(o){if(typeof o!="string"||o.length>mc)return hc(`state must be at most ${mc} characters`);let s=await t.send("televet.visit.availability",{method:"POST",path:eE,body:{state:o}},{idempotent:false,maxAttempts:1});if(!s.ok)return E(s.error);let a=s.value?.available;return typeof a!="boolean"?Oi("the availability response carried no usable answer"):L(Object.freeze({available:a}))},async chatEntryOpen(){try{let o=await t.send("televet.visit.chat_entry",{method:"GET",path:tE},{maxAttempts:1});return o.ok&&o.value?.open===!0}catch{return false}}}}i(vc,"createVetVisitController");function sE(e){if(typeof e!="object"||e===null)return null;let{url:t,expires_at:r}=e;return typeof t!="string"||typeof r!="string"||r.length===0||!dE(t)?null:Object.freeze({url:t,expiresAt:r})}i(sE,"parseHandoff");var aE=new Set(["localhost","127.0.0.1","[::1]"]),lE=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,uE=/[\s\u0000-\u001f\u007f]/;function dE(e){if(uE.test(e))return false;let t=lE.exec(e);if(t===null)return false;let r=(t[1]??"").toLowerCase(),n=t[2]??"";if(n.length===0||n.includes("@"))return false;let o=n.replace(/:\d+$/,"").toLowerCase(),s=r==="https",a=r==="http"&&aE.has(o);if(!s&&!a)return false;let l=e.indexOf("#");if(l<0)return false;let u=e.slice(l);return u.startsWith("#h=")&&u.length>3}i(dE,"isOpenableVisitUrl");function bc(e,t,r){if(e)try{e.track(t,r);}catch{}}i(bc,"safeTrack");var Mi=Object.freeze({status:"idle",error:null,errorReason:null});function pE(e,t,r){let{usState:n,chat:o,scope:s}=r,a=t&&(n!==null||o),l=`${n??""}|${o?"chat":""}`,[u,d]=react.useState(null);if(react.useEffect(()=>{if(!a)return;let p=true,f=e.current;return d(null),i(async()=>{try{if(o&&!(f.chatEntryOpen&&await f.chatEntryOpen()))return !1;if(n===null)return !0;if(!f.checkAvailability)return !1;let y=await f.checkAvailability(n);return y.ok&&y.value.available}catch{return false}},"ask")().then(y=>{p&&d({key:l,open:y});}),()=>{p=false;}},[a,l,n,o,s,e]),!a)return null;let c=u!==null&&u.key===l;return {open:c&&u.open,pending:!c}}i(pE,"usePreflight");var fE=Object.freeze({status:"opening",error:null,errorReason:null});function Rc(e,t={}){let{runtime:r,userRef:n,scopeEpoch:o}=Y(),s=Nt("televet"),a=s.enabled&&n!==null,l=t.usState??null,u=t.entry==="chat",d=t.petRef??null,c=t.prefer==="redirect",p=react.useMemo(()=>{if(t.controller)return t.controller;let{services:T}=r.registry;return vc({auth:T.authFor(n),telemetry:T.telemetry,...T.errorPolicy?{errorPolicy:T.errorPolicy}:{}})},[r,n,o,t.controller]),f=react.useRef(p);f.current=p;let m=react.useMemo(()=>({runtime:r,userRef:n,scopeEpoch:o}),[r,n,o]),y=pE(f,a,{usState:l,chat:u,scope:m}),x=a&&(y===null||y.open)&&(!u||d!==null),b=t.returnTo??null,[C,_]=react.useState(Mi),P=react.useRef(null),k=react.useRef({runtime:r,userRef:n,scopeEpoch:o});k.current={runtime:r,userRef:n,scopeEpoch:o};let g=react.useRef(p);g.current=p;let w=react.useRef(x);w.current=x;let O=react.useCallback((T,V)=>{if(P.current)return P.current;let j=i((fe,Qe)=>(_({status:fe==="cancelled"?"idle":"error",error:Qe,errorReason:fe==="cancelled"?null:fe}),Object.freeze({opened:false,reason:fe,error:Qe})),"fail");if(!w.current)return Promise.resolve(j("unavailable",null));let W=e.prepare();if(!W.ok)return Promise.resolve(j(W.reason,null));let ne=k.current,he=g.current;_(fE);let st=(async()=>{let fe,Qe={...b!==null?{returnTo:b}:{},...u?{entry:"chat"}:{},...V!==null?{visitRef:V.visitRef}:{},...V!==null&&V.intent!==null&&V.intent!==void 0?{intent:V.intent}:{}},Ir=Object.keys(Qe).length===0?void 0:Qe,Ar=T===void 0?d:T;try{fe=await(Ir===void 0?he.createHandoff(Ar):he.createHandoff(Ar,Ir));}catch{return e.abandon(W.value),j("unknown",null)}let At=k.current;if(At.runtime!==ne.runtime||At.userRef!==ne.userRef||At.scopeEpoch!==ne.scopeEpoch)return e.abandon(W.value),j("cancelled",null);if(!fe.ok)return e.abandon(W.value),j(Fi(fe.error),fe.error);let Yt=await e.finish(W.value,fe.value);return Yt!==null?j(Yt,null):(_(Mi),Object.freeze(fe.value.flowId===void 0?{opened:true}:{opened:true,flowId:fe.value.flowId}))})().finally(()=>{P.current===st&&(P.current=null);});return P.current=st,st},[e,d,b,u]),M=react.useCallback((T,V)=>{if(!w.current)return _({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(Object.freeze({opened:false,reason:"unavailable",error:null}));let j=T===void 0?d:T,W={...j!==null?{petRef:j}:{},...l!==null?{usState:l}:{},...V!==null?{visitRef:V.visitRef,intent:V.intent}:{}};return kn(W)===null?(_({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(Object.freeze({opened:false,reason:"unavailable",error:null}))):(_(Mi),Promise.resolve(Object.freeze({opened:true})))},[d,l]),I=react.useCallback(T=>c?O(T,null):M(T,null),[c,O,M]),v=react.useCallback((T,V)=>c?O(void 0,{visitRef:T,intent:V??null}):M(void 0,{visitRef:T,intent:V??null}),[c,O,M]);return {available:x,isPending:s.isPending||(y?.pending??false),status:C.status,error:C.error,errorReason:C.errorReason,open:I,openVisit:v}}i(Rc,"useVetVisitWith");var gE=i(e=>reactNative.Linking.openURL(e),"defaultOpenUrl");function _n(e={}){let{openUrl:t,...r}=e,n=react.useMemo(()=>{let o=t??gE;return {prepare:i(()=>({ok:true,value:null}),"prepare"),async finish(s,a){try{return await o(a.url),null}catch{return "openFailed"}},abandon:i(()=>{},"abandon")}},[t]);return Rc(n,r)}i(_n,"useVetVisit");var Sc=44,CE=.6;function jt(e){let{petRef:t,label:r,openUrl:n,onOpened:o,onError:s,style:a,labelStyle:l,controller:u,returnTo:d,usState:c,entry:p,visitRef:f,intent:m,onStartInApp:y,prefer:x}=e,b=x==="redirect",C=_n({...d!==void 0?{returnTo:d}:{},...c!==void 0?{usState:c}:{},...p!==void 0?{entry:p}:{},...t!==void 0?{petRef:t}:{},...n!==void 0?{openUrl:n}:{},...u!==void 0?{controller:u}:{},prefer:b?"redirect":"in-app"}),_=F(),P=react.useMemo(()=>RE(_),[_]),k=react.useRef(false);if(!C.available)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[null,jsxRuntime.jsx(Rr,{})]});let g=C.status==="opening",w=r??rc.visitButton;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactNative.Pressable,{onPress:i(()=>{if(!(g||k.current)){if(!b){let M={...t!==void 0?{petRef:t}:{},...c!==void 0?{usState:c}:{},...f!=null?{visitRef:f,intent:m??null}:{}};kn(M,y)===null&&q(s,"unavailable",null);return}k.current=true,(f==null?C.open():C.openVisit(f,m??null)).then(M=>{M.opened?q(o,M.flowId??null):M.reason!=="cancelled"&&q(s,M.reason,M.error);}).finally(()=>{k.current=false;});}},"onPress"),accessibilityRole:"button",accessibilityLabel:w,accessibilityState:{busy:g,disabled:g},style:[P.button,g?P.busy:null,a],children:jsxRuntime.jsx(R,{style:[P.label,l],children:w})}),jsxRuntime.jsx(Rr,{})]})}i(jt,"VetVisitButton");function RE(e){let{color:t,space:r,radius:n,type:o,slots:s}=e;return reactNative.StyleSheet.create({button:{minHeight:Sc,minWidth:Sc,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.primary,...pe(s.vetVisitButton)},busy:{opacity:CE},label:{...S(e,"medium"),color:t.onPrimary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.snug,...Ie(s.vetVisitButton)}})}i(RE,"makeStyles");function Li(e){return ur(e)==="cat"?"cat":"dog"}i(Li,"speciesOf");function Di(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:Math.floor(e)}i(Di,"petAgeYears");function xc(e){let t=Di(e.ageYears),r=Li(e.species)==="cat"?"Cat":"Dog";if(t==null)return r;let n=t===1?"1 yr":`${t} yrs`;return `${r} \xB7 ${n}`}i(xc,"formatPetMeta");var kc=Object.freeze([Object.freeze({background:"#ffbdbd",foreground:"#6d1d14"}),Object.freeze({background:"#a0c4f6",foreground:"#0b3a73"}),Object.freeze({background:"#fbc558",foreground:"#10462e"}),Object.freeze({background:"#bde7c5",foreground:"#0e3b22"}),Object.freeze({background:"#dcc7f4",foreground:"#3a1d6a"}),Object.freeze({background:"#ffd8a8",foreground:"#5a2a04"})]);function SE(e){let t=0;for(let r=0;r<e.length;r+=1)t=t*31+e.charCodeAt(r)>>>0;return kc[t%kc.length]}i(SE,"pickInitialsPalette");function Ni(e){let t=(e??"").trim();return (Array.from(t)[0]??"?").toUpperCase()}i(Ni,"getInitial");function _c(e){return {...SE(e.petRef),initial:Ni(e.name)}}i(_c,"petInitials");function xE(e){return Math.max(12,Math.round(e*.42))}i(xE,"letterSize");function Tr({pet:e,size:t,ringStroke:r}){let n=F(),o=react.useMemo(()=>_E(n),[n]),s=t-r*2,a=e===null?null:_c(e),l=xE(s);return jsxRuntime.jsx(vn,{size:t,strokeWidth:r,color:n.color.success,children:jsxRuntime.jsx(reactNative.View,{style:[o.disc,{width:s,height:s,borderRadius:s/2},a===null?o.discEmpty:{backgroundColor:a.background}],children:jsxRuntime.jsx(R,{tier:"badge",style:[o.letter,{fontSize:l,lineHeight:Math.round(l*1.2),color:a===null?n.color.text.muted:a.foreground}],children:a===null?Ni(null):a.initial})})})}i(Tr,"PetDisc");function _E(e){return reactNative.StyleSheet.create({disc:{alignItems:"center",justifyContent:"center",overflow:"hidden"},discEmpty:{backgroundColor:e.color.brandSoft},letter:{...S(e,"bold"),textAlign:"center",includeFontPadding:false}})}i(_E,"makeStyles");var Vi=48,Ac=2,ME=320,LE="80%",DE="rgba(17,17,17,0.45)",NE=18,wc=22,UE=12,Ic=.4,VE=44;function Hi(e){return e?.name?.trim()||h.yourPet}i(Hi,"petDisplayName");function Oc({visible:e,pets:t,activePetRef:r,onSelect:n,onAddPet:o=null,onClose:s}){let a=F(),l=react.useMemo(()=>HE(a),[a]);return e?jsxRuntime.jsx(reactNative.Modal,{visible:true,transparent:true,animationType:a.motion.reducedMotion?"none":"fade",onRequestClose:s,children:jsxRuntime.jsxs(reactNative.View,{style:l.root,children:[jsxRuntime.jsx(reactNative.Pressable,{style:Se,onPress:s,accessibilityRole:"button",accessibilityLabel:h.close,children:jsxRuntime.jsx(reactNative.View,{style:l.backdrop})}),jsxRuntime.jsxs(reactNative.View,{style:l.panel,accessibilityViewIsModal:true,children:[jsxRuntime.jsx(R,{tier:"heading",style:l.title,accessibilityRole:"header",children:h.yourPets}),jsxRuntime.jsx(reactNative.ScrollView,{style:l.list,contentContainerStyle:l.listContent,showsVerticalScrollIndicator:true,children:t.map(u=>{let d=u.petRef===r,c=Hi(u),p=xc(u);return jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:K(d?h.petCurrentlyActive:h.switchToPet,{name:c}),accessibilityState:{selected:d},style:[l.row,d?l.rowActive:null],onPress:()=>n(u.petRef),children:[jsxRuntime.jsx(Tr,{pet:u,size:Vi,ringStroke:Ac}),jsxRuntime.jsxs(reactNative.View,{style:l.copy,children:[jsxRuntime.jsx(R,{style:l.name,numberOfLines:1,children:c}),jsxRuntime.jsx(R,{tier:"compact",style:l.meta,numberOfLines:1,children:d?`${h.activePrefix}${p}`:p})]}),d?jsxRuntime.jsx(nt,{size:NE,color:a.color.brandInk}):null]},u.petRef)})}),o!==null?jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:h.addAnotherPet,style:l.addRow,onPress:o,children:[jsxRuntime.jsx(reactNative.View,{style:l.addDisc,children:jsxRuntime.jsx(R,{tier:"control",style:l.addPlus,children:"+"})}),jsxRuntime.jsx(R,{style:l.addLabel,children:h.addAnotherPet})]}):null,jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:h.close,containerStyle:l.closeSlot,style:l.closeButton,onPress:s,children:jsxRuntime.jsx(R,{tier:"control",style:l.closeText,children:h.close})})]})]})}):null}i(Oc,"PetSwitcherSheet");function HE(e){let t=e.color,r=e.radius;return reactNative.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{flex:1,backgroundColor:DE},panel:{backgroundColor:t.surface,paddingHorizontal:20,paddingTop:20,paddingBottom:32,borderTopLeftRadius:wc,borderTopRightRadius:wc,gap:14,maxHeight:LE},title:{...S(e,"bold"),fontSize:18,lineHeight:22,color:t.brandInk},list:{maxHeight:ME,flexShrink:1},listContent:{gap:10},addRow:{flexDirection:"row",alignItems:"center",gap:12,minHeight:VE,paddingHorizontal:8},addDisc:{width:Vi,height:Vi,borderRadius:r.pill,alignItems:"center",justifyContent:"center",borderWidth:Ac,borderStyle:"dashed",borderColor:t.brandBorder,backgroundColor:t.surfaceCream},addPlus:{...S(e,"bold"),fontSize:20,lineHeight:22,color:t.brandInk},addLabel:{...S(e,"bold"),fontSize:15,lineHeight:20,color:t.text.primary},row:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:r.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface},rowActive:{borderColor:t.brandInk,backgroundColor:t.brandSoft},copy:{flex:1,gap:2},name:{...S(e,"bold"),fontSize:15,lineHeight:18,color:t.text.primary},meta:{...S(e,"monoBold"),fontSize:11,lineHeight:13,color:t.text.muted,textTransform:"uppercase",letterSpacing:Ic},closeSlot:{alignSelf:"flex-end"},closeButton:{paddingHorizontal:18,paddingVertical:10,borderRadius:UE,backgroundColor:t.brandSoft},closeText:{...S(e,"bold"),color:t.brandInk,fontSize:13,lineHeight:16,letterSpacing:Ic}})}i(HE,"makeStyles");var jE=44,In=36,WE=22,Bi=9,GE=1.5,Mc=6,Tt=35,An=1.75,zi=12.4,KE=.5,qE=8,$E=28,YE=160;function Wi(e,t){return tc(e,t)}i(Wi,"headerPet");function Dc({pets:e,petRef:t,historyUnread:r,onOpenHistory:n,onPetChange:o,onAddPet:s,vet:a}){let l=F(),u=react.useMemo(()=>QE(l),[l]),[d,c]=react.useState(false),p=Wi(e.pets,t),f=e.pets.length>=2,m=t??p?.petRef??null,y=Hi(p),x=i(C=>{c(false),e.setActivePet(C),q(o,C);},"select"),b=s===void 0?null:()=>{c(false),q(s);};return jsxRuntime.jsxs(reactNative.View,{style:u.row,children:[jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:r?h.openMenuUnread:h.openMenu,containerStyle:u.iconSlot,style:u.iconButton,onPress:n,children:[jsxRuntime.jsx(fd,{size:WE,color:l.color.text.primary,strokeWidth:2}),r?jsxRuntime.jsx(reactNative.View,{style:u.unreadDot,pointerEvents:"none"}):null]}),jsxRuntime.jsx(reactNative.View,{style:u.center,pointerEvents:"box-none",children:jsxRuntime.jsx(XE,{logoUrl:l.meta.logoUrl,name:l.meta.displayName,styles:u})}),m===null?null:jsxRuntime.jsx(jt,{entry:"chat",petRef:m,...a?.returnTo!==void 0?{returnTo:a.returnTo}:{},...a?.usState!==void 0?{usState:a.usState}:{},...a?.prefer!==void 0?{prefer:a.prefer}:{},style:u.vetEntry,labelStyle:u.vetEntryLabel}),jsxRuntime.jsx(reactNative.View,{style:u.right,children:f?jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:K(h.switchActivePet,{name:y}),containerStyle:u.avatarSlot,style:u.avatarWrap,onPress:()=>c(true),children:[jsxRuntime.jsx(Tr,{pet:p,size:Tt,ringStroke:An}),jsxRuntime.jsx(reactNative.View,{style:u.addBadge,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:jsxRuntime.jsx(yd,{size:qE,color:l.color.brandInk,strokeWidth:2})})]}):e.loading&&p===null?jsxRuntime.jsx(reactNative.View,{style:u.avatarWrap,accessible:true,accessibilityLabel:h.yourPet,children:jsxRuntime.jsx(vn,{size:Tt,strokeWidth:An,color:l.color.success,children:jsxRuntime.jsx(reactNative.View,{style:u.placeholderDisc})})}):jsxRuntime.jsx(reactNative.View,{style:u.avatarWrap,accessible:true,accessibilityRole:"image",accessibilityLabel:p===null?h.yourPet:y,children:jsxRuntime.jsx(Tr,{pet:p,size:Tt,ringStroke:An})})}),jsxRuntime.jsx(Oc,{visible:d,pets:e.pets,activePetRef:p?.petRef??null,onSelect:x,onAddPet:b,onClose:()=>c(false)})]})}i(Dc,"ChatHeader");function XE({logoUrl:e,name:t,styles:r}){let[n,o]=react.useState(null);return e===null||n===e?null:jsxRuntime.jsx(reactNative.View,{style:r.logoBar,children:jsxRuntime.jsx(reactNative.Image,{source:{uri:e},style:r.logo,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,onError:()=>o(e)})})}i(XE,"BrandLogo");function QE(e){let t=e.color,r=Tt-An*2;return reactNative.StyleSheet.create({vetEntry:{minHeight:jE,justifyContent:"center",paddingHorizontal:12,borderRadius:e.radius.pill,backgroundColor:t.surfaceCream,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},vetEntryLabel:{...S(e,"bold"),color:t.brandInk,fontSize:e.type.size.caption},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingVertical:10,backgroundColor:t.surface},iconSlot:{borderRadius:In/2},iconButton:{width:In,height:In,borderRadius:In/2,alignItems:"center",justifyContent:"center"},unreadDot:{position:"absolute",top:Mc,right:Mc,width:Bi,height:Bi,borderRadius:Bi,backgroundColor:t.danger,borderWidth:GE,borderColor:t.surface},center:{...Se,alignItems:"center",justifyContent:"center"},logoBar:{alignItems:"center",paddingHorizontal:e.space.lg},logo:{height:$E,width:YE},right:{alignItems:"flex-end"},avatarSlot:{borderRadius:Tt/2},avatarWrap:{width:Tt,height:Tt,position:"relative"},placeholderDisc:{width:r,height:r,borderRadius:r/2,backgroundColor:t.brandSoft},addBadge:{position:"absolute",bottom:0,right:0,width:zi,height:zi,borderRadius:zi/2,borderWidth:KE,borderColor:t.success,backgroundColor:t.surface,alignItems:"center",justifyContent:"center"}})}i(QE,"makeStyles");var Vc=44,rC="rgba(17,17,17,0.55)",Hc=26,nC=36,Bc=4,Gi=20,Ki=38,oC=18,iC=12;function zc({visible:e,onSubmit:t,onSkip:r}){let n=F(),o=react.useMemo(()=>sC(n),[n]),[s,a]=react.useState(null),[l,u]=react.useState(""),[d,c]=react.useState(false),[p,f]=react.useState(false),m=i(()=>{a(null),u(""),c(false),f(false);},"reset"),y=i(()=>{d||(m(),r());},"skip"),x=i(async()=>{if(d)return;c(true),f(false);let C=l.trim();await t(s,C.length>0?C:null)?m():(c(false),f(true));},"submit");if(!e)return null;let b=[...l].length>Mt;return jsxRuntime.jsx(reactNative.Modal,{visible:true,transparent:true,animationType:n.motion.reducedMotion?"none":"slide",onRequestClose:y,children:jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{behavior:reactNative.Platform.OS==="ios"?"padding":void 0,style:o.root,children:[jsxRuntime.jsx(reactNative.Pressable,{style:o.scrim,onPress:y,accessibilityRole:"button",accessibilityLabel:h.feedbackSkipA11y}),jsxRuntime.jsxs(reactNative.View,{style:o.sheet,accessibilityViewIsModal:true,accessibilityLiveRegion:"polite",children:[jsxRuntime.jsx(reactNative.View,{style:o.handle}),jsxRuntime.jsxs(reactNative.View,{style:o.header,children:[jsxRuntime.jsx(reactNative.View,{style:o.iconBadge,children:jsxRuntime.jsx(bn,{size:oC,color:n.color.brandInk,active:false,rotate:"180deg"})}),jsxRuntime.jsxs(reactNative.View,{style:o.headerText,children:[jsxRuntime.jsx(R,{tier:"heading",style:o.title,accessibilityRole:"header",children:h.feedbackTitle}),jsxRuntime.jsx(R,{style:o.subtitle,children:h.feedbackSubtitle})]})]}),jsxRuntime.jsx(reactNative.View,{style:o.options,children:ri.map(C=>{let _=s===C.key;return jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:C.label,accessibilityState:{selected:_},style:[o.option,_?o.optionSelected:null],onPress:()=>a(P=>P===C.key?null:C.key),children:[jsxRuntime.jsx(R,{style:[o.optionLabel,_?o.optionLabelSelected:null],children:C.label}),jsxRuntime.jsx(reactNative.View,{style:[o.radio,_?o.radioSelected:null],children:_?jsxRuntime.jsx(nt,{size:iC,color:n.color.surface,strokeWidth:2}):null})]},C.key)})}),jsxRuntime.jsxs(reactNative.View,{style:o.inputWrap,children:[jsxRuntime.jsx(Ut,{style:o.input,placeholder:h.feedbackNotesPlaceholder,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:h.feedbackNotesPlaceholder,value:l,onChangeText:u,multiline:true,editable:!d}),l.length>0?jsxRuntime.jsx(R,{tier:"compact",style:[o.counter,b?o.counterOver:null],children:`${[...l].length}/${Mt}`}):null]}),p?jsxRuntime.jsx(R,{style:o.failed,accessibilityRole:"alert",children:h.feedbackFailed}):null,jsxRuntime.jsxs(reactNative.View,{style:o.actions,children:[jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:h.feedbackSubmit,accessibilityState:{busy:d,disabled:d||b},disabled:d||b,style:[o.submit,d||b?o.submitDisabled:null],onPress:()=>{x();},children:jsxRuntime.jsx(R,{tier:"control",style:o.submitLabel,children:h.feedbackSubmit})}),jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:h.feedbackSkipA11y,hitSlop:8,onPress:y,style:o.skip,children:jsxRuntime.jsx(R,{tier:"control",style:o.skipLabel,children:h.feedbackSkip})})]})]})]})})}i(zc,"FeedbackReasons");function sC(e){let t=e.color,r=e.type,n=e.radius,o=e.slots;return reactNative.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},scrim:{...Se,backgroundColor:rC},sheet:{backgroundColor:t.surface,borderTopLeftRadius:Hc,borderTopRightRadius:Hc,paddingHorizontal:22,paddingTop:12,paddingBottom:34,gap:14},handle:{alignSelf:"center",width:nC,height:Bc,borderRadius:Bc/2,backgroundColor:t.brandBorder,marginBottom:2},header:{flexDirection:"row",alignItems:"center",gap:12},iconBadge:{width:Ki,height:Ki,borderRadius:Ki/2,alignItems:"center",justifyContent:"center",backgroundColor:t.brandSoft},headerText:{flex:1,gap:2},title:{...S(e,"bold"),fontSize:20,lineHeight:28,color:t.text.primary,letterSpacing:r.letterSpacing.tight},subtitle:{...S(e,"regular"),fontSize:r.size.body,lineHeight:r.size.body*r.lineHeight.relaxed,color:t.text.muted},options:{gap:8},option:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:14,paddingVertical:13,borderRadius:n.md,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder,backgroundColor:t.surface},optionSelected:{borderColor:t.brandInk,backgroundColor:t.brandSoft},optionLabel:{...S(e,"medium"),fontSize:r.size.body,color:t.text.primary},optionLabelSelected:{color:t.brandInk},radio:{width:Gi,height:Gi,borderRadius:Gi/2,borderWidth:2,borderColor:t.brandBorderStrong,alignItems:"center",justifyContent:"center"},radioSelected:{borderColor:t.brandInk,backgroundColor:t.brandInk},inputWrap:{gap:4},input:{minHeight:72,maxHeight:132,borderRadius:n.md,borderWidth:1,borderColor:t.brandBorderStrong,paddingHorizontal:14,paddingTop:12,paddingBottom:12,...S(e,"regular"),fontSize:r.size.body,color:t.text.primary,textAlignVertical:"top"},counter:{...S(e,"mono"),alignSelf:"flex-end",fontSize:r.size.caption,letterSpacing:.3,color:t.text.placeholder},counterOver:{color:t.danger},failed:{...S(e,"regular"),fontSize:r.size.caption,lineHeight:r.size.caption*r.lineHeight.normal,color:t.danger},actions:{gap:10,alignItems:"center"},submit:{alignSelf:"stretch",minHeight:Vc,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.xl,borderRadius:n.pill,backgroundColor:t.brand,...pe(o.primaryButton)},submitDisabled:{opacity:.6},submitLabel:{...S(e,"medium"),fontSize:r.size.body,color:t.onPrimary,...Ie(o.primaryButton)},skip:{minHeight:Vc,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},skipLabel:{...S(e,"medium"),fontSize:r.size.body,color:t.text.muted}})}i(sC,"makeStyles");var CC=.88,RC=420,SC=58,TC="rgba(17,17,17,0.28)",PC=.08,kC=.1,xC=.08,_C=.18,wC=.78,IC=.7,qi=36,AC=10,OC=14,FC=12,MC=16,LC=14,$i=8,DC=1.5,NC=.5,UC=Cn(vr.standard);function VC(e){return Math.min(Math.round(e*CC),RC)}i(VC,"drawerPanelWidth");function jc({chat:e,history:t}){let[r,n]=react.useState(t.open),o=react.useCallback(()=>n(false),[]);return t.open&&!r&&n(true),r?jsxRuntime.jsx(HC,{chat:e,history:t,onHidden:o}):null}i(jc,"HistoryDrawer");function HC({chat:e,history:t,onHidden:r}){let n=F(),o=react.useMemo(()=>zC(n),[n]),s=X(),a=reactNativeSafeAreaContext.useSafeAreaInsets(),{width:l}=reactNative.useWindowDimensions(),u=VC(l),d=t.open,c=react.useRef(null);c.current===null&&(c.current=new reactNative.Animated.Value(s.drawerMs<=0&&d?1:0));let p=c.current;react.useEffect(()=>{if(!d&&s.drawerMs<=0){r();return}let C=reactNative.Animated.timing(p,{toValue:d?1:0,duration:s.drawerMs,easing:UC,useNativeDriver:true});return C.start(({finished:_})=>{_&&!d&&r();}),()=>C.stop()},[d,p,s.drawerMs,r]);let f=p.interpolate({inputRange:[0,1],outputRange:[-u,0]}),m=t.filtered,y=t.rows.length===0,x=y&&t.loading?jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,accessibilityLabel:Z.loading,accessibilityState:{busy:true},children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{color:n.color.onPrimary}),jsxRuntime.jsx(R,{style:o.emptyBody,children:Z.loading})]}):y&&t.error!==null?jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,children:[jsxRuntime.jsx(R,{style:o.emptyTitle,accessibilityRole:"alert",children:Z.loadFailed}),jsxRuntime.jsx(R,{style:o.emptyBody,children:t.error}),jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:Z.retryA11y,containerStyle:o.retrySlot,style:o.retryButton,onPress:()=>{t.load();},children:jsxRuntime.jsx(R,{tier:"control",style:o.retryText,children:Z.retry})})]}):jsxRuntime.jsxs(reactNative.View,{style:o.emptyCard,children:[jsxRuntime.jsx(R,{style:o.emptyTitle,children:t.emptyKind==="empty"?Z.empty:Z.noMatch}),jsxRuntime.jsx(R,{style:o.emptyBody,children:t.emptyKind==="empty"?Z.emptyBody:Z.noMatchBody})]}),b=!t.searching&&t.loadingMore?jsxRuntime.jsx(reactNative.View,{style:o.loadMoreFooter,children:jsxRuntime.jsx(R,{style:o.loadMoreLabel,children:Z.loadingMore})}):null;return jsxRuntime.jsx(reactNative.Modal,{visible:true,transparent:true,animationType:"none",onRequestClose:t.close,children:jsxRuntime.jsxs(reactNative.View,{style:o.root,children:[jsxRuntime.jsx(reactNative.Pressable,{style:Se,onPress:t.close,accessibilityRole:"button",accessibilityLabel:Z.closeA11y,children:jsxRuntime.jsx(reactNative.Animated.View,{style:[o.backdrop,{opacity:p}]})}),jsxRuntime.jsx(reactNative.Animated.View,{style:[o.panel,{width:u,paddingTop:Math.max(SC,a.top+n.space.md),transform:[{translateX:f}]}],accessibilityViewIsModal:true,children:jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{style:o.keyboardAvoider,behavior:reactNative.Platform.OS==="ios"?"padding":"height",children:[jsxRuntime.jsxs(reactNative.View,{style:o.searchRow,children:[jsxRuntime.jsxs(reactNative.View,{style:o.searchPill,children:[jsxRuntime.jsx(Sd,{size:LC,color:n.color.text.muted,strokeWidth:1.5}),jsxRuntime.jsx(Ut,{value:t.query,onChangeText:C=>t.setQuery(C.replace(/^\s+/,"")),style:o.searchInput,placeholder:Z.search,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:Z.search,autoCorrect:false,autoCapitalize:"none",returnKeyType:"search"})]}),jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:Z.newConversation,style:o.newButton,onPress:t.newConversation,children:jsxRuntime.jsx(Td,{size:MC,color:n.color.text.primary,strokeWidth:1.5})})]}),jsxRuntime.jsx(R,{tier:"heading",style:o.heading,accessibilityRole:"header",children:Z.heading}),t.error!==null&&!y?jsxRuntime.jsx(reactNative.View,{style:o.errorCard,children:jsxRuntime.jsx(R,{style:o.errorText,accessibilityRole:"alert",children:t.error})}):null,jsxRuntime.jsx(reactNative.FlatList,{data:m,keyExtractor:C=>C.id,renderItem:({item:C})=>jsxRuntime.jsx(BC,{row:C,active:C.id===e.conversationId,disabled:t.loading,styles:o,onPress:()=>{t.resume(C.id);}}),contentContainerStyle:m.length===0?o.listEmpty:o.list,keyboardShouldPersistTaps:"handled",ListEmptyComponent:x,ListFooterComponent:b,onEndReached:t.loadMore,onEndReachedThreshold:NC})]})})]})})}i(HC,"DrawerModal");function BC({row:e,active:t,disabled:r,styles:n,onPress:o}){let s=e.unreadCount!==null&&e.unreadCount>0;return jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:ed(e),accessibilityState:{selected:t,disabled:r},disabled:r,style:[n.item,t?n.itemActive:null],onPress:o,children:jsxRuntime.jsxs(reactNative.View,{style:n.itemRow,children:[jsxRuntime.jsx(R,{style:[n.itemTitle,s?n.itemTitleUnread:null],numberOfLines:1,children:mn(e.title)}),s?jsxRuntime.jsx(reactNative.View,{style:n.unreadDot}):null]})})}i(BC,"Row");function Mn(e,t){if(!/^#[0-9a-f]{6}$/i.test(e))return "transparent";let r=Math.round(Math.min(1,Math.max(0,t))*255);return `${e}${r.toString(16).padStart(2,"0").toUpperCase()}`}i(Mn,"inkWash");function zC(e){let t=e.color,r=e.slots,n=t.onPrimary;return reactNative.StyleSheet.create({root:{flex:1},backdrop:{flex:1,backgroundColor:TC},panel:{position:"absolute",left:0,top:0,bottom:0,backgroundColor:t.brand,paddingHorizontal:16,borderRightWidth:.5,borderRightColor:t.brandBorder,gap:12},keyboardAvoider:{flex:1,gap:12},searchRow:{flexDirection:"row",alignItems:"center",gap:10},searchPill:{flex:1,flexDirection:"row",alignItems:"center",gap:8,borderRadius:e.radius.pill,backgroundColor:t.surface,paddingHorizontal:14,paddingVertical:10,borderWidth:1,borderColor:Mn(n,kC)},searchInput:{...S(e,"regular"),flex:1,fontSize:13,lineHeight:16,color:t.text.primary,padding:0},newButton:{width:qi,height:qi,borderRadius:qi/2,alignItems:"center",justifyContent:"center",backgroundColor:t.surface},heading:{...S(e,"bold"),fontSize:14,lineHeight:17,color:n,marginTop:4},list:{gap:10,paddingBottom:28},listEmpty:{flexGrow:1},item:{paddingVertical:12,paddingHorizontal:4,borderRadius:AC},itemActive:{backgroundColor:Mn(n,PC)},itemRow:{flexDirection:"row",alignItems:"center",gap:8},itemTitle:{...S(e,"regular"),flex:1,fontSize:14,lineHeight:18,color:n},itemTitleUnread:S(e,"bold"),unreadDot:{width:$i,height:$i,borderRadius:$i/2,backgroundColor:t.danger,borderWidth:DC,borderColor:n},errorCard:{borderRadius:FC,borderWidth:.5,borderColor:t.danger,backgroundColor:t.surface,padding:12},errorText:{...S(e,"regular"),fontSize:11,lineHeight:16,color:t.danger},emptyCard:{borderRadius:OC,padding:14,gap:6,backgroundColor:Mn(n,xC),borderWidth:.5,borderColor:Mn(n,_C)},emptyTitle:{...S(e,"bold"),fontSize:12,lineHeight:15,color:n},emptyBody:{...S(e,"regular"),fontSize:11,lineHeight:17,color:n,opacity:wC},retrySlot:{marginTop:8,alignSelf:"flex-start"},retryButton:{borderRadius:e.radius.pill,paddingHorizontal:14,paddingVertical:7,borderWidth:1,borderColor:n,...pe(r.primaryButton)},retryText:{...S(e,"bold"),fontSize:12,lineHeight:15,color:n,...Ie(r.primaryButton)},loadMoreFooter:{paddingVertical:14,alignItems:"center"},loadMoreLabel:{...S(e,"regular"),fontSize:11,lineHeight:14,color:n,opacity:IC}})}i(zC,"makeStyles");var $C=Object.freeze({}),YC=100,XC=20;function QC(e,t,r,n){return ![e,t,r,n].every(Number.isFinite)||e+r>n+1?null:{chatTop:Math.max(0,e),parentTop:Math.max(0,e-t)}}i(QC,"readWindowTops");function Wc(e,t){let r=typeof e=="number"&&Number.isFinite(e),n=react.useRef(null),[o,s]=react.useState(null),a=react.useRef(null),l=react.useRef(null),u=react.useRef(true),d=react.useCallback(()=>{l.current!==null&&clearTimeout(l.current),l.current=null;},[]);react.useEffect(()=>(u.current=true,()=>{u.current=false,d();}),[d]);let c=react.useCallback(i(function f(m){n.current?.measureInWindow((y,x)=>{let b=a.current;if(!u.current||b===null)return;let C=QC(x,b.y,b.height,reactNative.Dimensions.get("window").height);if(C!==null){s(_=>_!==null&&_.chatTop===C.chatTop&&_.parentTop===C.parentTop?_:C);return}m>=XC||(l.current=setTimeout(()=>{l.current=null,f(m+1);},YC));});},"measureAt"),[]),p=react.useCallback(f=>{let{y:m,height:y}=f.nativeEvent.layout;a.current={y:m,height:y},d(),c(0);},[c,d]);return react.useMemo(()=>{if(!t)return {avoidingProps:r?{keyboardVerticalOffset:e}:$C,probeRef:null,topInWindow:null};let f=o?.parentTop??0;return {avoidingProps:r?{keyboardVerticalOffset:e,onLayout:p}:f>0?{keyboardVerticalOffset:f,onLayout:p}:{onLayout:p},probeRef:n,topInWindow:o?.chatTop??null}},[t,r,e,o,p])}i(Wc,"useChatKeyboardOffset");function Gc({probeRef:e}){return e===null?null:jsxRuntime.jsx(reactNative.View,{ref:e,collapsable:false,pointerEvents:"none",style:ZC})}i(Gc,"KeyboardOffsetProbe");var ZC=Object.freeze({position:"absolute",top:0,left:0,width:0,height:0});function Kc(e,t){let r={entry:"chat",petRef:e};return t?.returnTo!==void 0&&(r.returnTo=t.returnTo),t?.usState!==void 0&&(r.usState=t.usState),t?.prefer!==void 0&&(r.prefer=t.prefer),r}i(Kc,"chatVetVisitOptions");var nR=16,oR=.75,Xi=12,qc=15,iR=18,Dn=22,sR=14,aR=8,lR=20,uR=10,dR=13;function Yc({surface:e,petRef:t,renderVetAction:r,onFindVet:n,vet:o}){let s=F(),a=react.useMemo(()=>cR(s),[s]),l=X(),u=e.tier,d=e.source;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(vi,{visible:e.showBanner&&u!==null,inMs:l.bannerInMs,outMs:l.bannerOutMs,style:a.pinned,children:u!==null&&d!==null?jsxRuntime.jsxs(reactNative.View,{accessibilityRole:"alert",style:[a.card,{borderColor:u.borderColor,backgroundColor:u.backgroundColor}],children:[jsxRuntime.jsx(R,{tier:"compact",style:[a.label,{color:u.textColor}],children:u.label}),d.reason!==null?jsxRuntime.jsx(R,{style:[a.reason,{color:u.reasonColor}],children:d.reason}):null,e.showVetAction?r!==void 0?jsxRuntime.jsx(Et,{render:()=>r(u.level),fallback:jsxRuntime.jsx($c,{tier:u,petRef:t,onFindVet:n,vet:o,styles:a}),resetKey:u.level}):jsxRuntime.jsx($c,{tier:u,petRef:t,onFindVet:n,vet:o,styles:a}):null,e.dismissLabel!==null?jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:e.dismissLabel,hitSlop:aR,containerStyle:a.closeSlot,style:a.closeButton,onPress:e.dismiss,children:jsxRuntime.jsx(Ct,{size:sR,color:u.textColor,strokeWidth:1.5})}):null]}):null}),jsxRuntime.jsx(vi,{visible:e.showCompactIcon,inMs:l.iconInMs,outMs:l.iconOutMs,style:a.indicatorRow,children:jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:h.showLatestVetAlert,hitSlop:uR,onPress:e.expand,children:jsxRuntime.jsx(vd,{size:lR,color:s.color.text.muted,strokeWidth:2})})})]})}i(Yc,"UrgencyBanner");function $c({tier:e,petRef:t,onFindVet:r,vet:n,styles:o}){let s=F(),a=_n(Kc(t,n)),l=a.status==="opening",u=a.available?()=>{a.open();}:r!==void 0?()=>{q(r,e.level);}:null;if(u===null)return null;let d=xi(s.slots.vetVisitButton)?.textColor??e.textColor;return jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:h.findVetA11y,accessibilityState:{busy:l},containerStyle:o.findVetSlot,style:[o.findVetButton,{borderColor:e.borderColor,backgroundColor:e.pillColor},o.findVetSlotBox,l?o.findVetBusy:null],onPress:u,children:[jsxRuntime.jsx(Pd,{size:dR,color:d,strokeWidth:1.5}),jsxRuntime.jsx(R,{tier:"control",style:[o.findVetLabel,{color:d}],children:h.findVet})]})}i($c,"VetAction");function cR(e){let t=xi(e.slots.vetVisitButton);return reactNative.StyleSheet.create({pinned:{marginTop:0,marginBottom:4,paddingHorizontal:e.space.lg},card:{borderRadius:nR,borderWidth:oR,paddingHorizontal:14,paddingVertical:8,gap:2},label:{...S(e,"monoBold"),fontSize:Xi,lineHeight:qc},reason:{...S(e,"regular"),fontSize:Xi,lineHeight:iR,paddingRight:Dn},findVetSlot:{alignSelf:"flex-start",marginTop:6},findVetButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:e.radius.pill,borderWidth:1},findVetSlotBox:{...pe(t,1)},findVetBusy:{opacity:.6},findVetLabel:{...S(e,"monoBold"),fontSize:Xi,lineHeight:qc},closeSlot:{position:"absolute",top:6,right:6},closeButton:{width:Dn,height:Dn,borderRadius:Dn/2,alignItems:"center",justifyContent:"center"},indicatorRow:{alignItems:"flex-end",paddingHorizontal:16,paddingTop:2,paddingBottom:4}})}i(cR,"makeStyles");function Xc(){let e=Tn(),{handle:t}=Y(),r=react.useCallback(n=>t.setActivePet(n),[t]);return react.useMemo(()=>({...e,setActivePet:r}),[e,r])}i(Xc,"useChatPets");var op=300,ip=3e3,Zc=120,Gt=44,gR=120,hR="86%",Jc=15,ep=22,Nn=.5,bR=.04,vR=8,ER=2,CR=1,RR=.6,SR=22,TR=48,tp=1.25,PR=14,kR=18,xR=6,_R=14,wR=.04,IR=12,AR=2,OR=2,rp=36,FR=20,Wt=36,Kt=(Gt-Wt)/2,sp=24,ap=22,MR=.4,Un=30,lp=20,LR=.4,DR=480,NR=8,np=14,UR=10,VR=14,HR=12,BR=13,zR=18,jR="12%";function Ee(){let e=F(),t=react.useMemo(()=>WR(e),[e]);return {theme:e,styles:t}}i(Ee,"useChatTheme");function WR(e){let t=e.color,r=e.space,n=e.radius,o=e.type,s=e.slots;return reactNative.StyleSheet.create({container:{flex:1,minHeight:Zc,backgroundColor:t.chatGround},body:{flex:1},centered:{minHeight:Zc,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl},emptyContent:{flexGrow:1,alignItems:"center",justifyContent:"flex-start",paddingTop:jR,paddingHorizontal:r.lg,paddingBottom:r.lg,minHeight:DR,gap:18},errorText:{...S(e,"regular"),fontSize:o.size.subtitle,lineHeight:o.size.subtitle*o.lineHeight.snug,color:t.danger,textAlign:"center",marginBottom:r.md},retryButton:{minHeight:Gt,minWidth:Gt,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.brand,...pe(s.primaryButton)},retryLabel:{...S(e,"medium"),color:t.onPrimary,fontSize:o.size.body,...Ie(s.primaryButton)},setupNotice:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm,paddingHorizontal:r.lg,paddingVertical:r.sm,backgroundColor:t.surfaceCream},setupNoticeText:{...S(e,"regular"),color:t.danger,fontSize:o.size.caption,flexShrink:1},turnNotice:{gap:r.xs,padding:r.md,borderRadius:n.lg,backgroundColor:t.surfaceCream,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder,alignItems:"flex-start"},turnNoticeError:{borderColor:t.danger},turnNoticeTitle:{...S(e,"bold"),color:t.text.primary,fontSize:o.size.body},turnNoticeTitleError:{color:t.danger},turnNoticeBody:{...S(e,"regular"),color:t.text.secondary,fontSize:o.size.caption,lineHeight:o.size.caption*o.lineHeight.normal},turnNoticeAction:{minHeight:Gt,justifyContent:"center"},turnNoticeActionLabel:{...S(e,"medium"),color:t.brandInk,fontSize:o.size.body},setupNoticeAction:{...S(e,"medium"),color:t.brandInk,fontSize:o.size.caption},reconnectingCaption:{...S(e,"medium"),color:t.text.secondary,fontSize:o.size.caption,lineHeight:o.size.caption*o.lineHeight.normal,textTransform:"uppercase",letterSpacing:.5},list:{flex:1},listContent:{padding:r.lg,gap:r.md},rowBlock:{gap:r.sm},rowBlockUser:{},rowBlockAssistant:{paddingRight:r.xl},row:{flexDirection:"row"},rowUser:{justifyContent:"flex-end"},rowAssistant:{justifyContent:"flex-start"},bubble:{maxWidth:hR},bubbleUser:{padding:Jc,backgroundColor:t.bubbleUser,borderRadius:n.xl,borderBottomRightRadius:n.sm,borderWidth:Nn,borderColor:t.accentEdge,shadowColor:t.brand,shadowOpacity:bR,shadowRadius:vR,shadowOffset:{width:0,height:ER},elevation:CR,...pe(s.userBubble,Nn)},bubbleAssistant:s.assistantBubble?.backgroundColor===void 0?{...pe(s.assistantBubble,Nn)}:{padding:Jc,borderRadius:n.xl,...pe(s.assistantBubble,Nn)},bubblePending:{opacity:RR},bubbleTextUser:{...S(e,"medium"),color:t.onPrimary,fontSize:o.size.body,lineHeight:ep,...Ie(s.userBubble)},bubbleTextAssistant:{...S(e,"medium"),color:t.text.primary,fontSize:o.size.body,lineHeight:ep,...Ie(s.assistantBubble)},bubbleBold:S(e,"bold"),bubbleItalic:{fontStyle:"italic"},bubbleCode:S(e,"mono"),followUps:{alignSelf:"stretch",marginTop:r.sm,gap:NR},followUpSlot:{alignSelf:"stretch",borderRadius:np},followUpRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:HR,paddingVertical:UR,paddingHorizontal:VR,borderRadius:np,backgroundColor:t.brandSoft},followUpText:{...S(e,"medium"),flex:1,color:t.text.primary,fontSize:BR,lineHeight:zR},composerOuter:{position:"relative"},composer:{marginHorizontal:r.md,marginTop:r.xs,marginBottom:r.sm,minHeight:TR,justifyContent:"center",paddingLeft:PR,paddingRight:kR,paddingVertical:xR,backgroundColor:t.composerFill,borderWidth:tp,borderColor:t.composerBorder,borderRadius:SR,shadowColor:t.shadow,shadowOpacity:wR,shadowRadius:IR,shadowOffset:{width:0,height:AR},elevation:OR,...pe(s.composerInput,tp)},composerRow:{flexDirection:"row",alignItems:"center",gap:_R,minHeight:rp},attachControl:{width:Un,height:Un,alignItems:"center",justifyContent:"center"},attachControlDisabled:{opacity:LR},input:{flex:1,minHeight:rp,maxHeight:gR,paddingHorizontal:0,paddingVertical:0,...S(e,"regular"),fontSize:o.size.body,lineHeight:FR,color:t.text.primary,...Ie(s.composerInput)},sendControl:{minHeight:Wt,minWidth:Wt,alignItems:"center",justifyContent:"center"},sendDisc:{width:Wt,height:Wt,borderRadius:Wt/2,alignItems:"center",justifyContent:"center",...pe(s.sendButton)},sendControlDisabled:{opacity:MR},poweredBy:{...S(e,"regular"),color:t.text.muted,fontSize:o.size.micro,textAlign:"center",paddingBottom:r.xs}})}i(WR,"makeStyles");var GR=Object.freeze({kind:"live"}),KR=Object.freeze({kind:"folded"});function Zi(e){if(e.role!=="assistant"||e.checkin===void 0)return null;let t=e.checkin.caseId,r=mo(e.proactiveOriginRef);return {caseId:t,dueDay:r!==null&&r.caseId===t?r.dueDay:""}}i(Zi,"askOf");function dp(e){let t=new Map,r=new Map;for(let o of e){let s=Zi(o);if(s===null)continue;let a=r.get(s.caseId);(a===void 0||s.dueDay>=a.dueDay)&&r.set(s.caseId,{messageId:o.id,dueDay:s.dueDay});}if(r.size===0)return t;let n=null;for(let o of e){let s=Zi(o);if(s===null){n=null;continue}if(r.get(s.caseId)?.messageId===o.id){t.set(o.id,GR),n=null;continue}if(n!==null&&n.caseId===s.caseId){n.days.push(s.dueDay),t.set(o.id,KR);continue}let a=[s.dueDay];n={id:o.id,caseId:s.caseId,days:a},t.set(o.id,{kind:"past",runDueDays:a});}return t}i(dp,"placeCheckins");var up=864e5,qR=365;function Vn(e,t){if(typeof e!="string"||typeof t!="string")return null;let r=Date.parse(e),n=Date.parse(t);if(Number.isNaN(r)||Number.isNaN(n))return null;let o=Math.floor(n/up)-Math.floor(r/up);return o<1||o>qR?null:o}i(Vn,"checkinDayNumber");function cp(e){return Zi(e)?.dueDay||null}i(cp,"checkinDueDay");var Te=Object.freeze({eyebrow:"Checking in",logged:"Logged",findVet:"Find a vet now",day:"Day {day}",daySeparator:" \xB7 ",answers:Object.freeze({better:"Better",same:"Same",worse:"Worse"})}),pp=Object.freeze(Wr.map(e=>Object.freeze({answer:e,label:Te.answers[e]})));function fp(e,t){let[r,n]=react.useState(null),[o,s]=react.useState(null),[a,l]=react.useState(null),u=react.useCallback(c=>{t!==null&&(n(c),s(null),t(e.caseId,c).then(p=>{n(null),p.ok?l(c):s(p.error);}));},[t,e.caseId]),d=a??e.answer;return {answer:d,answerable:!ha(e),escalated:d==="worse",pending:r,error:o,choose:u}}i(fp,"useCheckinCard");var gp=44,XR=.6;function bp({message:e,checkin:t,onAnswer:r,petRef:n,onFindVet:o,vet:s,onLayout:a}){let l=F(),u=react.useMemo(()=>QR(l),[l]),d=fp(t,r),c=d.answer!==null||d.pending!==null,p=r!==null&&d.answerable,f=Vn(t.openedAt,cp(e));return jsxRuntime.jsxs(reactNative.View,{style:u.card,accessibilityLabel:Te.eyebrow,onLayout:a,children:[jsxRuntime.jsxs(reactNative.View,{style:u.head,children:[jsxRuntime.jsx(R,{tier:"compact",style:u.eyebrow,children:Te.eyebrow}),f!==null?jsxRuntime.jsx(R,{tier:"compact",style:u.headDay,children:K(Te.day,{day:f})}):null]}),jsxRuntime.jsx(R,{style:u.question,accessibilityRole:"text",children:e.text}),p?jsxRuntime.jsx(reactNative.View,{style:[u.row,d.pending?u.rowPending:null],children:pp.map(({answer:m,label:y})=>{let x=(d.pending??d.answer)===m;return jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>d.choose(m),disabled:c,accessibilityRole:"button",accessibilityLabel:y,accessibilityState:{selected:x,disabled:c,busy:d.pending===m},style:[u.pill,x?u.pillSelected:null],children:jsxRuntime.jsx(R,{tier:"control",style:[u.pillLabel,x?u.pillLabelSelected:null],children:y})},m)})}):null,d.answer!==null?jsxRuntime.jsx(R,{style:u.logged,children:Te.logged}):null,d.escalated?o!==void 0?jsxRuntime.jsx(reactNative.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:Te.findVet,style:u.findVet,children:jsxRuntime.jsx(R,{tier:"control",style:u.findVetLabel,children:Te.findVet})}):n?jsxRuntime.jsx(jt,{entry:"chat",petRef:n,label:Te.findVet,...s?.returnTo!==void 0?{returnTo:s.returnTo}:{},...s?.usState!==void 0?{usState:s.usState}:{},...s?.prefer!==void 0?{prefer:s.prefer}:{},style:u.findVet,labelStyle:u.findVetLabel}):null:null,t.resolutionText?jsxRuntime.jsx(R,{style:u.resolution,children:t.resolutionText}):null,d.error?jsxRuntime.jsx(R,{style:u.error,accessibilityRole:"alert",children:d.error.displayMessage}):null]})}i(bp,"CheckinCard");function QR(e){let t=e.color,r=e.space,n=e.radius,o=e.type;return reactNative.StyleSheet.create({card:{maxWidth:"92%",padding:r.md,gap:r.sm,borderRadius:n.lg,backgroundColor:t.brandSoft,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},head:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},eyebrow:{...S(e,"regular"),color:t.text.secondary,fontSize:o.size.caption,letterSpacing:o.letterSpacing.eyebrow,textTransform:"uppercase"},headDay:{...S(e,"bold"),color:t.text.primary,fontSize:o.size.caption,letterSpacing:o.letterSpacing.eyebrow,textTransform:"uppercase"},question:{...S(e,"regular"),color:t.text.primary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.normal},row:{flexDirection:"row",gap:r.sm,marginTop:r.xs},rowPending:{opacity:XR},pill:{flex:1,minHeight:gp,alignItems:"center",justifyContent:"center",paddingHorizontal:r.md,borderRadius:n.pill,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface},pillSelected:{backgroundColor:t.brand,borderColor:t.brand},pillLabel:{...S(e,"regular"),color:t.text.primary,fontSize:o.size.body},pillLabelSelected:{color:t.onPrimary},logged:{...S(e,"regular"),color:t.text.secondary,fontSize:o.size.caption},resolution:{...S(e,"regular"),color:t.text.primary,fontSize:o.size.body,lineHeight:o.size.body*o.lineHeight.normal},error:{...S(e,"regular"),color:t.danger,fontSize:o.size.caption},findVet:{alignSelf:"stretch",minHeight:gp,alignItems:"center",justifyContent:"center",borderRadius:n.pill,borderWidth:1.5,borderColor:t.brandBorder,backgroundColor:t.surface},findVetLabel:{...S(e,"bold"),color:t.brandInk,fontSize:o.size.body}})}i(QR,"makeStyles");var eS=1.5,tS=3;function Ep({text:e,runDueDays:t,openedAt:r,onLayout:n}){let o=F(),s=react.useMemo(()=>rS(o),[o]),a=t.map(u=>Vn(r,u)).filter(u=>u!==null),l=t.length>1;return l&&a.length===0?null:jsxRuntime.jsxs(reactNative.View,{style:s.row,onLayout:n,children:[jsxRuntime.jsx(reactNative.View,{style:s.rule,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"}),jsxRuntime.jsxs(reactNative.View,{style:s.body,children:[a.length>0?jsxRuntime.jsx(R,{tier:"compact",style:s.days,children:a.map(u=>K(Te.day,{day:u})).join(Te.daySeparator)}):null,l?null:jsxRuntime.jsx(R,{style:s.question,accessibilityRole:"text",children:e})]})]})}i(Ep,"CheckinPastAsk");function rS(e){let t=e.color,r=e.space,n=e.type;return reactNative.StyleSheet.create({row:{flexDirection:"row",paddingVertical:r.xs},rule:{width:eS,borderRadius:1,backgroundColor:t.borderHairlineGreen,marginRight:r.md},body:{flex:1,gap:tS},days:{...S(e,"monoMedium"),fontSize:n.size.nano,letterSpacing:n.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase"},question:{...S(e,"regular"),fontSize:n.size.bodyTight,lineHeight:n.size.bodyTight*n.lineHeight.normal,color:t.text.muted}})}i(rS,"makeStyles");var nS=Object.freeze({TIER_1:"#07C168",TIER_2:"#27A9FF",TIER_3:"#FBC558"}),Cp="#C8BEB4";function oS(e){return e?nS[e.toUpperCase()]??Cp:Cp}i(oS,"tierColor");function iS(e){if(!e)return null;let t=/^tier[_\s-]?(\d+)$/i.exec(e.trim());return t?`Tier ${t[1]}`:e}i(iS,"tierLabel");function He(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}i(He,"text");function sS(e){let t=He(e);return t!==null&&/^https:\/\/\S+$/i.test(t)?t:null}i(sS,"httpsUrl");function aS(e,t){let r=He(e.source_name)??He(e.sourceName),n=He(e.section),o=He(e.authority_tier)??He(e.authorityTier),s=iS(o),a=r??He(e.title)??`Source ${t+1}`,l=He(e.monograph_chunk_id)??He(e.chunkId),u=[n,s].filter(d=>d!==null).join(" \xB7 ");return Object.freeze({title:a,sourceName:r,section:n,authorityTier:o,tierLabel:s,meta:u.length===0?null:u,url:sS(e.url),excerpt:He(e.excerpt),tierColor:oS(o),key:`${a}-${l??"none"}-${t}`})}i(aS,"toCitationCard");function Rp(e){return e===void 0||e.length===0?lS:Object.freeze(e.map((t,r)=>aS(t,r)))}i(Rp,"toCitationCards");var lS=Object.freeze([]);function ns(e){return e===1?`1 ${h.sourceSingular}`:`${e} ${h.sourcePlural}`}i(ns,"sourcesLabel");function Sp(e,t){return `${t?h.hideSources:h.showSources} ${ns(e)}`}i(Sp,"sourcesToggleLabel");function Tp(e){return [e.url!==null?`${h.openSource}: ${e.title}`:e.title,e.meta,e.excerpt].filter(t=>t!==null&&t.length>0).join(". ")}i(Tp,"citationA11yLabel");var fS=244,kp=8,xp=13,mS=14,yS=.3,gS=-0.24,hS=22,bS=10,vS=15;function _p({citations:e,onOpenUrl:t}){let r=F(),n=react.useMemo(()=>RS(r),[r]),o=react.useMemo(()=>Rp(e),[e]),[s,a]=react.useState(false);if(o.length===0)return null;let l=o.length;return jsxRuntime.jsxs(reactNative.View,{style:n.block,children:[jsxRuntime.jsxs(B,{accessibilityRole:"button",accessibilityLabel:Sp(l,s),accessibilityState:{expanded:s},containerStyle:n.toggleSlot,style:n.togglePill,onPress:()=>a(u=>!u),children:[jsxRuntime.jsx(gd,{size:xp,color:r.color.brandInk,strokeWidth:1.5}),jsxRuntime.jsx(R,{tier:"compact",style:n.toggleLabel,children:ns(l)}),jsxRuntime.jsx(hn,{size:xp,color:r.color.brandInk,strokeWidth:1.5,direction:s?"up":"down"})]}),s?jsxRuntime.jsx(ES,{cards:o,styles:n,open:t}):null]})}i(_p,"CitationCards");function ES({cards:e,styles:t,open:r}){let n=X(),o=Rt(n.citationsInMs,{risePx:n.citationsRisePx});return jsxRuntime.jsx(reactNative.Animated.View,{style:o,children:jsxRuntime.jsx(reactNative.ScrollView,{horizontal:true,nestedScrollEnabled:true,showsHorizontalScrollIndicator:false,contentContainerStyle:t.row,children:e.map(s=>jsxRuntime.jsx(CS,{card:s,styles:t,open:r},s.key))})})}i(ES,"Deck");function CS({card:e,styles:t,open:r}){let n=F(),o=e.url!==null&&r!==void 0,s=Tp(o?e:{...e,url:null}),a=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(reactNative.View,{style:t.cardHeader,children:[jsxRuntime.jsx(reactNative.View,{style:[t.tierDot,{backgroundColor:e.tierColor}]}),jsxRuntime.jsx(R,{style:[t.cardTitle,o?t.cardTitleLink:null],numberOfLines:2,children:e.title}),o?jsxRuntime.jsx(hd,{size:mS,color:n.color.linkInk,strokeWidth:1.5}):null]}),e.meta!==null?jsxRuntime.jsx(R,{tier:"compact",style:t.cardMeta,numberOfLines:1,children:e.meta}):null,e.excerpt!==null?jsxRuntime.jsx(R,{style:t.cardExcerpt,numberOfLines:3,children:e.excerpt}):null]});if(e.url!==null&&r!==void 0){let l=e.url;return jsxRuntime.jsx(B,{accessibilityRole:"link",accessibilityLabel:s,style:t.card,onPress:()=>r(l),children:a})}return jsxRuntime.jsx(reactNative.View,{accessible:true,accessibilityRole:"text",accessibilityLabel:s,style:t.card,children:a})}i(CS,"Card");function RS(e){let t=e.color,r=e.space,n=e.radius,o=e.type.size;return reactNative.StyleSheet.create({block:{gap:r.sm},toggleSlot:{alignSelf:"flex-start",borderRadius:n.pill},togglePill:{flexDirection:"row",alignItems:"center",gap:r.xs+2,paddingHorizontal:r.md,paddingVertical:r.xs+2,borderRadius:n.pill,backgroundColor:t.brandSoft},toggleLabel:{...S(e,"monoBold"),fontSize:o.micro,lineHeight:o.micro,letterSpacing:yS,color:t.brandInk,textTransform:"uppercase"},row:{gap:r.sm,paddingRight:r.xl,paddingTop:r.xs},card:{width:fS,borderRadius:n.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,padding:r.md,gap:r.xs+2},cardHeader:{flexDirection:"row",alignItems:"center",gap:r.sm},tierDot:{width:kp,height:kp,borderRadius:n.pill},cardTitle:{...S(e,"bold"),flex:1,fontSize:o.bodyTight,lineHeight:hS,color:t.text.primary,letterSpacing:gS},cardTitleLink:{color:t.linkInk},cardMeta:{...S(e,"monoMedium"),fontSize:o.nano,lineHeight:bS,letterSpacing:e.type.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase"},cardExcerpt:{...S(e,"regular"),fontSize:o.tiny,lineHeight:vS,color:t.text.muted}})}i(RS,"makeStyles");function wp(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}i(wp,"formatMessageTime");var xr=15,_S=15,wS=6,IS=Object.freeze({up:"0deg",neutral:"270deg",down:"180deg"});function Mp({message:e,onCopy:t,sentiment:r=null,onSentiment:n,thanks:o=false}){let s=F(),a=react.useMemo(()=>AS(s),[s]),l=X(),u=e.role==="user",d=react.useMemo(()=>wp(e.createdAt),[e.createdAt]),c=t!==void 0&&e.text.length>0,p=!u&&n!==void 0&&e.responseId!==void 0,[f,m]=react.useState(false),y=react.useRef(null);react.useEffect(()=>()=>{y.current&&clearTimeout(y.current);},[]);let x=i(()=>{t!==void 0&&(Ht(t,e.text),m(true),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{m(false),y.current=null;},l.copiedMs));},"copy");return d===null&&!c&&!p?null:jsxRuntime.jsxs(reactNative.View,{style:a.wrap,children:[jsxRuntime.jsxs(reactNative.View,{style:[a.row,u?a.rowUser:a.rowAssistant],children:[d!==null?jsxRuntime.jsx(R,{tier:"compact",style:a.timestamp,children:d}):null,c?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:f?h.copied:u?h.copyUserMessage:h.copyAssistantMessage,hitSlop:_S,onPress:x,style:a.iconHit,children:f?jsxRuntime.jsx(nt,{size:xr,color:s.color.success,strokeWidth:2}):jsxRuntime.jsx(bd,{size:xr,color:s.color.text.timestamp,strokeWidth:1.5})}):null,p?xu.map(({sentiment:b,label:C})=>jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:C,accessibilityState:{selected:r===b},hitSlop:wS,onPress:()=>n?.(b),style:a.iconHit,children:jsxRuntime.jsx(bn,{size:xr,color:s.color.sentiment[b],active:r===b,rotate:IS[b],strokeWidth:1.5})},b)):null]}),o?jsxRuntime.jsx(R,{style:a.thanks,accessibilityLiveRegion:"polite",children:h.feedbackThanks}):null]})}i(Mp,"MessageFooter");function AS(e){let t=e.type;return reactNative.StyleSheet.create({wrap:{gap:4},row:{flexDirection:"row",alignItems:"center",gap:10,paddingTop:6},rowAssistant:{alignSelf:"flex-start"},rowUser:{alignSelf:"flex-end"},timestamp:{...S(e,"monoMedium"),fontSize:t.size.nano,lineHeight:t.size.nano+2,color:e.color.text.timestamp,textAlign:"center"},iconHit:{width:xr,height:xr,alignItems:"center",justifyContent:"center"},thanks:{...S(e,"regular"),fontSize:t.size.caption,lineHeight:t.size.caption*t.lineHeight.normal,color:e.color.text.secondary}})}i(AS,"makeStyles");var Lp="#10462E",Dp="#000000",OS="#83E0B4",FS=Object.freeze([Object.freeze({id:"breed-health-miss",intent:"send",label:"What {breed} health issue do owners miss most?",fallbackLabel:"What {species} health issue do owners miss most?",background:"#A0C4F6",borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),Object.freeze({id:"attention-at-age",intent:"send",label:"What changes should I expect at {ageYears} years old?",fallbackLabel:"What changes should I expect as my {species} ages?",background:OS,borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),Object.freeze({id:"early-pain-signs",intent:"send",label:"What are early signs of pain?",background:"#FBC558",borderColor:Lp,brandEdge:true,borderWidth:1}),Object.freeze({id:"vet-prep",intent:"vet_report",label:"Help me prep for {petName}\u2019s vet visit.",background:"#FFBDBD",borderColor:"#6D1D14",borderWidth:1.25})]),MS=/\s*-\s*(?:small|medium|large|giant|toy)\s*$/i;function LS(e){return e==null?e:e.replace(MS,"").trim()}i(LS,"formatBreedForPrompt");var DS=new Set(["","?","-","--",".","n/a","na","none","null","nil","unknown","unspecified","unsure","not sure","not specified","not applicable","no idea","dunno","idk","tbd","other","i dont know","i don't know","dont know","don't know","do not know","i do not know","not known","no clue"]);function NS(e){let t=String(e??"").replace(/\s+/gu," ").trim().toLowerCase().replace(/\u2019/g,"'");return DS.has(t)}i(NS,"isUninformativeBreed");function US(e){return e==="cat"?"Domestic Short Hair Mix":"Mixed Breed"}i(US,"unspecifiedBreedLabel");function VS(e,t){return NS(e)?US(t):String(e).replace(/\s+/gu," ").trim()}i(VS,"resolveBreedLabel");function Np(e){let t=e?.name?.trim()||h.emptyTitlePetFallback;return K(h.emptyTitle,{petName:t})}i(Np,"emptyStateTitle");function Up(e,t=Lp){let r=Li(e?.species),n=r==="cat"?"my cat":"my dog",o=e?.name?.trim()||null,s=o||n,a=VS(LS(e?.breed),r)||null,l=Di(e?.ageYears),u=l===null?null:String(l);return Object.freeze(FS.map(d=>{let c=d.label.includes("{breed}"),p=d.label.includes("{ageYears}"),m=d.fallbackLabel!==void 0&&(c&&!a||p&&!u)&&d.fallbackLabel?d.fallbackLabel:d.label,y=K(m,{petName:s,breed:a??n,species:r,ageYears:u??""}),x=!o&&m.startsWith("{petName}")?y.charAt(0).toUpperCase()+y.slice(1):y;return Object.freeze({id:d.id,intent:d.intent,label:x,background:d.background,borderColor:d.brandEdge===true?t:d.borderColor,borderWidth:d.borderWidth})}))}i(Up,"resolveQuickPrompts");var BS=36,Bp=4,zS=340;function zp({pet:e,petRef:t,onSend:r,onVetPrep:n,vet:o}){let s=F(),a=react.useMemo(()=>WS(s),[s]),l=react.useMemo(()=>Up(e,s.color.brandInk),[e,s.color.brandInk]),u=Np(e);return jsxRuntime.jsxs(reactNative.View,{style:a.block,children:[jsxRuntime.jsx(R,{tier:"heading",style:a.title,accessibilityRole:"header",children:u}),jsxRuntime.jsx(reactNative.View,{style:a.list,children:l.map((d,c)=>jsxRuntime.jsx(jS,{prompt:d,index:c,petRef:t,onSend:r,onVetPrep:n,vet:o,pet:e,styles:a},d.id))})]})}i(zp,"QuickPrompts");function jS({prompt:e,index:t,pet:r,petRef:n,onSend:o,onVetPrep:s,vet:a,styles:l}){let u=X(),d=Rt(u.followUpInMs,{delayMs:En(u,t)}),c={backgroundColor:e.background,borderColor:e.borderColor,borderWidth:e.borderWidth};return e.intent==="vet_report"?s!==void 0?jsxRuntime.jsx(reactNative.Animated.View,{style:d,children:jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:Bp,style:[l.chip,c],onPress:()=>{q(s,r);},children:jsxRuntime.jsx(R,{tier:"compact",style:l.chipLabel,children:e.label})})}):n===null?null:jsxRuntime.jsx(reactNative.Animated.View,{style:d,children:jsxRuntime.jsx(jt,{entry:"chat",petRef:n,label:e.label,...a?.returnTo!==void 0?{returnTo:a.returnTo}:{},...a?.usState!==void 0?{usState:a.usState}:{},...a?.prefer!==void 0?{prefer:a.prefer}:{},style:[l.chip,c],labelStyle:l.chipLabel})}):jsxRuntime.jsx(reactNative.Animated.View,{style:d,children:jsxRuntime.jsx(B,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:Bp,style:[l.chip,c],onPress:()=>o(e.label),children:jsxRuntime.jsx(R,{tier:"compact",style:l.chipLabel,children:e.label})})})}i(jS,"Chip");function WS(e){let t=e.color;return reactNative.StyleSheet.create({block:{gap:18,alignItems:"center",width:"100%"},title:{...S(e,"bold"),fontSize:28,lineHeight:34,color:t.text.primary,letterSpacing:-0.8,textAlign:"center",maxWidth:zS},list:{width:"100%",gap:12,alignItems:"center"},chip:{borderRadius:e.radius.pill,paddingHorizontal:14,paddingVertical:9,minHeight:BS,minWidth:0,alignItems:"center",justifyContent:"center",maxWidth:"100%"},chipLabel:{...S(e,"bold"),fontSize:12,lineHeight:14,color:Dp,textAlign:"center"}})}i(WS,"makeStyles");var is=/\*\*([^*]+?)\*\*|\*([^*]+?)\*|`([^`]+?)`/g;function jp(e){return e.includes("*")||e.includes("`")}i(jp,"hasInlineMarkup");function Wp(e){let t=[],r=0;is.lastIndex=0;for(let n=is.exec(e);n!==null;n=is.exec(e)){n.index>r&&t.push({kind:"text",text:e.slice(r,n.index)});let o=n[1],s=n[2],a=n[3];o!==void 0?t.push({kind:"bold",text:o}):s!==void 0?t.push({kind:"italic",text:s}):a!==void 0&&t.push({kind:"code",text:a}),r=n.index+n[0].length;}return r<e.length&&t.push({kind:"text",text:e.slice(r)}),t}i(Wp,"tokenizeInlineMarkdown");function Gp(e,t){return jp(e)?Wp(e).map((r,n)=>{switch(r.kind){case "bold":return jsxRuntime.jsx(R,{style:t.bold,children:r.text},n);case "italic":return t.italic?jsxRuntime.jsx(R,{style:t.italic,children:r.text},n):r.text;case "code":return t.code?jsxRuntime.jsx(R,{style:t.code,children:r.text},n):r.text;default:return r.text}}):e}i(Gp,"renderInlineMarkdown");var $p=6,Qp=520,XS=Math.round(Qp*.18),Yp=.44,QS=.5,Xp=[0,.5,1],ZS=[0,1,2];function Zp(){let e=F(),t=react.useMemo(()=>eT(e),[e]),r=!e.motion.reducedMotion;return jsxRuntime.jsx(reactNative.View,{style:t.card,accessible:true,accessibilityRole:"text",accessibilityLabel:h.typing,accessibilityLiveRegion:"polite",accessibilityState:{busy:true},children:ZS.map(n=>r?jsxRuntime.jsx(JS,{index:n,style:t.dot},n):jsxRuntime.jsx(reactNative.View,{style:[t.dot,t.dotStatic]},n))})}i(Zp,"TypingIndicator");function JS({index:e,style:t}){let r=react.useRef(new reactNative.Animated.Value(0)).current;react.useEffect(()=>{let s=reactNative.Animated.sequence([reactNative.Animated.delay(e*XS),reactNative.Animated.loop(reactNative.Animated.timing(r,{toValue:1,duration:Qp,useNativeDriver:true}))]);return s.start(),()=>s.stop()},[r,e]);let n=r.interpolate({inputRange:Xp,outputRange:[Yp,1,Yp]}),o=r.interpolate({inputRange:Xp,outputRange:[0,-3.5,0]});return jsxRuntime.jsx(reactNative.Animated.View,{style:[t,{opacity:n,transform:[{translateY:o}]}]})}i(JS,"AnimatedDot");function eT(e){let t=e.color,r=e.space,n=e.radius;return reactNative.StyleSheet.create({card:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:r.xs,paddingHorizontal:r.md,paddingVertical:r.sm,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:t.brandBorder},dot:{width:$p,height:$p,borderRadius:n.pill,backgroundColor:t.brand},dotStatic:{opacity:QS}})}i(eT,"makeStyles");function Jp(e,t,r){let n=e-r,o=t!=null?Math.min(n,t):n;return Math.max(0,o)}i(Jp,"resolveTurnScrollTarget");function ef(e){let t=e.length-1,r=e[t];if(r===void 0||r.role!=="assistant")return null;let n=e[t-1];return {assistantIndex:t,userIndex:n!==void 0&&n.role==="user"?t-1:null}}i(ef,"latestTurn");function tf(e,t,r){let n=Math.max(0,r),o=e===null?n:Math.min(Math.max(0,e),n);return o>t+1?o:null}i(tf,"nextFollowOffset");function rf(e,t){let r=react.useRef(null),n=react.useRef(true),o=react.useRef(t),s=react.useRef(0),a=react.useRef(0),l=react.useRef(0),u=react.useRef(new Map),d=ef(e),c=d===null?null:e[d.assistantIndex]?.id??null,p=d===null||d.userIndex===null?null:e[d.userIndex]?.id??null,f=react.useCallback(()=>{let P=r.current;if(P===null||!n.current||a.current===0)return;let k=null;if(c!==null){let w=u.current.get(c);if(w===void 0)return;let O=p===null?null:u.current.get(p)??null;k=Jp(w,O,96);}let g=tf(k,s.current,l.current-a.current);g!==null&&(s.current=g,P.scrollTo({y:g,animated:false}));},[c,p]);react.useEffect(()=>{t&&!o.current&&(n.current=true),o.current=t,f();},[e,t,f]);let m=react.useCallback(P=>{a.current=P.nativeEvent.layout.height,f();},[f]),y=react.useCallback((P,k)=>{l.current=k,a.current>0&&(s.current=Math.min(s.current,Math.max(0,k-a.current))),f();},[f]),x=react.useCallback(P=>{s.current=P.nativeEvent.contentOffset.y;},[]),b=react.useCallback(()=>{n.current=false;},[]),C=react.useCallback(P=>{let{contentOffset:k,contentSize:g,layoutMeasurement:w}=P.nativeEvent;s.current=k.y,n.current=g.height-k.y-w.height<=24;},[]),_=react.useCallback(P=>k=>{u.current.set(P,k.nativeEvent.layout.y),(P===c||P===p)&&f();},[c,p,f]);return {ref:r,onLayout:m,onContentSizeChange:y,onScroll:x,onScrollBeginDrag:b,onScrollEnd:C,rowLayout:_}}i(rf,"useThreadFollow");function lf(e,t,r){switch(e){case "loading":return r.renderPending?jsxRuntime.jsx(Et,{render:r.renderPending,fallback:jsxRuntime.jsx(of,{})}):jsxRuntime.jsx(of,{});case "empty":return jsxRuntime.jsx(lT,{pet:r.shownPet,petRef:t.petRef,prompts:t.suggestedPrompts,onSelectPrompt:r.onSelectPrompt,onVetPrep:r.onVetPrep,vet:r.vet});case "error":return jsxRuntime.jsx(dT,{error:t.error,onRetry:t.retryLast,onAddPet:r.onAddPet});case "populated":return jsxRuntime.jsx(cT,{messages:t.messages,prompts:t.suggestedPrompts,onSelectPrompt:r.onSelectPrompt,isStreaming:t.isStreaming,onAnswerCheckin:t.petRef?t.answerCheckin:null,onCopy:r.onCopy,sentimentByMessage:t.sentimentByMessage,onSentiment:r.onSentiment,thanksFor:r.thanksFor,imagesByMessage:r.imagesByMessage,onPreview:r.onPreview,notice:r.notice,reconnecting:t.reconnecting===true,onRetry:t.retryLast,onStartNew:t.newConversation,petRef:t.petRef,onFindVet:r.onCheckinFindVet,vet:r.vet,onOpenUrl:r.onOpenUrl});default:return Ze(e)}}i(lf,"renderView");function of(){let{theme:e,styles:t}=Ee(),[r,n]=react.useState(false);return react.useEffect(()=>{let o=setTimeout(()=>n(true),op);return ()=>clearTimeout(o)},[]),jsxRuntime.jsx(reactNative.View,{style:t.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:h.loading,children:r?jsxRuntime.jsx(reactNative.ActivityIndicator,{color:e.color.brandInk}):null})}i(of,"LoadingState");function lT({pet:e,petRef:t,prompts:r,onSelectPrompt:n,onVetPrep:o,vet:s}){let{styles:a}=Ee();return jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:a.emptyContent,keyboardShouldPersistTaps:"handled",nestedScrollEnabled:true,accessibilityLabel:h.empty,children:[jsxRuntime.jsx(zp,{pet:e,petRef:t,onSend:n,onVetPrep:o,vet:s}),jsxRuntime.jsx(uf,{prompts:r,onSelectPrompt:n})]})}i(lT,"EmptyState");function uf({prompts:e,onSelectPrompt:t}){let{styles:r}=Ee();return e.length===0?null:jsxRuntime.jsx(reactNative.View,{style:r.followUps,children:e.map((n,o)=>jsxRuntime.jsx(uT,{prompt:n,index:o,onSelectPrompt:t},n))})}i(uf,"FollowUps");function uT({prompt:e,index:t,onSelectPrompt:r}){let{theme:n,styles:o}=Ee(),s=X(),a=Rt(s.followUpInMs,{delayMs:En(s,t)});return jsxRuntime.jsx(reactNative.Animated.View,{style:a,children:jsxRuntime.jsxs(B,{onPress:()=>r(e),accessibilityRole:"button",accessibilityLabel:e,containerStyle:o.followUpSlot,style:o.followUpRow,children:[jsxRuntime.jsx(R,{style:o.followUpText,children:e}),jsxRuntime.jsx(hn,{size:yT,color:n.color.brandInk,direction:"right"})]})})}i(uT,"FollowUpRow");function dT({error:e,onRetry:t,onAddPet:r}){let{styles:n}=Ee(),o=Du(e)?Wu(r):void 0;return jsxRuntime.jsxs(reactNative.View,{style:n.centered,accessible:true,accessibilityRole:"alert",children:[jsxRuntime.jsx(R,{style:n.errorText,children:e.displayMessage}),o!==void 0?jsxRuntime.jsx(reactNative.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:h.addPet,style:n.retryButton,children:jsxRuntime.jsx(R,{tier:"control",style:n.retryLabel,children:h.addPet})}):null,e.retryable?jsxRuntime.jsx(reactNative.Pressable,{onPress:t,accessibilityRole:"button",accessibilityLabel:h.retry,style:n.retryButton,children:jsxRuntime.jsx(R,{tier:"control",style:n.retryLabel,children:h.retry})}):null]})}i(dT,"ErrorState");function cT({messages:e,prompts:t,onSelectPrompt:r,isStreaming:n,onAnswerCheckin:o,onCopy:s,sentimentByMessage:a,onSentiment:l,thanksFor:u,imagesByMessage:d,onPreview:c,notice:p,reconnecting:f,onRetry:m,onStartNew:y,petRef:x,onFindVet:b,vet:C,onOpenUrl:_}){let{styles:P}=Ee(),k=X();Er(e.length,k);let g=react.useMemo(()=>dp(e),[e]),w=ld(e,n),O=e[e.length-1],M=react.useMemo(()=>e.filter(v=>!(v.checkin&&g.get(v.id)?.kind==="folded")),[e,g]),I=rf(M,n);return jsxRuntime.jsxs(reactNative.ScrollView,{ref:I.ref,style:P.list,contentContainerStyle:P.listContent,accessibilityLabel:h.transcript,keyboardShouldPersistTaps:"handled",nestedScrollEnabled:true,onLayout:I.onLayout,onContentSizeChange:I.onContentSizeChange,onScroll:I.onScroll,scrollEventThrottle:mT,onScrollBeginDrag:I.onScrollBeginDrag,onScrollEndDrag:I.onScrollEnd,onMomentumScrollEnd:I.onScrollEnd,children:[e.map(v=>{let T=v.checkin?g.get(v.id):void 0;return T?.kind==="folded"?null:T?.kind==="past"?jsxRuntime.jsx(Ep,{text:v.text,runDueDays:T.runDueDays,openedAt:v.checkin?.openedAt,onLayout:I.rowLayout(v.id)},v.id):v.checkin&&T!==void 0?jsxRuntime.jsx(bp,{message:v,checkin:v.checkin,onAnswer:o,petRef:x,onFindVet:b,vet:C,onLayout:I.rowLayout(v.id)},v.id):jsxRuntime.jsx(gT,{onLayout:I.rowLayout(v.id),message:v,revealing:n&&v===O&&v.role==="assistant",onCopy:s,sentiment:v.responseId===void 0?null:a[String(v.responseId)]??null,onSentiment:l,thanks:u!==null&&v.responseId!==void 0&&String(v.responseId)===u,images:d[v.id]??fT,onPreview:c,onOpenUrl:_},v.id)}),f?jsxRuntime.jsx(R,{tier:"compact",style:P.reconnectingCaption,accessibilityRole:"text",children:h.reconnecting}):null,w?jsxRuntime.jsx(Zp,{}):null,p!==null?jsxRuntime.jsx(pT,{notice:p,onRetry:m,onStartNew:y}):null,n?null:jsxRuntime.jsx(uf,{prompts:t,onSelectPrompt:r})]})}i(cT,"PopulatedState");function pT({notice:e,onRetry:t,onStartNew:r}){let{styles:n}=Ee(),o=e.tone==="error";return jsxRuntime.jsxs(reactNative.View,{style:[n.turnNotice,o?n.turnNoticeError:null],accessible:true,accessibilityRole:"alert",children:[jsxRuntime.jsx(R,{tier:"control",style:[n.turnNoticeTitle,o?n.turnNoticeTitleError:null],children:e.title}),jsxRuntime.jsx(R,{tier:"compact",style:n.turnNoticeBody,children:e.body}),jsxRuntime.jsx(reactNative.Pressable,{onPress:e.action==="startNew"?r:t,accessibilityRole:"button",accessibilityLabel:e.actionLabel,hitSlop:Kt,style:n.turnNoticeAction,children:jsxRuntime.jsx(R,{tier:"control",style:n.turnNoticeActionLabel,children:e.actionLabel})})]})}i(pT,"TurnNoticeCard");var fT=Object.freeze([]),mT=16,yT=14;function gT({message:e,revealing:t,onCopy:r,sentiment:n,onSentiment:o,thanks:s,images:a,onPreview:l,onOpenUrl:u,onLayout:d}){let{styles:c}=Ee(),p=X(),f=Rt(p.messageInMs),m=Ld(e.text,t,p),y=e.role==="user",x=y?h.senderUser:h.senderAssistant,b=react.useCallback(_=>o(e,_),[o,e]),C=e.pending!==true;return jsxRuntime.jsxs(reactNative.Animated.View,{style:[c.rowBlock,y?c.rowBlockUser:c.rowBlockAssistant,f],onLayout:d,children:[jsxRuntime.jsx(reactNative.View,{style:[c.row,y?c.rowUser:c.rowAssistant],accessible:true,accessibilityRole:"text",accessibilityLabel:`${x}: ${e.text}`,accessibilityState:e.pending===true?{busy:true}:void 0,children:jsxRuntime.jsxs(reactNative.View,{style:[c.bubble,y?c.bubbleUser:c.bubbleAssistant,e.pending?c.bubblePending:null],children:[y&&a.length>0?jsxRuntime.jsx(Zd,{images:a,onPreview:_=>l({uri:_.uri,label:_.filename})}):null,jsxRuntime.jsx(R,{style:y?c.bubbleTextUser:c.bubbleTextAssistant,children:y?e.text:Gp(m,{bold:c.bubbleBold,italic:c.bubbleItalic,code:c.bubbleCode})})]})}),!y&&!t?jsxRuntime.jsx(_p,{citations:e.citations,onOpenUrl:u}):null,C?jsxRuntime.jsx(Mp,{message:e,onCopy:r,sentiment:n,onSentiment:e.responseId===void 0?void 0:b,thanks:s}):null]})}i(gT,"MessageRow");var CT=Object.freeze(["photo"]),RT=1;function cf(e){let{style:t,renderPending:r}=e;return jsxRuntime.jsx(ti,{capability:"chat",style:t,...r?{renderPending:r}:{},children:jsxRuntime.jsx(ST,{...e})})}i(cf,"EverfurChat");function ST({petRef:e,conversationId:t,style:r,renderPending:n,onCopy:o,onPetChange:s,onVetPrep:a,onFindVet:l,renderVetAction:u,attachments:d,pet:c,onAddPet:p,checkinTarget:f,initialAsk:m,composerSeed:y,lifecycle:x,draftStore:b,vetReturnTo:C,vetUsState:_,vetPrefer:P,onOpenUrl:k,keyboardVerticalOffset:g}){let{theme:w,styles:O}=Ee(),M=X(),I=react.useMemo(()=>ud(e,t),[e,t]),v=hr(I),T=sd(v),V=Xc(),j=td(v),W=reactNativeSafeAreaContext.useSafeAreaInsets(),ne=ad(v),he=react.useMemo(()=>l===void 0?void 0:()=>{q(l,"emergency");},[l]),ke=react.useMemo(()=>C===void 0&&_===void 0&&P===void 0?void 0:{returnTo:C,usState:_,prefer:P},[C,_,P]),st=Wi(V.pets,v.petRef),fe=react.useMemo(()=>od(v.messages,st?.name??null),[v.messages,st?.name]),Qe=id(fe);Er(Qe.showBanner,M),$u(v.openCheckin,f),Bu(v.askEverfur,v.isBootstrapping,m);let Ir=react.useMemo(()=>ui(y),[y]);Ku(x,{conversationId:v.conversationId===null?null:String(v.conversationId),isTurnInFlight:v.isStreaming,refresh:v.refreshActiveThread});let Ar=(v.hasUnreadThreads??false)||j.rows.some(Ce=>Ce.unreadCount!==null&&Ce.unreadCount>0)||(v.unreadCount??0)>0,At=Vu(v.messages),[Yt,Wn]=react.useState(null),ff=react.useCallback(()=>Wn(null),[]),[Xt,Gn]=react.useState(null),[mf,us]=react.useState(null),Ot=react.useRef(null);react.useEffect(()=>()=>{Ot.current&&clearTimeout(Ot.current);},[]);let ds=react.useCallback(Ce=>{us(String(Ce)),Ot.current&&clearTimeout(Ot.current),Ot.current=setTimeout(()=>{us(null),Ot.current=null;},ip);},[]),yf=react.useCallback((Ce,Fr)=>{let Qt=Ce.responseId;if(Qt===void 0)return;let Cf=v.sentimentByMessage[String(Qt)];v.feedback(Qt,Fr),Fr==="down"&&Cf!=="down"&&Gn(Qt);},[v]),gf=react.useCallback(async(Ce,Fr)=>Xt===null||!(await v.feedback(Xt,"down",Ce??"other",Fr)).ok?false:(Gn(null),ds(Xt),true),[v,Xt,ds]),hf=react.useCallback(()=>Gn(null),[]),bf=react.useCallback(Ce=>{v.send(Ce);},[v.send]),vf=react.useMemo(()=>k===void 0?void 0:Ce=>{q(k,Ce,"citation");},[k]),cs=reactNative.Platform.OS==="ios"?"padding":void 0,Or=Wc(g,cs!==void 0),Ef=Or.topInWindow===null?W.top:Math.max(0,W.top-Or.topInWindow),ps={send:v.send,stop:v.stop,isStreaming:v.isStreaming,conversationId:v.conversationId,seed:Ir,draftStore:b,onStage:At.stage,onPreview:Wn};return jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{style:[O.container,{paddingTop:Ef},r],behavior:cs,...Or.avoidingProps,children:[jsxRuntime.jsx(Gc,{probeRef:Or.probeRef}),jsxRuntime.jsx(Dc,{pets:V,petRef:v.petRef,historyUnread:Ar,onOpenHistory:j.show,onPetChange:s,onAddPet:p,vet:ke}),c!==void 0?jsxRuntime.jsx(TT,{petRef:e??null,pet:c,onRegistered:V.refresh}):null,jsxRuntime.jsx(Yc,{surface:Qe,petRef:v.petRef,renderVetAction:u,onFindVet:l,vet:ke}),jsxRuntime.jsx(reactNative.View,{style:O.body,children:lf(T,v,{notice:ne,vet:ke,onCheckinFindVet:he,onSelectPrompt:bf,renderPending:n,shownPet:st,onVetPrep:a,onCopy:o,onSentiment:yf,thanksFor:mf,imagesByMessage:At.byMessage,onPreview:Wn,onAddPet:p,onOpenUrl:vf})}),d!==void 0?jsxRuntime.jsx(PT,{...ps,attachments:d}):jsxRuntime.jsx(pf,{...ps,attachments:null}),jsxRuntime.jsx(pd,{}),w.meta.hidePoweredBy?null:jsxRuntime.jsx(R,{tier:"compact",style:O.poweredBy,accessibilityRole:"text",accessibilityLabel:h.poweredBy,children:h.poweredBy}),jsxRuntime.jsx(jc,{chat:v,history:j}),jsxRuntime.jsx(zc,{visible:Xt!==null,onSubmit:gf,onSkip:hf}),jsxRuntime.jsx(Dd,{uri:Yt?.uri??null,label:Yt?.label??"",onClose:ff}),jsxRuntime.jsx(Rr,{})]})}i(ST,"ChatBody");function TT({petRef:e,pet:t,onRegistered:r}){let{styles:n}=Ee(),o=Nu(e,t,r);return o.status!=="failed"||o.error===null?null:jsxRuntime.jsxs(reactNative.View,{style:n.setupNotice,accessible:true,accessibilityRole:"alert",children:[jsxRuntime.jsx(R,{tier:"compact",style:n.setupNoticeText,children:o.error.displayMessage}),jsxRuntime.jsx(reactNative.Pressable,{onPress:o.retry,accessibilityRole:"button",accessibilityLabel:h.retry,hitSlop:Kt,children:jsxRuntime.jsx(R,{tier:"control",style:n.setupNoticeAction,children:h.retry})})]})}i(TT,"PetSetupNotice");function PT({attachments:e,...t}){let r=react.useMemo(()=>ec(),[]),n=pn({maxPerMessage:e.maxPerMessage??RT,transport:r}),o=react.useMemo(()=>({state:n,sources:e.sources??CT,pick:e.pick}),[n,e.sources,e.pick]);return jsxRuntime.jsx(pf,{...t,attachments:o})}i(PT,"ComposerWithAttachments");function pf({send:e,stop:t,isStreaming:r,conversationId:n,attachments:o,seed:s,draftStore:a,onStage:l,onPreview:u}){let{theme:d,styles:c}=Ee(),p=X(),[f,m]=Qu(e,n,s);Zu(a,n===null?null:String(n),f,m);let[y,x]=react.useState(false),[b,C]=react.useState(false);react.useEffect(()=>{C(false);},[n]);let _=d.meta.placeholder??h.placeholder,P=o?.state.uploading??false,k=o?.state.failed??false,g=P||k,w=o?.state.attachments??kT;Er(w.length,p);let O=react.useCallback(()=>{if(f.trim().length===0||g||[...f].length>Lt)return;let W=o?.state.s3Keys??xT;o!==null&&W.length>0?(l(o.state.attachments.filter(ne=>ne.status==="uploaded").map(ne=>({uri:ne.previewUri,filename:ne.filename}))),e(f,{imageS3Keys:W}),o.state.clear()):e(f),m(""),C(false);},[f,e,g,o,l]),M=react.useCallback(()=>{t();},[t]),I=react.useCallback(W=>{x(false),o!==null&&(C(false),o.state.dismissRejected(),Ht(o.pick,W).then(ne=>{if(!ne.ok){C(true);return}ne.value!==null&&o.state.add(ne.value);}));},[o]),T=react.useMemo(()=>[...f].length>Lt,[f])||g,V=o!==null&&w.length>=o.state.maxPerMessage,j=d.slots.sendButton?.textColor??d.color.brandInk;return jsxRuntime.jsxs(reactNative.View,{style:c.composerOuter,children:[o!==null&&y?jsxRuntime.jsx(Vd,{sources:o.sources,full:V,onPick:I,onClose:()=>x(false)}):null,jsxRuntime.jsxs(reactNative.View,{style:c.composer,children:[o!==null?jsxRuntime.jsx(Qd,{attachments:w,rejected:b?_T:o.state.rejected,uploadFailed:k,onRetry:o.state.retry,onRemove:o.state.remove,onPreview:W=>u({uri:W.previewUri,label:W.filename})}):null,jsxRuntime.jsxs(reactNative.View,{style:c.composerRow,children:[o!==null?jsxRuntime.jsx(reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:Fu(w.length,o.state.maxPerMessage),accessibilityState:{disabled:V,expanded:y},disabled:V,hitSlop:(Gt-Un)/2,style:[c.attachControl,V?c.attachControlDisabled:null],onPress:()=>x(W=>!W),children:jsxRuntime.jsx(Ed,{size:lp,color:V?d.color.text.muted:d.color.brandInk,strokeWidth:1.75})}):null,jsxRuntime.jsx(Ut,{style:c.input,value:f,onChangeText:m,placeholder:_,placeholderTextColor:d.slots.composerInput?.textColor??d.color.text.placeholder,onSubmitEditing:O,returnKeyType:"send",blurOnSubmit:false,multiline:true,editable:true}),r?jsxRuntime.jsx(reactNative.Pressable,{onPress:M,accessibilityRole:"button",accessibilityLabel:h.stop,hitSlop:Kt,style:c.sendControl,children:jsxRuntime.jsx(reactNative.View,{style:c.sendDisc,testID:"everfur-stop-disc",children:jsxRuntime.jsx(xd,{size:ap,color:j,testID:"everfur-stop-glyph"})})}):jsxRuntime.jsx(reactNative.Pressable,{onPress:O,disabled:T,accessibilityRole:"button",accessibilityLabel:h.send,accessibilityState:{disabled:T,busy:P},hitSlop:Kt,style:[c.sendControl,T?c.sendControlDisabled:null],children:jsxRuntime.jsx(reactNative.View,{style:c.sendDisc,testID:"everfur-send-disc",children:jsxRuntime.jsx(kd,{size:sp,color:j,testID:"everfur-send-glyph"})})})]})]})]})}i(pf,"Composer");var kT=Object.freeze([]),xT=Object.freeze([]),_T=Object.freeze({code:"unknown",retryable:true,filename:""});function FT(e){let{runtime:t,userRef:r,scopeEpoch:n}=Y(),o=react.useMemo(()=>Je(t.registry.services.authFor(r)),[t,r,n]),s=react.useMemo(()=>({repository:o,petRef:e}),[o,e]),[a,l]=react.useState({key:s,profile:null,loading:e!==null,error:null}),u=a.key===s?a:{profile:null,loading:e!==null,error:null},d=react.useRef(0),c=react.useCallback(async()=>{let p=++d.current;if(s.petRef===null){l({key:s,profile:null,loading:false,error:null});return}l(m=>({key:s,profile:m.key===s?m.profile:null,loading:true,error:null}));let f=await s.repository.getPetProfile(s.petRef);p===d.current&&l(f.ok?{key:s,profile:f.value,loading:false,error:null}:{key:s,profile:null,loading:false,error:f.error});},[s]);return react.useEffect(()=>(c(),()=>{d.current+=1;}),[c]),react.useMemo(()=>({profile:u.profile,loading:u.loading,error:u.error,refresh:c}),[u.profile,u.loading,u.error,c])}i(FT,"useEverfurPetProfile");function LT(e){return react.createElement(un,{clientTheme:e.clientTheme??null,seams:cn,children:e.children})}i(LT,"EverfurThemeProvider");exports.CapabilityGate=ti;exports.EverfurChat=cf;exports.EverfurConfigError=Q;exports.EverfurProvider=$h;exports.EverfurThemeProvider=LT;exports.EverfurThrownError=Mr;exports.THEME_SLOT_KEYS=mg;exports.THEME_SLOT_NAMES=gt;exports.canonicalPetSpecies=ur;exports.categoryFor=qn;exports.conversationId=wf;exports.createRnRecordsUploadTransport=qf;exports.face=S;exports.isErr=Tf;exports.isOk=Sf;exports.isRetryableCode=$n;exports.petRef=xf;exports.previewTheme=zg;exports.unwrap=Pf;exports.useCapability=Nt;exports.useChatAttachments=pn;exports.useEverfur=ou;exports.useEverfurChat=hr;exports.useEverfurPetProfile=FT;exports.useEverfurPets=Tn;exports.useEverfurTheme=F;exports.userFacingError=Ft;exports.userRef=_f;
|