@everfur/sdk 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Chat.d-B4GybUU4.d.ts → Chat.d-BIr_4AJt.d.ts} +1 -1
- package/dist/{Chat.d-DPM2ncxi.d.cts → Chat.d-BhevtXn9.d.cts} +1 -1
- package/dist/{DepthViews.d-BGspxovy.d.cts → DepthViews.d-C8KdfzwR.d.cts} +1 -1
- package/dist/{DepthViews.d-BaLh7Lsi.d.cts → DepthViews.d-DWQ-J208.d.cts} +1 -1
- package/dist/{DepthViews.d-BIHVrf9r.d.ts → DepthViews.d-DYVUq4Xk.d.ts} +1 -1
- package/dist/{DepthViews.d-CEVk9poG.d.ts → DepthViews.d-oKr9R0Ql.d.ts} +1 -1
- package/dist/{IntakeMedia.d-CwSkSLNM.d.ts → IntakeMedia.d-B-ZZK6vd.d.ts} +1 -1
- package/dist/{IntakeMedia.d-LRXO38_z.d.cts → IntakeMedia.d-CuVkzIsO.d.cts} +1 -1
- package/dist/{IntakeMedia.d-DmaeGU6T.d.cts → IntakeMedia.d-CyF6NPHx.d.cts} +1 -1
- package/dist/{IntakeMedia.d-Dyb9R8b0.d.ts → IntakeMedia.d-vU8g9OM5.d.ts} +1 -1
- package/dist/{RecordsPage.d-D10RIgdc.d.ts → RecordsPage.d-DU8Nswzh.d.ts} +1 -1
- package/dist/{RecordsPage.d-DbhYNSbq.d.cts → RecordsPage.d-DzPhqMHW.d.cts} +1 -1
- package/dist/animations/index.d.cts +3 -3
- package/dist/animations/index.d.ts +3 -3
- package/dist/{attachments.d-CF4lLuGK.d.cts → attachments.d-0nOPDIng.d.cts} +1 -1
- package/dist/{attachments.d-BlukNfIf.d.ts → attachments.d-BlyI-RCY.d.ts} +1 -1
- package/dist/{bookingCopy.d-Bn8bdo89.d.ts → bookingCopy.d-ClL8OxBS.d.ts} +3 -3
- package/dist/{bookingCopy.d-Dg7bPM-U.d.cts → bookingCopy.d-DUVqhF5f.d.cts} +3 -3
- package/dist/{branding.d-XrZYClN4.d.ts → branding.d-D0LV3aFE.d.ts} +1 -1
- package/dist/{branding.d-CqDLKj1U.d.cts → branding.d-DzSPLZKl.d.cts} +1 -1
- package/dist/{casesRepository.d-CVuKTkJo.d.cts → casesRepository.d-DnanKXJ1.d.cts} +1 -1
- package/dist/{casesRepository.d-Dn1fK1b2.d.ts → casesRepository.d-_4QucKVC.d.ts} +1 -1
- package/dist/chat/index.cjs +239 -238
- package/dist/chat/index.d.cts +11 -11
- package/dist/chat/index.d.ts +11 -11
- package/dist/chat/index.js +241 -240
- package/dist/chat/lite/index.cjs +239 -238
- package/dist/chat/lite/index.d.cts +11 -11
- package/dist/chat/lite/index.d.ts +11 -11
- package/dist/chat/lite/index.js +239 -238
- package/dist/chat-cards/index.cjs +2 -2
- package/dist/chat-cards/index.js +9 -9
- package/dist/{chatHandoffToken.d-zdp23Ukr.d.ts → chatHandoffToken.d-BoZGGbIB.d.ts} +5 -5
- package/dist/{chatHandoffToken.d-Cap2z62P.d.cts → chatHandoffToken.d-DhhGdLNH.d.cts} +5 -5
- package/dist/{checkin.d-CuIUahcd.d.cts → checkin.d-DB-HlK7r.d.cts} +9 -4
- package/dist/{checkin.d-BoZXWjxX.d.ts → checkin.d-DogrR06X.d.ts} +9 -4
- package/dist/{chunk-LMIBOI3I.js → chunk-6E3J6IVM.js} +13 -13
- package/dist/{chunk-6AIEUA4V.js → chunk-J5ZUBY3S.js} +1 -1
- package/dist/{chunk-BN7OAFBS.js → chunk-LPHBCDJP.js} +21 -21
- package/dist/{chunk-IXHLESYC.js → chunk-ULQDOC75.js} +1 -1
- package/dist/client/index.cjs +28 -27
- package/dist/client/index.d.cts +13 -13
- package/dist/client/index.d.ts +13 -13
- package/dist/client/index.js +25 -24
- package/dist/{clinicBatch.d-C0xx5L4j.d.cts → clinicBatch.d-BvPF6vXS.d.cts} +2 -2
- package/dist/{clinicBatch.d-DNi4UURs.d.ts → clinicBatch.d-CF0GIvpx.d.ts} +2 -2
- package/dist/{config.d-B7Z-KTGq.d.ts → config.d-Bc41Ax6M.d.ts} +5 -1
- package/dist/{config.d-ClAI2RZ6.d.cts → config.d-Bn6GEGfl.d.cts} +5 -1
- package/dist/consent/index.d.cts +5 -5
- package/dist/consent/index.d.ts +5 -5
- package/dist/{context.d-D7zX6Q0J.d.ts → context.d-0QfLaI3W.d.ts} +5 -5
- package/dist/{context.d-guaLkx5t.d.cts → context.d-CyQpedoU.d.cts} +5 -5
- package/dist/{copy.d--F5A9cXK.d.cts → copy.d-B55PpLxr.d.cts} +2 -2
- package/dist/{copy.d-DmxuFJFe.d.ts → copy.d-B8wIE6cH.d.ts} +2 -2
- package/dist/core/index.cjs +32 -31
- package/dist/core/index.d.cts +22 -16
- package/dist/core/index.d.ts +22 -16
- package/dist/core/index.js +37 -36
- package/dist/{depth.d-CgzYE6_n.d.ts → depth.d-CrtZXnLy.d.ts} +2 -2
- package/dist/{depth.d-DLaP0o8Y.d.cts → depth.d-Cxz6VisZ.d.cts} +2 -2
- package/dist/{entitlementRepository.d-CkUTlVAb.d.ts → entitlementRepository.d-BaZTIe1B.d.ts} +3 -3
- package/dist/{entitlementRepository.d-DVTp-BB9.d.cts → entitlementRepository.d-YeNG2TKI.d.cts} +3 -3
- package/dist/{focus.d-u-HYvim0.d.ts → focus.d-520VEHKB.d.ts} +1 -1
- package/dist/{focus.d-CLTjm6In.d.cts → focus.d-DoempN1I.d.cts} +1 -1
- package/dist/health-plan/index.cjs +236 -235
- package/dist/health-plan/index.d.cts +15 -15
- package/dist/health-plan/index.d.ts +15 -15
- package/dist/health-plan/index.js +236 -235
- package/dist/{healthPlanRepository.d-CwRXeoM7.d.ts → healthPlanRepository.d-BHu9LO0r.d.ts} +2 -2
- package/dist/{healthPlanRepository.d-B22kjrYa.d.cts → healthPlanRepository.d-tUR1f_5s.d.cts} +2 -2
- package/dist/{idempotency.d-DrxKLPPe.d.cts → idempotency.d-CcFLvzYW.d.cts} +1 -1
- package/dist/{idempotency.d-CbB07p64.d.ts → idempotency.d-CvqKG3Uq.d.ts} +1 -1
- package/dist/{identity.d-D4VtpqRr.d.ts → identity.d-Bex_XJZx.d.ts} +1 -1
- package/dist/{identity.d-DDpXOtas.d.cts → identity.d-Dm0Buvn8.d.cts} +1 -1
- package/dist/{inbox.d-B2JXK0uI.d.ts → inbox.d-9ajb0oiJ.d.ts} +1 -1
- package/dist/{inbox.d-CwA1ogzV.d.cts → inbox.d-CGCYOZIq.d.cts} +1 -1
- package/dist/index.cjs +259 -258
- package/dist/index.d.cts +17 -17
- package/dist/index.d.ts +17 -17
- package/dist/index.js +258 -257
- package/dist/{introEvents.d-DW3gLljE.d.ts → introEvents.d-CuVaufTy.d.ts} +1 -1
- package/dist/{introEvents.d-B7acmGwf.d.cts → introEvents.d-DU6feqx4.d.cts} +1 -1
- package/dist/{layout.d-C8y_ki1V.d.ts → layout.d-BQ5IVS-m.d.ts} +1 -1
- package/dist/{layout.d-DfaFM_lp.d.cts → layout.d-CSPr33BP.d.cts} +1 -1
- package/dist/notifications/inbox/index.d.cts +6 -6
- package/dist/notifications/inbox/index.d.ts +6 -6
- package/dist/notifications/index.d.cts +7 -7
- package/dist/notifications/index.d.ts +7 -7
- package/dist/{optInView.d-Cps7aLQN.d.ts → optInView.d-DpGXnpGw.d.ts} +21 -3
- package/dist/{optInView.d-ChJyJMBA.d.cts → optInView.d-dLjrI3co.d.cts} +21 -3
- package/dist/{pets.d-BpLObpfM.d.ts → pets.d-CHdSIoBf.d.ts} +1 -1
- package/dist/{pets.d-DXhzTNuI.d.cts → pets.d-jnhrJhqm.d.cts} +1 -1
- package/dist/{petsRepository.d-ai_tZ3lu.d.cts → petsRepository.d-BeKRiNao.d.cts} +1 -1
- package/dist/{petsRepository.d-_QfM7F6T.d.ts → petsRepository.d-BjwB1vku.d.ts} +1 -1
- package/dist/{presentation.d-BkIvMtIl.d.cts → presentation.d-Br3TnwA6.d.cts} +17 -1
- package/dist/{presentation.d-BkIvMtIl.d.ts → presentation.d-Br3TnwA6.d.ts} +17 -1
- package/dist/records/depth/index.d.cts +9 -9
- package/dist/records/depth/index.d.ts +9 -9
- package/dist/records/index.cjs +237 -228
- package/dist/records/index.d.cts +39 -12
- package/dist/records/index.d.ts +39 -12
- package/dist/records/index.js +155 -146
- package/dist/{requestFunnel.d-DKBPTpsy.d.ts → requestFunnel.d-C_NMgz9R.d.ts} +2 -2
- package/dist/{requestFunnel.d-BwZDfWVD.d.cts → requestFunnel.d-DoJWLySc.d.cts} +2 -2
- package/dist/{route.d-QBCoO62z.d.cts → route.d-BW2abFVK.d.cts} +2 -2
- package/dist/{route.d-B3u14HJT.d.ts → route.d-Olr_gXaa.d.ts} +2 -2
- package/dist/{runtimeTypes.d-hjN6xvxm.d.ts → runtimeTypes.d-Bp2VW6YE.d.ts} +6 -6
- package/dist/{runtimeTypes.d-BSxuUCOX.d.cts → runtimeTypes.d-StvJY45N.d.cts} +6 -6
- package/dist/{screenProps.d-fHBKArt_.d.ts → screenProps.d-BTLSji0N.d.ts} +1 -1
- package/dist/{screenProps.d-6xmE1C-V.d.cts → screenProps.d-B_5Bh7aQ.d.cts} +1 -1
- package/dist/server/events/index.cjs +2 -2
- package/dist/server/events/index.d.cts +19 -5
- package/dist/server/events/index.d.ts +19 -5
- package/dist/server/events/index.js +2 -2
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.d.cts +3 -3
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +1 -1
- package/dist/shop/index.d.cts +3 -3
- package/dist/shop/index.d.ts +3 -3
- package/dist/slots/index.cjs +200 -199
- package/dist/slots/index.d.cts +5 -5
- package/dist/slots/index.d.ts +5 -5
- package/dist/slots/index.js +200 -199
- package/dist/tabs/index.cjs +200 -190
- package/dist/tabs/index.d.cts +68 -11
- package/dist/tabs/index.d.ts +68 -11
- package/dist/tabs/index.js +201 -191
- package/dist/tabs-bar/index.cjs +247 -0
- package/dist/tabs-bar/index.d.cts +10 -0
- package/dist/tabs-bar/index.d.ts +10 -0
- package/dist/tabs-bar/index.js +247 -0
- package/dist/{tabsModel.d-D9GWPFrL.d.ts → tabsModel.d-B4MSQB57.d.cts} +5 -2
- package/dist/{tabsModel.d-D9GWPFrL.d.cts → tabsModel.d-C8pd-DP3.d.ts} +5 -2
- package/dist/televet/booking/index.cjs +147 -145
- package/dist/televet/booking/index.d.cts +10 -10
- package/dist/televet/booking/index.d.ts +10 -10
- package/dist/televet/booking/index.js +163 -161
- package/dist/televet/call/index.cjs +52 -52
- package/dist/televet/call/index.d.cts +5 -0
- package/dist/televet/call/index.d.ts +5 -0
- package/dist/televet/call/index.js +25 -25
- package/dist/televet/index.d.cts +3 -3
- package/dist/televet/index.d.ts +3 -3
- package/dist/{televetGlobal.d-gZrXPaLl.d.cts → televetGlobal.d-B_I_fy7O.d.cts} +9 -0
- package/dist/{televetGlobal.d-DkJkV55Y.d.ts → televetGlobal.d-DN7o45WJ.d.ts} +9 -0
- package/dist/testing/index.cjs +3 -3
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +3 -3
- package/dist/testing/rn/index.d.cts +9 -9
- package/dist/testing/rn/index.d.ts +9 -9
- package/dist/testing/web/index.d.cts +9 -9
- package/dist/testing/web/index.d.ts +9 -9
- package/dist/texting/index.cjs +32 -27
- package/dist/texting/index.d.cts +5 -5
- package/dist/texting/index.d.ts +5 -5
- package/dist/texting/index.js +52 -47
- package/dist/{threadOptions.d-NSlFx-Lp.d.ts → threadOptions.d-D_3hk79R.d.ts} +5 -5
- package/dist/{threadOptions.d-Dc57dm7h.d.cts → threadOptions.d-D_GU6lp9.d.cts} +5 -5
- package/dist/{timelineRows.d-CthNM5hV.d.ts → timelineRows.d-BbVuARtc.d.ts} +1 -1
- package/dist/{timelineRows.d-7w8NsNi4.d.cts → timelineRows.d-BiLAAbYl.d.cts} +1 -1
- package/dist/{typeStyle.d-8mcLhtbH.d.ts → typeStyle.d-DSk99BuZ.d.ts} +1 -1
- package/dist/{typeStyle.d-CLrQZW-r.d.cts → typeStyle.d-DqR6mWCF.d.cts} +1 -1
- package/dist/{useHealthPlanSubscription.d-CV7M21HS.d.ts → useHealthPlanSubscription.d-CpE6l1VW.d.ts} +3 -3
- package/dist/{useHealthPlanSubscription.d-SA9-SuKe.d.cts → useHealthPlanSubscription.d-DRiWDJXq.d.cts} +3 -3
- package/dist/{useInboxUnread.d-0DrQPn7J.d.ts → useInboxUnread.d-BV7PkWDH.d.ts} +1 -1
- package/dist/{useInboxUnread.d-CRcOTkmu.d.cts → useInboxUnread.d-CElyXBkY.d.cts} +1 -1
- package/dist/{usePresentation.d-BJzFicRQ.d.cts → usePresentation.d-BcazazQH.d.cts} +3 -3
- package/dist/{usePresentation.d-DgSGIWS-.d.ts → usePresentation.d-CMOypLlH.d.ts} +3 -3
- package/dist/{useRecordsDepth.d-ZX2rhcUx.d.ts → useRecordsDepth.d-Bka4KQhq.d.ts} +1 -1
- package/dist/{useRecordsDepth.d-C9W45gwS.d.cts → useRecordsDepth.d-TgmpxKdX.d.cts} +1 -1
- package/dist/{useUnread.d-4SbFChbd.d.ts → useUnread.d-CGqaP-dB.d.ts} +27 -5
- package/dist/{useUnread.d-B0YhhR_D.d.cts → useUnread.d-DVVnYNPU.d.cts} +27 -5
- package/dist/{view.d-3lxzyJlL.d.cts → view.d-CwruYhQy.d.cts} +3 -3
- package/dist/{view.d-DRiYNQJ8.d.ts → view.d-DamH8TQF.d.ts} +3 -3
- package/dist/web/consent/index.d.cts +5 -5
- package/dist/web/consent/index.d.ts +5 -5
- package/dist/web/health-plan/index.cjs +9 -8
- package/dist/web/health-plan/index.d.cts +16 -16
- package/dist/web/health-plan/index.d.ts +16 -16
- package/dist/web/health-plan/index.js +49 -48
- package/dist/web/inbox/index.d.cts +7 -7
- package/dist/web/inbox/index.d.ts +7 -7
- package/dist/web/index.cjs +185 -184
- package/dist/web/index.d.cts +32 -32
- package/dist/web/index.d.ts +32 -32
- package/dist/web/index.js +187 -186
- package/dist/web/intro/index.d.cts +7 -7
- package/dist/web/intro/index.d.ts +7 -7
- package/dist/web/notifications/index.d.cts +6 -6
- package/dist/web/notifications/index.d.ts +6 -6
- package/dist/web/records/depth/index.d.cts +9 -9
- package/dist/web/records/depth/index.d.ts +9 -9
- package/dist/web/records/index.d.cts +11 -11
- package/dist/web/records/index.d.ts +11 -11
- package/dist/web/records-sheet/index.cjs +111 -110
- package/dist/web/records-sheet/index.js +111 -110
- package/dist/web/shop/index.cjs +1 -1
- package/dist/web/shop/index.d.cts +3 -3
- package/dist/web/shop/index.d.ts +3 -3
- package/dist/web/shop/index.js +1 -1
- package/dist/web/televet/booking/index.cjs +3 -3
- package/dist/web/televet/booking/index.d.cts +10 -10
- package/dist/web/televet/booking/index.d.ts +10 -10
- package/dist/web/televet/booking/index.js +69 -69
- package/dist/web/televet/call/index.cjs +1 -1
- package/dist/web/televet/call/index.js +1 -1
- package/dist/web/televet/index.d.cts +3 -3
- package/dist/web/televet/index.d.ts +3 -3
- package/dist/web/texting/index.cjs +34 -29
- package/dist/web/texting/index.d.cts +5 -5
- package/dist/web/texting/index.d.ts +5 -5
- package/dist/web/texting/index.js +45 -40
- package/dist/web/ui/index.cjs +1 -1
- package/dist/web/ui/index.js +33 -33
- package/package.json +16 -1
- package/tabs-bar/package.json +8 -0
|
@@ -1,69 +1,74 @@
|
|
|
1
1
|
/*! @everfur/sdk. Copyright (c) 2026 Strand Health Inc. dba Everfur. All rights reserved. Use is subject to the Everfur SDK License: https://docs.everfur.com/license */
|
|
2
2
|
"use client";
|
|
3
|
-
import{createContext,useMemo as e,useRef as t,useEffect as r,useSyncExternalStore as n,useCallback as i,useId as o,useState as a,useContext as l,createElement as s,Component as d}from"react";import{jsxs as u,jsx as c,Fragment as p}from"react/jsx-runtime";function f(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e)}catch{}}function h(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}function b(e,...t){if(typeof e=="function")try{let r=e(...t);return h(r)&&Promise.resolve(r).then(void 0,f),r}catch(e){f(e);return}}var y=/* @__PURE__ */new WeakMap;function g(e){if(typeof e!="function")return;let t=y.get(e);if(t!==void 0)return t;let r=(...t)=>{b(e,...t)};return y.set(e,r),r}function m(e,t){let r=null;for(let n of t){let t=e[n];typeof t=="function"&&(r??={...e},r[n]=g(t))}return r??e}var v=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:t,resetKey:r}){return s(v,{fallback:t,resetKey:r,children:s(RenderHost,{render:e})})}var _=[{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}],w=/* @__PURE__ */Object.freeze(_.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(w.map(e=>e.wireCode));var C=/* @__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"}),S=/* @__PURE__ */Object.freeze(w.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:C[e.wireCode]}))),k=new Map(S.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),x=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(S.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",...x]){let t=k.get(e+r);if(t)return t}}var E=/* @__PURE__ */Object.freeze({authExpired:"authentication",authRejected:"authentication",sessionRequired:"authentication",identitySignatureRequired:"authentication",accessDenied:"authorization",paymentRequired:"entitlement",quotaExceeded:"rateLimit",rateLimited:"rateLimit",validationFailed:"invalidRequest",sdkUpdateRequired:"invalidRequest",runtimeDisposed:"invalidRequest",conversationNotFound:"notFound",petNotFound:"notFound",resourceNotFound:"notFound",conflict:"conflict",idempotencyConflict:"conflict",idempotencyInFlight:"conflict",streamTimeout:"connection",streamIncomplete:"connection",upstreamLlmTimeout:"connection",serviceUnavailable:"connection",internalError:"server",notImplemented:"server",mediaUploadFailed:"media",moderationBlocked:"policy",unknown:"unknown"});function categoryFor(e){return E[e]}function fromWire(e){let t=contractErrorFor(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),n=r.replace(/[^A-Z0-9]/g,"");if(n==="AUTHREJECTED")return"authRejected";if(r.startsWith("AUTH"))return"authExpired";switch(n){case"DAILYQUOTAEXCEEDED":case"QUOTAEXCEEDED":return"quotaExceeded";case"RATELIMITED":case"TOOMANYREQUESTS":case"TELEVETRATELIMITED":return"rateLimited";case"IDEMPOTENCYKEYCONFLICT":case"IDEMPOTENCYCONFLICT":return"idempotencyConflict";case"ACCESSDENIED":case"FORBIDDEN":return"accessDenied";case"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";case"RUNTIMEDISPOSED":return"runtimeDisposed";case"NOTFOUND":case"CONVERSATIONNOTFOUND":return"conversationNotFound";case"PETNOTFOUND":return"petNotFound";case"TIMEOUT":case"STREAMTIMEOUT":return"streamTimeout";case"MEDIAUPLOADFAILED":case"UNRECOGNIZEDVIDEOFORMAT":case"FILETOOSMALL":return"mediaUploadFailed";case"MODERATIONBLOCKED":return"moderationBlocked";case"UPSTREAMLLMTIMEOUT":return"upstreamLlmTimeout";case"INTERNALERROR":case"INTERNALSERVERERROR":return"internalError";case"STREAMINCOMPLETE":case"CHATSTREAMINCOMPLETE":return"streamIncomplete";case"INVALIDANALYSISTYPE":case"INVALIDUPLOADPURPOSE":return"unknown";default:return"unknown"}}var F=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return F.has(e)}var T=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||T.has(e)}var O=500,I=8e3,A=4;function backoffDelayMs(e,t=Math.random){let r=Math.max(0,e),n=Math.min(O*2**r,I);return Math.floor(t()*n)}var R="This feature isn't available on your account right now.",D="Something in that request was not right. Check the details and try again.",z=/* @__PURE__ */Object.freeze({authExpired:"Please sign in again to continue.",authRejected:"Please sign in again to continue.",sessionRequired:"This app needs to be updated to keep using Everfur.",accessDenied:R,paymentRequired:"This is part of a paid plan.",quotaExceeded:"You have used today's messages. This resets tomorrow.",rateLimited:"You are sending messages quickly. Try again in a few seconds.",validationFailed:D,sdkUpdateRequired:"This app needs to be updated to keep using Everfur.",conflict:"That is already running. Wait for it to finish, then try again.",idempotencyConflict:"That message was already delivered.",idempotencyInFlight:"That is still processing. Give it a moment.",conversationNotFound:"This conversation is no longer available.",petNotFound:"We could not find that pet. Please pick a pet and try again.",resourceNotFound:"We could not find that.",streamTimeout:"The response timed out. Tap retry to try again.",mediaUploadFailed:"We could not upload that photo. Please attach it again.",moderationBlocked:"This request cannot be answered here.",upstreamLlmTimeout:"The response timed out. Tap retry to try again.",internalError:"We hit a snag on our end. Please try again.",notImplemented:"That is not available yet.",serviceUnavailable:"That service is briefly unavailable. Try again shortly.",streamIncomplete:"The connection dropped mid-answer. Tap retry to continue.",identitySignatureRequired:R,runtimeDisposed:D,unknown:"Something went wrong. Please try again."}),N="This session has ended. Please sign in again.",P="linked_account_read_only";function j(e,t,r){return e==="conflict"&&r===P?R:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?N:userFacingError(e)}function userFacingError(e){return z[e]}function M(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var L=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===P,i={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:j(e,t?.wireCode,n?P:null)};t?.httpStatus!==void 0&&(i.httpStatus=t.httpStatus),t?.requestId&&(i.requestId=t.requestId),typeof t?.reasonCode=="string"&&L.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&&M(i,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&M(i,"raw",t.raw),/* @__PURE__ */Object.freeze(i)}function ok(e,t){/* @__PURE__ */
|
|
3
|
+
import{createContext,useMemo as e,useRef as t,useEffect as r,useSyncExternalStore as n,useCallback as i,useId as o,useState as a,useContext as l,createElement as s,Component as d}from"react";import{jsxs as u,jsx as c,Fragment as p}from"react/jsx-runtime";function f(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e)}catch{}}function h(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}function b(e,...t){if(typeof e=="function")try{let r=e(...t);return h(r)&&Promise.resolve(r).then(void 0,f),r}catch(e){f(e);return}}var y=/* @__PURE__ */new WeakMap;function m(e){if(typeof e!="function")return;let t=y.get(e);if(t!==void 0)return t;let r=(...t)=>{b(e,...t)};return y.set(e,r),r}function g(e,t){let r=null;for(let n of t){let t=e[n];typeof t=="function"&&(r??={...e},r[n]=m(t))}return r??e}var v=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:t,resetKey:r}){return s(v,{fallback:t,resetKey:r,children:s(RenderHost,{render:e})})}var _=[{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}],C=/* @__PURE__ */Object.freeze(_.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(C.map(e=>e.wireCode));var w=/* @__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"}),S=/* @__PURE__ */Object.freeze(C.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:w[e.wireCode]}))),k=new Map(S.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),x=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(S.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",...x]){let t=k.get(e+r);if(t)return t}}var E=/* @__PURE__ */Object.freeze({authExpired:"authentication",authRejected:"authentication",sessionRequired:"authentication",identitySignatureRequired:"authentication",accessDenied:"authorization",paymentRequired:"entitlement",quotaExceeded:"rateLimit",rateLimited:"rateLimit",validationFailed:"invalidRequest",sdkUpdateRequired:"invalidRequest",runtimeDisposed:"invalidRequest",conversationNotFound:"notFound",petNotFound:"notFound",resourceNotFound:"notFound",conflict:"conflict",idempotencyConflict:"conflict",idempotencyInFlight:"conflict",streamTimeout:"connection",streamIncomplete:"connection",upstreamLlmTimeout:"connection",serviceUnavailable:"connection",internalError:"server",notImplemented:"server",mediaUploadFailed:"media",moderationBlocked:"policy",unknown:"unknown"});function categoryFor(e){return E[e]}function fromWire(e){let t=contractErrorFor(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),n=r.replace(/[^A-Z0-9]/g,"");if(n==="AUTHREJECTED")return"authRejected";if(r.startsWith("AUTH"))return"authExpired";switch(n){case"DAILYQUOTAEXCEEDED":case"QUOTAEXCEEDED":return"quotaExceeded";case"RATELIMITED":case"TOOMANYREQUESTS":case"TELEVETRATELIMITED":return"rateLimited";case"IDEMPOTENCYKEYCONFLICT":case"IDEMPOTENCYCONFLICT":return"idempotencyConflict";case"ACCESSDENIED":case"FORBIDDEN":return"accessDenied";case"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";case"RUNTIMEDISPOSED":return"runtimeDisposed";case"NOTFOUND":case"CONVERSATIONNOTFOUND":return"conversationNotFound";case"PETNOTFOUND":return"petNotFound";case"TIMEOUT":case"STREAMTIMEOUT":return"streamTimeout";case"MEDIAUPLOADFAILED":case"UNRECOGNIZEDVIDEOFORMAT":case"FILETOOSMALL":return"mediaUploadFailed";case"MODERATIONBLOCKED":return"moderationBlocked";case"UPSTREAMLLMTIMEOUT":return"upstreamLlmTimeout";case"INTERNALERROR":case"INTERNALSERVERERROR":return"internalError";case"STREAMINCOMPLETE":case"CHATSTREAMINCOMPLETE":return"streamIncomplete";case"INVALIDANALYSISTYPE":case"INVALIDUPLOADPURPOSE":return"unknown";default:return"unknown"}}var F=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return F.has(e)}var T=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||T.has(e)}var O=500,I=8e3,A=4;function backoffDelayMs(e,t=Math.random){let r=Math.max(0,e),n=Math.min(O*2**r,I);return Math.floor(t()*n)}var R="This feature isn't available on your account right now.",N="Something in that request was not right. Check the details and try again.",D=/* @__PURE__ */Object.freeze({authExpired:"Please sign in again to continue.",authRejected:"Please sign in again to continue.",sessionRequired:"This app needs to be updated to keep using Everfur.",accessDenied:R,paymentRequired:"This is part of a paid plan.",quotaExceeded:"You have used today's messages. This resets tomorrow.",rateLimited:"You are sending messages quickly. Try again in a few seconds.",validationFailed:N,sdkUpdateRequired:"This app needs to be updated to keep using Everfur.",conflict:"That is already running. Wait for it to finish, then try again.",idempotencyConflict:"That message was already delivered.",idempotencyInFlight:"That is still processing. Give it a moment.",conversationNotFound:"This conversation is no longer available.",petNotFound:"We could not find that pet. Please pick a pet and try again.",resourceNotFound:"We could not find that.",streamTimeout:"The response timed out. Tap retry to try again.",mediaUploadFailed:"We could not upload that photo. Please attach it again.",moderationBlocked:"This request cannot be answered here.",upstreamLlmTimeout:"The response timed out. Tap retry to try again.",internalError:"We hit a snag on our end. Please try again.",notImplemented:"That is not available yet.",serviceUnavailable:"That service is briefly unavailable. Try again shortly.",streamIncomplete:"The connection dropped mid-answer. Tap retry to continue.",identitySignatureRequired:R,runtimeDisposed:N,unknown:"Something went wrong. Please try again."}),z="This session has ended. Please sign in again.",P="linked_account_read_only";function j(e,t,r){return e==="conflict"&&r===P?R:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?z:userFacingError(e)}function userFacingError(e){return D[e]}function M(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var q=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===P,i={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:j(e,t?.wireCode,n?P:null)};t?.httpStatus!==void 0&&(i.httpStatus=t.httpStatus),t?.requestId&&(i.requestId=t.requestId),typeof t?.reasonCode=="string"&&q.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&&M(i,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&M(i,"raw",t.raw),/* @__PURE__ */Object.freeze(i)}function ok(e,t){/* @__PURE__ */
|
|
4
4
|
return Object.freeze({ok:true,value:e})}function err(e){/* @__PURE__ */
|
|
5
|
-
return Object.freeze({ok:false,error:e})}var
|
|
6
|
-
return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryable,wireMessage:e.wireMessage,synthesized:e.synthesized,lastEventId:e.lastEventId,serverRequestId:null,...e.freeCap?{freeCap:/* @__PURE__ */Object.freeze({...e.freeCap})}:{}})}var $="x-everfur-anon-token",B="anonTokenInvalid";async function U(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}function H(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[$]=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:{...V(e.headers),...authHeaders(t)}}}function V(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===$||(t[r]=n)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let r=await U(t),n=await t.transport.request(withAuthHeaders(e,Y(t,r)));if(n.ok||
|
|
5
|
+
return Object.freeze({ok:false,error:e})}var L=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__ */
|
|
6
|
+
return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryable,wireMessage:e.wireMessage,synthesized:e.synthesized,lastEventId:e.lastEventId,serverRequestId:null,...e.freeCap?{freeCap:/* @__PURE__ */Object.freeze({...e.freeCap})}:{}})}var $="x-everfur-anon-token",B="anonTokenInvalid";async function U(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}function H(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[$]=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:{...V(e.headers),...authHeaders(t)}}}function V(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===$||(t[r]=n)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let r=await U(t),n=await t.transport.request(withAuthHeaders(e,Y(t,r)));if(n.ok||K(n.error.raw)!==B||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,Y(t,i)))}let r;try{r=await t.identity.currentToken()}catch(e){return t.identity.reportRejected?.(),err(H(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(H(e,{wireCode:K(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(W(o.error))):o}function Y(e,t){return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}function W(e){let t=e.raw,r=K(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 K(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:G(e)})}function G(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var Q=3e4,J=I*2,X="idempotency-key",Z=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),ee=/* @__PURE__ */Object.freeze({onEvent(){}}),te=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function re(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??ee,r=e.timers??te,n=e.rng??Math.random,i=e.sleep??((e,t)=>ge(e,r,t)),o=e.maxAttempts??A,a=e.unaryTimeoutMs??Q,l=e.newIdempotencyKey??ie(),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??Z.has(d.method),h=u?.idempotencyKey===void 0?null:re(u.idempotencyKey),b=f?h??l():null,y=ne(d,b),m=0;for(;;){let o=e=>/* @__PURE__ */Object.freeze({call:t,method:d.method,path:d.path,attempt:m,...b?{idempotencyKey:b}:{},...e});s(o({phase:"attempt"}));let l=ye(a,r),u=me(l.signal,d.signal),f;try{f=await authedSend({...y,signal:u.signal},e.auth)}catch(e){f=err(networkError(e))}finally{u.dispose(),l.cancel()}if(f.ok)return s(o({phase:"settled",ok:true,reason:"ok"})),f;let h=f.error,g=ae(h,m,{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:g.reason,...h.httpStatus!==void 0?{httpStatus:h.httpStatus}:{},...h.requestId!==void 0?{requestId:h.requestId}:{}};if(!g.retry)return s(o({phase:"settled",...v})),err(h);if(s(o({phase:"retry",...v,delayMs:g.delayMs})),await i(g.delayMs,d.signal),d.signal?.aborted===true)return s(o({phase:"settled",...v,reason:"aborted"})),err(h);m+=1}}async function u(t){return withAuthHeaders(t,await be(e.auth))}async function*c(t,r,n){s(
|
|
7
7
|
/* @__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__ */
|
|
8
|
-
return Object.freeze({send:d,authorize:u,stream:c})}function ne(e,t){let r={};for(let[t,n]of Object.entries(e.headers??{}))t.toLowerCase()!==X&&(r[t]=n);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}function ie(){let e=0;return()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var oe=10;function ae(e,t,r){if(r.aborted)return{retry:false,reason:"aborted"};let n=le(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(oe,Math.floor(t)))},a=r.perCallMaxAttempts??o()??r.maxAttempts;if(t+1>=a)return{retry:false,reason:"attempts-exhausted"};let l=se(e,r.now);return l!==null?l>J?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:i,delayMs:l}:{retry:true,reason:i,delayMs:backoffDelayMs(t,r.rng)}}function le(e){let t=e.code==="unknown"?fromWire(fe(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}function se(e,t){let r=ue(e.raw);if(r!==null){let e=r-t;return e>0?e:0}let n=de(e.raw);return n===null?null:Math.round(n*1e3)}function de(e){for(let t of ce(e)){let e=t.retry_after_seconds;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e}return null}function ue(e){for(let t of ce(e)){let e=t.resets_at,r=pe(e);if(r!==null)return r}return null}function ce(e){if(!he(e))return[];let t=[e];for(let r of["error","detail"]){let n=e[r];he(n)&&t.push(n)}return t}function pe(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 fe(e){for(let t of ce(e)){let e=t.code;if(typeof e=="string"&&e.length>0)return e}return null}function he(e){return typeof e=="object"&&e!==null}async function be(e){if(e.mode==="anonymous"){let t=await U(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 ye(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return{signal:r.signal,cancel:()=>t.clearTimeout(n)}}function
|
|
9
|
-
return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:Je(Oe,e.sex),spayedNeutered:Xe(e.spayed_neutered),birthDate:Qe(e.birth_date),birthDatePrecision:Je(Ie,e.birth_date_precision),activityLevel:Je(Ae,e.activity_level),indoorOutdoor:Je(Re,e.indoor_outdoor),foodBrand:Qe(e.food_brand),foodType:Qe(e.food_type),microchipId:Qe(e.microchip_id),allergies:Ze(e.allergies,e=>{let t=Qe(e.allergen);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Qe(e.ref),allergen:t,severity:Je(
|
|
10
|
-
return Object.freeze({petRef:yt(t.pet_ref)??petRef,name:yt(t.name),species:yt(t.species),breed:yt(t.breed),ageYears:
|
|
11
|
-
return Object.freeze(t.flatMap(e=>{let t=widgetPetFromWire(e);return t===null?[]:[t]}))}function createPetsRepository(e){return
|
|
12
|
-
return Object.freeze(t)}function
|
|
13
|
-
return Object.freeze(t)}var
|
|
14
|
-
return Object.freeze({challengeId:r,expiresAt:Jt(t.expires_at),attemptsRemaining:i})}function er(e){return e==null||e===""?true:typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0}var tr=/* @__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(Gt(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=>Mt(e,Yt),n=async(e,n,i,o)=>{let a=await t.send(e,n,i);if(!a.ok)return err(r(a.error));let l=textingIdentityFromWire(a.value);return l!==null?ok(l):o!==void 0&&er(a.value)?ok(o):err(Qt(e))};return{read(e){let t=e?.signal?{method:"GET",path:qt,signal:e.signal}:{method:"GET",path:qt};return n("texting.read",t)},async startVerification(e){if(typeof e!="object"||e===null||!isE164(e.phoneE164))return err(Wt("phoneE164 must be an E.164 number"));if(typeof e.consentVersion!="string"||e.consentVersion.length===0||e.consentVersion.length>64)return err(Wt("consentVersion must be the tenant profile consent version (1..64 characters)"));let n=await t.send("texting.verification.start",{method:"POST",path:$t,body:{phone_e164:e.phoneE164,consent_version:e.consentVersion}},{maxAttempts:1});if(!n.ok)return err(r(n.error));let i=Zt(n.value);return i===null?err(Qt("texting.verification.start")):ok(i)},async confirmVerification(e,t){return typeof e!="string"||e.length===0?err(Wt("challengeId is required")):typeof t!="string"||!Vt.test(t)?err(Wt("code must be the digits that were texted")):n("texting.verification.confirm",{method:"POST",path:Bt,body:{challenge_id:e,code:t}},{maxAttempts:1})},async selectPet(petRef){return typeof petRef!="string"||petRef.length===0||petRef.length>128?err(Wt("petRef must be 1..128 characters")):n("texting.pet.select",{method:"PUT",path:Ut,body:{pet_ref:petRef}})},optOut(){return n("texting.optOut",{method:"DELETE",path:qt},void 0,tr)}}}function textingErrorText(e,t,r=null,n=Ot){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=Ot){return typeof e.requestId=="string"&&e.requestId.length>0?`${t.supportReference} ${e.requestId}`:null}function textingInputProblemText(e,t=Ot){return t[e]}function textingOptedOutBody(e,t,r=Ot,n=It){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 rr=/* @__PURE__ */Object.freeze({phase:"loading",identity:null,challenge:null,phoneE164:null,error:null,failedAction:null,codeRefusal:null,savingPet:false,resending:false});function nr(e){return e.status==="verified"?"verified":e.status==="opted_out"?"optedOut":"enroll"}var ir=class{constructor(e,t=Date.now){this.repository=e;this.now=t;this.snapshot=rr;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:nr(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:nr(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:nr(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 or(e,n){let[i,o]=a(e),l=t(false);return r(()=>{let t=i;return l.current&&(t=e(),o(t)),l.current=true,()=>t.dispose()},n),i}function validateTextingEnroll(e,t){return toTextingE164(e)===null?"phoneInvalid":t?null:"consentRequired"}var ar=6;function validateTextingCode(e){return new RegExp(`^\\d{${ar}}$`).test(e.trim())?null:"codeInvalidFormat"}var NO_SUBSCRIPTION=()=>()=>{};function lr(){let{runtime:e}=Ft(),t=e.entitlements??null,r=i(e=>t===null?NO_SUBSCRIPTION():t.subscribe(e),[t]),o=i(()=>t===null?void 0:t.getSnapshot().smsProfilePublic,[t]);return n(r,o,o)}function useEverfurTextingProfile(){let t=lr();return e(()=>parseTextingProfile(t),[t])}function useEverfurTextingRepository(){let{runtime:t}=Ft();return e(()=>createTextingRepository(t),[t])}function useEverfurTexting(){return sr(true)}function sr(o){let{userRef:userRef,scopeEpoch:a}=Ft(),l=useEverfurTextingRepository(),s=useEverfurTextingProfile(),d=or(()=>new ir(l),[l,userRef,a]),u=t(null);r(()=>{userRef===null||!o||u.current===d||(u.current=d,d.load())},[d,userRef,o]);let c=n(d.subscribe,d.getSnapshot,d.getSnapshot),p=i(async e=>{let t=toTextingE164(e);return t===null||s===null||userRef===null?false:d.start(t,s.consentVersion)},[d,s,userRef]),f=i(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,e(()=>({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 dr=/* @__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 ur=Object.freeze;function deepFreeze(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){ur(e);for(let t of Object.keys(e))deepFreeze(e[t])}return e}var cr=/* @__PURE__ */Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3});var pr={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},fr={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},hr={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},br={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},yr={regular:"400",medium:"500",bold:"700"},gr={eyebrow:1,monoWide:.9,headerBrand:-.42,tight:-.35},mr=0,vr="System",_r="monospace",wr=["content","heading","control","compact","badge"];function Cr(e){let t={};for(let r of wr)t[r]=e;return t}var Sr=[];function kr(){return{family:vr,mono:_r,fontUrl:null,families:{regular:vr,medium:vr,bold:vr,mono:_r,monoMedium:_r,monoBold:_r},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:hr,tierSizes:Cr(hr),lineHeight:br,weight:yr,letterSpacing:gr,scale:1,maxScale:mr,scaleCaps:cr,headingFamily:null,headingWeight:null,fontSources:Sr,roles:dr,typeScale:1}}var xr={},Er=/* @__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 Fr={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:cssCubicBezier(Er.standard),emphasized:cssCubicBezier(Er.emphasized),exit:cssCubicBezier(Er.exit)},reducedMotion:false},Tr={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)"},Or=deepFreeze({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:Tr,space:pr,radius:fr,type:kr(),motion:Fr,slots:xr}),Ir={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:Ir,space:pr,radius:fr,type:kr(),motion:Fr,slots:xr});var Ar=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),Rr=globalThis,Dr=Rr[Ar]??(Rr[Ar]=createContext(Or));Dr.displayName??="EverfurThemeContext";function useEverfurTheme(){return l(Dr)}var zr=/* @__PURE__ */Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});var Nr='system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',Pr="System";function jr(e){let t=e.trim();return t.length===0||t===Pr?Nr:`${Lr(t)}, ${Nr}`}function Mr(e){let t=e.trim();return t.length===0||t==="monospace"?"ui-monospace, Menlo, Consolas, monospace":`${Lr(t)}, ui-monospace, Menlo, Consolas, monospace`}function Lr(e){return`"${e.replace(/[\\"]/g,"\\$&")}"`}function faceCss(e,t){let r=e.type,n=r.families[t];return{fontFamily:t==="mono"||t==="monoMedium"||t==="monoBold"?Mr(n):jr(n),fontWeight:r.namedFaces[t]?r.weight.regular:r.weight[zr[t]]}}function headingFaceCss(e,t="bold"){let{headingFamily:r,headingWeight:n}=e.type,i=faceCss(e,t);return r===null&&n===null?i:r!==null?{fontFamily:jr(r),fontWeight:n??e.type.weight[zr[t]]}:e.type.namedFaces[t]||n===null?i:{fontFamily:i.fontFamily,fontWeight:n}}var qr=/* @__PURE__ */Object.freeze({textAlign:"start"});var $r=/* @__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 $r[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 Hr({name:e,enabled:false,isPending:true,limits:{}});let o=Br(n,i);return n.filter(e=>i.get(e)?.granted!==true).length===0?Hr({name:e,enabled:true,isPending:false,limits:o}):Hr({name:e,enabled:false,isPending:false,limits:o,disabled:Ur(n,i)})}function Br(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 Ur(e,t){for(let r of e){let e=t.get(r)?.disabled;if(e)/* @__PURE__ */
|
|
8
|
+
return Object.freeze({send:d,authorize:u,stream:c})}function ne(e,t){let r={};for(let[t,n]of Object.entries(e.headers??{}))t.toLowerCase()!==X&&(r[t]=n);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}function ie(){let e=0;return()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var oe=10;function ae(e,t,r){if(r.aborted)return{retry:false,reason:"aborted"};let n=le(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(oe,Math.floor(t)))},a=r.perCallMaxAttempts??o()??r.maxAttempts;if(t+1>=a)return{retry:false,reason:"attempts-exhausted"};let l=se(e,r.now);return l!==null?l>J?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:i,delayMs:l}:{retry:true,reason:i,delayMs:backoffDelayMs(t,r.rng)}}function le(e){let t=e.code==="unknown"?fromWire(fe(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}function se(e,t){let r=ue(e.raw);if(r!==null){let e=r-t;return e>0?e:0}let n=de(e.raw);return n===null?null:Math.round(n*1e3)}function de(e){for(let t of ce(e)){let e=t.retry_after_seconds;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e}return null}function ue(e){for(let t of ce(e)){let e=t.resets_at,r=pe(e);if(r!==null)return r}return null}function ce(e){if(!he(e))return[];let t=[e];for(let r of["error","detail"]){let n=e[r];he(n)&&t.push(n)}return t}function pe(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 fe(e){for(let t of ce(e)){let e=t.code;if(typeof e=="string"&&e.length>0)return e}return null}function he(e){return typeof e=="object"&&e!==null}async function be(e){if(e.mode==="anonymous"){let t=await U(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 ye(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return{signal:r.signal,cancel:()=>t.clearTimeout(n)}}function me(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 ge(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 ve(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 _e(e){return[...e].length}var Ce=/* @__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(Ce,t)?Ce[t]:null}var we=50,Se=128,ke=120,xe=120,Ee=2e3,Fe=120,Te=80,Oe=/* @__PURE__ */new Set(["male","female","unknown"]),Ie=/* @__PURE__ */new Set(["day","month","year"]),Ae=/* @__PURE__ */new Set(["low","medium","high","athletic"]),Re=/* @__PURE__ */new Set(["indoor","outdoor","both"]),Ne=/* @__PURE__ */new Set(["mild","moderate","severe"]),De=/^(\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"]],Pe=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];/* @__PURE__ */Object.freeze([...ze,...Pe].map(([e])=>e));function je(e){let t=De.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 Me=e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,qe=(e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,Le=(e,t)=>typeof t=="string"&&je(t)?null:`${e} must be a real date written YYYY-MM-DD`,$e=(e,t={})=>(r,n)=>{if(typeof n!="string")return`${r} must be a string`;if(ve(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=_e(i);return o<=e?null:`${r} is ${o} characters; the server accepts at most ${e}`},Be={sex:Me(Oe),spayedNeutered:qe,birthDate:Le,birthDatePrecision:Me(Ie),activityLevel:Me(Ae),indoorOutdoor:Me(Re),foodBrand:$e(Fe),foodType:$e(Fe),microchipId:$e(Te)},Ue=["ref","ref",false,$e(Se,{required:true,trimmed:true})],He=["notes","notes",false,$e(Ee,{trimmed:true})],Ve=[Ue,["name","name",true,$e(ke,{required:true,trimmed:true})],["dose","dose",false,$e(xe,{trimmed:true})],["frequency","frequency",false,$e(xe,{trimmed:true})],["startDate","start_date",false,Le],["endDate","end_date",false,Le],He],Ye={allergies:[Ue,["allergen","allergen",true,$e(ke,{required:true,trimmed:true})],["severity","severity",false,Me(Ne)],He],medications:Ve,supplements:Ve,conditions:[Ue,["conditionName","condition_name",true,$e(ke,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,Le],He]};function We(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,a,l]of Ye[e]){let e=i[t];if(e==null){if(a)return{error:`${n}.${t} is required`};e===null&&(o[r]=null);continue}let s=l(`${n}.${t}`,e);if(s!==null)return{error:s};o[r]=e}let a=o.start_date,l=o.end_date;return typeof a=="string"&&typeof l=="string"&&l<a?{error:`${n}.endDate must not be before startDate`}:{item:o}}function Ke(e,t){if(!Array.isArray(t))return{error:`${e} must be an array (send [] to clear it)`};if(t.length>we)return{error:`${e} has ${t.length} items; the server accepts at most ${we}`};let r=[],n=/* @__PURE__ */new Set;for(let i=0;i<t.length;i+=1){let o=We(e,i,t[i]);if("error"in o)return o;let a=o.item.ref;if(typeof a=="string"){let t=a.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 Ge(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=Be[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 Pe){let i=r[e];if(i===void 0)continue;let o=Ke(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 Qe=e=>typeof e=="string"?e:null,Je=(e,t)=>typeof t=="string"&&e.has(t)?t:null,Xe=e=>typeof e=="boolean"?e:null;function Ze(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 et(e){let t=Qe(e.name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Qe(e.ref),name:t,dose:Qe(e.dose),frequency:Qe(e.frequency),startDate:Qe(e.start_date),endDate:Qe(e.end_date),notes:Qe(e.notes)})}function tt(e){let t=e.profile_version;/* @__PURE__ */
|
|
9
|
+
return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:Je(Oe,e.sex),spayedNeutered:Xe(e.spayed_neutered),birthDate:Qe(e.birth_date),birthDatePrecision:Je(Ie,e.birth_date_precision),activityLevel:Je(Ae,e.activity_level),indoorOutdoor:Je(Re,e.indoor_outdoor),foodBrand:Qe(e.food_brand),foodType:Qe(e.food_type),microchipId:Qe(e.microchip_id),allergies:Ze(e.allergies,e=>{let t=Qe(e.allergen);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Qe(e.ref),allergen:t,severity:Je(Ne,e.severity),notes:Qe(e.notes)})}),medications:Ze(e.medications,et),supplements:Ze(e.supplements,et),conditions:Ze(e.conditions,e=>{let t=Qe(e.condition_name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Qe(e.ref),conditionName:t,diagnosedDate:Qe(e.diagnosed_date),notes:Qe(e.notes)})})})}var rt=100,nt=50,it=100,ot=50,at=500,lt=128,st=6e4;function dt(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function ut(e,t,r){if(typeof t!="string")return dt(`${e} must be a string`);let n=_e(t);return n<=r?null:dt(`${e} is ${n} characters; the server accepts at most ${r}`)}function ct(e,t,r){return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=r?null:dt(`${e} must be a finite number between 0 and ${r}`)}function pt(petRef,e){if(typeof petRef!="string")return dt("pet_ref must be a string");if(petRef.trim().length===0)return dt("pet_ref must not be blank");if(ve(petRef))return dt("pet_ref contains an unpaired surrogate and cannot be encoded");if(e!=null&&typeof e!="object")return dt("profile must be an object");let t=[ut("pet_ref",petRef,lt)];return e?.name!==void 0&&t.push(ut("name",e.name,rt)),e?.species!==void 0&&t.push(ut("species",e.species,nt)),e?.breed!==void 0&&t.push(ut("breed",e.breed,it)),e?.ageYears!==void 0&&t.push(ct("age_years",e.ageYears,ot)),e?.weightKg!==void 0&&t.push(ct("weight_kg",e.weightKg,at)),t.find(e=>e!==null)??null}function ft(e,t){let r=Ge(e,t);return"error"in r?{error:dt(r.error)}:r}function ht(e){if(typeof e!="object"||e===null)return{error:dt("patch must be an object")};let t=e,r=[["name","name",e=>ut("name",e,rt)],["species","species",e=>ut("species",e,nt)],["breed","breed",e=>ut("breed",e,it)],["ageYears","age_years",e=>ct("age_years",e,ot)],["weightKg","weight_kg",e=>ct("weight_kg",e,at)]],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=ft(t,t.species);return"error"in i?i:(Object.assign(n,i.body),Object.keys(n).length===0?{error:dt("patch must change at least one field")}:{body:n})}function bt(e){if(e==null)return{body:{}};let t=ft(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 yt=e=>typeof e=="string"?e:null,mt=e=>typeof e=="number"&&Number.isFinite(e)?e:null;function gt(e,petRef){let t=typeof e=="object"&&e!==null?e:{};/* @__PURE__ */
|
|
10
|
+
return Object.freeze({petRef:yt(t.pet_ref)??petRef,name:yt(t.name),species:yt(t.species),breed:yt(t.breed),ageYears:mt(t.age_years),weightKg:mt(t.weight_kg)})}function widgetPetFromWire(e){if(typeof e!="object"||e===null)return null;let t=e,petRef=yt(t.pet_ref);return petRef===null||petRef.length===0?null:/* @__PURE__ */Object.freeze({petId:yt(t.pet_id),petRef:petRef,name:yt(t.name),species:yt(t.species),breed:yt(t.breed),ageYears:mt(t.age_years),weightKg:mt(t.weight_kg),updatedAt:yt(t.updated_at)})}function vt(e){let t=widgetPetFromWire(e);return t===null?null:/* @__PURE__ */Object.freeze({...t,...tt(e)})}function _t(e){let t=Array.isArray(e)?e:typeof e=="object"&&e!==null&&Array.isArray(e.pets)?e.pets:[];/* @__PURE__ */
|
|
11
|
+
return Object.freeze(t.flatMap(e=>{let t=widgetPetFromWire(e);return t===null?[]:[t]}))}function createPetsRepository(e){return Ct(createRequestFunnel({auth:e}),createRequestFunnel({auth:e,unaryTimeoutMs:st}))}function Ct(e,t=e){let r=(e,t)=>t?{...e,signal:t}:e,n=petRef=>pt(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(_t(n.value)):err(n.error)},async registerPet(petRef,t,r){let n=pt(petRef,t);if(n!==null)return err(n);let i=bt(t);if("error"in i)return err(i.error);let o={method:"POST",path:`/widget/v1/pets/${encodeURIComponent(petRef)}`,body:i.body},a=await e.send("pets.registerPet",r?.signal?{...o,signal:r.signal}:o);return a.ok?ok(gt(a.value,petRef)):err(a.error)},async updatePet(petRef,t,i){let o=n(petRef);if(typeof o!="string")return err(o);let a=ht(t);if("error"in a)return err(a.error);let l=await e.send("pets.updatePet",r({method:"PATCH",path:o,body:a.body},i?.signal));return l.ok?ok(gt(l.value,petRef)):err(l.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 a=vt(o.value);return a===null?err(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:"the pet profile response carried no pet_ref"})):ok(a)},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 wt=/* @__PURE__ */new WeakMap;function St(e,t){let r=wt.get(e);return r===void 0&&(r=/* @__PURE__ */new Set,wt.set(e,r)),r.add(t),()=>{r?.delete(t)}}var kt=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),xt=globalThis,Et=xt[kt]??(xt[kt]=createContext(null));Et.displayName??="EverfurContext";function Ft(){let e=l(Et);if(e===null)throw new L("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}function useEverfurPets(){let{runtime:n,userRef:userRef,activePet:o,scopeEpoch:l}=Ft(),s=e(()=>createPetsRepository(n.registry.services.authFor(userRef)),[n,userRef,l]),[d,u]=a({repository:s,pets:[],loading:true,error:null}),c=d.repository===s?d:{pets:[],loading:true,error:null},p=t(0),f=i(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]);r(()=>(f(),()=>{p.current+=1}),[f]),r(()=>St(n,()=>{f()}),[n,f]);let h=e(()=>o===null?null:c.pets.find(e=>e.petRef===o)??null,[o,c.pets]);return e(()=>({pets:c.pets,activePet:h,loading:c.loading,error:c.error,refresh:f}),[c.pets,c.loading,c.error,h,f])}var Tt="[copy needed: ",Ot=/* @__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.",numberConfirmTitle:"Is this still your number?",numberConfirmBody:"We've paused texts to this number until you confirm it's still yours.",numberConfirmAction:"Yes, still mine",numberConfirmOther:"Not mine anymore? Use a different number or turn off texts below.",numberConfirmFailed:"We couldn't confirm your number. Please try again."}),It=/* @__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}.`}),At=/* @__PURE__ */Object.freeze(Object.keys(Ot).filter(e=>Ot[e].startsWith(Tt)));function Rt(e){if(e==null||typeof e!="object")return Ot;let t={...Ot};for(let r of Object.keys(Ot)){let n=e[r];typeof n=="string"&&n.trim().length>0&&(t[r]=n)}/* @__PURE__ */
|
|
12
|
+
return Object.freeze(t)}function Nt(e){if(e==null||typeof e!="object")return It;let t={...It};for(let r of Object.keys(It)){let n=e[r];if(typeof n!="function")continue;let i=It[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__ */
|
|
13
|
+
return Object.freeze(t)}var Dt=createContext({copy:Ot,brandCopy:It});function zt(){return l(Dt)}function Pt(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 jt(e,t){let r=Pt(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 Mt(e,t){let r=jt(e,t);if(r!==e||Pt(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 qt(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=qt(t.brand_name,120),n=qt(t.consent_text),i=qt(t.consent_version,64);return r===null||n===null||i===null?null:/* @__PURE__ */Object.freeze({brandName:r,consentText:n,consentVersion:i,helpContact:qt(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 Lt="/widget/v1/me/sms-identity",$t=`${Lt}/verification`,Bt=`${$t}/confirm`,Ut=`${Lt}/selected-pet`,Ht=`${Lt}/confirm-number`,Vt=/* @__PURE__ */Object.freeze(["none","pending","verified","opted_out"]),Yt=/^\d{4,8}$/,Wt=/* @__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}}),Kt=/* @__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??Pt(e);return typeof t=="string"?Kt[t]??null:null}function Gt(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function Qt(e){return makeEverfurError("runtimeDisposed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}function Jt(e){return makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:`${e}: the response was not the documented shape`})}var Xt=e=>typeof e=="string"&&e.length>0?e:null;function Zt(e){return typeof e=="string"&&Vt.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:Zt(t.status),phoneMasked:Xt(t.phone_masked),consentVersion:Xt(t.consent_version),selectedPetRef:Xt(t.selected_pet_ref),numberConfirmationRequired:t.number_confirmation_required===true})}function er(e){if(e===null||typeof e!="object")return null;let t=e,r=Xt(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__ */
|
|
14
|
+
return Object.freeze({challengeId:r,expiresAt:Xt(t.expires_at),attemptsRemaining:i})}function tr(e){return e==null||e===""?true:typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0}var rr=/* @__PURE__ */Object.freeze({status:"opted_out",phoneMasked:null,consentVersion:null,selectedPetRef:null,numberConfirmationRequired:false});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(Qt(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(),confirmNumber:()=>e.isDisposed?r("confirmNumber"):t().confirmNumber()}}function createTextingRepositoryOver(e){let t=e.funnel??createRequestFunnel({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e=>Mt(e,Wt),n=async(e,n,i,o)=>{let a=await t.send(e,n,i);if(!a.ok)return err(r(a.error));let l=textingIdentityFromWire(a.value);return l!==null?ok(l):o!==void 0&&tr(a.value)?ok(o):err(Jt(e))};return{read(e){let t=e?.signal?{method:"GET",path:Lt,signal:e.signal}:{method:"GET",path:Lt};return n("texting.read",t)},async startVerification(e){if(typeof e!="object"||e===null||!isE164(e.phoneE164))return err(Gt("phoneE164 must be an E.164 number"));if(typeof e.consentVersion!="string"||e.consentVersion.length===0||e.consentVersion.length>64)return err(Gt("consentVersion must be the tenant profile consent version (1..64 characters)"));let n=await t.send("texting.verification.start",{method:"POST",path:$t,body:{phone_e164:e.phoneE164,consent_version:e.consentVersion}},{maxAttempts:1});if(!n.ok)return err(r(n.error));let i=er(n.value);return i===null?err(Jt("texting.verification.start")):ok(i)},async confirmVerification(e,t){return typeof e!="string"||e.length===0?err(Gt("challengeId is required")):typeof t!="string"||!Yt.test(t)?err(Gt("code must be the digits that were texted")):n("texting.verification.confirm",{method:"POST",path:Bt,body:{challenge_id:e,code:t}},{maxAttempts:1})},async selectPet(petRef){return typeof petRef!="string"||petRef.length===0||petRef.length>128?err(Gt("petRef must be 1..128 characters")):n("texting.pet.select",{method:"PUT",path:Ut,body:{pet_ref:petRef}})},optOut(){return n("texting.optOut",{method:"DELETE",path:Lt},void 0,rr)},async confirmNumber(){let e=await t.send("texting.number.confirm",{method:"POST",path:Ht});return e.ok?ok(void 0):err(r(e.error))}}}function textingErrorText(e,t,r=null,n=Ot){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==="confirmNumber"?n.numberConfirmFailed:t==="start"?n.providerFailed:n.genericFailure}}function textingSupportText(e,t=Ot){return typeof e.requestId=="string"&&e.requestId.length>0?`${t.supportReference} ${e.requestId}`:null}function textingInputProblemText(e,t=Ot){return t[e]}function textingOptedOutBody(e,t,r=Ot,n=It){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 nr=/* @__PURE__ */Object.freeze({phase:"loading",identity:null,challenge:null,phoneE164:null,error:null,failedAction:null,codeRefusal:null,savingPet:false,confirmingNumber:false,resending:false});function ir(e){return e.status==="verified"?"verified":e.status==="opted_out"?"optedOut":"enroll"}var or=class{constructor(e,t=Date.now){this.repository=e;this.now=t;this.snapshot=nr;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:ir(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:ir(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:ir(t.value)}),true):(this.set({savingPet:false,error:t.error,failedAction:"selectPet"}),false)}async confirmNumber(){if(this.snapshot.phase!=="verified"||this.snapshot.confirmingNumber)return false;let e=this.generation;this.set({confirmingNumber:true,error:null,failedAction:null});let t=await this.repository.confirmNumber();if(e!==this.generation)return false;if(!t.ok)return this.set({confirmingNumber:false,error:t.error,failedAction:"confirmNumber"}),false;let r=await this.repository.read();if(e!==this.generation)return false;if(r.ok)this.set({confirmingNumber:false,identity:r.value,phase:ir(r.value)});else{let{identity:e}=this.snapshot;this.set({confirmingNumber:false,identity:e===null?null:/* @__PURE__ */Object.freeze({...e,numberConfirmationRequired:false})})}return true}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 ar(e,n){let[i,o]=a(e),l=t(false);return r(()=>{let t=i;return l.current&&(t=e(),o(t)),l.current=true,()=>t.dispose()},n),i}function validateTextingEnroll(e,t){return toTextingE164(e)===null?"phoneInvalid":t?null:"consentRequired"}var lr=6;function validateTextingCode(e){return new RegExp(`^\\d{${lr}}$`).test(e.trim())?null:"codeInvalidFormat"}var NO_SUBSCRIPTION=()=>()=>{};function sr(){let{runtime:e}=Ft(),t=e.entitlements??null,r=i(e=>t===null?NO_SUBSCRIPTION():t.subscribe(e),[t]),o=i(()=>t===null?void 0:t.getSnapshot().smsProfilePublic,[t]);return n(r,o,o)}function useEverfurTextingProfile(){let t=sr();return e(()=>parseTextingProfile(t),[t])}function useEverfurTextingRepository(){let{runtime:t}=Ft();return e(()=>createTextingRepository(t),[t])}function useEverfurTexting(){return dr(true)}function dr(o){let{userRef:userRef,scopeEpoch:a}=Ft(),l=useEverfurTextingRepository(),s=useEverfurTextingProfile(),d=ar(()=>new or(l),[l,userRef,a]),u=t(null);r(()=>{userRef===null||!o||u.current===d||(u.current=d,d.load())},[d,userRef,o]);let c=n(d.subscribe,d.getSnapshot,d.getSnapshot),p=i(async e=>{let t=toTextingE164(e);return t===null||s===null||userRef===null?false:d.start(t,s.consentVersion)},[d,s,userRef]),f=i(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,e(()=>({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(),confirmNumber:()=>d.confirmNumber(),refresh:()=>d.load()}),[h,s,c,p,f,d])}var ur=/* @__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 cr=Object.freeze;function deepFreeze(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){cr(e);for(let t of Object.keys(e))deepFreeze(e[t])}return e}var pr=/* @__PURE__ */Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3});var fr={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},hr={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},br={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},yr={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},mr={regular:"400",medium:"500",bold:"700"},gr={eyebrow:1,monoWide:.9,headerBrand:-.42,tight:-.35},vr=0,_r="System",Cr="monospace",wr=["content","heading","control","compact","badge"];function Sr(e){let t={};for(let r of wr)t[r]=e;return t}var kr=[];function xr(){return{family:_r,mono:Cr,fontUrl:null,families:{regular:_r,medium:_r,bold:_r,mono:Cr,monoMedium:Cr,monoBold:Cr},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:br,tierSizes:Sr(br),lineHeight:yr,weight:mr,letterSpacing:gr,scale:1,maxScale:vr,scaleCaps:pr,headingFamily:null,headingWeight:null,fontSources:kr,roles:ur,typeScale:1}}var Er={},Fr=/* @__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 Tr={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:cssCubicBezier(Fr.standard),emphasized:cssCubicBezier(Fr.emphasized),exit:cssCubicBezier(Fr.exit)},reducedMotion:false},Or={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)"},Ir=deepFreeze({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:Or,space:fr,radius:hr,type:xr(),motion:Tr,slots:Er}),Ar={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:Ar,space:fr,radius:hr,type:xr(),motion:Tr,slots:Er});var Rr=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),Nr=globalThis,Dr=Nr[Rr]??(Nr[Rr]=createContext(Ir));Dr.displayName??="EverfurThemeContext";function useEverfurTheme(){return l(Dr)}var zr=/* @__PURE__ */Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});var Pr='system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',jr="System";function Mr(e){let t=e.trim();return t.length===0||t===jr?Pr:`${Lr(t)}, ${Pr}`}function qr(e){let t=e.trim();return t.length===0||t==="monospace"?"ui-monospace, Menlo, Consolas, monospace":`${Lr(t)}, ui-monospace, Menlo, Consolas, monospace`}function Lr(e){return`"${e.replace(/[\\"]/g,"\\$&")}"`}function faceCss(e,t){let r=e.type,n=r.families[t];return{fontFamily:t==="mono"||t==="monoMedium"||t==="monoBold"?qr(n):Mr(n),fontWeight:r.namedFaces[t]?r.weight.regular:r.weight[zr[t]]}}function headingFaceCss(e,t="bold"){let{headingFamily:r,headingWeight:n}=e.type,i=faceCss(e,t);return r===null&&n===null?i:r!==null?{fontFamily:Mr(r),fontWeight:n??e.type.weight[zr[t]]}:e.type.namedFaces[t]||n===null?i:{fontFamily:i.fontFamily,fontWeight:n}}var $r=/* @__PURE__ */Object.freeze({textAlign:"start"});var Br=/* @__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 Br[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 Vr({name:e,enabled:false,isPending:true,limits:{}});let o=Ur(n,i);return n.filter(e=>i.get(e)?.granted!==true).length===0?Vr({name:e,enabled:true,isPending:false,limits:o}):Vr({name:e,enabled:false,isPending:false,limits:o,disabled:Hr(n,i)})}function Ur(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 Hr(e,t){for(let r of e){let e=t.get(r)?.disabled;if(e)/* @__PURE__ */
|
|
15
15
|
return Object.freeze({reason:e.reason,level:e.level,recoverable:e.recoverable})}/* @__PURE__ */
|
|
16
|
-
return Object.freeze({reason:userFacingError("accessDenied"),level:"user_entitlement",recoverable:false})}function
|
|
16
|
+
return Object.freeze({reason:userFacingError("accessDenied"),level:"user_entitlement",recoverable:false})}function Vr(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(t){let{runtime:r}=Ft(),i=r.entitlements,o=n(i.subscribe,i.getSnapshot,i.getSnapshot);return e(()=>decideCapability(t,o.decisions,{isPending:o.isPending}),[t,o])}var Yr=48;function Wr(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}function CapabilityGate(t){let{capability:r,children:n,renderDisabled:i,renderPending:o,style:a,className:l}=t,s=useCapability(r),d=e(()=>Wr(s),[s]);switch(d){case"enabled":return n;case"pending":return o?/* @__PURE__ */c(HostRender,{render:o,fallback:/* @__PURE__ */c(PendingSkeleton,{capability:r,style:a,className:l})}):/* @__PURE__ */c(PendingSkeleton,{capability:r,style:a,className:l});case"disabled":return i?/* @__PURE__ */c(HostRender,{render:()=>i(s),fallback:/* @__PURE__ */c(OffState,{decision:s,style:a,className:l}),resetKey:s}):/* @__PURE__ */c(OffState,{decision:s,style:a,className:l});default:return assertNever(d)}}function PendingSkeleton({capability:t,style:r,className:n}){let i=useEverfurTheme(),o=e(()=>Kr(i),[i]);/* @__PURE__ */
|
|
17
17
|
return c("div",{role:"status","aria-busy":"true","aria-label":`Loading ${t}`,className:n,style:{...o.offstate,...r},children:/* @__PURE__ */c("div",{style:o.skeletonBar})})}function OffState({decision:t,style:r,className:n}){let i=useEverfurTheme(),o=e(()=>Kr(i),[i]),a=t.disabled?.reason??"";/* @__PURE__ */
|
|
18
|
-
return c("div",{className:n,style:{...o.offstate,...r},children:a.length>0?/* @__PURE__ */c("p",{style:o.offstateText,children:a}):null})}function Kr(e){let{color:t,space:r,radius:n,type:i}=e;return{offstate:{
|
|
18
|
+
return c("div",{className:n,style:{...o.offstate,...r},children:a.length>0?/* @__PURE__ */c("p",{style:o.offstateText,children:a}):null})}function Kr(e){let{color:t,space:r,radius:n,type:i}=e;return{offstate:{...$r,boxSizing:"border-box",minHeight:Yr,display:"flex",flexDirection:"column",justifyContent:"center",padding:`${r.md}px ${r.lg}px`,backgroundColor:t.surfaceCream,borderRadius:n.md,border:`1px solid ${t.brandBorder}`},offstateText:{margin:0,...faceCss(e,"regular"),fontSize:i.size.body,lineHeight:`${Math.round(i.size.body*i.lineHeight.normal)}px`,color:t.text.muted},skeletonBar:{height:r.md,borderRadius:n.xs,backgroundColor:t.brandSofter}}}function Gr(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 Qr(e){return e?.textColor===void 0?{}:{color:e.textColor}}function Jr(e,t){let r=Gr(e,t),n={};return r.backgroundColor!==void 0&&(n.backgroundColor=r.backgroundColor),r.borderColor!==void 0&&(n.border=`${r.borderWidth??1}px solid ${r.borderColor}`),r.borderRadius!==void 0&&(n.borderRadius=r.borderRadius),n}function Xr(e,t){return{...Jr(e,t),...Qr(e)}}function EverfurTextingOptIn(t){let r=g(t,["onStatusChange"]),n=e(()=>({copy:Rt(t.copy),brandCopy:Nt(t.brandCopy)}),[t.copy,t.brandCopy]),{copy:i,brandCopy:o}=n,a=useEverfurTheme(),l=e(()=>Zr(a),[a]),s=useEverfurTexting();return s.status==="signedOut"?/* @__PURE__ */u("section",{className:r.className,style:{...l.card,...r.style},children:[
|
|
19
19
|
/* @__PURE__ */c("h2",{style:l.title,children:o.introTitle(a.meta.displayName)}),
|
|
20
|
-
/* @__PURE__ */c("p",{style:l.body,children:i.signedOut})]}):/* @__PURE__ */c(CapabilityGate,{capability:"texting",...r.renderDisabled?{renderDisabled:r.renderDisabled}:{},style:r.style,className:r.className,children:/* @__PURE__ */c(
|
|
20
|
+
/* @__PURE__ */c("p",{style:l.body,children:i.signedOut})]}):/* @__PURE__ */c(CapabilityGate,{capability:"texting",...r.renderDisabled?{renderDisabled:r.renderDisabled}:{},style:r.style,className:r.className,children:/* @__PURE__ */c(Dt.Provider,{value:n,children:/* @__PURE__ */c(OptInBody,{...r,texting:s,styles:l})})})}function OptInBody({texting:e,styles:t,onStatusChange:n,renderNotice:i,style:l,className:s}){let{copy:d,brandCopy:f}=zt(),h=useEverfurTheme(),b=o(),{status:y,profile:m,snapshot:g}=e,v=m?.brandName??h.meta.displayName,[_,C]=a(""),[w,S]=a(false),[k,x]=a(""),[E,F]=a(null),[T,O]=a(false),[I,A]=a(""),[R,N]=a(false);r(()=>{n?.(y)},[n,y]),r(()=>{F(null),O(false)},[y]);let D=(e,r=false)=>/* @__PURE__ */c("section",{className:s,style:{...t.card,...l},"aria-busy":r?"true":void 0,children:e}),z=(e,r)=>{let n=textingErrorText(e,g.failedAction,g.codeRefusal,d);/* @__PURE__ */
|
|
21
21
|
return u("div",{style:t.notice,role:"alert",children:[
|
|
22
|
-
/* @__PURE__ */c(HostRender,{resetKey:e,render:()=>i?i(e):/* @__PURE__ */c("p",{style:t.noticeText,children:n}),fallback:/* @__PURE__ */c("p",{style:t.noticeText,children:n})}),r===void 0?null:/* @__PURE__ */c("button",{type:"button",onClick:r,style:t.link,children:d.retry})]})};if(y==="unavailable")return
|
|
22
|
+
/* @__PURE__ */c(HostRender,{resetKey:e,render:()=>i?i(e):/* @__PURE__ */c("p",{style:t.noticeText,children:n}),fallback:/* @__PURE__ */c("p",{style:t.noticeText,children:n})}),r===void 0?null:/* @__PURE__ */c("button",{type:"button",onClick:r,style:t.link,children:d.retry})]})};if(y==="unavailable")return D(
|
|
23
23
|
/* @__PURE__ */u(p,{children:[
|
|
24
24
|
/* @__PURE__ */c("h2",{style:t.title,children:d.unavailableTitle}),
|
|
25
|
-
/* @__PURE__ */c("p",{style:t.body,children:d.unavailableBody})]}));if(
|
|
26
|
-
return c("section",{className:s,style:{...t.card,...l},role:"status","aria-busy":"true","aria-label":d.loading,children:/* @__PURE__ */c("div",{style:t.skeleton})});if(y==="failed")return
|
|
25
|
+
/* @__PURE__ */c("p",{style:t.body,children:d.unavailableBody})]}));if(m===null)return null;if(y==="loading")/* @__PURE__ */
|
|
26
|
+
return c("section",{className:s,style:{...t.card,...l},role:"status","aria-busy":"true","aria-label":d.loading,children:/* @__PURE__ */c("div",{style:t.skeleton})});if(y==="failed")return D(
|
|
27
27
|
/* @__PURE__ */u(p,{children:[
|
|
28
|
-
/* @__PURE__ */c("h2",{style:t.title,children:f.introTitle(v)}),
|
|
28
|
+
/* @__PURE__ */c("h2",{style:t.title,children:f.introTitle(v)}),g.error===null?null:z(g.error,textingReasonOf(g.error)==="session_required"?void 0:()=>{e.refresh()})]}));let P=m.helpContact===null?null:/* @__PURE__ */u("p",{style:t.footnote,children:[d.helpContactLabel," ",m.helpContact]});if(y==="enroll"||y==="requesting"&&!g.resending){let r=y==="requesting",n=()=>{let t=validateTextingEnroll(_,w);F(t),t===null&&e.start(_)};return D(
|
|
29
29
|
/* @__PURE__ */u(p,{children:[
|
|
30
30
|
/* @__PURE__ */c("h2",{style:t.title,children:f.introTitle(v)}),
|
|
31
31
|
/* @__PURE__ */c("p",{style:t.body,children:f.introBody(v)}),
|
|
32
32
|
/* @__PURE__ */c("label",{htmlFor:`${b}-phone`,style:t.label,children:d.phoneLabel}),
|
|
33
|
-
/* @__PURE__ */c("input",{id:`${b}-phone`,type:"tel",inputMode:"tel",autoComplete:"tel-national",value:_,disabled:r,"aria-describedby":`${b}-phone-hint`,"aria-invalid":E==="phoneInvalid"?"true":void 0,onChange:e=>
|
|
33
|
+
/* @__PURE__ */c("input",{id:`${b}-phone`,type:"tel",inputMode:"tel",autoComplete:"tel-national",value:_,disabled:r,"aria-describedby":`${b}-phone-hint`,"aria-invalid":E==="phoneInvalid"?"true":void 0,onChange:e=>C(e.currentTarget.value),style:t.input}),
|
|
34
34
|
/* @__PURE__ */c("p",{id:`${b}-phone-hint`,style:t.footnote,children:d.phoneHint}),
|
|
35
35
|
/* @__PURE__ */u("label",{style:t.consentRow,children:[
|
|
36
|
-
/* @__PURE__ */c("input",{type:"checkbox",checked:
|
|
37
|
-
/* @__PURE__ */c("span",{style:t.consentText,children:
|
|
38
|
-
/* @__PURE__ */c("button",{type:"button",onClick:n,disabled:r,"aria-busy":r?"true":void 0,style:t.primary,children:r?d.sendingCode:d.sendCode})]}),r)}if(y==="code"||y==="confirming"||y==="requesting"){let r=y==="confirming",n=y==="requesting",i=r||n,o=()=>{let t=validateTextingCode(k);F(t),t===null&&e.confirm(k)};return
|
|
36
|
+
/* @__PURE__ */c("input",{type:"checkbox",checked:w,disabled:r,"aria-invalid":E==="consentRequired"?"true":void 0,onChange:e=>S(e.currentTarget.checked),style:t.box}),
|
|
37
|
+
/* @__PURE__ */c("span",{style:t.consentText,children:m.consentText})]}),P,E===null?null:/* @__PURE__ */c("p",{style:t.noticeText,role:"alert",children:textingInputProblemText(E,d)}),g.error===null?null:z(g.error),
|
|
38
|
+
/* @__PURE__ */c("button",{type:"button",onClick:n,disabled:r,"aria-busy":r?"true":void 0,style:t.primary,children:r?d.sendingCode:d.sendCode})]}),r)}if(y==="code"||y==="confirming"||y==="requesting"){let r=y==="confirming",n=y==="requesting",i=r||n,o=()=>{let t=validateTextingCode(k);F(t),t===null&&e.confirm(k)};return D(
|
|
39
39
|
/* @__PURE__ */u(p,{children:[
|
|
40
40
|
/* @__PURE__ */c("h2",{style:t.title,children:d.codeTitle}),
|
|
41
|
-
/* @__PURE__ */u("p",{style:t.body,children:[d.codeSentTo," ",formatTextingPhone(
|
|
41
|
+
/* @__PURE__ */u("p",{style:t.body,children:[d.codeSentTo," ",formatTextingPhone(g.phoneE164)]}),
|
|
42
42
|
/* @__PURE__ */c("label",{htmlFor:`${b}-code`,style:t.label,children:d.codeLabel}),
|
|
43
|
-
/* @__PURE__ */c("input",{id:`${b}-code`,type:"text",inputMode:"numeric",autoComplete:"one-time-code",maxLength:6,value:k,disabled:i,"aria-invalid":E==="codeInvalidFormat"?"true":void 0,onChange:e=>x(e.currentTarget.value.replace(/\D/g,"")),style:t.input}),E===null?null:/* @__PURE__ */c("p",{style:t.noticeText,role:"alert",children:textingInputProblemText(E,d)}),
|
|
43
|
+
/* @__PURE__ */c("input",{id:`${b}-code`,type:"text",inputMode:"numeric",autoComplete:"one-time-code",maxLength:6,value:k,disabled:i,"aria-invalid":E==="codeInvalidFormat"?"true":void 0,onChange:e=>x(e.currentTarget.value.replace(/\D/g,"")),style:t.input}),E===null?null:/* @__PURE__ */c("p",{style:t.noticeText,role:"alert",children:textingInputProblemText(E,d)}),g.error===null?null:z(g.error),
|
|
44
44
|
/* @__PURE__ */c("button",{type:"button",onClick:o,disabled:i,"aria-busy":r?"true":void 0,style:t.primary,children:r?d.confirmingCode:d.confirmCode}),
|
|
45
45
|
/* @__PURE__ */u("div",{style:t.links,children:[
|
|
46
46
|
/* @__PURE__ */c("button",{type:"button",disabled:i,"aria-busy":n?"true":void 0,onClick:()=>{x(""),e.resend()},style:t.link,children:d.requestNewCode}),
|
|
47
|
-
/* @__PURE__ */c("button",{type:"button",onClick:()=>{x(""),e.changeNumber()},style:t.link,children:d.changeNumber})]})]}),i)}if(y==="optedOut")return
|
|
47
|
+
/* @__PURE__ */c("button",{type:"button",onClick:()=>{x(""),e.changeNumber()},style:t.link,children:d.changeNumber})]})]}),i)}if(y==="optedOut")return D(
|
|
48
48
|
/* @__PURE__ */u(p,{children:[
|
|
49
49
|
/* @__PURE__ */c("h2",{style:t.title,children:d.optedOutTitle}),
|
|
50
|
-
/* @__PURE__ */c("p",{style:t.body,children:textingOptedOutBody(
|
|
51
|
-
/* @__PURE__ */c("button",{type:"button",onClick:()=>{S(false),e.reenroll()},style:t.primary,children:d.reenroll})]}));let j=y==="optingOut";return
|
|
50
|
+
/* @__PURE__ */c("p",{style:t.body,children:textingOptedOutBody(g.identity,v,d,f)}),P,
|
|
51
|
+
/* @__PURE__ */c("button",{type:"button",onClick:()=>{S(false),e.reenroll()},style:t.primary,children:d.reenroll})]}));let j=y==="optingOut";return D(
|
|
52
52
|
/* @__PURE__ */u(p,{children:[
|
|
53
53
|
/* @__PURE__ */c("h2",{style:t.title,children:d.verifiedTitle}),
|
|
54
|
-
/* @__PURE__ */c("p",{style:t.body,children:f.statusActive(v)}),
|
|
55
|
-
/* @__PURE__ */c(
|
|
54
|
+
/* @__PURE__ */c("p",{style:t.body,children:f.statusActive(v)}),g.identity?.phoneMasked?/* @__PURE__ */c("p",{style:t.phone,children:g.identity.phoneMasked}):null,g.identity?.numberConfirmationRequired===true?/* @__PURE__ */u("div",{style:t.confirm,role:"group","aria-labelledby":`${b}-number`,"data-testid":"texting-number-confirm",children:[
|
|
55
|
+
/* @__PURE__ */c("p",{id:`${b}-number`,style:t.subtitle,children:d.numberConfirmTitle}),
|
|
56
|
+
/* @__PURE__ */c("p",{style:t.body,children:d.numberConfirmBody}),
|
|
57
|
+
/* @__PURE__ */c("div",{style:t.links,children:/* @__PURE__ */c("button",{type:"button",disabled:j||g.confirmingNumber,"aria-busy":g.confirmingNumber?"true":void 0,onClick:()=>{e.confirmNumber()},style:t.primary,children:d.numberConfirmAction})}),
|
|
58
|
+
/* @__PURE__ */c("p",{style:t.footnote,children:d.numberConfirmOther}),
|
|
59
|
+
/* @__PURE__ */c("div",{style:t.links,children:/* @__PURE__ */c("button",{type:"button",disabled:j||g.confirmingNumber,onClick:()=>e.changeNumber(),style:t.link,children:d.changeNumber})})]}):null,
|
|
60
|
+
/* @__PURE__ */c(PetPicker,{styles:t,selectedPetRef:g.identity?.selectedPetRef??null,choice:I,saving:g.savingPet,saved:R,onChoose:e=>{A(e),N(false)},onSave:petRef=>{e.selectPet(petRef).then(e=>N(e))}}),P,g.error===null?null:z(g.error),T?/* @__PURE__ */u("div",{style:t.confirm,role:"group","aria-labelledby":`${b}-off`,children:[
|
|
56
61
|
/* @__PURE__ */c("p",{id:`${b}-off`,style:t.subtitle,children:d.disableConfirmTitle}),
|
|
57
62
|
/* @__PURE__ */c("p",{style:t.body,children:d.disableConfirmBody}),
|
|
58
63
|
/* @__PURE__ */u("div",{style:t.links,children:[
|
|
59
64
|
/* @__PURE__ */c("button",{type:"button",disabled:j,"aria-busy":j?"true":void 0,onClick:()=>{e.optOut()},style:t.primary,children:j?d.disabling:d.disableConfirm}),
|
|
60
|
-
/* @__PURE__ */c("button",{type:"button",disabled:j,onClick:()=>O(false),style:t.link,children:d.disableCancel})]})]}):/* @__PURE__ */c("button",{type:"button",onClick:()=>O(true),style:t.link,children:d.disable})]}),j)}function PetPicker({styles:e,selectedPetRef:t,choice:r,saving:n,saved:i,onChoose:a,onSave:l}){let{copy:s}=
|
|
65
|
+
/* @__PURE__ */c("button",{type:"button",disabled:j,onClick:()=>O(false),style:t.link,children:d.disableCancel})]})]}):/* @__PURE__ */c("button",{type:"button",onClick:()=>O(true),style:t.link,children:d.disable})]}),j)}function PetPicker({styles:e,selectedPetRef:t,choice:r,saving:n,saved:i,onChoose:a,onSave:l}){let{copy:s}=zt(),d=o(),{pets:p}=useEverfurPets();if(p.length===0)return null;let f=r!==""?r:t??"",h=f!==""&&f!==t;/* @__PURE__ */
|
|
61
66
|
return u("div",{style:e.petRow,children:[
|
|
62
67
|
/* @__PURE__ */c("label",{htmlFor:`${d}-pet`,style:e.label,children:s.defaultPetLabel}),
|
|
63
68
|
/* @__PURE__ */u("select",{id:`${d}-pet`,value:f,disabled:n,onChange:e=>a(e.currentTarget.value),style:e.input,children:[f===""?/* @__PURE__ */c("option",{value:"",children:s.noPetSelected}):null,p.map(e=>/* @__PURE__ */c("option",{value:e.petRef,children:e.name??e.petRef},e.petRef))]}),
|
|
64
69
|
/* @__PURE__ */u("div",{style:e.links,children:[
|
|
65
|
-
/* @__PURE__ */c("button",{type:"button",disabled:!h||n,"aria-busy":n?"true":void 0,onClick:()=>l(f),style:e.secondary,children:n?s.savingPet:s.savePet}),i&&!h?/* @__PURE__ */c("p",{style:e.footnote,role:"status",children:s.petSaved}):null]})]})}function Xr(e){let{color:t,radius:r,space:n,type:i,slots:o}=e,a=e=>`${Math.round(e*i.lineHeight.snug)}px`,l=(t,r,n)=>({margin:0,...faceCss(e,n),fontSize:t,lineHeight:a(t),color:r}),s=o.card?.textColor;return{card:{boxSizing:"border-box",display:"flex",flexDirection:"column",gap:n.md,padding:n.lg,borderRadius:r.lg,border:`1px solid ${t.brandBorder}`,backgroundColor:t.surface,...Jr(o.card,1)},title:l(i.size.subtitle,s??t.text.primary,"bold"),subtitle:l(i.size.body,s??t.text.primary,"bold"),body:l(i.size.body,s??t.text.secondary,"regular"),footnote:l(i.size.caption,t.text.muted,"regular"),phone:l(i.size.body,s??t.text.primary,"bold"),label:l(i.size.caption,s??t.text.primary,"bold"),input:{boxSizing:"border-box",width:"100%",minHeight:44,padding:`0 ${n.md}px`,borderRadius:r.md,border:`1px solid ${t.controlEdge}`,backgroundColor:t.surface,...faceCss(e,"regular"),fontSize:i.size.body,color:t.text.primary,...Jr(o.input,1)},consentRow:{display:"flex",alignItems:"flex-start",gap:n.sm,cursor:"pointer"},box:{width:24,height:24,minWidth:24,margin:0,accentColor:t.brand,cursor:"pointer"},consentText:{...l(i.size.caption,s??t.text.secondary,"regular"),whiteSpace:"pre-wrap"},primary:{minHeight:44,padding:`0 ${n.lg}px`,borderRadius:r.pill,border:"none",backgroundColor:t.brand,color:t.text.onBrand,cursor:"pointer",...faceCss(e,"bold"),fontSize:i.size.body,...Jr(o.primaryButton)},secondary:{minHeight:44,padding:`0 ${n.lg}px`,borderRadius:r.pill,border:`1px solid ${t.brandBorder}`,backgroundColor:t.surface,color:t.brandInk,cursor:"pointer",...faceCss(e,"bold"),fontSize:i.size.caption},link:{alignSelf:"flex-start",minHeight:44,padding:0,border:"none",background:"none",cursor:"pointer",...faceCss(e,"bold"),fontSize:i.size.caption,color:t.linkInk,...Jr(o.link)},links:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:n.md},notice:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:n.xs},noticeText:l(i.size.caption,t.errorRed,"regular"),confirm:{display:"flex",flexDirection:"column",gap:n.sm,padding:n.md,borderRadius:r.md,backgroundColor:t.surfaceSubtle},petRow:{display:"flex",flexDirection:"column",gap:n.xs},skeleton:{height:96,borderRadius:r.md,backgroundColor:t.skeleton}}}var Zr=/* @__PURE__ */Symbol.for("@everfur/sdk#IntroOpen@v1"),en=globalThis;function tn(e){if(typeof e!="object"||e===null)return false;let t=e;return t.holds instanceof Set&&t.listeners instanceof Set}var rn=en[Zr],nn=()=>({holds:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set}),on=tn(rn)?rn:en[Zr]=nn();function an(){return on.holds.size>0}function ln(e){return on.listeners.add(e),()=>{on.listeners.delete(e)}}function sn(){return n(ln,an,an)}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 dn=/* @__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"&&dn.has(t.urgencyLevel))}var un=/* @__PURE__ */new WeakSet;function cn(e){return un.has(e)}var pn="everfur.texting.askSchedule.v1",fn=2880*60*1e3,hn=3,bn=/* @__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>=hn?false:r.nextAskAt===null||t>=r.nextAskAt}function yn(e,t){return{askCount:Math.min(e.askCount+1,hn),nextAskAt:t+fn,completed:e.completed}}function gn(e,t){return{...e,nextAskAt:t+fn}}function mn(e){return{...e,completed:true}}function vn(e){return e.askCount<=0?1:e.askCount===1?2:3}function _n(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,hn),nextAskAt:n,completed:i}}function wn(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=_n(n);if(t===null)return null;r[e]=t}return r}var Cn=/* @__PURE__ */Symbol.for("@everfur/sdk/texting/ask-schedule@v1");function Sn(){let e=globalThis,t=e[Cn];return t===void 0&&(t={sessions:/* @__PURE__ */new Map,sessionListeners:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set,writeChain:Promise.resolve()},e[Cn]=t),t.sessionListeners===void 0&&(t.sessionListeners=/* @__PURE__ */new Set),t}async function kn(e){if(cn(e))return{status:"unreadable"};let t;try{t=await e.getItem(pn)}catch{return{status:"unreadable"}}if(t===null)try{return await e.setItem(pn,"{}"),await e.getItem(pn)===null?{status:"unreadable"}:{status:"ok",map:{}}}catch{return{status:"unreadable"}}let r=wn(t);if(r!==null)return{status:"ok",map:r};try{await e.removeItem(pn)}catch{}return{status:"unreadable"}}function xn(e){let{listeners:t}=Sn();return t.add(e),()=>{t.delete(e)}}function En(e,userRef,t){let r=Sn(),n=async()=>{let n=await kn(e);if(n.status!=="ok")return;let i=n.map[userRef]??bn;try{await e.setItem(pn,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 Fn(e,userRef){let t=await kn(e);return t.status!=="ok"?{status:"unreadable"}:{status:"ok",entry:t.map[userRef]??bn}}function Tn(e,userRef,t=Date.now()){return En(e,userRef,e=>yn(e,t))}function On(e,userRef,t=Date.now()){return En(e,userRef,e=>gn(e,t))}function In(e,userRef){return En(e,userRef,mn)}function An(userRef){return Sn().sessions.get(userRef)??null}function Rn(userRef,e){let t=Sn();t.sessions.set(userRef,e);for(let e of[...t.sessionListeners])e()}function Dn(e){let{sessionListeners:t}=Sn();return t.add(e),()=>{t.delete(e)}}var NO_SNAPSHOT=()=>null;function zn(){let{runtime:t}=Ft(),r=t.entitlements??null,o=i(e=>r===null?()=>{}:r.subscribe(e),[r]),a=r===null?NO_SNAPSHOT:r.getSnapshot,l=n(o,a,a);return e(()=>l!==null&&decideCapability("texting",l.decisions,{isPending:l.isPending}).enabled,[l])}var Nn=/* @__PURE__ */Object.freeze({status:"idle"});function Pn(userRef){let{runtime:e}=Ft(),t=e.registry.services.kv,[n,i]=a({user:null,value:Nn});return r(()=>{if(userRef===null)return;let e=true,r=()=>{Fn(t,userRef).then(t=>{e&&i({user:userRef,value:{status:"ready",read:t}})})};r();let n=xn(r);return()=>{e=false,n()}},[t,userRef]),n.user===userRef?n.value:Nn}function jn(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(t={}){let o=t.enabled!==false,l=t.ready!==false,s=t.surface??"prompt",d=t.entry===true,{runtime:u,userRef:userRef}=Ft(),c=u.registry.services.kv,p=zn(),f=Pn(o&&userRef!==null?userRef:null),h=i(()=>userRef===null?null:An(userRef),[userRef]),b=n(Dn,h,h),y=i(e=>{userRef!==null&&Rn(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(),w=f.status==="ready"&&isTextingAskEligible(f.read,_),[C,S]=a(null),k=d&&userRef!==null&&p,x=sr(userRef!==null&&C===userRef||v!=="hidden"||g||k),E=jn(x),{readEnabled:F,due:T}=resolveTextingAskDue({enabled:o,capabilityGranted:p,hasProfile:x.profile!==null,signedIn:userRef!==null,scheduleEligible:w,offeredThisSession:b!==null,identity:E,surfaceReady:l});r(()=>{F&&userRef!==null&&S(userRef)},[F,userRef]);let O=b?.askNumber??(f.status==="ready"&&f.read.status==="ok"?vn(f.read.entry):1);r(()=>{!T||userRef===null||An(userRef)!==null||y({surface:s,stage:"offered",answered:false,askNumber:O})},[T,userRef,y,O,s]),r(()=>{!g||b.stage!=="handoff"||o&&l&&p&&x.profile!==null&&E==="none"&&y({...b,stage:"offered"})},[g,b,o,l,p,x.profile,E,y]);let I=f.status==="ready"&&f.read.status==="ok"&&f.read.entry.completed;r(()=>{userRef===null||E!=="exists"||I||f.status!=="ready"||In(c,userRef)},[E,I,f.status,c,userRef]),r(()=>{g&&b.stage==="enrolling"&&x.status==="verified"&&y({...b,stage:"verified"})},[g,b,x.status,y]);let A=i(e=>userRef===null||e.answered?e:(Tn(c,userRef),{...e,answered:true}),[c,userRef]),R=i(()=>{g&&b.stage==="offered"&&y({...b,stage:"enrolling"})},[g,b,y]),D=i(()=>{if(!g||b.stage!=="enrolling")return;let{back:e,...t}=b;y({...t,stage:e??"offered"})},[g,b,y]),z=i(()=>{if(!(!g||b.stage!=="offered"&&b.stage!=="enrolling")){if(s==="prompt"){y({...A(b),surface:"chat",stage:"handoff",fromPrompt:true});return}b.fromPrompt===true&&b.answered&&userRef!==null&&On(c,userRef),y({...A(b),stage:"dismissed"})}},[g,b,s,y,A,c,userRef]),{start:N}=x,P=i(async e=>!g||b.stage!=="enrolling"?false:(b.answered||y(A(b)),N(e)),[g,b,y,A,N]),j=k&&x.profile!==null&&E==="none"&&v!=="enrolling"&&v!=="verified",M=i(()=>{if(!j||userRef===null)return;let e=g?b:null;y({surface:s,stage:"enrolling",answered:e?.answered??false,askNumber:b?.askNumber??O,...e?.fromPrompt===true?{fromPrompt:true}:{},back:e?.stage==="offered"?"offered":"dismissed"})},[j,userRef,g,b,y,s,O]),L=x.profile?.brandName??"";return e(()=>({stage:userRef===null?"hidden":v,brand:L,askNumber:O,texting:x,accept:R,dismiss:z,close:D,start:P,canOpen:j,open:M}),[userRef,v,L,O,x,R,z,D,P,j,M])}var Mn=/* @__PURE__ */new Set(["signedOut","unavailable","failed","verified","optingOut","optedOut"]);function Ln(e,n,i,o){let{userRef:userRef}=Ft(),a=t(null),{canOpen:l,open:s,stage:d,texting:u}=e;r(()=>{if(!n){a.current=null;return}if(!(userRef===null||a.current===userRef)){if(l){a.current=userRef,s();return}if(d==="enrolling"||d==="verified"){a.current=userRef;return}(!i||Mn.has(u.status))&&(a.current=userRef,b(o,"skipped"))}},[n,userRef,l,s,d,u.status,i,o])}var qn='button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])';function $n(e){return e.tagName==="DIALOG"}function Bn(e){if(typeof document>"u")return null;let t=e?.getRootNode();return t&&t!==document&&"activeElement"in t?t.activeElement:document.activeElement}function Un(e,n,o,a){let l=a?.escapeAtKeyDown===true,s=t(null),d=t(false),u=t(null),c=t(o);c.current=o;let p=i(()=>{if(!d.current)return;d.current=false;let e=c.current===void 0?u.current:c.current.current;e&&e.isConnected&&e.focus(),(!e||!e.isConnected||Bn(e)===e)&&(u.current=null)},[]);r(()=>{if(!e){p();return}let t=s.current;if(!d.current){let e=Bn(t);e!==null&&t!==null&&t.contains(e)||(u.current=e instanceof HTMLElement?e:null)}if(d.current=true,t===null)return;if(!$n(t)){t.contains(Bn(t))||(t.querySelector(qn)??t).focus();return}let r=t;typeof r.showModal=="function"?r.open||r.showModal():r.setAttribute("open","")},[e,p]),r(()=>p,[p]),r(()=>{let t=s.current;if(!e||t===null||!$n(t))return;let r=t;if(typeof r.showModal!="function")return;let n=null,i=e=>{e.target instanceof HTMLElement&&(n=e.target)},o=()=>{if(!r.isConnected||r.open)return;let e=n;r.showModal(),e!==null&&e.isConnected&&r.contains(e)&&Bn(r)!==e&&e.focus()};return r.addEventListener("focusin",i),r.addEventListener("close",o),()=>{r.removeEventListener("focusin",i),r.removeEventListener("close",o)}},[e]);let f=i(e=>{let t=s.current;if(t===null)return;if(e.key==="Escape"&&!$n(t)){e.preventDefault(),e.stopPropagation(),n();return}if(e.key==="Escape"&&l);if(e.key!=="Tab")return;let r=Array.from(t.querySelectorAll(qn)),i=r[0],o=r[r.length-1];if(!i||!o){e.preventDefault();return}let a=Bn(t);e.shiftKey&&(a===i||!t.contains(a))?(e.preventDefault(),o.focus()):!e.shiftKey&&(a===o||!t.contains(a))&&(e.preventDefault(),i.focus())},[n,l]),h=i(e=>{e.target===e.currentTarget&&(e.preventDefault(),n())},[n]);return{dialogRef:s,onKeyDown:f,onCancel:h}}var Hn=2,Vn="data-ef-focus-ring";function ChatTextingAskController({enabled:e,ready:t,onAsk:n,entry:i=false}){let o=useTextingAsk({enabled:e,ready:t,surface:"chat",entry:i});return r(()=>{b(n,o)},[o,n]),null}function textingAskLines(e){return{line:It.chatAskLine(e.brand),accept:Ot.promptAccept,dismiss:Ot.promptDismiss,verified:It.chatAskVerified(e.brand)}}function ChatTextingAskComposer({ask:t}){let r=useEverfurTheme(),n=e(()=>Yn(r),[r]);/* @__PURE__ */
|
|
66
|
-
return c(AskEntry,{ask:t,styles:n})}function AskEntry({ask:e,styles:n}){let i=o(),{texting:l}=e,{status:s,profile:d,snapshot:p}=l,[f,h]=a(""),[b,y]=a(false),[g
|
|
70
|
+
/* @__PURE__ */c("button",{type:"button",disabled:!h||n,"aria-busy":n?"true":void 0,onClick:()=>l(f),style:e.secondary,children:n?s.savingPet:s.savePet}),i&&!h?/* @__PURE__ */c("p",{style:e.footnote,role:"status",children:s.petSaved}):null]})]})}function Zr(e){let{color:t,radius:r,space:n,type:i,slots:o}=e,a=e=>`${Math.round(e*i.lineHeight.snug)}px`,l=(t,r,n)=>({margin:0,...faceCss(e,n),fontSize:t,lineHeight:a(t),color:r}),s=o.card?.textColor;return{card:{boxSizing:"border-box",display:"flex",flexDirection:"column",gap:n.md,padding:n.lg,borderRadius:r.lg,border:`1px solid ${t.brandBorder}`,backgroundColor:t.surface,...Xr(o.card,1)},title:l(i.size.subtitle,s??t.text.primary,"bold"),subtitle:l(i.size.body,s??t.text.primary,"bold"),body:l(i.size.body,s??t.text.secondary,"regular"),footnote:l(i.size.caption,t.text.muted,"regular"),phone:l(i.size.body,s??t.text.primary,"bold"),label:l(i.size.caption,s??t.text.primary,"bold"),input:{boxSizing:"border-box",width:"100%",minHeight:44,padding:`0 ${n.md}px`,borderRadius:r.md,border:`1px solid ${t.controlEdge}`,backgroundColor:t.surface,...faceCss(e,"regular"),fontSize:i.size.body,color:t.text.primary,...Xr(o.input,1)},consentRow:{display:"flex",alignItems:"flex-start",gap:n.sm,cursor:"pointer"},box:{width:24,height:24,minWidth:24,margin:0,accentColor:t.brand,cursor:"pointer"},consentText:{...l(i.size.caption,s??t.text.secondary,"regular"),whiteSpace:"pre-wrap"},primary:{minHeight:44,padding:`0 ${n.lg}px`,borderRadius:r.pill,border:"none",backgroundColor:t.brand,color:t.text.onBrand,cursor:"pointer",...faceCss(e,"bold"),fontSize:i.size.body,...Xr(o.primaryButton)},secondary:{minHeight:44,padding:`0 ${n.lg}px`,borderRadius:r.pill,border:`1px solid ${t.brandBorder}`,backgroundColor:t.surface,color:t.brandInk,cursor:"pointer",...faceCss(e,"bold"),fontSize:i.size.caption},link:{alignSelf:"flex-start",minHeight:44,padding:0,border:"none",background:"none",cursor:"pointer",...faceCss(e,"bold"),fontSize:i.size.caption,color:t.linkInk,...Xr(o.link)},links:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:n.md},notice:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:n.xs},noticeText:l(i.size.caption,t.errorRed,"regular"),confirm:{display:"flex",flexDirection:"column",gap:n.sm,padding:n.md,borderRadius:r.md,backgroundColor:t.surfaceSubtle},petRow:{display:"flex",flexDirection:"column",gap:n.xs},skeleton:{height:96,borderRadius:r.md,backgroundColor:t.skeleton}}}var en=/* @__PURE__ */Symbol.for("@everfur/sdk#IntroOpen@v1"),tn=globalThis;function rn(e){if(typeof e!="object"||e===null)return false;let t=e;return t.holds instanceof Set&&t.listeners instanceof Set}var nn=tn[en],on=()=>({holds:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set}),an=rn(nn)?nn:tn[en]=on();function ln(){return an.holds.size>0}function sn(e){return an.listeners.add(e),()=>{an.listeners.delete(e)}}function dn(){return n(sn,ln,ln)}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 un=/* @__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"&&un.has(t.urgencyLevel))}var cn=/* @__PURE__ */new WeakSet;function pn(e){return cn.has(e)}var fn="everfur.texting.askSchedule.v1",hn=2880*60*1e3,bn=3,yn=/* @__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>=bn?false:r.nextAskAt===null||t>=r.nextAskAt}function mn(e,t){return{askCount:Math.min(e.askCount+1,bn),nextAskAt:t+hn,completed:e.completed}}function gn(e,t){return{...e,nextAskAt:t+hn}}function vn(e){return{...e,completed:true}}function _n(e){return e.askCount<=0?1:e.askCount===1?2:3}function Cn(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,bn),nextAskAt:n,completed:i}}function wn(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=Cn(n);if(t===null)return null;r[e]=t}return r}var Sn=/* @__PURE__ */Symbol.for("@everfur/sdk/texting/ask-schedule@v1");function kn(){let e=globalThis,t=e[Sn];return t===void 0&&(t={sessions:/* @__PURE__ */new Map,sessionListeners:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set,writeChain:Promise.resolve()},e[Sn]=t),t.sessionListeners===void 0&&(t.sessionListeners=/* @__PURE__ */new Set),t}async function xn(e){if(pn(e))return{status:"unreadable"};let t;try{t=await e.getItem(fn)}catch{return{status:"unreadable"}}if(t===null)try{return await e.setItem(fn,"{}"),await e.getItem(fn)===null?{status:"unreadable"}:{status:"ok",map:{}}}catch{return{status:"unreadable"}}let r=wn(t);if(r!==null)return{status:"ok",map:r};try{await e.removeItem(fn)}catch{}return{status:"unreadable"}}function En(e){let{listeners:t}=kn();return t.add(e),()=>{t.delete(e)}}function Fn(e,userRef,t){let r=kn(),n=async()=>{let n=await xn(e);if(n.status!=="ok")return;let i=n.map[userRef]??yn;try{await e.setItem(fn,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 Tn(e,userRef){let t=await xn(e);return t.status!=="ok"?{status:"unreadable"}:{status:"ok",entry:t.map[userRef]??yn}}function On(e,userRef,t=Date.now()){return Fn(e,userRef,e=>mn(e,t))}function In(e,userRef,t=Date.now()){return Fn(e,userRef,e=>gn(e,t))}function An(e,userRef){return Fn(e,userRef,vn)}function Rn(userRef){return kn().sessions.get(userRef)??null}function Nn(userRef,e){let t=kn();t.sessions.set(userRef,e);for(let e of[...t.sessionListeners])e()}function Dn(e){let{sessionListeners:t}=kn();return t.add(e),()=>{t.delete(e)}}var NO_SNAPSHOT=()=>null;function zn(){let{runtime:t}=Ft(),r=t.entitlements??null,o=i(e=>r===null?()=>{}:r.subscribe(e),[r]),a=r===null?NO_SNAPSHOT:r.getSnapshot,l=n(o,a,a);return e(()=>l!==null&&decideCapability("texting",l.decisions,{isPending:l.isPending}).enabled,[l])}var Pn=/* @__PURE__ */Object.freeze({status:"idle"});function jn(userRef){let{runtime:e}=Ft(),t=e.registry.services.kv,[n,i]=a({user:null,value:Pn});return r(()=>{if(userRef===null)return;let e=true,r=()=>{Tn(t,userRef).then(t=>{e&&i({user:userRef,value:{status:"ready",read:t}})})};r();let n=En(r);return()=>{e=false,n()}},[t,userRef]),n.user===userRef?n.value:Pn}function Mn(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(t={}){let o=t.enabled!==false,l=t.ready!==false,s=t.surface??"prompt",d=t.entry===true,{runtime:u,userRef:userRef}=Ft(),c=u.registry.services.kv,p=zn(),f=jn(o&&userRef!==null?userRef:null),h=i(()=>userRef===null?null:Rn(userRef),[userRef]),b=n(Dn,h,h),y=i(e=>{userRef!==null&&Nn(userRef,e)},[userRef]),m=b!==null&&b.surface===s,g=b!==null&&b.fromPrompt===true,v=m?b.stage==="handoff"?"hidden":b.stage:s==="prompt"&&g?"dismissed":"hidden",_=Date.now(),C=f.status==="ready"&&isTextingAskEligible(f.read,_),[w,S]=a(null),k=d&&userRef!==null&&p,x=dr(userRef!==null&&w===userRef||v!=="hidden"||m||k),E=Mn(x),{readEnabled:F,due:T}=resolveTextingAskDue({enabled:o,capabilityGranted:p,hasProfile:x.profile!==null,signedIn:userRef!==null,scheduleEligible:C,offeredThisSession:b!==null,identity:E,surfaceReady:l});r(()=>{F&&userRef!==null&&S(userRef)},[F,userRef]);let O=b?.askNumber??(f.status==="ready"&&f.read.status==="ok"?_n(f.read.entry):1);r(()=>{!T||userRef===null||Rn(userRef)!==null||y({surface:s,stage:"offered",answered:false,askNumber:O})},[T,userRef,y,O,s]),r(()=>{!m||b.stage!=="handoff"||o&&l&&p&&x.profile!==null&&E==="none"&&y({...b,stage:"offered"})},[m,b,o,l,p,x.profile,E,y]);let I=f.status==="ready"&&f.read.status==="ok"&&f.read.entry.completed;r(()=>{userRef===null||E!=="exists"||I||f.status!=="ready"||An(c,userRef)},[E,I,f.status,c,userRef]),r(()=>{m&&b.stage==="enrolling"&&x.status==="verified"&&y({...b,stage:"verified"})},[m,b,x.status,y]);let A=i(e=>userRef===null||e.answered?e:(On(c,userRef),{...e,answered:true}),[c,userRef]),R=i(()=>{m&&b.stage==="offered"&&y({...b,stage:"enrolling"})},[m,b,y]),N=i(()=>{if(!m||b.stage!=="enrolling")return;let{back:e,...t}=b;y({...t,stage:e??"offered"})},[m,b,y]),D=i(()=>{if(!(!m||b.stage!=="offered"&&b.stage!=="enrolling")){if(s==="prompt"){y({...A(b),surface:"chat",stage:"handoff",fromPrompt:true});return}b.fromPrompt===true&&b.answered&&userRef!==null&&In(c,userRef),y({...A(b),stage:"dismissed"})}},[m,b,s,y,A,c,userRef]),{start:z}=x,P=i(async e=>!m||b.stage!=="enrolling"?false:(b.answered||y(A(b)),z(e)),[m,b,y,A,z]),j=k&&x.profile!==null&&E==="none"&&v!=="enrolling"&&v!=="verified",M=i(()=>{if(!j||userRef===null)return;let e=m?b:null;y({surface:s,stage:"enrolling",answered:e?.answered??false,askNumber:b?.askNumber??O,...e?.fromPrompt===true?{fromPrompt:true}:{},back:e?.stage==="offered"?"offered":"dismissed"})},[j,userRef,m,b,y,s,O]),q=x.profile?.brandName??"";return e(()=>({stage:userRef===null?"hidden":v,brand:q,askNumber:O,texting:x,accept:R,dismiss:D,close:N,start:P,canOpen:j,open:M}),[userRef,v,q,O,x,R,D,N,P,j,M])}var qn=/* @__PURE__ */new Set(["signedOut","unavailable","failed","verified","optingOut","optedOut"]);function Ln(e,n,i,o){let{userRef:userRef}=Ft(),a=t(null),{canOpen:l,open:s,stage:d,texting:u}=e;r(()=>{if(!n){a.current=null;return}if(!(userRef===null||a.current===userRef)){if(l){a.current=userRef,s();return}if(d==="enrolling"||d==="verified"){a.current=userRef;return}(!i||qn.has(u.status))&&(a.current=userRef,b(o,"skipped"))}},[n,userRef,l,s,d,u.status,i,o])}var $n='button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])';function Bn(e){return e.tagName==="DIALOG"}function Un(e){if(typeof document>"u")return null;let t=e?.getRootNode();return t&&t!==document&&"activeElement"in t?t.activeElement:document.activeElement}function Hn(e,n,o,a){let l=a?.escapeAtKeyDown===true,s=t(null),d=t(false),u=t(null),c=t(o);c.current=o;let p=i(()=>{if(!d.current)return;d.current=false;let e=c.current===void 0?u.current:c.current.current;e&&e.isConnected&&e.focus(),(!e||!e.isConnected||Un(e)===e)&&(u.current=null)},[]);r(()=>{if(!e){p();return}let t=s.current;if(!d.current){let e=Un(t);e!==null&&t!==null&&t.contains(e)||(u.current=e instanceof HTMLElement?e:null)}if(d.current=true,t===null)return;if(!Bn(t)){t.contains(Un(t))||(t.querySelector($n)??t).focus();return}let r=t;typeof r.showModal=="function"?r.open||r.showModal():r.setAttribute("open","")},[e,p]),r(()=>p,[p]),r(()=>{let t=s.current;if(!e||t===null||!Bn(t))return;let r=t;if(typeof r.showModal!="function")return;let n=null,i=e=>{e.target instanceof HTMLElement&&(n=e.target)},o=()=>{if(!r.isConnected||r.open)return;let e=n;r.showModal(),e!==null&&e.isConnected&&r.contains(e)&&Un(r)!==e&&e.focus()};return r.addEventListener("focusin",i),r.addEventListener("close",o),()=>{r.removeEventListener("focusin",i),r.removeEventListener("close",o)}},[e]);let f=i(e=>{let t=s.current;if(t===null)return;if(e.key==="Escape"&&!Bn(t)){e.preventDefault(),e.stopPropagation(),n();return}if(e.key==="Escape"&&l);if(e.key!=="Tab")return;let r=Array.from(t.querySelectorAll($n)),i=r[0],o=r[r.length-1];if(!i||!o){e.preventDefault();return}let a=Un(t);e.shiftKey&&(a===i||!t.contains(a))?(e.preventDefault(),o.focus()):!e.shiftKey&&(a===o||!t.contains(a))&&(e.preventDefault(),i.focus())},[n,l]),h=i(e=>{e.target===e.currentTarget&&(e.preventDefault(),n())},[n]);return{dialogRef:s,onKeyDown:f,onCancel:h}}var Vn=2,Yn="data-ef-focus-ring";function ChatTextingAskController({enabled:e,ready:t,onAsk:n,entry:i=false}){let o=useTextingAsk({enabled:e,ready:t,surface:"chat",entry:i});return r(()=>{b(n,o)},[o,n]),null}function textingAskLines(e){return{line:It.chatAskLine(e.brand),accept:Ot.promptAccept,dismiss:Ot.promptDismiss,verified:It.chatAskVerified(e.brand)}}function ChatTextingAskComposer({ask:t}){let r=useEverfurTheme(),n=e(()=>Wn(r),[r]);/* @__PURE__ */
|
|
71
|
+
return c(AskEntry,{ask:t,styles:n})}function AskEntry({ask:e,styles:n}){let i=o(),{texting:l}=e,{status:s,profile:d,snapshot:p}=l,[f,h]=a(""),[b,y]=a(false),[m,g]=a(""),[v,_]=a(null),C=t(null),w=t(null),[S,k]=a(false),x={[Yn]:"self",onFocus:()=>k(true),onBlur:()=>k(false)},E=S?{...n.pill,...n.pillFocused}:n.pill,F=s==="enroll"||s==="requesting"&&!p.resending,T=s==="code"||s==="confirming"||s==="requesting";r(()=>{_(null)},[s]),r(()=>{F?C.current?.focus():T&&w.current?.focus()},[F,T]);let O=/* @__PURE__ */c("button",{type:"button","aria-label":Ot.close,onClick:e.close,style:n.close,children:/* @__PURE__ */c("svg",{width:18,height:18,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:/* @__PURE__ */c("path",{d:"M6 6l12 12M18 6L6 18",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",fill:"none"})})}),I=p.error===null?null:/* @__PURE__ */c("div",{role:"alert",style:n.notice,children:/* @__PURE__ */c("p",{style:n.noticeText,children:textingErrorText(p.error,p.failedAction,p.codeRefusal)})}),A=v===null?null:/* @__PURE__ */c("p",{role:"alert",style:n.noticeText,children:textingInputProblemText(v)});if(d===null)return null;if(s==="loading"||s==="failed"||s==="signedOut"||s==="unavailable")/* @__PURE__ */
|
|
67
72
|
return c("div",{style:n.root,"data-everfur-texting-ask":"entry","aria-busy":s==="loading"?"true":void 0,children:/* @__PURE__ */u("div",{style:n.head,children:[
|
|
68
73
|
/* @__PURE__ */c("div",{style:n.headBody,children:s==="failed"?I:null}),O]})});if(F){let t=s==="requesting",r=()=>{let t=validateTextingEnroll(f,b);_(t),t===null&&e.start(f)};/* @__PURE__ */
|
|
69
74
|
return u("div",{style:n.root,"data-everfur-texting-ask":"phone",children:[
|
|
@@ -73,23 +78,23 @@ return u("div",{style:n.root,"data-everfur-texting-ask":"phone",children:[
|
|
|
73
78
|
/* @__PURE__ */c("input",{type:"checkbox",checked:b,disabled:t,"aria-invalid":v==="consentRequired"?"true":void 0,onChange:e=>y(e.currentTarget.checked),style:n.box}),
|
|
74
79
|
/* @__PURE__ */c("span",{style:n.consentText,children:d.consentText})]}),d.helpContact===null?null:/* @__PURE__ */u("p",{style:n.footnote,children:[Ot.helpContactLabel," ",d.helpContact]})]}),O]}),A,I,
|
|
75
80
|
/* @__PURE__ */u("form",{style:E,onSubmit:e=>{e.preventDefault(),r()},children:[
|
|
76
|
-
/* @__PURE__ */c("input",{ref:
|
|
77
|
-
/* @__PURE__ */c("button",{type:"submit",disabled:t,"aria-busy":t?"true":void 0,style:n.primary,children:t?Ot.sendingCode:Ot.sendCode})]})]})}if(T){let e=s==="confirming",t=s==="requesting",r=e||t,i=()=>{let e=validateTextingCode(
|
|
81
|
+
/* @__PURE__ */c("input",{ref:C,id:`${i}-phone`,type:"tel",inputMode:"tel",autoComplete:"tel-national","aria-label":Ot.phoneLabel,placeholder:Ot.phoneLabel,value:f,disabled:t,"aria-invalid":v==="phoneInvalid"?"true":void 0,onChange:e=>h(e.currentTarget.value),...x,style:n.field}),
|
|
82
|
+
/* @__PURE__ */c("button",{type:"submit",disabled:t,"aria-busy":t?"true":void 0,style:n.primary,children:t?Ot.sendingCode:Ot.sendCode})]})]})}if(T){let e=s==="confirming",t=s==="requesting",r=e||t,i=()=>{let e=validateTextingCode(m);_(e),e===null&&l.confirm(m)};/* @__PURE__ */
|
|
78
83
|
return u("div",{style:n.root,"data-everfur-texting-ask":"code",children:[
|
|
79
84
|
/* @__PURE__ */u("div",{style:n.head,children:[
|
|
80
85
|
/* @__PURE__ */u("div",{style:n.headBody,children:[
|
|
81
86
|
/* @__PURE__ */u("p",{style:n.body,children:[Ot.codeSentTo," ",formatTextingPhone(p.phoneE164)]}),
|
|
82
87
|
/* @__PURE__ */u("div",{style:n.links,children:[
|
|
83
|
-
/* @__PURE__ */c("button",{type:"button",disabled:r,"aria-busy":t?"true":void 0,onClick:()=>{
|
|
84
|
-
/* @__PURE__ */c("button",{type:"button",disabled:r,onClick:()=>{
|
|
88
|
+
/* @__PURE__ */c("button",{type:"button",disabled:r,"aria-busy":t?"true":void 0,onClick:()=>{g(""),l.resend()},style:n.link,children:Ot.requestNewCode}),
|
|
89
|
+
/* @__PURE__ */c("button",{type:"button",disabled:r,onClick:()=>{g(""),l.changeNumber()},style:n.link,children:Ot.changeNumber})]})]}),O]}),A,I,
|
|
85
90
|
/* @__PURE__ */u("form",{style:E,onSubmit:e=>{e.preventDefault(),i()},children:[
|
|
86
|
-
/* @__PURE__ */c("input",{ref:
|
|
87
|
-
/* @__PURE__ */c("button",{type:"submit",disabled:r,"aria-busy":e?"true":void 0,style:n.primary,children:e?Ot.confirmingCode:Ot.confirmCode})]})]})}return null}function
|
|
88
|
-
return c("dialog",{ref:_.dialogRef,"aria-label":
|
|
89
|
-
/* @__PURE__ */c("h2",{style:d.title,children:
|
|
91
|
+
/* @__PURE__ */c("input",{ref:w,type:"text",inputMode:"numeric",autoComplete:"one-time-code",maxLength:6,"aria-label":Ot.codeLabel,placeholder:Ot.codeLabel,value:m,disabled:r,"aria-invalid":v==="codeInvalidFormat"?"true":void 0,onChange:e=>g(e.currentTarget.value.replace(/\D/g,"")),...x,style:{...n.field,fontVariantNumeric:"tabular-nums"}}),
|
|
92
|
+
/* @__PURE__ */c("button",{type:"submit",disabled:r,"aria-busy":e?"true":void 0,style:n.primary,children:e?Ot.confirmingCode:Ot.confirmCode})]})]})}return null}function Wn(e){let{color:t,radius:r,space:n,type:i,slots:o}=e,a=e=>`${Math.round(e*i.lineHeight.snug)}px`,l=(t,r,n)=>({margin:0,...faceCss(e,n),fontSize:t,lineHeight:a(t),color:r});return{root:{boxSizing:"border-box",display:"flex",flexDirection:"column",gap:n.sm,width:"100%"},head:{display:"flex",alignItems:"flex-start",gap:n.sm},headBody:{display:"flex",flexDirection:"column",gap:n.xs,minWidth:0,flex:"1 1 auto"},consentRow:{display:"flex",alignItems:"flex-start",gap:n.sm,cursor:"pointer"},box:{width:24,height:24,minWidth:24,margin:0,accentColor:t.brand,cursor:"pointer"},consentText:{...l(i.size.caption,t.text.secondary,"regular"),whiteSpace:"pre-wrap"},body:l(i.size.body,t.text.primary,"regular"),footnote:l(i.size.caption,t.text.muted,"regular"),pill:{boxSizing:"border-box",display:"flex",alignItems:"center",gap:n.xs,margin:0,minHeight:50,padding:`${n.xs}px ${n.xs}px ${n.xs}px ${n.md}px`,borderRadius:r.pill,border:`1.5px solid ${t.controlEdge}`,backgroundColor:t.surface,...Xr(o.input,1)},pillFocused:{border:`1.5px solid ${o.input?.borderColor??t.brandInk}`,outline:`${Vn}px solid ${t.brandInk}`,outlineOffset:Vn},field:{boxSizing:"border-box",flex:"1 1 auto",minWidth:0,minHeight:44,padding:0,border:"none",outline:"none",background:"transparent",...faceCss(e,"regular"),fontSize:Math.max(16,i.size.body),color:t.text.primary},primary:{flex:"0 0 auto",minHeight:44,padding:`0 ${n.lg}px`,borderRadius:r.pill,border:"none",backgroundColor:t.brand,color:t.text.onBrand,cursor:"pointer",...faceCss(e,"bold"),fontSize:i.size.caption,...Xr(o.primaryButton)},close:{flex:"0 0 auto",display:"inline-flex",alignItems:"center",justifyContent:"center",width:44,height:44,padding:0,border:"none",borderRadius:r.pill,background:"none",color:t.text.muted,cursor:"pointer"},links:{display:"flex",flexWrap:"wrap",alignItems:"center",columnGap:n.md},link:{minHeight:44,padding:0,border:"none",background:"none",cursor:"pointer",...faceCss(e,"bold"),fontSize:i.size.caption,color:t.linkInk,...Xr(o.link)},notice:{display:"flex",flexDirection:"column",gap:n.xs},noticeText:l(i.size.caption,t.errorRed,"regular")}}var Kn=/* @__PURE__ */new Set(["offered","enrolling"]);function EverfurTextingPrompt({onResolved:n,requested:i=false}){let o=dn(),l=useTextingAsk({surface:"prompt",ready:!o,entry:i});Ln(l,i,zn(),n);let s=useEverfurTheme(),d=e(()=>Gn(s),[s]),f=e(()=>Wn(s),[s]),h=t(false),[y,m]=a(false);Kn.has(l.stage)&&(h.current=true);let g=h.current&&(Kn.has(l.stage)||l.stage==="verified")&&!y&&!o,v=()=>{y||(l.stage==="verified"?(m(true),b(n,"verified")):l.dismiss())};r(()=>{h.current&&l.stage==="dismissed"&&!y&&(m(true),b(n,"dismissed"))},[l.stage,n,y]);let _=Hn(g,v);if(!g)return null;let C=l.stage==="verified"?Ot.verifiedTitle:It.promptTitle(l.brand);/* @__PURE__ */
|
|
93
|
+
return c("dialog",{ref:_.dialogRef,"aria-label":C,"aria-modal":"true",onCancel:_.onCancel,onKeyDown:_.onKeyDown,style:d.frame,"data-everfur-texting-prompt":"",children:/* @__PURE__ */c("div",{style:d.scrim,onClick:e=>{e.target===e.currentTarget&&v()},children:/* @__PURE__ */u("div",{style:d.panel,children:[
|
|
94
|
+
/* @__PURE__ */c("h2",{style:d.title,children:C}),l.stage==="offered"?/* @__PURE__ */u(p,{children:[
|
|
90
95
|
/* @__PURE__ */c("p",{style:d.body,children:Ot.promptBody}),
|
|
91
96
|
/* @__PURE__ */u("div",{style:d.actions,children:[
|
|
92
97
|
/* @__PURE__ */c("button",{type:"button",onClick:l.accept,style:d.primary,children:Ot.promptAccept}),
|
|
93
98
|
/* @__PURE__ */c("button",{type:"button",onClick:l.dismiss,style:d.secondary,children:Ot.promptDismiss})]})]}):null,l.stage==="enrolling"?/* @__PURE__ */c(AskEntry,{ask:l,styles:f}):null,l.stage==="verified"?/* @__PURE__ */u(p,{children:[
|
|
94
99
|
/* @__PURE__ */c("p",{style:d.body,children:It.chatAskVerified(l.brand)}),
|
|
95
|
-
/* @__PURE__ */c("div",{style:d.actions,children:/* @__PURE__ */c("button",{type:"button",onClick:v,style:d.secondary,children:Ot.close})})]}):null]})})})}function
|
|
100
|
+
/* @__PURE__ */c("div",{style:d.actions,children:/* @__PURE__ */c("button",{type:"button",onClick:v,style:d.secondary,children:Ot.close})})]}):null]})})})}function Gn(e){let{color:t,radius:r,space:n,type:i,slots:o}=e,a={minHeight:48,padding:`0 ${n.lg}px`,borderRadius:r.pill,cursor:"pointer",...faceCss(e,"bold"),fontSize:i.size.body};return{frame:{boxSizing:"border-box",position:"fixed",inset:0,width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",margin:0,padding:0,border:0,backgroundColor:"transparent",overflow:"hidden"},scrim:{boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",padding:n.lg,backgroundColor:"rgba(0,0,0,0.4)"},panel:{boxSizing:"border-box",width:"100%",maxWidth:480,maxHeight:"100%",overflowY:"auto",display:"flex",flexDirection:"column",gap:n.md,padding:`${n.xl}px ${n.lg}px ${n.lg}px`,borderRadius:r.xl,backgroundColor:t.surface,textAlign:"center",...Xr(o.dialog)},title:{margin:0,...headingFaceCss(e,"bold"),fontSize:i.size.heading,lineHeight:`${Math.round(i.size.heading*i.lineHeight.snug)}px`,color:t.text.primary},body:{margin:0,...faceCss(e,"regular"),fontSize:i.size.body,lineHeight:`${Math.round(i.size.body*i.lineHeight.normal)}px`,color:t.text.secondary},actions:{display:"flex",flexDirection:"column",gap:n.xs,marginTop:n.xs},primary:{...a,border:"none",backgroundColor:t.brand,color:t.text.onBrand,...Xr(o.primaryButton)},secondary:{...a,border:"none",background:"none",color:t.text.muted}}}export{Tt as COPY_PLACEHOLDER_PREFIX,ChatTextingAskComposer,ChatTextingAskController,Vt as EVERFUR_TEXTING_STATUSES,EverfurTextingOptIn,EverfurTextingPrompt,bn as TEXTING_ASK_MAX_ASKS,fn as TEXTING_ASK_SCHEDULE_KEY,hn as TEXTING_ASK_SNOOZE_MS,It as TEXTING_BRAND_COPY,Yt as TEXTING_CODE_PATTERN,Ot as TEXTING_COPY,At as TEXTING_COPY_PLACEHOLDERS,lr as TEXTING_UI_CODE_LENGTH,or as TextingController,createTextingRepository,createTextingRepositoryOver,formatTextingPhone,isE164,isTextingAskEligible,parseTextingProfile,resolveTextingAskDue,textingAskLines,textingAskThreadReady,textingErrorText,textingIdentityFromWire,textingInputProblemText,textingOptedOutBody,textingReasonOf,textingSupportText,toTextingE164,useEverfurTexting,useEverfurTextingProfile,useEverfurTextingRepository,useTextingAsk,validateTextingCode,validateTextingEnroll};
|