@everfur/sdk 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Chat.d-D9n8tSDD.d.cts → Chat.d-Bl-_TsvQ.d.cts} +1 -1
- package/dist/{Chat.d-BXuEjJsg.d.ts → Chat.d-qQVN6VLp.d.ts} +1 -1
- package/dist/animations/index.cjs +1 -1
- package/dist/animations/index.js +1 -1
- package/dist/{attachments.d-Bsg6duaq.d.cts → attachments.d-DBlHzWYy.d.cts} +1 -1
- package/dist/{attachments.d-DjWUR-h9.d.ts → attachments.d-DOmkQ_8O.d.ts} +1 -1
- package/dist/{branding.d-Bzs4HJoN.d.cts → branding.d-CqDLKj1U.d.cts} +1 -1
- package/dist/{branding.d-CiC6xfGT.d.ts → branding.d-XrZYClN4.d.ts} +1 -1
- package/dist/chat/index.cjs +194 -194
- package/dist/chat/index.d.cts +7 -7
- package/dist/chat/index.d.ts +7 -7
- package/dist/chat/index.js +202 -202
- package/dist/chat/lite/index.cjs +205 -205
- package/dist/chat/lite/index.d.cts +7 -7
- package/dist/chat/lite/index.d.ts +7 -7
- package/dist/chat/lite/index.js +205 -205
- package/dist/{chatHandoffToken.d-sbumx0He.d.cts → chatHandoffToken.d-B4-iQ35P.d.cts} +3 -3
- package/dist/{chatHandoffToken.d-YJY6TZbj.d.ts → chatHandoffToken.d-Br3Gw3w-.d.ts} +3 -3
- package/dist/{checkin.d-DxpoRutq.d.cts → checkin.d-CAKQydg8.d.cts} +14 -2
- package/dist/{checkin.d-C6vh9KVr.d.ts → checkin.d-qvYXugN3.d.ts} +14 -2
- package/dist/{chunk-AJEELSFO.js → chunk-5OK2AF63.js} +14 -14
- package/dist/{chunk-II4QDD6F.js → chunk-6I4REU4U.js} +1 -1
- package/dist/{chunk-ZPIOCHKW.js → chunk-7MMJ7CYN.js} +1 -1
- package/dist/{chunk-FZ6DAQFH.js → chunk-PJHMKQ5C.js} +19 -19
- package/dist/client/index.cjs +2 -2
- package/dist/client/index.d.cts +7 -7
- package/dist/client/index.d.ts +7 -7
- package/dist/client/index.js +2 -2
- package/dist/consent/index.cjs +1 -1
- package/dist/consent/index.js +2 -2
- package/dist/{context.d-Cq2C4vdh.d.cts → context.d-DZfxKxNi.d.cts} +3 -3
- package/dist/{context.d-D1l56nFr.d.ts → context.d-FjU7dQP7.d.ts} +3 -3
- package/dist/core/index.cjs +21 -21
- package/dist/core/index.d.cts +10 -10
- package/dist/core/index.d.ts +10 -10
- package/dist/core/index.js +21 -21
- package/dist/{entitlementRepository.d-x2YFdgYD.d.ts → entitlementRepository.d-BltqS1W8.d.ts} +1 -1
- package/dist/{entitlementRepository.d-CEDU1gZE.d.cts → entitlementRepository.d-wfqpUIKN.d.cts} +1 -1
- package/dist/health-plan/index.cjs +1 -1
- package/dist/health-plan/index.d.cts +4 -4
- package/dist/health-plan/index.d.ts +4 -4
- package/dist/health-plan/index.js +1 -1
- package/dist/index.cjs +221 -221
- package/dist/index.d.cts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.js +221 -221
- package/dist/notifications/inbox/index.cjs +9 -9
- package/dist/notifications/inbox/index.js +9 -9
- package/dist/notifications/index.cjs +3 -3
- package/dist/notifications/index.d.cts +3 -3
- package/dist/notifications/index.d.ts +3 -3
- package/dist/notifications/index.js +6 -6
- package/dist/photo/index.cjs +1 -1
- package/dist/photo/index.js +23 -23
- package/dist/{presentation.d-CWGjwq8Z.d.cts → presentation.d-BkIvMtIl.d.cts} +3 -3
- package/dist/{presentation.d-CWGjwq8Z.d.ts → presentation.d-BkIvMtIl.d.ts} +3 -3
- package/dist/records/depth/index.cjs +1 -1
- package/dist/records/depth/index.js +1 -1
- package/dist/records/index.cjs +2 -2
- package/dist/records/index.d.cts +2 -2
- package/dist/records/index.d.ts +2 -2
- package/dist/records/index.js +71 -71
- package/dist/{route.d-IP_gkOWL.d.ts → route.d-B395-hNX.d.ts} +1 -1
- package/dist/{route.d-9wclfD-y.d.cts → route.d-DSSSpSB-.d.cts} +1 -1
- package/dist/{runtimeTypes.d-BdUe3tYs.d.ts → runtimeTypes.d-DAz0Tgw5.d.ts} +5 -5
- package/dist/{runtimeTypes.d-_UZ6rMUY.d.cts → runtimeTypes.d-DPh1Wh15.d.cts} +5 -5
- package/dist/server/events/index.cjs +3 -3
- package/dist/server/events/index.js +3 -3
- package/dist/server/index.cjs +8 -8
- package/dist/server/index.d.cts +15 -1
- package/dist/server/index.d.ts +15 -1
- package/dist/server/index.js +8 -8
- package/dist/slots/index.cjs +1 -1
- package/dist/slots/index.js +1 -1
- package/dist/tabs/index.cjs +2 -2
- package/dist/tabs/index.js +24 -24
- package/dist/televet/booking/index.cjs +51 -51
- package/dist/televet/booking/index.js +1 -1
- package/dist/televet/index.cjs +1 -1
- package/dist/televet/index.js +1 -1
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/testing/rn/index.cjs +8 -8
- package/dist/testing/rn/index.d.cts +5 -5
- package/dist/testing/rn/index.d.ts +5 -5
- package/dist/testing/rn/index.js +9 -9
- package/dist/testing/web/index.cjs +3 -3
- package/dist/testing/web/index.d.cts +5 -5
- package/dist/testing/web/index.d.ts +5 -5
- package/dist/testing/web/index.js +1 -1
- package/dist/texting/index.cjs +1 -1
- package/dist/texting/index.js +26 -26
- package/dist/{threadOptions.d-BW0rePcs.d.cts → threadOptions.d-DUQxxHyM.d.cts} +3 -3
- package/dist/{threadOptions.d-CrAb71J2.d.ts → threadOptions.d-DnM9UcMx.d.ts} +3 -3
- package/dist/{typeStyle.d-rzVzCfLz.d.ts → typeStyle.d-8mcLhtbH.d.ts} +1 -1
- package/dist/{typeStyle.d-B-YgiWcS.d.cts → typeStyle.d-CLrQZW-r.d.cts} +1 -1
- package/dist/{unreadStore.d-gCsleb6l.d.ts → unreadStore.d-CLnChKca.d.ts} +17 -9
- package/dist/{unreadStore.d-w5x6lEpR.d.cts → unreadStore.d-Donv4bcF.d.cts} +17 -9
- package/dist/{usePresentation.d-w5_oWKmh.d.ts → usePresentation.d-Buxz2Jkt.d.ts} +1 -1
- package/dist/{usePresentation.d-DefUwatV.d.cts → usePresentation.d-DUYzYXgA.d.cts} +1 -1
- package/dist/{useUnread.d-DeRDFtTb.d.cts → useUnread.d-7-cuCooM.d.cts} +3 -3
- package/dist/{useUnread.d-xDOpYyqx.d.ts → useUnread.d-B6Ehu0ao.d.ts} +3 -3
- package/dist/video/index.cjs +1 -1
- package/dist/video/index.js +1 -1
- package/dist/web/consent/index.cjs +3 -3
- package/dist/web/consent/index.js +5 -5
- package/dist/web/health-plan/index.cjs +2 -2
- package/dist/web/health-plan/index.d.cts +5 -5
- package/dist/web/health-plan/index.d.ts +5 -5
- package/dist/web/health-plan/index.js +1 -1
- package/dist/web/inbox/index.cjs +5 -5
- package/dist/web/inbox/index.js +5 -5
- package/dist/web/index.cjs +176 -176
- package/dist/web/index.d.cts +18 -18
- package/dist/web/index.d.ts +18 -18
- package/dist/web/index.js +181 -181
- package/dist/web/intro/index.cjs +10 -10
- package/dist/web/intro/index.js +6 -6
- package/dist/web/notifications/index.cjs +5 -5
- package/dist/web/notifications/index.d.cts +2 -2
- package/dist/web/notifications/index.d.ts +2 -2
- package/dist/web/notifications/index.js +1 -1
- package/dist/web/records/depth/index.cjs +1 -1
- package/dist/web/records/depth/index.js +1 -1
- package/dist/web/records/index.cjs +1 -1
- package/dist/web/records/index.js +1 -1
- package/dist/web/records-sheet/index.cjs +2 -2
- package/dist/web/records-sheet/index.js +2 -2
- package/dist/web/shop/index.cjs +1 -1
- package/dist/web/shop/index.js +15 -15
- package/dist/web/televet/booking/index.cjs +2 -2
- package/dist/web/televet/booking/index.js +64 -64
- package/dist/web/televet/call/index.cjs +1 -1
- package/dist/web/televet/call/index.js +1 -1
- package/dist/web/televet/index.cjs +6 -6
- package/dist/web/televet/index.js +1 -1
- package/dist/web/texting/index.cjs +1 -1
- package/dist/web/texting/index.js +1 -1
- package/dist/web/ui/index.cjs +1 -1
- package/dist/web/ui/index.js +33 -33
- package/package.json +1 -1
package/dist/{entitlementRepository.d-x2YFdgYD.d.ts → entitlementRepository.d-BltqS1W8.d.ts}
RENAMED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { E as EverfurError } from './EverfurError.d-8NHtlgzA.js';
|
|
3
3
|
import { R as RequestFunnel } from './requestFunnel.d-CehftayS.js';
|
|
4
4
|
import { A as AuthContext } from './identity.d-DOKJFaiz.js';
|
|
5
|
-
import { C as ClientBranding } from './branding.d-
|
|
5
|
+
import { C as ClientBranding } from './branding.d-XrZYClN4.js';
|
|
6
6
|
import { E as EntitlementDecision } from './resolve.d-BTC3b6FW.js';
|
|
7
7
|
|
|
8
8
|
/** The conditional-GET endpoint (SPEC-00 §5.3). Relative; the transport prefixes the resolved base URL. */
|
package/dist/{entitlementRepository.d-CEDU1gZE.d.cts → entitlementRepository.d-wfqpUIKN.d.cts}
RENAMED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { E as EverfurError } from './EverfurError.d-8NHtlgzA.cjs';
|
|
3
3
|
import { R as RequestFunnel } from './requestFunnel.d-SySe6xHp.cjs';
|
|
4
4
|
import { A as AuthContext } from './identity.d-DIH9h3Le.cjs';
|
|
5
|
-
import { C as ClientBranding } from './branding.d-
|
|
5
|
+
import { C as ClientBranding } from './branding.d-CqDLKj1U.cjs';
|
|
6
6
|
import { E as EntitlementDecision } from './resolve.d-BTC3b6FW.cjs';
|
|
7
7
|
|
|
8
8
|
/** The conditional-GET endpoint (SPEC-00 §5.3). Relative; the transport prefixes the resolved base URL. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! @everfur/sdk. Copyright (c) 2026 Strand Health Inc. dba Everfur. All rights reserved. Use is subject to the Everfur SDK License: https://docs.everfur.com/license */
|
|
2
2
|
"use strict";var e=require("react"),t=require("react-native"),n=require("react/jsx-runtime"),r=require("react-native-safe-area-context"),i=require("@everfur/sdk/records");var o=/* @__PURE__ */Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function face(e,t){let n=e.type,r=n.families[t];return t==="mono"||n.namedFaces[t]?{fontFamily:r}:{fontFamily:r,fontWeight:n.weight[o[t]]}}function headingFace(e,t="bold"){let{headingFamily:n,headingWeight:r}=e.type;if(n===null&&r===null)return face(e,t);if(n!==null)return{fontFamily:n,fontWeight:r??e.type.weight[o[t]]};let i=face(e,t);return i.fontWeight===void 0||r===null?i:{fontFamily:i.fontFamily,fontWeight:r}}function l(e){return e<=450?"regular":e<=650?"medium":"bold"}var a={regular:"mono",medium:"monoMedium",bold:"monoBold"};function textRole(e,t){let n=s.get(e);n===void 0&&(n=/* @__PURE__ */new Map,s.set(e,n));let r=n.get(t);if(r!==void 0)return r;let i=c(e,t);return n.set(t,i),i}var s=/* @__PURE__ */new WeakMap;function c(e,t){let n=e.type.roles[t],r=n.weight==="400"&&n.face!=="mono"?e.type.weight.regular:n.weight,i=l(Number(r)),o=n.face==="mono"?face(e,a[i]):n.face==="heading"?headingFace(e,i):face(e,i),s=n.face==="heading"?e.type.headingWeight??r:r,c=o.fontWeight===void 0?o:{fontFamily:o.fontFamily,fontWeight:s},d=n.size,u={...c,fontSize:d,lineHeight:Math.round(d*n.lineHeight*100)/100};return n.letterSpacing!==0&&(u.letterSpacing=Math.round(d*n.letterSpacing*100)/100),n.uppercase&&(u.textTransform="uppercase"),/* @__PURE__ */Object.freeze(u)}var d=/* @__PURE__ */Object.freeze({loading:"Loading",retry:"Try again",signedOut:"Sign in required",addToCart:"Add to cart",added:"Added",remove:"Remove",checkout:"Checkout",subtotal:"Subtotal",sample:"Sample",cartEmpty:"Your cart is empty.",choosePet:"Choose a pet",emptyTitle:"",emptyBody:"",emptyAsk:""}),u=/* @__PURE__ */Object.freeze({emptyTitle:true,emptyBody:true,emptyAsk:true}),p=/* @__PURE__ */Object.freeze({dna:"",records:"Records",inside:"Inside",profile:""}),h=/* @__PURE__ */Object.freeze({planTitle:e=>`${e}'s care plan`,cartLabel:e=>`${e} cart`}),g=/* @__PURE__ */Object.freeze([...Object.keys(d).filter(e=>u[e]===true&&d[e]==="").map(e=>`HEALTH_PLAN_COPY.${e}`),...["profile"].filter(e=>p[e]==="").map(e=>`HEALTH_PLAN_REASON_LABELS.${e}`)]);var f=/* @__PURE__ */Object.freeze({imageVariant:"wide",reasonVariant:"pills",cartBarVisibility:"whenItems",cartBarPlacement:"sticky",addButtonSize:"full",addedVariant:"link",categoryVariant:"text",showCategory:false,cardShadow:false,cardBorder:true});function m(e,t){return{setInPlan:t,addAll:async()=>{let n=(e?.items??[]).filter(e=>!e.inPlan);return(await Promise.all(n.map(e=>t(e.productId,true)))).every(Boolean)}}}function showHealthPlanCartBar(e,t){return(e??f.cartBarVisibility)==="always"||t>0}var y=/* @__PURE__ */Object.freeze(["showCategory","cardShadow","cardBorder","addButtonSize","addButtonFontSize","addedVariant","categoryVariant","cardPadding","itemTitleSize","itemTitleWeight","priceSize","priceWeight","reasonTextSize","reasonLabelWidth","reasonGap"]);function b(e){let t={};for(let n of y)e[n]!==void 0&&(t[n]=e[n]);return t}function w(e){let t=typeof e=="number"&&Number.isFinite(e)&&e>0?e:e==="compact"?32:44;return{height:t,hit:Math.max(44,t)}}function x(e){if(e.length>200||e.includes(",")&&!/rgba?\(|hsla?\(/i.test(e))return null;let t=/(rgba?\([^)]*\)|hsla?\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)\s*$/i.exec(e.trim())?.[1]??null;if(t===null)return null;let n=e.trim().slice(0,e.trim().length-t.length).trim().split(/\s+/).filter(Boolean);if(n.length<2||n.length>4)return null;let r=n.map(e=>e==="0"?0:/^-?\d*\.?\d+px$/.test(e)?Number(e.slice(0,-2)):Number.NaN);return r.some(e=>!Number.isFinite(e))?null:{color:t,offsetX:r[0]??0,offsetY:r[1]??0,blur:Math.max(0,r[2]??0)}}function k(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:null}function v(e,t){let n=k(e);return n===null?0:n-t}function isHealthPlanSessionRequired(e){return e!==null&&(e.reasonCode==="session_required"||e.code==="sessionRequired")}var S=/* @__PURE__ */Symbol.for("@everfur/sdk#HealthPlanCartDock@v1"),T=globalThis,C=T[S]??(T[S]=e.createContext(null));function HealthPlanCartScope({children:t}){let[n,r]=e.useState(null),i=e.useMemo(()=>({dock:n,publish:r}),[n]);return e.createElement(C.Provider,{value:i},t)}function useHealthPlanCartDock(){return e.useContext(C)?.dock??null}function j(t,n,r,petRef,i,o){let l=e.useContext(C)?.publish,a=e.useRef(o);e.useEffect(()=>{a.current=o},[o]);let s=e.useMemo(()=>m(i,(e,t)=>a.current(e,t)),[i]);e.useEffect(()=>{if(!(l===void 0||!t))return l(/* @__PURE__ */Object.freeze({cart:n,busy:r,petRef:petRef,plan:i,...s})),()=>l(null)},[l,t,n,r,petRef,i,s])}var I=/* @__PURE__ */Object.freeze({track(){},trackExpectedFailure(){}});function ok(e,t){/* @__PURE__ */
|
|
3
3
|
return Object.freeze({ok:true,value:e})}function err(e){/* @__PURE__ */
|
|
4
|
-
return Object.freeze({ok:false,error:e})}var H=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var P=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),F=globalThis,R=F[P]??(F[P]=e.createContext(null));R.displayName??="EverfurContext";function D(){let t=e.useContext(R);if(t===null)throw new H("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return t}var z=/* @__PURE__ */Object.freeze({opened:"health_plan.opened",productClicked:"health_plan.product_clicked",checkoutStarted:"health_plan.checkout_started"});function $(){return e.useContext(R)?.runtime.registry.services.telemetry??I}var O=e.createContext(null);function HealthPlanPetScope({petRef:petRef,children:t}){return e.createElement(O.Provider,{value:petRef},t)}function B(t){let n=e.useContext(O),r=e.useContext(R);return n??t??r?.activePet??null}function _(t,petRef,n){let r=$(),i=e.useRef(null);e.useEffect(()=>{if(!t||petRef===null||i.current===petRef)return;i.current=petRef;let e=n?.items??[];r.track(z.opened,{petRef:petRef,itemsCount:e.length,inPlanCount:e.filter(e=>e.inPlan).length})},[t,petRef,n,r])}function L(e,petRef,t,n){e.track(z.productClicked,{petRef:petRef,productId:t,inPlan:n})}function E(e,petRef,t){e.track(z.checkoutStarted,{petRef:petRef,itemsCount:t.count,subtotal:t.subtotal,currency:t.currency})}function A(e){return e!=null&&(e.wait!==void 0||e.pick.hidden===true)}function W(e){return{...e,pick:{...e.pick,none:true,hidden:true}}}var V=/* @__PURE__ */Object.freeze({productId:"",partnerSku:null,title:"",description:null,category:null,price:null,currency:null,imageUrl:null,url:null,reasons:[],inPlan:false,sample:false});var M=[{wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"DAILY_QUOTA_EXCEEDED",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"FILE_TOO_LARGE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"IDEMPOTENCY_KEY_IN_FLIGHT",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"INVALID_CONTENT_TYPE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"InternalFailureException",envelope:"http_envelope",httpStatus:500,retryable:true},{wireCode:"MethodNotAllowedException",envelope:"http_envelope",httpStatus:405,retryable:false},{wireCode:"NotImplementedException",envelope:"http_envelope",httpStatus:501,retryable:false},{wireCode:"PaymentRequiredException",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ResourceNotFoundException",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"ServiceUnavailableException",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"TIER_UPGRADE_REQUIRED",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ThrottlingException",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"ValidationException",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"accessDenied",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"access_denied",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"anchor_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"anchor_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"anonTokenInvalid",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"attachment_unreadable",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"authExpired",envelope:"http_envelope",httpStatus:401,retryable:true},{wireCode:"authRejected",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"before_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_not_uploaded",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundles_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"catalog_empty_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"catalog_shrink_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"consent_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_required",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_scope_wrong_route",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"device_cipher_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"email_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"endpoint_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"environment_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_cursor_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_payload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_not_available",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_unknown",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_required",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_reused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"inbox_cursor_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"insufficientCapability",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"insufficient_scope",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"internal_error",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"invalidRequest",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"invalid_client",envelope:"oauth_error",httpStatus:401,retryable:false},{wireCode:"invalid_client_metadata",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_grant",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_redirect_uri",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_request",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_scope",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_target",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"item_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"linked_account_read_only",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_connection_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"mcp_request_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_request_gone",envelope:"http_envelope",httpStatus:410,retryable:false},{wireCode:"mcp_request_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"not_found",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"open_url_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"partner_visit_link_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"partner_visit_owner_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"partner_visit_pet_already_mapped",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"payload_too_large",envelope:"http_envelope",httpStatus:413,retryable:false},{wireCode:"petRefInUse",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"pet_health_list_removals_unconfirmed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_health_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_not_registered",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"provider_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"rateLimited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"read_target_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_subject_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"record_upload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"records_consent_required",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"restricted_key",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"sandbox_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_required",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_revoked",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"share_limit_reached",envelope:"http_envelope",httpStatus:429,retryable:false},{wireCode:"slow_down",envelope:"oauth_error",httpStatus:429,retryable:true},{wireCode:"species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"subscription_keys_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"tenant_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"tenant_has_no_capabilities",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tenant_resource_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"tenant_surface_not_enabled",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"ticket_not_resolved",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tickets_disabled",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"timeout",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"token_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"unavailable",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"unrestrictedKeyRequired",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"unsupported_grant_type",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"unsupported_response_type",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"user_ref_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"verify_mint_rate_limited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"verify_mint_refused",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"verify_mint_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"verify_user_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"web_push_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"webhook_endpoint_update_empty",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false}],N=/* @__PURE__ */Object.freeze(M.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(N.map(e=>e.wireCode));var U=/* @__PURE__ */Object.freeze({ValidationException:"validationFailed",AuthorizationException:"authRejected",PaymentRequiredException:"paymentRequired",AccessDeniedException:"accessDenied",ResourceNotFoundException:"resourceNotFound",ConflictException:"conflict",ThrottlingException:"rateLimited",InternalFailureException:"internalError",NotImplementedException:"notImplemented",ServiceUnavailableException:"serviceUnavailable",MethodNotAllowedException:"validationFailed",authExpired:"authExpired",unavailable:"serviceUnavailable",session_required:"sessionRequired",session_revoked:"authExpired",anonTokenInvalid:"authRejected",accessDenied:"accessDenied",invalidRequest:"sdkUpdateRequired",authRejected:"authRejected",rateLimited:"rateLimited",insufficientCapability:"accessDenied",unrestrictedKeyRequired:"accessDenied",user_ref_invalid:"validationFailed",event_cursor_invalid:"validationFailed",event_filter_invalid:"validationFailed",event_payload_invalid:"validationFailed",event_type_unknown:"validationFailed",idempotency_key_invalid:"validationFailed",idempotency_key_required:"validationFailed",idempotency_key_reused:"idempotencyConflict",payload_too_large:"validationFailed",webhook_url_rejected:"validationFailed",webhook_endpoint_update_empty:"validationFailed",webhook_endpoint_update_invalid:"validationFailed",event_type_not_available:"conflict",record_subject_not_found:"resourceNotFound",records_consent_required:"conflict",record_species_unsupported:"validationFailed",record_upload_invalid:"validationFailed",FILE_TOO_LARGE:"validationFailed",INVALID_CONTENT_TYPE:"validationFailed",attachment_unreadable:"validationFailed",provider_unsupported:"validationFailed",token_invalid:"validationFailed",device_cipher_unavailable:"serviceUnavailable",email_invalid:"validationFailed",consent_required:"validationFailed",consent_invalid:"validationFailed",consent_scope_wrong_route:"validationFailed",IDEMPOTENCY_KEY_IN_FLIGHT:"idempotencyInFlight",IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST:"idempotencyConflict",DAILY_QUOTA_EXCEEDED:"quotaExceeded",TIER_UPGRADE_REQUIRED:"paymentRequired",not_found:"conversationNotFound",timeout:"streamTimeout",internal_error:"internalError",invalid_request:"validationFailed",invalid_client:"authRejected",invalid_grant:"authRejected",unsupported_grant_type:"validationFailed",invalid_scope:"validationFailed",invalid_target:"validationFailed",invalid_redirect_uri:"validationFailed",invalid_client_metadata:"validationFailed",unsupported_response_type:"validationFailed",access_denied:"accessDenied",slow_down:"rateLimited",mcp_request_not_found:"resourceNotFound",mcp_request_gone:"resourceNotFound",mcp_connection_not_found:"resourceNotFound",mcp_request_conflict:"conflict",sandbox_only:"accessDenied",tenant_has_no_capabilities:"conflict",verify_mint_refused:"accessDenied",verify_mint_rate_limited:"rateLimited",verify_mint_unavailable:"serviceUnavailable",verify_user_ref_invalid:"validationFailed",insufficient_scope:"accessDenied",tenant_filter_invalid:"validationFailed",tenant_resource_not_found:"resourceNotFound",tenant_surface_not_enabled:"conflict",pet_health_species_unsupported:"validationFailed",pet_health_list_removals_unconfirmed:"validationFailed",petRefInUse:"conflict",share_limit_reached:"conflict",pet_not_registered:"resourceNotFound",species_unsupported:"validationFailed",partner_visit_owner_only:"accessDenied",partner_visit_link_conflict:"conflict",partner_visit_pet_already_mapped:"conflict",linked_account_read_only:"conflict",catalog_empty_refused:"conflict",catalog_shrink_refused:"conflict",endpoint_not_allowed:"validationFailed",event_id_invalid:"validationFailed",inbox_cursor_invalid:"validationFailed",item_id_invalid:"validationFailed",open_url_not_allowed:"validationFailed",read_target_invalid:"validationFailed",subscription_keys_invalid:"validationFailed",web_push_unavailable:"serviceUnavailable",anchor_not_found:"resourceNotFound",anchor_ref_invalid:"validationFailed",before_invalid:"validationFailed",bundle_mismatch:"validationFailed",bundle_not_uploaded:"validationFailed",bundles_unavailable:"serviceUnavailable",environment_mismatch:"validationFailed",restricted_key:"accessDenied",ticket_not_resolved:"conflict",tickets_disabled:"resourceNotFound"}),q=/* @__PURE__ */Object.freeze(N.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:U[e.wireCode]}))),G=new Map(q.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),K=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(q.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(e,t){if(typeof e!="string")return;let n=e.trim().toUpperCase();if(n.length!==0)for(let e of[t??"http_envelope",...K]){let t=G.get(e+n);if(t)return t}}var X=/* @__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 X[e]}function fromWire(e){let t=contractErrorFor(e);if(t)return t.normalized;let n=(e??"").trim().toUpperCase(),r=n.replace(/[^A-Z0-9]/g,"");if(r==="AUTHREJECTED")return"authRejected";if(n.startsWith("AUTH"))return"authExpired";switch(r){case"DAILYQUOTAEXCEEDED":case"QUOTAEXCEEDED":return"quotaExceeded";case"RATELIMITED":case"TOOMANYREQUESTS":case"TELEVETRATELIMITED":return"rateLimited";case"IDEMPOTENCYKEYCONFLICT":case"IDEMPOTENCYCONFLICT":return"idempotencyConflict";case"ACCESSDENIED":case"FORBIDDEN":return"accessDenied";case"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";case"RUNTIMEDISPOSED":return"runtimeDisposed";case"NOTFOUND":case"CONVERSATIONNOTFOUND":return"conversationNotFound";case"PETNOTFOUND":return"petNotFound";case"TIMEOUT":case"STREAMTIMEOUT":return"streamTimeout";case"MEDIAUPLOADFAILED":case"UNRECOGNIZEDVIDEOFORMAT":case"FILETOOSMALL":return"mediaUploadFailed";case"MODERATIONBLOCKED":return"moderationBlocked";case"UPSTREAMLLMTIMEOUT":return"upstreamLlmTimeout";case"INTERNALERROR":case"INTERNALSERVERERROR":return"internalError";case"STREAMINCOMPLETE":case"CHATSTREAMINCOMPLETE":return"streamIncomplete";case"INVALIDANALYSISTYPE":case"INVALIDUPLOADPURPOSE":return"unknown";default:return"unknown"}}var Y=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return Y.has(e)}var J=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||J.has(e)}var Q=500,Z=8e3,ee=4;function backoffDelayMs(e,t=Math.random){let n=Math.max(0,e),r=Math.min(Q*2**n,Z);return Math.floor(t()*r)}var te="This feature isn't available on your account right now.",ne="Something in that request was not right. Check the details and try again.",re=/* @__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:te,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:ne,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:te,runtimeDisposed:ne,unknown:"Something went wrong. Please try again."}),ie="This session has ended. Please sign in again.",oe="linked_account_read_only";function le(e,t,n){return e==="conflict"&&n===oe?te:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?ie:userFacingError(e)}function userFacingError(e){return re[e]}function ae(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:false,writable:false,configurable:false})}var se=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let n=contractErrorFor(t?.wireCode,t?.wireEnvelope),r=e==="conflict"&&t?.reasonCode===oe,i={code:e,category:categoryFor(e),retryable:t?.retryable??(r?false:isRetryableCode(e)),displayMessage:le(e,t?.wireCode,r?oe:null)};t?.httpStatus!==void 0&&(i.httpStatus=t.httpStatus),t?.requestId&&(i.requestId=t.requestId),typeof t?.reasonCode=="string"&&se.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)),n);return t?.wireMessage&&ae(i,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&ae(i,"raw",t.raw),/* @__PURE__ */Object.freeze(i)}function assertNever(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}function errorFrame(e){/* @__PURE__ */
|
|
4
|
+
return Object.freeze({ok:false,error:e})}var H=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var P=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),F=globalThis,R=F[P]??(F[P]=e.createContext(null));R.displayName??="EverfurContext";function D(){let t=e.useContext(R);if(t===null)throw new H("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return t}var z=/* @__PURE__ */Object.freeze({opened:"health_plan.opened",productClicked:"health_plan.product_clicked",checkoutStarted:"health_plan.checkout_started"});function $(){return e.useContext(R)?.runtime.registry.services.telemetry??I}var O=e.createContext(null);function HealthPlanPetScope({petRef:petRef,children:t}){return e.createElement(O.Provider,{value:petRef},t)}function B(t){let n=e.useContext(O),r=e.useContext(R);return n??t??r?.activePet??null}function _(t,petRef,n){let r=$(),i=e.useRef(null);e.useEffect(()=>{if(!t||petRef===null||i.current===petRef)return;i.current=petRef;let e=n?.items??[];r.track(z.opened,{petRef:petRef,itemsCount:e.length,inPlanCount:e.filter(e=>e.inPlan).length})},[t,petRef,n,r])}function L(e,petRef,t,n){e.track(z.productClicked,{petRef:petRef,productId:t,inPlan:n})}function E(e,petRef,t){e.track(z.checkoutStarted,{petRef:petRef,itemsCount:t.count,subtotal:t.subtotal,currency:t.currency})}function A(e){return e!=null&&(e.wait!==void 0||e.pick.hidden===true)}function W(e){return{...e,pick:{...e.pick,none:true,hidden:true}}}var V=/* @__PURE__ */Object.freeze({productId:"",partnerSku:null,title:"",description:null,category:null,price:null,currency:null,imageUrl:null,url:null,reasons:[],inPlan:false,sample:false});var M=[{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}],N=/* @__PURE__ */Object.freeze(M.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(N.map(e=>e.wireCode));var U=/* @__PURE__ */Object.freeze({ValidationException:"validationFailed",AuthorizationException:"authRejected",PaymentRequiredException:"paymentRequired",AccessDeniedException:"accessDenied",ResourceNotFoundException:"resourceNotFound",ConflictException:"conflict",ThrottlingException:"rateLimited",InternalFailureException:"internalError",NotImplementedException:"notImplemented",ServiceUnavailableException:"serviceUnavailable",MethodNotAllowedException:"validationFailed",authExpired:"authExpired",unavailable:"serviceUnavailable",session_required:"sessionRequired",session_revoked:"authExpired",anonTokenInvalid:"authRejected",accessDenied:"accessDenied",invalidRequest:"sdkUpdateRequired",authRejected:"authRejected",rateLimited:"rateLimited",insufficientCapability:"accessDenied",unrestrictedKeyRequired:"accessDenied",user_ref_invalid:"validationFailed",event_cursor_invalid:"validationFailed",event_filter_invalid:"validationFailed",event_payload_invalid:"validationFailed",event_type_unknown:"validationFailed",idempotency_key_invalid:"validationFailed",idempotency_key_required:"validationFailed",idempotency_key_reused:"idempotencyConflict",payload_too_large:"validationFailed",webhook_url_rejected:"validationFailed",webhook_endpoint_update_empty:"validationFailed",webhook_endpoint_update_invalid:"validationFailed",event_type_not_available:"conflict",record_subject_not_found:"resourceNotFound",records_consent_required:"conflict",record_species_unsupported:"validationFailed",record_upload_invalid:"validationFailed",FILE_TOO_LARGE:"validationFailed",INVALID_CONTENT_TYPE:"validationFailed",attachment_unreadable:"validationFailed",provider_unsupported:"validationFailed",token_invalid:"validationFailed",device_cipher_unavailable:"serviceUnavailable",email_invalid:"validationFailed",consent_required:"validationFailed",consent_invalid:"validationFailed",consent_scope_wrong_route:"validationFailed",IDEMPOTENCY_KEY_IN_FLIGHT:"idempotencyInFlight",IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST:"idempotencyConflict",DAILY_QUOTA_EXCEEDED:"quotaExceeded",TIER_UPGRADE_REQUIRED:"paymentRequired",not_found:"conversationNotFound",timeout:"streamTimeout",internal_error:"internalError",invalid_request:"validationFailed",invalid_client:"authRejected",invalid_grant:"authRejected",unsupported_grant_type:"validationFailed",invalid_scope:"validationFailed",invalid_target:"validationFailed",invalid_redirect_uri:"validationFailed",invalid_client_metadata:"validationFailed",unsupported_response_type:"validationFailed",access_denied:"accessDenied",slow_down:"rateLimited",mcp_request_not_found:"resourceNotFound",mcp_request_gone:"resourceNotFound",mcp_connection_not_found:"resourceNotFound",mcp_request_conflict:"conflict",sandbox_only:"accessDenied",tenant_has_no_capabilities:"conflict",verify_mint_refused:"accessDenied",verify_mint_rate_limited:"rateLimited",verify_mint_unavailable:"serviceUnavailable",verify_user_ref_invalid:"validationFailed",insufficient_scope:"accessDenied",tenant_filter_invalid:"validationFailed",tenant_resource_not_found:"resourceNotFound",tenant_surface_not_enabled:"conflict",pet_health_species_unsupported:"validationFailed",pet_health_list_removals_unconfirmed:"validationFailed",petRefInUse:"conflict",share_limit_reached:"conflict",pet_not_registered:"resourceNotFound",species_unsupported:"validationFailed",partner_visit_owner_only:"accessDenied",partner_visit_link_conflict:"conflict",partner_visit_pet_already_mapped:"conflict",linked_account_read_only:"conflict",catalog_empty_refused:"conflict",catalog_shrink_refused:"conflict",endpoint_not_allowed:"validationFailed",event_id_invalid:"validationFailed",inbox_cursor_invalid:"validationFailed",item_id_invalid:"validationFailed",open_url_not_allowed:"validationFailed",read_target_invalid:"validationFailed",subscription_keys_invalid:"validationFailed",web_push_unavailable:"serviceUnavailable",anchor_not_found:"resourceNotFound",anchor_ref_invalid:"validationFailed",before_invalid:"validationFailed",bundle_mismatch:"validationFailed",bundle_not_uploaded:"validationFailed",bundles_unavailable:"serviceUnavailable",environment_mismatch:"validationFailed",restricted_key:"accessDenied",ticket_not_resolved:"conflict",tickets_disabled:"resourceNotFound",timezone_invalid:"validationFailed"}),q=/* @__PURE__ */Object.freeze(N.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:U[e.wireCode]}))),G=new Map(q.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),K=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(q.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(e,t){if(typeof e!="string")return;let n=e.trim().toUpperCase();if(n.length!==0)for(let e of[t??"http_envelope",...K]){let t=G.get(e+n);if(t)return t}}var X=/* @__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 X[e]}function fromWire(e){let t=contractErrorFor(e);if(t)return t.normalized;let n=(e??"").trim().toUpperCase(),r=n.replace(/[^A-Z0-9]/g,"");if(r==="AUTHREJECTED")return"authRejected";if(n.startsWith("AUTH"))return"authExpired";switch(r){case"DAILYQUOTAEXCEEDED":case"QUOTAEXCEEDED":return"quotaExceeded";case"RATELIMITED":case"TOOMANYREQUESTS":case"TELEVETRATELIMITED":return"rateLimited";case"IDEMPOTENCYKEYCONFLICT":case"IDEMPOTENCYCONFLICT":return"idempotencyConflict";case"ACCESSDENIED":case"FORBIDDEN":return"accessDenied";case"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";case"RUNTIMEDISPOSED":return"runtimeDisposed";case"NOTFOUND":case"CONVERSATIONNOTFOUND":return"conversationNotFound";case"PETNOTFOUND":return"petNotFound";case"TIMEOUT":case"STREAMTIMEOUT":return"streamTimeout";case"MEDIAUPLOADFAILED":case"UNRECOGNIZEDVIDEOFORMAT":case"FILETOOSMALL":return"mediaUploadFailed";case"MODERATIONBLOCKED":return"moderationBlocked";case"UPSTREAMLLMTIMEOUT":return"upstreamLlmTimeout";case"INTERNALERROR":case"INTERNALSERVERERROR":return"internalError";case"STREAMINCOMPLETE":case"CHATSTREAMINCOMPLETE":return"streamIncomplete";case"INVALIDANALYSISTYPE":case"INVALIDUPLOADPURPOSE":return"unknown";default:return"unknown"}}var Y=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return Y.has(e)}var J=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||J.has(e)}var Q=500,Z=8e3,ee=4;function backoffDelayMs(e,t=Math.random){let n=Math.max(0,e),r=Math.min(Q*2**n,Z);return Math.floor(t()*r)}var te="This feature isn't available on your account right now.",ne="Something in that request was not right. Check the details and try again.",re=/* @__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:te,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:ne,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:te,runtimeDisposed:ne,unknown:"Something went wrong. Please try again."}),ie="This session has ended. Please sign in again.",oe="linked_account_read_only";function le(e,t,n){return e==="conflict"&&n===oe?te:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?ie:userFacingError(e)}function userFacingError(e){return re[e]}function ae(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:false,writable:false,configurable:false})}var se=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let n=contractErrorFor(t?.wireCode,t?.wireEnvelope),r=e==="conflict"&&t?.reasonCode===oe,i={code:e,category:categoryFor(e),retryable:t?.retryable??(r?false:isRetryableCode(e)),displayMessage:le(e,t?.wireCode,r?oe:null)};t?.httpStatus!==void 0&&(i.httpStatus=t.httpStatus),t?.requestId&&(i.requestId=t.requestId),typeof t?.reasonCode=="string"&&se.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)),n);return t?.wireMessage&&ae(i,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&ae(i,"raw",t.raw),/* @__PURE__ */Object.freeze(i)}function assertNever(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}function errorFrame(e){/* @__PURE__ */
|
|
5
5
|
return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryable,wireMessage:e.wireMessage,synthesized:e.synthesized,lastEventId:e.lastEventId,serverRequestId:null,...e.freeCap?{freeCap:/* @__PURE__ */Object.freeze({...e.freeCap})}:{}})}var ce="x-everfur-anon-token",de="anonTokenInvalid";async function ue(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}function pe(e,t){let n=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}:{},...n?{wireMessage:n}:{},...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[ce]=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:{...he(e.headers),...authHeaders(t)}}}function he(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e)){let e=n.toLowerCase();e==="authorization"||e==="x-everfur-partner-key"||e===ce||(t[n]=r)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let n=await ue(t),r=await t.transport.request(withAuthHeaders(e,ge(t,n)));if(r.ok||me(r.error.raw)!==de||t.anonIdentity===void 0||t.userRef!==null)return r;let i=await t.anonIdentity.token({forceRefresh:true});return i===null||i===n?r:t.transport.request(withAuthHeaders(e,ge(t,i)))}let n;try{n=await t.identity.currentToken()}catch(e){return t.identity.reportRejected?.(),err(pe(e))}let r=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:n,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(r.ok||r.error.httpStatus!==401)return r;let i;try{i=await t.identity.currentToken({forceRefresh:!0})}catch(e){return t.identity.reportRejected?.(),err(pe(e,{wireCode:me(r.error.raw),requestId:r.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(fe(o.error))):o}function ge(e,t){return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}function fe(e){let t=e.raw,n=me(t);return makeEverfurError("authRejected",{retryable:false,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId?{requestId:e.requestId}:{},...n?{wireCode:n}:{},...e.reasonCode?{reasonCode:e.reasonCode}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},...t!=null?{raw:t}:{}})}function me(e){if(typeof e!="object"||e===null)return null;let t=e,n=(typeof t.error=="object"&&t.error!==null?t.error.code:void 0)??t.code;return typeof n=="string"&&n.length>0?n:null}function ye(e,t){let n=globalThis.URL;if(typeof n=="function"){let r;try{r=t===void 0?new n(e):new n(e,t)}catch{return null}try{if(r.protocol)return r}catch{}}return ke(e)}var be=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,we=/[\s\u0000-\u001f\u007f\\]/,xe={"http:":"80","https:":"443"};function ke(e,t){let n=e.trim();let r=we.test(n)?null:be.exec(n);if(r===null)return null;let[,i="",o="",l="",a="",s="",c="",d="",u=""]=r,p=`${i.toLowerCase()}:`,h=Number(s);if(h>65535)return null;let g=s===""||String(h)===xe[p]?"":String(h),f=xe[p]!==void 0,m=a.toLowerCase()+(g&&`:${g}`),y=c||(f?"/":""),b=o||l?`${o}${l&&`:${l}`}@`:"";return{href:`${p}//${b}${m}${y}${d}${u}`,protocol:p,username:o,password:l,hostname:a.toLowerCase(),port:g,origin:f?`${p}//${m}`:"null",pathname:y,search:d==="?"?"":d,hash:u==="#"?"":u}}function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:ve(e)})}function ve(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var Se=3e4,Te=Z*2,Ce="idempotency-key",je=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),Ie=/* @__PURE__ */Object.freeze({onEvent(){}}),He=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function Pe(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??Ie,n=e.timers??He,r=e.rng??Math.random,i=e.sleep??((e,t)=>Ue(e,n,t)),o=e.maxAttempts??ee,l=e.unaryTimeoutMs??Se,a=e.newIdempotencyKey??Re(),s=e=>{try{t.onEvent(e)}catch{}};async function c(t,c,d){let u=d?.maxAttempts,p=Math.max(1,u??o),h=d?.idempotent??je.has(c.method),g=d?.idempotencyKey===void 0?null:Pe(d.idempotencyKey),f=h?g??a():null,m=Fe(c,f),y=0;for(;;){let o=e=>/* @__PURE__ */Object.freeze({call:t,method:c.method,path:c.path,attempt:y,...f?{idempotencyKey:f}:{},...e});s(o({phase:"attempt"}));let a=Me(l,n),d=Ne(a.signal,c.signal),h;try{h=await authedSend({...m,signal:d.signal},e.auth)}catch(e){h=err(networkError(e))}finally{d.dispose(),a.cancel()}if(h.ok)return s(o({phase:"settled",ok:true,reason:"ok"})),h;let g=h.error,b=ze(g,y,{maxAttempts:p,rng:r,now:n.now(),aborted:c.signal?.aborted===true,...u!==void 0?{perCallMaxAttempts:u}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),w={ok:false,code:g.code,reason:b.reason,...g.httpStatus!==void 0?{httpStatus:g.httpStatus}:{},...g.requestId!==void 0?{requestId:g.requestId}:{}};if(!b.retry)return s(o({phase:"settled",...w})),err(g);if(s(o({phase:"retry",...w,delayMs:b.delayMs})),await i(b.delayMs,c.signal),c.signal?.aborted===true)return s(o({phase:"settled",...w,reason:"aborted"})),err(g);y+=1}}async function d(t){return withAuthHeaders(t,await Ve(e.auth))}async function*u(t,n,r){s(
|
|
6
6
|
/* @__PURE__ */Object.freeze({call:t,phase:"stream.open",method:n.method,path:n.path,attempt:0}));try{yield*e.auth.transport.stream(n,r)}catch{yield errorFrame({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}}/* @__PURE__ */
|
|
7
7
|
return Object.freeze({send:c,authorize:d,stream:u})}function Fe(e,t){let n={};for(let[t,r]of Object.entries(e.headers??{}))t.toLowerCase()!==Ce&&(n[t]=r);return t!==null&&(n["Idempotency-Key"]=t),{...e,headers:n}}function Re(){let e=0;return()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var De=10;function ze(e,t,n){if(n.aborted)return{retry:false,reason:"aborted"};let r=$e(e);if(r==="quota")return{retry:false,reason:"daily-quota-exhausted"};if(r!=="burst"&&!isAutoRetryable(e.code))return{retry:false,reason:"terminal-code"};let i=r==="burst"?"burst-throttle":"retryable-code";if((()=>{if(n.policy===void 0)return false;try{return!n.policy.shouldRetry(e.code,t)}catch{return false}})())return{retry:false,reason:"terminal-code"};let o=()=>{if(n.policy===void 0)return null;let t;try{t=n.policy.maxAttempts(e.code)}catch{return null}return typeof t!="number"||!Number.isFinite(t)?null:Math.max(1,Math.min(De,Math.floor(t)))},l=n.perCallMaxAttempts??o()??n.maxAttempts;if(t+1>=l)return{retry:false,reason:"attempts-exhausted"};let a=Oe(e,n.now);return a!==null?a>Te?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:i,delayMs:a}:{retry:true,reason:i,delayMs:backoffDelayMs(t,n.rng)}}function $e(e){let t=e.code==="unknown"?fromWire(Ae(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}function Oe(e,t){let n=_e(e.raw);if(n!==null){let e=n-t;return e>0?e:0}let r=Be(e.raw);return r===null?null:Math.round(r*1e3)}function Be(e){for(let t of Le(e)){let e=t.retry_after_seconds;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e}return null}function _e(e){for(let t of Le(e)){let e=t.resets_at,n=Ee(e);if(n!==null)return n}return null}function Le(e){if(!We(e))return[];let t=[e];for(let n of["error","detail"]){let r=e[n];We(r)&&t.push(r)}return t}function Ee(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 Ae(e){for(let t of Le(e)){let e=t.code;if(typeof e=="string"&&e.length>0)return e}return null}function We(e){return typeof e=="object"&&e!==null}async function Ve(e){if(e.mode==="anonymous"){let t=await ue(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 Me(e,t){let n=new AbortController,r=t.setTimeout(()=>n.abort(),e);return{signal:n.signal,cancel:()=>t.clearTimeout(r)}}function Ne(e,t){let n=()=>{};if(!t)return{signal:e,dispose:n};let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),{signal:r.signal,dispose:n};let i=()=>r.abort();return e.addEventListener("abort",i,{once:true}),t.addEventListener("abort",i,{once:true}),{signal:r.signal,dispose:()=>{e.removeEventListener("abort",i),t.removeEventListener("abort",i)}}}function Ue(e,t,n){return e<=0||n?.aborted===true?Promise.resolve():new Promise(r=>{let i=t.setTimeout(()=>{n?.removeEventListener("abort",o),r()},e),o=()=>{t.clearTimeout(i),r()};n?.addEventListener("abort",o,{once:true})})}function qe(e){return e!=null&&(e.httpStatus===404||e.category==="notFound")}function Ge(e){return e.code!=="conversationNotFound"?e:makeEverfurError("resourceNotFound",{retryable:false,...e.httpStatus===void 0?{}:{httpStatus:e.httpStatus},...e.requestId===void 0?{}:{requestId:e.requestId},...e.reasonCode===void 0?{}:{reasonCode:e.reasonCode},...e.wireMessage===void 0?{}:{wireMessage:e.wireMessage},...e.raw===void 0?{}:{raw:e.raw}})}function Ke(e){return e.ok?e:err(Ge(e.error))}function Xe(e){return{send:async(...t)=>Ke(await e.send(...t)),authorize:t=>e.authorize(t),stream:(t,n,r)=>e.stream(t,n,r)}}var Ye=/* @__PURE__ */Object.freeze(["dna","records","inside","profile"]),Je=128;function Qe(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function Ze(e){return makeEverfurError("runtimeDisposed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}function et(e){return makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:`${e}: the response carried no plan`})}var tt=(e,t=4e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null;function nt(e){let t=tt(e,2048);return t===null?null:/^https:\/\/[^\s]+$/i.test(t)?t:null}function rt(e){let t=typeof e=="number"?e:typeof e=="string"&&/^\d+(\.\d+)?$/.test(e.trim())?Number(e):Number.NaN;return Number.isFinite(t)&&t>=0?t:null}function it(e){return typeof e=="string"&&/^[A-Za-z]{3}$/.test(e)?e.toUpperCase():null}function ot(e){if(!Array.isArray(e))/* @__PURE__ */return Object.freeze([]);let t=[];for(let n of e){if(n===null||typeof n!="object")continue;let e=n,r=tt(e.text,1e3);if(r===null)continue;let i=typeof e.kind=="string"&&Ye.includes(e.kind)?e.kind:"profile";t.push(/* @__PURE__ */Object.freeze({kind:i,text:r}))}/* @__PURE__ */
|
|
@@ -8,10 +8,10 @@ import { P as PetRef } from '../ids.d-B2GAAifq.cjs';
|
|
|
8
8
|
export { B as Brand, C as ConversationId, R as RecordsRequestId, U as UserRef, _ as __brand } from '../ids.d-B2GAAifq.cjs';
|
|
9
9
|
import { H as HealthPlanItem } from '../healthPlanRepository.d-DBx7-NLE.cjs';
|
|
10
10
|
export { g as HEALTH_PLAN_REASON_KINDS, a as HealthPlan, d as HealthPlanItemDetail, h as HealthPlanItemDose, i as HealthPlanItemReview, j as HealthPlanReason, c as HealthPlanReasonKind, b as HealthPlanRepository, f as HealthPlanRepositoryDeps, e as HealthPlanRuntime, k as createHealthPlanRepository, l as createHealthPlanRepositoryOver, m as healthPlanFromWire } from '../healthPlanRepository.d-DBx7-NLE.cjs';
|
|
11
|
-
import { i as EverfurPresentationInput } from '../presentation.d-
|
|
12
|
-
export { E as EverfurChatAnswerStyle, a as EverfurChatComposerPlaceholder, b as EverfurChatComposerStyle, c as EverfurChatHistoryBarSetting, d as EverfurChatHistoryStyle, e as EverfurChatSendButtonSetting, f as EverfurChatTopCardSetting, g as EverfurHealthPlanLayout, h as EverfurPresentation, j as EverfurSafetyDisclaimerPlacement } from '../presentation.d-
|
|
13
|
-
import { H as HealthPlanBlanksFacts, a as HealthPlanEmptyCopy, o as HealthPlanTopCardOptions } from '../usePresentation.d-
|
|
14
|
-
export { d as HEALTH_PLAN_COPY, e as HEALTH_PLAN_COPY_PLACEHOLDERS, f as HEALTH_PLAN_REASON_LABELS, g as HEALTH_PLAN_TEMPLATES, h as HEALTH_PLAN_TOP_CARD_COPY, i as HealthPlanBlanksPhase, p as HealthPlanPossessivePet, c as HealthPlanTopCardCopy, j as HealthPlanTopCardFocus, k as HealthPlanTopCardPet, l as healthPlanBlanksFacts, m as healthPlanNextShotsAt, q as healthPlanPossessive, n as healthPlanRecordsWeightKg, r as healthPlanTopCard, u as useEverfurPresentation } from '../usePresentation.d-
|
|
11
|
+
import { i as EverfurPresentationInput } from '../presentation.d-BkIvMtIl.cjs';
|
|
12
|
+
export { E as EverfurChatAnswerStyle, a as EverfurChatComposerPlaceholder, b as EverfurChatComposerStyle, c as EverfurChatHistoryBarSetting, d as EverfurChatHistoryStyle, e as EverfurChatSendButtonSetting, f as EverfurChatTopCardSetting, g as EverfurHealthPlanLayout, h as EverfurPresentation, j as EverfurSafetyDisclaimerPlacement } from '../presentation.d-BkIvMtIl.cjs';
|
|
13
|
+
import { H as HealthPlanBlanksFacts, a as HealthPlanEmptyCopy, o as HealthPlanTopCardOptions } from '../usePresentation.d-DUYzYXgA.cjs';
|
|
14
|
+
export { d as HEALTH_PLAN_COPY, e as HEALTH_PLAN_COPY_PLACEHOLDERS, f as HEALTH_PLAN_REASON_LABELS, g as HEALTH_PLAN_TEMPLATES, h as HEALTH_PLAN_TOP_CARD_COPY, i as HealthPlanBlanksPhase, p as HealthPlanPossessivePet, c as HealthPlanTopCardCopy, j as HealthPlanTopCardFocus, k as HealthPlanTopCardPet, l as healthPlanBlanksFacts, m as healthPlanNextShotsAt, q as healthPlanPossessive, n as healthPlanRecordsWeightKg, r as healthPlanTopCard, u as useEverfurPresentation } from '../usePresentation.d-DUYzYXgA.cjs';
|
|
15
15
|
import { H as HealthPlanPriceFormat, a as HealthPlanLayoutProps, c as HealthPlanCardOptions, d as HealthPlanImageVariant, e as HealthPlanReasonVariant, b as HealthPlanCart$1 } from '../layout.d-CFF-nBXf.cjs';
|
|
16
16
|
export { E as EverfurHealthPlanOptions, f as EverfurHealthPlanState, g as EverfurHealthPlanStatus, h as HEALTH_PLAN_LAYOUT_DEFAULTS, i as HealthPlanAddButtonSize, j as HealthPlanAddedVariant, k as HealthPlanCardShadow, l as HealthPlanCartBarPlacement, m as HealthPlanCartBarVisibility, n as HealthPlanCategoryVariant, o as HealthPlanFontWeight, p as HealthPlanHeaderContext, q as HealthPlanPageContext, r as HealthPlanShadow, s as formatHealthPlanPrice, t as formatHealthPlanPriceWith, u as healthPlanCart, v as isHealthPlanSessionRequired, w as showHealthPlanCartBar, x as useEverfurHealthPlan, y as useEverfurHealthPlanRepository } from '../layout.d-CFF-nBXf.cjs';
|
|
17
17
|
import { L as LifecyclePort } from '../LifecyclePort.d-Cb9NtmP-.cjs';
|
|
@@ -8,10 +8,10 @@ import { P as PetRef } from '../ids.d-B2GAAifq.js';
|
|
|
8
8
|
export { B as Brand, C as ConversationId, R as RecordsRequestId, U as UserRef, _ as __brand } from '../ids.d-B2GAAifq.js';
|
|
9
9
|
import { H as HealthPlanItem } from '../healthPlanRepository.d-C7K9dJK5.js';
|
|
10
10
|
export { g as HEALTH_PLAN_REASON_KINDS, a as HealthPlan, d as HealthPlanItemDetail, h as HealthPlanItemDose, i as HealthPlanItemReview, j as HealthPlanReason, c as HealthPlanReasonKind, b as HealthPlanRepository, f as HealthPlanRepositoryDeps, e as HealthPlanRuntime, k as createHealthPlanRepository, l as createHealthPlanRepositoryOver, m as healthPlanFromWire } from '../healthPlanRepository.d-C7K9dJK5.js';
|
|
11
|
-
import { i as EverfurPresentationInput } from '../presentation.d-
|
|
12
|
-
export { E as EverfurChatAnswerStyle, a as EverfurChatComposerPlaceholder, b as EverfurChatComposerStyle, c as EverfurChatHistoryBarSetting, d as EverfurChatHistoryStyle, e as EverfurChatSendButtonSetting, f as EverfurChatTopCardSetting, g as EverfurHealthPlanLayout, h as EverfurPresentation, j as EverfurSafetyDisclaimerPlacement } from '../presentation.d-
|
|
13
|
-
import { H as HealthPlanBlanksFacts, a as HealthPlanEmptyCopy, o as HealthPlanTopCardOptions } from '../usePresentation.d-
|
|
14
|
-
export { d as HEALTH_PLAN_COPY, e as HEALTH_PLAN_COPY_PLACEHOLDERS, f as HEALTH_PLAN_REASON_LABELS, g as HEALTH_PLAN_TEMPLATES, h as HEALTH_PLAN_TOP_CARD_COPY, i as HealthPlanBlanksPhase, p as HealthPlanPossessivePet, c as HealthPlanTopCardCopy, j as HealthPlanTopCardFocus, k as HealthPlanTopCardPet, l as healthPlanBlanksFacts, m as healthPlanNextShotsAt, q as healthPlanPossessive, n as healthPlanRecordsWeightKg, r as healthPlanTopCard, u as useEverfurPresentation } from '../usePresentation.d-
|
|
11
|
+
import { i as EverfurPresentationInput } from '../presentation.d-BkIvMtIl.js';
|
|
12
|
+
export { E as EverfurChatAnswerStyle, a as EverfurChatComposerPlaceholder, b as EverfurChatComposerStyle, c as EverfurChatHistoryBarSetting, d as EverfurChatHistoryStyle, e as EverfurChatSendButtonSetting, f as EverfurChatTopCardSetting, g as EverfurHealthPlanLayout, h as EverfurPresentation, j as EverfurSafetyDisclaimerPlacement } from '../presentation.d-BkIvMtIl.js';
|
|
13
|
+
import { H as HealthPlanBlanksFacts, a as HealthPlanEmptyCopy, o as HealthPlanTopCardOptions } from '../usePresentation.d-Buxz2Jkt.js';
|
|
14
|
+
export { d as HEALTH_PLAN_COPY, e as HEALTH_PLAN_COPY_PLACEHOLDERS, f as HEALTH_PLAN_REASON_LABELS, g as HEALTH_PLAN_TEMPLATES, h as HEALTH_PLAN_TOP_CARD_COPY, i as HealthPlanBlanksPhase, p as HealthPlanPossessivePet, c as HealthPlanTopCardCopy, j as HealthPlanTopCardFocus, k as HealthPlanTopCardPet, l as healthPlanBlanksFacts, m as healthPlanNextShotsAt, q as healthPlanPossessive, n as healthPlanRecordsWeightKg, r as healthPlanTopCard, u as useEverfurPresentation } from '../usePresentation.d-Buxz2Jkt.js';
|
|
15
15
|
import { H as HealthPlanPriceFormat, a as HealthPlanLayoutProps, c as HealthPlanCardOptions, d as HealthPlanImageVariant, e as HealthPlanReasonVariant, b as HealthPlanCart$1 } from '../layout.d-Bm2_1wa4.js';
|
|
16
16
|
export { E as EverfurHealthPlanOptions, f as EverfurHealthPlanState, g as EverfurHealthPlanStatus, h as HEALTH_PLAN_LAYOUT_DEFAULTS, i as HealthPlanAddButtonSize, j as HealthPlanAddedVariant, k as HealthPlanCardShadow, l as HealthPlanCartBarPlacement, m as HealthPlanCartBarVisibility, n as HealthPlanCategoryVariant, o as HealthPlanFontWeight, p as HealthPlanHeaderContext, q as HealthPlanPageContext, r as HealthPlanShadow, s as formatHealthPlanPrice, t as formatHealthPlanPriceWith, u as healthPlanCart, v as isHealthPlanSessionRequired, w as showHealthPlanCartBar, x as useEverfurHealthPlan, y as useEverfurHealthPlanRepository } from '../layout.d-Bm2_1wa4.js';
|
|
17
17
|
import { L as LifecyclePort } from '../LifecyclePort.d-Cb9NtmP-.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! @everfur/sdk. Copyright (c) 2026 Strand Health Inc. dba Everfur. All rights reserved. Use is subject to the Everfur SDK License: https://docs.everfur.com/license */
|
|
2
2
|
import{createContext,forwardRef as e,createElement as t,useState as n,useMemo as r,useContext as i,useEffect as o,useSyncExternalStore as l,useCallback as a,useRef as s,Fragment as c,useLayoutEffect as d,Component as u}from"react";import{TextInput as p,StyleSheet as h,View as g,Pressable as f,Animated as m,Easing as y,useWindowDimensions as b,ScrollView as k,Modal as w,KeyboardAvoidingView as v,Platform as x,Image as S,Text as T,Linking as C,AppState as I,AccessibilityInfo as H}from"react-native";import{jsxs as F,jsx as R,Fragment as P}from"react/jsx-runtime";import{useSafeAreaInsets as z}from"react-native-safe-area-context";import{useEverfurRecords}from"@everfur/sdk/records";var D=/* @__PURE__ */Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function face(e,t){let n=e.type,r=n.families[t];return t==="mono"||n.namedFaces[t]?{fontFamily:r}:{fontFamily:r,fontWeight:n.weight[D[t]]}}function headingFace(e,t="bold"){let{headingFamily:n,headingWeight:r}=e.type;if(n===null&&r===null)return face(e,t);if(n!==null)return{fontFamily:n,fontWeight:r??e.type.weight[D[t]]};let i=face(e,t);return i.fontWeight===void 0||r===null?i:{fontFamily:i.fontFamily,fontWeight:r}}function $(e){return e<=450?"regular":e<=650?"medium":"bold"}var O={regular:"mono",medium:"monoMedium",bold:"monoBold"};function textRole(e,t){let n=B.get(e);n===void 0&&(n=/* @__PURE__ */new Map,B.set(e,n));let r=n.get(t);if(r!==void 0)return r;let i=_(e,t);return n.set(t,i),i}var B=/* @__PURE__ */new WeakMap;function _(e,t){let n=e.type.roles[t],r=n.weight==="400"&&n.face!=="mono"?e.type.weight.regular:n.weight,i=$(Number(r)),o=n.face==="mono"?face(e,O[i]):n.face==="heading"?headingFace(e,i):face(e,i),l=n.face==="heading"?e.type.headingWeight??r:r,a=o.fontWeight===void 0?o:{fontFamily:o.fontFamily,fontWeight:l},s=n.size,c={...a,fontSize:s,lineHeight:Math.round(s*n.lineHeight*100)/100};return n.letterSpacing!==0&&(c.letterSpacing=Math.round(s*n.letterSpacing*100)/100),n.uppercase&&(c.textTransform="uppercase"),/* @__PURE__ */Object.freeze(c)}var L=/* @__PURE__ */Object.freeze({loading:"Loading",retry:"Try again",signedOut:"Sign in required",addToCart:"Add to cart",added:"Added",remove:"Remove",checkout:"Checkout",subtotal:"Subtotal",sample:"Sample",cartEmpty:"Your cart is empty.",choosePet:"Choose a pet",emptyTitle:"",emptyBody:"",emptyAsk:""}),E=/* @__PURE__ */Object.freeze({emptyTitle:true,emptyBody:true,emptyAsk:true}),A=/* @__PURE__ */Object.freeze({dna:"",records:"Records",inside:"Inside",profile:""}),j=/* @__PURE__ */Object.freeze({planTitle:e=>`${e}'s care plan`,cartLabel:e=>`${e} cart`}),W=/* @__PURE__ */Object.freeze([...Object.keys(L).filter(e=>E[e]===true&&L[e]==="").map(e=>`HEALTH_PLAN_COPY.${e}`),...["profile"].filter(e=>A[e]==="").map(e=>`HEALTH_PLAN_REASON_LABELS.${e}`)]);var M=/* @__PURE__ */Object.freeze({imageVariant:"wide",reasonVariant:"pills",cartBarVisibility:"whenItems",cartBarPlacement:"sticky",addButtonSize:"full",addedVariant:"link",categoryVariant:"text",showCategory:false,cardShadow:false,cardBorder:true});function N(e,t){return{setInPlan:t,addAll:async()=>{let n=(e?.items??[]).filter(e=>!e.inPlan);return(await Promise.all(n.map(e=>t(e.productId,true)))).every(Boolean)}}}function showHealthPlanCartBar(e,t){return(e??M.cartBarVisibility)==="always"||t>0}var U=/* @__PURE__ */Object.freeze(["showCategory","cardShadow","cardBorder","addButtonSize","addButtonFontSize","addedVariant","categoryVariant","cardPadding","itemTitleSize","itemTitleWeight","priceSize","priceWeight","reasonTextSize","reasonLabelWidth","reasonGap"]);function q(e){let t={};for(let n of U)e[n]!==void 0&&(t[n]=e[n]);return t}function V(e){let t=typeof e=="number"&&Number.isFinite(e)&&e>0?e:e==="compact"?32:44;return{height:t,hit:Math.max(44,t)}}function G(e){if(e.length>200||e.includes(",")&&!/rgba?\(|hsla?\(/i.test(e))return null;let t=/(rgba?\([^)]*\)|hsla?\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)\s*$/i.exec(e.trim())?.[1]??null;if(t===null)return null;let n=e.trim().slice(0,e.trim().length-t.length).trim().split(/\s+/).filter(Boolean);if(n.length<2||n.length>4)return null;let r=n.map(e=>e==="0"?0:/^-?\d*\.?\d+px$/.test(e)?Number(e.slice(0,-2)):Number.NaN);return r.some(e=>!Number.isFinite(e))?null:{color:t,offsetX:r[0]??0,offsetY:r[1]??0,blur:Math.max(0,r[2]??0)}}function K(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:null}function X(e,t){let n=K(e);return n===null?0:n-t}function isHealthPlanSessionRequired(e){return e!==null&&(e.reasonCode==="session_required"||e.code==="sessionRequired")}var Y=/* @__PURE__ */Symbol.for("@everfur/sdk#HealthPlanCartDock@v1"),J=globalThis,Q=J[Y]??(J[Y]=createContext(null));function HealthPlanCartScope({children:e}){let[i,o]=n(null),l=r(()=>({dock:i,publish:o}),[i]);return t(Q.Provider,{value:l},e)}function useHealthPlanCartDock(){return i(Q)?.dock??null}function Z(e,t,n,petRef,l,a){let c=i(Q)?.publish,d=s(a);o(()=>{d.current=a},[a]);let u=r(()=>N(l,(e,t)=>d.current(e,t)),[l]);o(()=>{if(!(c===void 0||!e))return c(/* @__PURE__ */Object.freeze({cart:t,busy:n,petRef:petRef,plan:l,...u})),()=>c(null)},[c,e,t,n,petRef,l,u])}var ee=/* @__PURE__ */Object.freeze({track(){},trackExpectedFailure(){}});function ok(e,t){/* @__PURE__ */
|
|
3
3
|
return Object.freeze({ok:true,value:e})}function err(e){/* @__PURE__ */
|
|
4
|
-
return Object.freeze({ok:false,error:e})}var te=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var ne=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),re=globalThis,ie=re[ne]??(re[ne]=createContext(null));ie.displayName??="EverfurContext";function oe(){let e=i(ie);if(e===null)throw new te("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}var le=/* @__PURE__ */Object.freeze({opened:"health_plan.opened",productClicked:"health_plan.product_clicked",checkoutStarted:"health_plan.checkout_started"});function ae(){return i(ie)?.runtime.registry.services.telemetry??ee}var se=createContext(null);function HealthPlanPetScope({petRef:petRef,children:e}){return t(se.Provider,{value:petRef},e)}function ce(e){let t=i(se),n=i(ie);return t??e??n?.activePet??null}function de(e,petRef,t){let n=ae(),r=s(null);o(()=>{if(!e||petRef===null||r.current===petRef)return;r.current=petRef;let i=t?.items??[];n.track(le.opened,{petRef:petRef,itemsCount:i.length,inPlanCount:i.filter(e=>e.inPlan).length})},[e,petRef,t,n])}function ue(e,petRef,t,n){e.track(le.productClicked,{petRef:petRef,productId:t,inPlan:n})}function pe(e,petRef,t){e.track(le.checkoutStarted,{petRef:petRef,itemsCount:t.count,subtotal:t.subtotal,currency:t.currency})}function he(e){return e!=null&&(e.wait!==void 0||e.pick.hidden===true)}function ge(e){return{...e,pick:{...e.pick,none:true,hidden:true}}}var fe=/* @__PURE__ */Object.freeze({productId:"",partnerSku:null,title:"",description:null,category:null,price:null,currency:null,imageUrl:null,url:null,reasons:[],inPlan:false,sample:false});var me=[{wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"DAILY_QUOTA_EXCEEDED",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"FILE_TOO_LARGE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"IDEMPOTENCY_KEY_IN_FLIGHT",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"INVALID_CONTENT_TYPE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"InternalFailureException",envelope:"http_envelope",httpStatus:500,retryable:true},{wireCode:"MethodNotAllowedException",envelope:"http_envelope",httpStatus:405,retryable:false},{wireCode:"NotImplementedException",envelope:"http_envelope",httpStatus:501,retryable:false},{wireCode:"PaymentRequiredException",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ResourceNotFoundException",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"ServiceUnavailableException",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"TIER_UPGRADE_REQUIRED",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ThrottlingException",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"ValidationException",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"accessDenied",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"access_denied",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"anchor_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"anchor_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"anonTokenInvalid",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"attachment_unreadable",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"authExpired",envelope:"http_envelope",httpStatus:401,retryable:true},{wireCode:"authRejected",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"before_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_not_uploaded",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundles_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"catalog_empty_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"catalog_shrink_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"consent_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_required",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_scope_wrong_route",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"device_cipher_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"email_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"endpoint_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"environment_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_cursor_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_payload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_not_available",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_unknown",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_required",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_reused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"inbox_cursor_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"insufficientCapability",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"insufficient_scope",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"internal_error",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"invalidRequest",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"invalid_client",envelope:"oauth_error",httpStatus:401,retryable:false},{wireCode:"invalid_client_metadata",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_grant",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_redirect_uri",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_request",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_scope",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_target",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"item_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"linked_account_read_only",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_connection_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"mcp_request_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_request_gone",envelope:"http_envelope",httpStatus:410,retryable:false},{wireCode:"mcp_request_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"not_found",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"open_url_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"partner_visit_link_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"partner_visit_owner_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"partner_visit_pet_already_mapped",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"payload_too_large",envelope:"http_envelope",httpStatus:413,retryable:false},{wireCode:"petRefInUse",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"pet_health_list_removals_unconfirmed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_health_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_not_registered",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"provider_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"rateLimited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"read_target_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_subject_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"record_upload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"records_consent_required",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"restricted_key",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"sandbox_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_required",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_revoked",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"share_limit_reached",envelope:"http_envelope",httpStatus:429,retryable:false},{wireCode:"slow_down",envelope:"oauth_error",httpStatus:429,retryable:true},{wireCode:"species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"subscription_keys_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"tenant_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"tenant_has_no_capabilities",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tenant_resource_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"tenant_surface_not_enabled",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"ticket_not_resolved",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tickets_disabled",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"timeout",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"token_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"unavailable",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"unrestrictedKeyRequired",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"unsupported_grant_type",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"unsupported_response_type",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"user_ref_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"verify_mint_rate_limited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"verify_mint_refused",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"verify_mint_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"verify_user_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"web_push_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"webhook_endpoint_update_empty",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false}],ye=/* @__PURE__ */Object.freeze(me.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(ye.map(e=>e.wireCode));var be=/* @__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"}),ke=/* @__PURE__ */Object.freeze(ye.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:be[e.wireCode]}))),we=new Map(ke.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),ve=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(ke.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(e,t){if(typeof e!="string")return;let n=e.trim().toUpperCase();if(n.length!==0)for(let e of[t??"http_envelope",...ve]){let t=we.get(e+n);if(t)return t}}var xe=/* @__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 xe[e]}function fromWire(e){let t=contractErrorFor(e);if(t)return t.normalized;let n=(e??"").trim().toUpperCase(),r=n.replace(/[^A-Z0-9]/g,"");if(r==="AUTHREJECTED")return"authRejected";if(n.startsWith("AUTH"))return"authExpired";switch(r){case"DAILYQUOTAEXCEEDED":case"QUOTAEXCEEDED":return"quotaExceeded";case"RATELIMITED":case"TOOMANYREQUESTS":case"TELEVETRATELIMITED":return"rateLimited";case"IDEMPOTENCYKEYCONFLICT":case"IDEMPOTENCYCONFLICT":return"idempotencyConflict";case"ACCESSDENIED":case"FORBIDDEN":return"accessDenied";case"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";case"RUNTIMEDISPOSED":return"runtimeDisposed";case"NOTFOUND":case"CONVERSATIONNOTFOUND":return"conversationNotFound";case"PETNOTFOUND":return"petNotFound";case"TIMEOUT":case"STREAMTIMEOUT":return"streamTimeout";case"MEDIAUPLOADFAILED":case"UNRECOGNIZEDVIDEOFORMAT":case"FILETOOSMALL":return"mediaUploadFailed";case"MODERATIONBLOCKED":return"moderationBlocked";case"UPSTREAMLLMTIMEOUT":return"upstreamLlmTimeout";case"INTERNALERROR":case"INTERNALSERVERERROR":return"internalError";case"STREAMINCOMPLETE":case"CHATSTREAMINCOMPLETE":return"streamIncomplete";case"INVALIDANALYSISTYPE":case"INVALIDUPLOADPURPOSE":return"unknown";default:return"unknown"}}var Se=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return Se.has(e)}var Te=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||Te.has(e)}var Ce=500,Ie=8e3,He=4;function backoffDelayMs(e,t=Math.random){let n=Math.max(0,e),r=Math.min(Ce*2**n,Ie);return Math.floor(t()*r)}var Fe="This feature isn't available on your account right now.",Re="Something in that request was not right. Check the details and try again.",Pe=/* @__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:Fe,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:Re,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:Fe,runtimeDisposed:Re,unknown:"Something went wrong. Please try again."}),ze="This session has ended. Please sign in again.",De="linked_account_read_only";function $e(e,t,n){return e==="conflict"&&n===De?Fe:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?ze:userFacingError(e)}function userFacingError(e){return Pe[e]}function Oe(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:false,writable:false,configurable:false})}var Be=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let n=contractErrorFor(t?.wireCode,t?.wireEnvelope),r=e==="conflict"&&t?.reasonCode===De,i={code:e,category:categoryFor(e),retryable:t?.retryable??(r?false:isRetryableCode(e)),displayMessage:$e(e,t?.wireCode,r?De:null)};t?.httpStatus!==void 0&&(i.httpStatus=t.httpStatus),t?.requestId&&(i.requestId=t.requestId),typeof t?.reasonCode=="string"&&Be.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)),n);return t?.wireMessage&&Oe(i,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&Oe(i,"raw",t.raw),/* @__PURE__ */Object.freeze(i)}function assertNever(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}function errorFrame(e){/* @__PURE__ */
|
|
4
|
+
return Object.freeze({ok:false,error:e})}var te=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var ne=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),re=globalThis,ie=re[ne]??(re[ne]=createContext(null));ie.displayName??="EverfurContext";function oe(){let e=i(ie);if(e===null)throw new te("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}var le=/* @__PURE__ */Object.freeze({opened:"health_plan.opened",productClicked:"health_plan.product_clicked",checkoutStarted:"health_plan.checkout_started"});function ae(){return i(ie)?.runtime.registry.services.telemetry??ee}var se=createContext(null);function HealthPlanPetScope({petRef:petRef,children:e}){return t(se.Provider,{value:petRef},e)}function ce(e){let t=i(se),n=i(ie);return t??e??n?.activePet??null}function de(e,petRef,t){let n=ae(),r=s(null);o(()=>{if(!e||petRef===null||r.current===petRef)return;r.current=petRef;let i=t?.items??[];n.track(le.opened,{petRef:petRef,itemsCount:i.length,inPlanCount:i.filter(e=>e.inPlan).length})},[e,petRef,t,n])}function ue(e,petRef,t,n){e.track(le.productClicked,{petRef:petRef,productId:t,inPlan:n})}function pe(e,petRef,t){e.track(le.checkoutStarted,{petRef:petRef,itemsCount:t.count,subtotal:t.subtotal,currency:t.currency})}function he(e){return e!=null&&(e.wait!==void 0||e.pick.hidden===true)}function ge(e){return{...e,pick:{...e.pick,none:true,hidden:true}}}var fe=/* @__PURE__ */Object.freeze({productId:"",partnerSku:null,title:"",description:null,category:null,price:null,currency:null,imageUrl:null,url:null,reasons:[],inPlan:false,sample:false});var me=[{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}],ye=/* @__PURE__ */Object.freeze(me.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(ye.map(e=>e.wireCode));var be=/* @__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"}),ke=/* @__PURE__ */Object.freeze(ye.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:be[e.wireCode]}))),we=new Map(ke.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),ve=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(ke.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(e,t){if(typeof e!="string")return;let n=e.trim().toUpperCase();if(n.length!==0)for(let e of[t??"http_envelope",...ve]){let t=we.get(e+n);if(t)return t}}var xe=/* @__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 xe[e]}function fromWire(e){let t=contractErrorFor(e);if(t)return t.normalized;let n=(e??"").trim().toUpperCase(),r=n.replace(/[^A-Z0-9]/g,"");if(r==="AUTHREJECTED")return"authRejected";if(n.startsWith("AUTH"))return"authExpired";switch(r){case"DAILYQUOTAEXCEEDED":case"QUOTAEXCEEDED":return"quotaExceeded";case"RATELIMITED":case"TOOMANYREQUESTS":case"TELEVETRATELIMITED":return"rateLimited";case"IDEMPOTENCYKEYCONFLICT":case"IDEMPOTENCYCONFLICT":return"idempotencyConflict";case"ACCESSDENIED":case"FORBIDDEN":return"accessDenied";case"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";case"RUNTIMEDISPOSED":return"runtimeDisposed";case"NOTFOUND":case"CONVERSATIONNOTFOUND":return"conversationNotFound";case"PETNOTFOUND":return"petNotFound";case"TIMEOUT":case"STREAMTIMEOUT":return"streamTimeout";case"MEDIAUPLOADFAILED":case"UNRECOGNIZEDVIDEOFORMAT":case"FILETOOSMALL":return"mediaUploadFailed";case"MODERATIONBLOCKED":return"moderationBlocked";case"UPSTREAMLLMTIMEOUT":return"upstreamLlmTimeout";case"INTERNALERROR":case"INTERNALSERVERERROR":return"internalError";case"STREAMINCOMPLETE":case"CHATSTREAMINCOMPLETE":return"streamIncomplete";case"INVALIDANALYSISTYPE":case"INVALIDUPLOADPURPOSE":return"unknown";default:return"unknown"}}var Se=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return Se.has(e)}var Te=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||Te.has(e)}var Ce=500,Ie=8e3,He=4;function backoffDelayMs(e,t=Math.random){let n=Math.max(0,e),r=Math.min(Ce*2**n,Ie);return Math.floor(t()*r)}var Fe="This feature isn't available on your account right now.",Re="Something in that request was not right. Check the details and try again.",Pe=/* @__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:Fe,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:Re,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:Fe,runtimeDisposed:Re,unknown:"Something went wrong. Please try again."}),ze="This session has ended. Please sign in again.",De="linked_account_read_only";function $e(e,t,n){return e==="conflict"&&n===De?Fe:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?ze:userFacingError(e)}function userFacingError(e){return Pe[e]}function Oe(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:false,writable:false,configurable:false})}var Be=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let n=contractErrorFor(t?.wireCode,t?.wireEnvelope),r=e==="conflict"&&t?.reasonCode===De,i={code:e,category:categoryFor(e),retryable:t?.retryable??(r?false:isRetryableCode(e)),displayMessage:$e(e,t?.wireCode,r?De:null)};t?.httpStatus!==void 0&&(i.httpStatus=t.httpStatus),t?.requestId&&(i.requestId=t.requestId),typeof t?.reasonCode=="string"&&Be.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)),n);return t?.wireMessage&&Oe(i,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&Oe(i,"raw",t.raw),/* @__PURE__ */Object.freeze(i)}function assertNever(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}function errorFrame(e){/* @__PURE__ */
|
|
5
5
|
return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryable,wireMessage:e.wireMessage,synthesized:e.synthesized,lastEventId:e.lastEventId,serverRequestId:null,...e.freeCap?{freeCap:/* @__PURE__ */Object.freeze({...e.freeCap})}:{}})}var _e="x-everfur-anon-token",Le="anonTokenInvalid";async function Ee(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}function Ae(e,t){let n=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}:{},...n?{wireMessage:n}:{},...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]=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:{...je(e.headers),...authHeaders(t)}}}function je(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e)){let e=n.toLowerCase();e==="authorization"||e==="x-everfur-partner-key"||e===_e||(t[n]=r)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let n=await Ee(t),r=await t.transport.request(withAuthHeaders(e,We(t,n)));if(r.ok||Ne(r.error.raw)!==Le||t.anonIdentity===void 0||t.userRef!==null)return r;let i=await t.anonIdentity.token({forceRefresh:true});return i===null||i===n?r:t.transport.request(withAuthHeaders(e,We(t,i)))}let n;try{n=await t.identity.currentToken()}catch(e){return t.identity.reportRejected?.(),err(Ae(e))}let r=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:n,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(r.ok||r.error.httpStatus!==401)return r;let i;try{i=await t.identity.currentToken({forceRefresh:!0})}catch(e){return t.identity.reportRejected?.(),err(Ae(e,{wireCode:Ne(r.error.raw),requestId:r.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(Me(o.error))):o}function We(e,t){return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}function Me(e){let t=e.raw,n=Ne(t);return makeEverfurError("authRejected",{retryable:false,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId?{requestId:e.requestId}:{},...n?{wireCode:n}:{},...e.reasonCode?{reasonCode:e.reasonCode}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},...t!=null?{raw:t}:{}})}function Ne(e){if(typeof e!="object"||e===null)return null;let t=e,n=(typeof t.error=="object"&&t.error!==null?t.error.code:void 0)??t.code;return typeof n=="string"&&n.length>0?n:null}function Ue(e,t){let n=globalThis.URL;if(typeof n=="function"){let r;try{r=t===void 0?new n(e):new n(e,t)}catch{return null}try{if(r.protocol)return r}catch{}}return Ke(e)}var qe=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,Ve=/[\s\u0000-\u001f\u007f\\]/,Ge={"http:":"80","https:":"443"};function Ke(e,t){let n=e.trim();let r=Ve.test(n)?null:qe.exec(n);if(r===null)return null;let[,i="",o="",l="",a="",s="",c="",d="",u=""]=r,p=`${i.toLowerCase()}:`,h=Number(s);if(h>65535)return null;let g=s===""||String(h)===Ge[p]?"":String(h),f=Ge[p]!==void 0,m=a.toLowerCase()+(g&&`:${g}`),y=c||(f?"/":""),b=o||l?`${o}${l&&`:${l}`}@`:"";return{href:`${p}//${b}${m}${y}${d}${u}`,protocol:p,username:o,password:l,hostname:a.toLowerCase(),port:g,origin:f?`${p}//${m}`:"null",pathname:y,search:d==="?"?"":d,hash:u==="#"?"":u}}function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:Xe(e)})}function Xe(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var Ye=3e4,Je=Ie*2,Qe="idempotency-key",Ze=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),et=/* @__PURE__ */Object.freeze({onEvent(){}}),tt=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function nt(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??et,n=e.timers??tt,r=e.rng??Math.random,i=e.sleep??((e,t)=>bt(e,n,t)),o=e.maxAttempts??He,l=e.unaryTimeoutMs??Ye,a=e.newIdempotencyKey??it(),s=e=>{try{t.onEvent(e)}catch{}};async function c(t,c,d){let u=d?.maxAttempts,p=Math.max(1,u??o),h=d?.idempotent??Ze.has(c.method),g=d?.idempotencyKey===void 0?null:nt(d.idempotencyKey),f=h?g??a():null,m=rt(c,f),y=0;for(;;){let o=e=>/* @__PURE__ */Object.freeze({call:t,method:c.method,path:c.path,attempt:y,...f?{idempotencyKey:f}:{},...e});s(o({phase:"attempt"}));let a=mt(l,n),d=yt(a.signal,c.signal),h;try{h=await authedSend({...m,signal:d.signal},e.auth)}catch(e){h=err(networkError(e))}finally{d.dispose(),a.cancel()}if(h.ok)return s(o({phase:"settled",ok:true,reason:"ok"})),h;let g=h.error,b=lt(g,y,{maxAttempts:p,rng:r,now:n.now(),aborted:c.signal?.aborted===true,...u!==void 0?{perCallMaxAttempts:u}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),k={ok:false,code:g.code,reason:b.reason,...g.httpStatus!==void 0?{httpStatus:g.httpStatus}:{},...g.requestId!==void 0?{requestId:g.requestId}:{}};if(!b.retry)return s(o({phase:"settled",...k})),err(g);if(s(o({phase:"retry",...k,delayMs:b.delayMs})),await i(b.delayMs,c.signal),c.signal?.aborted===true)return s(o({phase:"settled",...k,reason:"aborted"})),err(g);y+=1}}async function d(t){return withAuthHeaders(t,await ft(e.auth))}async function*u(t,n,r){s(
|
|
6
6
|
/* @__PURE__ */Object.freeze({call:t,phase:"stream.open",method:n.method,path:n.path,attempt:0}));try{yield*e.auth.transport.stream(n,r)}catch{yield errorFrame({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}}/* @__PURE__ */
|
|
7
7
|
return Object.freeze({send:c,authorize:d,stream:u})}function rt(e,t){let n={};for(let[t,r]of Object.entries(e.headers??{}))t.toLowerCase()!==Qe&&(n[t]=r);return t!==null&&(n["Idempotency-Key"]=t),{...e,headers:n}}function it(){let e=0;return()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var ot=10;function lt(e,t,n){if(n.aborted)return{retry:false,reason:"aborted"};let r=at(e);if(r==="quota")return{retry:false,reason:"daily-quota-exhausted"};if(r!=="burst"&&!isAutoRetryable(e.code))return{retry:false,reason:"terminal-code"};let i=r==="burst"?"burst-throttle":"retryable-code";if((()=>{if(n.policy===void 0)return false;try{return!n.policy.shouldRetry(e.code,t)}catch{return false}})())return{retry:false,reason:"terminal-code"};let o=()=>{if(n.policy===void 0)return null;let t;try{t=n.policy.maxAttempts(e.code)}catch{return null}return typeof t!="number"||!Number.isFinite(t)?null:Math.max(1,Math.min(ot,Math.floor(t)))},l=n.perCallMaxAttempts??o()??n.maxAttempts;if(t+1>=l)return{retry:false,reason:"attempts-exhausted"};let a=st(e,n.now);return a!==null?a>Je?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:i,delayMs:a}:{retry:true,reason:i,delayMs:backoffDelayMs(t,n.rng)}}function at(e){let t=e.code==="unknown"?fromWire(ht(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}function st(e,t){let n=dt(e.raw);if(n!==null){let e=n-t;return e>0?e:0}let r=ct(e.raw);return r===null?null:Math.round(r*1e3)}function ct(e){for(let t of ut(e)){let e=t.retry_after_seconds;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e}return null}function dt(e){for(let t of ut(e)){let e=t.resets_at,n=pt(e);if(n!==null)return n}return null}function ut(e){if(!gt(e))return[];let t=[e];for(let n of["error","detail"]){let r=e[n];gt(r)&&t.push(r)}return t}function pt(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 ht(e){for(let t of ut(e)){let e=t.code;if(typeof e=="string"&&e.length>0)return e}return null}function gt(e){return typeof e=="object"&&e!==null}async function ft(e){if(e.mode==="anonymous"){let t=await Ee(e);return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}return{mode:"personalized",token:await e.identity.currentToken(),userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{}}}function mt(e,t){let n=new AbortController,r=t.setTimeout(()=>n.abort(),e);return{signal:n.signal,cancel:()=>t.clearTimeout(r)}}function yt(e,t){let n=()=>{};if(!t)return{signal:e,dispose:n};let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),{signal:r.signal,dispose:n};let i=()=>r.abort();return e.addEventListener("abort",i,{once:true}),t.addEventListener("abort",i,{once:true}),{signal:r.signal,dispose:()=>{e.removeEventListener("abort",i),t.removeEventListener("abort",i)}}}function bt(e,t,n){return e<=0||n?.aborted===true?Promise.resolve():new Promise(r=>{let i=t.setTimeout(()=>{n?.removeEventListener("abort",o),r()},e),o=()=>{t.clearTimeout(i),r()};n?.addEventListener("abort",o,{once:true})})}function kt(e){return e!=null&&(e.httpStatus===404||e.category==="notFound")}function wt(e){return e.code!=="conversationNotFound"?e:makeEverfurError("resourceNotFound",{retryable:false,...e.httpStatus===void 0?{}:{httpStatus:e.httpStatus},...e.requestId===void 0?{}:{requestId:e.requestId},...e.reasonCode===void 0?{}:{reasonCode:e.reasonCode},...e.wireMessage===void 0?{}:{wireMessage:e.wireMessage},...e.raw===void 0?{}:{raw:e.raw}})}function vt(e){return e.ok?e:err(wt(e.error))}function xt(e){return{send:async(...t)=>vt(await e.send(...t)),authorize:t=>e.authorize(t),stream:(t,n,r)=>e.stream(t,n,r)}}var St=/* @__PURE__ */Object.freeze(["dna","records","inside","profile"]),Tt=128;function Ct(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function It(e){return makeEverfurError("runtimeDisposed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}function Ht(e){return makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:`${e}: the response carried no plan`})}var Ft=(e,t=4e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null;function Rt(e){let t=Ft(e,2048);return t===null?null:/^https:\/\/[^\s]+$/i.test(t)?t:null}function Pt(e){let t=typeof e=="number"?e:typeof e=="string"&&/^\d+(\.\d+)?$/.test(e.trim())?Number(e):Number.NaN;return Number.isFinite(t)&&t>=0?t:null}function zt(e){return typeof e=="string"&&/^[A-Za-z]{3}$/.test(e)?e.toUpperCase():null}function Dt(e){if(!Array.isArray(e))/* @__PURE__ */return Object.freeze([]);let t=[];for(let n of e){if(n===null||typeof n!="object")continue;let e=n,r=Ft(e.text,1e3);if(r===null)continue;let i=typeof e.kind=="string"&&St.includes(e.kind)?e.kind:"profile";t.push(/* @__PURE__ */Object.freeze({kind:i,text:r}))}/* @__PURE__ */
|