@everfur/sdk 0.18.3 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +141 -0
- package/dist/{Chat.d-CKKuXVw5.d.ts → Chat.d-D61LLPJh.d.ts} +1 -1
- package/dist/{Chat.d-BEbRI8FZ.d.cts → Chat.d-IpxKa9gS.d.cts} +1 -1
- package/dist/{DepthViews.d-CiU4f98J.d.ts → DepthViews.d-C8EsR8Gq.d.ts} +1 -1
- package/dist/{DepthViews.d-BiePRa3Z.d.cts → DepthViews.d-CDIL4mPa.d.cts} +1 -1
- package/dist/{DepthViews.d-Chn2xwZu.d.cts → DepthViews.d-Q1nqdH8n.d.cts} +1 -1
- package/dist/{DepthViews.d-_WMIpymE.d.ts → DepthViews.d-w2o4Nf7r.d.ts} +1 -1
- package/dist/{RecordsPage.d-CtNzoxre.d.cts → RecordsPage.d-BSjZOHu8.d.cts} +11 -5
- package/dist/{RecordsPage.d-CRRJM35Q.d.ts → RecordsPage.d-DqhM_rCr.d.ts} +11 -5
- package/dist/animations/index.cjs +1 -94
- package/dist/animations/index.d.cts +3 -3
- package/dist/animations/index.d.ts +3 -3
- package/dist/animations/index.js +1 -94
- package/dist/{attachments.d-BLEOCUU7.d.cts → attachments.d-BviU_Tja.d.cts} +2 -2
- package/dist/{attachments.d-DRkqNR-o.d.ts → attachments.d-DZVfHHnY.d.ts} +2 -2
- package/dist/{bookingCopy.d-CrUufdoE.d.ts → bookingCopy.d-5V3erfXD.d.ts} +2 -2
- package/dist/{bookingCopy.d-CoiNXrY8.d.cts → bookingCopy.d-DlzUPsFE.d.cts} +2 -2
- package/dist/{casesRepository.d-OyZOSNNv.d.cts → casesRepository.d-7Us2O-z8.d.cts} +1 -1
- package/dist/{casesRepository.d-DhI69yuj.d.ts → casesRepository.d-Dqg-KbpA.d.ts} +1 -1
- package/dist/chat/index.cjs +29 -119
- package/dist/chat/index.d.cts +11 -10
- package/dist/chat/index.d.ts +11 -10
- package/dist/chat/index.js +30 -120
- package/dist/chat/lite/index.cjs +29 -119
- package/dist/chat/lite/index.d.cts +11 -10
- package/dist/chat/lite/index.d.ts +11 -10
- package/dist/chat/lite/index.js +30 -120
- package/dist/{attachments.d-CeXw6R7_.d.cts → chatHandoffToken.d-B9pjkEfl.d.cts} +33 -9
- package/dist/{attachments.d-d1rWAw9K.d.ts → chatHandoffToken.d-TYcD8NIi.d.ts} +33 -9
- package/dist/{ports.d-CIfa_XF6.d.ts → chatTypes.d-DPALEQoW.d.ts} +41 -52
- package/dist/{ports.d--OjPUqPb.d.cts → chatTypes.d-RnQ5R4zP.d.cts} +41 -52
- package/dist/client/index.cjs +2 -95
- package/dist/client/index.d.cts +7 -7
- package/dist/client/index.d.ts +7 -7
- package/dist/client/index.js +2 -95
- package/dist/{clinicBatch.d-DVahpaN3.d.cts → clinicBatch.d-C6MzLj3X.d.cts} +3 -3
- package/dist/{clinicBatch.d-CcqnQ7-d.d.ts → clinicBatch.d-t9hkown2.d.ts} +3 -3
- package/dist/{clinicRequestProps.d-CjsMg_OD.d.ts → clinicRequestProps.d-BuMuGoVZ.d.ts} +1 -1
- package/dist/{clinicRequestProps.d-1dCtouGA.d.cts → clinicRequestProps.d-DjzUdDFx.d.cts} +1 -1
- package/dist/{config.d-KX-EkQ9j.d.ts → config.d-BnZkxI5a.d.ts} +1 -1
- package/dist/{config.d-Z_fyOZke.d.cts → config.d-DoC-XaJ0.d.cts} +1 -1
- package/dist/consent/index.cjs +2 -95
- package/dist/consent/index.d.cts +5 -5
- package/dist/consent/index.d.ts +5 -5
- package/dist/consent/index.js +2 -95
- package/dist/{context.d-DV5E_2Fs.d.cts → context.d-BAh7C7T4.d.cts} +7 -6
- package/dist/{context.d-DY6d4qXG.d.ts → context.d-z2zIjKEb.d.ts} +7 -6
- package/dist/{copy.d-CMY9OoCC.d.cts → copy.d-BkX6G-Ws.d.cts} +2 -2
- package/dist/{copy.d-BPzpKGGc.d.ts → copy.d-DLxgHsZZ.d.ts} +2 -2
- package/dist/core/index.cjs +6 -99
- package/dist/core/index.d.cts +15 -14
- package/dist/core/index.d.ts +15 -14
- package/dist/core/index.js +6 -99
- package/dist/{depth.d-qVYPByPb.d.cts → depth.d-aXddCjyh.d.cts} +3 -3
- package/dist/{depth.d-B_qNSgXr.d.ts → depth.d-z2FlzY3x.d.ts} +3 -3
- package/dist/{entitlementRepository.d-CwTVi7he.d.cts → entitlementRepository.d-CDCF8eFx.d.cts} +2 -2
- package/dist/{entitlementRepository.d-BXDWPyP8.d.ts → entitlementRepository.d-Cgmy4Opa.d.ts} +2 -2
- package/dist/{focus.d-BPofD7ow.d.ts → focus.d-C2fd_5MW.d.ts} +2 -2
- package/dist/{focus.d-DJD4lWFB.d.cts → focus.d-q_sXGhLn.d.cts} +2 -2
- package/dist/health-plan/index.cjs +1 -94
- package/dist/health-plan/index.d.cts +10 -10
- package/dist/health-plan/index.d.ts +10 -10
- package/dist/health-plan/index.js +1 -94
- package/dist/{idempotency.d-BmYuCb-n.d.cts → idempotency.d-Bqdyv_yn.d.cts} +1 -1
- package/dist/{idempotency.d-BVO0mU2R.d.ts → idempotency.d-DlAPAxD5.d.ts} +1 -1
- package/dist/{identity.d-CRVNfZzQ.d.ts → identity.d-BWZiaByn.d.ts} +1 -1
- package/dist/{identity.d-3ROlHbnP.d.cts → identity.d-CooKscNj.d.cts} +1 -1
- package/dist/index.cjs +30 -120
- package/dist/index.d.cts +14 -13
- package/dist/index.d.ts +14 -13
- package/dist/index.js +31 -121
- package/dist/{introEvents.d-DGQDEPJi.d.cts → introEvents.d-C8bDDiK6.d.cts} +1 -1
- package/dist/{introEvents.d-cvMxJfYd.d.ts → introEvents.d-baVM016i.d.ts} +1 -1
- package/dist/{models.d-BSqvbTE1.d.cts → models.d-BN53M9sU.d.cts} +52 -1
- package/dist/{models.d-DOwnr8fi.d.ts → models.d-Bhq9p6Wa.d.ts} +52 -1
- package/dist/notifications/inbox/index.cjs +44 -0
- package/dist/notifications/inbox/index.d.cts +50 -0
- package/dist/notifications/inbox/index.d.ts +50 -0
- package/dist/notifications/inbox/index.js +44 -0
- package/dist/notifications/index.cjs +18 -98
- package/dist/notifications/index.d.cts +12 -6
- package/dist/notifications/index.d.ts +12 -6
- package/dist/notifications/index.js +18 -98
- package/dist/{optInView.d-DIGu47Lz.d.ts → optInView.d-C04aX0Hs.d.ts} +2 -2
- package/dist/{optInView.d-CU1U_K-B.d.cts → optInView.d-D_D7fs6C.d.cts} +2 -2
- package/dist/parse.d-DYsx1Q2V.d.cts +168 -0
- package/dist/parse.d-Do0sdAgm.d.ts +168 -0
- package/dist/{pets.d-BRsbR8QU.d.ts → pets.d-CkFNO-x-.d.ts} +1 -1
- package/dist/{pets.d-5SMtOAwB.d.cts → pets.d-oJ2OIY22.d.cts} +1 -1
- package/dist/{petsRepository.d-DWsChqAS.d.ts → petsRepository.d-CKCi6rtp.d.ts} +1 -1
- package/dist/{petsRepository.d-DEnoZn92.d.cts → petsRepository.d-VWMyIeIJ.d.cts} +1 -1
- package/dist/photo/index.cjs +1 -94
- package/dist/photo/index.js +1 -94
- package/dist/records/depth/index.cjs +2 -95
- package/dist/records/depth/index.d.cts +11 -11
- package/dist/records/depth/index.d.ts +11 -11
- package/dist/records/depth/index.js +2 -95
- package/dist/records/index.cjs +17 -108
- package/dist/records/index.d.cts +47 -17
- package/dist/records/index.d.ts +47 -17
- package/dist/records/index.js +17 -108
- package/dist/{requestFunnel.d-CQX_Z1Hi.d.cts → requestFunnel.d-By0-I8Cp.d.cts} +2 -2
- package/dist/{requestFunnel.d-DSvCGf4J.d.ts → requestFunnel.d-DVCytzTE.d.ts} +2 -2
- package/dist/{parse.d-icynBIS-.d.ts → route.d-Ay-lRct1.d.ts} +90 -53
- package/dist/{parse.d-GzZJYu__.d.cts → route.d-DQDX6QFn.d.cts} +90 -53
- package/dist/{runtimeTypes.d-Be_vhOER.d.ts → runtimeTypes.d-C49Cgb9c.d.ts} +39 -5
- package/dist/{runtimeTypes.d-sXpNYnJp.d.cts → runtimeTypes.d-DUVNpR6g.d.cts} +39 -5
- package/dist/{screenProps.d-DpMK2_gi.d.ts → screenProps.d-B_arD3Lh.d.ts} +2 -2
- package/dist/{screenProps.d-BW6PZh5k.d.cts → screenProps.d-BgxlmfG5.d.cts} +2 -2
- package/dist/server/events/index.cjs +2 -95
- package/dist/server/events/index.d.cts +92 -5
- package/dist/server/events/index.d.ts +92 -5
- package/dist/server/events/index.js +2 -95
- package/dist/server/index.cjs +2 -95
- package/dist/server/index.d.cts +3 -3
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +2 -95
- package/dist/{sheetSeam.d-BBuEIVsa.d.cts → sheetSeam.d-B9iQqG_I.d.cts} +2 -2
- package/dist/{sheetSeam.d-B09jf4YC.d.ts → sheetSeam.d-CtuKILqp.d.ts} +2 -2
- package/dist/shop/index.d.cts +3 -3
- package/dist/shop/index.d.ts +3 -3
- package/dist/tabs/index.cjs +3 -96
- package/dist/tabs/index.d.cts +8 -8
- package/dist/tabs/index.d.ts +8 -8
- package/dist/tabs/index.js +3 -96
- package/dist/televet/booking/index.cjs +1 -94
- package/dist/televet/booking/index.d.cts +6 -6
- package/dist/televet/booking/index.d.ts +6 -6
- package/dist/televet/booking/index.js +1 -94
- package/dist/televet/index.cjs +1 -94
- package/dist/televet/index.js +1 -94
- package/dist/testing/index.cjs +1 -94
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +1 -94
- package/dist/testing/rn/index.cjs +1 -94
- package/dist/testing/rn/index.d.cts +9 -8
- package/dist/testing/rn/index.d.ts +9 -8
- package/dist/testing/rn/index.js +1 -94
- package/dist/testing/web/index.cjs +1 -94
- package/dist/testing/web/index.d.cts +10 -9
- package/dist/testing/web/index.d.ts +10 -9
- package/dist/testing/web/index.js +1 -94
- package/dist/texting/index.cjs +1 -94
- package/dist/texting/index.d.cts +5 -5
- package/dist/texting/index.d.ts +5 -5
- package/dist/texting/index.js +1 -94
- package/dist/{threadOptions.d-DMOn3mmj.d.ts → threadOptions.d-Cbhjjb9_.d.ts} +2 -2
- package/dist/{threadOptions.d-Csmb-XgL.d.cts → threadOptions.d-pZXzsd2d.d.cts} +2 -2
- package/dist/{timelineRows.d-B0XZevKx.d.ts → timelineRows.d-BHxMeZzl.d.ts} +1 -1
- package/dist/{timelineRows.d-Kllr7Mcu.d.cts → timelineRows.d-DlMs82N1.d.cts} +1 -1
- package/dist/unreadStore.d-gCsleb6l.d.ts +74 -0
- package/dist/unreadStore.d-w5x6lEpR.d.cts +74 -0
- package/dist/{useHealthPlanSubscription.d-bNRntgWe.d.ts → useHealthPlanSubscription.d-BoC7H85G.d.ts} +2 -2
- package/dist/{useHealthPlanSubscription.d-C-c_mQ4u.d.cts → useHealthPlanSubscription.d-CZn06-lu.d.cts} +2 -2
- package/dist/useInboxUnread.d-DW0dpWdv.d.cts +206 -0
- package/dist/useInboxUnread.d-vYpOXVRv.d.ts +206 -0
- package/dist/{usePresentation.d-CmQgbrZr.d.ts → usePresentation.d-CgvwGb2A.d.ts} +2 -2
- package/dist/{usePresentation.d-BHKhBKQn.d.cts → usePresentation.d-CyCEJ6nj.d.cts} +2 -2
- package/dist/{useRecords.d-BYNX01El.d.cts → useRecords.d-BMSW4aRD.d.cts} +46 -3
- package/dist/{useRecords.d-DWk61a4c.d.ts → useRecords.d-Cv1nhZrv.d.ts} +46 -3
- package/dist/{useRecordsDepth.d-BilHZaR4.d.ts → useRecordsDepth.d-CbXhWbx7.d.ts} +1 -1
- package/dist/{useRecordsDepth.d-WW_2cWwU.d.cts → useRecordsDepth.d-CcbL98FD.d.cts} +1 -1
- package/dist/{appStateLifecycle.d-JuPhh7Oy.d.ts → useUnread.d-BsZKbLp9.d.ts} +49 -14
- package/dist/{appStateLifecycle.d-BQcy4J5O.d.cts → useUnread.d-CfF2Cx-q.d.cts} +49 -14
- package/dist/video/index.cjs +1 -94
- package/dist/video/index.js +1 -94
- package/dist/{view.d-BTnjZu2S.d.cts → view.d-CF3AP3T7.d.cts} +5 -5
- package/dist/{view.d-BtN_L_UF.d.ts → view.d-DdyOf0T0.d.ts} +5 -5
- package/dist/web/consent/index.cjs +2 -95
- package/dist/web/consent/index.d.cts +5 -5
- package/dist/web/consent/index.d.ts +5 -5
- package/dist/web/consent/index.js +2 -95
- package/dist/web/health-plan/index.cjs +1 -94
- package/dist/web/health-plan/index.d.cts +12 -12
- package/dist/web/health-plan/index.d.ts +12 -12
- package/dist/web/health-plan/index.js +1 -94
- package/dist/web/inbox/index.cjs +49 -0
- package/dist/web/inbox/index.d.cts +191 -0
- package/dist/web/inbox/index.d.ts +191 -0
- package/dist/web/inbox/index.js +49 -0
- package/dist/web/index.cjs +28 -118
- package/dist/web/index.d.cts +80 -40
- package/dist/web/index.d.ts +80 -40
- package/dist/web/index.js +28 -118
- package/dist/web/intro/index.cjs +3 -96
- package/dist/web/intro/index.d.cts +8 -8
- package/dist/web/intro/index.d.ts +8 -8
- package/dist/web/intro/index.js +3 -96
- package/dist/web/notifications/index.cjs +16 -96
- package/dist/web/notifications/index.d.cts +8 -3
- package/dist/web/notifications/index.d.ts +8 -3
- package/dist/web/notifications/index.js +16 -96
- package/dist/web/records/depth/index.cjs +2 -95
- package/dist/web/records/depth/index.d.cts +11 -11
- package/dist/web/records/depth/index.d.ts +11 -11
- package/dist/web/records/depth/index.js +2 -95
- package/dist/web/records/index.cjs +16 -107
- package/dist/web/records/index.d.cts +43 -19
- package/dist/web/records/index.d.ts +43 -19
- package/dist/web/records/index.js +16 -107
- package/dist/web/records-sheet/index.cjs +2 -95
- package/dist/web/records-sheet/index.d.cts +4 -4
- package/dist/web/records-sheet/index.d.ts +4 -4
- package/dist/web/records-sheet/index.js +2 -95
- package/dist/web/shop/index.d.cts +3 -3
- package/dist/web/shop/index.d.ts +3 -3
- package/dist/web/televet/booking/index.cjs +1 -94
- package/dist/web/televet/booking/index.d.cts +6 -6
- package/dist/web/televet/booking/index.d.ts +6 -6
- package/dist/web/televet/booking/index.js +1 -94
- package/dist/web/televet/index.cjs +1 -94
- package/dist/web/televet/index.js +1 -94
- package/dist/web/texting/index.cjs +1 -94
- package/dist/web/texting/index.d.cts +5 -5
- package/dist/web/texting/index.d.ts +5 -5
- package/dist/web/texting/index.js +1 -94
- package/notifications/inbox/package.json +8 -0
- package/package.json +29 -1
- package/web/inbox/native-blocked.cjs +12 -0
- package/web/inbox/package.json +8 -0
|
@@ -2,100 +2,7 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import{useEverfurTheme,cssMonoFamily,headingFaceCss,faceCss,EVERFUR_LIGHT,EVERFUR_DARK,Toast,useDsStyles,buttonCss,segmentedTabsCss,summaryListCss,toastCss,ThemeProvider,Button,SummaryList,SegmentedTabs,resolveTheme,everfurWebTheme}from"../../chunk-Y3Q4GW47.js";import{createContext,lazy,useMemo,useEffect,useRef,useId,useState,useContext,useCallback,useLayoutEffect,createElement,useSyncExternalStore,Fragment as Fragment$1,Suspense,Component}from"react";import{jsx,jsxs,Fragment}from"react/jsx-runtime";import{createPortal}from"react-dom";function toRgba(value){if(typeof value=="number")return argbIntToRgba(value);if(typeof value!="string")return null;let s=value.trim();if(s.length===0)return null;if(s.startsWith("#"))return fromHex(s.slice(1));if(s.toLowerCase().startsWith("0x"))return fromHex(s.slice(2));if(s.toLowerCase().startsWith("rgb"))return fromRgbFunc(s);if(/^[0-9a-fA-F]+$/.test(s)){let hex=fromHex(s);if(hex!==null)return hex}return/^\d+$/.test(s)?argbIntToRgba(Number.parseInt(s,10)):null}function fromHex(hex){let h=hex.trim();if(!/^[0-9a-fA-F]+$/.test(h))return null;if(h.length===3)return{r:dup(h[0]),g:dup(h[1]),b:dup(h[2]),a:1};if(h.length===6)return{r:byte(h,0),g:byte(h,2),b:byte(h,4),a:1};if(h.length===8){let a=byte(h,0);return{r:byte(h,2),g:byte(h,4),b:byte(h,6),a:a/255}}return null}function fromRgbFunc(input){let open=input.indexOf("("),close=input.indexOf(")");if(open<0||close<0||close<open)return null;let parts=input.slice(open+1,close).split(",").map(p=>p.trim());if(parts.length<3)return null;let r=clampByte(Number(parts[0])),g=clampByte(Number(parts[1])),b=clampByte(Number(parts[2]));if(r===null||g===null||b===null)return null;let a=1;if(parts.length>=4){let alpha=Number(parts[3]);if(!Number.isFinite(alpha))return null;a=Math.min(1,Math.max(0,alpha))}return{r:r,g:g,b:b,a:a}}function argbIntToRgba(n){if(!Number.isFinite(n))return null;let int2=Math.trunc(n)>>>0,a=int2>>>24&255;return{r:int2>>>16&255,g:int2>>>8&255,b:int2&255,a:a===0?1:a/255}}function byte(hex,at){return Number.parseInt(hex.slice(at,at+2),16)}function dup(nibble){return Number.parseInt(`${nibble??"0"}${nibble??"0"}`,16)}function clampByte(n){return Number.isFinite(n)?Math.min(255,Math.max(0,Math.round(n))):null}function rgbToHex(r,g,b){return`#${hex2(r)}${hex2(g)}${hex2(b)}`.toUpperCase()}function hex2(n){return n.toString(16).padStart(2,"0")}var NEAR_BLACK="#111111",WHITE="#FFFFFF",BLACK="#000000";function readableOn(background){let rgba=toRgba(background);if(rgba===null)return WHITE;let bg=relativeLuminance(rgba),black=relativeLuminance({r:17,g:17,b:17}),white=relativeLuminance({r:255,g:255,b:255});return luminanceContrast(bg,white)>=luminanceContrast(bg,black)?WHITE:NEAR_BLACK}function legibleOn(background,target){let first=readableOn(background);return contrastRatio(first,background)>=target?first:contrastRatio(WHITE,background)>=contrastRatio(BLACK,background)?WHITE:BLACK}function poleForGrounds(grounds){let worst=ink=>grounds.reduce((low,ground)=>Math.min(low,contrastRatio(ink,ground)),Number.POSITIVE_INFINITY);return worst(WHITE)>=worst(BLACK)?WHITE:BLACK}function relativeLuminance(rgba){let r=linearize(rgba.r/255),g=linearize(rgba.g/255),b=linearize(rgba.b/255);return.2126*r+.7152*g+.0722*b}function linearize(channel){return channel<=.03928?channel/12.92:Math.pow((channel+.055)/1.055,2.4)}function luminanceContrast(l1,l2){let lighter=Math.max(l1,l2),darker=Math.min(l1,l2);return(lighter+.05)/(darker+.05)}function contrastRatio(a,b){let fg=toRgba(a),bg=toRgba(b);if(fg===null||bg===null)return 1;let ground=bg.a>=1?bg:{...bg},fore=fg.a>=1?fg:composite(fg,ground);return luminanceContrast(relativeLuminance(fore),relativeLuminance(ground))}function composite(fg,bg){let a=fg.a,mix=(f,g)=>Math.round(f*a+g*(1-a));return{r:mix(fg.r,bg.r),g:mix(fg.g,bg.g),b:mix(fg.b,bg.b),a:1}}function flattenOnto(color,background){let fg=toRgba(color),bg=toRgba(background);if(fg===null||bg===null)return null;let out=fg.a>=1?fg:composite(fg,{...bg});return rgbToHex(out.r,out.g,out.b)}function withAlpha(color,alpha){let rgba=toRgba(color);if(rgba===null)return null;let a=Math.min(1,Math.max(0,alpha));return`rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${a})`}var PUSH_STEP=.05;function pushToContrast(color,grounds,pole,target){let first=grounds[0];if(first===void 0)return pole;let reads=candidate=>grounds.every(ground=>contrastRatio(candidate,ground)>=target);if(toRgba(color)===null)return pole;if(reads(color))return color;let flat=flattenOnto(color,first),from=flat===null?null:toRgba(flat),to=toRgba(pole);if(from===null||to===null)return pole;for(let step=1;step<1/PUSH_STEP;step+=1){let t=step*PUSH_STEP,mix=(a,b)=>Math.round(a+(b-a)*t),candidate=rgbToHex(mix(from.r,to.r),mix(from.g,to.g),mix(from.b,to.b));if(reads(candidate))return candidate}return pole}var PLAN_DS_PRESET={ink:"#10462E",go:"#07C168",alert:"#C03410",tintSage:"#E6ECE8"},DS_THEME_CONTEXT=/* @__PURE__ */Symbol.for("@everfur-health/ui-core#ThemeContext@v1");function dsThemeContext(){let host=globalThis,ctx=host[DS_THEME_CONTEXT];return ctx===void 0&&(ctx=createContext(null),ctx.displayName="EverfurThemeContext",host[DS_THEME_CONTEXT]=ctx),ctx}var same=(a,b)=>a.toUpperCase()===b.toUpperCase();function isDark(bg){let rgba=toRgba(bg);return rgba!==null&&relativeLuminance(rgba)<.18}var cache=/* @__PURE__ */new WeakMap;function planThemeWithHost(theme,host){if(host===null)return theme;let byHost=cache.get(theme);byHost===void 0&&(byHost=/* @__PURE__ */new WeakMap,cache.set(theme,byHost));let out=byHost.get(host);return out===void 0&&(out=overlay(theme,host),byHost.set(host,out)),out}function overlay(theme,host){let h=host.colors,inkMoved=!same(h.ink,PLAN_DS_PRESET.ink),goMoved=!same(h.go,PLAN_DS_PRESET.go),darkHost=theme===EVERFUR_LIGHT&&isDark(h.bg),base3=darkHost?EVERFUR_DARK:theme,c=base3.color,free=key=>darkHost||c[key]===EVERFUR_LIGHT.color[key],color={};inkMoved&&free("primary")&&(Object.assign(color,{primary:h.ink,onPrimary:h.onInk,brand:h.ink,brandInk:h.ink}),free("linkInk")&&(color.linkInk=h.ink),!goMoved&&free("accent")&&Object.assign(color,{accent:h.ink,onAccent:h.onInk})),goMoved&&free("accent")&&Object.assign(color,{accent:h.go,onAccent:h.onGo}),!same(h.alert,PLAN_DS_PRESET.alert)&&free("danger")&&(color.danger=h.alert),!same(h.tintSage,PLAN_DS_PRESET.tintSage)&&free("brandSoft")&&(color.brandSoft=h.tintSage,free("brandSofter")&&(color.brandSofter=h.tintSage)),darkHost&&Object.assign(color,{background:h.bg,surface:h.surface,text:{...c.text,primary:h.text,muted:h.muted},borderRingCream:h.line});let reduced=host.motion?.reduced===true&&!base3.motion.reducedMotion;return!darkHost&&!reduced&&Object.keys(color).length===0?theme:{...base3,color:{...c,...color},...reduced?{motion:{...base3.motion,reducedMotion:true}}:{}}}function usePlanTheme(){let theme=useEverfurTheme(),host=useContext(dsThemeContext());return useMemo(()=>planThemeWithHost(theme,host),[theme,host])}var HEALTH_PLAN_COPY=/* @__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:""}),COPY_ASKS=/* @__PURE__ */Object.freeze({emptyTitle:true,emptyBody:true,emptyAsk:true}),HEALTH_PLAN_REASON_LABELS=/* @__PURE__ */Object.freeze({dna:"",records:"Records",inside:"Inside",profile:""}),HEALTH_PLAN_TEMPLATES=/* @__PURE__ */Object.freeze({planTitle:petName=>`${petName}'s care plan`,cartLabel:brand=>`${brand} cart`}),HEALTH_PLAN_COPY_PLACEHOLDERS=/* @__PURE__ */Object.freeze([...Object.keys(HEALTH_PLAN_COPY).filter(key=>COPY_ASKS[key]===true&&HEALTH_PLAN_COPY[key]==="").map(key=>`HEALTH_PLAN_COPY.${key}`),...["profile"].filter(kind=>HEALTH_PLAN_REASON_LABELS[kind]==="").map(kind=>`HEALTH_PLAN_REASON_LABELS.${kind}`)]);var HEALTH_PLAN_LAYOUT_DEFAULTS=/* @__PURE__ */Object.freeze({imageVariant:"wide",reasonVariant:"pills",cartBarVisibility:"whenItems",cartBarPlacement:"sticky",addButtonSize:"full",addedVariant:"link",categoryVariant:"text",showCategory:false,cardShadow:false,cardBorder:true});function healthPlanWrites(plan,setInPlan){return{setInPlan:setInPlan,addAll:async()=>{let missing=(plan?.items??[]).filter(item=>!item.inPlan);return(await Promise.all(missing.map(item=>setInPlan(item.productId,true)))).every(Boolean)}}}function showHealthPlanCartBar(visibility,count){return(visibility??HEALTH_PLAN_LAYOUT_DEFAULTS.cartBarVisibility)==="always"||count>0}var HEALTH_PLAN_CARD_OPTION_KEYS=/* @__PURE__ */Object.freeze(["showCategory","cardShadow","cardBorder","addButtonSize","addButtonFontSize","addedVariant","categoryVariant","cardPadding","itemTitleSize","itemTitleWeight","priceSize","priceWeight","reasonTextSize","reasonLabelWidth","reasonGap"]);function pickHealthPlanCardOptions(props){let out={};for(let key of HEALTH_PLAN_CARD_OPTION_KEYS)props[key]!==void 0&&(out[key]=props[key]);return out}function healthPlanAddButtonHeight(size){let height=typeof size=="number"&&Number.isFinite(size)&&size>0?size:size==="compact"?32:44;return{height:height,hit:Math.max(44,height)}}function healthPlanLength(value){return typeof value=="number"&&Number.isFinite(value)&&value>=0?value:null}function healthPlanTitleOffset(titleGap,sectionGap){let gap=healthPlanLength(titleGap);return gap===null?0:gap-sectionGap}function isHealthPlanSessionRequired(error){return error!==null&&(error.reasonCode==="session_required"||error.code==="sessionRequired")}var DockContext=createContext(null);function HealthPlanCartScope({children:children}){let[dock,setDock]=useState(null),store=useMemo(()=>({dock:dock,publish:setDock}),[dock]);return createElement(DockContext.Provider,{value:store},children)}function useHealthPlanCartDock(){return useContext(DockContext)?.dock??null}function usePublishHealthPlanCart(enabled,cart,busy,petRef,plan,setInPlan){let publish=useContext(DockContext)?.publish,latest=useRef(setInPlan);useEffect(()=>{latest.current=setInPlan},[setInPlan]);let writes=useMemo(()=>healthPlanWrites(plan,(productId,inPlan)=>latest.current(productId,inPlan)),[plan]);useEffect(()=>{if(!(publish===void 0||!enabled))return publish(/* @__PURE__ */Object.freeze({cart:cart,busy:busy,petRef:petRef,plan:plan,...writes})),()=>publish(null)},[publish,enabled,cart,busy,petRef,plan,writes])}function healthPlanPetWords(name,sex){let n=name?.trim()??"",named=n===""?"your pet":n,Named=n===""?"Your pet":n;return sex==="female"?{name:named,Name:Named,poss:"her",Poss:"Her",obj:"her"}:sex==="male"?{name:named,Name:Named,poss:"his",Poss:"His",obj:"him"}:{name:named,Name:Named,poss:`${named}'s`,Poss:`${Named}'s`,obj:named}}var cartRenewal=p=>p===null?"":`${p.productName} renews every ${p.intervalDays} days at ${p.box??""} until you cancel; skip or cancel anytime in the app.`,HEALTH_PLAN_NO_SHIP_DAY_COPY=/* @__PURE__ */Object.freeze({onceFine:"",cartFine:cartRenewal,startedWhat:()=>""});function healthPlanFocusCopyFor(pet){let w=healthPlanPetWords(pet.name,pet.sex),nameOf=p=>p.petName?.trim()||w.name,NameOf=p=>p.petName?.trim()||w.Name,copy=/* @__PURE__ */Object.freeze({jumpKicker:(p,subscribed)=>subscribed?`In ${w.poss} plan, every ${p.intervalDays} days`:p.offer?`${p.discountPercent}% off ${w.poss} first box`:p.intervalDays>0?`Ships every ${p.intervalDays} days`:copy.onceLine(p),optionsLabel:"How to buy",subscribe:"Subscribe",bestValue:"Best value",subscribeLine:p=>p.offer?`First box, then ${p.box??""}`:`${p.box??""} every ${p.intervalDays} days`,priceLine:p=>p.offer?`${p.discountPercent}% off the first box. Ships every ${p.intervalDays} days.`:p.intervalDays>0?`Ships every ${p.intervalDays} days.`:copy.onceOffer(p),once:"One box",onceLine:p=>p.onceDiscountPercent>0?`${p.onceDiscountPercent}% off, ships once`:"Ships once",buyOnce:p=>`Buy one box, ${p.once??p.box??""}`,subscribed:"Subscribed",subscribedLine:(p,next)=>next===null?`Every ${p.intervalDays} days`:`Every ${p.intervalDays} days · next box ${next}`,manage:"Manage",checkoutKicker:"Checkout",checkoutTitle:p=>`Checkout: ${p.productName}`,checkoutOffer:p=>`${p.discountPercent}% off your first box.`,shipsEvery:"Ships every",days:n=>`${n} days`,buyOnceOption:"Buy once",checkoutGo:(_p,subscribe,today)=>`${subscribe?"Subscribe":"Buy now"} · ${today} today`,renews:p=>`Renews every ${p.intervalDays} days at ${p.box??""} until you cancel; skip or cancel anytime in the app.`,onceFine:"One box, ships tomorrow.",onceOffer:p=>p.onceDiscountPercent>0?`${p.onceDiscountPercent}% off, ships once.`:"Ships once.",checkoutNote:"",close:"Close",startedTitle:p=>`${NameOf(p)}'s plan has started.`,orderedTitle:()=>"Order placed.",startedWhat:p=>`${p.productName} ships tomorrow.`,startedNote:"",startedSteps:"What happens next",tomorrow:"Tomorrow",firstBoxShips:`${w.Poss} first box ships.`,trackingComesByText:"Tracking comes by text.",checkin:q=>q===null?"A 2-week check-in by text.":`A 2-week check-in by text: ${q}`,refill:`A text 3 days before ${w.poss} next box. Reply SKIP to skip it.`,nextBoxShips:p=>`${w.Poss} next box ships, ${p.box??""}.`,startedDone:`Back to ${w.poss} plan`,manageKicker:"Your subscription",manageTitle:p=>`Manage ${p.productName}`,skip:"Skip the next box",cancel:"Cancel subscription",skipped:(_p,next)=>next===null?"Skipped.":`Skipped. ${w.Poss} next box ships ${next}.`,cancelled:p=>`${p.productName} is cancelled. Restart it from ${w.poss} plan anytime.`,orders:"Orders",startedHeader:"Subscribed",placedHeader:"Order placed",cartCheckoutTitle:"Checkout",orderNote:"",cartLabel:n=>n>0?`Cart, ${n} item${n>1?"s":""}`:"Cart, empty",addToCart:price=>`Add to cart · ${price}`,viewCart:"View cart",addedToCart:(p,subscription)=>`${p.productName} is in your cart${subscription?", as a subscription":""}.`,removedFromCart:name=>`${name} is out of your cart.`,cartTitle:"Cart",cartEmptyTitle:"Your cart is empty",cartEmptyBody:p=>`${NameOf(p)}'s plan pick lands here when you add it.`,seeOrders:`See ${w.poss} orders`,quantityLabel:name=>`How many: ${name}`,fewer:"One fewer",more:"One more",remove:"Remove",cartSubLine:p=>p.offer?`First box ${p.discountPercent}% off, then ${p.box??""} every ${p.intervalDays} days`:`Every ${p.intervalDays} days`,cartOnceLine:(p,subscribed)=>subscribed?`An extra box. ${w.Poss} plan keeps shipping.`:p.onceDiscountPercent>0?`One box, ${p.onceDiscountPercent}% off`:"One box",cartModeLabel:name=>`How to buy ${name}`,cartModeSubscribe:p=>p.offer?`Subscribe, ${p.discountPercent}% off the first box`:"Subscribe",cartModeOnce:p=>p.onceDiscountPercent>0?`One box, ${p.onceDiscountPercent}% off`:"One box",subtotal:"Subtotal",shipping:"Shipping",shippingValue:"",shippingTag:"",total:"Total",dueToday:"Due today",thenRenews:p=>`Then ${p.productName}`,renewsEvery:p=>`${p.box??""} every ${p.intervalDays} days`,checkoutCart:total=>`Checkout · ${total}`,cartOneAtATime:"",cartSubscriptionApart:"",cartItemSubscription:p=>`Subscription, every ${p.intervalDays} days`,cartItemQuantity:n=>`Qty ${n}`,placeOrder:(total,subscribe)=>`${subscribe?"Place order and subscribe":"Place order"} · ${total}`,cartFine:p=>`${p===null?"":`${cartRenewal(p)} `}Ships tomorrow.`,placedSteps:"What's coming",placedShips:"It ships.",placedArrives:"It arrives at home.",viewOrder:"View order",herSubscription:`${w.Poss} subscription`,nextBox:day=>`Next box ${day}`,everyDays:n=>`Every ${n} days`,ordersHeading:afterSubscription=>afterSubscription?"Orders":`${w.Poss} orders`,ordersFine:"",ordersEmptyTitle:"No orders yet",ordersEmptyBody:p=>`The boxes from ${nameOf(p)}'s plan show up here.`,moreOrders:"",orderSteps:["Ordered","Shipped","Out for delivery","Delivered"],subscriptionBox:"Subscription box",orderTitle:n=>n===null?"Order":`Order ${n}`,arrivesBy:day=>`Arrives by ${day}`,deliveredOn:day=>`Delivered ${day}`,expected:day=>`Expected ${day}`,tracking:"Tracking",trackingByText:"The tracking number comes by text when it ships.",trackOn:carrier=>`Track on ${carrier}`,trackLink:"",inThisOrder:"In this order",orderItemLine:(n,box)=>`Qty ${n}${box?" · subscription box":""}`,paidWith:"Paid with",buyAgain:"Buy again",orderHelp:"Get help with this order",addWeightTitle:`Add ${w.poss} weight to size ${w.poss} dose`,addWeightBody:`From a home scale or ${w.poss} last vet visit.`,connectRecordsTitle:`Connect ${w.poss} vet records`,connectRecordsBody:`${w.Poss} weight, visits and labs make ${w.poss} plan sharper.`,weightKicker:`${w.Poss} weight`,weightTitle:p=>`Add ${nameOf(p)}'s weight`,weightBody:`From a home scale or ${w.poss} last vet visit. ${w.Poss} plan uses it to size ${w.poss} dose.`,weightField:`${w.Poss} weight`,weightUnit:"lb",weightUnitKg:"kg",weightErrorKg:"Enter your pet’s weight",weightError:`Enter ${w.poss} weight in pounds, like 14.1.`,weightSave:`Save ${w.poss} weight`,weightSaved:lb=>`Saved: ${lb} lb. ${w.Poss} dose is sized for ${w.obj}.`,weightSavedKg:kg=>`Saved: ${kg} kg. ${w.Poss} dose is sized for ${w.obj}.`,checkoutFailed:"That didn't go through. Please try again.",builtWith:vet=>`Built with ${vet}`,fromVet:shortName=>`From ${shortName}`,waitVetTips:vet=>`Free tips from ${vet}, built around that risk`,signalsFit:count=>`${count} of ${count} signals fit ${w.Name}`,signalsValue:count=>`${count}/${count}`,noPick:`No supplement for this one. ${w.Poss} vet comes first.`,callYourVet:"Call your vet today",callAVet:"Call a vet today",saveForCheckup:`Save for ${w.poss} next checkup`,savedForCheckup:`Saved for ${w.poss} next checkup`,blanksLabel:`${w.Poss} three blanks`,blanksAsked:clinic=>`Asked ${clinic}`,blanksAskedNoClinic:"",blanksWaitPill:"2 to 5 days",blanksFilledKicker:`From ${w.poss} vet records`,blanksFilled:(filled,total)=>`${filled} of ${total} filled`,blanksWeight:`Keep ${w.obj} at `,blanksWeightSource:`From ${w.poss} vet visits`,blanksDose:(dose,product)=>`${dose} of ${product}`,blanksDoseSource:`Sized to ${w.poss} weight`,blanksShots:`${w.Poss} next shots are due `,blanksShotsSource:`From ${w.poss} clinic`,blankEmpty:"blank",recordsLanded:`${w.Poss} records are in. ${w.Poss} plan now uses ${w.poss} weight and ${w.poss} visits.`,todayLabel:`${w.Poss} Health Plan`,poweredBy:"powered by",poweredByName:"Everfur",seeMore:"See more",seeLess:"See less",reportActions:"Actions to take",openReport:`Open it in ${w.poss} report`,askReport:"Ask about it",fullOpen:`See ${w.poss} full plan`,fullOpenLine:`${w.Poss} vet, reviews and ${w.poss} checkup`,fullClose:`Show ${w.poss} brief plan`,fullCloseLine:`${w.Poss} risk, tips, pick and signs`,hopeNoted:phrases=>`Noted. When ${w.poss} results land, we'll start with ${phrases}.`,productLink:product=>`${product}, see the product`,productPhotos:product=>`${product} photos, swipe for more`,shopAll:"Shop all",madeFor:`Made for ${w.name}`,ratingLine:count=>`· ${count} reviews`,productOffer:p=>`${p.discountPercent}% off ${w.poss} first box`,productEvery:p=>`Every ${p.intervalDays} days`,productOnce:p=>p.onceDiscountPercent>0?`One box, ${p.onceDiscountPercent}% off`:"One box",productExtraBox:"An extra box",productOnPlan:p=>`On ${w.poss} plan, every ${p.intervalDays} days. This adds one extra box.`,quantity:"Quantity",description:"Description",readMore:"Read more",readLess:"Read less",whatsInside:"What's inside",howMuch:"How much",reviewsTitle:"Reviews",reviewCount:count=>`${count} reviews`,reviewsSwipe:"Reviews, swipe for more",readAllReviews:count=>`Read all ${count} reviews`,starsLabel:rating=>`${rating} out of 5 stars`,buyNow:"Buy now"});return copy}var HEALTH_PLAN_FOCUS_COPY=healthPlanFocusCopyFor({sex:"female"});function formatHealthPlanDay(iso,locale){if(iso===null||!/^\d{4}-\d{2}-\d{2}$/.test(iso))return null;let d=/* @__PURE__ */new Date(`${iso}T00:00:00Z`);if(Number.isNaN(d.getTime()))return null;try{return new Intl.DateTimeFormat(locale??"en-US",{month:"short",day:"numeric",timeZone:"UTC"}).format(d)}catch{return iso}}function healthPlanPageDrawsWithoutItems(design){return design!=null&&(design.wait!==void 0||design.pick.hidden===true)}function withoutProductPart(design){return{...design,pick:{...design.pick,none:true,hidden:true}}}var NO_PLAN_ITEM=/* @__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 noopTelemetry=/* @__PURE__ */Object.freeze({track(){},trackExpectedFailure(){}});function ok(value,warning){/* @__PURE__ */
|
|
4
4
|
return Object.freeze({ok:true,value:value})}function err(error){/* @__PURE__ */
|
|
5
|
-
return Object.freeze({ok:false,error:error})}var EverfurConfigError=class _EverfurConfigError extends Error{constructor(kind,message){super(message),this.name="EverfurConfigError",this.kind=kind,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var EVERFUR_CONTEXT_SYMBOL=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),globalContextHost=globalThis,EverfurContext=globalContextHost[EVERFUR_CONTEXT_SYMBOL]??(globalContextHost[EVERFUR_CONTEXT_SYMBOL]=createContext(null));EverfurContext.displayName??="EverfurContext";function useEverfurContext(){let ctx=useContext(EverfurContext);if(ctx===null)throw new EverfurConfigError("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return ctx}var HEALTH_PLAN_EVENTS=/* @__PURE__ */Object.freeze({opened:"health_plan.opened",productClicked:"health_plan.product_clicked",checkoutStarted:"health_plan.checkout_started"});function useHealthPlanTelemetry(){return useContext(EverfurContext)?.runtime.registry.services.telemetry??noopTelemetry}var PlanPetContext=createContext(null);function HealthPlanPetScope({petRef:petRef,children:children}){return createElement(PlanPetContext.Provider,{value:petRef},children)}function useHealthPlanBarPet(dockPet){let page=useContext(PlanPetContext),ctx=useContext(EverfurContext);return page??dockPet??ctx?.activePet??null}function useHealthPlanOpened(drawn,petRef,plan){let telemetry=useHealthPlanTelemetry(),sent=useRef(null);useEffect(()=>{if(!drawn||petRef===null||sent.current===petRef)return;sent.current=petRef;let items=plan?.items??[];telemetry.track(HEALTH_PLAN_EVENTS.opened,{petRef:petRef,itemsCount:items.length,inPlanCount:items.filter(item=>item.inPlan).length})},[drawn,petRef,plan,telemetry])}function trackProductClicked(telemetry,petRef,productId,inPlan){telemetry.track(HEALTH_PLAN_EVENTS.productClicked,{petRef:petRef,productId:productId,inPlan:inPlan})}function trackCheckoutStarted(telemetry,petRef,cart){telemetry.track(HEALTH_PLAN_EVENTS.checkoutStarted,{petRef:petRef,itemsCount:cart.count,subtotal:cart.subtotal,currency:cart.currency})}var CONTRACT_RETRYABILITY=/* @__PURE__ */Object.freeze([
|
|
6
|
-
/* @__PURE__ */Object.freeze({wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false}),
|
|
7
|
-
/* @__PURE__ */Object.freeze({wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false}),
|
|
8
|
-
/* @__PURE__ */Object.freeze({wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true}),
|
|
9
|
-
/* @__PURE__ */Object.freeze({wireCode:"DAILY_QUOTA_EXCEEDED",envelope:"http_envelope",httpStatus:429,retryable:true}),
|
|
10
|
-
/* @__PURE__ */Object.freeze({wireCode:"FILE_TOO_LARGE",envelope:"http_envelope",httpStatus:400,retryable:false}),
|
|
11
|
-
/* @__PURE__ */Object.freeze({wireCode:"IDEMPOTENCY_KEY_IN_FLIGHT",envelope:"http_envelope",httpStatus:409,retryable:true}),
|
|
12
|
-
/* @__PURE__ */Object.freeze({wireCode:"IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST",envelope:"http_envelope",httpStatus:409,retryable:false}),
|
|
13
|
-
/* @__PURE__ */Object.freeze({wireCode:"INVALID_CONTENT_TYPE",envelope:"http_envelope",httpStatus:400,retryable:false}),
|
|
14
|
-
/* @__PURE__ */Object.freeze({wireCode:"InternalFailureException",envelope:"http_envelope",httpStatus:500,retryable:true}),
|
|
15
|
-
/* @__PURE__ */Object.freeze({wireCode:"MethodNotAllowedException",envelope:"http_envelope",httpStatus:405,retryable:false}),
|
|
16
|
-
/* @__PURE__ */Object.freeze({wireCode:"NotImplementedException",envelope:"http_envelope",httpStatus:501,retryable:false}),
|
|
17
|
-
/* @__PURE__ */Object.freeze({wireCode:"PaymentRequiredException",envelope:"http_envelope",httpStatus:402,retryable:false}),
|
|
18
|
-
/* @__PURE__ */Object.freeze({wireCode:"ResourceNotFoundException",envelope:"http_envelope",httpStatus:404,retryable:false}),
|
|
19
|
-
/* @__PURE__ */Object.freeze({wireCode:"ServiceUnavailableException",envelope:"http_envelope",httpStatus:503,retryable:true}),
|
|
20
|
-
/* @__PURE__ */Object.freeze({wireCode:"TIER_UPGRADE_REQUIRED",envelope:"http_envelope",httpStatus:402,retryable:false}),
|
|
21
|
-
/* @__PURE__ */Object.freeze({wireCode:"ThrottlingException",envelope:"http_envelope",httpStatus:429,retryable:true}),
|
|
22
|
-
/* @__PURE__ */Object.freeze({wireCode:"ValidationException",envelope:"http_envelope",httpStatus:400,retryable:false}),
|
|
23
|
-
/* @__PURE__ */Object.freeze({wireCode:"accessDenied",envelope:"http_envelope",httpStatus:403,retryable:false}),
|
|
24
|
-
/* @__PURE__ */Object.freeze({wireCode:"access_denied",envelope:"oauth_error",httpStatus:302,retryable:false}),
|
|
25
|
-
/* @__PURE__ */Object.freeze({wireCode:"attachment_unreadable",envelope:"http_envelope",httpStatus:400,retryable:false}),
|
|
26
|
-
/* @__PURE__ */Object.freeze({wireCode:"authExpired",envelope:"http_envelope",httpStatus:401,retryable:true}),
|
|
27
|
-
/* @__PURE__ */Object.freeze({wireCode:"authRejected",envelope:"http_envelope",httpStatus:401,retryable:false}),
|
|
28
|
-
/* @__PURE__ */Object.freeze({wireCode:"catalog_empty_refused",envelope:"http_envelope",httpStatus:409,retryable:false}),
|
|
29
|
-
/* @__PURE__ */Object.freeze({wireCode:"catalog_shrink_refused",envelope:"http_envelope",httpStatus:409,retryable:false}),
|
|
30
|
-
/* @__PURE__ */Object.freeze({wireCode:"consent_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),
|
|
31
|
-
/* @__PURE__ */Object.freeze({wireCode:"consent_required",envelope:"http_envelope",httpStatus:422,retryable:false}),
|
|
32
|
-
/* @__PURE__ */Object.freeze({wireCode:"consent_scope_wrong_route",envelope:"http_envelope",httpStatus:400,retryable:false}),
|
|
33
|
-
/* @__PURE__ */Object.freeze({wireCode:"device_cipher_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true}),
|
|
34
|
-
/* @__PURE__ */Object.freeze({wireCode:"email_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),
|
|
35
|
-
/* @__PURE__ */Object.freeze({wireCode:"event_cursor_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),
|
|
36
|
-
/* @__PURE__ */Object.freeze({wireCode:"event_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),
|
|
37
|
-
/* @__PURE__ */Object.freeze({wireCode:"event_payload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),
|
|
38
|
-
/* @__PURE__ */Object.freeze({wireCode:"event_type_not_available",envelope:"http_envelope",httpStatus:400,retryable:false}),
|
|
39
|
-
/* @__PURE__ */Object.freeze({wireCode:"event_type_unknown",envelope:"http_envelope",httpStatus:400,retryable:false}),
|
|
40
|
-
/* @__PURE__ */Object.freeze({wireCode:"idempotency_key_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),
|
|
41
|
-
/* @__PURE__ */Object.freeze({wireCode:"idempotency_key_required",envelope:"http_envelope",httpStatus:400,retryable:false}),
|
|
42
|
-
/* @__PURE__ */Object.freeze({wireCode:"idempotency_key_reused",envelope:"http_envelope",httpStatus:409,retryable:false}),
|
|
43
|
-
/* @__PURE__ */Object.freeze({wireCode:"insufficientCapability",envelope:"http_envelope",httpStatus:403,retryable:false}),
|
|
44
|
-
/* @__PURE__ */Object.freeze({wireCode:"insufficient_scope",envelope:"http_envelope",httpStatus:403,retryable:false}),
|
|
45
|
-
/* @__PURE__ */Object.freeze({wireCode:"internal_error",envelope:"sse_frame",httpStatus:200,retryable:false}),
|
|
46
|
-
/* @__PURE__ */Object.freeze({wireCode:"invalidRequest",envelope:"http_envelope",httpStatus:400,retryable:false}),
|
|
47
|
-
/* @__PURE__ */Object.freeze({wireCode:"invalid_client",envelope:"oauth_error",httpStatus:401,retryable:false}),
|
|
48
|
-
/* @__PURE__ */Object.freeze({wireCode:"invalid_client_metadata",envelope:"oauth_error",httpStatus:400,retryable:false}),
|
|
49
|
-
/* @__PURE__ */Object.freeze({wireCode:"invalid_grant",envelope:"oauth_error",httpStatus:400,retryable:false}),
|
|
50
|
-
/* @__PURE__ */Object.freeze({wireCode:"invalid_redirect_uri",envelope:"oauth_error",httpStatus:400,retryable:false}),
|
|
51
|
-
/* @__PURE__ */Object.freeze({wireCode:"invalid_request",envelope:"oauth_error",httpStatus:400,retryable:false}),
|
|
52
|
-
/* @__PURE__ */Object.freeze({wireCode:"invalid_scope",envelope:"oauth_error",httpStatus:400,retryable:false}),
|
|
53
|
-
/* @__PURE__ */Object.freeze({wireCode:"invalid_target",envelope:"oauth_error",httpStatus:400,retryable:false}),
|
|
54
|
-
/* @__PURE__ */Object.freeze({wireCode:"linked_account_read_only",envelope:"http_envelope",httpStatus:409,retryable:false}),
|
|
55
|
-
/* @__PURE__ */Object.freeze({wireCode:"mcp_connection_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),
|
|
56
|
-
/* @__PURE__ */Object.freeze({wireCode:"mcp_request_conflict",envelope:"http_envelope",httpStatus:409,retryable:false}),
|
|
57
|
-
/* @__PURE__ */Object.freeze({wireCode:"mcp_request_gone",envelope:"http_envelope",httpStatus:410,retryable:false}),
|
|
58
|
-
/* @__PURE__ */Object.freeze({wireCode:"mcp_request_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),
|
|
59
|
-
/* @__PURE__ */Object.freeze({wireCode:"not_found",envelope:"sse_frame",httpStatus:200,retryable:false}),
|
|
60
|
-
/* @__PURE__ */Object.freeze({wireCode:"partner_visit_link_conflict",envelope:"http_envelope",httpStatus:409,retryable:false}),
|
|
61
|
-
/* @__PURE__ */Object.freeze({wireCode:"partner_visit_owner_only",envelope:"http_envelope",httpStatus:403,retryable:false}),
|
|
62
|
-
/* @__PURE__ */Object.freeze({wireCode:"partner_visit_pet_already_mapped",envelope:"http_envelope",httpStatus:409,retryable:false}),
|
|
63
|
-
/* @__PURE__ */Object.freeze({wireCode:"payload_too_large",envelope:"http_envelope",httpStatus:413,retryable:false}),
|
|
64
|
-
/* @__PURE__ */Object.freeze({wireCode:"petRefInUse",envelope:"http_envelope",httpStatus:409,retryable:false}),
|
|
65
|
-
/* @__PURE__ */Object.freeze({wireCode:"pet_health_list_removals_unconfirmed",envelope:"http_envelope",httpStatus:422,retryable:false}),
|
|
66
|
-
/* @__PURE__ */Object.freeze({wireCode:"pet_health_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),
|
|
67
|
-
/* @__PURE__ */Object.freeze({wireCode:"pet_not_registered",envelope:"http_envelope",httpStatus:404,retryable:false}),
|
|
68
|
-
/* @__PURE__ */Object.freeze({wireCode:"provider_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),
|
|
69
|
-
/* @__PURE__ */Object.freeze({wireCode:"rateLimited",envelope:"http_envelope",httpStatus:429,retryable:true}),
|
|
70
|
-
/* @__PURE__ */Object.freeze({wireCode:"record_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),
|
|
71
|
-
/* @__PURE__ */Object.freeze({wireCode:"record_subject_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),
|
|
72
|
-
/* @__PURE__ */Object.freeze({wireCode:"record_upload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),
|
|
73
|
-
/* @__PURE__ */Object.freeze({wireCode:"records_consent_required",envelope:"http_envelope",httpStatus:409,retryable:false}),
|
|
74
|
-
/* @__PURE__ */Object.freeze({wireCode:"sandbox_only",envelope:"http_envelope",httpStatus:403,retryable:false}),
|
|
75
|
-
/* @__PURE__ */Object.freeze({wireCode:"session_required",envelope:"http_envelope",httpStatus:403,retryable:false}),
|
|
76
|
-
/* @__PURE__ */Object.freeze({wireCode:"session_revoked",envelope:"http_envelope",httpStatus:401,retryable:false}),
|
|
77
|
-
/* @__PURE__ */Object.freeze({wireCode:"share_limit_reached",envelope:"http_envelope",httpStatus:429,retryable:false}),
|
|
78
|
-
/* @__PURE__ */Object.freeze({wireCode:"slow_down",envelope:"oauth_error",httpStatus:429,retryable:true}),
|
|
79
|
-
/* @__PURE__ */Object.freeze({wireCode:"species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false}),
|
|
80
|
-
/* @__PURE__ */Object.freeze({wireCode:"tenant_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),
|
|
81
|
-
/* @__PURE__ */Object.freeze({wireCode:"tenant_has_no_capabilities",envelope:"http_envelope",httpStatus:409,retryable:false}),
|
|
82
|
-
/* @__PURE__ */Object.freeze({wireCode:"tenant_resource_not_found",envelope:"http_envelope",httpStatus:404,retryable:false}),
|
|
83
|
-
/* @__PURE__ */Object.freeze({wireCode:"tenant_surface_not_enabled",envelope:"http_envelope",httpStatus:409,retryable:false}),
|
|
84
|
-
/* @__PURE__ */Object.freeze({wireCode:"timeout",envelope:"sse_frame",httpStatus:200,retryable:true}),
|
|
85
|
-
/* @__PURE__ */Object.freeze({wireCode:"token_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),
|
|
86
|
-
/* @__PURE__ */Object.freeze({wireCode:"unavailable",envelope:"sse_frame",httpStatus:200,retryable:true}),
|
|
87
|
-
/* @__PURE__ */Object.freeze({wireCode:"unavailable",envelope:"http_envelope",httpStatus:503,retryable:true}),
|
|
88
|
-
/* @__PURE__ */Object.freeze({wireCode:"unrestrictedKeyRequired",envelope:"http_envelope",httpStatus:403,retryable:false}),
|
|
89
|
-
/* @__PURE__ */Object.freeze({wireCode:"unsupported_grant_type",envelope:"oauth_error",httpStatus:400,retryable:false}),
|
|
90
|
-
/* @__PURE__ */Object.freeze({wireCode:"unsupported_response_type",envelope:"oauth_error",httpStatus:302,retryable:false}),
|
|
91
|
-
/* @__PURE__ */Object.freeze({wireCode:"user_ref_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),
|
|
92
|
-
/* @__PURE__ */Object.freeze({wireCode:"verify_mint_rate_limited",envelope:"http_envelope",httpStatus:429,retryable:true}),
|
|
93
|
-
/* @__PURE__ */Object.freeze({wireCode:"verify_mint_refused",envelope:"http_envelope",httpStatus:403,retryable:false}),
|
|
94
|
-
/* @__PURE__ */Object.freeze({wireCode:"verify_mint_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true}),
|
|
95
|
-
/* @__PURE__ */Object.freeze({wireCode:"verify_user_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false}),
|
|
96
|
-
/* @__PURE__ */Object.freeze({wireCode:"webhook_endpoint_update_empty",envelope:"http_envelope",httpStatus:400,retryable:false}),
|
|
97
|
-
/* @__PURE__ */Object.freeze({wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false}),
|
|
98
|
-
/* @__PURE__ */Object.freeze({wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false})]);/* @__PURE__ */Object.freeze(CONTRACT_RETRYABILITY.map(row=>row.wireCode));var NORMALIZED_FOLD=/* @__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",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"}),CONTRACT_ERROR_ROWS=/* @__PURE__ */Object.freeze(CONTRACT_RETRYABILITY.map(generated=>/* @__PURE__ */Object.freeze({wireCode:generated.wireCode,envelope:generated.envelope,retryable:generated.retryable,normalized:NORMALIZED_FOLD[generated.wireCode]}))),BY_KEY=new Map(CONTRACT_ERROR_ROWS.map(r=>[r.envelope+r.wireCode.toUpperCase(),r])),ENVELOPE_LOOKUP_ORDER=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(CONTRACT_ERROR_ROWS.map(r=>r.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(wireCode,envelope){if(typeof wireCode!="string")return;let key=wireCode.trim().toUpperCase();if(key.length!==0)for(let candidate of[envelope??"http_envelope",...ENVELOPE_LOOKUP_ORDER]){let row=BY_KEY.get(candidate+key);if(row)return row}}var CATEGORY_OF=/* @__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(code){return CATEGORY_OF[code]}function fromWire(wire){let contractRow=contractErrorFor(wire);if(contractRow)return contractRow.normalized;let upper=(wire??"").trim().toUpperCase(),canonical=upper.replace(/[^A-Z0-9]/g,"");if(canonical==="AUTHREJECTED")return"authRejected";if(upper.startsWith("AUTH"))return"authExpired";switch(canonical){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"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 AUTO_RETRYABLE_CODES=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(code){return AUTO_RETRYABLE_CODES.has(code)}var RETRYABLE_CONTRACT_CODES=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(code){return isAutoRetryable(code)||RETRYABLE_CONTRACT_CODES.has(code)}var BACKOFF_BASE_MS=500,BACKOFF_CAP_MS=8e3,MAX_RETRY_ATTEMPTS=4;function backoffDelayMs(attempt,rng=Math.random){let bounded=Math.max(0,attempt),ceiling=Math.min(BACKOFF_BASE_MS*2**bounded,BACKOFF_CAP_MS);return Math.floor(rng()*ceiling)}var ACCESS_DENIED_COPY="This feature isn't available on your account right now.",VALIDATION_FAILED_COPY="Something in that request was not right. Check the details and try again.",USER_FACING_COPY=/* @__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:ACCESS_DENIED_COPY,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:VALIDATION_FAILED_COPY,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:ACCESS_DENIED_COPY,runtimeDisposed:VALIDATION_FAILED_COPY,unknown:"Something went wrong. Please try again."}),SESSION_REVOKED_COPY="This session has ended. Please sign in again.",LINKED_ACCOUNT_READ_ONLY="linked_account_read_only";function displayFor(code,wireCode,reasonCode){return code==="conflict"&&reasonCode===LINKED_ACCOUNT_READ_ONLY?ACCESS_DENIED_COPY:(code==="authRejected"||code==="authExpired")&&typeof wireCode=="string"&&wireCode.trim().toLowerCase()==="session_revoked"?SESSION_REVOKED_COPY:userFacingError(code)}function userFacingError(code){return USER_FACING_COPY[code]}function defineHidden(target,key,value){Object.defineProperty(target,key,{value:value,enumerable:false,writable:false,configurable:false})}var REASON_CODE_SHAPE=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(code,opts){let row=contractErrorFor(opts?.wireCode,opts?.wireEnvelope),linkedReadOnly=code==="conflict"&&opts?.reasonCode===LINKED_ACCOUNT_READ_ONLY,error={code:code,category:categoryFor(code),retryable:opts?.retryable??(linkedReadOnly?false:isRetryableCode(code)),displayMessage:displayFor(code,opts?.wireCode,linkedReadOnly?LINKED_ACCOUNT_READ_ONLY:null)};opts?.httpStatus!==void 0&&(error.httpStatus=opts.httpStatus),opts?.requestId&&(error.requestId=opts.requestId),typeof opts?.reasonCode=="string"&&REASON_CODE_SHAPE.test(opts.reasonCode)&&(error.reasonCode=opts.reasonCode);let wait=opts?.retryAfterSeconds;if(typeof wait=="number"&&Number.isFinite(wait)&&wait>=0&&(error.retryAfterSeconds=Math.round(wait)),row);return opts?.wireMessage&&defineHidden(error,"wireMessage",opts.wireMessage),opts?.raw!==void 0&&opts.raw!==null&&defineHidden(error,"raw",opts.raw),/* @__PURE__ */Object.freeze(error)}function assertNever(x){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(x)}`)}function errorFrame(fields){/* @__PURE__ */
|
|
5
|
+
return Object.freeze({ok:false,error:error})}var EverfurConfigError=class _EverfurConfigError extends Error{constructor(kind,message){super(message),this.name="EverfurConfigError",this.kind=kind,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var EVERFUR_CONTEXT_SYMBOL=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),globalContextHost=globalThis,EverfurContext=globalContextHost[EVERFUR_CONTEXT_SYMBOL]??(globalContextHost[EVERFUR_CONTEXT_SYMBOL]=createContext(null));EverfurContext.displayName??="EverfurContext";function useEverfurContext(){let ctx=useContext(EverfurContext);if(ctx===null)throw new EverfurConfigError("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return ctx}var HEALTH_PLAN_EVENTS=/* @__PURE__ */Object.freeze({opened:"health_plan.opened",productClicked:"health_plan.product_clicked",checkoutStarted:"health_plan.checkout_started"});function useHealthPlanTelemetry(){return useContext(EverfurContext)?.runtime.registry.services.telemetry??noopTelemetry}var PlanPetContext=createContext(null);function HealthPlanPetScope({petRef:petRef,children:children}){return createElement(PlanPetContext.Provider,{value:petRef},children)}function useHealthPlanBarPet(dockPet){let page=useContext(PlanPetContext),ctx=useContext(EverfurContext);return page??dockPet??ctx?.activePet??null}function useHealthPlanOpened(drawn,petRef,plan){let telemetry=useHealthPlanTelemetry(),sent=useRef(null);useEffect(()=>{if(!drawn||petRef===null||sent.current===petRef)return;sent.current=petRef;let items=plan?.items??[];telemetry.track(HEALTH_PLAN_EVENTS.opened,{petRef:petRef,itemsCount:items.length,inPlanCount:items.filter(item=>item.inPlan).length})},[drawn,petRef,plan,telemetry])}function trackProductClicked(telemetry,petRef,productId,inPlan){telemetry.track(HEALTH_PLAN_EVENTS.productClicked,{petRef:petRef,productId:productId,inPlan:inPlan})}function trackCheckoutStarted(telemetry,petRef,cart){telemetry.track(HEALTH_PLAN_EVENTS.checkoutStarted,{petRef:petRef,itemsCount:cart.count,subtotal:cart.subtotal,currency:cart.currency})}var RETRYABILITY_ROWS=[{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:"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:"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:"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:"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:"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:"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}],CONTRACT_RETRYABILITY=/* @__PURE__ */Object.freeze(RETRYABILITY_ROWS.map(row=>/* @__PURE__ */Object.freeze(row)));/* @__PURE__ */Object.freeze(CONTRACT_RETRYABILITY.map(row=>row.wireCode));var NORMALIZED_FOLD=/* @__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",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"}),CONTRACT_ERROR_ROWS=/* @__PURE__ */Object.freeze(CONTRACT_RETRYABILITY.map(generated=>/* @__PURE__ */Object.freeze({wireCode:generated.wireCode,envelope:generated.envelope,retryable:generated.retryable,normalized:NORMALIZED_FOLD[generated.wireCode]}))),BY_KEY=new Map(CONTRACT_ERROR_ROWS.map(r=>[r.envelope+r.wireCode.toUpperCase(),r])),ENVELOPE_LOOKUP_ORDER=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(CONTRACT_ERROR_ROWS.map(r=>r.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(wireCode,envelope){if(typeof wireCode!="string")return;let key=wireCode.trim().toUpperCase();if(key.length!==0)for(let candidate of[envelope??"http_envelope",...ENVELOPE_LOOKUP_ORDER]){let row=BY_KEY.get(candidate+key);if(row)return row}}var CATEGORY_OF=/* @__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(code){return CATEGORY_OF[code]}function fromWire(wire){let contractRow=contractErrorFor(wire);if(contractRow)return contractRow.normalized;let upper=(wire??"").trim().toUpperCase(),canonical=upper.replace(/[^A-Z0-9]/g,"");if(canonical==="AUTHREJECTED")return"authRejected";if(upper.startsWith("AUTH"))return"authExpired";switch(canonical){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"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 AUTO_RETRYABLE_CODES=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(code){return AUTO_RETRYABLE_CODES.has(code)}var RETRYABLE_CONTRACT_CODES=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(code){return isAutoRetryable(code)||RETRYABLE_CONTRACT_CODES.has(code)}var BACKOFF_BASE_MS=500,BACKOFF_CAP_MS=8e3,MAX_RETRY_ATTEMPTS=4;function backoffDelayMs(attempt,rng=Math.random){let bounded=Math.max(0,attempt),ceiling=Math.min(BACKOFF_BASE_MS*2**bounded,BACKOFF_CAP_MS);return Math.floor(rng()*ceiling)}var ACCESS_DENIED_COPY="This feature isn't available on your account right now.",VALIDATION_FAILED_COPY="Something in that request was not right. Check the details and try again.",USER_FACING_COPY=/* @__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:ACCESS_DENIED_COPY,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:VALIDATION_FAILED_COPY,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:ACCESS_DENIED_COPY,runtimeDisposed:VALIDATION_FAILED_COPY,unknown:"Something went wrong. Please try again."}),SESSION_REVOKED_COPY="This session has ended. Please sign in again.",LINKED_ACCOUNT_READ_ONLY="linked_account_read_only";function displayFor(code,wireCode,reasonCode){return code==="conflict"&&reasonCode===LINKED_ACCOUNT_READ_ONLY?ACCESS_DENIED_COPY:(code==="authRejected"||code==="authExpired")&&typeof wireCode=="string"&&wireCode.trim().toLowerCase()==="session_revoked"?SESSION_REVOKED_COPY:userFacingError(code)}function userFacingError(code){return USER_FACING_COPY[code]}function defineHidden(target,key,value){Object.defineProperty(target,key,{value:value,enumerable:false,writable:false,configurable:false})}var REASON_CODE_SHAPE=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(code,opts){let row=contractErrorFor(opts?.wireCode,opts?.wireEnvelope),linkedReadOnly=code==="conflict"&&opts?.reasonCode===LINKED_ACCOUNT_READ_ONLY,error={code:code,category:categoryFor(code),retryable:opts?.retryable??(linkedReadOnly?false:isRetryableCode(code)),displayMessage:displayFor(code,opts?.wireCode,linkedReadOnly?LINKED_ACCOUNT_READ_ONLY:null)};opts?.httpStatus!==void 0&&(error.httpStatus=opts.httpStatus),opts?.requestId&&(error.requestId=opts.requestId),typeof opts?.reasonCode=="string"&&REASON_CODE_SHAPE.test(opts.reasonCode)&&(error.reasonCode=opts.reasonCode);let wait=opts?.retryAfterSeconds;if(typeof wait=="number"&&Number.isFinite(wait)&&wait>=0&&(error.retryAfterSeconds=Math.round(wait)),row);return opts?.wireMessage&&defineHidden(error,"wireMessage",opts.wireMessage),opts?.raw!==void 0&&opts.raw!==null&&defineHidden(error,"raw",opts.raw),/* @__PURE__ */Object.freeze(error)}function assertNever(x){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(x)}`)}function errorFrame(fields){/* @__PURE__ */
|
|
99
6
|
return Object.freeze({kind:"error",terminal:true,code:fields.code,retryable:fields.retryable,wireMessage:fields.wireMessage,synthesized:fields.synthesized,lastEventId:fields.lastEventId,serverRequestId:null})}function mintFailedError(cause,refusal){let message=cause instanceof Error?cause.message:typeof cause=="string"?cause:null;return makeEverfurError("authRejected",{retryable:false,...refusal?.wireCode?{wireCode:refusal.wireCode}:{},...refusal?.requestId?{requestId:refusal.requestId}:{},...message?{wireMessage:message}:{},...cause!=null?{raw:cause}:{}})}function authHeaders(auth){let headers={};return auth.mode==="personalized"?headers.authorization=`Bearer ${auth.token}`:headers["x-everfur-partner-key"]=auth.publishableKey,auth.userRef&&(headers["x-everfur-user-ref"]=auth.userRef),auth.sessionId&&(headers["x-everfur-session-id"]=auth.sessionId),headers}function withAuthHeaders(req,auth){return{...req,headers:{...stripAuthHeaders(req.headers),...authHeaders(auth)}}}function stripAuthHeaders(headers){if(!headers)return{};let out={};for(let[key,value]of Object.entries(headers)){let lower=key.toLowerCase();lower==="authorization"||lower==="x-everfur-partner-key"||(out[key]=value)}return out}async function authedSend(req,ctx){if(ctx.mode==="anonymous")return ctx.transport.request(withAuthHeaders(req,{mode:"anonymous",publishableKey:ctx.publishableKey,userRef:ctx.userRef,...ctx.sessionId?{sessionId:ctx.sessionId}:{}}));let token;try{token=await ctx.identity.currentToken()}catch(cause){return ctx.identity.reportRejected?.(),err(mintFailedError(cause))}let first=await ctx.transport.request(withAuthHeaders(req,{mode:"personalized",token:token,userRef:ctx.userRef,...ctx.sessionId?{sessionId:ctx.sessionId}:{}}));if(first.ok||first.error.httpStatus!==401)return first;let refreshed;try{refreshed=await ctx.identity.currentToken({forceRefresh:!0})}catch(cause){return ctx.identity.reportRejected?.(),err(mintFailedError(cause,{wireCode:wireCodeOf(first.error.raw),requestId:first.error.requestId}))}let retry=await ctx.transport.request(withAuthHeaders(req,{mode:"personalized",token:refreshed,userRef:ctx.userRef,...ctx.sessionId?{sessionId:ctx.sessionId}:{}}));return!retry.ok&&retry.error.httpStatus===401?(ctx.identity.reportRejected?.(),err(refusedAfterRemintError(retry.error))):retry}function refusedAfterRemintError(refusal){let raw=refusal.raw,wireCode=wireCodeOf(raw);return makeEverfurError("authRejected",{retryable:false,...refusal.httpStatus!==void 0?{httpStatus:refusal.httpStatus}:{},...refusal.requestId?{requestId:refusal.requestId}:{},...wireCode?{wireCode:wireCode}:{},...refusal.reasonCode?{reasonCode:refusal.reasonCode}:{},...refusal.wireMessage?{wireMessage:refusal.wireMessage}:{},...raw!=null?{raw:raw}:{}})}function wireCodeOf(body){if(typeof body!="object"||body===null)return null;let b=body,code=(typeof b.error=="object"&&b.error!==null?b.error.code:void 0)??b.code;return typeof code=="string"&&code.length>0?code:null}function parseUrl(raw,base3){let Url=globalThis.URL;if(typeof Url=="function"){let url;try{url=base3===void 0?new Url(raw):new Url(raw,base3)}catch{return null}try{if(url.protocol)return url}catch{}}return parseByPattern(raw)}var WHOLE_URL=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,REWRITTEN_BY_STANDARD_PARSER=/[\s\u0000-\u001f\u007f\\]/,DEFAULT_PORTS={"http:":"80","https:":"443"};function parseByPattern(raw,base3){let input=raw.trim();let match=REWRITTEN_BY_STANDARD_PARSER.test(input)?null:WHOLE_URL.exec(input);if(match===null)return null;let[,scheme="",username="",password="",host="",portText="",path="",query="",fragment=""]=match,protocol=`${scheme.toLowerCase()}:`,portNumber=Number(portText);if(portNumber>65535)return null;let port=portText===""||String(portNumber)===DEFAULT_PORTS[protocol]?"":String(portNumber),special=DEFAULT_PORTS[protocol]!==void 0,hostPort=host.toLowerCase()+(port&&`:${port}`),pathname=path||(special?"/":""),credentials=username||password?`${username}${password&&`:${password}`}@`:"";return{href:`${protocol}//${credentials}${hostPort}${pathname}${query}${fragment}`,protocol:protocol,username:username,password:password,hostname:host.toLowerCase(),port:port,origin:special?`${protocol}//${hostPort}`:"null",pathname:pathname,search:query==="?"?"":query,hash:fragment==="#"?"":fragment}}function networkError(cause){return makeEverfurError("internalError",{retryable:true,wireMessage:describeCause(cause)})}function describeCause(cause){return cause instanceof Error?cause.message:typeof cause=="string"?cause:"network request failed"}var FUNNEL_UNARY_TIMEOUT_MS=3e4,RETRY_OVERRIDE_MAX_MS=BACKOFF_CAP_MS*2,IDEMPOTENCY_HEADER="idempotency-key",MUTATING_METHODS=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),NOOP_OBSERVER=/* @__PURE__ */Object.freeze({onEvent(){}}),defaultFunnelTimers=/* @__PURE__ */Object.freeze({setTimeout:(handler,ms)=>setTimeout(handler,ms),clearTimeout:handle=>clearTimeout(handle),now:()=>Date.now()});function seededIdempotencyKey(seed){let safe=seed.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return safe.length===0?null:`efs_${safe}`.slice(0,128)}function createRequestFunnel(deps){let observer=deps.observer??NOOP_OBSERVER,timers=deps.timers??defaultFunnelTimers,rng=deps.rng??Math.random,sleep=deps.sleep??((ms,signal)=>delayAbortable(ms,timers,signal)),ceiling=deps.maxAttempts??MAX_RETRY_ATTEMPTS,timeoutMs=deps.unaryTimeoutMs??FUNNEL_UNARY_TIMEOUT_MS,mintKey=deps.newIdempotencyKey??defaultIdempotencyKeyFactory(),emit=event=>{try{observer.onEvent(event)}catch{}};async function send(call,req,opts){let perCallMaxAttempts=opts?.maxAttempts,maxAttempts=Math.max(1,perCallMaxAttempts??ceiling),idempotent=opts?.idempotent??MUTATING_METHODS.has(req.method),seeded=opts?.idempotencyKey===void 0?null:seededIdempotencyKey(opts.idempotencyKey),idempotencyKey=idempotent?seeded??mintKey():null,base3=assembleHeaders(req,idempotencyKey),attempt=0;for(;;){let stamp=extra=>/* @__PURE__ */Object.freeze({call:call,method:req.method,path:req.path,attempt:attempt,...idempotencyKey?{idempotencyKey:idempotencyKey}:{},...extra});emit(stamp({phase:"attempt"}));let deadline=boundedSignal(timeoutMs,timers),merged=mergeSignals(deadline.signal,req.signal),settled;try{settled=await authedSend({...base3,signal:merged.signal},deps.auth)}catch(cause){settled=err(networkError(cause))}finally{merged.dispose(),deadline.cancel()}if(settled.ok)return emit(stamp({phase:"settled",ok:true,reason:"ok"})),settled;let error=settled.error,decision=decideRetry(error,attempt,{maxAttempts:maxAttempts,rng:rng,now:timers.now(),aborted:req.signal?.aborted===true,...perCallMaxAttempts!==void 0?{perCallMaxAttempts:perCallMaxAttempts}:{},...deps.errorPolicy!==void 0?{policy:deps.errorPolicy}:{}}),settledEvent={ok:false,code:error.code,reason:decision.reason,...error.httpStatus!==void 0?{httpStatus:error.httpStatus}:{},...error.requestId!==void 0?{requestId:error.requestId}:{}};if(!decision.retry)return emit(stamp({phase:"settled",...settledEvent})),err(error);if(emit(stamp({phase:"retry",...settledEvent,delayMs:decision.delayMs})),await sleep(decision.delayMs,req.signal),req.signal?.aborted===true)return emit(stamp({phase:"settled",...settledEvent,reason:"aborted"})),err(error);attempt+=1}}async function authorize(req){return withAuthHeaders(req,await resolveDeviceAuth(deps.auth))}async function*stream(call,req,signal){emit(
|
|
100
7
|
/* @__PURE__ */Object.freeze({call:call,phase:"stream.open",method:req.method,path:req.path,attempt:0}));try{yield*deps.auth.transport.stream(req,signal)}catch{yield errorFrame({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}}/* @__PURE__ */
|
|
101
8
|
return Object.freeze({send:send,authorize:authorize,stream:stream})}function assembleHeaders(req,idempotencyKey){let headers={};for(let[key,value]of Object.entries(req.headers??{}))key.toLowerCase()!==IDEMPOTENCY_HEADER&&(headers[key]=value);return idempotencyKey!==null&&(headers["Idempotency-Key"]=idempotencyKey),{...req,headers:headers}}function defaultIdempotencyKeyFactory(){let counter=0;return()=>`efk_${Date.now().toString(36)}_${(counter++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var POLICY_MAX_ATTEMPTS_CAP=10;function decideRetry(error,attempt,ctx){if(ctx.aborted)return{retry:false,reason:"aborted"};let throttle=throttleKind(error);if(throttle==="quota")return{retry:false,reason:"daily-quota-exhausted"};if(throttle!=="burst"&&!isAutoRetryable(error.code))return{retry:false,reason:"terminal-code"};let reason=throttle==="burst"?"burst-throttle":"retryable-code";if((()=>{if(ctx.policy===void 0)return false;try{return!ctx.policy.shouldRetry(error.code,attempt)}catch{return false}})())return{retry:false,reason:"terminal-code"};let policyCeiling=()=>{if(ctx.policy===void 0)return null;let raw;try{raw=ctx.policy.maxAttempts(error.code)}catch{return null}return typeof raw!="number"||!Number.isFinite(raw)?null:Math.max(1,Math.min(POLICY_MAX_ATTEMPTS_CAP,Math.floor(raw)))},ceiling=ctx.perCallMaxAttempts??policyCeiling()??ctx.maxAttempts;if(attempt+1>=ceiling)return{retry:false,reason:"attempts-exhausted"};let override=retryOverrideMs(error,ctx.now);return override!==null?override>RETRY_OVERRIDE_MAX_MS?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:reason,delayMs:override}:{retry:true,reason:reason,delayMs:backoffDelayMs(attempt,ctx.rng)}}function throttleKind(error){let code=error.code==="unknown"?fromWire(rawWireCode(error.raw)):error.code;return code==="quotaExceeded"?"quota":code==="rateLimited"||error.httpStatus===429?"burst":null}function retryOverrideMs(error,now){let at=findResetsAt(error.raw);if(at!==null){let delta=at-now;return delta>0?delta:0}let wait=findRetryAfterSeconds(error.raw);return wait===null?null:Math.round(wait*1e3)}function findRetryAfterSeconds(raw){for(let scope of candidateScopes(raw)){let value=scope.retry_after_seconds;if(typeof value=="number"&&Number.isFinite(value)&&value>=0)return value}return null}function findResetsAt(raw){for(let scope of candidateScopes(raw)){let value=scope.resets_at,parsed=parseInstantMs(value);if(parsed!==null)return parsed}return null}function candidateScopes(raw){if(!isRecord(raw))return[];let out=[raw];for(let nested of["error","detail"]){let value=raw[nested];isRecord(value)&&out.push(value)}return out}function parseInstantMs(value){if(typeof value=="number"&&Number.isFinite(value))return value<1e11?Math.round(value*1e3):Math.round(value);if(typeof value=="string"&&value.trim().length>0){let parsed=Date.parse(value);return Number.isFinite(parsed)?parsed:null}return null}function rawWireCode(raw){for(let scope of candidateScopes(raw)){let code=scope.code;if(typeof code=="string"&&code.length>0)return code}return null}function isRecord(value){return typeof value=="object"&&value!==null}async function resolveDeviceAuth(auth){return auth.mode==="anonymous"?{mode:"anonymous",publishableKey:auth.publishableKey,userRef:auth.userRef,...auth.sessionId?{sessionId:auth.sessionId}:{}}:{mode:"personalized",token:await auth.identity.currentToken(),userRef:auth.userRef,...auth.sessionId?{sessionId:auth.sessionId}:{}}}function boundedSignal(ms,timers){let ctrl=new AbortController,handle=timers.setTimeout(()=>ctrl.abort(),ms);return{signal:ctrl.signal,cancel:()=>timers.clearTimeout(handle)}}function mergeSignals(deadline,caller){let noop2=()=>{};if(!caller)return{signal:deadline,dispose:noop2};let ctrl=new AbortController;if(deadline.aborted||caller.aborted)return ctrl.abort(),{signal:ctrl.signal,dispose:noop2};let onAbort=()=>ctrl.abort();return deadline.addEventListener("abort",onAbort,{once:true}),caller.addEventListener("abort",onAbort,{once:true}),{signal:ctrl.signal,dispose:()=>{deadline.removeEventListener("abort",onAbort),caller.removeEventListener("abort",onAbort)}}}function delayAbortable(ms,timers,signal){return ms<=0||signal?.aborted===true?Promise.resolve():new Promise(resolve=>{let handle=timers.setTimeout(()=>{signal?.removeEventListener("abort",onAbort),resolve()},ms),onAbort=()=>{timers.clearTimeout(handle),resolve()};signal?.addEventListener("abort",onAbort,{once:true})})}function isNotFoundError(error){return error!=null&&(error.httpStatus===404||error.category==="notFound")}function plainNotFound(error){return error.code!=="conversationNotFound"?error:makeEverfurError("resourceNotFound",{retryable:false,...error.httpStatus===void 0?{}:{httpStatus:error.httpStatus},...error.requestId===void 0?{}:{requestId:error.requestId},...error.reasonCode===void 0?{}:{reasonCode:error.reasonCode},...error.wireMessage===void 0?{}:{wireMessage:error.wireMessage},...error.raw===void 0?{}:{raw:error.raw}})}function plainResult(res){return res.ok?res:err(plainNotFound(res.error))}function withPlainNotFound(funnel){return{send:async(...args)=>plainResult(await funnel.send(...args)),authorize:req=>funnel.authorize(req),stream:(call,req,signal)=>funnel.stream(call,req,signal)}}var HEALTH_PLAN_REASON_KINDS=/* @__PURE__ */Object.freeze(["dna","records","inside","profile"]),REF_MAX=128;function invalid(wireMessage){return makeEverfurError("validationFailed",{retryable:false,wireMessage:wireMessage})}function disposed(verb){return makeEverfurError("runtimeDisposed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${verb} was called after unmount`})}function malformed(call){return makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:`${call}: the response carried no plan`})}var str=(value,max=4e3)=>typeof value=="string"&&value.trim().length>0&&value.length<=max?value.trim():null;function httpsUrl(value){let s=str(value,2048);return s===null?null:/^https:\/\/[^\s]+$/i.test(s)?s:null}function priceOf(value){let n=typeof value=="number"?value:typeof value=="string"&&/^\d+(\.\d+)?$/.test(value.trim())?Number(value):Number.NaN;return Number.isFinite(n)&&n>=0?n:null}function currencyOf(value){return typeof value=="string"&&/^[A-Za-z]{3}$/.test(value)?value.toUpperCase():null}function reasonsOf(value){if(!Array.isArray(value))/* @__PURE__ */return Object.freeze([]);let out=[];for(let raw of value){if(raw===null||typeof raw!="object")continue;let o=raw,text2=str(o.text,1e3);if(text2===null)continue;let kind=typeof o.kind=="string"&&HEALTH_PLAN_REASON_KINDS.includes(o.kind)?o.kind:"profile";out.push(/* @__PURE__ */Object.freeze({kind:kind,text:text2}))}/* @__PURE__ */
|