@everfur/sdk 1.5.3 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/chat-cards/package.json +8 -0
  2. package/dist/{Chat.d-BCfyvzX8.d.ts → Chat.d-B4GybUU4.d.ts} +1 -1
  3. package/dist/{Chat.d-Od44h51D.d.cts → Chat.d-DPM2ncxi.d.cts} +1 -1
  4. package/dist/chat/index.cjs +174 -174
  5. package/dist/chat/index.d.cts +4 -4
  6. package/dist/chat/index.d.ts +4 -4
  7. package/dist/chat/index.js +340 -340
  8. package/dist/chat/lite/index.cjs +174 -174
  9. package/dist/chat/lite/index.d.cts +4 -4
  10. package/dist/chat/lite/index.d.ts +4 -4
  11. package/dist/chat/lite/index.js +339 -339
  12. package/dist/chat-cards/index.cjs +18 -0
  13. package/dist/chat-cards/index.d.cts +15 -0
  14. package/dist/chat-cards/index.d.ts +15 -0
  15. package/dist/chat-cards/index.js +18 -0
  16. package/dist/{chatHandoffToken.d-BjfmIxXk.d.cts → chatHandoffToken.d-Cap2z62P.d.cts} +1 -1
  17. package/dist/{chatHandoffToken.d-CFiI6IMc.d.ts → chatHandoffToken.d-zdp23Ukr.d.ts} +1 -1
  18. package/dist/{checkin.d-CokpahFL.d.ts → checkin.d-BoZXWjxX.d.ts} +8 -0
  19. package/dist/{checkin.d-BP3ZWBfX.d.cts → checkin.d-CuIUahcd.d.cts} +8 -0
  20. package/dist/{chunk-CFEHTNKX.js → chunk-6AIEUA4V.js} +1 -1
  21. package/dist/{chunk-OU5RMGKD.js → chunk-BN7OAFBS.js} +18 -18
  22. package/dist/{chunk-ZGL2GEEI.js → chunk-IXHLESYC.js} +1 -1
  23. package/dist/{chunk-XGF2HYNN.js → chunk-LMIBOI3I.js} +16 -16
  24. package/dist/client/index.cjs +1 -1
  25. package/dist/client/index.d.cts +1 -1
  26. package/dist/client/index.d.ts +1 -1
  27. package/dist/client/index.js +1 -1
  28. package/dist/{context.d-DS1GXUEY.d.ts → context.d-D7zX6Q0J.d.ts} +1 -1
  29. package/dist/{context.d-Bj6-xYPA.d.cts → context.d-guaLkx5t.d.cts} +1 -1
  30. package/dist/core/index.cjs +2 -2
  31. package/dist/core/index.d.cts +4 -4
  32. package/dist/core/index.d.ts +4 -4
  33. package/dist/core/index.js +2 -2
  34. package/dist/index.cjs +354 -354
  35. package/dist/index.d.cts +7 -7
  36. package/dist/index.d.ts +7 -7
  37. package/dist/index.js +364 -364
  38. package/dist/notifications/index.d.cts +3 -3
  39. package/dist/notifications/index.d.ts +3 -3
  40. package/dist/records/index.cjs +1 -1
  41. package/dist/records/index.js +1 -1
  42. package/dist/{route.d-DtuKY5dM.d.ts → route.d-B3u14HJT.d.ts} +1 -1
  43. package/dist/{route.d-Nt-r-7IO.d.cts → route.d-QBCoO62z.d.cts} +1 -1
  44. package/dist/{runtimeTypes.d-CL4l7ta4.d.cts → runtimeTypes.d-BSxuUCOX.d.cts} +1 -1
  45. package/dist/{runtimeTypes.d-BzUig75K.d.ts → runtimeTypes.d-hjN6xvxm.d.ts} +1 -1
  46. package/dist/server/events/index.cjs +1 -1
  47. package/dist/server/events/index.js +1 -1
  48. package/dist/server/index.cjs +1 -1
  49. package/dist/server/index.js +1 -1
  50. package/dist/testing/rn/index.d.cts +2 -2
  51. package/dist/testing/rn/index.d.ts +2 -2
  52. package/dist/testing/web/index.d.cts +2 -2
  53. package/dist/testing/web/index.d.ts +2 -2
  54. package/dist/{useUnread.d-CedFK4k6.d.ts → useUnread.d-4SbFChbd.d.ts} +30 -3
  55. package/dist/{useUnread.d-DST1GMmL.d.cts → useUnread.d-B0YhhR_D.d.cts} +30 -3
  56. package/dist/web/health-plan/index.cjs +1 -1
  57. package/dist/web/health-plan/index.js +1 -1
  58. package/dist/web/index.cjs +3 -3
  59. package/dist/web/index.d.cts +7 -7
  60. package/dist/web/index.d.ts +7 -7
  61. package/dist/web/index.js +3 -3
  62. package/dist/web/notifications/index.d.cts +2 -2
  63. package/dist/web/notifications/index.d.ts +2 -2
  64. package/dist/web/records-sheet/index.cjs +1 -1
  65. package/dist/web/records-sheet/index.js +1 -1
  66. package/dist/web/shop/index.cjs +1 -1
  67. package/dist/web/shop/index.js +1 -1
  68. package/dist/web/televet/booking/index.cjs +1 -1
  69. package/dist/web/televet/booking/index.js +1 -1
  70. package/dist/web/televet/call/index.cjs +1 -1
  71. package/dist/web/televet/call/index.js +1 -1
  72. package/dist/web/ui/index.cjs +1 -1
  73. package/dist/web/ui/index.js +32 -32
  74. package/package.json +16 -1
@@ -1,7 +1,7 @@
1
1
  /*! @everfur/sdk. Copyright (c) 2026 Strand Health Inc. dba Everfur. All rights reserved. Use is subject to the Everfur SDK License: https://docs.everfur.com/license */
