@everfur/sdk 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/README.md +2 -2
  2. package/dist/{Chat.d-qQVN6VLp.d.ts → Chat.d-BCfyvzX8.d.ts} +1 -1
  3. package/dist/{Chat.d-Bl-_TsvQ.d.cts → Chat.d-Od44h51D.d.cts} +1 -1
  4. package/dist/{DepthViews.d-PmjccZLr.d.cts → DepthViews.d-BGspxovy.d.cts} +1 -1
  5. package/dist/{DepthViews.d-aOChkwU2.d.ts → DepthViews.d-BIHVrf9r.d.ts} +1 -1
  6. package/dist/{DepthViews.d-ktxIIsnb.d.cts → DepthViews.d-BaLh7Lsi.d.cts} +1 -1
  7. package/dist/{DepthViews.d-CpF_Y_z9.d.ts → DepthViews.d-CEVk9poG.d.ts} +1 -1
  8. package/dist/ErrorPolicyPort.d-BIdmYQnk.d.cts +43 -0
  9. package/dist/ErrorPolicyPort.d-BnI5qWg4.d.ts +43 -0
  10. package/dist/{RecordsPage.d-BfMSOsg_.d.ts → RecordsPage.d-D10RIgdc.d.ts} +1 -1
  11. package/dist/{RecordsPage.d-DWjFpZs1.d.cts → RecordsPage.d-DbhYNSbq.d.cts} +1 -1
  12. package/dist/animations/index.d.cts +3 -3
  13. package/dist/animations/index.d.ts +3 -3
  14. package/dist/{attachments.d-DOmkQ_8O.d.ts → attachments.d-BlukNfIf.d.ts} +1 -1
  15. package/dist/{attachments.d-DBlHzWYy.d.cts → attachments.d-CF4lLuGK.d.cts} +1 -1
  16. package/dist/{bookingCopy.d-ITpabqPr.d.ts → bookingCopy.d-BuDv16WP.d.ts} +12 -12
  17. package/dist/{bookingCopy.d-B39JAmIZ.d.cts → bookingCopy.d-rnBSqOSN.d.cts} +12 -12
  18. package/dist/{callCopy.d-Bw6oZT54.d.cts → callCopy.d-BQxpwXqT.d.cts} +3 -3
  19. package/dist/{callCopy.d-Bw6oZT54.d.ts → callCopy.d-BQxpwXqT.d.ts} +3 -3
  20. package/dist/{callRoom.d-B1DoYdJe.d.cts → callRoom.d-9Dm7XnUr.d.cts} +1 -1
  21. package/dist/{callRoom.d-Dqm1rUqT.d.ts → callRoom.d-t-khijDv.d.ts} +1 -1
  22. package/dist/{casesRepository.d-De4ZtgJ_.d.cts → casesRepository.d-CVuKTkJo.d.cts} +1 -1
  23. package/dist/{casesRepository.d-DsEeFd0F.d.ts → casesRepository.d-Dn1fK1b2.d.ts} +1 -1
  24. package/dist/chat/index.cjs +21 -21
  25. package/dist/chat/index.d.cts +12 -12
  26. package/dist/chat/index.d.ts +12 -12
  27. package/dist/chat/index.js +21 -21
  28. package/dist/chat/lite/index.cjs +21 -21
  29. package/dist/chat/lite/index.d.cts +12 -12
  30. package/dist/chat/lite/index.d.ts +12 -12
  31. package/dist/chat/lite/index.js +21 -21
  32. package/dist/{chatHandoffToken.d-B4-iQ35P.d.cts → chatHandoffToken.d-BjfmIxXk.d.cts} +6 -6
  33. package/dist/{chatHandoffToken.d-Br3Gw3w-.d.ts → chatHandoffToken.d-CFiI6IMc.d.ts} +6 -6
  34. package/dist/{checkin.d-CAKQydg8.d.cts → checkin.d-BP3ZWBfX.d.cts} +5 -5
  35. package/dist/{checkin.d-qvYXugN3.d.ts → checkin.d-CokpahFL.d.ts} +5 -5
  36. package/dist/{chunk-PJHMKQ5C.js → chunk-4KFFE42Z.js} +19 -19
  37. package/dist/{chunk-7MMJ7CYN.js → chunk-6IHY7HS7.js} +1 -1
  38. package/dist/{chunk-6I4REU4U.js → chunk-BMYNDBUR.js} +1 -1
  39. package/dist/{chunk-5OK2AF63.js → chunk-HHCGXQJR.js} +19 -19
  40. package/dist/client/index.cjs +31 -31
  41. package/dist/client/index.d.cts +19 -16
  42. package/dist/client/index.d.ts +19 -16
  43. package/dist/client/index.js +30 -30
  44. package/dist/{clinicBatch.d-B3YJc8IO.d.cts → clinicBatch.d-C0xx5L4j.d.cts} +3 -3
  45. package/dist/{clinicBatch.d-DhvQuPHV.d.ts → clinicBatch.d-DNi4UURs.d.ts} +3 -3
  46. package/dist/{config.d-DRoQ2lAx.d.ts → config.d-B7Z-KTGq.d.ts} +10 -2
  47. package/dist/{config.d-BiVy0fLx.d.cts → config.d-ClAI2RZ6.d.cts} +10 -2
  48. package/dist/consent/index.d.cts +6 -6
  49. package/dist/consent/index.d.ts +6 -6
  50. package/dist/{context.d-DZfxKxNi.d.cts → context.d-Bj6-xYPA.d.cts} +11 -5
  51. package/dist/{context.d-FjU7dQP7.d.ts → context.d-DS1GXUEY.d.ts} +11 -5
  52. package/dist/{copy.d-Ce_8KuZg.d.cts → copy.d--F5A9cXK.d.cts} +3 -3
  53. package/dist/{copy.d-BP36f_63.d.ts → copy.d-DmxuFJFe.d.ts} +3 -3
  54. package/dist/core/index.cjs +41 -40
  55. package/dist/core/index.d.cts +16 -16
  56. package/dist/core/index.d.ts +16 -16
  57. package/dist/core/index.js +41 -40
  58. package/dist/{depth.d-DzMMmRN4.d.ts → depth.d-CgzYE6_n.d.ts} +3 -3
  59. package/dist/{depth.d-BtlcIqPJ.d.cts → depth.d-DLaP0o8Y.d.cts} +3 -3
  60. package/dist/{entitlementRepository.d-BltqS1W8.d.ts → entitlementRepository.d-CkUTlVAb.d.ts} +2 -2
  61. package/dist/{entitlementRepository.d-wfqpUIKN.d.cts → entitlementRepository.d-DVTp-BB9.d.cts} +2 -2
  62. package/dist/{focus.d-BX7oahFk.d.cts → focus.d-CLTjm6In.d.cts} +1 -1
  63. package/dist/{focus.d-armXecf0.d.ts → focus.d-u-HYvim0.d.ts} +1 -1
  64. package/dist/health-plan/index.d.cts +15 -15
  65. package/dist/health-plan/index.d.ts +15 -15
  66. package/dist/{healthPlanRepository.d-DBx7-NLE.d.cts → healthPlanRepository.d-B22kjrYa.d.cts} +3 -3
  67. package/dist/{healthPlanRepository.d-C7K9dJK5.d.ts → healthPlanRepository.d-CwRXeoM7.d.ts} +3 -3
  68. package/dist/{idempotency.d-Dak2-pON.d.cts → idempotency.d-CFVMhWcv.d.cts} +1 -1
  69. package/dist/{idempotency.d-symqJ8Tt.d.ts → idempotency.d-dOFfV91-.d.ts} +1 -1
  70. package/dist/{identity.d-DOKJFaiz.d.ts → identity.d-D4VtpqRr.d.ts} +1 -1
  71. package/dist/{identity.d-DIH9h3Le.d.cts → identity.d-DDpXOtas.d.cts} +1 -1
  72. package/dist/{inbox.d-AuGKeaZv.d.cts → inbox.d-CPcMMz-Y.d.cts} +2 -2
  73. package/dist/{inbox.d-B5b57OXc.d.ts → inbox.d-DJ9xgU1Z.d.ts} +2 -2
  74. package/dist/index.cjs +246 -245
  75. package/dist/index.d.cts +17 -17
  76. package/dist/index.d.ts +17 -17
  77. package/dist/index.js +244 -243
  78. package/dist/{introEvents.d-ehik7PEn.d.cts → introEvents.d-B7acmGwf.d.cts} +1 -1
  79. package/dist/{introEvents.d-S4Q4BOSt.d.ts → introEvents.d-DW3gLljE.d.ts} +1 -1
  80. package/dist/{layout.d-Bm2_1wa4.d.ts → layout.d-C8y_ki1V.d.ts} +1 -1
  81. package/dist/{layout.d-CFF-nBXf.d.cts → layout.d-DfaFM_lp.d.cts} +1 -1
  82. package/dist/{models.d-DOwpK1ZF.d.ts → models.d-BKmOfoqV.d.cts} +2 -2
  83. package/dist/{models.d-Su_BBBTW.d.cts → models.d-BULqCO2R.d.ts} +2 -2
  84. package/dist/notifications/inbox/index.d.cts +7 -7
  85. package/dist/notifications/inbox/index.d.ts +7 -7
  86. package/dist/notifications/index.d.cts +8 -8
  87. package/dist/notifications/index.d.ts +8 -8
  88. package/dist/{optInView.d-DbGx1A9R.d.cts → optInView.d-ByDJMrMv.d.cts} +13 -13
  89. package/dist/{optInView.d-xnIxCLlH.d.ts → optInView.d-DVshLxbD.d.ts} +13 -13
  90. package/dist/{parse.d-DtHmpAMT.d.cts → parse.d-BDZ7ffgj.d.cts} +4 -1
  91. package/dist/{parse.d-DtHmpAMT.d.ts → parse.d-BDZ7ffgj.d.ts} +4 -1
  92. package/dist/{pets.d-BEqKykpu.d.ts → pets.d-BpLObpfM.d.ts} +1 -1
  93. package/dist/{pets.d-BS6sLxY-.d.cts → pets.d-DXhzTNuI.d.cts} +1 -1
  94. package/dist/{petsRepository.d-iHrHkXM2.d.ts → petsRepository.d-_QfM7F6T.d.ts} +1 -1
  95. package/dist/{petsRepository.d-DB5CNKsK.d.cts → petsRepository.d-ai_tZ3lu.d.cts} +1 -1
  96. package/dist/records/depth/index.d.cts +10 -10
  97. package/dist/records/depth/index.d.ts +10 -10
  98. package/dist/records/index.cjs +1 -1
  99. package/dist/records/index.d.cts +11 -11
  100. package/dist/records/index.d.ts +11 -11
  101. package/dist/records/index.js +1 -1
  102. package/dist/{requestFunnel.d-SySe6xHp.d.cts → requestFunnel.d-BwZDfWVD.d.cts} +3 -3
  103. package/dist/{requestFunnel.d-CehftayS.d.ts → requestFunnel.d-DKBPTpsy.d.ts} +3 -3
  104. package/dist/{route.d-DSSSpSB-.d.cts → route.d-DCzQh4ix.d.cts} +3 -3
  105. package/dist/{route.d-B395-hNX.d.ts → route.d-DSYEd2MR.d.ts} +3 -3
  106. package/dist/{runtimeTypes.d-DAz0Tgw5.d.ts → runtimeTypes.d-BzUig75K.d.ts} +11 -7
  107. package/dist/{runtimeTypes.d-DPh1Wh15.d.cts → runtimeTypes.d-CL4l7ta4.d.cts} +11 -7
  108. package/dist/{screenProps.d-Bd2yphad.d.cts → screenProps.d-6xmE1C-V.d.cts} +2 -2
  109. package/dist/{screenProps.d-D9Vi-Afl.d.ts → screenProps.d-fHBKArt_.d.ts} +2 -2
  110. package/dist/{sdkConfigStore.d-VPvsIL8E.d.ts → sdkConfigStore.d-BNCVVEWC.d.ts} +1 -1
  111. package/dist/{sdkConfigStore.d-BHrzkVpP.d.cts → sdkConfigStore.d-C2BAr9kI.d.cts} +1 -1
  112. package/dist/server/events/index.cjs +4 -4
  113. package/dist/server/events/index.d.cts +2 -2
  114. package/dist/server/events/index.d.ts +2 -2
  115. package/dist/server/events/index.js +4 -4
  116. package/dist/server/index.cjs +9 -9
  117. package/dist/server/index.d.cts +3 -3
  118. package/dist/server/index.d.ts +3 -3
  119. package/dist/server/index.js +9 -9
  120. package/dist/shop/index.d.cts +3 -3
  121. package/dist/shop/index.d.ts +3 -3
  122. package/dist/slots/index.d.cts +6 -6
  123. package/dist/slots/index.d.ts +6 -6
  124. package/dist/tabs/index.cjs +87 -84
  125. package/dist/tabs/index.d.cts +15 -15
  126. package/dist/tabs/index.d.ts +15 -15
  127. package/dist/tabs/index.js +95 -92
  128. package/dist/televet/booking/index.cjs +75 -75
  129. package/dist/televet/booking/index.d.cts +8 -8
  130. package/dist/televet/booking/index.d.ts +8 -8
  131. package/dist/televet/booking/index.js +3 -3
  132. package/dist/televet/call/index.d.cts +2 -2
  133. package/dist/televet/call/index.d.ts +2 -2
  134. package/dist/testing/index.d.cts +1 -1
  135. package/dist/testing/index.d.ts +1 -1
  136. package/dist/testing/rn/index.d.cts +10 -10
  137. package/dist/testing/rn/index.d.ts +10 -10
  138. package/dist/testing/web/index.d.cts +10 -10
  139. package/dist/testing/web/index.d.ts +10 -10
  140. package/dist/texting/index.d.cts +6 -6
  141. package/dist/texting/index.d.ts +6 -6
  142. package/dist/{threadOptions.d-bEAFkIsC.d.cts → threadOptions.d-Bqy5d5Fx.d.cts} +1 -1
  143. package/dist/{threadOptions.d-U5YBUKM-.d.ts → threadOptions.d-DOEIpk1t.d.ts} +1 -1
  144. package/dist/{threadOptions.d-DUQxxHyM.d.cts → threadOptions.d-Dc57dm7h.d.cts} +5 -5
  145. package/dist/{threadOptions.d-DnM9UcMx.d.ts → threadOptions.d-NSlFx-Lp.d.ts} +5 -5
  146. package/dist/{timelineRows.d-DXppCSCg.d.cts → timelineRows.d-7w8NsNi4.d.cts} +1 -1
  147. package/dist/{timelineRows.d-9Uhf4q5d.d.ts → timelineRows.d-CthNM5hV.d.ts} +1 -1
  148. package/dist/{useHealthPlanSubscription.d-CRBPMlsc.d.ts → useHealthPlanSubscription.d-CV7M21HS.d.ts} +3 -3
  149. package/dist/{useHealthPlanSubscription.d-DfjTYv1u.d.cts → useHealthPlanSubscription.d-SA9-SuKe.d.cts} +3 -3
  150. package/dist/{useInboxUnread.d-CP3KwSkn.d.ts → useInboxUnread.d-CXiaR3BZ.d.ts} +1 -1
  151. package/dist/{useInboxUnread.d-DiE_NbtS.d.cts → useInboxUnread.d-DERpMelw.d.cts} +1 -1
  152. package/dist/{usePresentation.d-DUYzYXgA.d.cts → usePresentation.d-BJzFicRQ.d.cts} +2 -2
  153. package/dist/{usePresentation.d-Buxz2Jkt.d.ts → usePresentation.d-DgSGIWS-.d.ts} +2 -2
  154. package/dist/{useRecordsDepth.d-l6D0ZS4l.d.cts → useRecordsDepth.d-C9W45gwS.d.cts} +1 -1
  155. package/dist/{useRecordsDepth.d-DG2GiAyt.d.ts → useRecordsDepth.d-ZX2rhcUx.d.ts} +1 -1
  156. package/dist/{useUnread.d-B6Ehu0ao.d.ts → useUnread.d-CedFK4k6.d.ts} +4 -4
  157. package/dist/{useUnread.d-7-cuCooM.d.cts → useUnread.d-DST1GMmL.d.cts} +4 -4
  158. package/dist/{view.d-ufGX_MKK.d.cts → view.d-3lxzyJlL.d.cts} +6 -6
  159. package/dist/{view.d-iTInze7B.d.ts → view.d-DRiYNQJ8.d.ts} +6 -6
  160. package/dist/web/consent/index.d.cts +6 -6
  161. package/dist/web/consent/index.d.ts +6 -6
  162. package/dist/web/health-plan/index.cjs +1 -1
  163. package/dist/web/health-plan/index.d.cts +16 -16
  164. package/dist/web/health-plan/index.d.ts +16 -16
  165. package/dist/web/health-plan/index.js +1 -1
  166. package/dist/web/inbox/index.d.cts +9 -8
  167. package/dist/web/inbox/index.d.ts +9 -8
  168. package/dist/web/index.cjs +191 -190
  169. package/dist/web/index.d.cts +28 -28
  170. package/dist/web/index.d.ts +28 -28
  171. package/dist/web/index.js +191 -190
  172. package/dist/web/intro/index.d.cts +8 -8
  173. package/dist/web/intro/index.d.ts +8 -8
  174. package/dist/web/notifications/index.d.cts +7 -7
  175. package/dist/web/notifications/index.d.ts +7 -7
  176. package/dist/web/records/depth/index.d.cts +10 -10
  177. package/dist/web/records/depth/index.d.ts +10 -10
  178. package/dist/web/records/index.d.cts +13 -13
  179. package/dist/web/records/index.d.ts +13 -13
  180. package/dist/web/records-sheet/index.cjs +1 -1
  181. package/dist/web/records-sheet/index.js +1 -1
  182. package/dist/web/shop/index.cjs +1 -1
  183. package/dist/web/shop/index.d.cts +3 -3
  184. package/dist/web/shop/index.d.ts +3 -3
  185. package/dist/web/shop/index.js +1 -1
  186. package/dist/web/televet/booking/index.cjs +6 -6
  187. package/dist/web/televet/booking/index.d.cts +9 -9
  188. package/dist/web/televet/booking/index.d.ts +9 -9
  189. package/dist/web/televet/booking/index.js +6 -6
  190. package/dist/web/televet/call/index.cjs +1 -1
  191. package/dist/web/televet/call/index.d.cts +2 -2
  192. package/dist/web/televet/call/index.d.ts +2 -2
  193. package/dist/web/televet/call/index.js +1 -1
  194. package/dist/web/texting/index.d.cts +6 -6
  195. package/dist/web/texting/index.d.ts +6 -6
  196. package/dist/web/ui/index.cjs +1 -1
  197. package/dist/web/ui/index.js +33 -33
  198. package/package.json +1 -32
  199. package/dist/ErrorPolicyPort.d-68yrE3BE.d.ts +0 -23
  200. package/dist/ErrorPolicyPort.d-DirW9hgO.d.cts +0 -23
