@everfur/sdk 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Chat.d-D9n8tSDD.d.cts → Chat.d-Bl-_TsvQ.d.cts} +1 -1
- package/dist/{Chat.d-BXuEjJsg.d.ts → Chat.d-qQVN6VLp.d.ts} +1 -1
- package/dist/animations/index.cjs +1 -1
- package/dist/animations/index.js +1 -1
- package/dist/{attachments.d-Bsg6duaq.d.cts → attachments.d-DBlHzWYy.d.cts} +1 -1
- package/dist/{attachments.d-DjWUR-h9.d.ts → attachments.d-DOmkQ_8O.d.ts} +1 -1
- package/dist/{branding.d-Bzs4HJoN.d.cts → branding.d-CqDLKj1U.d.cts} +1 -1
- package/dist/{branding.d-CiC6xfGT.d.ts → branding.d-XrZYClN4.d.ts} +1 -1
- package/dist/chat/index.cjs +194 -194
- package/dist/chat/index.d.cts +7 -7
- package/dist/chat/index.d.ts +7 -7
- package/dist/chat/index.js +202 -202
- package/dist/chat/lite/index.cjs +205 -205
- package/dist/chat/lite/index.d.cts +7 -7
- package/dist/chat/lite/index.d.ts +7 -7
- package/dist/chat/lite/index.js +205 -205
- package/dist/{chatHandoffToken.d-sbumx0He.d.cts → chatHandoffToken.d-B4-iQ35P.d.cts} +3 -3
- package/dist/{chatHandoffToken.d-YJY6TZbj.d.ts → chatHandoffToken.d-Br3Gw3w-.d.ts} +3 -3
- package/dist/{checkin.d-DxpoRutq.d.cts → checkin.d-CAKQydg8.d.cts} +14 -2
- package/dist/{checkin.d-C6vh9KVr.d.ts → checkin.d-qvYXugN3.d.ts} +14 -2
- package/dist/{chunk-AJEELSFO.js → chunk-5OK2AF63.js} +14 -14
- package/dist/{chunk-II4QDD6F.js → chunk-6I4REU4U.js} +1 -1
- package/dist/{chunk-ZPIOCHKW.js → chunk-7MMJ7CYN.js} +1 -1
- package/dist/{chunk-FZ6DAQFH.js → chunk-PJHMKQ5C.js} +19 -19
- package/dist/client/index.cjs +2 -2
- package/dist/client/index.d.cts +7 -7
- package/dist/client/index.d.ts +7 -7
- package/dist/client/index.js +2 -2
- package/dist/consent/index.cjs +1 -1
- package/dist/consent/index.js +2 -2
- package/dist/{context.d-Cq2C4vdh.d.cts → context.d-DZfxKxNi.d.cts} +3 -3
- package/dist/{context.d-D1l56nFr.d.ts → context.d-FjU7dQP7.d.ts} +3 -3
- package/dist/core/index.cjs +21 -21
- package/dist/core/index.d.cts +10 -10
- package/dist/core/index.d.ts +10 -10
- package/dist/core/index.js +21 -21
- package/dist/{entitlementRepository.d-x2YFdgYD.d.ts → entitlementRepository.d-BltqS1W8.d.ts} +1 -1
- package/dist/{entitlementRepository.d-CEDU1gZE.d.cts → entitlementRepository.d-wfqpUIKN.d.cts} +1 -1
- package/dist/health-plan/index.cjs +1 -1
- package/dist/health-plan/index.d.cts +4 -4
- package/dist/health-plan/index.d.ts +4 -4
- package/dist/health-plan/index.js +1 -1
- package/dist/index.cjs +221 -221
- package/dist/index.d.cts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.js +221 -221
- package/dist/notifications/inbox/index.cjs +9 -9
- package/dist/notifications/inbox/index.js +9 -9
- package/dist/notifications/index.cjs +3 -3
- package/dist/notifications/index.d.cts +3 -3
- package/dist/notifications/index.d.ts +3 -3
- package/dist/notifications/index.js +6 -6
- package/dist/photo/index.cjs +1 -1
- package/dist/photo/index.js +23 -23
- package/dist/{presentation.d-CWGjwq8Z.d.cts → presentation.d-BkIvMtIl.d.cts} +3 -3
- package/dist/{presentation.d-CWGjwq8Z.d.ts → presentation.d-BkIvMtIl.d.ts} +3 -3
- package/dist/records/depth/index.cjs +1 -1
- package/dist/records/depth/index.js +1 -1
- package/dist/records/index.cjs +2 -2
- package/dist/records/index.d.cts +2 -2
- package/dist/records/index.d.ts +2 -2
- package/dist/records/index.js +71 -71
- package/dist/{route.d-IP_gkOWL.d.ts → route.d-B395-hNX.d.ts} +1 -1
- package/dist/{route.d-9wclfD-y.d.cts → route.d-DSSSpSB-.d.cts} +1 -1
- package/dist/{runtimeTypes.d-BdUe3tYs.d.ts → runtimeTypes.d-DAz0Tgw5.d.ts} +5 -5
- package/dist/{runtimeTypes.d-_UZ6rMUY.d.cts → runtimeTypes.d-DPh1Wh15.d.cts} +5 -5
- package/dist/server/events/index.cjs +3 -3
- package/dist/server/events/index.js +3 -3
- package/dist/server/index.cjs +8 -8
- package/dist/server/index.d.cts +15 -1
- package/dist/server/index.d.ts +15 -1
- package/dist/server/index.js +8 -8
- package/dist/slots/index.cjs +1 -1
- package/dist/slots/index.js +1 -1
- package/dist/tabs/index.cjs +2 -2
- package/dist/tabs/index.js +24 -24
- package/dist/televet/booking/index.cjs +51 -51
- package/dist/televet/booking/index.js +1 -1
- package/dist/televet/index.cjs +1 -1
- package/dist/televet/index.js +1 -1
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/testing/rn/index.cjs +8 -8
- package/dist/testing/rn/index.d.cts +5 -5
- package/dist/testing/rn/index.d.ts +5 -5
- package/dist/testing/rn/index.js +9 -9
- package/dist/testing/web/index.cjs +3 -3
- package/dist/testing/web/index.d.cts +5 -5
- package/dist/testing/web/index.d.ts +5 -5
- package/dist/testing/web/index.js +1 -1
- package/dist/texting/index.cjs +1 -1
- package/dist/texting/index.js +26 -26
- package/dist/{threadOptions.d-BW0rePcs.d.cts → threadOptions.d-DUQxxHyM.d.cts} +3 -3
- package/dist/{threadOptions.d-CrAb71J2.d.ts → threadOptions.d-DnM9UcMx.d.ts} +3 -3
- package/dist/{typeStyle.d-rzVzCfLz.d.ts → typeStyle.d-8mcLhtbH.d.ts} +1 -1
- package/dist/{typeStyle.d-B-YgiWcS.d.cts → typeStyle.d-CLrQZW-r.d.cts} +1 -1
- package/dist/{unreadStore.d-gCsleb6l.d.ts → unreadStore.d-CLnChKca.d.ts} +17 -9
- package/dist/{unreadStore.d-w5x6lEpR.d.cts → unreadStore.d-Donv4bcF.d.cts} +17 -9
- package/dist/{usePresentation.d-w5_oWKmh.d.ts → usePresentation.d-Buxz2Jkt.d.ts} +1 -1
- package/dist/{usePresentation.d-DefUwatV.d.cts → usePresentation.d-DUYzYXgA.d.cts} +1 -1
- package/dist/{useUnread.d-DeRDFtTb.d.cts → useUnread.d-7-cuCooM.d.cts} +3 -3
- package/dist/{useUnread.d-xDOpYyqx.d.ts → useUnread.d-B6Ehu0ao.d.ts} +3 -3
- package/dist/video/index.cjs +1 -1
- package/dist/video/index.js +1 -1
- package/dist/web/consent/index.cjs +3 -3
- package/dist/web/consent/index.js +5 -5
- package/dist/web/health-plan/index.cjs +2 -2
- package/dist/web/health-plan/index.d.cts +5 -5
- package/dist/web/health-plan/index.d.ts +5 -5
- package/dist/web/health-plan/index.js +1 -1
- package/dist/web/inbox/index.cjs +5 -5
- package/dist/web/inbox/index.js +5 -5
- package/dist/web/index.cjs +176 -176
- package/dist/web/index.d.cts +18 -18
- package/dist/web/index.d.ts +18 -18
- package/dist/web/index.js +181 -181
- package/dist/web/intro/index.cjs +10 -10
- package/dist/web/intro/index.js +6 -6
- package/dist/web/notifications/index.cjs +5 -5
- package/dist/web/notifications/index.d.cts +2 -2
- package/dist/web/notifications/index.d.ts +2 -2
- package/dist/web/notifications/index.js +1 -1
- package/dist/web/records/depth/index.cjs +1 -1
- package/dist/web/records/depth/index.js +1 -1
- package/dist/web/records/index.cjs +1 -1
- package/dist/web/records/index.js +1 -1
- package/dist/web/records-sheet/index.cjs +2 -2
- package/dist/web/records-sheet/index.js +2 -2
- package/dist/web/shop/index.cjs +1 -1
- package/dist/web/shop/index.js +15 -15
- package/dist/web/televet/booking/index.cjs +2 -2
- package/dist/web/televet/booking/index.js +64 -64
- package/dist/web/televet/call/index.cjs +1 -1
- package/dist/web/televet/call/index.js +1 -1
- package/dist/web/televet/index.cjs +6 -6
- package/dist/web/televet/index.js +1 -1
- package/dist/web/texting/index.cjs +1 -1
- package/dist/web/texting/index.js +1 -1
- package/dist/web/ui/index.cjs +1 -1
- package/dist/web/ui/index.js +33 -33
- package/package.json +1 -1
package/dist/texting/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
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{createContext,forwardRef as e,createElement as t,useMemo as r,useRef as n,useEffect as i,useSyncExternalStore as o,useCallback as l,useState as a,useContext as s,Component as d}from"react";import{TextInput as u,View as c,ActivityIndicator as p,Pressable as f,StyleSheet as h,Modal as b,KeyboardAvoidingView as y,ScrollView as g,Platform as m,Text as v,AccessibilityInfo as _}from"react-native";import{jsxs as C,jsx as w,Fragment as k}from"react/jsx-runtime";function S(e,t){if(e===void 0)return{};let r={};return e.backgroundColor!==void 0&&(r.backgroundColor=e.backgroundColor),e.borderColor!==void 0&&(r.borderColor=e.borderColor,r.borderWidth=t??1),e.borderRadius!==void 0&&(r.borderRadius=e.borderRadius),r}function x(e){return e?.textColor===void 0?{}:{color:e.textColor}}var T=/* @__PURE__ */Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function face(e,t){let r=e.type,n=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:n}:{fontFamily:n,fontWeight:r.weight[T[t]]}}function headingFace(e,t="bold"){let{headingFamily:r,headingWeight:n}=e.type;if(r===null&&n===null)return face(e,t);if(r!==null)return{fontFamily:r,fontWeight:n??e.type.weight[T[t]]};let i=face(e,t);return i.fontWeight===void 0||n===null?i:{fontFamily:i.fontFamily,fontWeight:n}}function E(e){return e<=450?"regular":e<=650?"medium":"bold"}var F={regular:"mono",medium:"monoMedium",bold:"monoBold"};function textRole(e,t){let r=I.get(e);r===void 0&&(r=/* @__PURE__ */new Map,I.set(e,r));let n=r.get(t);if(n!==void 0)return n;let i=R(e,t);return r.set(t,i),i}var I=/* @__PURE__ */new WeakMap;function R(e,t){let r=e.type.roles[t],n=r.weight==="400"&&r.face!=="mono"?e.type.weight.regular:r.weight,i=E(Number(n)),o=r.face==="mono"?face(e,F[i]):r.face==="heading"?headingFace(e,i):face(e,i),l=r.face==="heading"?e.type.headingWeight??n:n,a=o.fontWeight===void 0?o:{fontFamily:o.fontFamily,fontWeight:l},s=r.size,d={...a,fontSize:s,lineHeight:Math.round(s*r.lineHeight*100)/100};return r.letterSpacing!==0&&(d.letterSpacing=Math.round(s*r.letterSpacing*100)/100),r.uppercase&&(d.textTransform="uppercase"),/* @__PURE__ */Object.freeze(d)}function O(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e)}catch{}}function A(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}function D(e,...t){if(typeof e=="function")try{let r=e(...t);return A(r)&&Promise.resolve(r).then(void 0,O),r}catch(e){O(e);return}}var P=/* @__PURE__ */new WeakMap;function z(e){if(typeof e!="function")return;let t=P.get(e);if(t!==void 0)return t;let r=(...t)=>{D(e,...t)};return P.set(e,r),r}function L(e,t){let r=null;for(let n of t){let t=e[n];typeof t=="function"&&(r??={...e},r[n]=z(t))}return r??e}var j=class extends d{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey}}static getDerivedStateFromError(){return{failed:true}}static getDerivedStateFromProps(e,t){return Object.is(e.resetKey,t.key)?null:{failed:false,key:e.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};function RenderHost({render:e}){return e()}function HostRender({render:e,fallback:r,resetKey:n}){return t(j,{fallback:r,resetKey:n,children:t(RenderHost,{render:e})})}var N=[{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:"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(N.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(B.map(e=>e.wireCode));var M=/* @__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"}),q=/* @__PURE__ */Object.freeze(B.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:M[e.wireCode]}))),H=new Map(q.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),U=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(q.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",...U]){let t=H.get(e+r);if(t)return t}}var $=/* @__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]}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"}}var V=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return V.has(e)}var W=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||W.has(e)}var Y=500,K=8e3,G=4;function backoffDelayMs(e,t=Math.random){let r=Math.max(0,e),n=Math.min(Y*2**r,K);return Math.floor(t()*n)}var Q="This feature isn't available on your account right now.",J="Something in that request was not right. Check the details and try again.",X=/* @__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:Q,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:J,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:Q,runtimeDisposed:J,unknown:"Something went wrong. Please try again."}),Z="This session has ended. Please sign in again.",ee="linked_account_read_only";function te(e,t,r){return e==="conflict"&&r===ee?Q:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?Z:userFacingError(e)}function userFacingError(e){return X[e]}function re(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var ne=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===ee,i={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:te(e,t?.wireCode,n?ee:null)};t?.httpStatus!==void 0&&(i.httpStatus=t.httpStatus),t?.requestId&&(i.requestId=t.requestId),typeof t?.reasonCode=="string"&&ne.test(t.reasonCode)&&(i.reasonCode=t.reasonCode);let o=t?.retryAfterSeconds;if(typeof o=="number"&&Number.isFinite(o)&&o>=0&&(i.retryAfterSeconds=Math.round(o)),r);return t?.wireMessage&&re(i,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&re(i,"raw",t.raw),/* @__PURE__ */Object.freeze(i)}function ok(e,t){/* @__PURE__ */
|
|
2
|
+
import{createContext,forwardRef as e,createElement as t,useMemo as r,useRef as n,useEffect as i,useSyncExternalStore as o,useCallback as l,useState as a,useContext as s,Component as d}from"react";import{TextInput as u,View as c,ActivityIndicator as p,Pressable as f,StyleSheet as h,Modal as b,KeyboardAvoidingView as y,ScrollView as g,Platform as m,Text as v,AccessibilityInfo as _}from"react-native";import{jsxs as C,jsx as w,Fragment as S}from"react/jsx-runtime";function k(e,t){if(e===void 0)return{};let r={};return e.backgroundColor!==void 0&&(r.backgroundColor=e.backgroundColor),e.borderColor!==void 0&&(r.borderColor=e.borderColor,r.borderWidth=t??1),e.borderRadius!==void 0&&(r.borderRadius=e.borderRadius),r}function x(e){return e?.textColor===void 0?{}:{color:e.textColor}}var T=/* @__PURE__ */Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function face(e,t){let r=e.type,n=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:n}:{fontFamily:n,fontWeight:r.weight[T[t]]}}function headingFace(e,t="bold"){let{headingFamily:r,headingWeight:n}=e.type;if(r===null&&n===null)return face(e,t);if(r!==null)return{fontFamily:r,fontWeight:n??e.type.weight[T[t]]};let i=face(e,t);return i.fontWeight===void 0||n===null?i:{fontFamily:i.fontFamily,fontWeight:n}}function E(e){return e<=450?"regular":e<=650?"medium":"bold"}var F={regular:"mono",medium:"monoMedium",bold:"monoBold"};function textRole(e,t){let r=I.get(e);r===void 0&&(r=/* @__PURE__ */new Map,I.set(e,r));let n=r.get(t);if(n!==void 0)return n;let i=R(e,t);return r.set(t,i),i}var I=/* @__PURE__ */new WeakMap;function R(e,t){let r=e.type.roles[t],n=r.weight==="400"&&r.face!=="mono"?e.type.weight.regular:r.weight,i=E(Number(n)),o=r.face==="mono"?face(e,F[i]):r.face==="heading"?headingFace(e,i):face(e,i),l=r.face==="heading"?e.type.headingWeight??n:n,a=o.fontWeight===void 0?o:{fontFamily:o.fontFamily,fontWeight:l},s=r.size,d={...a,fontSize:s,lineHeight:Math.round(s*r.lineHeight*100)/100};return r.letterSpacing!==0&&(d.letterSpacing=Math.round(s*r.letterSpacing*100)/100),r.uppercase&&(d.textTransform="uppercase"),/* @__PURE__ */Object.freeze(d)}function O(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e)}catch{}}function A(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}function D(e,...t){if(typeof e=="function")try{let r=e(...t);return A(r)&&Promise.resolve(r).then(void 0,O),r}catch(e){O(e);return}}var P=/* @__PURE__ */new WeakMap;function z(e){if(typeof e!="function")return;let t=P.get(e);if(t!==void 0)return t;let r=(...t)=>{D(e,...t)};return P.set(e,r),r}function L(e,t){let r=null;for(let n of t){let t=e[n];typeof t=="function"&&(r??={...e},r[n]=z(t))}return r??e}var j=class extends d{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey}}static getDerivedStateFromError(){return{failed:true}}static getDerivedStateFromProps(e,t){return Object.is(e.resetKey,t.key)?null:{failed:false,key:e.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};function RenderHost({render:e}){return e()}function HostRender({render:e,fallback:r,resetKey:n}){return t(j,{fallback:r,resetKey:n,children:t(RenderHost,{render:e})})}var N=[{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(N.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(B.map(e=>e.wireCode));var M=/* @__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"}),q=/* @__PURE__ */Object.freeze(B.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:M[e.wireCode]}))),H=new Map(q.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),U=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(q.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",...U]){let t=H.get(e+r);if(t)return t}}var $=/* @__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]}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"}}var V=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return V.has(e)}var W=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||W.has(e)}var Y=500,K=8e3,G=4;function backoffDelayMs(e,t=Math.random){let r=Math.max(0,e),n=Math.min(Y*2**r,K);return Math.floor(t()*n)}var Q="This feature isn't available on your account right now.",J="Something in that request was not right. Check the details and try again.",X=/* @__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:Q,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:J,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:Q,runtimeDisposed:J,unknown:"Something went wrong. Please try again."}),Z="This session has ended. Please sign in again.",ee="linked_account_read_only";function te(e,t,r){return e==="conflict"&&r===ee?Q:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?Z:userFacingError(e)}function userFacingError(e){return X[e]}function re(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var ne=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===ee,i={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:te(e,t?.wireCode,n?ee:null)};t?.httpStatus!==void 0&&(i.httpStatus=t.httpStatus),t?.requestId&&(i.requestId=t.requestId),typeof t?.reasonCode=="string"&&ne.test(t.reasonCode)&&(i.reasonCode=t.reasonCode);let o=t?.retryAfterSeconds;if(typeof o=="number"&&Number.isFinite(o)&&o>=0&&(i.retryAfterSeconds=Math.round(o)),r);return t?.wireMessage&&re(i,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&re(i,"raw",t.raw),/* @__PURE__ */Object.freeze(i)}function ok(e,t){/* @__PURE__ */
|
|
3
3
|
return Object.freeze({ok:true,value:e})}function err(e){/* @__PURE__ */
|
|
4
4
|
return Object.freeze({ok:false,error:e})}var ie=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};function assertNever(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}function errorFrame(e){/* @__PURE__ */
|
|
5
|
-
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 oe="x-everfur-anon-token",le="anonTokenInvalid";async function ae(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}function se(e,t){let r=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}:{},...r?{wireMessage:r}:{},...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[oe]=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:{...de(e.headers),...authHeaders(t)}}}function de(e){if(!e)return{};let t={};for(let[r,n]of Object.entries(e)){let e=r.toLowerCase();e==="authorization"||e==="x-everfur-partner-key"||e===oe||(t[r]=n)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let r=await ae(t),n=await t.transport.request(withAuthHeaders(e,ue(t,r)));if(n.ok||pe(n.error.raw)!==le||t.anonIdentity===void 0||t.userRef!==null)return n;let i=await t.anonIdentity.token({forceRefresh:true});return i===null||i===r?n:t.transport.request(withAuthHeaders(e,ue(t,i)))}let r;try{r=await t.identity.currentToken()}catch(e){return t.identity.reportRejected?.(),err(se(e))}let n=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:r,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(n.ok||n.error.httpStatus!==401)return n;let i;try{i=await t.identity.currentToken({forceRefresh:!0})}catch(e){return t.identity.reportRejected?.(),err(se(e,{wireCode:pe(n.error.raw),requestId:n.error.requestId}))}let o=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:i,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return!o.ok&&o.error.httpStatus===401?(t.identity.reportRejected?.(),err(ce(o.error))):o}function ue(e,t){return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}function ce(e){let t=e.raw,r=pe(t);return makeEverfurError("authRejected",{retryable:false,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId?{requestId:e.requestId}:{},...r?{wireCode:r}:{},...e.reasonCode?{reasonCode:e.reasonCode}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},...t!=null?{raw:t}:{}})}function pe(e){if(typeof e!="object"||e===null)return null;let t=e,r=(typeof t.error=="object"&&t.error!==null?t.error.code:void 0)??t.code;return typeof r=="string"&&r.length>0?r:null}function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:fe(e)})}function fe(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var he=3e4,be=K*2,ye="idempotency-key",ge=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),me=/* @__PURE__ */Object.freeze({onEvent(){}}),ve=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function _e(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??me,r=e.timers??ve,n=e.rng??Math.random,i=e.sleep??((e,t)=>Le(e,r,t)),o=e.maxAttempts??G,l=e.unaryTimeoutMs??he,a=e.newIdempotencyKey??we(),s=e=>{try{t.onEvent(e)}catch{}};async function d(t,d,u){let c=u?.maxAttempts,p=Math.max(1,c??o),f=u?.idempotent??ge.has(d.method),h=u?.idempotencyKey===void 0?null:_e(u.idempotencyKey),b=f?h??a():null,y=Ce(d,b),g=0;for(;;){let o=e=>/* @__PURE__ */Object.freeze({call:t,method:d.method,path:d.path,attempt:g,...b?{idempotencyKey:b}:{},...e});s(o({phase:"attempt"}));let a=Pe(l,r),u=ze(a.signal,d.signal),f;try{f=await authedSend({...y,signal:u.signal},e.auth)}catch(e){f=err(networkError(e))}finally{u.dispose(),a.cancel()}if(f.ok)return s(o({phase:"settled",ok:true,reason:"ok"})),f;let h=f.error,m=
|
|
5
|
+
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 oe="x-everfur-anon-token",le="anonTokenInvalid";async function ae(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}function se(e,t){let r=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}:{},...r?{wireMessage:r}:{},...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[oe]=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:{...de(e.headers),...authHeaders(t)}}}function de(e){if(!e)return{};let t={};for(let[r,n]of Object.entries(e)){let e=r.toLowerCase();e==="authorization"||e==="x-everfur-partner-key"||e===oe||(t[r]=n)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let r=await ae(t),n=await t.transport.request(withAuthHeaders(e,ue(t,r)));if(n.ok||pe(n.error.raw)!==le||t.anonIdentity===void 0||t.userRef!==null)return n;let i=await t.anonIdentity.token({forceRefresh:true});return i===null||i===r?n:t.transport.request(withAuthHeaders(e,ue(t,i)))}let r;try{r=await t.identity.currentToken()}catch(e){return t.identity.reportRejected?.(),err(se(e))}let n=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:r,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(n.ok||n.error.httpStatus!==401)return n;let i;try{i=await t.identity.currentToken({forceRefresh:!0})}catch(e){return t.identity.reportRejected?.(),err(se(e,{wireCode:pe(n.error.raw),requestId:n.error.requestId}))}let o=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:i,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return!o.ok&&o.error.httpStatus===401?(t.identity.reportRejected?.(),err(ce(o.error))):o}function ue(e,t){return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}function ce(e){let t=e.raw,r=pe(t);return makeEverfurError("authRejected",{retryable:false,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId?{requestId:e.requestId}:{},...r?{wireCode:r}:{},...e.reasonCode?{reasonCode:e.reasonCode}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},...t!=null?{raw:t}:{}})}function pe(e){if(typeof e!="object"||e===null)return null;let t=e,r=(typeof t.error=="object"&&t.error!==null?t.error.code:void 0)??t.code;return typeof r=="string"&&r.length>0?r:null}function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:fe(e)})}function fe(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var he=3e4,be=K*2,ye="idempotency-key",ge=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),me=/* @__PURE__ */Object.freeze({onEvent(){}}),ve=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function _e(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??me,r=e.timers??ve,n=e.rng??Math.random,i=e.sleep??((e,t)=>Le(e,r,t)),o=e.maxAttempts??G,l=e.unaryTimeoutMs??he,a=e.newIdempotencyKey??we(),s=e=>{try{t.onEvent(e)}catch{}};async function d(t,d,u){let c=u?.maxAttempts,p=Math.max(1,c??o),f=u?.idempotent??ge.has(d.method),h=u?.idempotencyKey===void 0?null:_e(u.idempotencyKey),b=f?h??a():null,y=Ce(d,b),g=0;for(;;){let o=e=>/* @__PURE__ */Object.freeze({call:t,method:d.method,path:d.path,attempt:g,...b?{idempotencyKey:b}:{},...e});s(o({phase:"attempt"}));let a=Pe(l,r),u=ze(a.signal,d.signal),f;try{f=await authedSend({...y,signal:u.signal},e.auth)}catch(e){f=err(networkError(e))}finally{u.dispose(),a.cancel()}if(f.ok)return s(o({phase:"settled",ok:true,reason:"ok"})),f;let h=f.error,m=ke(h,g,{maxAttempts:p,rng:n,now:r.now(),aborted:d.signal?.aborted===true,...c!==void 0?{perCallMaxAttempts:c}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),v={ok:false,code:h.code,reason:m.reason,...h.httpStatus!==void 0?{httpStatus:h.httpStatus}:{},...h.requestId!==void 0?{requestId:h.requestId}:{}};if(!m.retry)return s(o({phase:"settled",...v})),err(h);if(s(o({phase:"retry",...v,delayMs:m.delayMs})),await i(m.delayMs,d.signal),d.signal?.aborted===true)return s(o({phase:"settled",...v,reason:"aborted"})),err(h);g+=1}}async function u(t){return withAuthHeaders(t,await De(e.auth))}async function*c(t,r,n){s(
|
|
6
6
|
/* @__PURE__ */Object.freeze({call:t,phase:"stream.open",method:r.method,path:r.path,attempt:0}));try{yield*e.auth.transport.stream(r,n)}catch{yield errorFrame({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}}/* @__PURE__ */
|
|
7
|
-
return Object.freeze({send:d,authorize:u,stream:c})}function Ce(e,t){let r={};for(let[t,n]of Object.entries(e.headers??{}))t.toLowerCase()!==ye&&(r[t]=n);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}function we(){let e=0;return()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var
|
|
8
|
-
return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:bt(Ye,e.sex),spayedNeutered:yt(e.spayed_neutered),birthDate:ht(e.birth_date),birthDatePrecision:bt(Ke,e.birth_date_precision),activityLevel:bt(Ge,e.activity_level),indoorOutdoor:bt(Qe,e.indoor_outdoor),foodBrand:ht(e.food_brand),foodType:ht(e.food_type),microchipId:ht(e.microchip_id),allergies:gt(e.allergies,e=>{let t=ht(e.allergen);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:ht(e.ref),allergen:t,severity:bt(Je,e.severity),notes:ht(e.notes)})}),medications:gt(e.medications,mt),supplements:gt(e.supplements,mt),conditions:gt(e.conditions,e=>{let t=ht(e.condition_name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:ht(e.ref),conditionName:t,diagnosedDate:ht(e.diagnosed_date),notes:ht(e.notes)})})})}var _t=100,Ct=50,wt=100,
|
|
7
|
+
return Object.freeze({send:d,authorize:u,stream:c})}function Ce(e,t){let r={};for(let[t,n]of Object.entries(e.headers??{}))t.toLowerCase()!==ye&&(r[t]=n);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}function we(){let e=0;return()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var Se=10;function ke(e,t,r){if(r.aborted)return{retry:false,reason:"aborted"};let n=xe(e);if(n==="quota")return{retry:false,reason:"daily-quota-exhausted"};if(n!=="burst"&&!isAutoRetryable(e.code))return{retry:false,reason:"terminal-code"};let i=n==="burst"?"burst-throttle":"retryable-code";if((()=>{if(r.policy===void 0)return false;try{return!r.policy.shouldRetry(e.code,t)}catch{return false}})())return{retry:false,reason:"terminal-code"};let o=()=>{if(r.policy===void 0)return null;let t;try{t=r.policy.maxAttempts(e.code)}catch{return null}return typeof t!="number"||!Number.isFinite(t)?null:Math.max(1,Math.min(Se,Math.floor(t)))},l=r.perCallMaxAttempts??o()??r.maxAttempts;if(t+1>=l)return{retry:false,reason:"attempts-exhausted"};let a=Te(e,r.now);return a!==null?a>be?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:i,delayMs:a}:{retry:true,reason:i,delayMs:backoffDelayMs(t,r.rng)}}function xe(e){let t=e.code==="unknown"?fromWire(Oe(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}function Te(e,t){let r=Fe(e.raw);if(r!==null){let e=r-t;return e>0?e:0}let n=Ee(e.raw);return n===null?null:Math.round(n*1e3)}function Ee(e){for(let t of Ie(e)){let e=t.retry_after_seconds;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e}return null}function Fe(e){for(let t of Ie(e)){let e=t.resets_at,r=Re(e);if(r!==null)return r}return null}function Ie(e){if(!Ae(e))return[];let t=[e];for(let r of["error","detail"]){let n=e[r];Ae(n)&&t.push(n)}return t}function Re(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 Oe(e){for(let t of Ie(e)){let e=t.code;if(typeof e=="string"&&e.length>0)return e}return null}function Ae(e){return typeof e=="object"&&e!==null}async function De(e){if(e.mode==="anonymous"){let t=await ae(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 Pe(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return{signal:r.signal,cancel:()=>t.clearTimeout(n)}}function ze(e,t){let r=()=>{};if(!t)return{signal:e,dispose:r};let n=new AbortController;if(e.aborted||t.aborted)return n.abort(),{signal:n.signal,dispose:r};let i=()=>n.abort();return e.addEventListener("abort",i,{once:true}),t.addEventListener("abort",i,{once:true}),{signal:n.signal,dispose:()=>{e.removeEventListener("abort",i),t.removeEventListener("abort",i)}}}function Le(e,t,r){return e<=0||r?.aborted===true?Promise.resolve():new Promise(n=>{let i=t.setTimeout(()=>{r?.removeEventListener("abort",o),n()},e),o=()=>{t.clearTimeout(i),n()};r?.addEventListener("abort",o,{once:true})})}function je(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 Ne(e){return[...e].length}var Be=/* @__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(Be,t)?Be[t]:null}var Me=50,qe=128,He=120,Ue=120,$e=2e3,Ve=120,We=80,Ye=/* @__PURE__ */new Set(["male","female","unknown"]),Ke=/* @__PURE__ */new Set(["day","month","year"]),Ge=/* @__PURE__ */new Set(["low","medium","high","athletic"]),Qe=/* @__PURE__ */new Set(["indoor","outdoor","both"]),Je=/* @__PURE__ */new Set(["mild","moderate","severe"]),Xe=/^(\d{4})-(\d{2})-(\d{2})$/,Ze=[["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"]],et=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];/* @__PURE__ */Object.freeze([...Ze,...et].map(([e])=>e));function tt(e){let t=Xe.exec(e);if(t===null)return false;let[r,n,i]=[Number(t[1]),Number(t[2]),Number(t[3])],o=new Date(Date.UTC(r,n-1,i));return o.getUTCFullYear()===r&&o.getUTCMonth()===n-1&&o.getUTCDate()===i}var rt=e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,nt=(e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,it=(e,t)=>typeof t=="string"&&tt(t)?null:`${e} must be a real date written YYYY-MM-DD`,ot=(e,t={})=>(r,n)=>{if(typeof n!="string")return`${r} must be a string`;if(je(n))return`${r} contains an unpaired surrogate and cannot be encoded`;let i=t.trimmed?n.trim():n;if(t.required&&i.length===0)return`${r} is required and must not be blank`;let o=Ne(i);return o<=e?null:`${r} is ${o} characters; the server accepts at most ${e}`},lt={sex:rt(Ye),spayedNeutered:nt,birthDate:it,birthDatePrecision:rt(Ke),activityLevel:rt(Ge),indoorOutdoor:rt(Qe),foodBrand:ot(Ve),foodType:ot(Ve),microchipId:ot(We)},at=["ref","ref",false,ot(qe,{required:true,trimmed:true})],st=["notes","notes",false,ot($e,{trimmed:true})],dt=[at,["name","name",true,ot(He,{required:true,trimmed:true})],["dose","dose",false,ot(Ue,{trimmed:true})],["frequency","frequency",false,ot(Ue,{trimmed:true})],["startDate","start_date",false,it],["endDate","end_date",false,it],st],ut={allergies:[at,["allergen","allergen",true,ot(He,{required:true,trimmed:true})],["severity","severity",false,rt(Je)],st],medications:dt,supplements:dt,conditions:[at,["conditionName","condition_name",true,ot(He,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,it],st]};function ct(e,t,r){let n=`${e}[${t}]`;if(typeof r!="object"||r===null||Array.isArray(r))return{error:`${n} must be an object`};let i=r,o={};for(let[t,r,l,a]of ut[e]){let e=i[t];if(e==null){if(l)return{error:`${n}.${t} is required`};e===null&&(o[r]=null);continue}let s=a(`${n}.${t}`,e);if(s!==null)return{error:s};o[r]=e}let l=o.start_date,a=o.end_date;return typeof l=="string"&&typeof a=="string"&&a<l?{error:`${n}.endDate must not be before startDate`}:{item:o}}function pt(e,t){if(!Array.isArray(t))return{error:`${e} must be an array (send [] to clear it)`};if(t.length>Me)return{error:`${e} has ${t.length} items; the server accepts at most ${Me}`};let r=[],n=/* @__PURE__ */new Set;for(let i=0;i<t.length;i+=1){let o=ct(e,i,t[i]);if("error"in o)return o;let l=o.item.ref;if(typeof l=="string"){let t=l.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(o.item)}return{items:r}}function ft(e,t){let r=e,n={};for(let[e,t]of Ze){let i=r[e];if(i!==void 0){if(i!==null){let t=lt[e](e,i);if(t!==null)return{error:t}}n[t]=i}}let i=r.birthDate!==void 0,o=r.birthDatePrecision!==void 0;if(i!==o||i&&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 et){let i=r[e];if(i===void 0)continue;let o=pt(e,i);if("error"in o)return o;n[t]=o.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 ht=e=>typeof e=="string"?e:null,bt=(e,t)=>typeof t=="string"&&e.has(t)?t:null,yt=e=>typeof e=="boolean"?e:null;function gt(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 mt(e){let t=ht(e.name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:ht(e.ref),name:t,dose:ht(e.dose),frequency:ht(e.frequency),startDate:ht(e.start_date),endDate:ht(e.end_date),notes:ht(e.notes)})}function vt(e){let t=e.profile_version;/* @__PURE__ */
|
|
8
|
+
return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:bt(Ye,e.sex),spayedNeutered:yt(e.spayed_neutered),birthDate:ht(e.birth_date),birthDatePrecision:bt(Ke,e.birth_date_precision),activityLevel:bt(Ge,e.activity_level),indoorOutdoor:bt(Qe,e.indoor_outdoor),foodBrand:ht(e.food_brand),foodType:ht(e.food_type),microchipId:ht(e.microchip_id),allergies:gt(e.allergies,e=>{let t=ht(e.allergen);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:ht(e.ref),allergen:t,severity:bt(Je,e.severity),notes:ht(e.notes)})}),medications:gt(e.medications,mt),supplements:gt(e.supplements,mt),conditions:gt(e.conditions,e=>{let t=ht(e.condition_name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:ht(e.ref),conditionName:t,diagnosedDate:ht(e.diagnosed_date),notes:ht(e.notes)})})})}var _t=100,Ct=50,wt=100,St=50,kt=500,xt=128,Tt=6e4;function Et(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function Ft(e,t,r){if(typeof t!="string")return Et(`${e} must be a string`);let n=Ne(t);return n<=r?null:Et(`${e} is ${n} characters; the server accepts at most ${r}`)}function It(e,t,r){return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=r?null:Et(`${e} must be a finite number between 0 and ${r}`)}function Rt(petRef,e){if(typeof petRef!="string")return Et("pet_ref must be a string");if(petRef.trim().length===0)return Et("pet_ref must not be blank");if(je(petRef))return Et("pet_ref contains an unpaired surrogate and cannot be encoded");if(e!=null&&typeof e!="object")return Et("profile must be an object");let t=[Ft("pet_ref",petRef,xt)];return e?.name!==void 0&&t.push(Ft("name",e.name,_t)),e?.species!==void 0&&t.push(Ft("species",e.species,Ct)),e?.breed!==void 0&&t.push(Ft("breed",e.breed,wt)),e?.ageYears!==void 0&&t.push(It("age_years",e.ageYears,St)),e?.weightKg!==void 0&&t.push(It("weight_kg",e.weightKg,kt)),t.find(e=>e!==null)??null}function Ot(e,t){let r=ft(e,t);return"error"in r?{error:Et(r.error)}:r}function At(e){if(typeof e!="object"||e===null)return{error:Et("patch must be an object")};let t=e,r=[["name","name",e=>Ft("name",e,_t)],["species","species",e=>Ft("species",e,Ct)],["breed","breed",e=>Ft("breed",e,wt)],["ageYears","age_years",e=>It("age_years",e,St)],["weightKg","weight_kg",e=>It("weight_kg",e,kt)]],n={};for(let[e,i,o]of r){let r=t[e];if(r!==void 0){if(r!==null){let e=o(r);if(e!==null)return{error:e}}n[i]=r}}let i=Ot(t,t.species);return"error"in i?i:(Object.assign(n,i.body),Object.keys(n).length===0?{error:Et("patch must change at least one field")}:{body:n})}function Dt(e){if(e==null)return{body:{}};let t=Ot(e,e.species);return"error"in t?t:{body:{...e.name!==void 0?{name:e.name}:{},...e.species!==void 0?{species:e.species}:{},...e.breed!==void 0?{breed:e.breed}:{},...e.ageYears!==void 0?{age_years:e.ageYears}:{},...e.weightKg!==void 0?{weight_kg:e.weightKg}:{},...t.body}}}var Pt=e=>typeof e=="string"?e:null,zt=e=>typeof e=="number"&&Number.isFinite(e)?e:null;function Lt(e,petRef){let t=typeof e=="object"&&e!==null?e:{};/* @__PURE__ */
|
|
9
9
|
return Object.freeze({petRef:Pt(t.pet_ref)??petRef,name:Pt(t.name),species:Pt(t.species),breed:Pt(t.breed),ageYears:zt(t.age_years),weightKg:zt(t.weight_kg)})}function widgetPetFromWire(e){if(typeof e!="object"||e===null)return null;let t=e,petRef=Pt(t.pet_ref);return petRef===null||petRef.length===0?null:/* @__PURE__ */Object.freeze({petId:Pt(t.pet_id),petRef:petRef,name:Pt(t.name),species:Pt(t.species),breed:Pt(t.breed),ageYears:zt(t.age_years),weightKg:zt(t.weight_kg),updatedAt:Pt(t.updated_at)})}function jt(e){let t=widgetPetFromWire(e);return t===null?null:/* @__PURE__ */Object.freeze({...t,...vt(e)})}function Nt(e){let t=Array.isArray(e)?e:typeof e=="object"&&e!==null&&Array.isArray(e.pets)?e.pets:[];/* @__PURE__ */
|
|
10
10
|
return Object.freeze(t.flatMap(e=>{let t=widgetPetFromWire(e);return t===null?[]:[t]}))}function createPetsRepository(e){return Bt(createRequestFunnel({auth:e}),createRequestFunnel({auth:e,unaryTimeoutMs:Tt}))}function Bt(e,t=e){let r=(e,t)=>t?{...e,signal:t}:e,n=petRef=>Rt(petRef,void 0)??`/widget/v1/pets/${encodeURIComponent(petRef)}`;return{async list(t){let n=await e.send("pets.list",r({method:"GET",path:"/widget/v1/pets"},t?.signal));return n.ok?ok(Nt(n.value)):err(n.error)},async registerPet(petRef,t,r){let n=Rt(petRef,t);if(n!==null)return err(n);let i=Dt(t);if("error"in i)return err(i.error);let o={method:"POST",path:`/widget/v1/pets/${encodeURIComponent(petRef)}`,body:i.body},l=await e.send("pets.registerPet",r?.signal?{...o,signal:r.signal}:o);return l.ok?ok(Lt(l.value,petRef)):err(l.error)},async updatePet(petRef,t,i){let o=n(petRef);if(typeof o!="string")return err(o);let l=At(t);if("error"in l)return err(l.error);let a=await e.send("pets.updatePet",r({method:"PATCH",path:o,body:l.body},i?.signal));return a.ok?ok(Lt(a.value,petRef)):err(a.error)},async getPetProfile(petRef,t){let i=n(petRef);if(typeof i!="string")return err(i);let o=await e.send("pets.getPetProfile",r({method:"GET",path:`${i}/profile`},t?.signal));if(!o.ok)return err(o.error);let l=jt(o.value);return l===null?err(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:"the pet profile response carried no pet_ref"})):ok(l)},async deletePet(petRef,t){let i=n(petRef);if(typeof i!="string")return err(i);let o=await e.send("pets.deletePet",r({method:"DELETE",path:i},t?.signal));return o.ok?ok(void 0):err(o.error)},async eraseUserData(e){let n=await t.send("pets.eraseUserData",r({method:"DELETE",path:"/widget/v1/me"},e?.signal),{maxAttempts:1});return n.ok?ok(void 0):err(n.error)}}}var Mt=/* @__PURE__ */new WeakMap;function qt(e,t){let r=Mt.get(e);return r===void 0&&(r=/* @__PURE__ */new Set,Mt.set(e,r)),r.add(t),()=>{r?.delete(t)}}var Ht=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),Ut=globalThis,$t=Ut[Ht]??(Ut[Ht]=createContext(null));$t.displayName??="EverfurContext";function Vt(){let e=s($t);if(e===null)throw new ie("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}function useEverfurPets(){let{runtime:e,userRef:userRef,activePet:t,scopeEpoch:o}=Vt(),s=r(()=>createPetsRepository(e.registry.services.authFor(userRef)),[e,userRef,o]),[d,u]=a({repository:s,pets:[],loading:true,error:null}),c=d.repository===s?d:{pets:[],loading:true,error:null},p=n(0),f=l(async()=>{let e=++p.current;u(e=>({...e,repository:s,loading:true,error:null,pets:e.repository===s?e.pets:[]}));let t=await s.list();e===p.current&&u(t.ok?{repository:s,pets:t.value,loading:false,error:null}:e=>({repository:s,pets:e.repository===s?e.pets:[],loading:false,error:t.error}))},[s]);i(()=>(f(),()=>{p.current+=1}),[f]),i(()=>qt(e,()=>{f()}),[e,f]);let h=r(()=>t===null?null:c.pets.find(e=>e.petRef===t)??null,[t,c.pets]);return r(()=>({pets:c.pets,activePet:h,loading:c.loading,error:c.error,refresh:f}),[c.pets,c.loading,c.error,h,f])}var Wt="[copy needed: ",Yt=/* @__PURE__ */Object.freeze({loading:"Loading",retry:"Try again",signedOut:"Sign in required",close:"Close",phoneLabel:"Mobile number",phoneHint:"We'll text a 6-digit code to confirm it's you.",phoneInvalid:"That doesn't look like a valid number. Check it and the country, then try again.",consentRequired:"Please agree to receive SMS messages to continue.",sendCode:"Send code",sendingCode:"Sending code",codeTitle:"Enter your code",codeSentTo:"We texted a 6-digit code to",codeLabel:"6-digit code",codeInvalidFormat:"Enter all 6 digits of the code.",confirmCode:"Verify",confirmingCode:"Verifying",verificationInvalid:"That code is no longer valid. Request a new one.",codeExpired:"This code has expired. Request a new one.",requestNewCode:"Request a new code",noResendsLeft:"You've requested the maximum number of codes. Please try again later or contact support.",changeNumber:"Use a different number",defaultPetLabel:"Default pet for SMS",noPetSelected:"Choose a pet",savePet:"Save",savingPet:"Saving",petSaved:"Saved",petIneligible:"That pet can't be selected anymore. Please choose another.",optedOutTitle:"SMS paused",verifiedTitle:"SMS Chat is on",disable:"Turn off SMS Chat",disabling:"Turning off",disableConfirmTitle:"Turn off SMS Chat?",disableConfirmBody:"We'll stop texting this number. You can turn it back on anytime.",disableConfirm:"Turn off",disableCancel:"Keep it on",unavailableTitle:"SMS Chat isn't available yet",unavailableBody:"We're still setting it up. Check back soon.",phoneAlreadyLinked:"This number is already linked to another Everfur account. Contact support and we'll move it for you.",providerFailed:"We couldn't send the text. Please try again.",genericFailure:"That didn't go through. Please try again.",supportReference:"Support reference:",promptBody:"Ask questions about your pet by text message, anytime. No app needed.",promptAccept:"Turn on SMS Chat",promptDismiss:"Not now",phoneCountryNotAllowed:"That doesn't look like a valid number. Check it and the country, then try again.",verificationBusy:"SMS Chat is temporarily unavailable. Please try again in a few minutes.",helpContactLabel:"Help:",reenroll:"Turn on SMS Chat",optedOutByMemberBody:"We'll stop texting this number. You can turn it back on anytime.",codeWrong:"That code didn't work. Check it and try again."}),Kt=/* @__PURE__ */Object.freeze({introTitle:e=>`Chat with ${e} by text`,introBody:e=>`Ask ${e} about your pet by text, the same way you'd message a friend. We'll text you back.`,statusActive:e=>`You can text ${e} anytime from this number.`,optedOutBody:e=>`You texted STOP, so we won't message you. Text START to ${e} to turn SMS Chat back on.`,promptTitle:e=>`Ask ${e} by text, for every pet`,chatAskLine:e=>`Want answers by text too? Add your mobile number and you can text ${e} about your pet anytime.`,chatAskVerified:e=>`Verified. You're all set to text ${e}.`}),Gt=/* @__PURE__ */Object.freeze(Object.keys(Yt).filter(e=>Yt[e].startsWith(Wt)));function Qt(e){if(e==null||typeof e!="object")return Yt;let t={...Yt};for(let r of Object.keys(Yt)){let n=e[r];typeof n=="string"&&n.trim().length>0&&(t[r]=n)}/* @__PURE__ */
|
|
11
11
|
return Object.freeze(t)}function Jt(e){if(e==null||typeof e!="object")return Kt;let t={...Kt};for(let r of Object.keys(Kt)){let n=e[r];if(typeof n!="function")continue;let i=Kt[r];t[r]=e=>{try{let t=n(e);return typeof t=="string"&&t.trim().length>0?t:i(e)}catch{return i(e)}}}/* @__PURE__ */
|
|
12
12
|
return Object.freeze(t)}var Xt=createContext({copy:Yt,brandCopy:Kt});function Zt(){return s(Xt)}function er(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 tr(e,t){let r=er(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 rr(e,t){let r=tr(e,t);if(r!==e||er(e)!==null)return r;let n=e.reasonCode;if(typeof n!="string")return e;let i=t[n];return i===void 0?e:makeEverfurError(i.code,{retryable:i.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})}function nr(e,t=4e3){if(typeof e!="string")return null;let r=e.trim();return r.length>0&&r.length<=t?r:null}function parseTextingProfile(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r=nr(t.brand_name,120),n=nr(t.consent_text),i=nr(t.consent_version,64);return r===null||n===null||i===null?null:/* @__PURE__ */Object.freeze({brandName:r,consentText:n,consentVersion:i,helpContact:nr(t.help_contact,320),isLive:t.status_is_live===true})}function toTextingE164(e){if(typeof e!="string"||e.length>40)return null;let t=e.trim();if(!/^\+?[\d\s().-]+$/.test(t))return null;let r=t.replace(/\D/g,"");if(t.startsWith("+")&&!r.startsWith("1"))return null;let n=r.length===11&&r.startsWith("1")?r.slice(1):r;return n.length!==10||!/^[2-9]\d{2}[2-9]\d{6}$/.test(n)?null:`+1${n}`}function isE164(e){return typeof e=="string"&&/^\+[1-9]\d{7,14}$/.test(e)}var ir="/widget/v1/me/sms-identity",or=`${ir}/verification`,lr=`${or}/confirm`,ar=`${ir}/selected-pet`,sr=/* @__PURE__ */Object.freeze(["none","pending","verified","opted_out"]),dr=/^\d{4,8}$/,ur=/* @__PURE__ */Object.freeze({sms_not_live:{code:"accessDenied",retryable:false},consent_version_mismatch:{code:"conflict",retryable:false},pet_not_found:{code:"resourceNotFound",retryable:false},pet_species_unsupported:{code:"validationFailed",retryable:false},phone_country_not_allowed:{code:"accessDenied",retryable:false},verification_tenant_limit:{code:"rateLimited",retryable:false},verification_phone_limit:{code:"rateLimited",retryable:false},SMS_NOT_LIVE:{code:"accessDenied",retryable:false},SMS_CHAT_VERIFICATION_INVALID:{code:"validationFailed",retryable:false},SMS_CHAT_PHONE_ALREADY_LINKED:{code:"conflict",retryable:false},SMS_CHAT_PET_INELIGIBLE:{code:"validationFailed",retryable:false},SMS_CHAT_IDENTITY_NOT_FOUND:{code:"resourceNotFound",retryable:false}}),cr=/* @__PURE__ */Object.freeze({sms_not_live:"not_live",SMS_NOT_LIVE:"not_live",session_required:"session_required",consent_version_mismatch:"consent_changed",pet_not_found:"pet_ineligible",pet_species_unsupported:"pet_ineligible",phone_country_not_allowed:"country_not_allowed",verification_phone_limit:"phone_code_limit",verification_tenant_limit:"tenant_code_limit",SMS_CHAT_VERIFICATION_INVALID:"code_invalid",SMS_CHAT_PHONE_ALREADY_LINKED:"phone_linked",SMS_CHAT_PET_INELIGIBLE:"pet_ineligible",SMS_CHAT_IDENTITY_NOT_FOUND:"no_identity"});function textingReasonOf(e){if(e==null)return null;let t=e.reasonCode??er(e);return typeof t=="string"?cr[t]??null:null}function pr(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function fr(e){return makeEverfurError("runtimeDisposed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}function hr(e){return makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:`${e}: the response was not the documented shape`})}var br=e=>typeof e=="string"&&e.length>0?e:null;function yr(e){return typeof e=="string"&&sr.includes(e)?e:"none"}function textingIdentityFromWire(e){if(e===null||typeof e!="object")return null;let t=e;return typeof t.status!="string"?null:/* @__PURE__ */Object.freeze({status:yr(t.status),phoneMasked:br(t.phone_masked),consentVersion:br(t.consent_version),selectedPetRef:br(t.selected_pet_ref)})}function gr(e){if(e===null||typeof e!="object")return null;let t=e,r=br(t.challenge_id);if(r===null)return null;let n=t.attempts_remaining,i=typeof n=="number"&&Number.isInteger(n)&&n>=0?n:null;/* @__PURE__ */
|
|
13
|
-
return Object.freeze({challengeId:r,expiresAt:br(t.expires_at),attemptsRemaining:i})}function mr(e){return e==null||e===""?true:typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0}var vr=/* @__PURE__ */Object.freeze({status:"opted_out",phoneMasked:null,consentVersion:null,selectedPetRef:null});function createTextingRepository(e){let t=()=>{let{services:t}=e.registry;return createTextingRepositoryOver({auth:t.authFor(null),...t.errorPolicy?{errorPolicy:t.errorPolicy}:{}})},r=e=>Promise.resolve(err(fr(e)));return{read:n=>e.isDisposed?r("read"):t().read(n),startVerification:n=>e.isDisposed?r("startVerification"):t().startVerification(n),confirmVerification:(n,i)=>e.isDisposed?r("confirmVerification"):t().confirmVerification(n,i),selectPet:petRef=>e.isDisposed?r("selectPet"):t().selectPet(petRef),optOut:()=>e.isDisposed?r("optOut"):t().optOut()}}function createTextingRepositoryOver(e){let t=e.funnel??createRequestFunnel({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e=>rr(e,ur),n=async(e,n,i,o)=>{let l=await t.send(e,n,i);if(!l.ok)return err(r(l.error));let a=textingIdentityFromWire(l.value);return a!==null?ok(a):o!==void 0&&mr(l.value)?ok(o):err(hr(e))};return{read(e){let t=e?.signal?{method:"GET",path:ir,signal:e.signal}:{method:"GET",path:ir};return n("texting.read",t)},async startVerification(e){if(typeof e!="object"||e===null||!isE164(e.phoneE164))return err(pr("phoneE164 must be an E.164 number"));if(typeof e.consentVersion!="string"||e.consentVersion.length===0||e.consentVersion.length>64)return err(pr("consentVersion must be the tenant profile consent version (1..64 characters)"));let n=await t.send("texting.verification.start",{method:"POST",path:or,body:{phone_e164:e.phoneE164,consent_version:e.consentVersion}},{maxAttempts:1});if(!n.ok)return err(r(n.error));let i=gr(n.value);return i===null?err(hr("texting.verification.start")):ok(i)},async confirmVerification(e,t){return typeof e!="string"||e.length===0?err(pr("challengeId is required")):typeof t!="string"||!dr.test(t)?err(pr("code must be the digits that were texted")):n("texting.verification.confirm",{method:"POST",path:lr,body:{challenge_id:e,code:t}},{maxAttempts:1})},async selectPet(petRef){return typeof petRef!="string"||petRef.length===0||petRef.length>128?err(pr("petRef must be 1..128 characters")):n("texting.pet.select",{method:"PUT",path:ar,body:{pet_ref:petRef}})},optOut(){return n("texting.optOut",{method:"DELETE",path:ir},void 0,vr)}}}function textingErrorText(e,t,r=null,n=Yt){switch(textingReasonOf(e)){case"code_invalid":return r==="wrong"?n.codeWrong:r==="expired"?n.codeExpired:n.verificationInvalid;case"phone_linked":return n.phoneAlreadyLinked;case"pet_ineligible":return n.petIneligible;case"not_live":return n.unavailableBody;case"session_required":return n.signedOut;case"country_not_allowed":return n.phoneCountryNotAllowed;case"phone_code_limit":return n.noResendsLeft;case"tenant_code_limit":return n.verificationBusy;default:return t==="start"?n.providerFailed:n.genericFailure}}function textingSupportText(e,t=Yt){return typeof e.requestId=="string"&&e.requestId.length>0?`${t.supportReference} ${e.requestId}`:null}function textingInputProblemText(e,t=Yt){return t[e]}function textingOptedOutBody(e,t,r=Yt,n=Kt){return e!==null&&e.phoneMasked!==null?n.optedOutBody(t):r.optedOutByMemberBody}function formatTextingPhone(e){if(e===null)return"";let t=/^\+1(\d{3})(\d{3})(\d{4})$/.exec(e);return t===null?e:`(${t[1]}) ${t[2]}-${t[3]}`}var _r=/* @__PURE__ */Object.freeze({phase:"loading",identity:null,challenge:null,phoneE164:null,error:null,failedAction:null,codeRefusal:null,savingPet:false,resending:false});function Cr(e){return e.status==="verified"?"verified":e.status==="opted_out"?"optedOut":"enroll"}var wr=class{constructor(e,t=Date.now){this.repository=e;this.now=t;this.snapshot=_r;this.listeners=/* @__PURE__ */new Set;this.generation=0;this.consentVersion=null;this.disposed=false;this.subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});this.getSnapshot=()=>this.snapshot}set(e){if(!this.disposed){this.snapshot=/* @__PURE__ */Object.freeze({...this.snapshot,codeRefusal:null,resending:false,...e});for(let e of this.listeners)e()}}async load(){let e=++this.generation;this.set({phase:"loading",error:null,failedAction:null});let t=await this.repository.read();if(e===this.generation){if(!t.ok){this.set({phase:"failed",error:t.error,failedAction:"read"});return}this.set({phase:Cr(t.value),identity:t.value,challenge:null,error:null,failedAction:null})}}async start(e,t){let r=this.snapshot.phase;if(r!=="enroll"&&r!=="code"&&r!=="optedOut")return false;let n=++this.generation;this.consentVersion=t,this.set({phase:"requesting",phoneE164:e,error:null,failedAction:null,resending:r==="code"});let i=await this.repository.startVerification({phoneE164:e,consentVersion:t});return n!==this.generation?false:i.ok?(this.set({phase:"code",challenge:i.value,error:null,failedAction:null}),true):(this.set({phase:r==="code"?"code":"enroll",error:i.error,failedAction:"start"}),false)}resend(){let{phoneE164:e}=this.snapshot;return e===null||this.consentVersion===null?Promise.resolve(false):this.start(e,this.consentVersion)}async confirm(e){let{challenge:t}=this.snapshot;if(this.snapshot.phase!=="code"||t===null)return false;let r=++this.generation;this.set({phase:"confirming",error:null,failedAction:null});let n=await this.repository.confirmVerification(t.challengeId,e);if(r!==this.generation)return false;if(!n.ok){if(textingReasonOf(n.error)!=="code_invalid")return this.set({phase:"code",error:n.error,failedAction:"confirm"}),false;let e=t.attemptsRemaining===null?null:Math.max(0,t.attemptsRemaining-1),r=t.expiresAt===null?Number.NaN:Date.parse(t.expiresAt),i=null;return Number.isFinite(r)&&this.now()>=r?i="expired":e===0?i="spent":e!==null&&Number.isFinite(r)&&(i="wrong"),this.set({phase:"code",challenge:/* @__PURE__ */Object.freeze({...t,attemptsRemaining:e}),error:n.error,failedAction:"confirm",codeRefusal:i}),false}return this.set({phase:Cr(n.value),identity:n.value,challenge:null,error:null,failedAction:null}),true}changeNumber(){this.generation+=1,this.set({phase:"enroll",challenge:null,error:null,failedAction:null})}reenroll(){this.snapshot.phase==="optedOut"&&(this.generation+=1,this.set({phase:"enroll",challenge:null,error:null,failedAction:null}))}async selectPet(petRef){if(this.snapshot.phase!=="verified"||this.snapshot.savingPet)return false;let e=this.generation;this.set({savingPet:true,error:null,failedAction:null});let t=await this.repository.selectPet(petRef);return e!==this.generation?false:t.ok?(this.set({savingPet:false,identity:t.value,phase:Cr(t.value)}),true):(this.set({savingPet:false,error:t.error,failedAction:"selectPet"}),false)}async optOut(){if(this.snapshot.phase!=="verified")return false;let e=++this.generation;this.set({phase:"optingOut",error:null,failedAction:null});let t=await this.repository.optOut();return e!==this.generation?false:t.ok?(this.set({phase:"optedOut",identity:t.value,error:null,failedAction:null}),true):(this.set({phase:"verified",error:t.error,failedAction:"optOut"}),false)}dispose(){this.generation+=1,this.disposed=true,this.listeners.clear()}};function kr(e,t){let[r,o]=a(e),l=n(false);return i(()=>{let t=r;return l.current&&(t=e(),o(t)),l.current=true,()=>t.dispose()},t),r}function validateTextingEnroll(e,t){return toTextingE164(e)===null?"phoneInvalid":t?null:"consentRequired"}var Sr=6;function validateTextingCode(e){return new RegExp(`^\\d{${Sr}}$`).test(e.trim())?null:"codeInvalidFormat"}var NO_SUBSCRIPTION=()=>()=>{};function xr(){let{runtime:e}=Vt(),t=e.entitlements??null,r=l(e=>t===null?NO_SUBSCRIPTION():t.subscribe(e),[t]),n=l(()=>t===null?void 0:t.getSnapshot().smsProfilePublic,[t]);return o(r,n,n)}function useEverfurTextingProfile(){let e=xr();return r(()=>parseTextingProfile(e),[e])}function useEverfurTextingRepository(){let{runtime:e}=Vt();return r(()=>createTextingRepository(e),[e])}function useEverfurTexting(){return Tr(true)}function Tr(e){let{userRef:userRef,scopeEpoch:t}=Vt(),a=useEverfurTextingRepository(),s=useEverfurTextingProfile(),d=kr(()=>new wr(a),[a,userRef,t]),u=n(null);i(()=>{userRef===null||!e||u.current===d||(u.current=d,d.load())},[d,userRef,e]);let c=o(d.subscribe,d.getSnapshot,d.getSnapshot),p=l(async e=>{let t=toTextingE164(e);return t===null||s===null||userRef===null?false:d.start(t,s.consentVersion)},[d,s,userRef]),f=l(e=>validateTextingCode(e)===null?d.confirm(e.trim()):Promise.resolve(false),[d]),h;return userRef===null?h="signedOut":s===null?h="unavailable":h=c.phase,r(()=>({status:h,profile:s,snapshot:c,start:p,resend:()=>d.resend(),confirm:f,changeNumber:()=>d.changeNumber(),reenroll:()=>d.reenroll(),selectPet:petRef=>d.selectPet(petRef),optOut:()=>d.optOut(),refresh:()=>d.load()}),[h,s,c,p,f,d])}var Er=/* @__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 Fr=Object.freeze;function deepFreeze(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){Fr(e);for(let t of Object.keys(e))deepFreeze(e[t])}return e}var Ir=/* @__PURE__ */Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3});var Rr={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},Or={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},Ar={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},Dr={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},Pr={regular:"400",medium:"500",bold:"700"},zr={eyebrow:1,monoWide:.9,headerBrand:-.42,tight:-.35},Lr=0,jr="System",Nr="monospace",Br=["content","heading","control","compact","badge"];function Mr(e){let t={};for(let r of Br)t[r]=e;return t}var qr=[];function Hr(){return{family:jr,mono:Nr,fontUrl:null,families:{regular:jr,medium:jr,bold:jr,mono:Nr,monoMedium:Nr,monoBold:Nr},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:Ar,tierSizes:Mr(Ar),lineHeight:Dr,weight:Pr,letterSpacing:zr,scale:1,maxScale:Lr,scaleCaps:Ir,headingFamily:null,headingWeight:null,fontSources:qr,roles:Er,typeScale:1}}var Ur={},$r=/* @__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 Vr={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:cssCubicBezier($r.standard),emphasized:cssCubicBezier($r.emphasized),exit:cssCubicBezier($r.exit)},reducedMotion:false},Wr={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)"},Yr=deepFreeze({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:Wr,space:Rr,radius:Or,type:Hr(),motion:Vr,slots:Ur}),Kr={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)"};deepFreeze({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:Kr,space:Rr,radius:Or,type:Hr(),motion:Vr,slots:Ur});var Gr=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),Qr=globalThis,Jr=Qr[Gr]??(Qr[Gr]=createContext(Yr));Jr.displayName??="EverfurThemeContext";function useEverfurTheme(){return s(Jr)}function Xr(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}function Text({tier:e,variant:r,...n}){let i=useEverfurTheme(),o=r===void 0?void 0:i.type.roles[r],l=Xr(i.type,e??o?.tier??"content"),a=r===void 0?n:{...n,style:[{...textRole(i,r),color:i.color.text.primary,flexShrink:1},n.style]};return t(v,l===void 0?a:{maxFontSizeMultiplier:l,...a})}var Zr=e(function(e,r){return t(u,{...e,...r===null?{}:{ref:r}})});var en=/* @__PURE__ */Object.freeze({chat:/* @__PURE__ */Object.freeze(["chat.message.create"]),records:/* @__PURE__ */Object.freeze(["records.upload.create","records.record.read"]),recordsClinic:/* @__PURE__ */Object.freeze(["records.clinic.create"]),video:/* @__PURE__ */Object.freeze(["video.gait.execute"]),photo:/* @__PURE__ */Object.freeze(["photo.checkup.execute"]),animations:/* @__PURE__ */Object.freeze(["animations.state.read"]),televet:/* @__PURE__ */Object.freeze(["televet.visit.create"]),texting:/* @__PURE__ */Object.freeze(["sms.identity.read","sms.identity.update"]),healthPlan:/* @__PURE__ */Object.freeze(["shop.plan.read","shop.plan.update"])});function requires(e){return en[e]}function decideCapability(e,t,r){let n=requires(e),i=/* @__PURE__ */new Map;for(let e of t)i.set(e.resource,e);if(r?.isPending===true&&n.some(e=>!i.has(e)))return nn({name:e,enabled:false,isPending:true,limits:{}});let o=tn(n,i);return n.filter(e=>i.get(e)?.granted!==true).length===0?nn({name:e,enabled:true,isPending:false,limits:o}):nn({name:e,enabled:false,isPending:false,limits:o,disabled:rn(n,i)})}function tn(e,t){let r={};for(let n of e){let e=t.get(n)?.limits;if(e)for(let[t,n]of Object.entries(e)){let e=r[t];r[t]=e===void 0?n:Math.min(e,n)}}return r}function rn(e,t){for(let r of e){let e=t.get(r)?.disabled;if(e)/* @__PURE__ */
|
|
13
|
+
return Object.freeze({challengeId:r,expiresAt:br(t.expires_at),attemptsRemaining:i})}function mr(e){return e==null||e===""?true:typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0}var vr=/* @__PURE__ */Object.freeze({status:"opted_out",phoneMasked:null,consentVersion:null,selectedPetRef:null});function createTextingRepository(e){let t=()=>{let{services:t}=e.registry;return createTextingRepositoryOver({auth:t.authFor(null),...t.errorPolicy?{errorPolicy:t.errorPolicy}:{}})},r=e=>Promise.resolve(err(fr(e)));return{read:n=>e.isDisposed?r("read"):t().read(n),startVerification:n=>e.isDisposed?r("startVerification"):t().startVerification(n),confirmVerification:(n,i)=>e.isDisposed?r("confirmVerification"):t().confirmVerification(n,i),selectPet:petRef=>e.isDisposed?r("selectPet"):t().selectPet(petRef),optOut:()=>e.isDisposed?r("optOut"):t().optOut()}}function createTextingRepositoryOver(e){let t=e.funnel??createRequestFunnel({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e=>rr(e,ur),n=async(e,n,i,o)=>{let l=await t.send(e,n,i);if(!l.ok)return err(r(l.error));let a=textingIdentityFromWire(l.value);return a!==null?ok(a):o!==void 0&&mr(l.value)?ok(o):err(hr(e))};return{read(e){let t=e?.signal?{method:"GET",path:ir,signal:e.signal}:{method:"GET",path:ir};return n("texting.read",t)},async startVerification(e){if(typeof e!="object"||e===null||!isE164(e.phoneE164))return err(pr("phoneE164 must be an E.164 number"));if(typeof e.consentVersion!="string"||e.consentVersion.length===0||e.consentVersion.length>64)return err(pr("consentVersion must be the tenant profile consent version (1..64 characters)"));let n=await t.send("texting.verification.start",{method:"POST",path:or,body:{phone_e164:e.phoneE164,consent_version:e.consentVersion}},{maxAttempts:1});if(!n.ok)return err(r(n.error));let i=gr(n.value);return i===null?err(hr("texting.verification.start")):ok(i)},async confirmVerification(e,t){return typeof e!="string"||e.length===0?err(pr("challengeId is required")):typeof t!="string"||!dr.test(t)?err(pr("code must be the digits that were texted")):n("texting.verification.confirm",{method:"POST",path:lr,body:{challenge_id:e,code:t}},{maxAttempts:1})},async selectPet(petRef){return typeof petRef!="string"||petRef.length===0||petRef.length>128?err(pr("petRef must be 1..128 characters")):n("texting.pet.select",{method:"PUT",path:ar,body:{pet_ref:petRef}})},optOut(){return n("texting.optOut",{method:"DELETE",path:ir},void 0,vr)}}}function textingErrorText(e,t,r=null,n=Yt){switch(textingReasonOf(e)){case"code_invalid":return r==="wrong"?n.codeWrong:r==="expired"?n.codeExpired:n.verificationInvalid;case"phone_linked":return n.phoneAlreadyLinked;case"pet_ineligible":return n.petIneligible;case"not_live":return n.unavailableBody;case"session_required":return n.signedOut;case"country_not_allowed":return n.phoneCountryNotAllowed;case"phone_code_limit":return n.noResendsLeft;case"tenant_code_limit":return n.verificationBusy;default:return t==="start"?n.providerFailed:n.genericFailure}}function textingSupportText(e,t=Yt){return typeof e.requestId=="string"&&e.requestId.length>0?`${t.supportReference} ${e.requestId}`:null}function textingInputProblemText(e,t=Yt){return t[e]}function textingOptedOutBody(e,t,r=Yt,n=Kt){return e!==null&&e.phoneMasked!==null?n.optedOutBody(t):r.optedOutByMemberBody}function formatTextingPhone(e){if(e===null)return"";let t=/^\+1(\d{3})(\d{3})(\d{4})$/.exec(e);return t===null?e:`(${t[1]}) ${t[2]}-${t[3]}`}var _r=/* @__PURE__ */Object.freeze({phase:"loading",identity:null,challenge:null,phoneE164:null,error:null,failedAction:null,codeRefusal:null,savingPet:false,resending:false});function Cr(e){return e.status==="verified"?"verified":e.status==="opted_out"?"optedOut":"enroll"}var wr=class{constructor(e,t=Date.now){this.repository=e;this.now=t;this.snapshot=_r;this.listeners=/* @__PURE__ */new Set;this.generation=0;this.consentVersion=null;this.disposed=false;this.subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});this.getSnapshot=()=>this.snapshot}set(e){if(!this.disposed){this.snapshot=/* @__PURE__ */Object.freeze({...this.snapshot,codeRefusal:null,resending:false,...e});for(let e of this.listeners)e()}}async load(){let e=++this.generation;this.set({phase:"loading",error:null,failedAction:null});let t=await this.repository.read();if(e===this.generation){if(!t.ok){this.set({phase:"failed",error:t.error,failedAction:"read"});return}this.set({phase:Cr(t.value),identity:t.value,challenge:null,error:null,failedAction:null})}}async start(e,t){let r=this.snapshot.phase;if(r!=="enroll"&&r!=="code"&&r!=="optedOut")return false;let n=++this.generation;this.consentVersion=t,this.set({phase:"requesting",phoneE164:e,error:null,failedAction:null,resending:r==="code"});let i=await this.repository.startVerification({phoneE164:e,consentVersion:t});return n!==this.generation?false:i.ok?(this.set({phase:"code",challenge:i.value,error:null,failedAction:null}),true):(this.set({phase:r==="code"?"code":"enroll",error:i.error,failedAction:"start"}),false)}resend(){let{phoneE164:e}=this.snapshot;return e===null||this.consentVersion===null?Promise.resolve(false):this.start(e,this.consentVersion)}async confirm(e){let{challenge:t}=this.snapshot;if(this.snapshot.phase!=="code"||t===null)return false;let r=++this.generation;this.set({phase:"confirming",error:null,failedAction:null});let n=await this.repository.confirmVerification(t.challengeId,e);if(r!==this.generation)return false;if(!n.ok){if(textingReasonOf(n.error)!=="code_invalid")return this.set({phase:"code",error:n.error,failedAction:"confirm"}),false;let e=t.attemptsRemaining===null?null:Math.max(0,t.attemptsRemaining-1),r=t.expiresAt===null?Number.NaN:Date.parse(t.expiresAt),i=null;return Number.isFinite(r)&&this.now()>=r?i="expired":e===0?i="spent":e!==null&&Number.isFinite(r)&&(i="wrong"),this.set({phase:"code",challenge:/* @__PURE__ */Object.freeze({...t,attemptsRemaining:e}),error:n.error,failedAction:"confirm",codeRefusal:i}),false}return this.set({phase:Cr(n.value),identity:n.value,challenge:null,error:null,failedAction:null}),true}changeNumber(){this.generation+=1,this.set({phase:"enroll",challenge:null,error:null,failedAction:null})}reenroll(){this.snapshot.phase==="optedOut"&&(this.generation+=1,this.set({phase:"enroll",challenge:null,error:null,failedAction:null}))}async selectPet(petRef){if(this.snapshot.phase!=="verified"||this.snapshot.savingPet)return false;let e=this.generation;this.set({savingPet:true,error:null,failedAction:null});let t=await this.repository.selectPet(petRef);return e!==this.generation?false:t.ok?(this.set({savingPet:false,identity:t.value,phase:Cr(t.value)}),true):(this.set({savingPet:false,error:t.error,failedAction:"selectPet"}),false)}async optOut(){if(this.snapshot.phase!=="verified")return false;let e=++this.generation;this.set({phase:"optingOut",error:null,failedAction:null});let t=await this.repository.optOut();return e!==this.generation?false:t.ok?(this.set({phase:"optedOut",identity:t.value,error:null,failedAction:null}),true):(this.set({phase:"verified",error:t.error,failedAction:"optOut"}),false)}dispose(){this.generation+=1,this.disposed=true,this.listeners.clear()}};function Sr(e,t){let[r,o]=a(e),l=n(false);return i(()=>{let t=r;return l.current&&(t=e(),o(t)),l.current=true,()=>t.dispose()},t),r}function validateTextingEnroll(e,t){return toTextingE164(e)===null?"phoneInvalid":t?null:"consentRequired"}var kr=6;function validateTextingCode(e){return new RegExp(`^\\d{${kr}}$`).test(e.trim())?null:"codeInvalidFormat"}var NO_SUBSCRIPTION=()=>()=>{};function xr(){let{runtime:e}=Vt(),t=e.entitlements??null,r=l(e=>t===null?NO_SUBSCRIPTION():t.subscribe(e),[t]),n=l(()=>t===null?void 0:t.getSnapshot().smsProfilePublic,[t]);return o(r,n,n)}function useEverfurTextingProfile(){let e=xr();return r(()=>parseTextingProfile(e),[e])}function useEverfurTextingRepository(){let{runtime:e}=Vt();return r(()=>createTextingRepository(e),[e])}function useEverfurTexting(){return Tr(true)}function Tr(e){let{userRef:userRef,scopeEpoch:t}=Vt(),a=useEverfurTextingRepository(),s=useEverfurTextingProfile(),d=Sr(()=>new wr(a),[a,userRef,t]),u=n(null);i(()=>{userRef===null||!e||u.current===d||(u.current=d,d.load())},[d,userRef,e]);let c=o(d.subscribe,d.getSnapshot,d.getSnapshot),p=l(async e=>{let t=toTextingE164(e);return t===null||s===null||userRef===null?false:d.start(t,s.consentVersion)},[d,s,userRef]),f=l(e=>validateTextingCode(e)===null?d.confirm(e.trim()):Promise.resolve(false),[d]),h;return userRef===null?h="signedOut":s===null?h="unavailable":h=c.phase,r(()=>({status:h,profile:s,snapshot:c,start:p,resend:()=>d.resend(),confirm:f,changeNumber:()=>d.changeNumber(),reenroll:()=>d.reenroll(),selectPet:petRef=>d.selectPet(petRef),optOut:()=>d.optOut(),refresh:()=>d.load()}),[h,s,c,p,f,d])}var Er=/* @__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 Fr=Object.freeze;function deepFreeze(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){Fr(e);for(let t of Object.keys(e))deepFreeze(e[t])}return e}var Ir=/* @__PURE__ */Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3});var Rr={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},Or={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},Ar={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},Dr={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},Pr={regular:"400",medium:"500",bold:"700"},zr={eyebrow:1,monoWide:.9,headerBrand:-.42,tight:-.35},Lr=0,jr="System",Nr="monospace",Br=["content","heading","control","compact","badge"];function Mr(e){let t={};for(let r of Br)t[r]=e;return t}var qr=[];function Hr(){return{family:jr,mono:Nr,fontUrl:null,families:{regular:jr,medium:jr,bold:jr,mono:Nr,monoMedium:Nr,monoBold:Nr},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:Ar,tierSizes:Mr(Ar),lineHeight:Dr,weight:Pr,letterSpacing:zr,scale:1,maxScale:Lr,scaleCaps:Ir,headingFamily:null,headingWeight:null,fontSources:qr,roles:Er,typeScale:1}}var Ur={},$r=/* @__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 Vr={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:cssCubicBezier($r.standard),emphasized:cssCubicBezier($r.emphasized),exit:cssCubicBezier($r.exit)},reducedMotion:false},Wr={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)"},Yr=deepFreeze({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:Wr,space:Rr,radius:Or,type:Hr(),motion:Vr,slots:Ur}),Kr={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)"};deepFreeze({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:Kr,space:Rr,radius:Or,type:Hr(),motion:Vr,slots:Ur});var Gr=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),Qr=globalThis,Jr=Qr[Gr]??(Qr[Gr]=createContext(Yr));Jr.displayName??="EverfurThemeContext";function useEverfurTheme(){return s(Jr)}function Xr(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}function Text({tier:e,variant:r,...n}){let i=useEverfurTheme(),o=r===void 0?void 0:i.type.roles[r],l=Xr(i.type,e??o?.tier??"content"),a=r===void 0?n:{...n,style:[{...textRole(i,r),color:i.color.text.primary,flexShrink:1},n.style]};return t(v,l===void 0?a:{maxFontSizeMultiplier:l,...a})}var Zr=e(function(e,r){return t(u,{...e,...r===null?{}:{ref:r}})});var en=/* @__PURE__ */Object.freeze({chat:/* @__PURE__ */Object.freeze(["chat.message.create"]),records:/* @__PURE__ */Object.freeze(["records.upload.create","records.record.read"]),recordsClinic:/* @__PURE__ */Object.freeze(["records.clinic.create"]),video:/* @__PURE__ */Object.freeze(["video.gait.execute"]),photo:/* @__PURE__ */Object.freeze(["photo.checkup.execute"]),animations:/* @__PURE__ */Object.freeze(["animations.state.read"]),televet:/* @__PURE__ */Object.freeze(["televet.visit.create"]),texting:/* @__PURE__ */Object.freeze(["sms.identity.read","sms.identity.update"]),healthPlan:/* @__PURE__ */Object.freeze(["shop.plan.read","shop.plan.update"])});function requires(e){return en[e]}function decideCapability(e,t,r){let n=requires(e),i=/* @__PURE__ */new Map;for(let e of t)i.set(e.resource,e);if(r?.isPending===true&&n.some(e=>!i.has(e)))return nn({name:e,enabled:false,isPending:true,limits:{}});let o=tn(n,i);return n.filter(e=>i.get(e)?.granted!==true).length===0?nn({name:e,enabled:true,isPending:false,limits:o}):nn({name:e,enabled:false,isPending:false,limits:o,disabled:rn(n,i)})}function tn(e,t){let r={};for(let n of e){let e=t.get(n)?.limits;if(e)for(let[t,n]of Object.entries(e)){let e=r[t];r[t]=e===void 0?n:Math.min(e,n)}}return r}function rn(e,t){for(let r of e){let e=t.get(r)?.disabled;if(e)/* @__PURE__ */
|
|
14
14
|
return Object.freeze({reason:e.reason,level:e.level,recoverable:e.recoverable})}/* @__PURE__ */
|
|
15
15
|
return Object.freeze({reason:userFacingError("accessDenied"),level:"user_entitlement",recoverable:false})}function nn(e){let t={name:e.name,enabled:e.enabled,isPending:e.isPending,limits:/* @__PURE__ */Object.freeze({...e.limits})};return e.disabled!==void 0&&(t.disabled=e.disabled),/* @__PURE__ */Object.freeze(t)}function useCapability(e){let{runtime:t}=Vt(),n=t.entitlements,i=o(n.subscribe,n.getSnapshot,n.getSnapshot);return r(()=>decideCapability(e,i.decisions,{isPending:i.isPending}),[e,i])}var on=48;function ln(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}function CapabilityGate(e){let{capability:t,children:n,renderDisabled:i,renderPending:o,style:l}=e,a=useCapability(t),s=r(()=>ln(a),[a]);switch(s){case"enabled":return n;case"pending":return o?/* @__PURE__ */w(HostRender,{render:o,fallback:/* @__PURE__ */w(PendingSkeleton,{capability:t,style:l})}):/* @__PURE__ */w(PendingSkeleton,{capability:t,style:l});case"disabled":return i?/* @__PURE__ */w(HostRender,{render:()=>i(a),fallback:/* @__PURE__ */w(OffState,{decision:a,style:l}),resetKey:a}):/* @__PURE__ */w(OffState,{decision:a,style:l});default:return assertNever(s)}}function PendingSkeleton({capability:e,style:t}){let n=useEverfurTheme(),i=r(()=>an(n),[n]);/* @__PURE__ */
|
|
16
16
|
return w(c,{style:[i.offstate,t],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${e}`,children:/* @__PURE__ */w(c,{style:i.skeletonBar})})}function OffState({decision:e,style:t}){let n=useEverfurTheme(),i=r(()=>an(n),[n]),o=e.disabled?.reason??"";/* @__PURE__ */
|
|
17
17
|
return w(c,{style:[i.offstate,t],accessible:true,accessibilityRole:"text",accessibilityLabel:o,children:o.length>0?/* @__PURE__ */w(Text,{style:i.offstateText,children:o}):null})}function an(e){let{color:t,space:r,radius:n,type:i}=e;return h.create({offstate:{minHeight:on,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:h.hairlineWidth,borderColor:t.brandBorder},offstateText:{...face(e,"regular"),fontSize:i.size.body,lineHeight:Math.round(i.size.body*i.lineHeight.normal),color:t.text.muted},skeletonBar:{height:r.md,borderRadius:n.xs,backgroundColor:t.brandSofter}})}function sn(e){if(!(m.OS!=="ios"||e===""))try{let t=_?.announceForAccessibility;typeof t=="function"&&t.call(_,e)}catch{}}function AnnounceLine({line:e}){return i(()=>{sn(e)},[e]),null}function EverfurTextingOptIn(e){let t=L(e,["onStatusChange"]),n=r(()=>({copy:Qt(e.copy),brandCopy:Jt(e.brandCopy)}),[e.copy,e.brandCopy]),{copy:i,brandCopy:o}=n,l=useEverfurTheme(),a=r(()=>dn(l),[l]),s=useEverfurTexting();return s.status==="signedOut"?/* @__PURE__ */C(c,{style:[a.card,t.style],children:[
|
|
18
18
|
/* @__PURE__ */w(Text,{style:a.title,accessibilityRole:"header",children:o.introTitle(l.meta.displayName)}),
|
|
19
19
|
/* @__PURE__ */w(Text,{style:a.body,children:i.signedOut})]}):/* @__PURE__ */w(CapabilityGate,{capability:"texting",...t.renderDisabled?{renderDisabled:t.renderDisabled}:{},style:t.style,children:/* @__PURE__ */w(Xt.Provider,{value:n,children:/* @__PURE__ */w(OptInBody,{...t,texting:s,styles:a})})})}function Button({label:e,onPress:t,disabled:r=false,busy:n=false,styles:i,kind:o="primary",testID:l}){let a=o==="primary"?i.primary:o==="secondary"?i.secondary:i.link,s=o==="primary"?i.primaryLabel:o==="secondary"?i.secondaryLabel:i.linkLabel;/* @__PURE__ */
|
|
20
|
-
return w(f,{onPress:t,disabled:r||n,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{disabled:r||n,busy:n},style:[a,r||n?i.dimmed:null],...l===void 0?{}:{testID:l},children:/* @__PURE__ */w(Text,{tier:"control",style:s,children:e})})}function OptInBody({texting:e,styles:t,onStatusChange:r,renderNotice:n,style:o}){let{copy:l,brandCopy:s}=Zt(),d=useEverfurTheme(),{status:u,profile:h,snapshot:b}=e,y=h?.brandName??d.meta.displayName,[g,m]=a(""),[v,_]=a(false),[
|
|
20
|
+
return w(f,{onPress:t,disabled:r||n,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{disabled:r||n,busy:n},style:[a,r||n?i.dimmed:null],...l===void 0?{}:{testID:l},children:/* @__PURE__ */w(Text,{tier:"control",style:s,children:e})})}function OptInBody({texting:e,styles:t,onStatusChange:r,renderNotice:n,style:o}){let{copy:l,brandCopy:s}=Zt(),d=useEverfurTheme(),{status:u,profile:h,snapshot:b}=e,y=h?.brandName??d.meta.displayName,[g,m]=a(""),[v,_]=a(false),[k,x]=a(""),[T,E]=a(null),[F,I]=a(false),[R,O]=a(null),[A,D]=a(false);i(()=>{r?.(u)},[r,u]),i(()=>{E(null),I(false)},[u]);let P=(e,r=false)=>/* @__PURE__ */w(c,{style:[t.card,o],accessibilityState:{busy:r},children:e}),z=(e,r)=>{let i=textingErrorText(e,b.failedAction,b.codeRefusal,l),o=textingSupportText(e,l);/* @__PURE__ */
|
|
21
21
|
return C(c,{style:t.notice,accessibilityLiveRegion:"polite",children:[
|
|
22
|
-
/* @__PURE__ */w(HostRender,{resetKey:e,render:()=>n?n(e):/* @__PURE__ */w(Text,{style:t.noticeText,children:i}),fallback:/* @__PURE__ */w(Text,{style:t.noticeText,children:i})}),o===null?null:/* @__PURE__ */w(Text,{style:t.footnote,children:o}),r===void 0?null:/* @__PURE__ */w(Button,{label:l.retry,onPress:r,styles:t,kind:"link"}),n?null:/* @__PURE__ */w(AnnounceLine,{line:o===null?i:`${i} ${o}`})]})},L=T===null?null:/* @__PURE__ */C(
|
|
22
|
+
/* @__PURE__ */w(HostRender,{resetKey:e,render:()=>n?n(e):/* @__PURE__ */w(Text,{style:t.noticeText,children:i}),fallback:/* @__PURE__ */w(Text,{style:t.noticeText,children:i})}),o===null?null:/* @__PURE__ */w(Text,{style:t.footnote,children:o}),r===void 0?null:/* @__PURE__ */w(Button,{label:l.retry,onPress:r,styles:t,kind:"link"}),n?null:/* @__PURE__ */w(AnnounceLine,{line:o===null?i:`${i} ${o}`})]})},L=T===null?null:/* @__PURE__ */C(S,{children:[
|
|
23
23
|
/* @__PURE__ */w(Text,{style:t.noticeText,accessibilityLiveRegion:"polite",children:textingInputProblemText(T,l)}),
|
|
24
24
|
/* @__PURE__ */w(AnnounceLine,{line:textingInputProblemText(T,l)})]});if(u==="unavailable")return P(
|
|
25
|
-
/* @__PURE__ */C(
|
|
25
|
+
/* @__PURE__ */C(S,{children:[
|
|
26
26
|
/* @__PURE__ */w(Text,{style:t.title,accessibilityRole:"header",children:l.unavailableTitle}),
|
|
27
27
|
/* @__PURE__ */w(Text,{style:t.body,children:l.unavailableBody})]}));if(h===null)return null;if(u==="loading")/* @__PURE__ */
|
|
28
28
|
return w(c,{style:[t.card,o],accessible:true,accessibilityRole:"progressbar",accessibilityLabel:l.loading,children:/* @__PURE__ */w(p,{color:d.color.brandInk})});if(u==="failed")return P(
|
|
29
|
-
/* @__PURE__ */C(
|
|
29
|
+
/* @__PURE__ */C(S,{children:[
|
|
30
30
|
/* @__PURE__ */w(Text,{style:t.title,accessibilityRole:"header",children:s.introTitle(y)}),b.error===null?null:z(b.error,textingReasonOf(b.error)==="session_required"?void 0:()=>{e.refresh()})]}));let j=h.helpContact===null?null:/* @__PURE__ */C(Text,{style:t.footnote,children:[l.helpContactLabel," ",h.helpContact]});if(u==="enroll"||u==="requesting"&&!b.resending){let r=u==="requesting";return P(
|
|
31
|
-
/* @__PURE__ */C(
|
|
31
|
+
/* @__PURE__ */C(S,{children:[
|
|
32
32
|
/* @__PURE__ */w(Text,{style:t.title,accessibilityRole:"header",children:s.introTitle(y)}),
|
|
33
33
|
/* @__PURE__ */w(Text,{style:t.body,children:s.introBody(y)}),
|
|
34
34
|
/* @__PURE__ */w(Text,{style:t.label,children:l.phoneLabel}),
|
|
@@ -38,20 +38,20 @@ return w(c,{style:[t.card,o],accessible:true,accessibilityRole:"progressbar",acc
|
|
|
38
38
|
/* @__PURE__ */w(c,{style:[t.box,v?t.boxChecked:null],accessibilityElementsHidden:true,importantForAccessibility:"no",children:v?/* @__PURE__ */w(Text,{style:t.tick,children:"✓"}):null}),
|
|
39
39
|
/* @__PURE__ */w(Text,{style:t.consentText,children:h.consentText})]}),j,L,b.error===null?null:z(b.error),
|
|
40
40
|
/* @__PURE__ */w(Button,{label:r?l.sendingCode:l.sendCode,busy:r,styles:t,testID:"texting-send",onPress:()=>{let t=validateTextingEnroll(g,v);E(t),t===null&&e.start(g)}})]}),r)}if(u==="code"||u==="confirming"||u==="requesting"){let r=u==="confirming",n=u==="requesting",i=r||n;return P(
|
|
41
|
-
/* @__PURE__ */C(
|
|
41
|
+
/* @__PURE__ */C(S,{children:[
|
|
42
42
|
/* @__PURE__ */w(Text,{style:t.title,accessibilityRole:"header",children:l.codeTitle}),
|
|
43
43
|
/* @__PURE__ */C(Text,{style:t.body,children:[l.codeSentTo," ",formatTextingPhone(b.phoneE164)]}),
|
|
44
44
|
/* @__PURE__ */w(Text,{style:t.label,children:l.codeLabel}),
|
|
45
|
-
/* @__PURE__ */w(Zr,{value:
|
|
46
|
-
/* @__PURE__ */w(Button,{label:r?l.confirmingCode:l.confirmCode,busy:r,disabled:n,styles:t,testID:"texting-confirm",onPress:()=>{let t=validateTextingCode(
|
|
45
|
+
/* @__PURE__ */w(Zr,{value:k,onChangeText:e=>x(e.replace(/\D/g,"")),editable:!i,keyboardType:"number-pad",textContentType:"oneTimeCode",autoComplete:"sms-otp",maxLength:6,accessibilityLabel:l.codeLabel,style:t.input,testID:"texting-code"}),L,b.error===null?null:z(b.error),
|
|
46
|
+
/* @__PURE__ */w(Button,{label:r?l.confirmingCode:l.confirmCode,busy:r,disabled:n,styles:t,testID:"texting-confirm",onPress:()=>{let t=validateTextingCode(k);E(t),t===null&&e.confirm(k)}}),
|
|
47
47
|
/* @__PURE__ */C(c,{style:t.links,children:[
|
|
48
48
|
/* @__PURE__ */w(Button,{label:l.requestNewCode,kind:"link",disabled:r,busy:n,styles:t,onPress:()=>{x(""),e.resend()}}),
|
|
49
49
|
/* @__PURE__ */w(Button,{label:l.changeNumber,kind:"link",styles:t,onPress:()=>{x(""),e.changeNumber()}})]})]}),i)}if(u==="optedOut")return P(
|
|
50
|
-
/* @__PURE__ */C(
|
|
50
|
+
/* @__PURE__ */C(S,{children:[
|
|
51
51
|
/* @__PURE__ */w(Text,{style:t.title,accessibilityRole:"header",children:l.optedOutTitle}),
|
|
52
52
|
/* @__PURE__ */w(Text,{style:t.body,children:textingOptedOutBody(b.identity,y,l,s)}),j,
|
|
53
53
|
/* @__PURE__ */w(Button,{label:l.reenroll,styles:t,onPress:()=>{_(false),e.reenroll()}})]}));let N=u==="optingOut";return P(
|
|
54
|
-
/* @__PURE__ */C(
|
|
54
|
+
/* @__PURE__ */C(S,{children:[
|
|
55
55
|
/* @__PURE__ */w(Text,{style:t.title,accessibilityRole:"header",children:l.verifiedTitle}),
|
|
56
56
|
/* @__PURE__ */w(Text,{style:t.body,children:s.statusActive(y)}),b.identity?.phoneMasked?/* @__PURE__ */w(Text,{style:t.phone,children:b.identity.phoneMasked}):null,
|
|
57
57
|
/* @__PURE__ */w(PetPicker,{styles:t,selectedPetRef:b.identity?.selectedPetRef??null,choice:R,saving:b.savingPet,saved:A,onChoose:petRef=>{O(petRef),D(false)},onSave:petRef=>{e.selectPet(petRef).then(e=>D(e))}}),j,b.error===null?null:z(b.error),F?/* @__PURE__ */C(c,{style:t.confirm,children:[
|
|
@@ -65,12 +65,12 @@ return C(c,{style:e.petRow,children:[
|
|
|
65
65
|
/* @__PURE__ */w(c,{style:e.chips,accessibilityRole:"radiogroup",accessibilityLabel:a.defaultPetLabel,children:s.map(t=>{let r=t.petRef===d;/* @__PURE__ */
|
|
66
66
|
return w(f,{onPress:()=>o(t.petRef),disabled:n,accessibilityRole:"radio",accessibilityState:{checked:r,disabled:n},accessibilityLabel:t.name??t.petRef,style:[e.chip,r?e.chipPicked:null],children:/* @__PURE__ */w(Text,{tier:"compact",style:[e.chipLabel,r?e.chipLabelPicked:null],children:t.name??t.petRef})},t.petRef)})}),
|
|
67
67
|
/* @__PURE__ */C(c,{style:e.links,children:[
|
|
68
|
-
/* @__PURE__ */w(Button,{label:n?a.savingPet:a.savePet,kind:"secondary",busy:n,disabled:!u,styles:e,onPress:()=>{d!==null&&l(d)},testID:"texting-pet-save"}),i&&!u?/* @__PURE__ */w(Text,{style:e.footnote,children:a.petSaved}):null]})]})}function dn(e){let{color:t,radius:r,space:n,type:i,slots:o}=e,l=(t,r,n)=>({...face(e,n),fontSize:t,lineHeight:Math.round(t*i.lineHeight.snug),color:r}),a=o.card?.textColor;return h.create({card:{gap:n.md,padding:n.lg,borderRadius:r.lg,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,...S(o.card,1)},title:l(i.size.subtitle,a??t.text.primary,"bold"),subtitle:l(i.size.body,a??t.text.primary,"bold"),body:l(i.size.body,a??t.text.secondary,"regular"),footnote:l(i.size.caption,t.text.muted,"regular"),phone:l(i.size.body,a??t.text.primary,"bold"),label:l(i.size.caption,a??t.text.primary,"bold"),input:{minHeight:44,paddingHorizontal:n.md,borderRadius:r.md,borderWidth:1,borderColor:t.controlEdge,backgroundColor:t.surface,...l(i.size.body,t.text.primary,"regular"),...S(o.input,1),...x(o.input)},consentRow:{flexDirection:"row",alignItems:"flex-start",gap:n.sm,minHeight:44},box:{width:24,height:24,borderRadius:r.xs,borderWidth:2,borderColor:t.controlEdge,alignItems:"center",justifyContent:"center",backgroundColor:t.surface},boxChecked:{backgroundColor:t.brand,borderColor:t.brandInk},tick:{...l(i.size.caption,t.text.onBrand,"bold")},consentText:{flex:1,...l(i.size.caption,a??t.text.secondary,"regular")},primary:{minHeight:44,paddingHorizontal:n.lg,borderRadius:r.pill,alignItems:"center",justifyContent:"center",backgroundColor:t.brand,...S(o.primaryButton)},primaryLabel:{...l(i.size.body,t.text.onBrand,"bold"),...x(o.primaryButton)},secondary:{minHeight:44,paddingHorizontal:n.lg,borderRadius:r.pill,borderWidth:1,borderColor:t.brandBorder,alignItems:"center",justifyContent:"center",backgroundColor:t.surface},secondaryLabel:l(i.size.caption,t.brandInk,"bold"),link:{minHeight:44,justifyContent:"center",alignSelf:"flex-start"},linkLabel:{...l(i.size.caption,t.linkInk,"bold"),...x(o.link)},dimmed:{opacity:.5},links:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:n.md},notice:{gap:n.xs},noticeText:l(i.size.caption,t.errorRed,"regular"),confirm:{gap:n.sm,padding:n.md,borderRadius:r.md,backgroundColor:t.surfaceSubtle},petRow:{gap:n.xs},chips:{flexDirection:"row",flexWrap:"wrap",gap:n.sm},chip:{minHeight:44,paddingHorizontal:n.md,borderRadius:r.pill,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,justifyContent:"center",...S(o.chip,1)},chipPicked:{backgroundColor:t.brandSoft,borderColor:t.brandInk},chipLabel:{...l(i.size.caption,t.text.primary,"regular"),...x(o.chip)},chipLabelPicked:{...face(e,"bold"),color:t.brandInk}})}var un=/* @__PURE__ */Symbol.for("@everfur/sdk#IntroOpen@v1"),cn=globalThis;function pn(e){if(typeof e!="object"||e===null)return false;let t=e;return t.holds instanceof Set&&t.listeners instanceof Set}var fn=cn[un],hn=()=>({holds:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set}),bn=pn(fn)?fn:cn[un]=hn();function yn(){return bn.holds.size>0}function gn(e){return bn.listeners.add(e),()=>{bn.listeners.delete(e)}}function mn(){return o(gn,yn,yn)}function resolveTextingAskDue(e){let t=e.enabled&&e.capabilityGranted&&e.hasProfile&&e.signedIn&&e.scheduleEligible&&!e.offeredThisSession,r=t&&e.identity==="none"&&e.surfaceReady;return{readEnabled:t,due:r}}var vn=/* @__PURE__ */new Set(["emergency","schedule_soon"]);function textingAskThreadReady(e){if(e.isBootstrapping===true||e.isLoadingHistory===true||e.isStreaming===true||e.status==="error"||e.stopped===true)return false;let t=e.messages[e.messages.length-1];return t===void 0||t.role!=="assistant"||t.pending===true||t.checkin!==void 0||t.text.trim().length===0?false:!(typeof t.urgencyLevel=="string"&&vn.has(t.urgencyLevel))}var _n=/* @__PURE__ */new WeakSet;function Cn(e){return _n.has(e)}var wn="everfur.texting.askSchedule.v1",kn=2880*60*1e3,Sn=3,xn=/* @__PURE__ */Object.freeze({askCount:0,nextAskAt:null,completed:false});function isTextingAskEligible(e,t){if(e.status!=="ok")return false;let{entry:r}=e;return r.completed||r.askCount>=Sn?false:r.nextAskAt===null||t>=r.nextAskAt}function Tn(e,t){return{askCount:Math.min(e.askCount+1,Sn),nextAskAt:t+kn,completed:e.completed}}function En(e,t){return{...e,nextAskAt:t+kn}}function Fn(e){return{...e,completed:true}}function In(e){return e.askCount<=0?1:e.askCount===1?2:3}function Rn(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,{askCount:r,nextAskAt:n,completed:i}=t;return typeof r!="number"||!Number.isInteger(r)||r<0||n!==null&&(typeof n!="number"||!Number.isFinite(n))||typeof i!="boolean"?null:{askCount:Math.min(r,Sn),nextAskAt:n,completed:i}}function On(e){let t;try{t=JSON.parse(e)}catch{return null}if(t===null||typeof t!="object"||Array.isArray(t))return null;let r={};for(let[e,n]of Object.entries(t)){let t=Rn(n);if(t===null)return null;r[e]=t}return r}var An=/* @__PURE__ */Symbol.for("@everfur/sdk/texting/ask-schedule@v1");function Dn(){let e=globalThis,t=e[An];return t===void 0&&(t={sessions:/* @__PURE__ */new Map,sessionListeners:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set,writeChain:Promise.resolve()},e[An]=t),t.sessionListeners===void 0&&(t.sessionListeners=/* @__PURE__ */new Set),t}async function Pn(e){if(Cn(e))return{status:"unreadable"};let t;try{t=await e.getItem(wn)}catch{return{status:"unreadable"}}if(t===null)try{return await e.setItem(wn,"{}"),await e.getItem(wn)===null?{status:"unreadable"}:{status:"ok",map:{}}}catch{return{status:"unreadable"}}let r=On(t);if(r!==null)return{status:"ok",map:r};try{await e.removeItem(wn)}catch{}return{status:"unreadable"}}function zn(e){let{listeners:t}=Dn();return t.add(e),()=>{t.delete(e)}}function Ln(e,userRef,t){let r=Dn(),n=async()=>{let n=await Pn(e);if(n.status!=="ok")return;let i=n.map[userRef]??xn;try{await e.setItem(wn,JSON.stringify({...n.map,[userRef]:t(i)}))}catch{return}for(let e of[...r.listeners])e()},i=r.writeChain.then(n,n);return r.writeChain=i.catch(()=>{}),i}async function jn(e,userRef){let t=await Pn(e);return t.status!=="ok"?{status:"unreadable"}:{status:"ok",entry:t.map[userRef]??xn}}function Nn(e,userRef,t=Date.now()){return Ln(e,userRef,e=>Tn(e,t))}function Bn(e,userRef,t=Date.now()){return Ln(e,userRef,e=>En(e,t))}function Mn(e,userRef){return Ln(e,userRef,Fn)}function qn(userRef){return Dn().sessions.get(userRef)??null}function Hn(userRef,e){let t=Dn();t.sessions.set(userRef,e);for(let e of[...t.sessionListeners])e()}function Un(e){let{sessionListeners:t}=Dn();return t.add(e),()=>{t.delete(e)}}var NO_SNAPSHOT=()=>null;function $n(){let{runtime:e}=Vt(),t=e.entitlements??null,n=l(e=>t===null?()=>{}:t.subscribe(e),[t]),i=t===null?NO_SNAPSHOT:t.getSnapshot,a=o(n,i,i);return r(()=>a!==null&&decideCapability("texting",a.decisions,{isPending:a.isPending}).enabled,[a])}var Vn=/* @__PURE__ */Object.freeze({status:"idle"});function Wn(userRef){let{runtime:e}=Vt(),t=e.registry.services.kv,[r,n]=a({user:null,value:Vn});return i(()=>{if(userRef===null)return;let e=true,r=()=>{jn(t,userRef).then(t=>{e&&n({user:userRef,value:{status:"ready",read:t}})})};r();let i=zn(r);return()=>{e=false,i()}},[t,userRef]),r.user===userRef?r.value:Vn}function Yn(e){switch(e.status){case"enroll":case"requesting":case"code":case"confirming":return"none";case"verified":case"optingOut":case"optedOut":return"exists";default:return"unknown"}}function useTextingAsk(e={}){let t=e.enabled!==false,n=e.ready!==false,s=e.surface??"prompt",d=e.entry===true,{runtime:u,userRef:userRef}=Vt(),c=u.registry.services.kv,p=$n(),f=Wn(t&&userRef!==null?userRef:null),h=l(()=>userRef===null?null:qn(userRef),[userRef]),b=o(Un,h,h),y=l(e=>{userRef!==null&&Hn(userRef,e)},[userRef]),g=b!==null&&b.surface===s,m=b!==null&&b.fromPrompt===true,v=g?b.stage==="handoff"?"hidden":b.stage:s==="prompt"&&m?"dismissed":"hidden",_=Date.now(),C=f.status==="ready"&&isTextingAskEligible(f.read,_),[w,k]=a(null),S=d&&userRef!==null&&p,x=Tr(userRef!==null&&w===userRef||v!=="hidden"||g||S),T=Yn(x),{readEnabled:E,due:F}=resolveTextingAskDue({enabled:t,capabilityGranted:p,hasProfile:x.profile!==null,signedIn:userRef!==null,scheduleEligible:C,offeredThisSession:b!==null,identity:T,surfaceReady:n});i(()=>{E&&userRef!==null&&k(userRef)},[E,userRef]);let I=b?.askNumber??(f.status==="ready"&&f.read.status==="ok"?In(f.read.entry):1);i(()=>{!F||userRef===null||qn(userRef)!==null||y({surface:s,stage:"offered",answered:false,askNumber:I})},[F,userRef,y,I,s]),i(()=>{!g||b.stage!=="handoff"||t&&n&&p&&x.profile!==null&&T==="none"&&y({...b,stage:"offered"})},[g,b,t,n,p,x.profile,T,y]);let R=f.status==="ready"&&f.read.status==="ok"&&f.read.entry.completed;i(()=>{userRef===null||T!=="exists"||R||f.status!=="ready"||Mn(c,userRef)},[T,R,f.status,c,userRef]),i(()=>{g&&b.stage==="enrolling"&&x.status==="verified"&&y({...b,stage:"verified"})},[g,b,x.status,y]);let O=l(e=>userRef===null||e.answered?e:(Nn(c,userRef),{...e,answered:true}),[c,userRef]),A=l(()=>{g&&b.stage==="offered"&&y({...b,stage:"enrolling"})},[g,b,y]),D=l(()=>{if(!g||b.stage!=="enrolling")return;let{back:e,...t}=b;y({...t,stage:e??"offered"})},[g,b,y]),P=l(()=>{if(!(!g||b.stage!=="offered"&&b.stage!=="enrolling")){if(s==="prompt"){y({...O(b),surface:"chat",stage:"handoff",fromPrompt:true});return}b.fromPrompt===true&&b.answered&&userRef!==null&&Bn(c,userRef),y({...O(b),stage:"dismissed"})}},[g,b,s,y,O,c,userRef]),{start:z}=x,L=l(async e=>!g||b.stage!=="enrolling"?false:(b.answered||y(O(b)),z(e)),[g,b,y,O,z]),j=S&&x.profile!==null&&T==="none"&&v!=="enrolling"&&v!=="verified",N=l(()=>{if(!j||userRef===null)return;let e=g?b:null;y({surface:s,stage:"enrolling",answered:e?.answered??false,askNumber:b?.askNumber??I,...e?.fromPrompt===true?{fromPrompt:true}:{},back:e?.stage==="offered"?"offered":"dismissed"})},[j,userRef,g,b,y,s,I]),B=x.profile?.brandName??"";return r(()=>({stage:userRef===null?"hidden":v,brand:B,askNumber:I,texting:x,accept:A,dismiss:P,close:D,start:L,canOpen:j,open:N}),[userRef,v,B,I,x,A,P,D,L,j,N])}var Kn=/* @__PURE__ */new Set(["signedOut","unavailable","failed","verified","optingOut","optedOut"]);function Gn(e,t,r,o){let{userRef:userRef}=Vt(),l=n(null),{canOpen:a,open:s,stage:d,texting:u}=e;i(()=>{if(!t){l.current=null;return}if(!(userRef===null||l.current===userRef)){if(a){l.current=userRef,s();return}if(d==="enrolling"||d==="verified"){l.current=userRef;return}(!r||Kn.has(u.status))&&(l.current=userRef,D(o,"skipped"))}},[t,userRef,a,s,d,u.status,r,o])}var Qn=/* @__PURE__ */Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});function ChatTextingAskController({enabled:e,ready:t,onAsk:r,entry:n=false}){let o=useTextingAsk({enabled:e,ready:t,surface:"chat",entry:n});return i(()=>{D(r,o)},[o,r]),null}function textingAskLines(e){return{line:Kt.chatAskLine(e.brand),accept:Yt.promptAccept,dismiss:Yt.promptDismiss,verified:Kt.chatAskVerified(e.brand)}}function ChatTextingAskComposer({ask:e}){let t=useEverfurTheme(),n=r(()=>Jn(t),[t]);/* @__PURE__ */
|
|
69
|
-
return w(AskEntry,{ask:e,styles:n})}function AskEntry({ask:e,styles:t}){let{texting:r}=e,{status:o,profile:l,snapshot:s}=r,[d,u]=a(""),[p,h]=a(false),[b,y]=a(""),[g,m]=a(null),[v,_]=a(false),
|
|
68
|
+
/* @__PURE__ */w(Button,{label:n?a.savingPet:a.savePet,kind:"secondary",busy:n,disabled:!u,styles:e,onPress:()=>{d!==null&&l(d)},testID:"texting-pet-save"}),i&&!u?/* @__PURE__ */w(Text,{style:e.footnote,children:a.petSaved}):null]})]})}function dn(e){let{color:t,radius:r,space:n,type:i,slots:o}=e,l=(t,r,n)=>({...face(e,n),fontSize:t,lineHeight:Math.round(t*i.lineHeight.snug),color:r}),a=o.card?.textColor;return h.create({card:{gap:n.md,padding:n.lg,borderRadius:r.lg,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,...k(o.card,1)},title:l(i.size.subtitle,a??t.text.primary,"bold"),subtitle:l(i.size.body,a??t.text.primary,"bold"),body:l(i.size.body,a??t.text.secondary,"regular"),footnote:l(i.size.caption,t.text.muted,"regular"),phone:l(i.size.body,a??t.text.primary,"bold"),label:l(i.size.caption,a??t.text.primary,"bold"),input:{minHeight:44,paddingHorizontal:n.md,borderRadius:r.md,borderWidth:1,borderColor:t.controlEdge,backgroundColor:t.surface,...l(i.size.body,t.text.primary,"regular"),...k(o.input,1),...x(o.input)},consentRow:{flexDirection:"row",alignItems:"flex-start",gap:n.sm,minHeight:44},box:{width:24,height:24,borderRadius:r.xs,borderWidth:2,borderColor:t.controlEdge,alignItems:"center",justifyContent:"center",backgroundColor:t.surface},boxChecked:{backgroundColor:t.brand,borderColor:t.brandInk},tick:{...l(i.size.caption,t.text.onBrand,"bold")},consentText:{flex:1,...l(i.size.caption,a??t.text.secondary,"regular")},primary:{minHeight:44,paddingHorizontal:n.lg,borderRadius:r.pill,alignItems:"center",justifyContent:"center",backgroundColor:t.brand,...k(o.primaryButton)},primaryLabel:{...l(i.size.body,t.text.onBrand,"bold"),...x(o.primaryButton)},secondary:{minHeight:44,paddingHorizontal:n.lg,borderRadius:r.pill,borderWidth:1,borderColor:t.brandBorder,alignItems:"center",justifyContent:"center",backgroundColor:t.surface},secondaryLabel:l(i.size.caption,t.brandInk,"bold"),link:{minHeight:44,justifyContent:"center",alignSelf:"flex-start"},linkLabel:{...l(i.size.caption,t.linkInk,"bold"),...x(o.link)},dimmed:{opacity:.5},links:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:n.md},notice:{gap:n.xs},noticeText:l(i.size.caption,t.errorRed,"regular"),confirm:{gap:n.sm,padding:n.md,borderRadius:r.md,backgroundColor:t.surfaceSubtle},petRow:{gap:n.xs},chips:{flexDirection:"row",flexWrap:"wrap",gap:n.sm},chip:{minHeight:44,paddingHorizontal:n.md,borderRadius:r.pill,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,justifyContent:"center",...k(o.chip,1)},chipPicked:{backgroundColor:t.brandSoft,borderColor:t.brandInk},chipLabel:{...l(i.size.caption,t.text.primary,"regular"),...x(o.chip)},chipLabelPicked:{...face(e,"bold"),color:t.brandInk}})}var un=/* @__PURE__ */Symbol.for("@everfur/sdk#IntroOpen@v1"),cn=globalThis;function pn(e){if(typeof e!="object"||e===null)return false;let t=e;return t.holds instanceof Set&&t.listeners instanceof Set}var fn=cn[un],hn=()=>({holds:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set}),bn=pn(fn)?fn:cn[un]=hn();function yn(){return bn.holds.size>0}function gn(e){return bn.listeners.add(e),()=>{bn.listeners.delete(e)}}function mn(){return o(gn,yn,yn)}function resolveTextingAskDue(e){let t=e.enabled&&e.capabilityGranted&&e.hasProfile&&e.signedIn&&e.scheduleEligible&&!e.offeredThisSession,r=t&&e.identity==="none"&&e.surfaceReady;return{readEnabled:t,due:r}}var vn=/* @__PURE__ */new Set(["emergency","schedule_soon"]);function textingAskThreadReady(e){if(e.isBootstrapping===true||e.isLoadingHistory===true||e.isStreaming===true||e.status==="error"||e.stopped===true)return false;let t=e.messages[e.messages.length-1];return t===void 0||t.role!=="assistant"||t.pending===true||t.checkin!==void 0||t.text.trim().length===0?false:!(typeof t.urgencyLevel=="string"&&vn.has(t.urgencyLevel))}var _n=/* @__PURE__ */new WeakSet;function Cn(e){return _n.has(e)}var wn="everfur.texting.askSchedule.v1",Sn=2880*60*1e3,kn=3,xn=/* @__PURE__ */Object.freeze({askCount:0,nextAskAt:null,completed:false});function isTextingAskEligible(e,t){if(e.status!=="ok")return false;let{entry:r}=e;return r.completed||r.askCount>=kn?false:r.nextAskAt===null||t>=r.nextAskAt}function Tn(e,t){return{askCount:Math.min(e.askCount+1,kn),nextAskAt:t+Sn,completed:e.completed}}function En(e,t){return{...e,nextAskAt:t+Sn}}function Fn(e){return{...e,completed:true}}function In(e){return e.askCount<=0?1:e.askCount===1?2:3}function Rn(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,{askCount:r,nextAskAt:n,completed:i}=t;return typeof r!="number"||!Number.isInteger(r)||r<0||n!==null&&(typeof n!="number"||!Number.isFinite(n))||typeof i!="boolean"?null:{askCount:Math.min(r,kn),nextAskAt:n,completed:i}}function On(e){let t;try{t=JSON.parse(e)}catch{return null}if(t===null||typeof t!="object"||Array.isArray(t))return null;let r={};for(let[e,n]of Object.entries(t)){let t=Rn(n);if(t===null)return null;r[e]=t}return r}var An=/* @__PURE__ */Symbol.for("@everfur/sdk/texting/ask-schedule@v1");function Dn(){let e=globalThis,t=e[An];return t===void 0&&(t={sessions:/* @__PURE__ */new Map,sessionListeners:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set,writeChain:Promise.resolve()},e[An]=t),t.sessionListeners===void 0&&(t.sessionListeners=/* @__PURE__ */new Set),t}async function Pn(e){if(Cn(e))return{status:"unreadable"};let t;try{t=await e.getItem(wn)}catch{return{status:"unreadable"}}if(t===null)try{return await e.setItem(wn,"{}"),await e.getItem(wn)===null?{status:"unreadable"}:{status:"ok",map:{}}}catch{return{status:"unreadable"}}let r=On(t);if(r!==null)return{status:"ok",map:r};try{await e.removeItem(wn)}catch{}return{status:"unreadable"}}function zn(e){let{listeners:t}=Dn();return t.add(e),()=>{t.delete(e)}}function Ln(e,userRef,t){let r=Dn(),n=async()=>{let n=await Pn(e);if(n.status!=="ok")return;let i=n.map[userRef]??xn;try{await e.setItem(wn,JSON.stringify({...n.map,[userRef]:t(i)}))}catch{return}for(let e of[...r.listeners])e()},i=r.writeChain.then(n,n);return r.writeChain=i.catch(()=>{}),i}async function jn(e,userRef){let t=await Pn(e);return t.status!=="ok"?{status:"unreadable"}:{status:"ok",entry:t.map[userRef]??xn}}function Nn(e,userRef,t=Date.now()){return Ln(e,userRef,e=>Tn(e,t))}function Bn(e,userRef,t=Date.now()){return Ln(e,userRef,e=>En(e,t))}function Mn(e,userRef){return Ln(e,userRef,Fn)}function qn(userRef){return Dn().sessions.get(userRef)??null}function Hn(userRef,e){let t=Dn();t.sessions.set(userRef,e);for(let e of[...t.sessionListeners])e()}function Un(e){let{sessionListeners:t}=Dn();return t.add(e),()=>{t.delete(e)}}var NO_SNAPSHOT=()=>null;function $n(){let{runtime:e}=Vt(),t=e.entitlements??null,n=l(e=>t===null?()=>{}:t.subscribe(e),[t]),i=t===null?NO_SNAPSHOT:t.getSnapshot,a=o(n,i,i);return r(()=>a!==null&&decideCapability("texting",a.decisions,{isPending:a.isPending}).enabled,[a])}var Vn=/* @__PURE__ */Object.freeze({status:"idle"});function Wn(userRef){let{runtime:e}=Vt(),t=e.registry.services.kv,[r,n]=a({user:null,value:Vn});return i(()=>{if(userRef===null)return;let e=true,r=()=>{jn(t,userRef).then(t=>{e&&n({user:userRef,value:{status:"ready",read:t}})})};r();let i=zn(r);return()=>{e=false,i()}},[t,userRef]),r.user===userRef?r.value:Vn}function Yn(e){switch(e.status){case"enroll":case"requesting":case"code":case"confirming":return"none";case"verified":case"optingOut":case"optedOut":return"exists";default:return"unknown"}}function useTextingAsk(e={}){let t=e.enabled!==false,n=e.ready!==false,s=e.surface??"prompt",d=e.entry===true,{runtime:u,userRef:userRef}=Vt(),c=u.registry.services.kv,p=$n(),f=Wn(t&&userRef!==null?userRef:null),h=l(()=>userRef===null?null:qn(userRef),[userRef]),b=o(Un,h,h),y=l(e=>{userRef!==null&&Hn(userRef,e)},[userRef]),g=b!==null&&b.surface===s,m=b!==null&&b.fromPrompt===true,v=g?b.stage==="handoff"?"hidden":b.stage:s==="prompt"&&m?"dismissed":"hidden",_=Date.now(),C=f.status==="ready"&&isTextingAskEligible(f.read,_),[w,S]=a(null),k=d&&userRef!==null&&p,x=Tr(userRef!==null&&w===userRef||v!=="hidden"||g||k),T=Yn(x),{readEnabled:E,due:F}=resolveTextingAskDue({enabled:t,capabilityGranted:p,hasProfile:x.profile!==null,signedIn:userRef!==null,scheduleEligible:C,offeredThisSession:b!==null,identity:T,surfaceReady:n});i(()=>{E&&userRef!==null&&S(userRef)},[E,userRef]);let I=b?.askNumber??(f.status==="ready"&&f.read.status==="ok"?In(f.read.entry):1);i(()=>{!F||userRef===null||qn(userRef)!==null||y({surface:s,stage:"offered",answered:false,askNumber:I})},[F,userRef,y,I,s]),i(()=>{!g||b.stage!=="handoff"||t&&n&&p&&x.profile!==null&&T==="none"&&y({...b,stage:"offered"})},[g,b,t,n,p,x.profile,T,y]);let R=f.status==="ready"&&f.read.status==="ok"&&f.read.entry.completed;i(()=>{userRef===null||T!=="exists"||R||f.status!=="ready"||Mn(c,userRef)},[T,R,f.status,c,userRef]),i(()=>{g&&b.stage==="enrolling"&&x.status==="verified"&&y({...b,stage:"verified"})},[g,b,x.status,y]);let O=l(e=>userRef===null||e.answered?e:(Nn(c,userRef),{...e,answered:true}),[c,userRef]),A=l(()=>{g&&b.stage==="offered"&&y({...b,stage:"enrolling"})},[g,b,y]),D=l(()=>{if(!g||b.stage!=="enrolling")return;let{back:e,...t}=b;y({...t,stage:e??"offered"})},[g,b,y]),P=l(()=>{if(!(!g||b.stage!=="offered"&&b.stage!=="enrolling")){if(s==="prompt"){y({...O(b),surface:"chat",stage:"handoff",fromPrompt:true});return}b.fromPrompt===true&&b.answered&&userRef!==null&&Bn(c,userRef),y({...O(b),stage:"dismissed"})}},[g,b,s,y,O,c,userRef]),{start:z}=x,L=l(async e=>!g||b.stage!=="enrolling"?false:(b.answered||y(O(b)),z(e)),[g,b,y,O,z]),j=k&&x.profile!==null&&T==="none"&&v!=="enrolling"&&v!=="verified",N=l(()=>{if(!j||userRef===null)return;let e=g?b:null;y({surface:s,stage:"enrolling",answered:e?.answered??false,askNumber:b?.askNumber??I,...e?.fromPrompt===true?{fromPrompt:true}:{},back:e?.stage==="offered"?"offered":"dismissed"})},[j,userRef,g,b,y,s,I]),B=x.profile?.brandName??"";return r(()=>({stage:userRef===null?"hidden":v,brand:B,askNumber:I,texting:x,accept:A,dismiss:P,close:D,start:L,canOpen:j,open:N}),[userRef,v,B,I,x,A,P,D,L,j,N])}var Kn=/* @__PURE__ */new Set(["signedOut","unavailable","failed","verified","optingOut","optedOut"]);function Gn(e,t,r,o){let{userRef:userRef}=Vt(),l=n(null),{canOpen:a,open:s,stage:d,texting:u}=e;i(()=>{if(!t){l.current=null;return}if(!(userRef===null||l.current===userRef)){if(a){l.current=userRef,s();return}if(d==="enrolling"||d==="verified"){l.current=userRef;return}(!r||Kn.has(u.status))&&(l.current=userRef,D(o,"skipped"))}},[t,userRef,a,s,d,u.status,r,o])}var Qn=/* @__PURE__ */Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});function ChatTextingAskController({enabled:e,ready:t,onAsk:r,entry:n=false}){let o=useTextingAsk({enabled:e,ready:t,surface:"chat",entry:n});return i(()=>{D(r,o)},[o,r]),null}function textingAskLines(e){return{line:Kt.chatAskLine(e.brand),accept:Yt.promptAccept,dismiss:Yt.promptDismiss,verified:Kt.chatAskVerified(e.brand)}}function ChatTextingAskComposer({ask:e}){let t=useEverfurTheme(),n=r(()=>Jn(t),[t]);/* @__PURE__ */
|
|
69
|
+
return w(AskEntry,{ask:e,styles:n})}function AskEntry({ask:e,styles:t}){let{texting:r}=e,{status:o,profile:l,snapshot:s}=r,[d,u]=a(""),[p,h]=a(false),[b,y]=a(""),[g,m]=a(null),[v,_]=a(false),k={onFocus:()=>_(true),onBlur:()=>_(false)},x=v?[t.pill,t.pillFocused]:t.pill,T=o==="enroll"||o==="requesting"&&!s.resending,E=o==="code"||o==="confirming"||o==="requesting",F=n(null),I=n(null),R=o==="enroll",O=o==="code";i(()=>{m(null)},[o]),i(()=>{R?F.current?.focus():O&&I.current?.focus()},[R,O]);let A=/* @__PURE__ */C(f,{onPress:e.close,accessibilityRole:"button",accessibilityLabel:Yt.close,hitSlop:8,style:t.close,testID:"texting-ask-close",children:[
|
|
70
70
|
/* @__PURE__ */w(c,{style:[t.closeBar,t.closeBarA]}),
|
|
71
71
|
/* @__PURE__ */w(c,{style:[t.closeBar,t.closeBarB]})]}),D=s.error===null?null:textingErrorText(s.error,s.failedAction,s.codeRefusal),P=s.error===null?null:textingSupportText(s.error),z=D===null?null:/* @__PURE__ */C(c,{style:t.notice,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:[
|
|
72
72
|
/* @__PURE__ */w(Text,{style:t.noticeText,children:D}),P===null?null:/* @__PURE__ */w(Text,{style:t.footnote,children:P}),
|
|
73
|
-
/* @__PURE__ */w(AnnounceLine,{line:P===null?D:`${D} ${P}`})]}),L=g===null?null:/* @__PURE__ */C(
|
|
73
|
+
/* @__PURE__ */w(AnnounceLine,{line:P===null?D:`${D} ${P}`})]}),L=g===null?null:/* @__PURE__ */C(S,{children:[
|
|
74
74
|
/* @__PURE__ */w(Text,{style:t.noticeText,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:textingInputProblemText(g)}),
|
|
75
75
|
/* @__PURE__ */w(AnnounceLine,{line:textingInputProblemText(g)})]});if(l===null)return null;if(o==="loading"||o==="failed"||o==="signedOut"||o==="unavailable")/* @__PURE__ */
|
|
76
76
|
return w(c,{style:t.root,testID:"texting-ask-entry",accessibilityState:{busy:o==="loading"},children:/* @__PURE__ */C(c,{style:t.head,children:[
|
|
@@ -82,7 +82,7 @@ return C(c,{style:t.root,testID:"texting-ask-phone",children:[
|
|
|
82
82
|
/* @__PURE__ */w(c,{style:[t.box,p?t.boxChecked:null],accessibilityElementsHidden:true,importantForAccessibility:"no",children:p?/* @__PURE__ */w(Text,{style:t.tick,children:"✓"}):null}),
|
|
83
83
|
/* @__PURE__ */w(Text,{style:t.consentText,children:l.consentText})]}),l.helpContact===null?null:/* @__PURE__ */C(Text,{style:t.footnote,children:[Yt.helpContactLabel," ",l.helpContact]})]}),A]}),L,z,
|
|
84
84
|
/* @__PURE__ */C(c,{style:x,children:[
|
|
85
|
-
/* @__PURE__ */w(Zr,{value:d,onChangeText:u,editable:!r,keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",accessibilityLabel:Yt.phoneLabel,placeholder:Yt.phoneLabel,placeholderTextColor:t.placeholder.color,ref:F,onSubmitEditing:n,...
|
|
85
|
+
/* @__PURE__ */w(Zr,{value:d,onChangeText:u,editable:!r,keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",accessibilityLabel:Yt.phoneLabel,placeholder:Yt.phoneLabel,placeholderTextColor:t.placeholder.color,ref:F,onSubmitEditing:n,...k,style:t.field,testID:"texting-ask-phone-input"},"phone"),
|
|
86
86
|
/* @__PURE__ */w(f,{onPress:n,disabled:r,accessibilityRole:"button",accessibilityLabel:r?Yt.sendingCode:Yt.sendCode,accessibilityState:{disabled:r,busy:r},style:[t.primary,r?t.dimmed:null],testID:"texting-ask-send",children:/* @__PURE__ */w(Text,{tier:"control",style:t.primaryLabel,children:r?Yt.sendingCode:Yt.sendCode})})]})]})}if(E){let e=o==="confirming",n=o==="requesting",i=e||n,l=()=>{let e=validateTextingCode(b);m(e),e===null&&r.confirm(b)};/* @__PURE__ */
|
|
87
87
|
return C(c,{style:t.root,testID:"texting-ask-code",children:[
|
|
88
88
|
/* @__PURE__ */C(c,{style:t.head,children:[
|
|
@@ -92,15 +92,15 @@ return C(c,{style:t.root,testID:"texting-ask-code",children:[
|
|
|
92
92
|
/* @__PURE__ */w(f,{onPress:()=>{y(""),r.resend()},disabled:i,accessibilityRole:"button",accessibilityState:{disabled:i,busy:n},style:[t.link,i?t.dimmed:null],children:/* @__PURE__ */w(Text,{style:t.linkLabel,children:Yt.requestNewCode})}),
|
|
93
93
|
/* @__PURE__ */w(f,{onPress:()=>{y(""),r.changeNumber()},disabled:i,accessibilityRole:"button",accessibilityState:{disabled:i},style:[t.link,i?t.dimmed:null],children:/* @__PURE__ */w(Text,{style:t.linkLabel,children:Yt.changeNumber})})]})]}),A]}),L,z,
|
|
94
94
|
/* @__PURE__ */C(c,{style:x,children:[
|
|
95
|
-
/* @__PURE__ */w(Zr,{value:b,onChangeText:e=>y(e.replace(/\D/g,"")),editable:!i,keyboardType:"number-pad",textContentType:"oneTimeCode",autoComplete:"sms-otp",maxLength:6,accessibilityLabel:Yt.codeLabel,placeholder:Yt.codeLabel,placeholderTextColor:t.placeholder.color,ref:I,onSubmitEditing:l,...
|
|
96
|
-
/* @__PURE__ */w(f,{onPress:l,disabled:i,accessibilityRole:"button",accessibilityLabel:e?Yt.confirmingCode:Yt.confirmCode,accessibilityState:{disabled:i,busy:e},style:[t.primary,i?t.dimmed:null],testID:"texting-ask-confirm",children:/* @__PURE__ */w(Text,{tier:"control",style:t.primaryLabel,children:e?Yt.confirmingCode:Yt.confirmCode})})]})]})}return null}function Jn(e,t="auto"){let{color:r,radius:n,space:i,type:o,slots:l}=e,a=(t,r,n)=>({...face(e,n),fontSize:t,lineHeight:Math.round(t*o.lineHeight.snug),color:r}),s={textAlign:t};return h.create({root:{gap:i.sm,width:"100%"},head:{flexDirection:"row",alignItems:"flex-start",gap:i.sm},headBody:{flex:1,minWidth:0,gap:i.xs},consentRow:{flexDirection:"row",alignItems:"flex-start",gap:i.sm,minHeight:44},box:{width:24,height:24,borderRadius:n.xs,borderWidth:2,borderColor:r.controlEdge,alignItems:"center",justifyContent:"center",backgroundColor:r.surface},boxChecked:{backgroundColor:r.brand,borderColor:r.brandInk},tick:a(o.size.caption,r.text.onBrand,"bold"),consentText:{...t==="center"?{flexShrink:1}:{flex:1},...a(o.size.caption,r.text.secondary,"regular"),...s},body:{...a(o.size.body,r.text.primary,"regular"),...s},footnote:{...a(o.size.caption,r.text.muted,"regular"),...s},placeholder:{color:r.text.placeholder},pill:{flexDirection:"row",alignItems:"center",gap:i.xs,minHeight:50,paddingVertical:i.xs,paddingLeft:i.md,paddingRight:i.xs,borderRadius:n.pill,borderWidth:1.5,borderColor:r.controlEdge,backgroundColor:r.surface,...
|
|
97
|
-
return w(b,{transparent:true,visible:true,animationType:s.motion.reducedMotion?"none":"fade",statusBarTranslucent:true,supportedOrientations:Xn,onRequestClose:
|
|
98
|
-
/* @__PURE__ */w(f,{style:Qn,accessibilityRole:"button",accessibilityLabel:Yt.close,onPress:
|
|
95
|
+
/* @__PURE__ */w(Zr,{value:b,onChangeText:e=>y(e.replace(/\D/g,"")),editable:!i,keyboardType:"number-pad",textContentType:"oneTimeCode",autoComplete:"sms-otp",maxLength:6,accessibilityLabel:Yt.codeLabel,placeholder:Yt.codeLabel,placeholderTextColor:t.placeholder.color,ref:I,onSubmitEditing:l,...k,style:[t.field,t.digits],testID:"texting-ask-code-input"},"code"),
|
|
96
|
+
/* @__PURE__ */w(f,{onPress:l,disabled:i,accessibilityRole:"button",accessibilityLabel:e?Yt.confirmingCode:Yt.confirmCode,accessibilityState:{disabled:i,busy:e},style:[t.primary,i?t.dimmed:null],testID:"texting-ask-confirm",children:/* @__PURE__ */w(Text,{tier:"control",style:t.primaryLabel,children:e?Yt.confirmingCode:Yt.confirmCode})})]})]})}return null}function Jn(e,t="auto"){let{color:r,radius:n,space:i,type:o,slots:l}=e,a=(t,r,n)=>({...face(e,n),fontSize:t,lineHeight:Math.round(t*o.lineHeight.snug),color:r}),s={textAlign:t};return h.create({root:{gap:i.sm,width:"100%"},head:{flexDirection:"row",alignItems:"flex-start",gap:i.sm},headBody:{flex:1,minWidth:0,gap:i.xs},consentRow:{flexDirection:"row",alignItems:"flex-start",gap:i.sm,minHeight:44},box:{width:24,height:24,borderRadius:n.xs,borderWidth:2,borderColor:r.controlEdge,alignItems:"center",justifyContent:"center",backgroundColor:r.surface},boxChecked:{backgroundColor:r.brand,borderColor:r.brandInk},tick:a(o.size.caption,r.text.onBrand,"bold"),consentText:{...t==="center"?{flexShrink:1}:{flex:1},...a(o.size.caption,r.text.secondary,"regular"),...s},body:{...a(o.size.body,r.text.primary,"regular"),...s},footnote:{...a(o.size.caption,r.text.muted,"regular"),...s},placeholder:{color:r.text.placeholder},pill:{flexDirection:"row",alignItems:"center",gap:i.xs,minHeight:50,paddingVertical:i.xs,paddingLeft:i.md,paddingRight:i.xs,borderRadius:n.pill,borderWidth:1.5,borderColor:r.controlEdge,backgroundColor:r.surface,...k(l.input,1)},pillFocused:{borderWidth:1.5,borderColor:l.input?.borderColor??r.brandInk},field:{flex:1,minWidth:0,minHeight:44,padding:0,...a(o.size.body,r.text.primary,"regular"),...x(l.input)},digits:{fontVariant:["tabular-nums"]},primary:{minHeight:44,paddingHorizontal:i.lg,borderRadius:n.pill,alignItems:"center",justifyContent:"center",backgroundColor:r.brand,...k(l.primaryButton)},primaryLabel:{...a(o.size.caption,r.text.onBrand,"bold"),...x(l.primaryButton)},dimmed:{opacity:.5},close:{width:44,height:44,alignItems:"center",justifyContent:"center"},closeBar:{position:"absolute",width:18,height:2,borderRadius:1,backgroundColor:r.text.muted},closeBarA:{transform:[{rotate:"45deg"}]},closeBarB:{transform:[{rotate:"-45deg"}]},links:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:i.md},link:{minHeight:44,justifyContent:"center"},linkLabel:{...a(o.size.caption,r.linkInk,"bold"),...x(l.link)},notice:{gap:i.xs},noticeText:{...a(o.size.caption,r.errorRed,"regular"),...s}})}var Xn=["portrait","landscape"],Zn=/* @__PURE__ */new Set(["offered","enrolling"]);function EverfurTextingPrompt({onResolved:e,requested:t=false}){let o=mn(),l=useTextingAsk({surface:"prompt",ready:!o,entry:t});Gn(l,t,$n(),e);let s=useEverfurTheme(),d=r(()=>ei(s),[s]),u=r(()=>Jn(s,"center"),[s]),p=n(false),[h,v]=a(false);Zn.has(l.stage)&&(p.current=true);let _=p.current&&(Zn.has(l.stage)||l.stage==="verified")&&!h&&!o,k=()=>{h||(l.stage==="verified"?(v(true),D(e,"verified")):l.dismiss())};if(i(()=>{p.current&&l.stage==="dismissed"&&!h&&(v(true),D(e,"dismissed"))},[l.stage,e,h]),!_)return null;let x=l.stage==="verified"?Yt.verifiedTitle:Kt.promptTitle(l.brand);/* @__PURE__ */
|
|
97
|
+
return w(b,{transparent:true,visible:true,animationType:s.motion.reducedMotion?"none":"fade",statusBarTranslucent:true,supportedOrientations:Xn,onRequestClose:k,children:/* @__PURE__ */C(y,{behavior:m.OS==="ios"?"padding":"height",style:d.backdrop,children:[
|
|
98
|
+
/* @__PURE__ */w(f,{style:Qn,accessibilityRole:"button",accessibilityLabel:Yt.close,onPress:k}),
|
|
99
99
|
/* @__PURE__ */w(c,{style:d.sheet,accessibilityViewIsModal:true,testID:"everfur-texting-prompt",children:/* @__PURE__ */C(g,{style:d.scroller,contentContainerStyle:d.sheetBody,keyboardShouldPersistTaps:"handled",bounces:false,testID:"everfur-texting-prompt-scroll",children:[
|
|
100
|
-
/* @__PURE__ */w(Text,{style:d.title,accessibilityRole:"header",children:x}),l.stage==="offered"?/* @__PURE__ */C(
|
|
100
|
+
/* @__PURE__ */w(Text,{style:d.title,accessibilityRole:"header",children:x}),l.stage==="offered"?/* @__PURE__ */C(S,{children:[
|
|
101
101
|
/* @__PURE__ */w(Text,{style:d.body,children:Yt.promptBody}),
|
|
102
102
|
/* @__PURE__ */C(c,{style:d.actions,children:[
|
|
103
103
|
/* @__PURE__ */w(f,{onPress:l.accept,accessibilityRole:"button",accessibilityLabel:Yt.promptAccept,style:d.primary,testID:"texting-prompt-accept",children:/* @__PURE__ */w(Text,{tier:"control",style:d.primaryLabel,children:Yt.promptAccept})}),
|
|
104
|
-
/* @__PURE__ */w(f,{onPress:l.dismiss,accessibilityRole:"button",accessibilityLabel:Yt.promptDismiss,style:d.secondary,testID:"texting-prompt-dismiss",children:/* @__PURE__ */w(Text,{tier:"control",style:d.secondaryLabel,children:Yt.promptDismiss})})]})]}):null,l.stage==="enrolling"?/* @__PURE__ */w(AskEntry,{ask:l,styles:u}):null,l.stage==="verified"?/* @__PURE__ */C(
|
|
104
|
+
/* @__PURE__ */w(f,{onPress:l.dismiss,accessibilityRole:"button",accessibilityLabel:Yt.promptDismiss,style:d.secondary,testID:"texting-prompt-dismiss",children:/* @__PURE__ */w(Text,{tier:"control",style:d.secondaryLabel,children:Yt.promptDismiss})})]})]}):null,l.stage==="enrolling"?/* @__PURE__ */w(AskEntry,{ask:l,styles:u}):null,l.stage==="verified"?/* @__PURE__ */C(S,{children:[
|
|
105
105
|
/* @__PURE__ */w(Text,{style:d.body,children:Kt.chatAskVerified(l.brand)}),
|
|
106
|
-
/* @__PURE__ */w(c,{style:d.actions,children:/* @__PURE__ */w(f,{onPress:
|
|
106
|
+
/* @__PURE__ */w(c,{style:d.actions,children:/* @__PURE__ */w(f,{onPress:k,accessibilityRole:"button",accessibilityLabel:Yt.close,style:d.secondary,testID:"texting-prompt-close",children:/* @__PURE__ */w(Text,{tier:"control",style:d.secondaryLabel,children:Yt.close})})})]}):null]})})]})})}function ei(e){let{color:t,radius:r,space:n,type:i,slots:o}=e,l=x(o.dialog),a=(t,r,n)=>({...face(e,n),fontSize:t,lineHeight:Math.round(t*i.lineHeight.normal),color:r}),s={minHeight:48,paddingHorizontal:n.lg,borderRadius:r.pill,alignItems:"center",justifyContent:"center"};return h.create({backdrop:{flex:1,justifyContent:"center",paddingHorizontal:n.lg,backgroundColor:"rgba(0,0,0,0.4)"},sheet:{width:"100%",maxWidth:480,alignSelf:"center",backgroundColor:t.surface,borderRadius:r.xl,maxHeight:"88%",overflow:"hidden",...k(o.dialog)},scroller:{flexGrow:0,flexShrink:1},sheetBody:{paddingHorizontal:n.lg,paddingTop:n.xl,paddingBottom:n.lg,gap:n.md},title:{...a(i.size.heading,t.text.primary,"bold"),...headingFace(e,"bold"),textAlign:"center",...l},body:{...a(i.size.body,t.text.secondary,"regular"),textAlign:"center",...l},actions:{gap:n.xs},primary:{...s,backgroundColor:t.brand,...k(o.primaryButton)},primaryLabel:{...a(i.size.body,t.text.onBrand,"bold"),...x(o.primaryButton)},secondary:s,secondaryLabel:a(i.size.body,t.text.muted,"bold")})}export{Wt as COPY_PLACEHOLDER_PREFIX,ChatTextingAskComposer,ChatTextingAskController,sr as EVERFUR_TEXTING_STATUSES,EverfurTextingOptIn,EverfurTextingPrompt,kn as TEXTING_ASK_MAX_ASKS,wn as TEXTING_ASK_SCHEDULE_KEY,Sn as TEXTING_ASK_SNOOZE_MS,Kt as TEXTING_BRAND_COPY,dr as TEXTING_CODE_PATTERN,Yt as TEXTING_COPY,Gt as TEXTING_COPY_PLACEHOLDERS,kr as TEXTING_UI_CODE_LENGTH,wr as TextingController,createTextingRepository,createTextingRepositoryOver,formatTextingPhone,isE164,isTextingAskEligible,parseTextingProfile,resolveTextingAskDue,textingAskLines,textingAskThreadReady,textingErrorText,textingIdentityFromWire,textingInputProblemText,textingOptedOutBody,textingReasonOf,textingSupportText,toTextingE164,useEverfurTexting,useEverfurTextingProfile,useEverfurTextingRepository,useTextingAsk,validateTextingCode,validateTextingEnroll};
|