2
2
  "use strict";function ok(e,t){/* @__PURE__ */
3
3
  return Object.freeze({ok:true,value:e})}function err(e){/* @__PURE__ */
4
- return Object.freeze({ok:false,error:e})}var e=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var t=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/;var r="1.5.3";var n="2026-09-19",a="EVERFUR_API_BASE_URL";function i(e,t){/* @__PURE__ */
4
+ return Object.freeze({ok:false,error:e})}var e=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var t=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/;var r="1.6.0";var n="2026-09-19",a="EVERFUR_API_BASE_URL";function i(e,t){/* @__PURE__ */
5
5
  return Object.freeze({ok:false,failure:/* @__PURE__ */Object.freeze({reason:e,message:t})})}function tryResolveApiBaseUrl(e){let t=e?.trim(),r=t&&t.length>0?t:c(a);return r?d(r):i("missing-api-base-url",`apiBaseUrl is required: pass config.apiBaseUrl or set ${a}. The SDK never ships a hardcoded host.`)}function resolveApiBaseUrl(t){let r=tryResolveApiBaseUrl(t);if(!r.ok)throw new e("invalid-argument",r.failure.message);return r.value}function o(e){return e.slice(e.lastIndexOf("@")+1).replace(/:\d+$/,"").toLowerCase()}function l(e){return e.length===0||e.includes("@")?false:e.startsWith("[")&&e.endsWith("]")?true:!e.includes(":")}function s(e,t){let r=e.indexOf("://");return r<0||e.slice(r+3).includes("@")?false:l(t)}function u(e,t){return`${e}://${t}`}function d(e){let r=e.trim(),n=t.exec(r);if(n===null||n[2]===void 0||n[2].length===0)return i("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let a=(n[1]??"").toLowerCase(),l=o(n[2]);if(l.length===0)return i("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let d=s(r,l)?`: ${u(a,l)}`:"";if(a!=="https"){if(!(a==="http"&&p(l)))return a==="http"?i("insecure-api-base-url",`apiBaseUrl must use https (cleartext http is only allowed for localhost)${d}`):i("unsupported-api-base-url-scheme",`apiBaseUrl must be http(s)${d}`)}let c=r.endsWith("/")?r.slice(0,-1):r;/* @__PURE__ */
6
6
  return Object.freeze({ok:true,value:c})}function p(e){let t=e.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="[::1]"||t==="::1"}function c(e){let t=globalThis.process?.env?.[e];return typeof t=="string"&&t.trim().length>0?t.trim():void 0}var f="server";function v(e){return{"X-Everfur-SDK-Version":r,"X-Everfur-SDK-Platform":f,"X-Everfur-Contract":e}}var _="DAILY_QUOTA_EXCEEDED",h=/* @__PURE__ */new Set(["THROTTLINGEXCEPTION","RATELIMITED","TOOMANYREQUESTS"]);function m(e,t){if(!h.has(e.toUpperCase().replace(/[^A-Z0-9]/g,"")))return e;let r=t,n=r?.daily_limit??r?.error?.daily_limit;return typeof n=="number"&&Number.isFinite(n)?_:e}var y=[{wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"DAILY_QUOTA_EXCEEDED",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"FILE_TOO_LARGE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"IDEMPOTENCY_KEY_IN_FLIGHT",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"INVALID_CONTENT_TYPE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"InternalFailureException",envelope:"http_envelope",httpStatus:500,retryable:true},{wireCode:"MethodNotAllowedException",envelope:"http_envelope",httpStatus:405,retryable:false},{wireCode:"NotImplementedException",envelope:"http_envelope",httpStatus:501,retryable:false},{wireCode:"PaymentRequiredException",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ResourceNotFoundException",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"ServiceUnavailableException",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"TIER_UPGRADE_REQUIRED",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ThrottlingException",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"ValidationException",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"accessDenied",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"access_denied",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"anchor_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"anchor_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"anonTokenInvalid",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"attachment_unreadable",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"authExpired",envelope:"http_envelope",httpStatus:401,retryable:true},{wireCode:"authRejected",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"before_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_not_uploaded",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundles_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"catalog_empty_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"catalog_shrink_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"consent_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_required",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_scope_wrong_route",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"device_cipher_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"email_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"endpoint_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"environment_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_cursor_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_payload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_not_available",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_unknown",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_required",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_reused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"inbox_cursor_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"insufficientCapability",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"insufficient_scope",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"internal_error",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"invalidRequest",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"invalid_client",envelope:"oauth_error",httpStatus:401,retryable:false},{wireCode:"invalid_client_metadata",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_grant",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_redirect_uri",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_request",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_scope",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_target",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"item_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"linked_account_read_only",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_connection_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"mcp_request_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_request_gone",envelope:"http_envelope",httpStatus:410,retryable:false},{wireCode:"mcp_request_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"not_found",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"open_url_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"partner_visit_link_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"partner_visit_owner_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"partner_visit_pet_already_mapped",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"payload_too_large",envelope:"http_envelope",httpStatus:413,retryable:false},{wireCode:"petRefInUse",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"pet_health_list_removals_unconfirmed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_health_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_not_registered",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"provider_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"rateLimited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"read_target_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_subject_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"record_upload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"records_consent_required",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"restricted_key",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"sandbox_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_required",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_revoked",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"share_limit_reached",envelope:"http_envelope",httpStatus:429,retryable:false},{wireCode:"slow_down",envelope:"oauth_error",httpStatus:429,retryable:true},{wireCode:"species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"subscription_keys_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"tenant_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"tenant_has_no_capabilities",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tenant_resource_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"tenant_surface_not_enabled",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"ticket_not_resolved",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tickets_disabled",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"timeout",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"timezone_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"token_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"unavailable",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"unrestrictedKeyRequired",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"unsupported_grant_type",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"unsupported_response_type",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"user_ref_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"verify_mint_rate_limited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"verify_mint_refused",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"verify_mint_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"verify_user_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"web_push_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"webhook_endpoint_update_empty",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false}],b=/* @__PURE__ */Object.freeze(y.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(b.map(e=>e.wireCode));var g=/* @__PURE__ */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",session_revoked:"authExpired",anonTokenInvalid:"authRejected",accessDenied:"accessDenied",invalidRequest:"sdkUpdateRequired",authRejected:"authRejected",rateLimited:"rateLimited",insufficientCapability:"accessDenied",unrestrictedKeyRequired:"accessDenied",user_ref_invalid:"validationFailed",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",linked_account_read_only:"conflict",catalog_empty_refused:"conflict",catalog_shrink_refused:"conflict",endpoint_not_allowed:"validationFailed",event_id_invalid:"validationFailed",inbox_cursor_invalid:"validationFailed",item_id_invalid:"validationFailed",open_url_not_allowed:"validationFailed",read_target_invalid:"validationFailed",subscription_keys_invalid:"validationFailed",web_push_unavailable:"serviceUnavailable",anchor_not_found:"resourceNotFound",anchor_ref_invalid:"validationFailed",before_invalid:"validationFailed",bundle_mismatch:"validationFailed",bundle_not_uploaded:"validationFailed",bundles_unavailable:"serviceUnavailable",environment_mismatch:"validationFailed",restricted_key:"accessDenied",ticket_not_resolved:"conflict",tickets_disabled:"resourceNotFound",timezone_invalid:"validationFailed"}),w=/* @__PURE__ */Object.freeze(b.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:g[e.wireCode]}))),S=new Map(w.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),C=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(w.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let e of[t??"http_envelope",...C]){let t=S.get(e+r);if(t)return t}}var E=/* @__PURE__ */Object.freeze({authExpired:"authentication",authRejected:"authentication",sessionRequired:"authentication",identitySignatureRequired:"authentication",accessDenied:"authorization",paymentRequired:"entitlement",quotaExceeded:"rateLimit",rateLimited:"rateLimit",validationFailed:"invalidRequest",sdkUpdateRequired:"invalidRequest",runtimeDisposed:"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 categoryFor(e){return E[e]}function fromWire(e){let t=contractErrorFor(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"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";case"RUNTIMEDISPOSED":return"runtimeDisposed";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"}}function fromHttpStatus(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"}var T=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return T.has(e)}var $=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||$.has(e)}var R="This feature isn't available on your account right now.",A="Something in that request was not right. Check the details and try again.",k=/* @__PURE__ */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:R,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:A,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.",identitySignatureRequired:R,runtimeDisposed:A,unknown:"Something went wrong. Please try again."}),I="This session has ended. Please sign in again.",D="linked_account_read_only";function F(e,t,r){return e==="conflict"&&r===D?R:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?I:userFacingError(e)}function userFacingError(e){return k[e]}function O(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var j=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===D,a={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:F(e,t?.wireCode,n?D:null)};t?.httpStatus!==void 0&&(a.httpStatus=t.httpStatus),t?.requestId&&(a.requestId=t.requestId),typeof t?.reasonCode=="string"&&j.test(t.reasonCode)&&(a.reasonCode=t.reasonCode);let i=t?.retryAfterSeconds;if(typeof i=="number"&&Number.isFinite(i)&&i>=0&&(a.retryAfterSeconds=Math.round(i)),r);return t?.wireMessage&&O(a,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&O(a,"raw",t.raw),/* @__PURE__ */Object.freeze(a)}var N="free_cap_reached";function x(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function U(e){if(typeof e!="object"||e===null)return null;let t=e,r=t.detail,n=typeof r=="object"&&r!==null?r:t;if(n.error!==N&&n.code!==N)return null;let a=x(n.limit),i=x(n.used);if(a===null||i===null)return null;let o=n.resets_at,l=n.emergency_guidance;/* @__PURE__ */
7
7
  return Object.freeze({limit:a,used:i,resetsAt:typeof o=="string"&&o.length>0?o:null,...typeof l=="string"&&l.trim().length>0?{emergencyGuidance:l}:{}})}function q(e,t){if(e.status!==429&&e.status!==503)return t;let r=z(e.headers.get(L),Date.now());if(r===null)return t;let n=t!==null&&typeof t=="object"&&!Array.isArray(t)?t:null;return n!==null&&P(n)?t:{...n??{},retry_after_seconds:r}}var L="retry-after";function z(e,t){if(e===null)return null;let r=e.trim();if(/^\d+$/.test(r))return Number(r);let n=Date.parse(r);return Number.isFinite(n)?Math.max(0,Math.ceil((n-t)/1e3)):null}function P(e){return[e,e.error,e.detail].some(e=>e!==null&&typeof e=="object"&&("retry_after_seconds"in e||"resets_at"in e))}var M="x-request-id";function errorFromResponse(e,t,r){let n=Y(t),a=n?fromWire(n):fromHttpStatus(e),i=V(t);return makeEverfurError(a,{httpStatus:e,...W(t)?{retryable:true}:{},...r?{requestId:r}:{},...n?{wireCode:n}:{},...B(t)?{reasonCode:B(t)}:{},...K(t)!==null?{retryAfterSeconds:K(t)}:{},...i?{wireMessage:i}:{},...t!=null?{raw:t}:{}})}function K(e){let t=e,r=t?.retry_after_seconds??t?.error?.retry_after_seconds;return typeof r=="number"&&Number.isFinite(r)&&r>=0?r:null}function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:Z(e)})}function requestIdOf(e){let t=e.headers.get(M);return typeof t=="string"&&t.length>0?t:null}function getGlobalFetch(){let t=globalThis.fetch;if(typeof t!="function")throw new e("missing-peer-dependency","global fetch is unavailable; provide config.transport or an injected fetch implementation");return t}function B(e){let t=e,r=t?.error?.reason_code??t?.reason_code;return typeof r=="string"&&r.length>0?r:null}function Y(e){let t=e,r=t?.error?.code??t?.code;return typeof r=="string"&&r.length>0?m(r,e):U(e)!==null?N:null}function V(e){let t=e,r=t?.error?.message??t?.message;return typeof r=="string"&&r.length>0?r:null}function W(e){let t=e;return t?.error?.retryable===true||t?.retryable===true}function Z(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var G=["sk_partner_","rk_partner_"];function Q(t,r){if(typeof t!="string"||t.length===0)throw new e("invalid-argument","partnerSecretKey is required");if(t.startsWith("pk_"))throw new e("invalid-argument",`partnerSecretKey is a publishable key (pk_...): ${r} needs your secret key, server side only`);if(!G.some(e=>t.startsWith(e)))throw new e("invalid-argument","partnerSecretKey must be an sk_partner_ secret key or an rk_partner_ restricted key")}var X=128;function assertValidUserRef(t){let r=typeof t=="string"?[...t].length:0;if(typeof t!="string"||r<1||r>X)throw new e("invalid-argument",`user_ref must be 1..${X} characters`);if(t.trim().length===0)throw new e("invalid-argument","user_ref must not be blank: the server strips surrounding whitespace before validating, so a whitespace-only value arrives empty and is rejected as required.");if(t!==t.trim())throw new e("invalid-argument","user_ref must not have leading or trailing whitespace: the server strips it, so padded and unpadded forms of the same id resolve to ONE user. Pass the exact id you want to key on.");if(t.includes("@"))throw new e("invalid-argument","user_ref must not contain '@'");if(!H(t))throw new e("invalid-argument","user_ref must be printable (no control characters)");return t}function H(e){return!J.test(e)}var J=/[\p{Cc}\p{Cf}\p{Cs}\p{Co}\p{Cn}\p{Zl}\p{Zp}]|(?!\u0020)[\p{Zs}]/u,ee="user_ref_invalid";function te(e){let t=e.raw,r=typeof t=="object"&&t!==null?t:null,n=(r!==null&&typeof r.error=="object"&&r.error!==null?r.error.code:void 0)??r?.code;return n!==ee&&e.reasonCode!==ee?e:makeEverfurError("validationFailed",{retryable:false,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId!==void 0?{requestId:e.requestId}:{},...typeof n=="string"?{wireCode:n}:{},reasonCode:ee,...e.wireMessage!==void 0?{wireMessage:e.wireMessage}:{},...t!==void 0?{raw:t}:{}})}function re(e){let t=e.raw;if(typeof t!="object"||t===null)return null;let r=t.code;return typeof r=="string"&&r.length>0?r:null}function ne(e,t){let r=re(e);if(r===null)return e;let n=t[r];return n===void 0?e:makeEverfurError(n.code,{retryable:n.retryable,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId!==void 0?{requestId:e.requestId}:{},wireCode:r,reasonCode:r,...e.wireMessage!==void 0?{wireMessage:e.wireMessage}:{},raw:e.raw})}function ae(e,t){let r=ne(e,t);if(r!==e||re(e)!==null)return r;let n=e.reasonCode;if(typeof n!="string")return e;let a=t[n];return a===void 0?e:makeEverfurError(a.code,{retryable:a.retryable,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId!==void 0?{requestId:e.requestId}:{},wireCode:n,reasonCode:n,...e.wireMessage!==void 0?{wireMessage:e.wireMessage}:{},raw:e.raw})}var ie=64;function oe(t){if(t!=null){if(typeof t!="string"||t.length===0||t.length>ie||/\s/.test(t))throw new e("invalid-argument",`timezone must be an IANA zone name such as 'America/Chicago' (at most ${ie} characters)`);return t}}function le(e){for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let r=e.charCodeAt(t+1);if(!(r>=56320&&r<=57343))return true;t+=1}else if(r>=56320&&r<=57343)return true}return false}function se(e){return[...e].length}var ue=/* @__PURE__ */Object.freeze({dog:"dog",canine:"dog",k9:"dog",puppy:"dog",cat:"cat",feline:"cat",kitten:"cat"});function canonicalPetSpecies(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.prototype.hasOwnProperty.call(ue,t)?ue[t]:null}var de=50,pe=128,ce=120,fe=120,ve=2e3,_e=120,he=80,me=/* @__PURE__ */new Set(["male","female","unknown"]),ye=/* @__PURE__ */new Set(["day","month","year"]),be=/* @__PURE__ */new Set(["low","medium","high","athletic"]),ge=/* @__PURE__ */new Set(["indoor","outdoor","both"]),we=/* @__PURE__ */new Set(["mild","moderate","severe"]),Se=/^(\d{4})-(\d{2})-(\d{2})$/,Ce=[["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"]],Ee=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];/* @__PURE__ */Object.freeze([...Ce,...Ee].map(([e])=>e));function Te(e){let t=Se.exec(e);if(t===null)return false;let[r,n,a]=[Number(t[1]),Number(t[2]),Number(t[3])],i=new Date(Date.UTC(r,n-1,a));return i.getUTCFullYear()===r&&i.getUTCMonth()===n-1&&i.getUTCDate()===a}var $e=e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,Re=(e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,Ae=(e,t)=>typeof t=="string"&&Te(t)?null:`${e} must be a real date written YYYY-MM-DD`,ke=(e,t={})=>(r,n)=>{if(typeof n!="string")return`${r} must be a string`;if(le(n))return`${r} contains an unpaired surrogate and cannot be encoded`;let a=t.trimmed?n.trim():n;if(t.required&&a.length===0)return`${r} is required and must not be blank`;let i=se(a);return i<=e?null:`${r} is ${i} characters; the server accepts at most ${e}`},Ie={sex:$e(me),spayedNeutered:Re,birthDate:Ae,birthDatePrecision:$e(ye),activityLevel:$e(be),indoorOutdoor:$e(ge),foodBrand:ke(_e),foodType:ke(_e),microchipId:ke(he)},De=["ref","ref",false,ke(pe,{required:true,trimmed:true})],Fe=["notes","notes",false,ke(ve,{trimmed:true})],Oe=[De,["name","name",true,ke(ce,{required:true,trimmed:true})],["dose","dose",false,ke(fe,{trimmed:true})],["frequency","frequency",false,ke(fe,{trimmed:true})],["startDate","start_date",false,Ae],["endDate","end_date",false,Ae],Fe],je={allergies:[De,["allergen","allergen",true,ke(ce,{required:true,trimmed:true})],["severity","severity",false,$e(we)],Fe],medications:Oe,supplements:Oe,conditions:[De,["conditionName","condition_name",true,ke(ce,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,Ae],Fe]};function Ne(e,t,r){let n=`${e}[${t}]`;if(typeof r!="object"||r===null||Array.isArray(r))return{error:`${n} must be an object`};let a=r,i={};for(let[t,r,o,l]of je[e]){let e=a[t];if(e==null){if(o)return{error:`${n}.${t} is required`};e===null&&(i[r]=null);continue}let s=l(`${n}.${t}`,e);if(s!==null)return{error:s};i[r]=e}let o=i.start_date,l=i.end_date;return typeof o=="string"&&typeof l=="string"&&l<o?{error:`${n}.endDate must not be before startDate`}:{item:i}}function xe(e,t){if(!Array.isArray(t))return{error:`${e} must be an array (send [] to clear it)`};if(t.length>de)return{error:`${e} has ${t.length} items; the server accepts at most ${de}`};let r=[],n=/* @__PURE__ */new Set;for(let a=0;a<t.length;a+=1){let i=Ne(e,a,t[a]);if("error"in i)return i;let o=i.item.ref;if(typeof o=="string"){let t=o.trim();if(n.has(t))return{error:`${e}: ref ${JSON.stringify(t)} is used twice; a ref names one item`};n.add(t)}r.push(i.item)}return{items:r}}function Ue(e,t){let r=e,n={};for(let[e,t]of Ce){let a=r[e];if(a!==void 0){if(a!==null){let t=Ie[e](e,a);if(t!==null)return{error:t}}n[t]=a}}let a=r.birthDate!==void 0,i=r.birthDatePrecision!==void 0;if(a!==i||a&&r.birthDate===null!=(r.birthDatePrecision===null))return{error:"birthDate and birthDatePrecision must be sent together, both set or both null"};for(let[e,t]of Ee){let a=r[e];if(a===void 0)continue;let i=xe(e,a);if("error"in i)return i;n[t]=i.items}return Object.keys(n).length>0&&t!==void 0&&canonicalPetSpecies(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}}var qe=e=>typeof e=="string"?e:null,Le=(e,t)=>typeof t=="string"&&e.has(t)?t:null,ze=e=>typeof e=="boolean"?e:null;function Pe(e,t){return Array.isArray(e)?/* @__PURE__ */Object.freeze(e.flatMap(e=>{if(typeof e!="object"||e===null||Array.isArray(e))return[];let r=t(e);return r===null?[]:[r]})):/* @__PURE__ */Object.freeze([])}function Me(e){let t=qe(e.name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:qe(e.ref),name:t,dose:qe(e.dose),frequency:qe(e.frequency),startDate:qe(e.start_date),endDate:qe(e.end_date),notes:qe(e.notes)})}function Ke(e){let t=e.profile_version;/* @__PURE__ */
@@ -1,7 +1,7 @@
1
1
  /*! @everfur/sdk. Copyright (c) 2026 Strand Health Inc. dba Everfur. All rights reserved. Use is subject to the Everfur SDK License: https://docs.everfur.com/license */
2
2
  function ok(e,t){/* @__PURE__ */
3
3
  return Object.freeze({ok:true,value:e})}function err(e){/* @__PURE__ */
4
- return Object.freeze({ok:false,error:e})}var e=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var t=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/;var r="1.5.3";var n="2026-09-19",a="EVERFUR_API_BASE_URL";function i(e,t){/* @__PURE__ */
4
+ return Object.freeze({ok:false,error:e})}var e=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var t=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/;var r="1.6.0";var n="2026-09-19",a="EVERFUR_API_BASE_URL";function i(e,t){/* @__PURE__ */
5
5
  return Object.freeze({ok:false,failure:/* @__PURE__ */Object.freeze({reason:e,message:t})})}function tryResolveApiBaseUrl(e){let t=e?.trim(),r=t&&t.length>0?t:c(a);return r?d(r):i("missing-api-base-url",`apiBaseUrl is required: pass config.apiBaseUrl or set ${a}. The SDK never ships a hardcoded host.`)}function resolveApiBaseUrl(t){let r=tryResolveApiBaseUrl(t);if(!r.ok)throw new e("invalid-argument",r.failure.message);return r.value}function o(e){return e.slice(e.lastIndexOf("@")+1).replace(/:\d+$/,"").toLowerCase()}function l(e){return e.length===0||e.includes("@")?false:e.startsWith("[")&&e.endsWith("]")?true:!e.includes(":")}function s(e,t){let r=e.indexOf("://");return r<0||e.slice(r+3).includes("@")?false:l(t)}function u(e,t){return`${e}://${t}`}function d(e){let r=e.trim(),n=t.exec(r);if(n===null||n[2]===void 0||n[2].length===0)return i("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let a=(n[1]??"").toLowerCase(),l=o(n[2]);if(l.length===0)return i("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let d=s(r,l)?`: ${u(a,l)}`:"";if(a!=="https"){if(!(a==="http"&&p(l)))return a==="http"?i("insecure-api-base-url",`apiBaseUrl must use https (cleartext http is only allowed for localhost)${d}`):i("unsupported-api-base-url-scheme",`apiBaseUrl must be http(s)${d}`)}let c=r.endsWith("/")?r.slice(0,-1):r;/* @__PURE__ */
6
6
  return Object.freeze({ok:true,value:c})}function p(e){let t=e.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="[::1]"||t==="::1"}function c(e){let t=globalThis.process?.env?.[e];return typeof t=="string"&&t.trim().length>0?t.trim():void 0}var f="server";function v(e){return{"X-Everfur-SDK-Version":r,"X-Everfur-SDK-Platform":f,"X-Everfur-Contract":e}}var _="DAILY_QUOTA_EXCEEDED",h=/* @__PURE__ */new Set(["THROTTLINGEXCEPTION","RATELIMITED","TOOMANYREQUESTS"]);function m(e,t){if(!h.has(e.toUpperCase().replace(/[^A-Z0-9]/g,"")))return e;let r=t,n=r?.daily_limit??r?.error?.daily_limit;return typeof n=="number"&&Number.isFinite(n)?_:e}var y=[{wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"DAILY_QUOTA_EXCEEDED",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"FILE_TOO_LARGE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"IDEMPOTENCY_KEY_IN_FLIGHT",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"INVALID_CONTENT_TYPE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"InternalFailureException",envelope:"http_envelope",httpStatus:500,retryable:true},{wireCode:"MethodNotAllowedException",envelope:"http_envelope",httpStatus:405,retryable:false},{wireCode:"NotImplementedException",envelope:"http_envelope",httpStatus:501,retryable:false},{wireCode:"PaymentRequiredException",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ResourceNotFoundException",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"ServiceUnavailableException",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"TIER_UPGRADE_REQUIRED",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ThrottlingException",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"ValidationException",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"accessDenied",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"access_denied",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"anchor_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"anchor_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"anonTokenInvalid",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"attachment_unreadable",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"authExpired",envelope:"http_envelope",httpStatus:401,retryable:true},{wireCode:"authRejected",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"before_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_not_uploaded",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundles_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"catalog_empty_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"catalog_shrink_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"consent_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_required",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_scope_wrong_route",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"device_cipher_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"email_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"endpoint_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"environment_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_cursor_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_payload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_not_available",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_unknown",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_required",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_reused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"inbox_cursor_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"insufficientCapability",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"insufficient_scope",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"internal_error",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"invalidRequest",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"invalid_client",envelope:"oauth_error",httpStatus:401,retryable:false},{wireCode:"invalid_client_metadata",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_grant",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_redirect_uri",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_request",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_scope",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_target",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"item_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"linked_account_read_only",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_connection_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"mcp_request_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_request_gone",envelope:"http_envelope",httpStatus:410,retryable:false},{wireCode:"mcp_request_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"not_found",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"open_url_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"partner_visit_link_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"partner_visit_owner_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"partner_visit_pet_already_mapped",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"payload_too_large",envelope:"http_envelope",httpStatus:413,retryable:false},{wireCode:"petRefInUse",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"pet_health_list_removals_unconfirmed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_health_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_not_registered",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"provider_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"rateLimited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"read_target_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_subject_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"record_upload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"records_consent_required",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"restricted_key",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"sandbox_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_required",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_revoked",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"share_limit_reached",envelope:"http_envelope",httpStatus:429,retryable:false},{wireCode:"slow_down",envelope:"oauth_error",httpStatus:429,retryable:true},{wireCode:"species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"subscription_keys_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"tenant_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"tenant_has_no_capabilities",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tenant_resource_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"tenant_surface_not_enabled",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"ticket_not_resolved",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tickets_disabled",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"timeout",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"timezone_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"token_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"unavailable",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"unrestrictedKeyRequired",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"unsupported_grant_type",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"unsupported_response_type",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"user_ref_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"verify_mint_rate_limited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"verify_mint_refused",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"verify_mint_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"verify_user_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"web_push_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"webhook_endpoint_update_empty",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false}],b=/* @__PURE__ */Object.freeze(y.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(b.map(e=>e.wireCode));var g=/* @__PURE__ */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",session_revoked:"authExpired",anonTokenInvalid:"authRejected",accessDenied:"accessDenied",invalidRequest:"sdkUpdateRequired",authRejected:"authRejected",rateLimited:"rateLimited",insufficientCapability:"accessDenied",unrestrictedKeyRequired:"accessDenied",user_ref_invalid:"validationFailed",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",linked_account_read_only:"conflict",catalog_empty_refused:"conflict",catalog_shrink_refused:"conflict",endpoint_not_allowed:"validationFailed",event_id_invalid:"validationFailed",inbox_cursor_invalid:"validationFailed",item_id_invalid:"validationFailed",open_url_not_allowed:"validationFailed",read_target_invalid:"validationFailed",subscription_keys_invalid:"validationFailed",web_push_unavailable:"serviceUnavailable",anchor_not_found:"resourceNotFound",anchor_ref_invalid:"validationFailed",before_invalid:"validationFailed",bundle_mismatch:"validationFailed",bundle_not_uploaded:"validationFailed",bundles_unavailable:"serviceUnavailable",environment_mismatch:"validationFailed",restricted_key:"accessDenied",ticket_not_resolved:"conflict",tickets_disabled:"resourceNotFound",timezone_invalid:"validationFailed"}),w=/* @__PURE__ */Object.freeze(b.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:g[e.wireCode]}))),S=new Map(w.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),C=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(w.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let e of[t??"http_envelope",...C]){let t=S.get(e+r);if(t)return t}}var E=/* @__PURE__ */Object.freeze({authExpired:"authentication",authRejected:"authentication",sessionRequired:"authentication",identitySignatureRequired:"authentication",accessDenied:"authorization",paymentRequired:"entitlement",quotaExceeded:"rateLimit",rateLimited:"rateLimit",validationFailed:"invalidRequest",sdkUpdateRequired:"invalidRequest",runtimeDisposed:"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 categoryFor(e){return E[e]}function fromWire(e){let t=contractErrorFor(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"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";case"RUNTIMEDISPOSED":return"runtimeDisposed";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"}}function fromHttpStatus(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"}var $=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return $.has(e)}var T=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||T.has(e)}var R="This feature isn't available on your account right now.",A="Something in that request was not right. Check the details and try again.",I=/* @__PURE__ */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:R,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:A,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.",identitySignatureRequired:R,runtimeDisposed:A,unknown:"Something went wrong. Please try again."}),k="This session has ended. Please sign in again.",D="linked_account_read_only";function F(e,t,r){return e==="conflict"&&r===D?R:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?k:userFacingError(e)}function userFacingError(e){return I[e]}function O(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var j=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===D,a={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:F(e,t?.wireCode,n?D:null)};t?.httpStatus!==void 0&&(a.httpStatus=t.httpStatus),t?.requestId&&(a.requestId=t.requestId),typeof t?.reasonCode=="string"&&j.test(t.reasonCode)&&(a.reasonCode=t.reasonCode);let i=t?.retryAfterSeconds;if(typeof i=="number"&&Number.isFinite(i)&&i>=0&&(a.retryAfterSeconds=Math.round(i)),r);return t?.wireMessage&&O(a,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&O(a,"raw",t.raw),/* @__PURE__ */Object.freeze(a)}var N="free_cap_reached";function x(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function U(e){if(typeof e!="object"||e===null)return null;let t=e,r=t.detail,n=typeof r=="object"&&r!==null?r:t;if(n.error!==N&&n.code!==N)return null;let a=x(n.limit),i=x(n.used);if(a===null||i===null)return null;let o=n.resets_at,l=n.emergency_guidance;/* @__PURE__ */
7
7
  return Object.freeze({limit:a,used:i,resetsAt:typeof o=="string"&&o.length>0?o:null,...typeof l=="string"&&l.trim().length>0?{emergencyGuidance:l}:{}})}function q(e,t){if(e.status!==429&&e.status!==503)return t;let r=z(e.headers.get(L),Date.now());if(r===null)return t;let n=t!==null&&typeof t=="object"&&!Array.isArray(t)?t:null;return n!==null&&P(n)?t:{...n??{},retry_after_seconds:r}}var L="retry-after";function z(e,t){if(e===null)return null;let r=e.trim();if(/^\d+$/.test(r))return Number(r);let n=Date.parse(r);return Number.isFinite(n)?Math.max(0,Math.ceil((n-t)/1e3)):null}function P(e){return[e,e.error,e.detail].some(e=>e!==null&&typeof e=="object"&&("retry_after_seconds"in e||"resets_at"in e))}var M="x-request-id";function errorFromResponse(e,t,r){let n=Y(t),a=n?fromWire(n):fromHttpStatus(e),i=V(t);return makeEverfurError(a,{httpStatus:e,...W(t)?{retryable:true}:{},...r?{requestId:r}:{},...n?{wireCode:n}:{},...B(t)?{reasonCode:B(t)}:{},...K(t)!==null?{retryAfterSeconds:K(t)}:{},...i?{wireMessage:i}:{},...t!=null?{raw:t}:{}})}function K(e){let t=e,r=t?.retry_after_seconds??t?.error?.retry_after_seconds;return typeof r=="number"&&Number.isFinite(r)&&r>=0?r:null}function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:Z(e)})}function requestIdOf(e){let t=e.headers.get(M);return typeof t=="string"&&t.length>0?t:null}function getGlobalFetch(){let t=globalThis.fetch;if(typeof t!="function")throw new e("missing-peer-dependency","global fetch is unavailable; provide config.transport or an injected fetch implementation");return t}function B(e){let t=e,r=t?.error?.reason_code??t?.reason_code;return typeof r=="string"&&r.length>0?r:null}function Y(e){let t=e,r=t?.error?.code??t?.code;return typeof r=="string"&&r.length>0?m(r,e):U(e)!==null?N:null}function V(e){let t=e,r=t?.error?.message??t?.message;return typeof r=="string"&&r.length>0?r:null}function W(e){let t=e;return t?.error?.retryable===true||t?.retryable===true}function Z(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var G=["sk_partner_","rk_partner_"];function Q(t,r){if(typeof t!="string"||t.length===0)throw new e("invalid-argument","partnerSecretKey is required");if(t.startsWith("pk_"))throw new e("invalid-argument",`partnerSecretKey is a publishable key (pk_...): ${r} needs your secret key, server side only`);if(!G.some(e=>t.startsWith(e)))throw new e("invalid-argument","partnerSecretKey must be an sk_partner_ secret key or an rk_partner_ restricted key")}var X=128;function assertValidUserRef(t){let r=typeof t=="string"?[...t].length:0;if(typeof t!="string"||r<1||r>X)throw new e("invalid-argument",`user_ref must be 1..${X} characters`);if(t.trim().length===0)throw new e("invalid-argument","user_ref must not be blank: the server strips surrounding whitespace before validating, so a whitespace-only value arrives empty and is rejected as required.");if(t!==t.trim())throw new e("invalid-argument","user_ref must not have leading or trailing whitespace: the server strips it, so padded and unpadded forms of the same id resolve to ONE user. Pass the exact id you want to key on.");if(t.includes("@"))throw new e("invalid-argument","user_ref must not contain '@'");if(!H(t))throw new e("invalid-argument","user_ref must be printable (no control characters)");return t}function H(e){return!J.test(e)}var J=/[\p{Cc}\p{Cf}\p{Cs}\p{Co}\p{Cn}\p{Zl}\p{Zp}]|(?!\u0020)[\p{Zs}]/u,ee="user_ref_invalid";function te(e){let t=e.raw,r=typeof t=="object"&&t!==null?t:null,n=(r!==null&&typeof r.error=="object"&&r.error!==null?r.error.code:void 0)??r?.code;return n!==ee&&e.reasonCode!==ee?e:makeEverfurError("validationFailed",{retryable:false,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId!==void 0?{requestId:e.requestId}:{},...typeof n=="string"?{wireCode:n}:{},reasonCode:ee,...e.wireMessage!==void 0?{wireMessage:e.wireMessage}:{},...t!==void 0?{raw:t}:{}})}function re(e){let t=e.raw;if(typeof t!="object"||t===null)return null;let r=t.code;return typeof r=="string"&&r.length>0?r:null}function ne(e,t){let r=re(e);if(r===null)return e;let n=t[r];return n===void 0?e:makeEverfurError(n.code,{retryable:n.retryable,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId!==void 0?{requestId:e.requestId}:{},wireCode:r,reasonCode:r,...e.wireMessage!==void 0?{wireMessage:e.wireMessage}:{},raw:e.raw})}function ae(e,t){let r=ne(e,t);if(r!==e||re(e)!==null)return r;let n=e.reasonCode;if(typeof n!="string")return e;let a=t[n];return a===void 0?e:makeEverfurError(a.code,{retryable:a.retryable,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId!==void 0?{requestId:e.requestId}:{},wireCode:n,reasonCode:n,...e.wireMessage!==void 0?{wireMessage:e.wireMessage}:{},raw:e.raw})}var ie=64;function oe(t){if(t!=null){if(typeof t!="string"||t.length===0||t.length>ie||/\s/.test(t))throw new e("invalid-argument",`timezone must be an IANA zone name such as 'America/Chicago' (at most ${ie} characters)`);return t}}function le(e){for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let r=e.charCodeAt(t+1);if(!(r>=56320&&r<=57343))return true;t+=1}else if(r>=56320&&r<=57343)return true}return false}function se(e){return[...e].length}var ue=/* @__PURE__ */Object.freeze({dog:"dog",canine:"dog",k9:"dog",puppy:"dog",cat:"cat",feline:"cat",kitten:"cat"});function canonicalPetSpecies(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.prototype.hasOwnProperty.call(ue,t)?ue[t]:null}var de=50,pe=128,ce=120,fe=120,ve=2e3,_e=120,he=80,me=/* @__PURE__ */new Set(["male","female","unknown"]),ye=/* @__PURE__ */new Set(["day","month","year"]),be=/* @__PURE__ */new Set(["low","medium","high","athletic"]),ge=/* @__PURE__ */new Set(["indoor","outdoor","both"]),we=/* @__PURE__ */new Set(["mild","moderate","severe"]),Se=/^(\d{4})-(\d{2})-(\d{2})$/,Ce=[["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"]],Ee=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];/* @__PURE__ */Object.freeze([...Ce,...Ee].map(([e])=>e));function $e(e){let t=Se.exec(e);if(t===null)return false;let[r,n,a]=[Number(t[1]),Number(t[2]),Number(t[3])],i=new Date(Date.UTC(r,n-1,a));return i.getUTCFullYear()===r&&i.getUTCMonth()===n-1&&i.getUTCDate()===a}var Te=e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,Re=(e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,Ae=(e,t)=>typeof t=="string"&&$e(t)?null:`${e} must be a real date written YYYY-MM-DD`,Ie=(e,t={})=>(r,n)=>{if(typeof n!="string")return`${r} must be a string`;if(le(n))return`${r} contains an unpaired surrogate and cannot be encoded`;let a=t.trimmed?n.trim():n;if(t.required&&a.length===0)return`${r} is required and must not be blank`;let i=se(a);return i<=e?null:`${r} is ${i} characters; the server accepts at most ${e}`},ke={sex:Te(me),spayedNeutered:Re,birthDate:Ae,birthDatePrecision:Te(ye),activityLevel:Te(be),indoorOutdoor:Te(ge),foodBrand:Ie(_e),foodType:Ie(_e),microchipId:Ie(he)},De=["ref","ref",false,Ie(pe,{required:true,trimmed:true})],Fe=["notes","notes",false,Ie(ve,{trimmed:true})],Oe=[De,["name","name",true,Ie(ce,{required:true,trimmed:true})],["dose","dose",false,Ie(fe,{trimmed:true})],["frequency","frequency",false,Ie(fe,{trimmed:true})],["startDate","start_date",false,Ae],["endDate","end_date",false,Ae],Fe],je={allergies:[De,["allergen","allergen",true,Ie(ce,{required:true,trimmed:true})],["severity","severity",false,Te(we)],Fe],medications:Oe,supplements:Oe,conditions:[De,["conditionName","condition_name",true,Ie(ce,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,Ae],Fe]};function Ne(e,t,r){let n=`${e}[${t}]`;if(typeof r!="object"||r===null||Array.isArray(r))return{error:`${n} must be an object`};let a=r,i={};for(let[t,r,o,l]of je[e]){let e=a[t];if(e==null){if(o)return{error:`${n}.${t} is required`};e===null&&(i[r]=null);continue}let s=l(`${n}.${t}`,e);if(s!==null)return{error:s};i[r]=e}let o=i.start_date,l=i.end_date;return typeof o=="string"&&typeof l=="string"&&l<o?{error:`${n}.endDate must not be before startDate`}:{item:i}}function xe(e,t){if(!Array.isArray(t))return{error:`${e} must be an array (send [] to clear it)`};if(t.length>de)return{error:`${e} has ${t.length} items; the server accepts at most ${de}`};let r=[],n=/* @__PURE__ */new Set;for(let a=0;a<t.length;a+=1){let i=Ne(e,a,t[a]);if("error"in i)return i;let o=i.item.ref;if(typeof o=="string"){let t=o.trim();if(n.has(t))return{error:`${e}: ref ${JSON.stringify(t)} is used twice; a ref names one item`};n.add(t)}r.push(i.item)}return{items:r}}function Ue(e,t){let r=e,n={};for(let[e,t]of Ce){let a=r[e];if(a!==void 0){if(a!==null){let t=ke[e](e,a);if(t!==null)return{error:t}}n[t]=a}}let a=r.birthDate!==void 0,i=r.birthDatePrecision!==void 0;if(a!==i||a&&r.birthDate===null!=(r.birthDatePrecision===null))return{error:"birthDate and birthDatePrecision must be sent together, both set or both null"};for(let[e,t]of Ee){let a=r[e];if(a===void 0)continue;let i=xe(e,a);if("error"in i)return i;n[t]=i.items}return Object.keys(n).length>0&&t!==void 0&&canonicalPetSpecies(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}}var qe=e=>typeof e=="string"?e:null,Le=(e,t)=>typeof t=="string"&&e.has(t)?t:null,ze=e=>typeof e=="boolean"?e:null;function Pe(e,t){return Array.isArray(e)?/* @__PURE__ */Object.freeze(e.flatMap(e=>{if(typeof e!="object"||e===null||Array.isArray(e))return[];let r=t(e);return r===null?[]:[r]})):/* @__PURE__ */Object.freeze([])}function Me(e){let t=qe(e.name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:qe(e.ref),name:t,dose:qe(e.dose),frequency:qe(e.frequency),startDate:qe(e.start_date),endDate:qe(e.end_date),notes:qe(e.notes)})}function Ke(e){let t=e.profile_version;/* @__PURE__ */
@@ -5,7 +5,7 @@ export { B as Brand, P as PetRef, R as RecordsRequestId, _ as __brand } from '..
5
5
  export { c as EverfurFontSource, d as EverfurFontWeight } from '../../tokens.d-DDiPRgye.cjs';
6
6
  export { C as ClientBranding, R as RadiusScale, S as SurfaceStyle } from '../../branding.d-CqDLKj1U.cjs';
7
7
  export { b as CapabilityDisabled, D as DisabledLevel, E as EntitlementDecision } from '../../resolve.d-BTC3b6FW.cjs';
8
- export { f as EntitlementSnapshot } from '../../runtimeTypes.d-CL4l7ta4.cjs';
8
+ export { f as EntitlementSnapshot } from '../../runtimeTypes.d-BSxuUCOX.cjs';
9
9
  export { l as RecordsRequestStatus, e as RecordsRequestView, m as RecordsSimpleStatus } from '../../models.d-D75NFs32.cjs';
10
10
  import { ReactNode } from 'react';
11
11
  import { R as RiskTier } from '../../PhotoController.d-Cb8Juile.cjs';
@@ -17,7 +17,7 @@ import '../../config.d-ClAI2RZ6.cjs';
17
17
  import '../../profile.d-CSs1wlXT.cjs';
18
18
  import '../../ErrorPolicyPort.d-BIdmYQnk.cjs';
19
19
  import '../../cacheEpoch.d-DknKn3S0.cjs';
20
- import '../../checkin.d-BP3ZWBfX.cjs';
20
+ import '../../checkin.d-CuIUahcd.cjs';
21
21
  import '../../casesRepository.d-CVuKTkJo.cjs';
22
22
  import '../../requestFunnel.d-BwZDfWVD.cjs';
23
23
  import '../../TelemetryPort.d-BDNr00hu.cjs';
@@ -5,7 +5,7 @@ export { B as Brand, P as PetRef, R as RecordsRequestId, _ as __brand } from '..
5
5
  export { c as EverfurFontSource, d as EverfurFontWeight } from '../../tokens.d-DDiPRgye.js';
6
6
  export { C as ClientBranding, R as RadiusScale, S as SurfaceStyle } from '../../branding.d-XrZYClN4.js';
7
7
  export { b as CapabilityDisabled, D as DisabledLevel, E as EntitlementDecision } from '../../resolve.d-BTC3b6FW.js';
8
- export { f as EntitlementSnapshot } from '../../runtimeTypes.d-BzUig75K.js';
8
+ export { f as EntitlementSnapshot } from '../../runtimeTypes.d-hjN6xvxm.js';
9
9
  export { l as RecordsRequestStatus, e as RecordsRequestView, m as RecordsSimpleStatus } from '../../models.d-C7d9Li6n.js';
10
10
  import { ReactNode } from 'react';
11
11
  import { R as RiskTier } from '../../PhotoController.d-BrFJ2lAc.js';
@@ -17,7 +17,7 @@ import '../../config.d-B7Z-KTGq.js';
17
17
  import '../../profile.d-CSs1wlXT.js';
18
18
  import '../../ErrorPolicyPort.d-BnI5qWg4.js';
19
19
  import '../../cacheEpoch.d-DknKn3S0.js';
20
- import '../../checkin.d-CokpahFL.js';
20
+ import '../../checkin.d-BoZXWjxX.js';
21
21
  import '../../casesRepository.d-Dn1fK1b2.js';
22
22
  import '../../requestFunnel.d-DKBPTpsy.js';
23
23
  import '../../TelemetryPort.d-BDNr00hu.js';
@@ -1,5 +1,5 @@
1
1
  /*! @everfur/sdk. Copyright (c) 2026 Strand Health Inc. dba Everfur. All rights reserved. Use is subject to the Everfur SDK License: https://docs.everfur.com/license */
2
- import { f as EntitlementSnapshot } from '../../runtimeTypes.d-CL4l7ta4.cjs';
2
+ import { f as EntitlementSnapshot } from '../../runtimeTypes.d-BSxuUCOX.cjs';
3
3
  import { E as EverfurResult } from '../../EverfurResult.d-BFH-3s6E.cjs';
4
4
  import { R as RecordsRequestId, P as PetRef } from '../../ids.d-B2GAAifq.cjs';
5
5
  export { B as Brand, _ as __brand } from '../../ids.d-B2GAAifq.cjs';
@@ -15,7 +15,7 @@ import '../../config.d-ClAI2RZ6.cjs';
15
15
  import '../../profile.d-CSs1wlXT.cjs';
16
16
  import '../../ErrorPolicyPort.d-BIdmYQnk.cjs';
17
17
  import '../../cacheEpoch.d-DknKn3S0.cjs';
18
- import '../../checkin.d-BP3ZWBfX.cjs';
18
+ import '../../checkin.d-CuIUahcd.cjs';
19
19
  import '../../casesRepository.d-CVuKTkJo.cjs';
20
20
  import '../../requestFunnel.d-BwZDfWVD.cjs';
21
21
  import '../../TelemetryPort.d-BDNr00hu.cjs';
@@ -1,5 +1,5 @@
1
1
  /*! @everfur/sdk. Copyright (c) 2026 Strand Health Inc. dba Everfur. All rights reserved. Use is subject to the Everfur SDK License: https://docs.everfur.com/license */
2
- import { f as EntitlementSnapshot } from '../../runtimeTypes.d-BzUig75K.js';
2
+ import { f as EntitlementSnapshot } from '../../runtimeTypes.d-hjN6xvxm.js';
3
3
  import { E as EverfurResult } from '../../EverfurResult.d-D_-254ZY.js';
4
4
  import { R as RecordsRequestId, P as PetRef } from '../../ids.d-B2GAAifq.js';
5
5
  export { B as Brand, _ as __brand } from '../../ids.d-B2GAAifq.js';
@@ -15,7 +15,7 @@ import '../../config.d-B7Z-KTGq.js';
15
15
  import '../../profile.d-CSs1wlXT.js';
16
16
  import '../../ErrorPolicyPort.d-BnI5qWg4.js';
17
17
  import '../../cacheEpoch.d-DknKn3S0.js';
18
- import '../../checkin.d-CokpahFL.js';
18
+ import '../../checkin.d-BoZXWjxX.js';
19
19
  import '../../casesRepository.d-Dn1fK1b2.js';
20
20
  import '../../requestFunnel.d-DKBPTpsy.js';
21
21
  import '../../TelemetryPort.d-BDNr00hu.js';
@@ -3,11 +3,11 @@ import { ReactNode } from 'react';
3
3
  import { StyleProp, ViewStyle } from 'react-native';
4
4
  import { P as PetRef, C as ConversationId } from './ids.d-B2GAAifq.js';
5
5
  import { i as EverfurPresentationInput } from './presentation.d-BkIvMtIl.js';
6
- import { a as ChatCheckinTarget } from './checkin.d-CokpahFL.js';
6
+ import { a as ChatCheckinTarget } from './checkin.d-BoZXWjxX.js';
7
7
  import { W as WidgetPet, P as PetProfileInput } from './petsRepository.d-_QfM7F6T.js';
8
8
  import { E as EverfurStarterPrompt } from './quickPrompts.d-NM_81Jc1.js';
9
9
  import { L as LifecyclePort } from './LifecyclePort.d-Cb9NtmP-.js';
10
- import { U as UrgencyDisplayLevel, E as EverfurChatDraftStore, b as ChatFollowUpPolicy, i as UseEverfurUnreadOptions, d as EverfurUnreadState } from './chatHandoffToken.d-CFiI6IMc.js';
10
+ import { U as UrgencyDisplayLevel, E as EverfurChatDraftStore, b as ChatFollowUpPolicy, i as UseEverfurUnreadOptions, d as EverfurUnreadState } from './chatHandoffToken.d-zdp23Ukr.js';
11
11
  import { F as FileHandle } from './ports.d-BX4f4UsB.js';
12
12
  import { g as EverfurChatOpeningCard, a as EverfurChatAnswerCards, f as EverfurChatHistorySheet, e as EverfurChatHistoryBar, c as EverfurChatEmptyState } from './threadOptions.d-DOEIpk1t.js';
13
13
  import { E as EverfurChatEmptyHeaderContext, a as EverfurChatTopCard } from './threadOptions.d-CW51PyVd.js';
@@ -295,6 +295,33 @@ type EverfurDictationLoader = () => unknown;
295
295
  */
296
296
  declare function registerEverfurDictation(next: EverfurDictationLoader | null): void;
297
297
 
298
+ /**
299
+ * What `registerEverfurChatCards` takes: a function that returns the `@everfur/sdk/chat-cards` module, or a promise of
300
+ * it (`() => import('@everfur/sdk/chat-cards')`).
301
+ *
302
+ * Everfur internal preview, not part of the partner API: it may change or go away in any release, and the platform
303
+ * sends cards only to tenants Everfur enables.
304
+ *
305
+ * @internal
306
+ */
307
+ type EverfurChatCardsLoader = () => {
308
+ readonly ServerCards: unknown;
309
+ } | Promise<{
310
+ readonly ServerCards: unknown;
311
+ }>;
312
+ /**
313
+ * Turns on server-sent chat cards (A2UI) on React Native: register the `@everfur/sdk/chat-cards` loader once, in your
314
+ * app entry, before the chat mounts. Passing `null` unregisters it. The module starts loading here; chat sends ask for
315
+ * cards only once it has loaded, so a loader that fails never asks for any. A chat already on screen reads the change
316
+ * on its next render.
317
+ *
318
+ * Everfur internal preview, not part of the partner API: it may change or go away in any release, and the platform
319
+ * sends cards only to tenants Everfur enables.
320
+ *
321
+ * @internal
322
+ */
323
+ declare function registerEverfurChatCards(next: EverfurChatCardsLoader | null): void;
324
+
298
325
  /** The app's foreground edge for EverfurChat: AppState going from `background` back to `active`. */
299
326
  declare function createAppStateLifecycle(): LifecyclePort;
300
327
 
@@ -305,4 +332,4 @@ declare function createAppStateLifecycle(): LifecyclePort;
305
332
  */
306
333
  declare function useEverfurUnread(options?: UseEverfurUnreadOptions): EverfurUnreadState;
307
334
 
308
- export { type AttachmentSource as A, type EverfurChatAttachments as E, type RenderVetAction as R, type EverfurChatProps as a, type EverfurDictationLoader as b, createAppStateLifecycle as c, registerEverfurDictation as r, useEverfurUnread as u };
335
+ export { type AttachmentSource as A, type EverfurChatAttachments as E, type RenderVetAction as R, type EverfurChatCardsLoader as a, type EverfurChatProps as b, type EverfurDictationLoader as c, createAppStateLifecycle as d, registerEverfurDictation as e, registerEverfurChatCards as r, useEverfurUnread as u };
@@ -3,11 +3,11 @@ import { ReactNode } from 'react';
3
3
  import { StyleProp, ViewStyle } from 'react-native';
4
4
  import { P as PetRef, C as ConversationId } from './ids.d-B2GAAifq.cjs';
5
5
  import { i as EverfurPresentationInput } from './presentation.d-BkIvMtIl.cjs';
6
- import { a as ChatCheckinTarget } from './checkin.d-BP3ZWBfX.cjs';
6
+ import { a as ChatCheckinTarget } from './checkin.d-CuIUahcd.cjs';
7
7
  import { W as WidgetPet, P as PetProfileInput } from './petsRepository.d-ai_tZ3lu.cjs';
8
8
  import { E as EverfurStarterPrompt } from './quickPrompts.d-NM_81Jc1.cjs';
9
9
  import { L as LifecyclePort } from './LifecyclePort.d-Cb9NtmP-.cjs';
10
- import { U as UrgencyDisplayLevel, E as EverfurChatDraftStore, b as ChatFollowUpPolicy, i as UseEverfurUnreadOptions, d as EverfurUnreadState } from './chatHandoffToken.d-BjfmIxXk.cjs';
10
+ import { U as UrgencyDisplayLevel, E as EverfurChatDraftStore, b as ChatFollowUpPolicy, i as UseEverfurUnreadOptions, d as EverfurUnreadState } from './chatHandoffToken.d-Cap2z62P.cjs';
11
11
  import { F as FileHandle } from './ports.d-BX4f4UsB.cjs';
12
12
  import { g as EverfurChatOpeningCard, a as EverfurChatAnswerCards, f as EverfurChatHistorySheet, e as EverfurChatHistoryBar, c as EverfurChatEmptyState } from './threadOptions.d-Bqy5d5Fx.cjs';
13
13
  import { E as EverfurChatEmptyHeaderContext, a as EverfurChatTopCard } from './threadOptions.d-CW51PyVd.cjs';
@@ -295,6 +295,33 @@ type EverfurDictationLoader = () => unknown;
295
295
  */
296
296
  declare function registerEverfurDictation(next: EverfurDictationLoader | null): void;
297
297
 
298
+ /**
299
+ * What `registerEverfurChatCards` takes: a function that returns the `@everfur/sdk/chat-cards` module, or a promise of
300
+ * it (`() => import('@everfur/sdk/chat-cards')`).
301
+ *
302
+ * Everfur internal preview, not part of the partner API: it may change or go away in any release, and the platform
303
+ * sends cards only to tenants Everfur enables.
304
+ *
305
+ * @internal
306
+ */
307
+ type EverfurChatCardsLoader = () => {
308
+ readonly ServerCards: unknown;
309
+ } | Promise<{
310
+ readonly ServerCards: unknown;
311
+ }>;
312
+ /**
313
+ * Turns on server-sent chat cards (A2UI) on React Native: register the `@everfur/sdk/chat-cards` loader once, in your
314
+ * app entry, before the chat mounts. Passing `null` unregisters it. The module starts loading here; chat sends ask for
315
+ * cards only once it has loaded, so a loader that fails never asks for any. A chat already on screen reads the change
316
+ * on its next render.
317
+ *
318
+ * Everfur internal preview, not part of the partner API: it may change or go away in any release, and the platform
319
+ * sends cards only to tenants Everfur enables.
320
+ *
321
+ * @internal
322
+ */
323
+ declare function registerEverfurChatCards(next: EverfurChatCardsLoader | null): void;
324
+
298
325
  /** The app's foreground edge for EverfurChat: AppState going from `background` back to `active`. */
299
326
  declare function createAppStateLifecycle(): LifecyclePort;
300
327
 
@@ -305,4 +332,4 @@ declare function createAppStateLifecycle(): LifecyclePort;
305
332
  */
306
333
  declare function useEverfurUnread(options?: UseEverfurUnreadOptions): EverfurUnreadState;
307
334
 
308
- export { type AttachmentSource as A, type EverfurChatAttachments as E, type RenderVetAction as R, type EverfurChatProps as a, type EverfurDictationLoader as b, createAppStateLifecycle as c, registerEverfurDictation as r, useEverfurUnread as u };
335
+ export { type AttachmentSource as A, type EverfurChatAttachments as E, type RenderVetAction as R, type EverfurChatCardsLoader as a, type EverfurChatProps as b, type EverfurDictationLoader as c, createAppStateLifecycle as d, registerEverfurDictation as e, registerEverfurChatCards as r, useEverfurUnread as u };
@@ -3,7 +3,7 @@
3
3
  "use strict";var e=require("react"),t=require("react/jsx-runtime"),i=require("react-dom");function r(e){if(typeof e=="number")return a(e);if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;if(t.startsWith("#"))return n(t.slice(1));if(t.toLowerCase().startsWith("0x"))return n(t.slice(2));if(t.toLowerCase().startsWith("rgb"))return o(t);if(/^[0-9a-fA-F]+$/.test(t)){let e=n(t);if(e!==null)return e}return/^\d+$/.test(t)?a(Number.parseInt(t,10)):null}function n(e){let t=e.trim();if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===3)return{r:l(t[0]),g:l(t[1]),b:l(t[2]),a:1};if(t.length===6)return{r:s(t,0),g:s(t,2),b:s(t,4),a:1};if(t.length===8){let e=s(t,0);return{r:s(t,2),g:s(t,4),b:s(t,6),a:e/255}}return null}function o(e){let t=e.indexOf("("),i=e.indexOf(")");if(t<0||i<0||i<t)return null;let r=e.slice(t+1,i).split(",").map(e=>e.trim());if(r.length<3)return null;let n=u(Number(r[0])),o=u(Number(r[1])),a=u(Number(r[2]));if(n===null||o===null||a===null)return null;let s=1;if(r.length>=4){let e=Number(r[3]);if(!Number.isFinite(e))return null;s=Math.min(1,Math.max(0,e))}return{r:n,g:o,b:a,a:s}}function a(e){if(!Number.isFinite(e))return null;let t=Math.trunc(e)>>>0,i=t>>>24&255;return{r:t>>>16&255,g:t>>>8&255,b:t&255,a:i===0?1:i/255}}function s(e,t){return Number.parseInt(e.slice(t,t+2),16)}function l(e){return Number.parseInt(`${e??"0"}${e??"0"}`,16)}function u(e){return Number.isFinite(e)?Math.min(255,Math.max(0,Math.round(e))):null}function c(e,t,i){return`#${d(e)}${d(t)}${d(i)}`.toUpperCase()}function d(e){return e.toString(16).padStart(2,"0")}var p="#111111",f="#FFFFFF",m="#000000";function readableOn(e){let t=r(e);if(t===null)return f;let i=b(t),n=b({r:17,g:17,b:17}),o=b({r:255,g:255,b:255});return x(i,o)>=x(i,n)?f:p}function h(e,t){let i=readableOn(e);return contrastRatio(i,e)>=t?i:contrastRatio(f,e)>=contrastRatio(m,e)?f:m}function g(e){let t=t=>e.reduce((e,i)=>Math.min(e,contrastRatio(t,i)),Number.POSITIVE_INFINITY);return t(f)>=t(m)?f:m}function b(e){let t=v(e.r/255),i=v(e.g/255),r=v(e.b/255);return.2126*t+.7152*i+.0722*r}function v(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}function x(e,t){let i=Math.max(e,t),r=Math.min(e,t);return(i+.05)/(r+.05)}function contrastRatio(e,t){let i=r(e),n=r(t);if(i===null||n===null)return 1;let o=n.a>=1?n:{...n},a=i.a>=1?i:y(i,o);return x(b(a),b(o))}function y(e,t){let i=e.a,r=(e,t)=>Math.round(e*i+t*(1-i));return{r:r(e.r,t.r),g:r(e.g,t.g),b:r(e.b,t.b),a:1}}function w(e,t){let i=r(e),n=r(t);if(i===null||n===null)return null;let o=i.a>=1?i:y(i,{...n});return c(o.r,o.g,o.b)}function k(e,t){let i=r(e);if(i===null)return null;let n=Math.min(1,Math.max(0,t));return`rgba(${i.r}, ${i.g}, ${i.b}, ${n})`}var _=.05;function j(e,t,i,n){let o=t[0];if(o===void 0)return i;let a=e=>t.every(t=>contrastRatio(e,t)>=n);if(r(e)===null)return i;if(a(e))return e;let s=w(e,o),l=s===null?null:r(s),u=r(i);if(l===null||u===null)return i;for(let e=1;e<1/_;e+=1){let t=e*_,i=(e,i)=>Math.round(e+(i-e)*t),r=c(i(l.r,u.r),i(l.g,u.g),i(l.b,u.b));if(a(r))return r}return i}var z=/* @__PURE__ */Object.freeze({display:/* @__PURE__ */Object.freeze({size:29,lineHeight:1.06,weight:"800",face:"heading",letterSpacing:-.01,uppercase:false,tier:"heading"}),title:/* @__PURE__ */Object.freeze({size:23,lineHeight:1.12,weight:"800",face:"heading",letterSpacing:-.01,uppercase:false,tier:"heading"}),cardTitle:/* @__PURE__ */Object.freeze({size:19,lineHeight:1.22,weight:"800",face:"sans",letterSpacing:0,uppercase:false,tier:"heading"}),rowTitle:/* @__PURE__ */Object.freeze({size:15.5,lineHeight:1.4,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),body:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),message:/* @__PURE__ */Object.freeze({size:15.5,lineHeight:1.5,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),bodySmall:/* @__PURE__ */Object.freeze({size:14.5,lineHeight:1.4,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),caption:/* @__PURE__ */Object.freeze({size:13,lineHeight:1.4,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),label:/* @__PURE__ */Object.freeze({size:10.5,lineHeight:1.4,weight:"400",face:"mono",letterSpacing:.05,uppercase:true,tier:"compact"}),eyebrow:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"400",face:"mono",letterSpacing:.07,uppercase:true,tier:"compact"}),chip:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.3,weight:"600",face:"sans",letterSpacing:0,uppercase:false,tier:"compact"}),tab:/* @__PURE__ */Object.freeze({size:16,lineHeight:1.5,weight:"600",face:"sans",letterSpacing:0,uppercase:false,tier:"compact"}),button:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"control"}),badge:/* @__PURE__ */Object.freeze({size:12,lineHeight:1.5,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"badge"})});var C=Object.freeze;function deepFreeze(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){C(e);for(let t of Object.keys(e))deepFreeze(e[t])}return e}var S=/* @__PURE__ */Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3});var P={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},T={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},F={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},$={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},O={regular:"400",medium:"500",bold:"700"},E={eyebrow:1,monoWide:.9,headerBrand:-.42,tight:-.35},I=0,L="System",H="monospace",R=["content","heading","control","compact","badge"];function D(e){let t={};for(let i of R)t[i]=e;return t}var N=[];function B(){return{family:L,mono:H,fontUrl:null,families:{regular:L,medium:L,bold:L,mono:H,monoMedium:H,monoBold:H},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:F,tierSizes:D(F),lineHeight:$,weight:O,letterSpacing:E,scale:1,maxScale:I,scaleCaps:S,headingFamily:null,headingWeight:null,fontSources:N,roles:z,typeScale:1}}var A={},M=/* @__PURE__ */Object.freeze({standard:/* @__PURE__ */Object.freeze([.2,0,0,1]),emphasized:/* @__PURE__ */Object.freeze([.2,.8,.2,1]),exit:/* @__PURE__ */Object.freeze([.4,0,1,1])});function cssCubicBezier(e){return`cubic-bezier(${e.join(", ")})`}var W={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:cssCubicBezier(M.standard),emphasized:cssCubicBezier(M.emphasized),exit:cssCubicBezier(M.exit)},reducedMotion:false},q={brand:"#10462E",brandSoft:"rgba(16,70,46,0.10)",brandSofter:"rgba(16,70,46,0.15)",brandBorder:"rgba(16,70,46,0.18)",borderHairlineGreen:"rgba(16,70,46,0.25)",brandBorderStrong:"rgba(16,70,46,0.55)",brandInk:"#10462E",linkInk:"#10462E",surface:"#FFFFFF",surfaceCream:"#FFFFFF",surfaceSubtle:"#F1F5F2",background:"#FFFFFF",borderRingCream:"#E4E4E4",chatGround:"#FFFFFF",composerFill:"#FFFFFF",composerBorder:"rgba(16,70,46,0.75)",shadow:"#0B3421",text:{primary:"#000000",secondary:"#0E462E",muted:"#6B6B6B",placeholder:"rgba(61,61,61,0.75)",onBrand:"#FFFFFF",metaCool:"#3D3D3D",timestamp:"rgba(61,61,61,0.75)"},primary:"#10462E",onPrimary:"#FFFFFF",accent:"#10462E",onAccent:"#FFFFFF",accentEdge:"#07C168",success:"#07C168",danger:"#C03410",onDanger:"#FFFFFF",errorRed:"#C03410",warningStrong:"#A45610",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.12)",badgeBgCaution:"rgba(217,130,29,0.14)",badgeBgCritical:"rgba(192,52,16,0.06)",badgeBgNeutral:"rgba(107,107,107,0.12)",bubbleUser:"#10462E",bubbleAssistant:"#FFFFFF",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#E9F1E9",scanButtonPink:"#FFC3BC",highlight:"#FFC3BC",onHighlight:"#000000",mark:"#07C168",controlEdge:"rgba(16,70,46,0.18)",structureEdge:"rgba(16,70,46,0.25)",primaryEdge:"#10462E",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)",info:"#10462E",badgeBgInfo:"rgba(16,70,46,0.10)",infoEdge:"rgba(16,70,46,0.25)"},U=deepFreeze({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:q,space:P,radius:T,type:B(),motion:W,slots:A}),K={brand:"#6BD39A",brandSoft:"rgba(107,211,154,0.12)",brandSofter:"rgba(107,211,154,0.18)",brandBorder:"rgba(107,211,154,0.22)",borderHairlineGreen:"rgba(107,211,154,0.28)",brandBorderStrong:"rgba(107,211,154,0.55)",brandInk:"#6BD39A",linkInk:"#6BD39A",surface:"#1C1F23",surfaceCream:"#23272C",surfaceSubtle:"#23272C",background:"#15171A",borderRingCream:"#3A3F45",chatGround:"#1C1F23",composerFill:"#23272C",composerBorder:"rgba(107,211,154,0.75)",shadow:"#000000",text:{primary:"#F5F3F0",secondary:"#A9E4C4",muted:"#9A9A9A",placeholder:"rgba(255,255,255,0.55)",onBrand:"#0E1F17",metaCool:"#C9C9C9",timestamp:"rgba(245,243,240,0.7)"},primary:"#6BD39A",onPrimary:"#0E1F17",accent:"#6BD39A",onAccent:"#0E1F17",accentEdge:"#34D888",success:"#07C168",danger:"#F87171",onDanger:"#0E1F17",errorRed:"#FF6B5B",warningStrong:"#F0A35E",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.18)",badgeBgCaution:"rgba(217,130,29,0.20)",badgeBgCritical:"rgba(185,28,28,0.22)",badgeBgNeutral:"rgba(255,255,255,0.10)",bubbleUser:"#6BD39A",bubbleAssistant:"#1C1F23",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#23272C",scanButtonPink:"#FFC3BC",highlight:"#605051",onHighlight:"#F5F3F0",mark:"#07C168",controlEdge:"rgba(107,211,154,0.22)",structureEdge:"rgba(107,211,154,0.28)",primaryEdge:"#6BD39A",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)",info:"#6BD39A",badgeBgInfo:"rgba(107,211,154,0.12)",infoEdge:"rgba(107,211,154,0.28)"},V=deepFreeze({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:K,space:P,radius:T,type:B(),motion:W,slots:A});var G=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),Y=globalThis,X=Y[G]??(Y[G]=e.createContext(U));X.displayName??="EverfurThemeContext";function useEverfurTheme(){return e.useContext(X)}var Q={ink:"#10462E",go:"#07C168",alert:"#C03410",tintSage:"#E6ECE8"},Z=/* @__PURE__ */Symbol.for("@everfur-health/ui-core#ThemeContext@v1");function J(){let t=globalThis,i=t[Z];return i===void 0&&(i=e.createContext(null),i.displayName="EverfurThemeContext",t[Z]=i),i}var ee=(e,t)=>e.toUpperCase()===t.toUpperCase();function te(e){let t=r(e);return t!==null&&b(t)<.18}var ie=/* @__PURE__ */new WeakMap;function re(e,t){if(t===null)return e;let i=ie.get(e);i===void 0&&(i=/* @__PURE__ */new WeakMap,ie.set(e,i));let r=i.get(t);return r===void 0&&(r=ne(e,t),i.set(t,r)),r}function ne(e,t){let i=t.colors,r=!ee(i.ink,Q.ink),n=!ee(i.go,Q.go),o=e===U&&te(i.bg),a=o?V:e,s=a.color,l=e=>o||s[e]===U.color[e],u={};r&&l("primary")&&(Object.assign(u,{primary:i.ink,onPrimary:i.onInk,brand:i.ink,brandInk:i.ink}),l("linkInk")&&(u.linkInk=i.ink),!n&&l("accent")&&Object.assign(u,{accent:i.ink,onAccent:i.onInk})),n&&l("accent")&&Object.assign(u,{accent:i.go,onAccent:i.onGo}),!ee(i.alert,Q.alert)&&l("danger")&&(u.danger=i.alert),!ee(i.tintSage,Q.tintSage)&&l("brandSoft")&&(u.brandSoft=i.tintSage,l("brandSofter")&&(u.brandSofter=i.tintSage)),o&&Object.assign(u,{background:i.bg,surface:i.surface,text:{...s.text,primary:i.text,muted:i.muted},borderRingCream:i.line});let c=t.motion?.reduced===true&&!a.motion.reducedMotion;return!o&&!c&&Object.keys(u).length===0?e:{...a,color:{...s,...u},...c?{motion:{...a.motion,reducedMotion:true}}:{}}}function oe(){let t=useEverfurTheme(),i=e.useContext(J());return e.useMemo(()=>re(t,i),[t,i])}var ae=/* @__PURE__ */Object.freeze({loading:"Loading",retry:"Try again",signedOut:"Sign in required",addToCart:"Add to cart",added:"Added",remove:"Remove",checkout:"Checkout",subtotal:"Subtotal",sample:"Sample",cartEmpty:"Your cart is empty.",choosePet:"Choose a pet",emptyTitle:"",emptyBody:"",emptyAsk:""}),se=/* @__PURE__ */Object.freeze({emptyTitle:true,emptyBody:true,emptyAsk:true}),le=/* @__PURE__ */Object.freeze({dna:"",records:"Records",inside:"Inside",profile:""}),ue=/* @__PURE__ */Object.freeze({planTitle:e=>`${e}'s care plan`,cartLabel:e=>`${e} cart`}),ce=/* @__PURE__ */Object.freeze([...Object.keys(ae).filter(e=>se[e]===true&&ae[e]==="").map(e=>`HEALTH_PLAN_COPY.${e}`),...["profile"].filter(e=>le[e]==="").map(e=>`HEALTH_PLAN_REASON_LABELS.${e}`)]);var de=/* @__PURE__ */Object.freeze({imageVariant:"wide",reasonVariant:"pills",cartBarVisibility:"whenItems",cartBarPlacement:"sticky",addButtonSize:"full",addedVariant:"link",categoryVariant:"text",showCategory:false,cardShadow:false,cardBorder:true});function pe(e,t){return{setInPlan:t,addAll:async()=>{let i=(e?.items??[]).filter(e=>!e.inPlan);return(await Promise.all(i.map(e=>t(e.productId,true)))).every(Boolean)}}}function showHealthPlanCartBar(e,t){return(e??de.cartBarVisibility)==="always"||t>0}var fe=/* @__PURE__ */Object.freeze(["showCategory","cardShadow","cardBorder","addButtonSize","addButtonFontSize","addedVariant","categoryVariant","cardPadding","itemTitleSize","itemTitleWeight","priceSize","priceWeight","reasonTextSize","reasonLabelWidth","reasonGap"]);function me(e){let t={};for(let i of fe)e[i]!==void 0&&(t[i]=e[i]);return t}function he(e){let t=typeof e=="number"&&Number.isFinite(e)&&e>0?e:e==="compact"?32:44;return{height:t,hit:Math.max(44,t)}}function ge(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:null}function be(e,t){let i=ge(e);return i===null?0:i-t}function isHealthPlanSessionRequired(e){return e!==null&&(e.reasonCode==="session_required"||e.code==="sessionRequired")}var ve=/* @__PURE__ */Symbol.for("@everfur/sdk#HealthPlanCartDock@v1"),xe=globalThis,ye=xe[ve]??(xe[ve]=e.createContext(null));function HealthPlanCartScope({children:t}){let[i,r]=e.useState(null),n=e.useMemo(()=>({dock:i,publish:r}),[i]);return e.createElement(ye.Provider,{value:n},t)}function useHealthPlanCartDock(){return e.useContext(ye)?.dock??null}function we(t,i,r,petRef,n,o){let a=e.useContext(ye)?.publish,s=e.useRef(o);e.useEffect(()=>{s.current=o},[o]);let l=e.useMemo(()=>pe(n,(e,t)=>s.current(e,t)),[n]);e.useEffect(()=>{if(!(a===void 0||!t))return a(/* @__PURE__ */Object.freeze({cart:i,busy:r,petRef:petRef,plan:n,...l})),()=>a(null)},[a,t,i,r,petRef,n,l])}function healthPlanPetWords(e,t){let i=e?.trim()??"",r=i===""?"your pet":i,n=i===""?"Your pet":i;return t==="female"?{name:r,Name:n,poss:"her",Poss:"Her",obj:"her"}:t==="male"?{name:r,Name:n,poss:"his",Poss:"His",obj:"him"}:{name:r,Name:n,poss:`${r}'s`,Poss:`${n}'s`,obj:r}}var ke=e=>e===null?"":`${e.productName} renews every ${e.intervalDays} days at ${e.box??""} until you cancel; skip or cancel anytime in the app.`,_e=/* @__PURE__ */Object.freeze({onceFine:"",cartFine:ke,startedWhat:()=>""});function healthPlanFocusCopyFor(e){let t=healthPlanPetWords(e.name,e.sex),i=e=>e.petName?.trim()||t.name,NameOf=e=>e.petName?.trim()||t.Name,r=/* @__PURE__ */Object.freeze({jumpKicker:(e,i)=>i?`In ${t.poss} plan, every ${e.intervalDays} days`:e.offer?`${e.discountPercent}% off ${t.poss} first box`:e.intervalDays>0?`Ships every ${e.intervalDays} days`:r.onceLine(e),optionsLabel:"How to buy",subscribe:"Subscribe",bestValue:"Best value",subscribeLine:e=>e.offer?`First box, then ${e.box??""}`:`${e.box??""} every ${e.intervalDays} days`,priceLine:e=>e.offer?`${e.discountPercent}% off the first box. Ships every ${e.intervalDays} days.`:e.intervalDays>0?`Ships every ${e.intervalDays} days.`:r.onceOffer(e),once:"One box",onceLine:e=>e.onceDiscountPercent>0?`${e.onceDiscountPercent}% off, ships once`:"Ships once",buyOnce:e=>`Buy one box, ${e.once??e.box??""}`,subscribed:"Subscribed",subscribedLine:(e,t)=>t===null?`Every ${e.intervalDays} days`:`Every ${e.intervalDays} days · next box ${t}`,manage:"Manage",checkoutKicker:"Checkout",checkoutTitle:e=>`Checkout: ${e.productName}`,checkoutOffer:e=>`${e.discountPercent}% off your first box.`,shipsEvery:"Ships every",days:e=>`${e} days`,buyOnceOption:"Buy once",checkoutGo:(e,t,i)=>`${t?"Subscribe":"Buy now"} · ${i} today`,renews:e=>`Renews every ${e.intervalDays} days at ${e.box??""} until you cancel; skip or cancel anytime in the app.`,onceFine:"One box, ships tomorrow.",onceOffer:e=>e.onceDiscountPercent>0?`${e.onceDiscountPercent}% off, ships once.`:"Ships once.",checkoutNote:"",close:"Close",startedTitle:e=>`${NameOf(e)}'s plan has started.`,orderedTitle:()=>"Order placed.",startedWhat:e=>`${e.productName} ships tomorrow.`,startedNote:"",startedSteps:"What happens next",tomorrow:"Tomorrow",firstBoxShips:`${t.Poss} first box ships.`,trackingComesByText:"Tracking comes by text.",checkin:e=>e===null?"A 2-week check-in by text.":`A 2-week check-in by text: ${e}`,refill:`A text 3 days before ${t.poss} next box. Reply SKIP to skip it.`,nextBoxShips:e=>`${t.Poss} next box ships, ${e.box??""}.`,startedDone:`Back to ${t.poss} plan`,manageKicker:"Your subscription",manageTitle:e=>`Manage ${e.productName}`,skip:"Skip the next box",cancel:"Cancel subscription",skipped:(e,i)=>i===null?"Skipped.":`Skipped. ${t.Poss} next box ships ${i}.`,cancelled:e=>`${e.productName} is cancelled. Restart it from ${t.poss} plan anytime.`,orders:"Orders",startedHeader:"Subscribed",placedHeader:"Order placed",cartCheckoutTitle:"Checkout",orderNote:"",cartLabel:e=>e>0?`Cart, ${e} item${e>1?"s":""}`:"Cart, empty",addToCart:e=>`Add to cart · ${e}`,viewCart:"View cart",addedToCart:(e,t)=>`${e.productName} is in your cart${t?", as a subscription":""}.`,removedFromCart:e=>`${e} is out of your cart.`,cartTitle:"Cart",cartEmptyTitle:"Your cart is empty",cartEmptyBody:e=>`${NameOf(e)}'s plan pick lands here when you add it.`,seeOrders:`See ${t.poss} orders`,quantityLabel:e=>`How many: ${e}`,fewer:"One fewer",more:"One more",remove:"Remove",cartSubLine:e=>e.offer?`First box ${e.discountPercent}% off, then ${e.box??""} every ${e.intervalDays} days`:`Every ${e.intervalDays} days`,cartOnceLine:(e,i)=>i?`An extra box. ${t.Poss} plan keeps shipping.`:e.onceDiscountPercent>0?`One box, ${e.onceDiscountPercent}% off`:"One box",cartModeLabel:e=>`How to buy ${e}`,cartModeSubscribe:e=>e.offer?`Subscribe, ${e.discountPercent}% off the first box`:"Subscribe",cartModeOnce:e=>e.onceDiscountPercent>0?`One box, ${e.onceDiscountPercent}% off`:"One box",subtotal:"Subtotal",shipping:"Shipping",shippingValue:"",shippingTag:"",total:"Total",dueToday:"Due today",thenRenews:e=>`Then ${e.productName}`,renewsEvery:e=>`${e.box??""} every ${e.intervalDays} days`,checkoutCart:e=>`Checkout · ${e}`,cartOneAtATime:"",cartSubscriptionApart:"",cartItemSubscription:e=>`Subscription, every ${e.intervalDays} days`,cartItemQuantity:e=>`Qty ${e}`,placeOrder:(e,t)=>`${t?"Place order and subscribe":"Place order"} · ${e}`,cartFine:e=>`${e===null?"":`${ke(e)} `}Ships tomorrow.`,placedSteps:"What's coming",placedShips:"It ships.",placedArrives:"It arrives at home.",viewOrder:"View order",herSubscription:`${t.Poss} subscription`,nextBox:e=>`Next box ${e}`,everyDays:e=>`Every ${e} days`,ordersHeading:e=>e?"Orders":`${t.Poss} orders`,ordersFine:"",ordersEmptyTitle:"No orders yet",ordersEmptyBody:e=>`The boxes from ${i(e)}'s plan show up here.`,moreOrders:"",orderSteps:["Ordered","Shipped","Out for delivery","Delivered"],subscriptionBox:"Subscription box",orderTitle:e=>e===null?"Order":`Order ${e}`,arrivesBy:e=>`Arrives by ${e}`,deliveredOn:e=>`Delivered ${e}`,expected:e=>`Expected ${e}`,tracking:"Tracking",trackingByText:"The tracking number comes by text when it ships.",trackOn:e=>`Track on ${e}`,trackLink:"",inThisOrder:"In this order",orderItemLine:(e,t)=>`Qty ${e}${t?" · subscription box":""}`,paidWith:"Paid with",buyAgain:"Buy again",orderHelp:"Get help with this order",addWeightTitle:`Add ${t.poss} weight to size ${t.poss} dose`,addWeightBody:`From a home scale or ${t.poss} last vet visit.`,connectRecordsTitle:`Connect ${t.poss} vet records`,connectRecordsBody:`${t.Poss} weight, visits and labs make ${t.poss} plan sharper.`,weightKicker:`${t.Poss} weight`,weightTitle:e=>`Add ${i(e)}'s weight`,weightBody:`From a home scale or ${t.poss} last vet visit. ${t.Poss} plan uses it to size ${t.poss} dose.`,weightField:`${t.Poss} weight`,weightUnit:"lb",weightUnitKg:"kg",weightErrorKg:"Enter your pet’s weight",weightError:`Enter ${t.poss} weight in pounds, like 14.1.`,weightSave:`Save ${t.poss} weight`,weightSaved:e=>`Saved: ${e} lb. ${t.Poss} dose is sized for ${t.obj}.`,weightSavedKg:e=>`Saved: ${e} kg. ${t.Poss} dose is sized for ${t.obj}.`,checkoutFailed:"That didn't go through. Please try again.",builtWith:e=>`Built with ${e}`,fromVet:e=>`From ${e}`,waitVetTips:e=>`Free tips from ${e}, built around that risk`,signalsFit:e=>`${e} of ${e} signals fit ${t.Name}`,signalsValue:e=>`${e}/${e}`,noPick:`No supplement for this one. ${t.Poss} vet comes first.`,callYourVet:"Call your vet today",callAVet:"Call a vet today",saveForCheckup:`Save for ${t.poss} next checkup`,savedForCheckup:`Saved for ${t.poss} next checkup`,blanksLabel:`${t.Poss} three blanks`,blanksAsked:e=>`Asked ${e}`,blanksAskedNoClinic:"",blanksWaitPill:"2 to 5 days",blanksFilledKicker:`From ${t.poss} vet records`,blanksFilled:(e,t)=>`${e} of ${t} filled`,blanksWeight:`Keep ${t.obj} at `,blanksWeightSource:`From ${t.poss} vet visits`,blanksDose:(e,t)=>`${e} of ${t}`,blanksDoseSource:`Sized to ${t.poss} weight`,blanksShots:`${t.Poss} next shots are due `,blanksShotsSource:`From ${t.poss} clinic`,blankEmpty:"blank",recordsLanded:`${t.Poss} records are in. ${t.Poss} plan now uses ${t.poss} weight and ${t.poss} visits.`,todayLabel:`${t.Poss} Health Plan`,poweredBy:"powered by",poweredByName:"Everfur",seeMore:"See more",seeLess:"See less",reportActions:"Actions to take",openReport:`Open it in ${t.poss} report`,askReport:"Ask about it",fullOpen:`See ${t.poss} full plan`,fullOpenLine:`${t.Poss} vet, reviews and ${t.poss} checkup`,fullClose:`Show ${t.poss} brief plan`,fullCloseLine:`${t.Poss} risk, tips, pick and signs`,hopeNoted:e=>`Noted. When ${t.poss} results land, we'll start with ${e}.`,productLink:e=>`${e}, see the product`,productPhotos:e=>`${e} photos, swipe for more`,shopAll:"Shop all",madeFor:`Made for ${t.name}`,ratingLine:e=>`· ${e} reviews`,productOffer:e=>`${e.discountPercent}% off ${t.poss} first box`,productEvery:e=>`Every ${e.intervalDays} days`,productOnce:e=>e.onceDiscountPercent>0?`One box, ${e.onceDiscountPercent}% off`:"One box",productExtraBox:"An extra box",productOnPlan:e=>`On ${t.poss} plan, every ${e.intervalDays} days. This adds one extra box.`,quantity:"Quantity",description:"Description",readMore:"Read more",readLess:"Read less",whatsInside:"What's inside",howMuch:"How much",reviewsTitle:"Reviews",reviewCount:e=>`${e} reviews`,reviewsSwipe:"Reviews, swipe for more",readAllReviews:e=>`Read all ${e} reviews`,starsLabel:e=>`${e} out of 5 stars`,buyNow:"Buy now"});return r}var je=healthPlanFocusCopyFor({sex:"female"});function formatHealthPlanDay(e,t){if(e===null||!/^\d{4}-\d{2}-\d{2}$/.test(e))return null;let i=/* @__PURE__ */new Date(`${e}T00:00:00Z`);if(Number.isNaN(i.getTime()))return null;try{return new Intl.DateTimeFormat(t??"en-US",{month:"short",day:"numeric",timeZone:"UTC"}).format(i)}catch{return e}}function ze(e){return e!=null&&(e.wait!==void 0||e.pick.hidden===true)}function Ce(e){return{...e,pick:{...e.pick,none:true,hidden:true}}}var Se=/* @__PURE__ */Object.freeze({productId:"",partnerSku:null,title:"",description:null,category:null,price:null,currency:null,imageUrl:null,url:null,reasons:[],inPlan:false,sample:false});var Pe=/* @__PURE__ */Object.freeze({track(){},trackExpectedFailure(){}});function ok(e,t){/* @__PURE__ */