@@ -1,12 +1,12 @@
1
1
  /*! @everfur/sdk. Copyright (c) 2026 Strand Health Inc. dba Everfur. All rights reserved. Use is subject to the Everfur SDK License: https://docs.everfur.com/license */
2
2
  "use strict";function ok(e,t){/* @__PURE__ */
3
3
  return Object.freeze({ok:true,value:e})}function err(e){/* @__PURE__ */
4
- return Object.freeze({ok:false,error:e})}var e=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var t=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/;var r="1.4.1";var n="react-native",a="2026-09-19",i="EVERFUR_API_BASE_URL";function o(e,t){/* @__PURE__ */
5
- return Object.freeze({ok:false,failure:/* @__PURE__ */Object.freeze({reason:e,message:t})})}function tryResolveApiBaseUrl(e){let t=e?.trim(),r=t&&t.length>0?t:f(i);return r?p(r):o("missing-api-base-url",`apiBaseUrl is required: pass config.apiBaseUrl or set ${i}. The SDK never ships a hardcoded host.`)}function resolveApiBaseUrl(t){let r=tryResolveApiBaseUrl(t);if(!r.ok)throw new e("invalid-argument",r.failure.message);return r.value}function buildBaseHeaders(e){return{"X-Everfur-SDK-Version":e.sdkVersion,"X-Everfur-SDK-Platform":e.platform,"X-Everfur-Contract":e.contractVersion}}function l(e){return e.slice(e.lastIndexOf("@")+1).replace(/:\d+$/,"").toLowerCase()}function s(e){return e.length===0||e.includes("@")?false:e.startsWith("[")&&e.endsWith("]")?true:!e.includes(":")}function u(e,t){let r=e.indexOf("://");return r<0||e.slice(r+3).includes("@")?false:s(t)}function d(e,t){return`${e}://${t}`}function p(e){let r=e.trim(),n=t.exec(r);if(n===null||n[2]===void 0||n[2].length===0)return o("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let a=(n[1]??"").toLowerCase(),i=l(n[2]);if(i.length===0)return o("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let s=u(r,i)?`: ${d(a,i)}`:"";if(a!=="https"){if(!(a==="http"&&c(i)))return a==="http"?o("insecure-api-base-url",`apiBaseUrl must use https (cleartext http is only allowed for localhost)${s}`):o("unsupported-api-base-url-scheme",`apiBaseUrl must be http(s)${s}`)}let p=r.endsWith("/")?r.slice(0,-1):r;/* @__PURE__ */
6
- return Object.freeze({ok:true,value:p})}function c(e){let t=e.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="[::1]"||t==="::1"}function f(e){let t=globalThis.process?.env?.[e];return typeof t=="string"&&t.trim().length>0?t.trim():void 0}var v="DAILY_QUOTA_EXCEEDED",_=/* @__PURE__ */new Set(["THROTTLINGEXCEPTION","RATELIMITED","TOOMANYREQUESTS"]);function h(e,t){if(!_.has(e.toUpperCase().replace(/[^A-Z0-9]/g,"")))return e;let r=t,n=r?.daily_limit??r?.error?.daily_limit;return typeof n=="number"&&Number.isFinite(n)?v:e}var m=[{wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"DAILY_QUOTA_EXCEEDED",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"FILE_TOO_LARGE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"IDEMPOTENCY_KEY_IN_FLIGHT",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"INVALID_CONTENT_TYPE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"InternalFailureException",envelope:"http_envelope",httpStatus:500,retryable:true},{wireCode:"MethodNotAllowedException",envelope:"http_envelope",httpStatus:405,retryable:false},{wireCode:"NotImplementedException",envelope:"http_envelope",httpStatus:501,retryable:false},{wireCode:"PaymentRequiredException",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ResourceNotFoundException",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"ServiceUnavailableException",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"TIER_UPGRADE_REQUIRED",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ThrottlingException",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"ValidationException",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"accessDenied",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"access_denied",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"anchor_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"anchor_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"anonTokenInvalid",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"attachment_unreadable",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"authExpired",envelope:"http_envelope",httpStatus:401,retryable:true},{wireCode:"authRejected",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"before_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_not_uploaded",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundles_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"catalog_empty_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"catalog_shrink_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"consent_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_required",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_scope_wrong_route",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"device_cipher_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"email_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"endpoint_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"environment_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_cursor_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_payload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_not_available",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_unknown",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_required",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_reused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"inbox_cursor_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"insufficientCapability",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"insufficient_scope",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"internal_error",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"invalidRequest",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"invalid_client",envelope:"oauth_error",httpStatus:401,retryable:false},{wireCode:"invalid_client_metadata",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_grant",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_redirect_uri",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_request",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_scope",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_target",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"item_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"linked_account_read_only",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_connection_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"mcp_request_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_request_gone",envelope:"http_envelope",httpStatus:410,retryable:false},{wireCode:"mcp_request_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"not_found",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"open_url_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"partner_visit_link_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"partner_visit_owner_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"partner_visit_pet_already_mapped",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"payload_too_large",envelope:"http_envelope",httpStatus:413,retryable:false},{wireCode:"petRefInUse",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"pet_health_list_removals_unconfirmed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_health_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_not_registered",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"provider_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"rateLimited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"read_target_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_subject_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"record_upload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"records_consent_required",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"restricted_key",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"sandbox_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_required",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_revoked",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"share_limit_reached",envelope:"http_envelope",httpStatus:429,retryable:false},{wireCode:"slow_down",envelope:"oauth_error",httpStatus:429,retryable:true},{wireCode:"species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"subscription_keys_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"tenant_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"tenant_has_no_capabilities",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tenant_resource_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"tenant_surface_not_enabled",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"ticket_not_resolved",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tickets_disabled",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"timeout",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"timezone_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"token_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"unavailable",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"unrestrictedKeyRequired",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"unsupported_grant_type",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"unsupported_response_type",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"user_ref_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"verify_mint_rate_limited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"verify_mint_refused",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"verify_mint_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"verify_user_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"web_push_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"webhook_endpoint_update_empty",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false}],y=/* @__PURE__ */Object.freeze(m.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(y.map(e=>e.wireCode));var b=/* @__PURE__ */Object.freeze({ValidationException:"validationFailed",AuthorizationException:"authRejected",PaymentRequiredException:"paymentRequired",AccessDeniedException:"accessDenied",ResourceNotFoundException:"resourceNotFound",ConflictException:"conflict",ThrottlingException:"rateLimited",InternalFailureException:"internalError",NotImplementedException:"notImplemented",ServiceUnavailableException:"serviceUnavailable",MethodNotAllowedException:"validationFailed",authExpired:"authExpired",unavailable:"serviceUnavailable",session_required:"sessionRequired",session_revoked:"authExpired",anonTokenInvalid:"authRejected",accessDenied:"accessDenied",invalidRequest:"sdkUpdateRequired",authRejected:"authRejected",rateLimited:"rateLimited",insufficientCapability:"accessDenied",unrestrictedKeyRequired:"accessDenied",user_ref_invalid:"validationFailed",event_cursor_invalid:"validationFailed",event_filter_invalid:"validationFailed",event_payload_invalid:"validationFailed",event_type_unknown:"validationFailed",idempotency_key_invalid:"validationFailed",idempotency_key_required:"validationFailed",idempotency_key_reused:"idempotencyConflict",payload_too_large:"validationFailed",webhook_url_rejected:"validationFailed",webhook_endpoint_update_empty:"validationFailed",webhook_endpoint_update_invalid:"validationFailed",event_type_not_available:"conflict",record_subject_not_found:"resourceNotFound",records_consent_required:"conflict",record_species_unsupported:"validationFailed",record_upload_invalid:"validationFailed",FILE_TOO_LARGE:"validationFailed",INVALID_CONTENT_TYPE:"validationFailed",attachment_unreadable:"validationFailed",provider_unsupported:"validationFailed",token_invalid:"validationFailed",device_cipher_unavailable:"serviceUnavailable",email_invalid:"validationFailed",consent_required:"validationFailed",consent_invalid:"validationFailed",consent_scope_wrong_route:"validationFailed",IDEMPOTENCY_KEY_IN_FLIGHT:"idempotencyInFlight",IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST:"idempotencyConflict",DAILY_QUOTA_EXCEEDED:"quotaExceeded",TIER_UPGRADE_REQUIRED:"paymentRequired",not_found:"conversationNotFound",timeout:"streamTimeout",internal_error:"internalError",invalid_request:"validationFailed",invalid_client:"authRejected",invalid_grant:"authRejected",unsupported_grant_type:"validationFailed",invalid_scope:"validationFailed",invalid_target:"validationFailed",invalid_redirect_uri:"validationFailed",invalid_client_metadata:"validationFailed",unsupported_response_type:"validationFailed",access_denied:"accessDenied",slow_down:"rateLimited",mcp_request_not_found:"resourceNotFound",mcp_request_gone:"resourceNotFound",mcp_connection_not_found:"resourceNotFound",mcp_request_conflict:"conflict",sandbox_only:"accessDenied",tenant_has_no_capabilities:"conflict",verify_mint_refused:"accessDenied",verify_mint_rate_limited:"rateLimited",verify_mint_unavailable:"serviceUnavailable",verify_user_ref_invalid:"validationFailed",insufficient_scope:"accessDenied",tenant_filter_invalid:"validationFailed",tenant_resource_not_found:"resourceNotFound",tenant_surface_not_enabled:"conflict",pet_health_species_unsupported:"validationFailed",pet_health_list_removals_unconfirmed:"validationFailed",petRefInUse:"conflict",share_limit_reached:"conflict",pet_not_registered:"resourceNotFound",species_unsupported:"validationFailed",partner_visit_owner_only:"accessDenied",partner_visit_link_conflict:"conflict",partner_visit_pet_already_mapped:"conflict",linked_account_read_only:"conflict",catalog_empty_refused:"conflict",catalog_shrink_refused:"conflict",endpoint_not_allowed:"validationFailed",event_id_invalid:"validationFailed",inbox_cursor_invalid:"validationFailed",item_id_invalid:"validationFailed",open_url_not_allowed:"validationFailed",read_target_invalid:"validationFailed",subscription_keys_invalid:"validationFailed",web_push_unavailable:"serviceUnavailable",anchor_not_found:"resourceNotFound",anchor_ref_invalid:"validationFailed",before_invalid:"validationFailed",bundle_mismatch:"validationFailed",bundle_not_uploaded:"validationFailed",bundles_unavailable:"serviceUnavailable",environment_mismatch:"validationFailed",restricted_key:"accessDenied",ticket_not_resolved:"conflict",tickets_disabled:"resourceNotFound",timezone_invalid:"validationFailed"}),g=/* @__PURE__ */Object.freeze(y.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:b[e.wireCode]}))),w=new Map(g.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),S=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(g.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let e of[t??"http_envelope",...S]){let t=w.get(e+r);if(t)return t}}var C=/* @__PURE__ */Object.freeze({authExpired:"authentication",authRejected:"authentication",sessionRequired:"authentication",identitySignatureRequired:"authentication",accessDenied:"authorization",paymentRequired:"entitlement",quotaExceeded:"rateLimit",rateLimited:"rateLimit",validationFailed:"invalidRequest",sdkUpdateRequired:"invalidRequest",runtimeDisposed:"invalidRequest",conversationNotFound:"notFound",petNotFound:"notFound",resourceNotFound:"notFound",conflict:"conflict",idempotencyConflict:"conflict",idempotencyInFlight:"conflict",streamTimeout:"connection",streamIncomplete:"connection",upstreamLlmTimeout:"connection",serviceUnavailable:"connection",internalError:"server",notImplemented:"server",mediaUploadFailed:"media",moderationBlocked:"policy",unknown:"unknown"});function categoryFor(e){return C[e]}function fromWire(e){let t=contractErrorFor(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),n=r.replace(/[^A-Z0-9]/g,"");if(n==="AUTHREJECTED")return"authRejected";if(r.startsWith("AUTH"))return"authExpired";switch(n){case"DAILYQUOTAEXCEEDED":case"QUOTAEXCEEDED":return"quotaExceeded";case"RATELIMITED":case"TOOMANYREQUESTS":case"TELEVETRATELIMITED":return"rateLimited";case"IDEMPOTENCYKEYCONFLICT":case"IDEMPOTENCYCONFLICT":return"idempotencyConflict";case"ACCESSDENIED":case"FORBIDDEN":return"accessDenied";case"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";case"RUNTIMEDISPOSED":return"runtimeDisposed";case"NOTFOUND":case"CONVERSATIONNOTFOUND":return"conversationNotFound";case"PETNOTFOUND":return"petNotFound";case"TIMEOUT":case"STREAMTIMEOUT":return"streamTimeout";case"MEDIAUPLOADFAILED":case"UNRECOGNIZEDVIDEOFORMAT":case"FILETOOSMALL":return"mediaUploadFailed";case"MODERATIONBLOCKED":return"moderationBlocked";case"UPSTREAMLLMTIMEOUT":return"upstreamLlmTimeout";case"INTERNALERROR":case"INTERNALSERVERERROR":return"internalError";case"STREAMINCOMPLETE":case"CHATSTREAMINCOMPLETE":return"streamIncomplete";case"INVALIDANALYSISTYPE":case"INVALIDUPLOADPURPOSE":return"unknown";default:return"unknown"}}function fromHttpStatus(e){return e===401?"authExpired":e===403?"accessDenied":e===404?"conversationNotFound":e===409?"idempotencyConflict":e===421?"unknown":e===429?"rateLimited":e===400||e===422?"unknown":e>=500?"internalError":"unknown"}var E=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return E.has(e)}var T=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||T.has(e)}var $="This feature isn't available on your account right now.",R="Something in that request was not right. Check the details and try again.",k=/* @__PURE__ */Object.freeze({authExpired:"Please sign in again to continue.",authRejected:"Please sign in again to continue.",sessionRequired:"This app needs to be updated to keep using Everfur.",accessDenied:$,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:R,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:$,runtimeDisposed:R,unknown:"Something went wrong. Please try again."}),A="This session has ended. Please sign in again.",I="linked_account_read_only";function D(e,t,r){return e==="conflict"&&r===I?$:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?A:userFacingError(e)}function userFacingError(e){return k[e]}function F(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var O=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===I,a={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:D(e,t?.wireCode,n?I:null)};t?.httpStatus!==void 0&&(a.httpStatus=t.httpStatus),t?.requestId&&(a.requestId=t.requestId),typeof t?.reasonCode=="string"&&O.test(t.reasonCode)&&(a.reasonCode=t.reasonCode);let i=t?.retryAfterSeconds;if(typeof i=="number"&&Number.isFinite(i)&&i>=0&&(a.retryAfterSeconds=Math.round(i)),r);return t?.wireMessage&&F(a,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&F(a,"raw",t.raw),/* @__PURE__ */Object.freeze(a)}var j="free_cap_reached";function N(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function x(e){if(typeof e!="object"||e===null)return null;let t=e,r=t.detail,n=typeof r=="object"&&r!==null?r:t;if(n.error!==j&&n.code!==j)return null;let a=N(n.limit),i=N(n.used);if(a===null||i===null)return null;let o=n.resets_at,l=n.emergency_guidance;/* @__PURE__ */
7
- return Object.freeze({limit:a,used:i,resetsAt:typeof o=="string"&&o.length>0?o:null,...typeof l=="string"&&l.trim().length>0?{emergencyGuidance:l}:{}})}function U(e,t){if(e.status!==429&&e.status!==503)return t;let r=L(e.headers.get(q),Date.now());if(r===null)return t;let n=t!==null&&typeof t=="object"&&!Array.isArray(t)?t:null;return n!==null&&z(n)?t:{...n??{},retry_after_seconds:r}}var q="retry-after";function L(e,t){if(e===null)return null;let r=e.trim();if(/^\d+$/.test(r))return Number(r);let n=Date.parse(r);return Number.isFinite(n)?Math.max(0,Math.ceil((n-t)/1e3)):null}function z(e){return[e,e.error,e.detail].some(e=>e!==null&&typeof e=="object"&&("retry_after_seconds"in e||"resets_at"in e))}var P="x-request-id";function errorFromResponse(e,t,r){let n=V(t),a=n?fromWire(n):fromHttpStatus(e),i=B(t);return makeEverfurError(a,{httpStatus:e,...Y(t)?{retryable:true}:{},...r?{requestId:r}:{},...n?{wireCode:n}:{},...K(t)?{reasonCode:K(t)}:{},...M(t)!==null?{retryAfterSeconds:M(t)}:{},...i?{wireMessage:i}:{},...t!=null?{raw:t}:{}})}function M(e){let t=e,r=t?.retry_after_seconds??t?.error?.retry_after_seconds;return typeof r=="number"&&Number.isFinite(r)&&r>=0?r:null}function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:W(e)})}function requestIdOf(e){let t=e.headers.get(P);return typeof t=="string"&&t.length>0?t:null}function getGlobalFetch(){let t=globalThis.fetch;if(typeof t!="function")throw new e("missing-peer-dependency","global fetch is unavailable; provide config.transport or an injected fetch implementation");return t}function K(e){let t=e,r=t?.error?.reason_code??t?.reason_code;return typeof r=="string"&&r.length>0?r:null}function V(e){let t=e,r=t?.error?.code??t?.code;return typeof r=="string"&&r.length>0?h(r,e):x(e)!==null?j:null}function B(e){let t=e,r=t?.error?.message??t?.message;return typeof r=="string"&&r.length>0?r:null}function Y(e){let t=e;return t?.error?.retryable===true||t?.retryable===true}function W(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var Z=["sk_partner_","rk_partner_"];function G(t,r){if(typeof t!="string"||t.length===0)throw new e("invalid-argument","partnerSecretKey is required");if(t.startsWith("pk_"))throw new e("invalid-argument",`partnerSecretKey is a publishable key (pk_...): ${r} needs your secret key, server side only`);if(!Z.some(e=>t.startsWith(e)))throw new e("invalid-argument","partnerSecretKey must be an sk_partner_ secret key or an rk_partner_ restricted key")}var Q=128;function assertValidUserRef(t){let r=typeof t=="string"?[...t].length:0;if(typeof t!="string"||r<1||r>Q)throw new e("invalid-argument",`user_ref must be 1..${Q} characters`);if(t.trim().length===0)throw new e("invalid-argument","user_ref must not be blank: the server strips surrounding whitespace before validating, so a whitespace-only value arrives empty and is rejected as required.");if(t!==t.trim())throw new e("invalid-argument","user_ref must not have leading or trailing whitespace: the server strips it, so padded and unpadded forms of the same id resolve to ONE user. Pass the exact id you want to key on.");if(t.includes("@"))throw new e("invalid-argument","user_ref must not contain '@'");if(!X(t))throw new e("invalid-argument","user_ref must be printable (no control characters)");return t}function X(e){return!H.test(e)}var H=/[\p{Cc}\p{Cf}\p{Cs}\p{Co}\p{Cn}\p{Zl}\p{Zp}]|(?!\u0020)[\p{Zs}]/u,J="user_ref_invalid";function ee(e){let t=e.raw,r=typeof t=="object"&&t!==null?t:null,n=(r!==null&&typeof r.error=="object"&&r.error!==null?r.error.code:void 0)??r?.code;return n!==J&&e.reasonCode!==J?e:makeEverfurError("validationFailed",{retryable:false,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId!==void 0?{requestId:e.requestId}:{},...typeof n=="string"?{wireCode:n}:{},reasonCode:J,...e.wireMessage!==void 0?{wireMessage:e.wireMessage}:{},...t!==void 0?{raw:t}:{}})}function te(e){let t=e.raw;if(typeof t!="object"||t===null)return null;let r=t.code;return typeof r=="string"&&r.length>0?r:null}function re(e,t){let r=te(e);if(r===null)return e;let n=t[r];return n===void 0?e:makeEverfurError(n.code,{retryable:n.retryable,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId!==void 0?{requestId:e.requestId}:{},wireCode:r,reasonCode:r,...e.wireMessage!==void 0?{wireMessage:e.wireMessage}:{},raw:e.raw})}function ne(e,t){let r=re(e,t);if(r!==e||te(e)!==null)return r;let n=e.reasonCode;if(typeof n!="string")return e;let a=t[n];return a===void 0?e:makeEverfurError(a.code,{retryable:a.retryable,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId!==void 0?{requestId:e.requestId}:{},wireCode:n,reasonCode:n,...e.wireMessage!==void 0?{wireMessage:e.wireMessage}:{},raw:e.raw})}var ae=64;function ie(t){if(t!=null){if(typeof t!="string"||t.length===0||t.length>ae||/\s/.test(t))throw new e("invalid-argument",`timezone must be an IANA zone name such as 'America/Chicago' (at most ${ae} characters)`);return t}}function oe(e){for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let r=e.charCodeAt(t+1);if(!(r>=56320&&r<=57343))return true;t+=1}else if(r>=56320&&r<=57343)return true}return false}function le(e){return[...e].length}var se=/* @__PURE__ */Object.freeze({dog:"dog",canine:"dog",k9:"dog",puppy:"dog",cat:"cat",feline:"cat",kitten:"cat"});function canonicalPetSpecies(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.prototype.hasOwnProperty.call(se,t)?se[t]:null}var ue=50,de=128,pe=120,ce=120,fe=2e3,ve=120,_e=80,he=/* @__PURE__ */new Set(["male","female","unknown"]),me=/* @__PURE__ */new Set(["day","month","year"]),ye=/* @__PURE__ */new Set(["low","medium","high","athletic"]),be=/* @__PURE__ */new Set(["indoor","outdoor","both"]),ge=/* @__PURE__ */new Set(["mild","moderate","severe"]),we=/^(\d{4})-(\d{2})-(\d{2})$/,Se=[["sex","sex"],["spayedNeutered","spayed_neutered"],["birthDate","birth_date"],["birthDatePrecision","birth_date_precision"],["activityLevel","activity_level"],["indoorOutdoor","indoor_outdoor"],["foodBrand","food_brand"],["foodType","food_type"],["microchipId","microchip_id"]],Ce=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];/* @__PURE__ */Object.freeze([...Se,...Ce].map(([e])=>e));function Ee(e){let t=we.exec(e);if(t===null)return false;let[r,n,a]=[Number(t[1]),Number(t[2]),Number(t[3])],i=new Date(Date.UTC(r,n-1,a));return i.getUTCFullYear()===r&&i.getUTCMonth()===n-1&&i.getUTCDate()===a}var Te=e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,$e=(e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,Re=(e,t)=>typeof t=="string"&&Ee(t)?null:`${e} must be a real date written YYYY-MM-DD`,ke=(e,t={})=>(r,n)=>{if(typeof n!="string")return`${r} must be a string`;if(oe(n))return`${r} contains an unpaired surrogate and cannot be encoded`;let a=t.trimmed?n.trim():n;if(t.required&&a.length===0)return`${r} is required and must not be blank`;let i=le(a);return i<=e?null:`${r} is ${i} characters; the server accepts at most ${e}`},Ae={sex:Te(he),spayedNeutered:$e,birthDate:Re,birthDatePrecision:Te(me),activityLevel:Te(ye),indoorOutdoor:Te(be),foodBrand:ke(ve),foodType:ke(ve),microchipId:ke(_e)},Ie=["ref","ref",false,ke(de,{required:true,trimmed:true})],De=["notes","notes",false,ke(fe,{trimmed:true})],Fe=[Ie,["name","name",true,ke(pe,{required:true,trimmed:true})],["dose","dose",false,ke(ce,{trimmed:true})],["frequency","frequency",false,ke(ce,{trimmed:true})],["startDate","start_date",false,Re],["endDate","end_date",false,Re],De],Oe={allergies:[Ie,["allergen","allergen",true,ke(pe,{required:true,trimmed:true})],["severity","severity",false,Te(ge)],De],medications:Fe,supplements:Fe,conditions:[Ie,["conditionName","condition_name",true,ke(pe,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,Re],De]};function je(e,t,r){let n=`${e}[${t}]`;if(typeof r!="object"||r===null||Array.isArray(r))return{error:`${n} must be an object`};let a=r,i={};for(let[t,r,o,l]of Oe[e]){let e=a[t];if(e==null){if(o)return{error:`${n}.${t} is required`};e===null&&(i[r]=null);continue}let s=l(`${n}.${t}`,e);if(s!==null)return{error:s};i[r]=e}let o=i.start_date,l=i.end_date;return typeof o=="string"&&typeof l=="string"&&l<o?{error:`${n}.endDate must not be before startDate`}:{item:i}}function Ne(e,t){if(!Array.isArray(t))return{error:`${e} must be an array (send [] to clear it)`};if(t.length>ue)return{error:`${e} has ${t.length} items; the server accepts at most ${ue}`};let r=[],n=/* @__PURE__ */new Set;for(let a=0;a<t.length;a+=1){let i=je(e,a,t[a]);if("error"in i)return i;let o=i.item.ref;if(typeof o=="string"){let t=o.trim();if(n.has(t))return{error:`${e}: ref ${JSON.stringify(t)} is used twice; a ref names one item`};n.add(t)}r.push(i.item)}return{items:r}}function xe(e,t){let r=e,n={};for(let[e,t]of Se){let a=r[e];if(a!==void 0){if(a!==null){let t=Ae[e](e,a);if(t!==null)return{error:t}}n[t]=a}}let a=r.birthDate!==void 0,i=r.birthDatePrecision!==void 0;if(a!==i||a&&r.birthDate===null!=(r.birthDatePrecision===null))return{error:"birthDate and birthDatePrecision must be sent together, both set or both null"};for(let[e,t]of Ce){let a=r[e];if(a===void 0)continue;let i=Ne(e,a);if("error"in i)return i;n[t]=i.items}return Object.keys(n).length>0&&t!==void 0&&canonicalPetSpecies(t)===null?{error:"health fields need a pet Everfur reads as a dog or a cat (dog, canine, k9, puppy, cat, feline, kitten)"}:{body:n}}var Ue=e=>typeof e=="string"?e:null,qe=(e,t)=>typeof t=="string"&&e.has(t)?t:null,Le=e=>typeof e=="boolean"?e:null;function ze(e,t){return Array.isArray(e)?/* @__PURE__ */Object.freeze(e.flatMap(e=>{if(typeof e!="object"||e===null||Array.isArray(e))return[];let r=t(e);return r===null?[]:[r]})):/* @__PURE__ */Object.freeze([])}function Pe(e){let t=Ue(e.name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Ue(e.ref),name:t,dose:Ue(e.dose),frequency:Ue(e.frequency),startDate:Ue(e.start_date),endDate:Ue(e.end_date),notes:Ue(e.notes)})}function Me(e){let t=e.profile_version;/* @__PURE__ */
8
- return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:qe(he,e.sex),spayedNeutered:Le(e.spayed_neutered),birthDate:Ue(e.birth_date),birthDatePrecision:qe(me,e.birth_date_precision),activityLevel:qe(ye,e.activity_level),indoorOutdoor:qe(be,e.indoor_outdoor),foodBrand:Ue(e.food_brand),foodType:Ue(e.food_type),microchipId:Ue(e.microchip_id),allergies:ze(e.allergies,e=>{let t=Ue(e.allergen);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Ue(e.ref),allergen:t,severity:qe(ge,e.severity),notes:Ue(e.notes)})}),medications:ze(e.medications,Pe),supplements:ze(e.supplements,Pe),conditions:ze(e.conditions,e=>{let t=Ue(e.condition_name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Ue(e.ref),conditionName:t,diagnosedDate:Ue(e.diagnosed_date),notes:Ue(e.notes)})})})}var Ke=128,Ve=3e4;async function upsertPartnerPet(e,t,r){return Be(e,"PUT",t,Qe(r,false))}async function updatePartnerPet(e,t,r){return Be(e,"PATCH",t,Qe(r,true))}async function getPartnerPet(e,t){let r=await Ye(e,"GET",t,void 0);if(!("status"in r))return r;let n=await tt(r),a=requestIdOf(r);if(!r.ok)return err(errorFromResponse(r.status,U(r,n),a));let i=et(n);return i?ok(/* @__PURE__ */Object.freeze({...i,...Me(n)})):err(errorFromResponse(502,{error:{code:"INTERNAL_ERROR"}},a))}async function deletePartnerPet(e,t){let r=await Ye(e,"DELETE",t,void 0);return"status"in r?r.ok?ok(void 0):err(errorFromResponse(r.status,U(r,await tt(r)),requestIdOf(r))):r}async function Be(e,t,r,n){let a=await Ye(e,t,r,n);if(!("status"in a))return a;let i=await tt(a),o=requestIdOf(a);if(!a.ok)return err(errorFromResponse(a.status,U(a,i),o));let l=et(i);return l?ok(l):err(errorFromResponse(502,{error:{code:"INTERNAL_ERROR"}},o))}async function Ye(e,t,i,o){G(e.partnerSecretKey,"writing pets");let l=We(i),s=e.fetchImpl??getGlobalFetch(),u=`${resolveApiBaseUrl(e.apiBaseUrl)}${l}`,d={...buildBaseHeaders({sdkVersion:r,platform:n,contractVersion:e.contractVersion??a}),accept:"application/json","x-everfur-partner-secret-key":e.partnerSecretKey};o!==void 0&&(d["content-type"]="application/json");let p=new AbortController,c=setTimeout(()=>p.abort(),Ve);try{return await s(u,{method:t,headers:d,...o!==void 0?{body:o}:{},signal:p.signal})}catch(e){return err(networkError(e))}finally{clearTimeout(c)}}function We(t){if(typeof t!="object"||t===null)throw new e("invalid-argument","target is required");let userRef=assertValidUserRef(t.userRef);Ze("userRef",userRef);let petRef=t.petRef,r=typeof petRef=="string"?[...petRef].length:0;if(typeof petRef!="string"||r<1||r>Ke)throw new e("invalid-argument",`petRef must be 1..${Ke} characters`);return Ze("petRef",petRef),`/partners/members/${encodeURIComponent(userRef)}/pets/${encodeURIComponent(petRef)}`}function Ze(t,r){if(r.includes("/")||r==="."||r==="..")throw new e("invalid-argument",`${t} cannot contain '/' or be '.' or '..': it is sent as a URL path segment`)}var Ge=[["name","name"],["species","species"],["breed","breed"],["ageYears","age_years"],["weightKg","weight_kg"],["partnerLabelInstructions","partner_label_instructions"]];function Qe(t,r){let n=Xe(t);if(r&&Object.keys(n).length===0)throw new e("invalid-argument","updatePartnerPet needs at least one field to change");return JSON.stringify(n)}function Xe(t){if(typeof t!="object"||t===null||Array.isArray(t))throw new e("invalid-argument","the pet profile must be an object");let r={};for(let[e,n]of Ge)t[e]!==void 0&&(r[n]=t[e]);let n=xe(t,t.species);if("error"in n)throw new e("invalid-argument",n.error);return Object.assign(r,n.body)}function He(e){return e==null?null:typeof e=="string"?e:void 0}function Je(e){return e==null?null:typeof e=="number"?e:void 0}function et(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.pet_id!="string"||typeof t.pet_ref!="string"||typeof t.updated_at!="string")return null;let r=He(t.name),n=He(t.species),a=He(t.breed),i=Je(t.age_years),o=Je(t.weight_kg);return r===void 0||n===void 0||a===void 0||i===void 0||o===void 0?null:/* @__PURE__ */Object.freeze({petId:t.pet_id,petRef:t.pet_ref,name:r,species:n,breed:a,ageYears:i,weightKg:o,updatedAt:t.updated_at})}async function tt(e){try{return await e.json()}catch{return null}}var rt=3e4;async function revokePartnerMemberSessions(t,i){if(G(t.partnerSecretKey,"revoking member sessions"),t.partnerSecretKey.startsWith("rk_partner_"))throw new e("invalid-argument","revoking member sessions needs your unrestricted sk_partner_ secret key; an rk_partner_ restricted key is refused (unrestrictedKeyRequired)");if(typeof i!="object"||i===null)throw new e("invalid-argument","input is required");let userRef=assertValidUserRef(i.userRef),o=t.fetchImpl??getGlobalFetch(),l=`${resolveApiBaseUrl(t.apiBaseUrl)}/widget/v1/sessions/revoke`,s={...buildBaseHeaders({sdkVersion:r,platform:n,contractVersion:t.contractVersion??a}),accept:"application/json","content-type":"application/json","x-everfur-partner-secret-key":t.partnerSecretKey},u=new AbortController,d=setTimeout(()=>u.abort(),rt),p;try{p=await o(l,{method:"POST",headers:s,body:JSON.stringify({user_ref:userRef}),signal:u.signal})}catch(e){return err(networkError(e))}finally{clearTimeout(d)}let c=await at(p),f=requestIdOf(p);if(!p.ok)return err(ee(errorFromResponse(p.status,U(p,c),f)));let v=nt(c);return v?ok(v):err(errorFromResponse(502,{error:{code:"INTERNAL_ERROR"}},f))}function nt(e){if(typeof e!="object"||e===null)return null;let t=e;return t.revoked!==true||typeof t.sessions_valid_after!="number"||!Number.isFinite(t.sessions_valid_after)?null:/* @__PURE__ */Object.freeze({revoked:true,sessionsValidAfter:t.sessions_valid_after})}async function at(e){try{return await e.json()}catch{return null}}var it=254,ot=64,lt=/^[^@\s]+@[^@\s]+\.[^@\s]+$/,st=3e4,ut=/* @__PURE__ */Object.freeze({consent_required:{code:"validationFailed",retryable:false},email_invalid:{code:"validationFailed",retryable:false},consent_invalid:{code:"validationFailed",retryable:false},timezone_invalid:{code:"validationFailed",retryable:false}});async function setPartnerMemberNotificationProfile(e,t){G(e.partnerSecretKey,"writing a member notification profile");let i=dt(t),o=ie(t.timezone),l=JSON.stringify({email:t.email,consent:pt(t.consent),...o!==void 0?{timezone:o}:{}}),s=e.fetchImpl??getGlobalFetch(),u=`${resolveApiBaseUrl(e.apiBaseUrl)}${i}`,d={...buildBaseHeaders({sdkVersion:r,platform:n,contractVersion:e.contractVersion??a}),accept:"application/json","content-type":"application/json","x-everfur-partner-secret-key":e.partnerSecretKey},p=new AbortController,c=setTimeout(()=>p.abort(),st),f;try{f=await s(u,{method:"PUT",headers:d,body:l,signal:p.signal})}catch(e){return err(networkError(e))}finally{clearTimeout(c)}let v=await _t(f),_=requestIdOf(f);if(!f.ok)return err(re(errorFromResponse(f.status,U(f,v),_),ut));let h=vt(v);return h?ok(h):err(errorFromResponse(502,{error:{code:"INTERNAL_ERROR"}},_))}function dt(t){if(typeof t!="object"||t===null)throw new e("invalid-argument","input is required");let userRef=assertValidUserRef(t.userRef);if(userRef.includes("/")||userRef==="."||userRef==="..")throw new e("invalid-argument","userRef cannot contain '/' or be '.' or '..': it is sent as a URL path segment");let r=t.email;if(typeof r!="string"||r.trim().length<3||r.trim().length>it||!lt.test(r.trim()))throw new e("invalid-argument",`email must be an address of at most ${it} characters`);return`/partners/members/${encodeURIComponent(userRef)}/notification-profile`}function pt(t){if(typeof t!="object"||t===null)throw new e("invalid-argument","consent is required: an address is stored only with the stamp of the consent you collected");if(t.method!=="partner_attested")throw new e("invalid-argument","consent.method must be 'partner_attested' in this version");let r=t.version;if(typeof r!="string"||r.length===0||r.length>ot)throw new e("invalid-argument",`consent.version must be 1..${ot} characters`);let n=t.givenAt instanceof Date?t.givenAt.toISOString():t.givenAt;if(typeof n!="string"||!Number.isFinite(Date.parse(n)))throw new e("invalid-argument","consent.givenAt must be an ISO 8601 instant or a Date");return{given_at:n,method:"partner_attested",version:r}}function ct(e){return e==null?null:typeof e=="string"?e:void 0}function ft(e){if(e==null)return null;if(typeof e!="object")return;let t=e;if(!(typeof t.given_at!="string"||typeof t.method!="string"||typeof t.version!="string"))/* @__PURE__ */
9
- return Object.freeze({givenAt:t.given_at,method:t.method,version:t.version})}function vt(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.user_ref!="string"||typeof t.updated_at!="string"||typeof t.push_enabled!="boolean"||typeof t.email_enabled!="boolean"||typeof t.active_devices!="number"||!Number.isFinite(t.active_devices))return null;let r=ct(t.email),n=ct(t.email_verified_at),a=ct(t.unsubscribed_at),i=ft(t.consent);return r===void 0||n===void 0||a===void 0||i===void 0?null:/* @__PURE__ */Object.freeze({userRef:t.user_ref,emailMasked:r,consent:i,emailVerifiedAt:n,pushEnabled:t.push_enabled,emailEnabled:t.email_enabled,unsubscribedAt:a,activeDevices:t.active_devices,updatedAt:t.updated_at})}async function _t(e){try{return await e.json()}catch{return null}}var ht=3e4;async function mt(e,t,i,o,l,s){let u=e.fetchImpl??getGlobalFetch(),d=`${resolveApiBaseUrl(e.apiBaseUrl)}${i}`,p={...buildBaseHeaders({sdkVersion:r,platform:n,contractVersion:e.contractVersion??a}),accept:"application/json","content-type":"application/json","x-everfur-partner-secret-key":e.partnerSecretKey},c=new AbortController,f=setTimeout(()=>c.abort(),ht),v;try{v=await u(d,{method:t,headers:p,body:JSON.stringify(o),signal:c.signal})}catch(e){return err(networkError(e))}finally{clearTimeout(f)}let _=null;try{_=await v.json()}catch{_=null}let h=requestIdOf(v);if(!v.ok)return err(ne(errorFromResponse(v.status,U(v,_),h),l));let m=s(_);return m===null?err(errorFromResponse(502,{error:{code:"INTERNAL_ERROR"}},h)):ok(m)}var yt=/^[a-z][a-z0-9_.]{0,63}$/,bt=/^[a-z_]{1,32}$/,gt=500,wt=20,St=/^[A-Za-z0-9._:-]{1,120}$/,Ct=/* @__PURE__ */new Set(["brand_name","app_link"]),Et=/* @__PURE__ */Object.freeze({sms_not_live:{code:"accessDenied",retryable:false},not_live:{code:"accessDenied",retryable:false},profile_missing:{code:"accessDenied",retryable:false},profile_suspended:{code:"accessDenied",retryable:false},identity_missing:{code:"accessDenied",retryable:false},identity_ambiguous:{code:"accessDenied",retryable:false},consent_not_partner:{code:"accessDenied",retryable:false},consent_version_mismatch:{code:"accessDenied",retryable:false},channel_opted_out:{code:"accessDenied",retryable:false},destination_not_allowed:{code:"accessDenied",retryable:false},template_not_found:{code:"validationFailed",retryable:false},template_not_approved:{code:"validationFailed",retryable:false},daily_cap:{code:"rateLimited",retryable:false},template_vars_missing:{code:"validationFailed",retryable:false},template_var_unexpected:{code:"validationFailed",retryable:false},template_var_invalid:{code:"validationFailed",retryable:false},template_var_reserved:{code:"validationFailed",retryable:false},member_not_found:{code:"resourceNotFound",retryable:false},idempotency_key_required:{code:"validationFailed",retryable:false},idempotency_key_reused:{code:"conflict",retryable:false}});function sendMemberText(t,r){if(G(t.partnerSecretKey,"sending a member text"),typeof r!="object"||r===null)throw new e("invalid-argument","input is required");let userRef=assertValidUserRef(r.userRef);if(userRef.includes("/")||userRef==="."||userRef==="..")throw new e("invalid-argument","userRef cannot contain '/' or be '.' or '..': it is sent as a URL path segment");if(typeof r.templateKey!="string"||!yt.test(r.templateKey))throw new e("invalid-argument","templateKey must start with a letter and be 1 to 64 of a-z, 0-9, _ and .");let n=Tt(r.vars??{}),a=r.idempotencyKey;if(typeof a!="string"||!St.test(a))throw new e("invalid-argument","idempotencyKey is required: 1 to 120 of A-Z, a-z, 0-9, ., _, : and -");return mt(t,"POST",`/partners/members/${encodeURIComponent(userRef)}/texts`,{template_key:r.templateKey,vars:n,idempotency_key:a},Et,$t)}function Tt(t){if(typeof t!="object"||t===null||Array.isArray(t))throw new e("invalid-argument","vars must be an object of strings");let r=Object.entries(t);if(r.length>wt)throw new e("invalid-argument",`vars carries at most ${wt} values`);let n={};for(let[t,a]of r){if(!bt.test(t))throw new e("invalid-argument",`vars.${t}: a name is 1 to 32 of a-z and _`);if(Ct.has(t))throw new e("invalid-argument",`vars.${t} is filled by Everfur from your texting profile`);if(typeof a!="string"||a.length>gt||a.includes(`\n`))throw new e("invalid-argument",`vars.${t} must be one line of at most ${gt} characters`);n[t]=a}return n}function $t(e){if(e==null)/* @__PURE__ */return Object.freeze({textId:null,status:null,duplicate:null});if(typeof e!="object"||Array.isArray(e))return null;let t=e,r=t.text_id??t.message_id??t.id;/* @__PURE__ */
10
- return Object.freeze({textId:typeof r=="string"&&r.length>0?r:null,status:typeof t.status=="string"?t.status:null,duplicate:typeof t.duplicate=="boolean"?t.duplicate:null})}var Rt=2e3,kt=120,At=200,It=600,Dt=60,Ft=1e3,Ot=1e6,jt=20,Nt=120,xt=1e4,Ut=30,qt=/^[A-Za-z][A-Za-z -]*$/,Lt=10,zt=200,Pt=50,Mt=90,Kt=5,Vt=1e8,Bt=5,Yt=300,Wt=80,Zt=12,Gt=60,Qt=/^[A-Za-z0-9._-]+$/,Xt=/^[A-Z]{3}$/,Ht=/^https:\/\/\S+$/,Jt=/^(species|life_stage|size|breed):[a-z0-9_-]{1,40}$/,er=/* @__PURE__ */Object.freeze({species:["dog","cat"],life_stage:["young","adult","senior"],size:["small","medium","large"]}),tr=/* @__PURE__ */Object.freeze({catalog_empty_refused:{code:"conflict",retryable:false},catalog_shrink_refused:{code:"conflict",retryable:false}});function rr(e){let t=e.reasonCode,r=typeof t=="string"?tr[t]:void 0;if(r===void 0||e.code===r.code&&e.retryable===r.retryable)return e;let n=te(e);return makeEverfurError(r.code,{retryable:r.retryable,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId!==void 0?{requestId:e.requestId}:{},...n!==null?{wireCode:n}:{},reasonCode:t??null,...e.wireMessage!==void 0?{wireMessage:e.wireMessage}:{},raw:e.raw})}function nr(e,t){return mt(e,"PUT","/partners/catalog/products",t,tr,hr).then(e=>e.ok?e:err(rr(e.error)))}function replaceCatalog(t,r){if(G(t.partnerSecretKey,"replacing the product catalog"),typeof r!="object"||r===null||!Array.isArray(r.products))throw new e("invalid-argument","input.products must be an array");if(r.products.length>Rt)throw new e("invalid-argument",`a catalog carries at most ${Rt} products`);let n=ar(r.confirmEmpty,"confirmEmpty"),a=ar(r.confirmShrink,"confirmShrink"),i=/* @__PURE__ */new Set,o=r.products.map((e,t)=>vr(e,t,i,"replace"));return nr(t,{products:o,...n?{confirm_empty:true}:{},...a?{confirm_shrink:true}:{}})}function mergeCatalog(t,r){if(G(t.partnerSecretKey,"merging into the product catalog"),typeof r!="object"||r===null)throw new e("invalid-argument","input must be an object");let n=r.products??[],a=r.remove??[];if(!Array.isArray(n))throw new e("invalid-argument","input.products must be an array");if(!Array.isArray(a))throw new e("invalid-argument","input.remove must be an array");if(n.length===0&&a.length===0)throw new e("invalid-argument","a merge needs at least one product or one remove entry");if(n.length+a.length>Rt)throw new e("invalid-argument",`a merge names at most ${Rt} SKUs in products and remove together`);let i=/* @__PURE__ */new Set,o=n.map((e,t)=>vr(e,t,i,"merge")),l=/* @__PURE__ */new Set,s=a.map((t,r)=>{let n=`remove[${r}]`;if(typeof t!="string"||t.length===0||t.length>kt||!Qt.test(t))throw new e("invalid-argument",`${n} must be a partnerSku of 1 to ${kt} of A-Z a-z 0-9 . _ -`);let a=t.toLowerCase();if(l.has(a))throw new e("invalid-argument",`${n} '${t}' appears twice`);if(i.has(a))throw new e("invalid-argument",`${n} '${t}' is also in products`);return l.add(a),t});return nr(t,{mode:"merge",products:o,...s.length===0?{}:{remove:s}})}function ar(t,r){if(t===void 0)return false;if(typeof t!="boolean")throw new e("invalid-argument",`${r} must be a boolean`);return t}function ir(t,r,n){if(t==null)return null;if(typeof t!="string"||t.length===0||t.length>n)throw new e("invalid-argument",`${r} must be a string of 1 to ${n} characters`);return t}function or(t,r){if(t===void 0)return[];if(!Array.isArray(t)||t.length>2||t.some(e=>e!=="dog"&&e!=="cat"))throw new e("invalid-argument",`${r} must list at most 'dog' and 'cat'`);return[...t]}function lr(t,r){if(t===void 0)return[];if(!Array.isArray(t)||t.length>jt)throw new e("invalid-argument",`${r} must be a list of at most ${jt} reasons`);return t.map((t,n)=>{let a=`${r}[${n}]`,i=typeof t=="object"&&t!==null?t:{},o=i.tag,l=i.text;if(typeof o!="string"||!Jt.test(o))throw new e("invalid-argument",`${a}.tag must be species:, life_stage:, size: or breed: and a value`);let[s="",u=""]=o.split(":",2),d=er[s];if(d!==void 0&&!d.includes(u))throw new e("invalid-argument",`${a}.tag: ${s} must be one of ${d.join(", ")}`);if(typeof l!="string"||l.length===0||l.length>Nt)throw new e("invalid-argument",`${a}.text must be 1 to ${Nt} characters`);return{tag:o,text:l}})}function sr(t,r){let n=ir(t,r,Ft+8);if(n!==null&&(!Ht.test(n)||n.length-8>Ft))throw new e("invalid-argument",`${r} must be an https URL`);return n}function ur(t,r,n,a){if(typeof t!="number"||!Number.isInteger(t)||t<n||t>a)throw new e("invalid-argument",`${r} must be a whole number from ${n} to ${a}`);return t}function dr(t,r,n){if(typeof t!="number"||!Number.isFinite(t)||t<=0||t>n)throw new e("invalid-argument",`${r} must be a number above 0 and at most ${n}`);return t}function pr(t,r){if(typeof t!="object"||t===null)throw new e("invalid-argument",`${r} must be an object`);let n=ur(t.unitsPerBox,`${r}.unitsPerBox`,1,xt),a=t.unitLabel;if(typeof a!="string"||a.length>Ut||!qt.test(a))throw new e("invalid-argument",`${r}.unitLabel must be 1 to ${Ut} letters, spaces or hyphens, starting with a letter`);let i=t.doseBands;if(!Array.isArray(i)||i.length===0||i.length>Lt)throw new e("invalid-argument",`${r}.doseBands must list 1 to ${Lt} bands`);let o=0,l=i.map((t,n)=>{let a=`${r}.doseBands[${n}]`,l=typeof t=="object"&&t!==null?t:{},s=l.maxWeightKg??null,u=dr(l.unitsPerDay,`${a}.unitsPerDay`,Pt);if(s===null){if(n!==i.length-1)throw new e("invalid-argument",`${a}: only the last dose band may leave out maxWeightKg`);return{max_weight_kg:null,units_per_day:u}}let d=dr(s,`${a}.maxWeightKg`,zt);if(d<=o)throw new e("invalid-argument",`${a}.maxWeightKg must be above the band before it`);return o=d,{max_weight_kg:d,units_per_day:u}});return{units_per_box:n,unit_label:a,dose_bands:l,...t.firstBoxDiscountPercent===void 0?{}:{first_box_discount_percent:ur(t.firstBoxDiscountPercent,`${r}.firstBoxDiscountPercent`,0,Mt)},...t.oneBoxDiscountPercent===void 0?{}:{one_box_discount_percent:ur(t.oneBoxDiscountPercent,`${r}.oneBoxDiscountPercent`,0,Mt)}}}function cr(t,r){if(!Array.isArray(t)||t.length>Bt)throw new e("invalid-argument",`${r} must be a list of at most ${Bt} reviews`);return t.map((t,n)=>{let a=`${r}[${n}]`,i=typeof t=="object"&&t!==null?t:{},o=i.text,l=i.by,s=ur(i.stars,`${a}.stars`,1,5);if(typeof o!="string"||o.length===0||o.length>Yt)throw new e("invalid-argument",`${a}.text must be 1 to ${Yt} characters`);if(typeof l!="string"||l.length===0||l.length>Wt)throw new e("invalid-argument",`${a}.by must be 1 to ${Wt} characters`);return{stars:s,text:o,by:l}})}function fr(t,r){if(!Array.isArray(t)||t.length>Zt)throw new e("invalid-argument",`${r} must be a list of at most ${Zt} ingredients`);return t.map((t,n)=>{let a=typeof t=="string"?t.trim():"";if(a.length===0||a.length>Gt)throw new e("invalid-argument",`${r}[${n}] must be 1 to ${Gt} characters`);return a})}function vr(t,r,n,a){let i=`products[${r}]`;if(typeof t!="object"||t===null)throw new e("invalid-argument",`${i} must be an object`);let o=t.partnerSku;if(typeof o!="string"||o.trim().length===0||o.length>kt)throw new e("invalid-argument",`${i}.partnerSku must be 1 to ${kt} characters`);let l=o.trim().toLowerCase();if(n.has(l))throw new e("invalid-argument",`${i}.partnerSku '${o}' appears twice`);if(n.add(l),typeof t.title!="string"||t.title.trim().length===0||t.title.length>At)throw new e("invalid-argument",`${i}.title must be 1 to ${At} characters`);let s=t.price??null;if(s!==null&&(typeof s!="number"||!Number.isFinite(s)||s<0||s>Ot))throw new e("invalid-argument",`${i}.price must be a number from 0 to ${Ot}`);let u=t.currency??null;if(u!==null&&(typeof u!="string"||!Xt.test(u)))throw new e("invalid-argument",`${i}.currency must be an ISO 4217 code such as USD`);let d=t.subscription??null;if(d!==null&&(s===null||s<=0))throw new e("invalid-argument",`${i}.subscription needs a price above 0 on the same product`);if(a==="merge"&&t.price!==void 0&&(s===null||s<=0)&&t.subscription===void 0)throw new e("invalid-argument",`${i}: a merge that clears a price or sets it to 0 must also send subscription (null to end it)`);let p=t.rating??null;if(p!==null&&(typeof p!="number"||!Number.isFinite(p)||p<0||p>Kt))throw new e("invalid-argument",`${i}.rating must be a number from 0 to ${Kt}`);let c=t.reviewCount??null;c!==null&&ur(c,`${i}.reviewCount`,0,Vt);let f=e=>a==="replace"||t[e]!==void 0,v=e=>a==="replace"?t[e]!==void 0&&t[e]!==null:t[e]!==void 0;return{partner_sku:o,title:t.title,...f("description")?{description:ir(t.description,`${i}.description`,It)}:{},...f("form")?{form:ir(t.form,`${i}.form`,Dt)}:{},...f("species")?{species:or(t.species,`${i}.species`)}:{},...f("price")?{price:s}:{},...u===null?{}:{currency:u},...f("url")?{url:sr(t.url,`${i}.url`)}:{},...f("imageUrl")?{image_url:sr(t.imageUrl,`${i}.imageUrl`)}:{},...f("category")?{category:ir(t.category,`${i}.category`,Dt)}:{},...f("reasonTags")?{reason_tags:lr(t.reasonTags,`${i}.reasonTags`)}:{},...f("sample")?{is_sample:t.sample===true}:{},...v("subscription")?{subscription:d===null?null:pr(d,`${i}.subscription`)}:{},...v("rating")?{rating:p}:{},...v("reviewCount")?{review_count:c}:{},...v("reviews")?{reviews:cr(t.reviews,`${i}.reviews`)}:{},...v("ingredients")?{ingredients:fr(t.ingredients,`${i}.ingredients`)}:{}}}function _r(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function hr(e){if(e==null)/* @__PURE__ */return Object.freeze({active:null,deactivated:null,syncRunId:null,deactivatedSkus:null});if(typeof e!="object"||Array.isArray(e))return null;let t=e,r=t.sync_run_id,n=t.deactivated_skus;/* @__PURE__ */
11
- return Object.freeze({active:_r(t.upserted??t.active),deactivated:_r(t.deactivated),syncRunId:typeof r=="string"&&r.length>0?r:null,deactivatedSkus:Array.isArray(n)&&n.every(e=>typeof e=="string")?/* @__PURE__ */Object.freeze([...n]):null})}var mr=60,yr=3600,br=3e4;async function mintPartnerSession(e){G(e.partnerSecretKey,"minting a session");let t=assertValidUserRef(e.userRef),i=Sr(e.ttlSeconds),o=wr(e.membership),l=ie(e.timezone),s=e.fetchImpl??getGlobalFetch(),u=`${resolveApiBaseUrl(e.apiBaseUrl)}/widget/v1/sessions`,d={...buildBaseHeaders({sdkVersion:r,platform:n,contractVersion:e.contractVersion??a}),accept:"application/json","content-type":"application/json","x-everfur-partner-secret-key":e.partnerSecretKey,"x-everfur-partner-key":e.publishableKey},p={user_ref:t};i!==void 0&&(p.ttl_seconds=i),o!==void 0&&(p.membership=o),l!==void 0&&(p.timezone=l);let c=Tr(br),f=$r(c.signal,e.signal),v={method:"POST",headers:d,body:JSON.stringify(p),signal:f},_;try{_=await s(u,v)}catch(e){return err(networkError(e))}finally{c.cancel()}let h=await Er(_),m=requestIdOf(_);if(!_.ok)return err(re(ee(errorFromResponse(_.status,U(_,h),m)),gr));let y=Cr(h);return y?ok(y):err(errorFromResponse(502,{error:{code:"INTERNAL_ERROR"}},m))}var gr=/* @__PURE__ */Object.freeze({timezone_invalid:{code:"validationFailed",retryable:false}});function wr(t){if(t!=null){if(t!=="member"&&t!=="free")throw new e("invalid-argument","membership must be 'member' or 'free'");return t}}function Sr(t){if(t!=null){if(!Number.isInteger(t))throw new e("invalid-argument","ttl_seconds must be an integer");return Math.min(yr,Math.max(mr,t))}}function Cr(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.session_token!="string"||t.session_token.length===0||typeof t.expires_at!="number")return null;let r=Array.isArray(t.capabilities)?t.capabilities.filter(e=>typeof e=="string"):[];/* @__PURE__ */
12
- return Object.freeze({sessionToken:t.session_token,expiresAt:t.expires_at,capabilities:/* @__PURE__ */Object.freeze(r)})}async function Er(e){try{return await e.json()}catch{return null}}function Tr(e){let t=new AbortController,r=setTimeout(()=>t.abort(),e);return{signal:t.signal,cancel:()=>clearTimeout(r)}}function $r(e,t){if(!t)return e;let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),r.signal;let n=()=>r.abort();return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),r.signal}exports.assertValidUserRef=assertValidUserRef;exports.canonicalPetSpecies=canonicalPetSpecies;exports.deletePartnerPet=deletePartnerPet;exports.getPartnerPet=getPartnerPet;exports.mergeCatalog=mergeCatalog;exports.mintPartnerSession=mintPartnerSession;exports.replaceCatalog=replaceCatalog;exports.revokePartnerMemberSessions=revokePartnerMemberSessions;exports.sendMemberText=sendMemberText;exports.setPartnerMemberNotificationProfile=setPartnerMemberNotificationProfile;exports.updatePartnerPet=updatePartnerPet;exports.upsertPartnerPet=upsertPartnerPet;
4
+ return Object.freeze({ok:false,error:e})}var e=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var t=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/;var r="1.5.0";var n="2026-09-19",a="EVERFUR_API_BASE_URL";function i(e,t){/* @__PURE__ */
5
+ return Object.freeze({ok:false,failure:/* @__PURE__ */Object.freeze({reason:e,message:t})})}function tryResolveApiBaseUrl(e){let t=e?.trim(),r=t&&t.length>0?t:c(a);return r?d(r):i("missing-api-base-url",`apiBaseUrl is required: pass config.apiBaseUrl or set ${a}. The SDK never ships a hardcoded host.`)}function resolveApiBaseUrl(t){let r=tryResolveApiBaseUrl(t);if(!r.ok)throw new e("invalid-argument",r.failure.message);return r.value}function o(e){return e.slice(e.lastIndexOf("@")+1).replace(/:\d+$/,"").toLowerCase()}function l(e){return e.length===0||e.includes("@")?false:e.startsWith("[")&&e.endsWith("]")?true:!e.includes(":")}function s(e,t){let r=e.indexOf("://");return r<0||e.slice(r+3).includes("@")?false:l(t)}function u(e,t){return`${e}://${t}`}function d(e){let r=e.trim(),n=t.exec(r);if(n===null||n[2]===void 0||n[2].length===0)return i("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let a=(n[1]??"").toLowerCase(),l=o(n[2]);if(l.length===0)return i("malformed-api-base-url","apiBaseUrl is not a valid absolute URL");let d=s(r,l)?`: ${u(a,l)}`:"";if(a!=="https"){if(!(a==="http"&&p(l)))return a==="http"?i("insecure-api-base-url",`apiBaseUrl must use https (cleartext http is only allowed for localhost)${d}`):i("unsupported-api-base-url-scheme",`apiBaseUrl must be http(s)${d}`)}let c=r.endsWith("/")?r.slice(0,-1):r;/* @__PURE__ */
6
+ return Object.freeze({ok:true,value:c})}function p(e){let t=e.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="[::1]"||t==="::1"}function c(e){let t=globalThis.process?.env?.[e];return typeof t=="string"&&t.trim().length>0?t.trim():void 0}var f="server";function v(e){return{"X-Everfur-SDK-Version":r,"X-Everfur-SDK-Platform":f,"X-Everfur-Contract":e}}var _="DAILY_QUOTA_EXCEEDED",h=/* @__PURE__ */new Set(["THROTTLINGEXCEPTION","RATELIMITED","TOOMANYREQUESTS"]);function m(e,t){if(!h.has(e.toUpperCase().replace(/[^A-Z0-9]/g,"")))return e;let r=t,n=r?.daily_limit??r?.error?.daily_limit;return typeof n=="number"&&Number.isFinite(n)?_:e}var y=[{wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"DAILY_QUOTA_EXCEEDED",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"FILE_TOO_LARGE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"IDEMPOTENCY_KEY_IN_FLIGHT",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"INVALID_CONTENT_TYPE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"InternalFailureException",envelope:"http_envelope",httpStatus:500,retryable:true},{wireCode:"MethodNotAllowedException",envelope:"http_envelope",httpStatus:405,retryable:false},{wireCode:"NotImplementedException",envelope:"http_envelope",httpStatus:501,retryable:false},{wireCode:"PaymentRequiredException",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ResourceNotFoundException",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"ServiceUnavailableException",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"TIER_UPGRADE_REQUIRED",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ThrottlingException",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"ValidationException",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"accessDenied",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"access_denied",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"anchor_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"anchor_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"anonTokenInvalid",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"attachment_unreadable",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"authExpired",envelope:"http_envelope",httpStatus:401,retryable:true},{wireCode:"authRejected",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"before_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_not_uploaded",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundles_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"catalog_empty_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"catalog_shrink_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"consent_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_required",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_scope_wrong_route",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"device_cipher_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"email_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"endpoint_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"environment_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_cursor_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_payload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_not_available",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_unknown",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_required",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_reused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"inbox_cursor_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"insufficientCapability",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"insufficient_scope",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"internal_error",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"invalidRequest",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"invalid_client",envelope:"oauth_error",httpStatus:401,retryable:false},{wireCode:"invalid_client_metadata",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_grant",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_redirect_uri",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_request",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_scope",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_target",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"item_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"linked_account_read_only",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_connection_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"mcp_request_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_request_gone",envelope:"http_envelope",httpStatus:410,retryable:false},{wireCode:"mcp_request_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"not_found",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"open_url_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"partner_visit_link_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"partner_visit_owner_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"partner_visit_pet_already_mapped",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"payload_too_large",envelope:"http_envelope",httpStatus:413,retryable:false},{wireCode:"petRefInUse",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"pet_health_list_removals_unconfirmed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_health_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_not_registered",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"provider_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"rateLimited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"read_target_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_subject_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"record_upload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"records_consent_required",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"restricted_key",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"sandbox_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_required",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_revoked",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"share_limit_reached",envelope:"http_envelope",httpStatus:429,retryable:false},{wireCode:"slow_down",envelope:"oauth_error",httpStatus:429,retryable:true},{wireCode:"species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"subscription_keys_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"tenant_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"tenant_has_no_capabilities",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tenant_resource_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"tenant_surface_not_enabled",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"ticket_not_resolved",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tickets_disabled",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"timeout",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"timezone_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"token_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"unavailable",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"unrestrictedKeyRequired",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"unsupported_grant_type",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"unsupported_response_type",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"user_ref_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"verify_mint_rate_limited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"verify_mint_refused",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"verify_mint_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"verify_user_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"web_push_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"webhook_endpoint_update_empty",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false}],b=/* @__PURE__ */Object.freeze(y.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(b.map(e=>e.wireCode));var g=/* @__PURE__ */Object.freeze({ValidationException:"validationFailed",AuthorizationException:"authRejected",PaymentRequiredException:"paymentRequired",AccessDeniedException:"accessDenied",ResourceNotFoundException:"resourceNotFound",ConflictException:"conflict",ThrottlingException:"rateLimited",InternalFailureException:"internalError",NotImplementedException:"notImplemented",ServiceUnavailableException:"serviceUnavailable",MethodNotAllowedException:"validationFailed",authExpired:"authExpired",unavailable:"serviceUnavailable",session_required:"sessionRequired",session_revoked:"authExpired",anonTokenInvalid:"authRejected",accessDenied:"accessDenied",invalidRequest:"sdkUpdateRequired",authRejected:"authRejected",rateLimited:"rateLimited",insufficientCapability:"accessDenied",unrestrictedKeyRequired:"accessDenied",user_ref_invalid:"validationFailed",event_cursor_invalid:"validationFailed",event_filter_invalid:"validationFailed",event_payload_invalid:"validationFailed",event_type_unknown:"validationFailed",idempotency_key_invalid:"validationFailed",idempotency_key_required:"validationFailed",idempotency_key_reused:"idempotencyConflict",payload_too_large:"validationFailed",webhook_url_rejected:"validationFailed",webhook_endpoint_update_empty:"validationFailed",webhook_endpoint_update_invalid:"validationFailed",event_type_not_available:"conflict",record_subject_not_found:"resourceNotFound",records_consent_required:"conflict",record_species_unsupported:"validationFailed",record_upload_invalid:"validationFailed",FILE_TOO_LARGE:"validationFailed",INVALID_CONTENT_TYPE:"validationFailed",attachment_unreadable:"validationFailed",provider_unsupported:"validationFailed",token_invalid:"validationFailed",device_cipher_unavailable:"serviceUnavailable",email_invalid:"validationFailed",consent_required:"validationFailed",consent_invalid:"validationFailed",consent_scope_wrong_route:"validationFailed",IDEMPOTENCY_KEY_IN_FLIGHT:"idempotencyInFlight",IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST:"idempotencyConflict",DAILY_QUOTA_EXCEEDED:"quotaExceeded",TIER_UPGRADE_REQUIRED:"paymentRequired",not_found:"conversationNotFound",timeout:"streamTimeout",internal_error:"internalError",invalid_request:"validationFailed",invalid_client:"authRejected",invalid_grant:"authRejected",unsupported_grant_type:"validationFailed",invalid_scope:"validationFailed",invalid_target:"validationFailed",invalid_redirect_uri:"validationFailed",invalid_client_metadata:"validationFailed",unsupported_response_type:"validationFailed",access_denied:"accessDenied",slow_down:"rateLimited",mcp_request_not_found:"resourceNotFound",mcp_request_gone:"resourceNotFound",mcp_connection_not_found:"resourceNotFound",mcp_request_conflict:"conflict",sandbox_only:"accessDenied",tenant_has_no_capabilities:"conflict",verify_mint_refused:"accessDenied",verify_mint_rate_limited:"rateLimited",verify_mint_unavailable:"serviceUnavailable",verify_user_ref_invalid:"validationFailed",insufficient_scope:"accessDenied",tenant_filter_invalid:"validationFailed",tenant_resource_not_found:"resourceNotFound",tenant_surface_not_enabled:"conflict",pet_health_species_unsupported:"validationFailed",pet_health_list_removals_unconfirmed:"validationFailed",petRefInUse:"conflict",share_limit_reached:"conflict",pet_not_registered:"resourceNotFound",species_unsupported:"validationFailed",partner_visit_owner_only:"accessDenied",partner_visit_link_conflict:"conflict",partner_visit_pet_already_mapped:"conflict",linked_account_read_only:"conflict",catalog_empty_refused:"conflict",catalog_shrink_refused:"conflict",endpoint_not_allowed:"validationFailed",event_id_invalid:"validationFailed",inbox_cursor_invalid:"validationFailed",item_id_invalid:"validationFailed",open_url_not_allowed:"validationFailed",read_target_invalid:"validationFailed",subscription_keys_invalid:"validationFailed",web_push_unavailable:"serviceUnavailable",anchor_not_found:"resourceNotFound",anchor_ref_invalid:"validationFailed",before_invalid:"validationFailed",bundle_mismatch:"validationFailed",bundle_not_uploaded:"validationFailed",bundles_unavailable:"serviceUnavailable",environment_mismatch:"validationFailed",restricted_key:"accessDenied",ticket_not_resolved:"conflict",tickets_disabled:"resourceNotFound",timezone_invalid:"validationFailed"}),w=/* @__PURE__ */Object.freeze(b.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:g[e.wireCode]}))),S=new Map(w.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),C=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(w.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let e of[t??"http_envelope",...C]){let t=S.get(e+r);if(t)return t}}var E=/* @__PURE__ */Object.freeze({authExpired:"authentication",authRejected:"authentication",sessionRequired:"authentication",identitySignatureRequired:"authentication",accessDenied:"authorization",paymentRequired:"entitlement",quotaExceeded:"rateLimit",rateLimited:"rateLimit",validationFailed:"invalidRequest",sdkUpdateRequired:"invalidRequest",runtimeDisposed:"invalidRequest",conversationNotFound:"notFound",petNotFound:"notFound",resourceNotFound:"notFound",conflict:"conflict",idempotencyConflict:"conflict",idempotencyInFlight:"conflict",streamTimeout:"connection",streamIncomplete:"connection",upstreamLlmTimeout:"connection",serviceUnavailable:"connection",internalError:"server",notImplemented:"server",mediaUploadFailed:"media",moderationBlocked:"policy",unknown:"unknown"});function categoryFor(e){return E[e]}function fromWire(e){let t=contractErrorFor(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),n=r.replace(/[^A-Z0-9]/g,"");if(n==="AUTHREJECTED")return"authRejected";if(r.startsWith("AUTH"))return"authExpired";switch(n){case"DAILYQUOTAEXCEEDED":case"QUOTAEXCEEDED":return"quotaExceeded";case"RATELIMITED":case"TOOMANYREQUESTS":case"TELEVETRATELIMITED":return"rateLimited";case"IDEMPOTENCYKEYCONFLICT":case"IDEMPOTENCYCONFLICT":return"idempotencyConflict";case"ACCESSDENIED":case"FORBIDDEN":return"accessDenied";case"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";case"RUNTIMEDISPOSED":return"runtimeDisposed";case"NOTFOUND":case"CONVERSATIONNOTFOUND":return"conversationNotFound";case"PETNOTFOUND":return"petNotFound";case"TIMEOUT":case"STREAMTIMEOUT":return"streamTimeout";case"MEDIAUPLOADFAILED":case"UNRECOGNIZEDVIDEOFORMAT":case"FILETOOSMALL":return"mediaUploadFailed";case"MODERATIONBLOCKED":return"moderationBlocked";case"UPSTREAMLLMTIMEOUT":return"upstreamLlmTimeout";case"INTERNALERROR":case"INTERNALSERVERERROR":return"internalError";case"STREAMINCOMPLETE":case"CHATSTREAMINCOMPLETE":return"streamIncomplete";case"INVALIDANALYSISTYPE":case"INVALIDUPLOADPURPOSE":return"unknown";default:return"unknown"}}function fromHttpStatus(e){return e===401?"authExpired":e===403?"accessDenied":e===404?"conversationNotFound":e===409?"idempotencyConflict":e===421?"unknown":e===429?"rateLimited":e===400||e===422?"unknown":e>=500?"internalError":"unknown"}var T=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return T.has(e)}var $=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||$.has(e)}var R="This feature isn't available on your account right now.",A="Something in that request was not right. Check the details and try again.",k=/* @__PURE__ */Object.freeze({authExpired:"Please sign in again to continue.",authRejected:"Please sign in again to continue.",sessionRequired:"This app needs to be updated to keep using Everfur.",accessDenied:R,paymentRequired:"This is part of a paid plan.",quotaExceeded:"You have used today's messages. This resets tomorrow.",rateLimited:"You are sending messages quickly. Try again in a few seconds.",validationFailed:A,sdkUpdateRequired:"This app needs to be updated to keep using Everfur.",conflict:"That is already running. Wait for it to finish, then try again.",idempotencyConflict:"That message was already delivered.",idempotencyInFlight:"That is still processing. Give it a moment.",conversationNotFound:"This conversation is no longer available.",petNotFound:"We could not find that pet. Please pick a pet and try again.",resourceNotFound:"We could not find that.",streamTimeout:"The response timed out. Tap retry to try again.",mediaUploadFailed:"We could not upload that photo. Please attach it again.",moderationBlocked:"This request cannot be answered here.",upstreamLlmTimeout:"The response timed out. Tap retry to try again.",internalError:"We hit a snag on our end. Please try again.",notImplemented:"That is not available yet.",serviceUnavailable:"That service is briefly unavailable. Try again shortly.",streamIncomplete:"The connection dropped mid-answer. Tap retry to continue.",identitySignatureRequired:R,runtimeDisposed:A,unknown:"Something went wrong. Please try again."}),I="This session has ended. Please sign in again.",D="linked_account_read_only";function F(e,t,r){return e==="conflict"&&r===D?R:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?I:userFacingError(e)}function userFacingError(e){return k[e]}function O(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var j=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===D,a={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:F(e,t?.wireCode,n?D:null)};t?.httpStatus!==void 0&&(a.httpStatus=t.httpStatus),t?.requestId&&(a.requestId=t.requestId),typeof t?.reasonCode=="string"&&j.test(t.reasonCode)&&(a.reasonCode=t.reasonCode);let i=t?.retryAfterSeconds;if(typeof i=="number"&&Number.isFinite(i)&&i>=0&&(a.retryAfterSeconds=Math.round(i)),r);return t?.wireMessage&&O(a,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&O(a,"raw",t.raw),/* @__PURE__ */Object.freeze(a)}var N="free_cap_reached";function x(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function U(e){if(typeof e!="object"||e===null)return null;let t=e,r=t.detail,n=typeof r=="object"&&r!==null?r:t;if(n.error!==N&&n.code!==N)return null;let a=x(n.limit),i=x(n.used);if(a===null||i===null)return null;let o=n.resets_at,l=n.emergency_guidance;/* @__PURE__ */
7
+ return Object.freeze({limit:a,used:i,resetsAt:typeof o=="string"&&o.length>0?o:null,...typeof l=="string"&&l.trim().length>0?{emergencyGuidance:l}:{}})}function q(e,t){if(e.status!==429&&e.status!==503)return t;let r=z(e.headers.get(L),Date.now());if(r===null)return t;let n=t!==null&&typeof t=="object"&&!Array.isArray(t)?t:null;return n!==null&&P(n)?t:{...n??{},retry_after_seconds:r}}var L="retry-after";function z(e,t){if(e===null)return null;let r=e.trim();if(/^\d+$/.test(r))return Number(r);let n=Date.parse(r);return Number.isFinite(n)?Math.max(0,Math.ceil((n-t)/1e3)):null}function P(e){return[e,e.error,e.detail].some(e=>e!==null&&typeof e=="object"&&("retry_after_seconds"in e||"resets_at"in e))}var M="x-request-id";function errorFromResponse(e,t,r){let n=Y(t),a=n?fromWire(n):fromHttpStatus(e),i=V(t);return makeEverfurError(a,{httpStatus:e,...W(t)?{retryable:true}:{},...r?{requestId:r}:{},...n?{wireCode:n}:{},...B(t)?{reasonCode:B(t)}:{},...K(t)!==null?{retryAfterSeconds:K(t)}:{},...i?{wireMessage:i}:{},...t!=null?{raw:t}:{}})}function K(e){let t=e,r=t?.retry_after_seconds??t?.error?.retry_after_seconds;return typeof r=="number"&&Number.isFinite(r)&&r>=0?r:null}function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:Z(e)})}function requestIdOf(e){let t=e.headers.get(M);return typeof t=="string"&&t.length>0?t:null}function getGlobalFetch(){let t=globalThis.fetch;if(typeof t!="function")throw new e("missing-peer-dependency","global fetch is unavailable; provide config.transport or an injected fetch implementation");return t}function B(e){let t=e,r=t?.error?.reason_code??t?.reason_code;return typeof r=="string"&&r.length>0?r:null}function Y(e){let t=e,r=t?.error?.code??t?.code;return typeof r=="string"&&r.length>0?m(r,e):U(e)!==null?N:null}function V(e){let t=e,r=t?.error?.message??t?.message;return typeof r=="string"&&r.length>0?r:null}function W(e){let t=e;return t?.error?.retryable===true||t?.retryable===true}function Z(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var G=["sk_partner_","rk_partner_"];function Q(t,r){if(typeof t!="string"||t.length===0)throw new e("invalid-argument","partnerSecretKey is required");if(t.startsWith("pk_"))throw new e("invalid-argument",`partnerSecretKey is a publishable key (pk_...): ${r} needs your secret key, server side only`);if(!G.some(e=>t.startsWith(e)))throw new e("invalid-argument","partnerSecretKey must be an sk_partner_ secret key or an rk_partner_ restricted key")}var X=128;function assertValidUserRef(t){let r=typeof t=="string"?[...t].length:0;if(typeof t!="string"||r<1||r>X)throw new e("invalid-argument",`user_ref must be 1..${X} characters`);if(t.trim().length===0)throw new e("invalid-argument","user_ref must not be blank: the server strips surrounding whitespace before validating, so a whitespace-only value arrives empty and is rejected as required.");if(t!==t.trim())throw new e("invalid-argument","user_ref must not have leading or trailing whitespace: the server strips it, so padded and unpadded forms of the same id resolve to ONE user. Pass the exact id you want to key on.");if(t.includes("@"))throw new e("invalid-argument","user_ref must not contain '@'");if(!H(t))throw new e("invalid-argument","user_ref must be printable (no control characters)");return t}function H(e){return!J.test(e)}var J=/[\p{Cc}\p{Cf}\p{Cs}\p{Co}\p{Cn}\p{Zl}\p{Zp}]|(?!\u0020)[\p{Zs}]/u,ee="user_ref_invalid";function te(e){let t=e.raw,r=typeof t=="object"&&t!==null?t:null,n=(r!==null&&typeof r.error=="object"&&r.error!==null?r.error.code:void 0)??r?.code;return n!==ee&&e.reasonCode!==ee?e:makeEverfurError("validationFailed",{retryable:false,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId!==void 0?{requestId:e.requestId}:{},...typeof n=="string"?{wireCode:n}:{},reasonCode:ee,...e.wireMessage!==void 0?{wireMessage:e.wireMessage}:{},...t!==void 0?{raw:t}:{}})}function re(e){let t=e.raw;if(typeof t!="object"||t===null)return null;let r=t.code;return typeof r=="string"&&r.length>0?r:null}function ne(e,t){let r=re(e);if(r===null)return e;let n=t[r];return n===void 0?e:makeEverfurError(n.code,{retryable:n.retryable,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId!==void 0?{requestId:e.requestId}:{},wireCode:r,reasonCode:r,...e.wireMessage!==void 0?{wireMessage:e.wireMessage}:{},raw:e.raw})}function ae(e,t){let r=ne(e,t);if(r!==e||re(e)!==null)return r;let n=e.reasonCode;if(typeof n!="string")return e;let a=t[n];return a===void 0?e:makeEverfurError(a.code,{retryable:a.retryable,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId!==void 0?{requestId:e.requestId}:{},wireCode:n,reasonCode:n,...e.wireMessage!==void 0?{wireMessage:e.wireMessage}:{},raw:e.raw})}var ie=64;function oe(t){if(t!=null){if(typeof t!="string"||t.length===0||t.length>ie||/\s/.test(t))throw new e("invalid-argument",`timezone must be an IANA zone name such as 'America/Chicago' (at most ${ie} characters)`);return t}}function le(e){for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let r=e.charCodeAt(t+1);if(!(r>=56320&&r<=57343))return true;t+=1}else if(r>=56320&&r<=57343)return true}return false}function se(e){return[...e].length}var ue=/* @__PURE__ */Object.freeze({dog:"dog",canine:"dog",k9:"dog",puppy:"dog",cat:"cat",feline:"cat",kitten:"cat"});function canonicalPetSpecies(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.prototype.hasOwnProperty.call(ue,t)?ue[t]:null}var de=50,pe=128,ce=120,fe=120,ve=2e3,_e=120,he=80,me=/* @__PURE__ */new Set(["male","female","unknown"]),ye=/* @__PURE__ */new Set(["day","month","year"]),be=/* @__PURE__ */new Set(["low","medium","high","athletic"]),ge=/* @__PURE__ */new Set(["indoor","outdoor","both"]),we=/* @__PURE__ */new Set(["mild","moderate","severe"]),Se=/^(\d{4})-(\d{2})-(\d{2})$/,Ce=[["sex","sex"],["spayedNeutered","spayed_neutered"],["birthDate","birth_date"],["birthDatePrecision","birth_date_precision"],["activityLevel","activity_level"],["indoorOutdoor","indoor_outdoor"],["foodBrand","food_brand"],["foodType","food_type"],["microchipId","microchip_id"]],Ee=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];/* @__PURE__ */Object.freeze([...Ce,...Ee].map(([e])=>e));function Te(e){let t=Se.exec(e);if(t===null)return false;let[r,n,a]=[Number(t[1]),Number(t[2]),Number(t[3])],i=new Date(Date.UTC(r,n-1,a));return i.getUTCFullYear()===r&&i.getUTCMonth()===n-1&&i.getUTCDate()===a}var $e=e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,Re=(e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,Ae=(e,t)=>typeof t=="string"&&Te(t)?null:`${e} must be a real date written YYYY-MM-DD`,ke=(e,t={})=>(r,n)=>{if(typeof n!="string")return`${r} must be a string`;if(le(n))return`${r} contains an unpaired surrogate and cannot be encoded`;let a=t.trimmed?n.trim():n;if(t.required&&a.length===0)return`${r} is required and must not be blank`;let i=se(a);return i<=e?null:`${r} is ${i} characters; the server accepts at most ${e}`},Ie={sex:$e(me),spayedNeutered:Re,birthDate:Ae,birthDatePrecision:$e(ye),activityLevel:$e(be),indoorOutdoor:$e(ge),foodBrand:ke(_e),foodType:ke(_e),microchipId:ke(he)},De=["ref","ref",false,ke(pe,{required:true,trimmed:true})],Fe=["notes","notes",false,ke(ve,{trimmed:true})],Oe=[De,["name","name",true,ke(ce,{required:true,trimmed:true})],["dose","dose",false,ke(fe,{trimmed:true})],["frequency","frequency",false,ke(fe,{trimmed:true})],["startDate","start_date",false,Ae],["endDate","end_date",false,Ae],Fe],je={allergies:[De,["allergen","allergen",true,ke(ce,{required:true,trimmed:true})],["severity","severity",false,$e(we)],Fe],medications:Oe,supplements:Oe,conditions:[De,["conditionName","condition_name",true,ke(ce,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,Ae],Fe]};function Ne(e,t,r){let n=`${e}[${t}]`;if(typeof r!="object"||r===null||Array.isArray(r))return{error:`${n} must be an object`};let a=r,i={};for(let[t,r,o,l]of je[e]){let e=a[t];if(e==null){if(o)return{error:`${n}.${t} is required`};e===null&&(i[r]=null);continue}let s=l(`${n}.${t}`,e);if(s!==null)return{error:s};i[r]=e}let o=i.start_date,l=i.end_date;return typeof o=="string"&&typeof l=="string"&&l<o?{error:`${n}.endDate must not be before startDate`}:{item:i}}function xe(e,t){if(!Array.isArray(t))return{error:`${e} must be an array (send [] to clear it)`};if(t.length>de)return{error:`${e} has ${t.length} items; the server accepts at most ${de}`};let r=[],n=/* @__PURE__ */new Set;for(let a=0;a<t.length;a+=1){let i=Ne(e,a,t[a]);if("error"in i)return i;let o=i.item.ref;if(typeof o=="string"){let t=o.trim();if(n.has(t))return{error:`${e}: ref ${JSON.stringify(t)} is used twice; a ref names one item`};n.add(t)}r.push(i.item)}return{items:r}}function Ue(e,t){let r=e,n={};for(let[e,t]of Ce){let a=r[e];if(a!==void 0){if(a!==null){let t=Ie[e](e,a);if(t!==null)return{error:t}}n[t]=a}}let a=r.birthDate!==void 0,i=r.birthDatePrecision!==void 0;if(a!==i||a&&r.birthDate===null!=(r.birthDatePrecision===null))return{error:"birthDate and birthDatePrecision must be sent together, both set or both null"};for(let[e,t]of Ee){let a=r[e];if(a===void 0)continue;let i=xe(e,a);if("error"in i)return i;n[t]=i.items}return Object.keys(n).length>0&&t!==void 0&&canonicalPetSpecies(t)===null?{error:"health fields need a pet Everfur reads as a dog or a cat (dog, canine, k9, puppy, cat, feline, kitten)"}:{body:n}}var qe=e=>typeof e=="string"?e:null,Le=(e,t)=>typeof t=="string"&&e.has(t)?t:null,ze=e=>typeof e=="boolean"?e:null;function Pe(e,t){return Array.isArray(e)?/* @__PURE__ */Object.freeze(e.flatMap(e=>{if(typeof e!="object"||e===null||Array.isArray(e))return[];let r=t(e);return r===null?[]:[r]})):/* @__PURE__ */Object.freeze([])}function Me(e){let t=qe(e.name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:qe(e.ref),name:t,dose:qe(e.dose),frequency:qe(e.frequency),startDate:qe(e.start_date),endDate:qe(e.end_date),notes:qe(e.notes)})}function Ke(e){let t=e.profile_version;/* @__PURE__ */
8
+ return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:Le(me,e.sex),spayedNeutered:ze(e.spayed_neutered),birthDate:qe(e.birth_date),birthDatePrecision:Le(ye,e.birth_date_precision),activityLevel:Le(be,e.activity_level),indoorOutdoor:Le(ge,e.indoor_outdoor),foodBrand:qe(e.food_brand),foodType:qe(e.food_type),microchipId:qe(e.microchip_id),allergies:Pe(e.allergies,e=>{let t=qe(e.allergen);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:qe(e.ref),allergen:t,severity:Le(we,e.severity),notes:qe(e.notes)})}),medications:Pe(e.medications,Me),supplements:Pe(e.supplements,Me),conditions:Pe(e.conditions,e=>{let t=qe(e.condition_name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:qe(e.ref),conditionName:t,diagnosedDate:qe(e.diagnosed_date),notes:qe(e.notes)})})})}var Be=128,Ye=3e4;async function upsertPartnerPet(e,t,r){return Ve(e,"PUT",t,Xe(r,false))}async function updatePartnerPet(e,t,r){return Ve(e,"PATCH",t,Xe(r,true))}async function getPartnerPet(e,t){let r=await We(e,"GET",t,void 0);if(!("status"in r))return r;let n=await rt(r),a=requestIdOf(r);if(!r.ok)return err(errorFromResponse(r.status,q(r,n),a));let i=tt(n);return i?ok(/* @__PURE__ */Object.freeze({...i,...Ke(n)})):err(errorFromResponse(502,{error:{code:"INTERNAL_ERROR"}},a))}async function deletePartnerPet(e,t){let r=await We(e,"DELETE",t,void 0);return"status"in r?r.ok?ok(void 0):err(errorFromResponse(r.status,q(r,await rt(r)),requestIdOf(r))):r}async function Ve(e,t,r,n){let a=await We(e,t,r,n);if(!("status"in a))return a;let i=await rt(a),o=requestIdOf(a);if(!a.ok)return err(errorFromResponse(a.status,q(a,i),o));let l=tt(i);return l?ok(l):err(errorFromResponse(502,{error:{code:"INTERNAL_ERROR"}},o))}async function We(e,t,r,a){Q(e.partnerSecretKey,"writing pets");let i=Ze(r),o=e.fetchImpl??getGlobalFetch(),l=`${resolveApiBaseUrl(e.apiBaseUrl)}${i}`,s={...v(e.contractVersion??n),accept:"application/json","x-everfur-partner-secret-key":e.partnerSecretKey};a!==void 0&&(s["content-type"]="application/json");let u=new AbortController,d=setTimeout(()=>u.abort(),Ye);try{return await o(l,{method:t,headers:s,...a!==void 0?{body:a}:{},signal:u.signal})}catch(e){return err(networkError(e))}finally{clearTimeout(d)}}function Ze(t){if(typeof t!="object"||t===null)throw new e("invalid-argument","target is required");let userRef=assertValidUserRef(t.userRef);Ge("userRef",userRef);let petRef=t.petRef,r=typeof petRef=="string"?[...petRef].length:0;if(typeof petRef!="string"||r<1||r>Be)throw new e("invalid-argument",`petRef must be 1..${Be} characters`);return Ge("petRef",petRef),`/partners/members/${encodeURIComponent(userRef)}/pets/${encodeURIComponent(petRef)}`}function Ge(t,r){if(r.includes("/")||r==="."||r==="..")throw new e("invalid-argument",`${t} cannot contain '/' or be '.' or '..': it is sent as a URL path segment`)}var Qe=[["name","name"],["species","species"],["breed","breed"],["ageYears","age_years"],["weightKg","weight_kg"],["partnerLabelInstructions","partner_label_instructions"]];function Xe(t,r){let n=He(t);if(r&&Object.keys(n).length===0)throw new e("invalid-argument","updatePartnerPet needs at least one field to change");return JSON.stringify(n)}function He(t){if(typeof t!="object"||t===null||Array.isArray(t))throw new e("invalid-argument","the pet profile must be an object");let r={};for(let[e,n]of Qe)t[e]!==void 0&&(r[n]=t[e]);let n=Ue(t,t.species);if("error"in n)throw new e("invalid-argument",n.error);return Object.assign(r,n.body)}function Je(e){return e==null?null:typeof e=="string"?e:void 0}function et(e){return e==null?null:typeof e=="number"?e:void 0}function tt(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.pet_id!="string"||typeof t.pet_ref!="string"||typeof t.updated_at!="string")return null;let r=Je(t.name),n=Je(t.species),a=Je(t.breed),i=et(t.age_years),o=et(t.weight_kg);return r===void 0||n===void 0||a===void 0||i===void 0||o===void 0?null:/* @__PURE__ */Object.freeze({petId:t.pet_id,petRef:t.pet_ref,name:r,species:n,breed:a,ageYears:i,weightKg:o,updatedAt:t.updated_at})}async function rt(e){try{return await e.json()}catch{return null}}var nt=3e4;async function revokePartnerMemberSessions(t,r){if(Q(t.partnerSecretKey,"revoking member sessions"),t.partnerSecretKey.startsWith("rk_partner_"))throw new e("invalid-argument","revoking member sessions needs your unrestricted sk_partner_ secret key; an rk_partner_ restricted key is refused (unrestrictedKeyRequired)");if(typeof r!="object"||r===null)throw new e("invalid-argument","input is required");let userRef=assertValidUserRef(r.userRef),a=t.fetchImpl??getGlobalFetch(),i=`${resolveApiBaseUrl(t.apiBaseUrl)}/widget/v1/sessions/revoke`,o={...v(t.contractVersion??n),accept:"application/json","content-type":"application/json","x-everfur-partner-secret-key":t.partnerSecretKey},l=new AbortController,s=setTimeout(()=>l.abort(),nt),u;try{u=await a(i,{method:"POST",headers:o,body:JSON.stringify({user_ref:userRef}),signal:l.signal})}catch(e){return err(networkError(e))}finally{clearTimeout(s)}let d=await it(u),p=requestIdOf(u);if(!u.ok)return err(te(errorFromResponse(u.status,q(u,d),p)));let c=at(d);return c?ok(c):err(errorFromResponse(502,{error:{code:"INTERNAL_ERROR"}},p))}function at(e){if(typeof e!="object"||e===null)return null;let t=e;return t.revoked!==true||typeof t.sessions_valid_after!="number"||!Number.isFinite(t.sessions_valid_after)?null:/* @__PURE__ */Object.freeze({revoked:true,sessionsValidAfter:t.sessions_valid_after})}async function it(e){try{return await e.json()}catch{return null}}var ot=254,lt=64,st=/^[^@\s]+@[^@\s]+\.[^@\s]+$/,ut=3e4,dt=/* @__PURE__ */Object.freeze({consent_required:{code:"validationFailed",retryable:false},email_invalid:{code:"validationFailed",retryable:false},consent_invalid:{code:"validationFailed",retryable:false},timezone_invalid:{code:"validationFailed",retryable:false}});async function setPartnerMemberNotificationProfile(e,t){Q(e.partnerSecretKey,"writing a member notification profile");let r=pt(t),a=oe(t.timezone),i=JSON.stringify({email:t.email,consent:ct(t.consent),...a!==void 0?{timezone:a}:{}}),o=e.fetchImpl??getGlobalFetch(),l=`${resolveApiBaseUrl(e.apiBaseUrl)}${r}`,s={...v(e.contractVersion??n),accept:"application/json","content-type":"application/json","x-everfur-partner-secret-key":e.partnerSecretKey},u=new AbortController,d=setTimeout(()=>u.abort(),ut),p;try{p=await o(l,{method:"PUT",headers:s,body:i,signal:u.signal})}catch(e){return err(networkError(e))}finally{clearTimeout(d)}let c=await ht(p),f=requestIdOf(p);if(!p.ok)return err(ne(errorFromResponse(p.status,q(p,c),f),dt));let _=_t(c);return _?ok(_):err(errorFromResponse(502,{error:{code:"INTERNAL_ERROR"}},f))}function pt(t){if(typeof t!="object"||t===null)throw new e("invalid-argument","input is required");let userRef=assertValidUserRef(t.userRef);if(userRef.includes("/")||userRef==="."||userRef==="..")throw new e("invalid-argument","userRef cannot contain '/' or be '.' or '..': it is sent as a URL path segment");let r=t.email;if(typeof r!="string"||r.trim().length<3||r.trim().length>ot||!st.test(r.trim()))throw new e("invalid-argument",`email must be an address of at most ${ot} characters`);return`/partners/members/${encodeURIComponent(userRef)}/notification-profile`}function ct(t){if(typeof t!="object"||t===null)throw new e("invalid-argument","consent is required: an address is stored only with the stamp of the consent you collected");if(t.method!=="partner_attested")throw new e("invalid-argument","consent.method must be 'partner_attested' in this version");let r=t.version;if(typeof r!="string"||r.length===0||r.length>lt)throw new e("invalid-argument",`consent.version must be 1..${lt} characters`);let n=t.givenAt instanceof Date?t.givenAt.toISOString():t.givenAt;if(typeof n!="string"||!Number.isFinite(Date.parse(n)))throw new e("invalid-argument","consent.givenAt must be an ISO 8601 instant or a Date");return{given_at:n,method:"partner_attested",version:r}}function ft(e){return e==null?null:typeof e=="string"?e:void 0}function vt(e){if(e==null)return null;if(typeof e!="object")return;let t=e;if(!(typeof t.given_at!="string"||typeof t.method!="string"||typeof t.version!="string"))/* @__PURE__ */
9
+ return Object.freeze({givenAt:t.given_at,method:t.method,version:t.version})}function _t(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.user_ref!="string"||typeof t.updated_at!="string"||typeof t.push_enabled!="boolean"||typeof t.email_enabled!="boolean"||typeof t.active_devices!="number"||!Number.isFinite(t.active_devices))return null;let r=ft(t.email),n=ft(t.email_verified_at),a=ft(t.unsubscribed_at),i=vt(t.consent);return r===void 0||n===void 0||a===void 0||i===void 0?null:/* @__PURE__ */Object.freeze({userRef:t.user_ref,emailMasked:r,consent:i,emailVerifiedAt:n,pushEnabled:t.push_enabled,emailEnabled:t.email_enabled,unsubscribedAt:a,activeDevices:t.active_devices,updatedAt:t.updated_at})}async function ht(e){try{return await e.json()}catch{return null}}var mt=3e4;async function yt(e,t,r,a,i,o){let l=e.fetchImpl??getGlobalFetch(),s=`${resolveApiBaseUrl(e.apiBaseUrl)}${r}`,u={...v(e.contractVersion??n),accept:"application/json","content-type":"application/json","x-everfur-partner-secret-key":e.partnerSecretKey},d=new AbortController,p=setTimeout(()=>d.abort(),mt),c;try{c=await l(s,{method:t,headers:u,body:JSON.stringify(a),signal:d.signal})}catch(e){return err(networkError(e))}finally{clearTimeout(p)}let f=null;try{f=await c.json()}catch{f=null}let _=requestIdOf(c);if(!c.ok)return err(ae(errorFromResponse(c.status,q(c,f),_),i));let h=o(f);return h===null?err(errorFromResponse(502,{error:{code:"INTERNAL_ERROR"}},_)):ok(h)}var bt=/^[a-z][a-z0-9_.]{0,63}$/,gt=/^[a-z_]{1,32}$/,wt=500,St=20,Ct=/^[A-Za-z0-9._:-]{1,120}$/,Et=/* @__PURE__ */new Set(["brand_name","app_link"]),Tt=/* @__PURE__ */Object.freeze({sms_not_live:{code:"accessDenied",retryable:false},not_live:{code:"accessDenied",retryable:false},profile_missing:{code:"accessDenied",retryable:false},profile_suspended:{code:"accessDenied",retryable:false},identity_missing:{code:"accessDenied",retryable:false},identity_ambiguous:{code:"accessDenied",retryable:false},consent_not_partner:{code:"accessDenied",retryable:false},consent_version_mismatch:{code:"accessDenied",retryable:false},channel_opted_out:{code:"accessDenied",retryable:false},destination_not_allowed:{code:"accessDenied",retryable:false},template_not_found:{code:"validationFailed",retryable:false},template_not_approved:{code:"validationFailed",retryable:false},daily_cap:{code:"rateLimited",retryable:false},template_vars_missing:{code:"validationFailed",retryable:false},template_var_unexpected:{code:"validationFailed",retryable:false},template_var_invalid:{code:"validationFailed",retryable:false},template_var_reserved:{code:"validationFailed",retryable:false},member_not_found:{code:"resourceNotFound",retryable:false},idempotency_key_required:{code:"validationFailed",retryable:false},idempotency_key_reused:{code:"conflict",retryable:false}});function sendMemberText(t,r){if(Q(t.partnerSecretKey,"sending a member text"),typeof r!="object"||r===null)throw new e("invalid-argument","input is required");let userRef=assertValidUserRef(r.userRef);if(userRef.includes("/")||userRef==="."||userRef==="..")throw new e("invalid-argument","userRef cannot contain '/' or be '.' or '..': it is sent as a URL path segment");if(typeof r.templateKey!="string"||!bt.test(r.templateKey))throw new e("invalid-argument","templateKey must start with a letter and be 1 to 64 of a-z, 0-9, _ and .");let n=$t(r.vars??{}),a=r.idempotencyKey;if(typeof a!="string"||!Ct.test(a))throw new e("invalid-argument","idempotencyKey is required: 1 to 120 of A-Z, a-z, 0-9, ., _, : and -");return yt(t,"POST",`/partners/members/${encodeURIComponent(userRef)}/texts`,{template_key:r.templateKey,vars:n,idempotency_key:a},Tt,Rt)}function $t(t){if(typeof t!="object"||t===null||Array.isArray(t))throw new e("invalid-argument","vars must be an object of strings");let r=Object.entries(t);if(r.length>St)throw new e("invalid-argument",`vars carries at most ${St} values`);let n={};for(let[t,a]of r){if(!gt.test(t))throw new e("invalid-argument",`vars.${t}: a name is 1 to 32 of a-z and _`);if(Et.has(t))throw new e("invalid-argument",`vars.${t} is filled by Everfur from your texting profile`);if(typeof a!="string"||a.length>wt||a.includes(`\n`))throw new e("invalid-argument",`vars.${t} must be one line of at most ${wt} characters`);n[t]=a}return n}function Rt(e){if(e==null)/* @__PURE__ */return Object.freeze({textId:null,status:null,duplicate:null});if(typeof e!="object"||Array.isArray(e))return null;let t=e,r=t.text_id??t.message_id??t.id;/* @__PURE__ */
10
+ return Object.freeze({textId:typeof r=="string"&&r.length>0?r:null,status:typeof t.status=="string"?t.status:null,duplicate:typeof t.duplicate=="boolean"?t.duplicate:null})}var At=2e3,kt=120,It=200,Dt=600,Ft=60,Ot=1e3,jt=1e6,Nt=20,xt=120,Ut=1e4,qt=30,Lt=/^[A-Za-z][A-Za-z -]*$/,zt=10,Pt=200,Mt=50,Kt=90,Bt=5,Yt=1e8,Vt=5,Wt=300,Zt=80,Gt=12,Qt=60,Xt=/^[A-Za-z0-9._-]+$/,Ht=/^[A-Z]{3}$/,Jt=/^https:\/\/\S+$/,er=/^(species|life_stage|size|breed):[a-z0-9_-]{1,40}$/,tr=/* @__PURE__ */Object.freeze({species:["dog","cat"],life_stage:["young","adult","senior"],size:["small","medium","large"]}),rr=/* @__PURE__ */Object.freeze({catalog_empty_refused:{code:"conflict",retryable:false},catalog_shrink_refused:{code:"conflict",retryable:false}});function nr(e){let t=e.reasonCode,r=typeof t=="string"?rr[t]:void 0;if(r===void 0||e.code===r.code&&e.retryable===r.retryable)return e;let n=re(e);return makeEverfurError(r.code,{retryable:r.retryable,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId!==void 0?{requestId:e.requestId}:{},...n!==null?{wireCode:n}:{},reasonCode:t??null,...e.wireMessage!==void 0?{wireMessage:e.wireMessage}:{},raw:e.raw})}function ar(e,t){return yt(e,"PUT","/partners/catalog/products",t,rr,mr).then(e=>e.ok?e:err(nr(e.error)))}function replaceCatalog(t,r){if(Q(t.partnerSecretKey,"replacing the product catalog"),typeof r!="object"||r===null||!Array.isArray(r.products))throw new e("invalid-argument","input.products must be an array");if(r.products.length>At)throw new e("invalid-argument",`a catalog carries at most ${At} products`);let n=ir(r.confirmEmpty,"confirmEmpty"),a=ir(r.confirmShrink,"confirmShrink"),i=/* @__PURE__ */new Set,o=r.products.map((e,t)=>_r(e,t,i,"replace"));return ar(t,{products:o,...n?{confirm_empty:true}:{},...a?{confirm_shrink:true}:{}})}function mergeCatalog(t,r){if(Q(t.partnerSecretKey,"merging into the product catalog"),typeof r!="object"||r===null)throw new e("invalid-argument","input must be an object");let n=r.products??[],a=r.remove??[];if(!Array.isArray(n))throw new e("invalid-argument","input.products must be an array");if(!Array.isArray(a))throw new e("invalid-argument","input.remove must be an array");if(n.length===0&&a.length===0)throw new e("invalid-argument","a merge needs at least one product or one remove entry");if(n.length+a.length>At)throw new e("invalid-argument",`a merge names at most ${At} SKUs in products and remove together`);let i=/* @__PURE__ */new Set,o=n.map((e,t)=>_r(e,t,i,"merge")),l=/* @__PURE__ */new Set,s=a.map((t,r)=>{let n=`remove[${r}]`;if(typeof t!="string"||t.length===0||t.length>kt||!Xt.test(t))throw new e("invalid-argument",`${n} must be a partnerSku of 1 to ${kt} of A-Z a-z 0-9 . _ -`);let a=t.toLowerCase();if(l.has(a))throw new e("invalid-argument",`${n} '${t}' appears twice`);if(i.has(a))throw new e("invalid-argument",`${n} '${t}' is also in products`);return l.add(a),t});return ar(t,{mode:"merge",products:o,...s.length===0?{}:{remove:s}})}function ir(t,r){if(t===void 0)return false;if(typeof t!="boolean")throw new e("invalid-argument",`${r} must be a boolean`);return t}function or(t,r,n){if(t==null)return null;if(typeof t!="string"||t.length===0||t.length>n)throw new e("invalid-argument",`${r} must be a string of 1 to ${n} characters`);return t}function lr(t,r){if(t===void 0)return[];if(!Array.isArray(t)||t.length>2||t.some(e=>e!=="dog"&&e!=="cat"))throw new e("invalid-argument",`${r} must list at most 'dog' and 'cat'`);return[...t]}function sr(t,r){if(t===void 0)return[];if(!Array.isArray(t)||t.length>Nt)throw new e("invalid-argument",`${r} must be a list of at most ${Nt} reasons`);return t.map((t,n)=>{let a=`${r}[${n}]`,i=typeof t=="object"&&t!==null?t:{},o=i.tag,l=i.text;if(typeof o!="string"||!er.test(o))throw new e("invalid-argument",`${a}.tag must be species:, life_stage:, size: or breed: and a value`);let[s="",u=""]=o.split(":",2),d=tr[s];if(d!==void 0&&!d.includes(u))throw new e("invalid-argument",`${a}.tag: ${s} must be one of ${d.join(", ")}`);if(typeof l!="string"||l.length===0||l.length>xt)throw new e("invalid-argument",`${a}.text must be 1 to ${xt} characters`);return{tag:o,text:l}})}function ur(t,r){let n=or(t,r,Ot+8);if(n!==null&&(!Jt.test(n)||n.length-8>Ot))throw new e("invalid-argument",`${r} must be an https URL`);return n}function dr(t,r,n,a){if(typeof t!="number"||!Number.isInteger(t)||t<n||t>a)throw new e("invalid-argument",`${r} must be a whole number from ${n} to ${a}`);return t}function pr(t,r,n){if(typeof t!="number"||!Number.isFinite(t)||t<=0||t>n)throw new e("invalid-argument",`${r} must be a number above 0 and at most ${n}`);return t}function cr(t,r){if(typeof t!="object"||t===null)throw new e("invalid-argument",`${r} must be an object`);let n=dr(t.unitsPerBox,`${r}.unitsPerBox`,1,Ut),a=t.unitLabel;if(typeof a!="string"||a.length>qt||!Lt.test(a))throw new e("invalid-argument",`${r}.unitLabel must be 1 to ${qt} letters, spaces or hyphens, starting with a letter`);let i=t.doseBands;if(!Array.isArray(i)||i.length===0||i.length>zt)throw new e("invalid-argument",`${r}.doseBands must list 1 to ${zt} bands`);let o=0,l=i.map((t,n)=>{let a=`${r}.doseBands[${n}]`,l=typeof t=="object"&&t!==null?t:{},s=l.maxWeightKg??null,u=pr(l.unitsPerDay,`${a}.unitsPerDay`,Mt);if(s===null){if(n!==i.length-1)throw new e("invalid-argument",`${a}: only the last dose band may leave out maxWeightKg`);return{max_weight_kg:null,units_per_day:u}}let d=pr(s,`${a}.maxWeightKg`,Pt);if(d<=o)throw new e("invalid-argument",`${a}.maxWeightKg must be above the band before it`);return o=d,{max_weight_kg:d,units_per_day:u}});return{units_per_box:n,unit_label:a,dose_bands:l,...t.firstBoxDiscountPercent===void 0?{}:{first_box_discount_percent:dr(t.firstBoxDiscountPercent,`${r}.firstBoxDiscountPercent`,0,Kt)},...t.oneBoxDiscountPercent===void 0?{}:{one_box_discount_percent:dr(t.oneBoxDiscountPercent,`${r}.oneBoxDiscountPercent`,0,Kt)}}}function fr(t,r){if(!Array.isArray(t)||t.length>Vt)throw new e("invalid-argument",`${r} must be a list of at most ${Vt} reviews`);return t.map((t,n)=>{let a=`${r}[${n}]`,i=typeof t=="object"&&t!==null?t:{},o=i.text,l=i.by,s=dr(i.stars,`${a}.stars`,1,5);if(typeof o!="string"||o.length===0||o.length>Wt)throw new e("invalid-argument",`${a}.text must be 1 to ${Wt} characters`);if(typeof l!="string"||l.length===0||l.length>Zt)throw new e("invalid-argument",`${a}.by must be 1 to ${Zt} characters`);return{stars:s,text:o,by:l}})}function vr(t,r){if(!Array.isArray(t)||t.length>Gt)throw new e("invalid-argument",`${r} must be a list of at most ${Gt} ingredients`);return t.map((t,n)=>{let a=typeof t=="string"?t.trim():"";if(a.length===0||a.length>Qt)throw new e("invalid-argument",`${r}[${n}] must be 1 to ${Qt} characters`);return a})}function _r(t,r,n,a){let i=`products[${r}]`;if(typeof t!="object"||t===null)throw new e("invalid-argument",`${i} must be an object`);let o=t.partnerSku;if(typeof o!="string"||o.trim().length===0||o.length>kt)throw new e("invalid-argument",`${i}.partnerSku must be 1 to ${kt} characters`);let l=o.trim().toLowerCase();if(n.has(l))throw new e("invalid-argument",`${i}.partnerSku '${o}' appears twice`);if(n.add(l),typeof t.title!="string"||t.title.trim().length===0||t.title.length>It)throw new e("invalid-argument",`${i}.title must be 1 to ${It} characters`);let s=t.price??null;if(s!==null&&(typeof s!="number"||!Number.isFinite(s)||s<0||s>jt))throw new e("invalid-argument",`${i}.price must be a number from 0 to ${jt}`);let u=t.currency??null;if(u!==null&&(typeof u!="string"||!Ht.test(u)))throw new e("invalid-argument",`${i}.currency must be an ISO 4217 code such as USD`);let d=t.subscription??null;if(d!==null&&(s===null||s<=0))throw new e("invalid-argument",`${i}.subscription needs a price above 0 on the same product`);if(a==="merge"&&t.price!==void 0&&(s===null||s<=0)&&t.subscription===void 0)throw new e("invalid-argument",`${i}: a merge that clears a price or sets it to 0 must also send subscription (null to end it)`);let p=t.rating??null;if(p!==null&&(typeof p!="number"||!Number.isFinite(p)||p<0||p>Bt))throw new e("invalid-argument",`${i}.rating must be a number from 0 to ${Bt}`);let c=t.reviewCount??null;c!==null&&dr(c,`${i}.reviewCount`,0,Yt);let f=e=>a==="replace"||t[e]!==void 0,v=e=>a==="replace"?t[e]!==void 0&&t[e]!==null:t[e]!==void 0;return{partner_sku:o,title:t.title,...f("description")?{description:or(t.description,`${i}.description`,Dt)}:{},...f("form")?{form:or(t.form,`${i}.form`,Ft)}:{},...f("species")?{species:lr(t.species,`${i}.species`)}:{},...f("price")?{price:s}:{},...u===null?{}:{currency:u},...f("url")?{url:ur(t.url,`${i}.url`)}:{},...f("imageUrl")?{image_url:ur(t.imageUrl,`${i}.imageUrl`)}:{},...f("category")?{category:or(t.category,`${i}.category`,Ft)}:{},...f("reasonTags")?{reason_tags:sr(t.reasonTags,`${i}.reasonTags`)}:{},...f("sample")?{is_sample:t.sample===true}:{},...v("subscription")?{subscription:d===null?null:cr(d,`${i}.subscription`)}:{},...v("rating")?{rating:p}:{},...v("reviewCount")?{review_count:c}:{},...v("reviews")?{reviews:fr(t.reviews,`${i}.reviews`)}:{},...v("ingredients")?{ingredients:vr(t.ingredients,`${i}.ingredients`)}:{}}}function hr(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function mr(e){if(e==null)/* @__PURE__ */return Object.freeze({active:null,deactivated:null,syncRunId:null,deactivatedSkus:null});if(typeof e!="object"||Array.isArray(e))return null;let t=e,r=t.sync_run_id,n=t.deactivated_skus;/* @__PURE__ */
11
+ return Object.freeze({active:hr(t.upserted??t.active),deactivated:hr(t.deactivated),syncRunId:typeof r=="string"&&r.length>0?r:null,deactivatedSkus:Array.isArray(n)&&n.every(e=>typeof e=="string")?/* @__PURE__ */Object.freeze([...n]):null})}var yr=60,br=3600,gr=3e4;async function mintPartnerSession(e){Q(e.partnerSecretKey,"minting a session");let t=assertValidUserRef(e.userRef),r=Cr(e.ttlSeconds),a=Sr(e.membership),i=oe(e.timezone),o=e.fetchImpl??getGlobalFetch(),l=`${resolveApiBaseUrl(e.apiBaseUrl)}/widget/v1/sessions`,s={...v(e.contractVersion??n),accept:"application/json","content-type":"application/json","x-everfur-partner-secret-key":e.partnerSecretKey,"x-everfur-partner-key":e.publishableKey},u={user_ref:t};r!==void 0&&(u.ttl_seconds=r),a!==void 0&&(u.membership=a),i!==void 0&&(u.timezone=i);let d=$r(gr),p=Rr(d.signal,e.signal),c={method:"POST",headers:s,body:JSON.stringify(u),signal:p},f;try{f=await o(l,c)}catch(e){return err(networkError(e))}finally{d.cancel()}let _=await Tr(f),h=requestIdOf(f);if(!f.ok)return err(ne(te(errorFromResponse(f.status,q(f,_),h)),wr));let m=Er(_);return m?ok(m):err(errorFromResponse(502,{error:{code:"INTERNAL_ERROR"}},h))}var wr=/* @__PURE__ */Object.freeze({timezone_invalid:{code:"validationFailed",retryable:false}});function Sr(t){if(t!=null){if(t!=="member"&&t!=="free")throw new e("invalid-argument","membership must be 'member' or 'free'");return t}}function Cr(t){if(t!=null){if(!Number.isInteger(t))throw new e("invalid-argument","ttl_seconds must be an integer");return Math.min(br,Math.max(yr,t))}}function Er(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.session_token!="string"||t.session_token.length===0||typeof t.expires_at!="number")return null;let r=Array.isArray(t.capabilities)?t.capabilities.filter(e=>typeof e=="string"):[];/* @__PURE__ */
12
+ return Object.freeze({sessionToken:t.session_token,expiresAt:t.expires_at,capabilities:/* @__PURE__ */Object.freeze(r)})}async function Tr(e){try{return await e.json()}catch{return null}}function $r(e){let t=new AbortController,r=setTimeout(()=>t.abort(),e);return{signal:t.signal,cancel:()=>clearTimeout(r)}}function Rr(e,t){if(!t)return e;let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),r.signal;let n=()=>r.abort();return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),r.signal}exports.assertValidUserRef=assertValidUserRef;exports.canonicalPetSpecies=canonicalPetSpecies;exports.deletePartnerPet=deletePartnerPet;exports.getPartnerPet=getPartnerPet;exports.mergeCatalog=mergeCatalog;exports.mintPartnerSession=mintPartnerSession;exports.replaceCatalog=replaceCatalog;exports.revokePartnerMemberSessions=revokePartnerMemberSessions;exports.sendMemberText=sendMemberText;exports.setPartnerMemberNotificationProfile=setPartnerMemberNotificationProfile;exports.updatePartnerPet=updatePartnerPet;exports.upsertPartnerPet=upsertPartnerPet;
@@ -1,8 +1,8 @@
1
1
  /*! @everfur/sdk. Copyright (c) 2026 Strand Health Inc. dba Everfur. All rights reserved. Use is subject to the Everfur SDK License: https://docs.everfur.com/license */