4
4
  return Object.freeze({ok:true,value:e})}function err(e){/* @__PURE__ */
5
5
  return Object.freeze({ok:false,error:e})}var Te=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var Fe=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),$e=globalThis,Oe=$e[Fe]??($e[Fe]=e.createContext(null));Oe.displayName??="EverfurContext";function Ee(){let t=e.useContext(Oe);if(t===null)throw new Te("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return t}var Ie=/* @__PURE__ */Object.freeze({opened:"health_plan.opened",productClicked:"health_plan.product_clicked",checkoutStarted:"health_plan.checkout_started"});function Le(){return e.useContext(Oe)?.runtime.registry.services.telemetry??Pe}var He=e.createContext(null);function HealthPlanPetScope({petRef:petRef,children:t}){return e.createElement(He.Provider,{value:petRef},t)}function Re(t){let i=e.useContext(He),r=e.useContext(Oe);return i??t??r?.activePet??null}function De(t,petRef,i){let r=Le(),n=e.useRef(null);e.useEffect(()=>{if(!t||petRef===null||n.current===petRef)return;n.current=petRef;let e=i?.items??[];r.track(Ie.opened,{petRef:petRef,itemsCount:e.length,inPlanCount:e.filter(e=>e.inPlan).length})},[t,petRef,i,r])}function Ne(e,petRef,t,i){e.track(Ie.productClicked,{petRef:petRef,productId:t,inPlan:i})}function Be(e,petRef,t){e.track(Ie.checkoutStarted,{petRef:petRef,itemsCount:t.count,subtotal:t.subtotal,currency:t.currency})}var Ae=[{wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"DAILY_QUOTA_EXCEEDED",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"FILE_TOO_LARGE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"IDEMPOTENCY_KEY_IN_FLIGHT",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"INVALID_CONTENT_TYPE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"InternalFailureException",envelope:"http_envelope",httpStatus:500,retryable:true},{wireCode:"MethodNotAllowedException",envelope:"http_envelope",httpStatus:405,retryable:false},{wireCode:"NotImplementedException",envelope:"http_envelope",httpStatus:501,retryable:false},{wireCode:"PaymentRequiredException",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ResourceNotFoundException",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"ServiceUnavailableException",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"TIER_UPGRADE_REQUIRED",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ThrottlingException",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"ValidationException",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"accessDenied",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"access_denied",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"anchor_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"anchor_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"anonTokenInvalid",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"attachment_unreadable",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"authExpired",envelope:"http_envelope",httpStatus:401,retryable:true},{wireCode:"authRejected",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"before_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_not_uploaded",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundles_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"catalog_empty_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"catalog_shrink_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"consent_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_required",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_scope_wrong_route",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"device_cipher_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"email_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"endpoint_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"environment_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_cursor_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_payload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_not_available",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_unknown",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_required",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_reused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"inbox_cursor_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"insufficientCapability",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"insufficient_scope",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"internal_error",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"invalidRequest",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"invalid_client",envelope:"oauth_error",httpStatus:401,retryable:false},{wireCode:"invalid_client_metadata",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_grant",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_redirect_uri",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_request",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_scope",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_target",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"item_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"linked_account_read_only",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_connection_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"mcp_request_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_request_gone",envelope:"http_envelope",httpStatus:410,retryable:false},{wireCode:"mcp_request_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"not_found",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"open_url_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"partner_visit_link_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"partner_visit_owner_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"partner_visit_pet_already_mapped",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"payload_too_large",envelope:"http_envelope",httpStatus:413,retryable:false},{wireCode:"petRefInUse",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"pet_health_list_removals_unconfirmed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_health_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_not_registered",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"provider_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"rateLimited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"read_target_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_subject_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"record_upload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"records_consent_required",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"restricted_key",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"sandbox_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_required",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_revoked",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"share_limit_reached",envelope:"http_envelope",httpStatus:429,retryable:false},{wireCode:"slow_down",envelope:"oauth_error",httpStatus:429,retryable:true},{wireCode:"species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"subscription_keys_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"tenant_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"tenant_has_no_capabilities",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tenant_resource_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"tenant_surface_not_enabled",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"ticket_not_resolved",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tickets_disabled",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"timeout",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"timezone_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"token_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"unavailable",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"unrestrictedKeyRequired",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"unsupported_grant_type",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"unsupported_response_type",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"user_ref_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"verify_mint_rate_limited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"verify_mint_refused",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"verify_mint_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"verify_user_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"web_push_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"webhook_endpoint_update_empty",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false}],Me=/* @__PURE__ */Object.freeze(Ae.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(Me.map(e=>e.wireCode));var We=/* @__PURE__ */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",session_revoked:"authExpired",anonTokenInvalid:"authRejected",accessDenied:"accessDenied",invalidRequest:"sdkUpdateRequired",authRejected:"authRejected",rateLimited:"rateLimited",insufficientCapability:"accessDenied",unrestrictedKeyRequired:"accessDenied",user_ref_invalid:"validationFailed",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",linked_account_read_only:"conflict",catalog_empty_refused:"conflict",catalog_shrink_refused:"conflict",endpoint_not_allowed:"validationFailed",event_id_invalid:"validationFailed",inbox_cursor_invalid:"validationFailed",item_id_invalid:"validationFailed",open_url_not_allowed:"validationFailed",read_target_invalid:"validationFailed",subscription_keys_invalid:"validationFailed",web_push_unavailable:"serviceUnavailable",anchor_not_found:"resourceNotFound",anchor_ref_invalid:"validationFailed",before_invalid:"validationFailed",bundle_mismatch:"validationFailed",bundle_not_uploaded:"validationFailed",bundles_unavailable:"serviceUnavailable",environment_mismatch:"validationFailed",restricted_key:"accessDenied",ticket_not_resolved:"conflict",tickets_disabled:"resourceNotFound",timezone_invalid:"validationFailed"}),qe=/* @__PURE__ */Object.freeze(Me.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:We[e.wireCode]}))),Ue=new Map(qe.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),Ke=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(qe.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(e,t){if(typeof e!="string")return;let i=e.trim().toUpperCase();if(i.length!==0)for(let e of[t??"http_envelope",...Ke]){let t=Ue.get(e+i);if(t)return t}}var Ve=/* @__PURE__ */Object.freeze({authExpired:"authentication",authRejected:"authentication",sessionRequired:"authentication",identitySignatureRequired:"authentication",accessDenied:"authorization",paymentRequired:"entitlement",quotaExceeded:"rateLimit",rateLimited:"rateLimit",validationFailed:"invalidRequest",sdkUpdateRequired:"invalidRequest",runtimeDisposed:"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 categoryFor(e){return Ve[e]}function fromWire(e){let t=contractErrorFor(e);if(t)return t.normalized;let i=(e??"").trim().toUpperCase(),r=i.replace(/[^A-Z0-9]/g,"");if(r==="AUTHREJECTED")return"authRejected";if(i.startsWith("AUTH"))return"authExpired";switch(r){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"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";case"RUNTIMEDISPOSED":return"runtimeDisposed";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"}}var Ge=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return Ge.has(e)}var Ye=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||Ye.has(e)}var Xe=500,Qe=8e3,Ze=4;function backoffDelayMs(e,t=Math.random){let i=Math.max(0,e),r=Math.min(Xe*2**i,Qe);return Math.floor(t()*r)}var Je="This feature isn't available on your account right now.",et="Something in that request was not right. Check the details and try again.",tt=/* @__PURE__ */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:Je,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:et,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.",identitySignatureRequired:Je,runtimeDisposed:et,unknown:"Something went wrong. Please try again."}),it="This session has ended. Please sign in again.",rt="linked_account_read_only";function nt(e,t,i){return e==="conflict"&&i===rt?Je:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?it:userFacingError(e)}function userFacingError(e){return tt[e]}function ot(e,t,i){Object.defineProperty(e,t,{value:i,enumerable:false,writable:false,configurable:false})}var at=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let i=contractErrorFor(t?.wireCode,t?.wireEnvelope),r=e==="conflict"&&t?.reasonCode===rt,n={code:e,category:categoryFor(e),retryable:t?.retryable??(r?false:isRetryableCode(e)),displayMessage:nt(e,t?.wireCode,r?rt:null)};t?.httpStatus!==void 0&&(n.httpStatus=t.httpStatus),t?.requestId&&(n.requestId=t.requestId),typeof t?.reasonCode=="string"&&at.test(t.reasonCode)&&(n.reasonCode=t.reasonCode);let o=t?.retryAfterSeconds;if(typeof o=="number"&&Number.isFinite(o)&&o>=0&&(n.retryAfterSeconds=Math.round(o)),i);return t?.wireMessage&&ot(n,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&ot(n,"raw",t.raw),/* @__PURE__ */Object.freeze(n)}function assertNever(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}function errorFrame(e){/* @__PURE__ */