2
2
  import { E as EverfurResult } from '../EverfurResult.d-BFH-3s6E.cjs';
3
- import { k as FetchLike } from '../config.d-BiVy0fLx.cjs';
4
- import { a as PartnerServerClient } from '../pets.d-BS6sLxY-.cjs';
5
- export { b as PartnerPet, P as PartnerPetProfile, c as PartnerPetTarget, d as PartnerPetWithProfile, e as deletePartnerPet, g as getPartnerPet, u as updatePartnerPet, f as upsertPartnerPet } from '../pets.d-BS6sLxY-.cjs';
3
+ import { k as FetchLike } from '../config.d-ClAI2RZ6.cjs';
4
+ import { a as PartnerServerClient } from '../pets.d-DXhzTNuI.cjs';
5
+ export { b as PartnerPet, P as PartnerPetProfile, c as PartnerPetTarget, d as PartnerPetWithProfile, e as deletePartnerPet, g as getPartnerPet, u as updatePartnerPet, f as upsertPartnerPet } from '../pets.d-DXhzTNuI.cjs';
6
6
  export { b as PetActivityLevel, c as PetAllergy, d as PetAllergySeverity, e as PetBirthDatePrecision, f as PetCondition, a as PetHealthProfile, P as PetHealthProfileInput, g as PetIndoorOutdoor, h as PetMedication, i as PetSex } from '../profile.d-CSs1wlXT.cjs';