6
- return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryable,wireMessage:e.wireMessage,synthesized:e.synthesized,lastEventId:e.lastEventId,serverRequestId:null,...e.freeCap?{freeCap:/* @__PURE__ */Object.freeze({...e.freeCap})}:{}})}var st="x-everfur-anon-token",lt="anonTokenInvalid";async function ut(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}function ct(e,t){let i=e instanceof Error?e.message:typeof e=="string"?e:null;return makeEverfurError("authRejected",{retryable:false,...t?.wireCode?{wireCode:t.wireCode}:{},...t?.requestId?{requestId:t.requestId}:{},...i?{wireMessage:i}:{},...e!=null?{raw:e}:{}})}function authHeaders(e){let t={};return e.mode==="personalized"?t.authorization=`Bearer ${e.token}`:(t["x-everfur-partner-key"]=e.publishableKey,e.anonToken&&(t[st]=e.anonToken)),e.userRef&&(t["x-everfur-user-ref"]=e.userRef),e.sessionId&&(t["x-everfur-session-id"]=e.sessionId),t}function withAuthHeaders(e,t){return{...e,headers:{...dt(e.headers),...authHeaders(t)}}}function dt(e){if(!e)return{};let t={};for(let[i,r]of Object.entries(e)){let e=i.toLowerCase();e==="authorization"||e==="x-everfur-partner-key"||e===st||(t[i]=r)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let i=await ut(t),r=await t.transport.request(withAuthHeaders(e,pt(t,i)));if(r.ok||mt(r.error.raw)!==lt||t.anonIdentity===void 0||t.userRef!==null)return r;let n=await t.anonIdentity.token({forceRefresh:true});return n===null||n===i?r:t.transport.request(withAuthHeaders(e,pt(t,n)))}let i;try{i=await t.identity.currentToken()}catch(e){return t.identity.reportRejected?.(),err(ct(e))}let r=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:i,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(r.ok||r.error.httpStatus!==401)return r;let n;try{n=await t.identity.currentToken({forceRefresh:!0})}catch(e){return t.identity.reportRejected?.(),err(ct(e,{wireCode:mt(r.error.raw),requestId:r.error.requestId}))}let o=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:n,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return!o.ok&&o.error.httpStatus===401?(t.identity.reportRejected?.(),err(ft(o.error))):o}function pt(e,t){return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}function ft(e){let t=e.raw,i=mt(t);return makeEverfurError("authRejected",{retryable:false,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId?{requestId:e.requestId}:{},...i?{wireCode:i}:{},...e.reasonCode?{reasonCode:e.reasonCode}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},...t!=null?{raw:t}:{}})}function mt(e){if(typeof e!="object"||e===null)return null;let t=e,i=(typeof t.error=="object"&&t.error!==null?t.error.code:void 0)??t.code;return typeof i=="string"&&i.length>0?i:null}function ht(e,t){let i=globalThis.URL;if(typeof i=="function"){let r;try{r=t===void 0?new i(e):new i(e,t)}catch{return null}try{if(r.protocol)return r}catch{}}return xt(e)}var gt=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,bt=/[\s\u0000-\u001f\u007f\\]/,vt={"http:":"80","https:":"443"};function xt(e,t){let i=e.trim();let r=bt.test(i)?null:gt.exec(i);if(r===null)return null;let[,n="",o="",a="",s="",l="",u="",c="",d=""]=r,p=`${n.toLowerCase()}:`,f=Number(l);if(f>65535)return null;let m=l===""||String(f)===vt[p]?"":String(f),h=vt[p]!==void 0,g=s.toLowerCase()+(m&&`:${m}`),b=u||(h?"/":""),v=o||a?`${o}${a&&`:${a}`}@`:"";return{href:`${p}//${v}${g}${b}${c}${d}`,protocol:p,username:o,password:a,hostname:s.toLowerCase(),port:m,origin:h?`${p}//${g}`:"null",pathname:b,search:c==="?"?"":c,hash:d==="#"?"":d}}var yt="1.5.3";function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:wt(e)})}function wt(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var kt=3e4,_t=Qe*2,jt="idempotency-key",zt=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),Ct=/* @__PURE__ */Object.freeze({onEvent(){}}),St=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function Pt(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}function createRequestFunnel(e){let t=e.observer??Ct,i=e.timers??St,r=e.rng??Math.random,n=e.sleep??((e,t)=>qt(e,i,t)),o=e.maxAttempts??Ze,a=e.unaryTimeoutMs??kt,s=e.newIdempotencyKey??Ft(),l=e=>{try{t.onEvent(e)}catch{}};async function u(t,u,c){let d=c?.maxAttempts,p=Math.max(1,d??o),f=c?.idempotent??zt.has(u.method),m=c?.idempotencyKey===void 0?null:Pt(c.idempotencyKey),h=f?m??s():null,g=Tt(u,h),b=0;for(;;){let o=e=>/* @__PURE__ */Object.freeze({call:t,method:u.method,path:u.path,attempt:b,...h?{idempotencyKey:h}:{},...e});l(o({phase:"attempt"}));let s=Mt(a,i),c=Wt(s.signal,u.signal),f;try{f=await authedSend({...g,signal:c.signal},e.auth)}catch(e){f=err(networkError(e))}finally{c.dispose(),s.cancel()}if(f.ok)return l(o({phase:"settled",ok:true,reason:"ok"})),f;let m=f.error,v=Ot(m,b,{maxAttempts:p,rng:r,now:i.now(),aborted:u.signal?.aborted===true,...d!==void 0?{perCallMaxAttempts:d}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),x={ok:false,code:m.code,reason:v.reason,...m.httpStatus!==void 0?{httpStatus:m.httpStatus}:{},...m.requestId!==void 0?{requestId:m.requestId}:{}};if(!v.retry)return l(o({phase:"settled",...x})),err(m);if(l(o({phase:"retry",...x,delayMs:v.delayMs})),await n(v.delayMs,u.signal),u.signal?.aborted===true)return l(o({phase:"settled",...x,reason:"aborted"})),err(m);b+=1}}async function c(t){return withAuthHeaders(t,await At(e.auth))}async function*d(t,i,r){l(
6
+ return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryable,wireMessage:e.wireMessage,synthesized:e.synthesized,lastEventId:e.lastEventId,serverRequestId:null,...e.freeCap?{freeCap:/* @__PURE__ */Object.freeze({...e.freeCap})}:{}})}var st="x-everfur-anon-token",lt="anonTokenInvalid";async function ut(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}function ct(e,t){let i=e instanceof Error?e.message:typeof e=="string"?e:null;return makeEverfurError("authRejected",{retryable:false,...t?.wireCode?{wireCode:t.wireCode}:{},...t?.requestId?{requestId:t.requestId}:{},...i?{wireMessage:i}:{},...e!=null?{raw:e}:{}})}function authHeaders(e){let t={};return e.mode==="personalized"?t.authorization=`Bearer ${e.token}`:(t["x-everfur-partner-key"]=e.publishableKey,e.anonToken&&(t[st]=e.anonToken)),e.userRef&&(t["x-everfur-user-ref"]=e.userRef),e.sessionId&&(t["x-everfur-session-id"]=e.sessionId),t}function withAuthHeaders(e,t){return{...e,headers:{...dt(e.headers),...authHeaders(t)}}}function dt(e){if(!e)return{};let t={};for(let[i,r]of Object.entries(e)){let e=i.toLowerCase();e==="authorization"||e==="x-everfur-partner-key"||e===st||(t[i]=r)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let i=await ut(t),r=await t.transport.request(withAuthHeaders(e,pt(t,i)));if(r.ok||mt(r.error.raw)!==lt||t.anonIdentity===void 0||t.userRef!==null)return r;let n=await t.anonIdentity.token({forceRefresh:true});return n===null||n===i?r:t.transport.request(withAuthHeaders(e,pt(t,n)))}let i;try{i=await t.identity.currentToken()}catch(e){return t.identity.reportRejected?.(),err(ct(e))}let r=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:i,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(r.ok||r.error.httpStatus!==401)return r;let n;try{n=await t.identity.currentToken({forceRefresh:!0})}catch(e){return t.identity.reportRejected?.(),err(ct(e,{wireCode:mt(r.error.raw),requestId:r.error.requestId}))}let o=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:n,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return!o.ok&&o.error.httpStatus===401?(t.identity.reportRejected?.(),err(ft(o.error))):o}function pt(e,t){return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}function ft(e){let t=e.raw,i=mt(t);return makeEverfurError("authRejected",{retryable:false,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId?{requestId:e.requestId}:{},...i?{wireCode:i}:{},...e.reasonCode?{reasonCode:e.reasonCode}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},...t!=null?{raw:t}:{}})}function mt(e){if(typeof e!="object"||e===null)return null;let t=e,i=(typeof t.error=="object"&&t.error!==null?t.error.code:void 0)??t.code;return typeof i=="string"&&i.length>0?i:null}function ht(e,t){let i=globalThis.URL;if(typeof i=="function"){let r;try{r=t===void 0?new i(e):new i(e,t)}catch{return null}try{if(r.protocol)return r}catch{}}return xt(e)}var gt=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,bt=/[\s\u0000-\u001f\u007f\\]/,vt={"http:":"80","https:":"443"};function xt(e,t){let i=e.trim();let r=bt.test(i)?null:gt.exec(i);if(r===null)return null;let[,n="",o="",a="",s="",l="",u="",c="",d=""]=r,p=`${n.toLowerCase()}:`,f=Number(l);if(f>65535)return null;let m=l===""||String(f)===vt[p]?"":String(f),h=vt[p]!==void 0,g=s.toLowerCase()+(m&&`:${m}`),b=u||(h?"/":""),v=o||a?`${o}${a&&`:${a}`}@`:"";return{href:`${p}//${v}${g}${b}${c}${d}`,protocol:p,username:o,password:a,hostname:s.toLowerCase(),port:m,origin:h?`${p}//${g}`:"null",pathname:b,search:c==="?"?"":c,hash:d==="#"?"":d}}var yt="1.6.0";function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:wt(e)})}function wt(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var kt=3e4,_t=Qe*2,jt="idempotency-key",zt=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),Ct=/* @__PURE__ */Object.freeze({onEvent(){}}),St=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function Pt(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}function createRequestFunnel(e){let t=e.observer??Ct,i=e.timers??St,r=e.rng??Math.random,n=e.sleep??((e,t)=>qt(e,i,t)),o=e.maxAttempts??Ze,a=e.unaryTimeoutMs??kt,s=e.newIdempotencyKey??Ft(),l=e=>{try{t.onEvent(e)}catch{}};async function u(t,u,c){let d=c?.maxAttempts,p=Math.max(1,d??o),f=c?.idempotent??zt.has(u.method),m=c?.idempotencyKey===void 0?null:Pt(c.idempotencyKey),h=f?m??s():null,g=Tt(u,h),b=0;for(;;){let o=e=>/* @__PURE__ */Object.freeze({call:t,method:u.method,path:u.path,attempt:b,...h?{idempotencyKey:h}:{},...e});l(o({phase:"attempt"}));let s=Mt(a,i),c=Wt(s.signal,u.signal),f;try{f=await authedSend({...g,signal:c.signal},e.auth)}catch(e){f=err(networkError(e))}finally{c.dispose(),s.cancel()}if(f.ok)return l(o({phase:"settled",ok:true,reason:"ok"})),f;let m=f.error,v=Ot(m,b,{maxAttempts:p,rng:r,now:i.now(),aborted:u.signal?.aborted===true,...d!==void 0?{perCallMaxAttempts:d}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),x={ok:false,code:m.code,reason:v.reason,...m.httpStatus!==void 0?{httpStatus:m.httpStatus}:{},...m.requestId!==void 0?{requestId:m.requestId}:{}};if(!v.retry)return l(o({phase:"settled",...x})),err(m);if(l(o({phase:"retry",...x,delayMs:v.delayMs})),await n(v.delayMs,u.signal),u.signal?.aborted===true)return l(o({phase:"settled",...x,reason:"aborted"})),err(m);b+=1}}async function c(t){return withAuthHeaders(t,await At(e.auth))}async function*d(t,i,r){l(
7
7
  /* @__PURE__ */Object.freeze({call:t,phase:"stream.open",method:i.method,path:i.path,attempt:0}));try{yield*e.auth.transport.stream(i,r)}catch{yield errorFrame({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}}/* @__PURE__ */
8
8
  return Object.freeze({send:u,authorize:c,stream:d})}function Tt(e,t){let i={};for(let[t,r]of Object.entries(e.headers??{}))t.toLowerCase()!==jt&&(i[t]=r);return t!==null&&(i["Idempotency-Key"]=t),{...e,headers:i}}function Ft(){let e=0;return()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var $t=10;function Ot(e,t,i){if(i.aborted)return{retry:false,reason:"aborted"};let r=Et(e);if(r==="quota")return{retry:false,reason:"daily-quota-exhausted"};if(r!=="burst"&&!isAutoRetryable(e.code))return{retry:false,reason:"terminal-code"};let n=r==="burst"?"burst-throttle":"retryable-code";if((()=>{if(i.policy===void 0)return false;try{return!i.policy.shouldRetry(e.code,t)}catch{return false}})())return{retry:false,reason:"terminal-code"};let o=()=>{if(i.policy===void 0)return null;let t;try{t=i.policy.maxAttempts(e.code)}catch{return null}return typeof t!="number"||!Number.isFinite(t)?null:Math.max(1,Math.min($t,Math.floor(t)))},a=i.perCallMaxAttempts??o()??i.maxAttempts;if(t+1>=a)return{retry:false,reason:"attempts-exhausted"};let s=It(e,i.now);return s!==null?s>_t?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:n,delayMs:s}:{retry:true,reason:n,delayMs:backoffDelayMs(t,i.rng)}}function Et(e){let t=e.code==="unknown"?fromWire(Nt(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}function It(e,t){let i=Ht(e.raw);if(i!==null){let e=i-t;return e>0?e:0}let r=Lt(e.raw);return r===null?null:Math.round(r*1e3)}function Lt(e){for(let t of Rt(e)){let e=t.retry_after_seconds;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e}return null}function Ht(e){for(let t of Rt(e)){let e=t.resets_at,i=Dt(e);if(i!==null)return i}return null}function Rt(e){if(!Bt(e))return[];let t=[e];for(let i of["error","detail"]){let r=e[i];Bt(r)&&t.push(r)}return t}function Dt(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}function Nt(e){for(let t of Rt(e)){let e=t.code;if(typeof e=="string"&&e.length>0)return e}return null}function Bt(e){return typeof e=="object"&&e!==null}async function At(e){if(e.mode==="anonymous"){let t=await ut(e);return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}return{mode:"personalized",token:await e.identity.currentToken(),userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{}}}function Mt(e,t){let i=new AbortController,r=t.setTimeout(()=>i.abort(),e);return{signal:i.signal,cancel:()=>t.clearTimeout(r)}}function Wt(e,t){let i=()=>{};if(!t)return{signal:e,dispose:i};let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),{signal:r.signal,dispose:i};let n=()=>r.abort();return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),{signal:r.signal,dispose:()=>{e.removeEventListener("abort",n),t.removeEventListener("abort",n)}}}function qt(e,t,i){return e<=0||i?.aborted===true?Promise.resolve():new Promise(r=>{let n=t.setTimeout(()=>{i?.removeEventListener("abort",o),r()},e),o=()=>{t.clearTimeout(n),r()};i?.addEventListener("abort",o,{once:true})})}function Ut(e){return e!=null&&(e.httpStatus===404||e.category==="notFound")}function Kt(e){return e.code!=="conversationNotFound"?e:makeEverfurError("resourceNotFound",{retryable:false,...e.httpStatus===void 0?{}:{httpStatus:e.httpStatus},...e.requestId===void 0?{}:{requestId:e.requestId},...e.reasonCode===void 0?{}:{reasonCode:e.reasonCode},...e.wireMessage===void 0?{}:{wireMessage:e.wireMessage},...e.raw===void 0?{}:{raw:e.raw}})}function Vt(e){return e.ok?e:err(Kt(e.error))}function Gt(e){return{send:async(...t)=>Vt(await e.send(...t)),authorize:t=>e.authorize(t),stream:(t,i,r)=>e.stream(t,i,r)}}var Yt=/* @__PURE__ */Object.freeze(["dna","records","inside","profile"]),Xt=128;function Qt(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function Zt(e){return makeEverfurError("runtimeDisposed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}function Jt(e){return makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:`${e}: the response carried no plan`})}var ei=(e,t=4e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null;function ti(e){let t=ei(e,2048);return t===null?null:/^https:\/\/[^\s]+$/i.test(t)?t:null}function ii(e){let t=typeof e=="number"?e:typeof e=="string"&&/^\d+(\.\d+)?$/.test(e.trim())?Number(e):Number.NaN;return Number.isFinite(t)&&t>=0?t:null}function ri(e){return typeof e=="string"&&/^[A-Za-z]{3}$/.test(e)?e.toUpperCase():null}function ni(e){if(!Array.isArray(e))/* @__PURE__ */return Object.freeze([]);let t=[];for(let i of e){if(i===null||typeof i!="object")continue;let e=i,r=ei(e.text,1e3);if(r===null)continue;let n=typeof e.kind=="string"&&Yt.includes(e.kind)?e.kind:"profile";t.push(/* @__PURE__ */Object.freeze({kind:n,text:r}))}/* @__PURE__ */
9
9
  return Object.freeze(t)}var oi=6;function ai(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=400?e:null}function si(e,t,i){if(!Array.isArray(e))/* @__PURE__ */return Object.freeze([]);let r=[];for(let n of e){if(r.length>=i)break;if(n===null||typeof n!="object"||Array.isArray(n))continue;let e=t(n);e!==null&&r.push(e)}/* @__PURE__ */