7
7
  export { C as CanonicalPetSpecies, c as canonicalPetSpecies } from '../species.d-BXAIMh7I.cjs';
8
8
  import '../EverfurError.d-8NHtlgzA.cjs';
@@ -1,8 +1,8 @@
1
1
  /*! @everfur/sdk. Copyright (c) 2026 Strand Health Inc. dba Everfur. All rights reserved. Use is subject to the Everfur SDK License: https://docs.everfur.com/license */
2
2
  import { E as EverfurResult } from '../EverfurResult.d-D_-254ZY.js';
3
- import { k as FetchLike } from '../config.d-DRoQ2lAx.js';
4
- import { a as PartnerServerClient } from '../pets.d-BEqKykpu.js';
5
- export { b as PartnerPet, P as PartnerPetProfile, c as PartnerPetTarget, d as PartnerPetWithProfile, e as deletePartnerPet, g as getPartnerPet, u as updatePartnerPet, f as upsertPartnerPet } from '../pets.d-BEqKykpu.js';
3
+ import { k as FetchLike } from '../config.d-B7Z-KTGq.js';
4
+ import { a as PartnerServerClient } from '../pets.d-BpLObpfM.js';
5
+ export { b as PartnerPet, P as PartnerPetProfile, c as PartnerPetTarget, d as PartnerPetWithProfile, e as deletePartnerPet, g as getPartnerPet, u as updatePartnerPet, f as upsertPartnerPet } from '../pets.d-BpLObpfM.js';
6
6
  export { b as PetActivityLevel, c as PetAllergy, d as PetAllergySeverity, e as PetBirthDatePrecision, f as PetCondition, a as PetHealthProfile, P as PetHealthProfileInput, g as PetIndoorOutdoor, h as PetMedication, i as PetSex } from '../profile.d-CSs1wlXT.js';
7
7
  export { C as CanonicalPetSpecies, c as canonicalPetSpecies } from '../species.d-BXAIMh7I.js';
8
8
  import '../EverfurError.d-8NHtlgzA.js';