@everfur/sdk 1.5.2 → 1.5.3

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 (63) hide show
  1. package/dist/{bookingCopy.d-BL2-URcv.d.ts → bookingCopy.d-Bn8bdo89.d.ts} +4 -4
  2. package/dist/{bookingCopy.d-Dfew1pjY.d.cts → bookingCopy.d-Dg7bPM-U.d.cts} +4 -4
  3. package/dist/chat/index.cjs +1 -1
  4. package/dist/chat/index.js +1 -1
  5. package/dist/chat/lite/index.cjs +1 -1
  6. package/dist/chat/lite/index.js +1 -1
  7. package/dist/{chunk-K7YHXFPQ.js → chunk-CFEHTNKX.js} +1 -1
  8. package/dist/{chunk-2T5CB5MW.js → chunk-OU5RMGKD.js} +8 -8
  9. package/dist/{chunk-ASE36WGP.js → chunk-XGF2HYNN.js} +14 -14
  10. package/dist/{chunk-CMDCBYUH.js → chunk-ZGL2GEEI.js} +1 -1
  11. package/dist/client/index.cjs +1 -1
  12. package/dist/client/index.d.cts +1 -1
  13. package/dist/client/index.d.ts +1 -1
  14. package/dist/client/index.js +1 -1
  15. package/dist/core/index.cjs +1 -1
  16. package/dist/core/index.js +1 -1
  17. package/dist/{idempotency.d-dOFfV91-.d.ts → idempotency.d-CbB07p64.d.ts} +10 -8
  18. package/dist/{idempotency.d-CFVMhWcv.d.cts → idempotency.d-DrxKLPPe.d.cts} +10 -8
  19. package/dist/index.cjs +2 -2
  20. package/dist/index.js +2 -2
  21. package/dist/{optInView.d-ByDJMrMv.d.cts → optInView.d-ChJyJMBA.d.cts} +4 -1
  22. package/dist/{optInView.d-DVshLxbD.d.ts → optInView.d-Cps7aLQN.d.ts} +4 -1
  23. package/dist/records/index.cjs +1 -1
  24. package/dist/records/index.js +1 -1
  25. package/dist/server/events/index.cjs +1 -1
  26. package/dist/server/events/index.js +1 -1
  27. package/dist/server/index.cjs +1 -1
  28. package/dist/server/index.js +1 -1
  29. package/dist/shop/index.cjs +1 -1
  30. package/dist/shop/index.d.cts +2 -2
  31. package/dist/shop/index.d.ts +2 -2
  32. package/dist/shop/index.js +1 -1
  33. package/dist/televet/booking/index.cjs +156 -156
  34. package/dist/televet/booking/index.d.cts +2 -2
  35. package/dist/televet/booking/index.d.ts +2 -2
  36. package/dist/televet/booking/index.js +156 -156
  37. package/dist/texting/index.cjs +8 -8
  38. package/dist/texting/index.d.cts +2 -2
  39. package/dist/texting/index.d.ts +2 -2
  40. package/dist/texting/index.js +8 -8
  41. package/dist/web/health-plan/index.cjs +1 -1
  42. package/dist/web/health-plan/index.js +1 -1
  43. package/dist/web/index.cjs +3 -3
  44. package/dist/web/index.js +3 -3
  45. package/dist/web/records-sheet/index.cjs +1 -1
  46. package/dist/web/records-sheet/index.js +1 -1
  47. package/dist/web/shop/index.cjs +2 -2
  48. package/dist/web/shop/index.d.cts +2 -2
  49. package/dist/web/shop/index.d.ts +2 -2
  50. package/dist/web/shop/index.js +3 -3
  51. package/dist/web/televet/booking/index.cjs +185 -185
  52. package/dist/web/televet/booking/index.d.cts +2 -2
  53. package/dist/web/televet/booking/index.d.ts +2 -2
  54. package/dist/web/televet/booking/index.js +185 -185
  55. package/dist/web/televet/call/index.cjs +1 -1
  56. package/dist/web/televet/call/index.js +1 -1
  57. package/dist/web/texting/index.cjs +3 -4
  58. package/dist/web/texting/index.d.cts +2 -2
  59. package/dist/web/texting/index.d.ts +2 -2
  60. package/dist/web/texting/index.js +3 -4
  61. package/dist/web/ui/index.cjs +1 -1
  62. package/dist/web/ui/index.js +33 -33
  63. package/package.json +1 -1
@@ -17,9 +17,9 @@ return r.jsx(t.View,{style:[l.offstate,i],accessible:true,accessibilityState:{bu
17
17
  return r.jsx(t.View,{style:[l.offstate,i],accessible:true,accessibilityRole:"text",accessibilityLabel:a,children:a.length>0?/* @__PURE__ */r.jsx(Text,{style:l.offstateText,children:a}):null})}function Mr(e){let{color:r,space:n,radius:i,type:o}=e;return t.StyleSheet.create({offstate:{minHeight:zr,justifyContent:"center",paddingHorizontal:n.lg,paddingVertical:n.md,backgroundColor:r.surfaceCream,borderRadius:i.md,borderWidth:t.StyleSheet.hairlineWidth,borderColor:r.brandBorder},offstateText:{...face(e,"regular"),fontSize:o.size.body,lineHeight:Math.round(o.size.body*o.lineHeight.normal),color:r.text.muted},skeletonBar:{height:n.md,borderRadius:i.xs,backgroundColor:r.brandSofter}})}function Br(e){if(!(t.Platform.OS!=="ios"||e===""))try{let r=t.AccessibilityInfo?.announceForAccessibility;typeof r=="function"&&r.call(t.AccessibilityInfo,e)}catch{}}function AnnounceLine({line:t}){return e.useEffect(()=>{Br(t)},[t]),null}function EverfurTextingOptIn(n){let i=b(n,["onStatusChange"]),o=e.useMemo(()=>({copy:Ft(n.copy),brandCopy:It(n.brandCopy)}),[n.copy,n.brandCopy]),{copy:l,brandCopy:a}=o,s=useEverfurTheme(),d=e.useMemo(()=>qr(s),[s]),u=useEverfurTexting();return u.status==="signedOut"?/* @__PURE__ */r.jsxs(t.View,{style:[d.card,i.style],children:[
18
18
  /* @__PURE__ */r.jsx(Text,{style:d.title,accessibilityRole:"header",children:a.introTitle(s.meta.displayName)}),
19
19
  /* @__PURE__ */r.jsx(Text,{style:d.body,children:l.signedOut})]}):/* @__PURE__ */r.jsx(CapabilityGate,{capability:"texting",...i.renderDisabled?{renderDisabled:i.renderDisabled}:{},style:i.style,children:/* @__PURE__ */r.jsx(Rt.Provider,{value:o,children:/* @__PURE__ */r.jsx(OptInBody,{...i,texting:u,styles:d})})})}function Button({label:e,onPress:n,disabled:i=false,busy:o=false,styles:l,kind:a="primary",testID:s}){let d=a==="primary"?l.primary:a==="secondary"?l.secondary:l.link,u=a==="primary"?l.primaryLabel:a==="secondary"?l.secondaryLabel:l.linkLabel;/* @__PURE__ */
20
- return r.jsx(t.Pressable,{onPress:n,disabled:i||o,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{disabled:i||o,busy:o},style:[d,i||o?l.dimmed:null],...s===void 0?{}:{testID:s},children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:u,children:e})})}function OptInBody({texting:n,styles:i,onStatusChange:o,renderNotice:l,style:a}){let{copy:s,brandCopy:d}=Ot(),u=useEverfurTheme(),{status:c,profile:p,snapshot:f}=n,h=p?.brandName??u.meta.displayName,[b,y]=e.useState(""),[g,m]=e.useState(false),[v,_]=e.useState(""),[x,C]=e.useState(null),[w,S]=e.useState(false),[k,E]=e.useState(null),[T,j]=e.useState(false);e.useEffect(()=>{o?.(c)},[o,c]),e.useEffect(()=>{C(null),S(false)},[c]);let F=(e,n=false)=>/* @__PURE__ */r.jsx(t.View,{style:[i.card,a],accessibilityState:{busy:n},children:e}),I=(e,n)=>{let o=textingErrorText(e,f.failedAction,f.codeRefusal,s),a=textingSupportText(e,s);/* @__PURE__ */
20
+ return r.jsx(t.Pressable,{onPress:n,disabled:i||o,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{disabled:i||o,busy:o},style:[d,i||o?l.dimmed:null],...s===void 0?{}:{testID:s},children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:u,children:e})})}function OptInBody({texting:n,styles:i,onStatusChange:o,renderNotice:l,style:a}){let{copy:s,brandCopy:d}=Ot(),u=useEverfurTheme(),{status:c,profile:p,snapshot:f}=n,h=p?.brandName??u.meta.displayName,[b,y]=e.useState(""),[g,m]=e.useState(false),[v,_]=e.useState(""),[x,C]=e.useState(null),[w,S]=e.useState(false),[k,E]=e.useState(null),[T,j]=e.useState(false);e.useEffect(()=>{o?.(c)},[o,c]),e.useEffect(()=>{C(null),S(false)},[c]);let F=(e,n=false)=>/* @__PURE__ */r.jsx(t.View,{style:[i.card,a],accessibilityState:{busy:n},children:e}),I=(e,n)=>{let o=textingErrorText(e,f.failedAction,f.codeRefusal,s);/* @__PURE__ */
21
21
  return r.jsxs(t.View,{style:i.notice,accessibilityLiveRegion:"polite",children:[
22
- /* @__PURE__ */r.jsx(HostRender,{resetKey:e,render:()=>l?l(e):/* @__PURE__ */r.jsx(Text,{style:i.noticeText,children:o}),fallback:/* @__PURE__ */r.jsx(Text,{style:i.noticeText,children:o})}),a===null?null:/* @__PURE__ */r.jsx(Text,{style:i.footnote,children:a}),n===void 0?null:/* @__PURE__ */r.jsx(Button,{label:s.retry,onPress:n,styles:i,kind:"link"}),l?null:/* @__PURE__ */r.jsx(AnnounceLine,{line:a===null?o:`${o} ${a}`})]})},R=x===null?null:/* @__PURE__ */r.jsxs(r.Fragment,{children:[
22
+ /* @__PURE__ */r.jsx(HostRender,{resetKey:e,render:()=>l?l(e):/* @__PURE__ */r.jsx(Text,{style:i.noticeText,children:o}),fallback:/* @__PURE__ */r.jsx(Text,{style:i.noticeText,children:o})}),n===void 0?null:/* @__PURE__ */r.jsx(Button,{label:s.retry,onPress:n,styles:i,kind:"link"}),l?null:/* @__PURE__ */r.jsx(AnnounceLine,{line:o})]})},R=x===null?null:/* @__PURE__ */r.jsxs(r.Fragment,{children:[
23
23
  /* @__PURE__ */r.jsx(Text,{style:i.noticeText,accessibilityLiveRegion:"polite",children:textingInputProblemText(x,s)}),
24
24
  /* @__PURE__ */r.jsx(AnnounceLine,{line:textingInputProblemText(x,s)})]});if(c==="unavailable")return F(
25
25
  /* @__PURE__ */r.jsxs(r.Fragment,{children:[
@@ -68,19 +68,19 @@ return r.jsx(t.Pressable,{onPress:()=>a(n.petRef),disabled:o,accessibilityRole:"
68
68
  /* @__PURE__ */r.jsx(Button,{label:o?d.savingPet:d.savePet,kind:"secondary",busy:o,disabled:!p,styles:e,onPress:()=>{c!==null&&s(c)},testID:"texting-pet-save"}),l&&!p?/* @__PURE__ */r.jsx(Text,{style:e.footnote,children:d.petSaved}):null]})]})}function qr(e){let{color:r,radius:o,space:l,type:a,slots:s}=e,d=(t,r,n)=>({...face(e,n),fontSize:t,lineHeight:Math.round(t*a.lineHeight.snug),color:r}),u=s.card?.textColor;return t.StyleSheet.create({card:{gap:l.md,padding:l.lg,borderRadius:o.lg,borderWidth:1,borderColor:r.brandBorder,backgroundColor:r.surface,...n(s.card,1)},title:d(a.size.subtitle,u??r.text.primary,"bold"),subtitle:d(a.size.body,u??r.text.primary,"bold"),body:d(a.size.body,u??r.text.secondary,"regular"),footnote:d(a.size.caption,r.text.muted,"regular"),phone:d(a.size.body,u??r.text.primary,"bold"),label:d(a.size.caption,u??r.text.primary,"bold"),input:{minHeight:44,paddingHorizontal:l.md,borderRadius:o.md,borderWidth:1,borderColor:r.controlEdge,backgroundColor:r.surface,...d(a.size.body,r.text.primary,"regular"),...n(s.input,1),...i(s.input)},consentRow:{flexDirection:"row",alignItems:"flex-start",gap:l.sm,minHeight:44},box:{width:24,height:24,borderRadius:o.xs,borderWidth:2,borderColor:r.controlEdge,alignItems:"center",justifyContent:"center",backgroundColor:r.surface},boxChecked:{backgroundColor:r.brand,borderColor:r.brandInk},tick:{...d(a.size.caption,r.text.onBrand,"bold")},consentText:{flex:1,...d(a.size.caption,u??r.text.secondary,"regular")},primary:{minHeight:44,paddingHorizontal:l.lg,borderRadius:o.pill,alignItems:"center",justifyContent:"center",backgroundColor:r.brand,...n(s.primaryButton)},primaryLabel:{...d(a.size.body,r.text.onBrand,"bold"),...i(s.primaryButton)},secondary:{minHeight:44,paddingHorizontal:l.lg,borderRadius:o.pill,borderWidth:1,borderColor:r.brandBorder,alignItems:"center",justifyContent:"center",backgroundColor:r.surface},secondaryLabel:d(a.size.caption,r.brandInk,"bold"),link:{minHeight:44,justifyContent:"center",alignSelf:"flex-start"},linkLabel:{...d(a.size.caption,r.linkInk,"bold"),...i(s.link)},dimmed:{opacity:.5},links:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:l.md},notice:{gap:l.xs},noticeText:d(a.size.caption,r.errorRed,"regular"),confirm:{gap:l.sm,padding:l.md,borderRadius:o.md,backgroundColor:r.surfaceSubtle},petRow:{gap:l.xs},chips:{flexDirection:"row",flexWrap:"wrap",gap:l.sm},chip:{minHeight:44,paddingHorizontal:l.md,borderRadius:o.pill,borderWidth:1,borderColor:r.brandBorder,backgroundColor:r.surface,justifyContent:"center",...n(s.chip,1)},chipPicked:{backgroundColor:r.brandSoft,borderColor:r.brandInk},chipLabel:{...d(a.size.caption,r.text.primary,"regular"),...i(s.chip)},chipLabelPicked:{...face(e,"bold"),color:r.brandInk}})}var Vr=/* @__PURE__ */Symbol.for("@everfur/sdk#IntroOpen@v1"),Hr=globalThis;function Ur(e){if(typeof e!="object"||e===null)return false;let t=e;return t.holds instanceof Set&&t.listeners instanceof Set}var $r=Hr[Vr],Wr=()=>({holds:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set}),Yr=Ur($r)?$r:Hr[Vr]=Wr();function Kr(){return Yr.holds.size>0}function Gr(e){return Yr.listeners.add(e),()=>{Yr.listeners.delete(e)}}function Xr(){return e.useSyncExternalStore(Gr,Kr,Kr)}function resolveTextingAskDue(e){let t=e.enabled&&e.capabilityGranted&&e.hasProfile&&e.signedIn&&e.scheduleEligible&&!e.offeredThisSession,r=t&&e.identity==="none"&&e.surfaceReady;return{readEnabled:t,due:r}}var Qr=/* @__PURE__ */new Set(["emergency","schedule_soon"]);function textingAskThreadReady(e){if(e.isBootstrapping===true||e.isLoadingHistory===true||e.isStreaming===true||e.status==="error"||e.stopped===true)return false;let t=e.messages[e.messages.length-1];return t===void 0||t.role!=="assistant"||t.pending===true||t.checkin!==void 0||t.text.trim().length===0?false:!(typeof t.urgencyLevel=="string"&&Qr.has(t.urgencyLevel))}var Jr=/* @__PURE__ */new WeakSet;function Zr(e){return Jr.has(e)}var en="everfur.texting.askSchedule.v1",tn=2880*60*1e3,rn=3,nn=/* @__PURE__ */Object.freeze({askCount:0,nextAskAt:null,completed:false});function isTextingAskEligible(e,t){if(e.status!=="ok")return false;let{entry:r}=e;return r.completed||r.askCount>=rn?false:r.nextAskAt===null||t>=r.nextAskAt}function on(e,t){return{askCount:Math.min(e.askCount+1,rn),nextAskAt:t+tn,completed:e.completed}}function ln(e,t){return{...e,nextAskAt:t+tn}}function an(e){return{...e,completed:true}}function sn(e){return e.askCount<=0?1:e.askCount===1?2:3}function dn(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,{askCount:r,nextAskAt:n,completed:i}=t;return typeof r!="number"||!Number.isInteger(r)||r<0||n!==null&&(typeof n!="number"||!Number.isFinite(n))||typeof i!="boolean"?null:{askCount:Math.min(r,rn),nextAskAt:n,completed:i}}function un(e){let t;try{t=JSON.parse(e)}catch{return null}if(t===null||typeof t!="object"||Array.isArray(t))return null;let r={};for(let[e,n]of Object.entries(t)){let t=dn(n);if(t===null)return null;r[e]=t}return r}var cn=/* @__PURE__ */Symbol.for("@everfur/sdk/texting/ask-schedule@v1");function pn(){let e=globalThis,t=e[cn];return t===void 0&&(t={sessions:/* @__PURE__ */new Map,sessionListeners:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set,writeChain:Promise.resolve()},e[cn]=t),t.sessionListeners===void 0&&(t.sessionListeners=/* @__PURE__ */new Set),t}async function fn(e){if(Zr(e))return{status:"unreadable"};let t;try{t=await e.getItem(en)}catch{return{status:"unreadable"}}if(t===null)try{return await e.setItem(en,"{}"),await e.getItem(en)===null?{status:"unreadable"}:{status:"ok",map:{}}}catch{return{status:"unreadable"}}let r=un(t);if(r!==null)return{status:"ok",map:r};try{await e.removeItem(en)}catch{}return{status:"unreadable"}}function hn(e){let{listeners:t}=pn();return t.add(e),()=>{t.delete(e)}}function bn(e,userRef,t){let r=pn(),n=async()=>{let n=await fn(e);if(n.status!=="ok")return;let i=n.map[userRef]??nn;try{await e.setItem(en,JSON.stringify({...n.map,[userRef]:t(i)}))}catch{return}for(let e of[...r.listeners])e()},i=r.writeChain.then(n,n);return r.writeChain=i.catch(()=>{}),i}async function yn(e,userRef){let t=await fn(e);return t.status!=="ok"?{status:"unreadable"}:{status:"ok",entry:t.map[userRef]??nn}}function gn(e,userRef,t=Date.now()){return bn(e,userRef,e=>on(e,t))}function mn(e,userRef,t=Date.now()){return bn(e,userRef,e=>ln(e,t))}function vn(e,userRef){return bn(e,userRef,an)}function _n(userRef){return pn().sessions.get(userRef)??null}function xn(userRef,e){let t=pn();t.sessions.set(userRef,e);for(let e of[...t.sessionListeners])e()}function Cn(e){let{sessionListeners:t}=pn();return t.add(e),()=>{t.delete(e)}}var NO_SNAPSHOT=()=>null;function wn(){let{runtime:t}=St(),r=t.entitlements??null,n=e.useCallback(e=>r===null?()=>{}:r.subscribe(e),[r]),i=r===null?NO_SNAPSHOT:r.getSnapshot,o=e.useSyncExternalStore(n,i,i);return e.useMemo(()=>o!==null&&decideCapability("texting",o.decisions,{isPending:o.isPending}).enabled,[o])}var Sn=/* @__PURE__ */Object.freeze({status:"idle"});function kn(userRef){let{runtime:t}=St(),r=t.registry.services.kv,[n,i]=e.useState({user:null,value:Sn});return e.useEffect(()=>{if(userRef===null)return;let e=true,t=()=>{yn(r,userRef).then(t=>{e&&i({user:userRef,value:{status:"ready",read:t}})})};t();let n=hn(t);return()=>{e=false,n()}},[r,userRef]),n.user===userRef?n.value:Sn}function En(e){switch(e.status){case"enroll":case"requesting":case"code":case"confirming":return"none";case"verified":case"optingOut":case"optedOut":return"exists";default:return"unknown"}}function useTextingAsk(t={}){let r=t.enabled!==false,n=t.ready!==false,i=t.surface??"prompt",o=t.entry===true,{runtime:l,userRef:userRef}=St(),a=l.registry.services.kv,s=wn(),d=kn(r&&userRef!==null?userRef:null),u=e.useCallback(()=>userRef===null?null:_n(userRef),[userRef]),c=e.useSyncExternalStore(Cn,u,u),p=e.useCallback(e=>{userRef!==null&&xn(userRef,e)},[userRef]),f=c!==null&&c.surface===i,h=c!==null&&c.fromPrompt===true,b=f?c.stage==="handoff"?"hidden":c.stage:i==="prompt"&&h?"dismissed":"hidden",y=Date.now(),g=d.status==="ready"&&isTextingAskEligible(d.read,y),[m,v]=e.useState(null),_=o&&userRef!==null&&s,x=or(userRef!==null&&m===userRef||b!=="hidden"||f||_),C=En(x),{readEnabled:w,due:S}=resolveTextingAskDue({enabled:r,capabilityGranted:s,hasProfile:x.profile!==null,signedIn:userRef!==null,scheduleEligible:g,offeredThisSession:c!==null,identity:C,surfaceReady:n});e.useEffect(()=>{w&&userRef!==null&&v(userRef)},[w,userRef]);let k=c?.askNumber??(d.status==="ready"&&d.read.status==="ok"?sn(d.read.entry):1);e.useEffect(()=>{!S||userRef===null||_n(userRef)!==null||p({surface:i,stage:"offered",answered:false,askNumber:k})},[S,userRef,p,k,i]),e.useEffect(()=>{!f||c.stage!=="handoff"||r&&n&&s&&x.profile!==null&&C==="none"&&p({...c,stage:"offered"})},[f,c,r,n,s,x.profile,C,p]);let E=d.status==="ready"&&d.read.status==="ok"&&d.read.entry.completed;e.useEffect(()=>{userRef===null||C!=="exists"||E||d.status!=="ready"||vn(a,userRef)},[C,E,d.status,a,userRef]),e.useEffect(()=>{f&&c.stage==="enrolling"&&x.status==="verified"&&p({...c,stage:"verified"})},[f,c,x.status,p]);let T=e.useCallback(e=>userRef===null||e.answered?e:(gn(a,userRef),{...e,answered:true}),[a,userRef]),j=e.useCallback(()=>{f&&c.stage==="offered"&&p({...c,stage:"enrolling"})},[f,c,p]),F=e.useCallback(()=>{if(!f||c.stage!=="enrolling")return;let{back:e,...t}=c;p({...t,stage:e??"offered"})},[f,c,p]),I=e.useCallback(()=>{if(!(!f||c.stage!=="offered"&&c.stage!=="enrolling")){if(i==="prompt"){p({...T(c),surface:"chat",stage:"handoff",fromPrompt:true});return}c.fromPrompt===true&&c.answered&&userRef!==null&&mn(a,userRef),p({...T(c),stage:"dismissed"})}},[f,c,i,p,T,a,userRef]),{start:R}=x,O=e.useCallback(async e=>!f||c.stage!=="enrolling"?false:(c.answered||p(T(c)),R(e)),[f,c,p,T,R]),A=_&&x.profile!==null&&C==="none"&&b!=="enrolling"&&b!=="verified",P=e.useCallback(()=>{if(!A||userRef===null)return;let e=f?c:null;p({surface:i,stage:"enrolling",answered:e?.answered??false,askNumber:c?.askNumber??k,...e?.fromPrompt===true?{fromPrompt:true}:{},back:e?.stage==="offered"?"offered":"dismissed"})},[A,userRef,f,c,p,i,k]),D=x.profile?.brandName??"";return e.useMemo(()=>({stage:userRef===null?"hidden":b,brand:D,askNumber:k,texting:x,accept:j,dismiss:I,close:F,start:O,canOpen:A,open:P}),[userRef,b,D,k,x,j,I,F,O,A,P])}var Tn=/* @__PURE__ */new Set(["signedOut","unavailable","failed","verified","optingOut","optedOut"]);function jn(t,r,n,i){let{userRef:userRef}=St(),o=e.useRef(null),{canOpen:l,open:a,stage:s,texting:d}=t;e.useEffect(()=>{if(!r){o.current=null;return}if(!(userRef===null||o.current===userRef)){if(l){o.current=userRef,a();return}if(s==="enrolling"||s==="verified"){o.current=userRef;return}(!n||Tn.has(d.status))&&(o.current=userRef,p(i,"skipped"))}},[r,userRef,l,a,s,d.status,n,i])}var Fn=/* @__PURE__ */Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});function ChatTextingAskController({enabled:t,ready:r,onAsk:n,entry:i=false}){let o=useTextingAsk({enabled:t,ready:r,surface:"chat",entry:i});return e.useEffect(()=>{p(n,o)},[o,n]),null}function textingAskLines(e){return{line:Tt.chatAskLine(e.brand),accept:Et.promptAccept,dismiss:Et.promptDismiss,verified:Tt.chatAskVerified(e.brand)}}function ChatTextingAskComposer({ask:t}){let n=useEverfurTheme(),i=e.useMemo(()=>In(n),[n]);/* @__PURE__ */
69
69
  return r.jsx(AskEntry,{ask:t,styles:i})}function AskEntry({ask:n,styles:i}){let{texting:o}=n,{status:l,profile:a,snapshot:s}=o,[d,u]=e.useState(""),[c,p]=e.useState(false),[f,h]=e.useState(""),[b,y]=e.useState(null),[g,m]=e.useState(false),v={onFocus:()=>m(true),onBlur:()=>m(false)},_=g?[i.pill,i.pillFocused]:i.pill,x=l==="enroll"||l==="requesting"&&!s.resending,C=l==="code"||l==="confirming"||l==="requesting",w=e.useRef(null),S=e.useRef(null),k=l==="enroll",E=l==="code";e.useEffect(()=>{y(null)},[l]),e.useEffect(()=>{k?w.current?.focus():E&&S.current?.focus()},[k,E]);let T=/* @__PURE__ */r.jsxs(t.Pressable,{onPress:n.close,accessibilityRole:"button",accessibilityLabel:Et.close,hitSlop:8,style:i.close,testID:"texting-ask-close",children:[
70
70
  /* @__PURE__ */r.jsx(t.View,{style:[i.closeBar,i.closeBarA]}),
71
- /* @__PURE__ */r.jsx(t.View,{style:[i.closeBar,i.closeBarB]})]}),j=s.error===null?null:textingErrorText(s.error,s.failedAction,s.codeRefusal),F=s.error===null?null:textingSupportText(s.error),I=j===null?null:/* @__PURE__ */r.jsxs(t.View,{style:i.notice,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:[
72
- /* @__PURE__ */r.jsx(Text,{style:i.noticeText,children:j}),F===null?null:/* @__PURE__ */r.jsx(Text,{style:i.footnote,children:F}),
73
- /* @__PURE__ */r.jsx(AnnounceLine,{line:F===null?j:`${j} ${F}`})]}),R=b===null?null:/* @__PURE__ */r.jsxs(r.Fragment,{children:[
71
+ /* @__PURE__ */r.jsx(t.View,{style:[i.closeBar,i.closeBarB]})]}),j=s.error===null?null:textingErrorText(s.error,s.failedAction,s.codeRefusal),F=j===null?null:/* @__PURE__ */r.jsxs(t.View,{style:i.notice,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:[
72
+ /* @__PURE__ */r.jsx(Text,{style:i.noticeText,children:j}),
73
+ /* @__PURE__ */r.jsx(AnnounceLine,{line:j})]}),I=b===null?null:/* @__PURE__ */r.jsxs(r.Fragment,{children:[
74
74
  /* @__PURE__ */r.jsx(Text,{style:i.noticeText,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:textingInputProblemText(b)}),
75
75
  /* @__PURE__ */r.jsx(AnnounceLine,{line:textingInputProblemText(b)})]});if(a===null)return null;if(l==="loading"||l==="failed"||l==="signedOut"||l==="unavailable")/* @__PURE__ */
76
76
  return r.jsx(t.View,{style:i.root,testID:"texting-ask-entry",accessibilityState:{busy:l==="loading"},children:/* @__PURE__ */r.jsxs(t.View,{style:i.head,children:[
77
- /* @__PURE__ */r.jsx(t.View,{style:i.headBody,children:l==="failed"?I:null}),T]})});if(x){let e=l==="requesting",o=()=>{let e=validateTextingEnroll(d,c);y(e),e===null&&n.start(d)};/* @__PURE__ */
77
+ /* @__PURE__ */r.jsx(t.View,{style:i.headBody,children:l==="failed"?F:null}),T]})});if(x){let e=l==="requesting",o=()=>{let e=validateTextingEnroll(d,c);y(e),e===null&&n.start(d)};/* @__PURE__ */
78
78
  return r.jsxs(t.View,{style:i.root,testID:"texting-ask-phone",children:[
79
79
  /* @__PURE__ */r.jsxs(t.View,{style:i.head,children:[
80
80
  /* @__PURE__ */r.jsxs(t.View,{style:i.headBody,children:[
81
81
  /* @__PURE__ */r.jsxs(t.Pressable,{onPress:()=>p(!c),disabled:e,accessibilityRole:"checkbox",accessibilityState:{checked:c,disabled:e},accessibilityLabel:a.consentText,style:i.consentRow,testID:"texting-ask-consent",children:[
82
82
  /* @__PURE__ */r.jsx(t.View,{style:[i.box,c?i.boxChecked:null],accessibilityElementsHidden:true,importantForAccessibility:"no",children:c?/* @__PURE__ */r.jsx(Text,{style:i.tick,children:"✓"}):null}),
83
- /* @__PURE__ */r.jsx(Text,{style:i.consentText,children:a.consentText})]}),a.helpContact===null?null:/* @__PURE__ */r.jsxs(Text,{style:i.footnote,children:[Et.helpContactLabel," ",a.helpContact]})]}),T]}),R,I,
83
+ /* @__PURE__ */r.jsx(Text,{style:i.consentText,children:a.consentText})]}),a.helpContact===null?null:/* @__PURE__ */r.jsxs(Text,{style:i.footnote,children:[Et.helpContactLabel," ",a.helpContact]})]}),T]}),I,F,
84
84
  /* @__PURE__ */r.jsxs(t.View,{style:_,children:[
85
85
  /* @__PURE__ */r.jsx(Or,{value:d,onChangeText:u,editable:!e,keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",accessibilityLabel:Et.phoneLabel,placeholder:Et.phoneLabel,placeholderTextColor:i.placeholder.color,ref:w,onSubmitEditing:o,...v,style:i.field,testID:"texting-ask-phone-input"},"phone"),
86
86
  /* @__PURE__ */r.jsx(t.Pressable,{onPress:o,disabled:e,accessibilityRole:"button",accessibilityLabel:e?Et.sendingCode:Et.sendCode,accessibilityState:{disabled:e,busy:e},style:[i.primary,e?i.dimmed:null],testID:"texting-ask-send",children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:i.primaryLabel,children:e?Et.sendingCode:Et.sendCode})})]})]})}if(C){let e=l==="confirming",n=l==="requesting",a=e||n,d=()=>{let e=validateTextingCode(f);y(e),e===null&&o.confirm(f)};/* @__PURE__ */
@@ -90,7 +90,7 @@ return r.jsxs(t.View,{style:i.root,testID:"texting-ask-code",children:[
90
90
  /* @__PURE__ */r.jsxs(Text,{style:i.body,children:[Et.codeSentTo," ",formatTextingPhone(s.phoneE164)]}),
91
91
  /* @__PURE__ */r.jsxs(t.View,{style:i.links,children:[
92
92
  /* @__PURE__ */r.jsx(t.Pressable,{onPress:()=>{h(""),o.resend()},disabled:a,accessibilityRole:"button",accessibilityState:{disabled:a,busy:n},style:[i.link,a?i.dimmed:null],children:/* @__PURE__ */r.jsx(Text,{style:i.linkLabel,children:Et.requestNewCode})}),
93
- /* @__PURE__ */r.jsx(t.Pressable,{onPress:()=>{h(""),o.changeNumber()},disabled:a,accessibilityRole:"button",accessibilityState:{disabled:a},style:[i.link,a?i.dimmed:null],children:/* @__PURE__ */r.jsx(Text,{style:i.linkLabel,children:Et.changeNumber})})]})]}),T]}),R,I,
93
+ /* @__PURE__ */r.jsx(t.Pressable,{onPress:()=>{h(""),o.changeNumber()},disabled:a,accessibilityRole:"button",accessibilityState:{disabled:a},style:[i.link,a?i.dimmed:null],children:/* @__PURE__ */r.jsx(Text,{style:i.linkLabel,children:Et.changeNumber})})]})]}),T]}),I,F,
94
94
  /* @__PURE__ */r.jsxs(t.View,{style:_,children:[
95
95
  /* @__PURE__ */r.jsx(Or,{value:f,onChangeText:e=>h(e.replace(/\D/g,"")),editable:!a,keyboardType:"number-pad",textContentType:"oneTimeCode",autoComplete:"sms-otp",maxLength:6,accessibilityLabel:Et.codeLabel,placeholder:Et.codeLabel,placeholderTextColor:i.placeholder.color,ref:S,onSubmitEditing:d,...v,style:[i.field,i.digits],testID:"texting-ask-code-input"},"code"),
96
96
  /* @__PURE__ */r.jsx(t.Pressable,{onPress:d,disabled:a,accessibilityRole:"button",accessibilityLabel:e?Et.confirmingCode:Et.confirmCode,accessibilityState:{disabled:a,busy:e},style:[i.primary,a?i.dimmed:null],testID:"texting-ask-confirm",children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:i.primaryLabel,children:e?Et.confirmingCode:Et.confirmCode})})]})]})}return null}function In(e,r="auto"){let{color:o,radius:l,space:a,type:s,slots:d}=e,u=(t,r,n)=>({...face(e,n),fontSize:t,lineHeight:Math.round(t*s.lineHeight.snug),color:r}),c={textAlign:r};return t.StyleSheet.create({root:{gap:a.sm,width:"100%"},head:{flexDirection:"row",alignItems:"flex-start",gap:a.sm},headBody:{flex:1,minWidth:0,gap:a.xs},consentRow:{flexDirection:"row",alignItems:"flex-start",gap:a.sm,minHeight:44},box:{width:24,height:24,borderRadius:l.xs,borderWidth:2,borderColor:o.controlEdge,alignItems:"center",justifyContent:"center",backgroundColor:o.surface},boxChecked:{backgroundColor:o.brand,borderColor:o.brandInk},tick:u(s.size.caption,o.text.onBrand,"bold"),consentText:{...r==="center"?{flexShrink:1}:{flex:1},...u(s.size.caption,o.text.secondary,"regular"),...c},body:{...u(s.size.body,o.text.primary,"regular"),...c},footnote:{...u(s.size.caption,o.text.muted,"regular"),...c},placeholder:{color:o.text.placeholder},pill:{flexDirection:"row",alignItems:"center",gap:a.xs,minHeight:50,paddingVertical:a.xs,paddingLeft:a.md,paddingRight:a.xs,borderRadius:l.pill,borderWidth:1.5,borderColor:o.controlEdge,backgroundColor:o.surface,...n(d.input,1)},pillFocused:{borderWidth:1.5,borderColor:d.input?.borderColor??o.brandInk},field:{flex:1,minWidth:0,minHeight:44,padding:0,...u(s.size.body,o.text.primary,"regular"),...i(d.input)},digits:{fontVariant:["tabular-nums"]},primary:{minHeight:44,paddingHorizontal:a.lg,borderRadius:l.pill,alignItems:"center",justifyContent:"center",backgroundColor:o.brand,...n(d.primaryButton)},primaryLabel:{...u(s.size.caption,o.text.onBrand,"bold"),...i(d.primaryButton)},dimmed:{opacity:.5},close:{width:44,height:44,alignItems:"center",justifyContent:"center"},closeBar:{position:"absolute",width:18,height:2,borderRadius:1,backgroundColor:o.text.muted},closeBarA:{transform:[{rotate:"45deg"}]},closeBarB:{transform:[{rotate:"-45deg"}]},links:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:a.md},link:{minHeight:44,justifyContent:"center"},linkLabel:{...u(s.size.caption,o.linkInk,"bold"),...i(d.link)},notice:{gap:a.xs},noticeText:{...u(s.size.caption,o.errorRed,"regular"),...c}})}var Rn=["portrait","landscape"],On=/* @__PURE__ */new Set(["offered","enrolling"]);function EverfurTextingPrompt({onResolved:n,requested:i=false}){let o=Xr(),l=useTextingAsk({surface:"prompt",ready:!o,entry:i});jn(l,i,wn(),n);let a=useEverfurTheme(),s=e.useMemo(()=>An(a),[a]),d=e.useMemo(()=>In(a,"center"),[a]),u=e.useRef(false),[c,f]=e.useState(false);On.has(l.stage)&&(u.current=true);let h=u.current&&(On.has(l.stage)||l.stage==="verified")&&!c&&!o,b=()=>{c||(l.stage==="verified"?(f(true),p(n,"verified")):l.dismiss())};if(e.useEffect(()=>{u.current&&l.stage==="dismissed"&&!c&&(f(true),p(n,"dismissed"))},[l.stage,n,c]),!h)return null;let y=l.stage==="verified"?Et.verifiedTitle:Tt.promptTitle(l.brand);/* @__PURE__ */
@@ -4,8 +4,8 @@ import { StyleProp, ViewStyle } from 'react-native';
4
4
  import { a as CapabilityDecision } from '../resolve.d-BTC3b6FW.cjs';
5
5
  import { E as EverfurError } from '../EverfurError.d-8NHtlgzA.cjs';
6
6
  export { a as EverfurErrorCategory, b as EverfurErrorCode } from '../EverfurError.d-8NHtlgzA.cjs';
7
- import { E as EverfurTextingViewStatus, T as TextingCopy, a as TextingBrandCopy, b as TextingAsk } from '../optInView.d-ByDJMrMv.cjs';
8
- export { C as COPY_PLACEHOLDER_PREFIX, c as EVERFUR_TEXTING_STATUSES, d as EverfurTextingChallenge, e as EverfurTextingIdentity, f as EverfurTextingInputProblem, g as EverfurTextingProfile, h as EverfurTextingReason, i as EverfurTextingState, j as EverfurTextingStatus, k as EverfurTextingVerificationInput, l as TEXTING_ASK_MAX_ASKS, m as TEXTING_ASK_SCHEDULE_KEY, n as TEXTING_ASK_SNOOZE_MS, o as TEXTING_BRAND_COPY, p as TEXTING_CODE_PATTERN, q as TEXTING_COPY, r as TEXTING_COPY_PLACEHOLDERS, s as TEXTING_UI_CODE_LENGTH, t as TextingAction, u as TextingAskDue, v as TextingAskDueInput, w as TextingAskEntry, x as TextingAskIdentity, y as TextingAskOptions, z as TextingAskScheduleRead, A as TextingAskStage, B as TextingAskThreadMessage, D as TextingAskThreadState, F as TextingCodeRefusal, G as TextingController, H as TextingPhase, I as TextingRepository, J as TextingRepositoryDeps, K as TextingRuntime, L as TextingSnapshot, M as createTextingRepository, N as createTextingRepositoryOver, O as formatTextingPhone, P as isE164, Q as isTextingAskEligible, R as parseTextingProfile, S as resolveTextingAskDue, U as textingAskThreadReady, V as textingErrorText, W as textingIdentityFromWire, X as textingInputProblemText, Y as textingOptedOutBody, Z as textingReasonOf, _ as textingSupportText, $ as toTextingE164, a0 as useEverfurTexting, a1 as useEverfurTextingProfile, a2 as useEverfurTextingRepository, a3 as useTextingAsk, a4 as validateTextingCode, a5 as validateTextingEnroll } from '../optInView.d-ByDJMrMv.cjs';
7
+ import { E as EverfurTextingViewStatus, T as TextingCopy, a as TextingBrandCopy, b as TextingAsk } from '../optInView.d-ChJyJMBA.cjs';
8
+ export { C as COPY_PLACEHOLDER_PREFIX, c as EVERFUR_TEXTING_STATUSES, d as EverfurTextingChallenge, e as EverfurTextingIdentity, f as EverfurTextingInputProblem, g as EverfurTextingProfile, h as EverfurTextingReason, i as EverfurTextingState, j as EverfurTextingStatus, k as EverfurTextingVerificationInput, l as TEXTING_ASK_MAX_ASKS, m as TEXTING_ASK_SCHEDULE_KEY, n as TEXTING_ASK_SNOOZE_MS, o as TEXTING_BRAND_COPY, p as TEXTING_CODE_PATTERN, q as TEXTING_COPY, r as TEXTING_COPY_PLACEHOLDERS, s as TEXTING_UI_CODE_LENGTH, t as TextingAction, u as TextingAskDue, v as TextingAskDueInput, w as TextingAskEntry, x as TextingAskIdentity, y as TextingAskOptions, z as TextingAskScheduleRead, A as TextingAskStage, B as TextingAskThreadMessage, D as TextingAskThreadState, F as TextingCodeRefusal, G as TextingController, H as TextingPhase, I as TextingRepository, J as TextingRepositoryDeps, K as TextingRuntime, L as TextingSnapshot, M as createTextingRepository, N as createTextingRepositoryOver, O as formatTextingPhone, P as isE164, Q as isTextingAskEligible, R as parseTextingProfile, S as resolveTextingAskDue, U as textingAskThreadReady, V as textingErrorText, W as textingIdentityFromWire, X as textingInputProblemText, Y as textingOptedOutBody, Z as textingReasonOf, _ as textingSupportText, $ as toTextingE164, a0 as useEverfurTexting, a1 as useEverfurTextingProfile, a2 as useEverfurTextingRepository, a3 as useTextingAsk, a4 as validateTextingCode, a5 as validateTextingEnroll } from '../optInView.d-ChJyJMBA.cjs';
9
9
  export { a as AnonIdentityProvider, A as AuthContext, I as IdentityProvider, M as MintedToken, T as TokenProvider } from '../identity.d-DDpXOtas.cjs';
10
10
  export { A as AcceptedFrame, a as AnalysisCompleteFrame, b as AnalysisStartedFrame, D as DeltaFrame, c as DoneFrame, E as ErrorFrame, d as EverfurRequest, e as EverfurRequestBase, F as Frame, f as FrameBase, g as FrameKind, h as FreeCapRefusal, H as HeartbeatFrame, i as HttpMethod, M as MultipartBody, T as TransportPort, U as UnknownFrame, j as UrgencyLevel } from '../config.d-ClAI2RZ6.cjs';
11
11
  export { B as Brand, C as ConversationId, P as PetRef, R as RecordsRequestId, U as UserRef, _ as __brand } from '../ids.d-B2GAAifq.cjs';
@@ -4,8 +4,8 @@ import { StyleProp, ViewStyle } from 'react-native';
4
4
  import { a as CapabilityDecision } from '../resolve.d-BTC3b6FW.js';
5
5
  import { E as EverfurError } from '../EverfurError.d-8NHtlgzA.js';
6
6
  export { a as EverfurErrorCategory, b as EverfurErrorCode } from '../EverfurError.d-8NHtlgzA.js';
7
- import { E as EverfurTextingViewStatus, T as TextingCopy, a as TextingBrandCopy, b as TextingAsk } from '../optInView.d-DVshLxbD.js';
8
- export { C as COPY_PLACEHOLDER_PREFIX, c as EVERFUR_TEXTING_STATUSES, d as EverfurTextingChallenge, e as EverfurTextingIdentity, f as EverfurTextingInputProblem, g as EverfurTextingProfile, h as EverfurTextingReason, i as EverfurTextingState, j as EverfurTextingStatus, k as EverfurTextingVerificationInput, l as TEXTING_ASK_MAX_ASKS, m as TEXTING_ASK_SCHEDULE_KEY, n as TEXTING_ASK_SNOOZE_MS, o as TEXTING_BRAND_COPY, p as TEXTING_CODE_PATTERN, q as TEXTING_COPY, r as TEXTING_COPY_PLACEHOLDERS, s as TEXTING_UI_CODE_LENGTH, t as TextingAction, u as TextingAskDue, v as TextingAskDueInput, w as TextingAskEntry, x as TextingAskIdentity, y as TextingAskOptions, z as TextingAskScheduleRead, A as TextingAskStage, B as TextingAskThreadMessage, D as TextingAskThreadState, F as TextingCodeRefusal, G as TextingController, H as TextingPhase, I as TextingRepository, J as TextingRepositoryDeps, K as TextingRuntime, L as TextingSnapshot, M as createTextingRepository, N as createTextingRepositoryOver, O as formatTextingPhone, P as isE164, Q as isTextingAskEligible, R as parseTextingProfile, S as resolveTextingAskDue, U as textingAskThreadReady, V as textingErrorText, W as textingIdentityFromWire, X as textingInputProblemText, Y as textingOptedOutBody, Z as textingReasonOf, _ as textingSupportText, $ as toTextingE164, a0 as useEverfurTexting, a1 as useEverfurTextingProfile, a2 as useEverfurTextingRepository, a3 as useTextingAsk, a4 as validateTextingCode, a5 as validateTextingEnroll } from '../optInView.d-DVshLxbD.js';
7
+ import { E as EverfurTextingViewStatus, T as TextingCopy, a as TextingBrandCopy, b as TextingAsk } from '../optInView.d-Cps7aLQN.js';
8
+ export { C as COPY_PLACEHOLDER_PREFIX, c as EVERFUR_TEXTING_STATUSES, d as EverfurTextingChallenge, e as EverfurTextingIdentity, f as EverfurTextingInputProblem, g as EverfurTextingProfile, h as EverfurTextingReason, i as EverfurTextingState, j as EverfurTextingStatus, k as EverfurTextingVerificationInput, l as TEXTING_ASK_MAX_ASKS, m as TEXTING_ASK_SCHEDULE_KEY, n as TEXTING_ASK_SNOOZE_MS, o as TEXTING_BRAND_COPY, p as TEXTING_CODE_PATTERN, q as TEXTING_COPY, r as TEXTING_COPY_PLACEHOLDERS, s as TEXTING_UI_CODE_LENGTH, t as TextingAction, u as TextingAskDue, v as TextingAskDueInput, w as TextingAskEntry, x as TextingAskIdentity, y as TextingAskOptions, z as TextingAskScheduleRead, A as TextingAskStage, B as TextingAskThreadMessage, D as TextingAskThreadState, F as TextingCodeRefusal, G as TextingController, H as TextingPhase, I as TextingRepository, J as TextingRepositoryDeps, K as TextingRuntime, L as TextingSnapshot, M as createTextingRepository, N as createTextingRepositoryOver, O as formatTextingPhone, P as isE164, Q as isTextingAskEligible, R as parseTextingProfile, S as resolveTextingAskDue, U as textingAskThreadReady, V as textingErrorText, W as textingIdentityFromWire, X as textingInputProblemText, Y as textingOptedOutBody, Z as textingReasonOf, _ as textingSupportText, $ as toTextingE164, a0 as useEverfurTexting, a1 as useEverfurTextingProfile, a2 as useEverfurTextingRepository, a3 as useTextingAsk, a4 as validateTextingCode, a5 as validateTextingEnroll } from '../optInView.d-Cps7aLQN.js';
9
9
  export { a as AnonIdentityProvider, A as AuthContext, I as IdentityProvider, M as MintedToken, T as TokenProvider } from '../identity.d-D4VtpqRr.js';
10
10
  export { A as AcceptedFrame, a as AnalysisCompleteFrame, b as AnalysisStartedFrame, D as DeltaFrame, c as DoneFrame, E as ErrorFrame, d as EverfurRequest, e as EverfurRequestBase, F as Frame, f as FrameBase, g as FrameKind, h as FreeCapRefusal, H as HeartbeatFrame, i as HttpMethod, M as MultipartBody, T as TransportPort, U as UnknownFrame, j as UrgencyLevel } from '../config.d-B7Z-KTGq.js';
11
11
  export { B as Brand, C as ConversationId, P as PetRef, R as RecordsRequestId, U as UserRef, _ as __brand } from '../ids.d-B2GAAifq.js';
@@ -17,9 +17,9 @@ return w(c,{style:[i.offstate,t],accessible:true,accessibilityState:{busy:true},
17
17
  return w(c,{style:[i.offstate,t],accessible:true,accessibilityRole:"text",accessibilityLabel:o,children:o.length>0?/* @__PURE__ */w(Text,{style:i.offstateText,children:o}):null})}function an(e){let{color:t,space:r,radius:n,type:i}=e;return h.create({offstate:{minHeight:on,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:h.hairlineWidth,borderColor:t.brandBorder},offstateText:{...face(e,"regular"),fontSize:i.size.body,lineHeight:Math.round(i.size.body*i.lineHeight.normal),color:t.text.muted},skeletonBar:{height:r.md,borderRadius:n.xs,backgroundColor:t.brandSofter}})}function sn(e){if(!(m.OS!=="ios"||e===""))try{let t=_?.announceForAccessibility;typeof t=="function"&&t.call(_,e)}catch{}}function AnnounceLine({line:e}){return i(()=>{sn(e)},[e]),null}function EverfurTextingOptIn(e){let t=L(e,["onStatusChange"]),n=r(()=>({copy:Qt(e.copy),brandCopy:Jt(e.brandCopy)}),[e.copy,e.brandCopy]),{copy:i,brandCopy:o}=n,l=useEverfurTheme(),a=r(()=>dn(l),[l]),s=useEverfurTexting();return s.status==="signedOut"?/* @__PURE__ */C(c,{style:[a.card,t.style],children:[
18
18
  /* @__PURE__ */w(Text,{style:a.title,accessibilityRole:"header",children:o.introTitle(l.meta.displayName)}),
19
19
  /* @__PURE__ */w(Text,{style:a.body,children:i.signedOut})]}):/* @__PURE__ */w(CapabilityGate,{capability:"texting",...t.renderDisabled?{renderDisabled:t.renderDisabled}:{},style:t.style,children:/* @__PURE__ */w(Xt.Provider,{value:n,children:/* @__PURE__ */w(OptInBody,{...t,texting:s,styles:a})})})}function Button({label:e,onPress:t,disabled:r=false,busy:n=false,styles:i,kind:o="primary",testID:l}){let a=o==="primary"?i.primary:o==="secondary"?i.secondary:i.link,s=o==="primary"?i.primaryLabel:o==="secondary"?i.secondaryLabel:i.linkLabel;/* @__PURE__ */
20
- return w(f,{onPress:t,disabled:r||n,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{disabled:r||n,busy:n},style:[a,r||n?i.dimmed:null],...l===void 0?{}:{testID:l},children:/* @__PURE__ */w(Text,{tier:"control",style:s,children:e})})}function OptInBody({texting:e,styles:t,onStatusChange:r,renderNotice:n,style:o}){let{copy:l,brandCopy:s}=Zt(),d=useEverfurTheme(),{status:u,profile:h,snapshot:b}=e,y=h?.brandName??d.meta.displayName,[g,m]=a(""),[v,_]=a(false),[k,x]=a(""),[T,E]=a(null),[F,I]=a(false),[R,O]=a(null),[A,D]=a(false);i(()=>{r?.(u)},[r,u]),i(()=>{E(null),I(false)},[u]);let P=(e,r=false)=>/* @__PURE__ */w(c,{style:[t.card,o],accessibilityState:{busy:r},children:e}),z=(e,r)=>{let i=textingErrorText(e,b.failedAction,b.codeRefusal,l),o=textingSupportText(e,l);/* @__PURE__ */
20
+ return w(f,{onPress:t,disabled:r||n,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{disabled:r||n,busy:n},style:[a,r||n?i.dimmed:null],...l===void 0?{}:{testID:l},children:/* @__PURE__ */w(Text,{tier:"control",style:s,children:e})})}function OptInBody({texting:e,styles:t,onStatusChange:r,renderNotice:n,style:o}){let{copy:l,brandCopy:s}=Zt(),d=useEverfurTheme(),{status:u,profile:h,snapshot:b}=e,y=h?.brandName??d.meta.displayName,[g,m]=a(""),[v,_]=a(false),[k,x]=a(""),[T,E]=a(null),[F,I]=a(false),[R,O]=a(null),[A,D]=a(false);i(()=>{r?.(u)},[r,u]),i(()=>{E(null),I(false)},[u]);let P=(e,r=false)=>/* @__PURE__ */w(c,{style:[t.card,o],accessibilityState:{busy:r},children:e}),z=(e,r)=>{let i=textingErrorText(e,b.failedAction,b.codeRefusal,l);/* @__PURE__ */
21
21
  return C(c,{style:t.notice,accessibilityLiveRegion:"polite",children:[
22
- /* @__PURE__ */w(HostRender,{resetKey:e,render:()=>n?n(e):/* @__PURE__ */w(Text,{style:t.noticeText,children:i}),fallback:/* @__PURE__ */w(Text,{style:t.noticeText,children:i})}),o===null?null:/* @__PURE__ */w(Text,{style:t.footnote,children:o}),r===void 0?null:/* @__PURE__ */w(Button,{label:l.retry,onPress:r,styles:t,kind:"link"}),n?null:/* @__PURE__ */w(AnnounceLine,{line:o===null?i:`${i} ${o}`})]})},L=T===null?null:/* @__PURE__ */C(S,{children:[
22
+ /* @__PURE__ */w(HostRender,{resetKey:e,render:()=>n?n(e):/* @__PURE__ */w(Text,{style:t.noticeText,children:i}),fallback:/* @__PURE__ */w(Text,{style:t.noticeText,children:i})}),r===void 0?null:/* @__PURE__ */w(Button,{label:l.retry,onPress:r,styles:t,kind:"link"}),n?null:/* @__PURE__ */w(AnnounceLine,{line:i})]})},L=T===null?null:/* @__PURE__ */C(S,{children:[
23
23
  /* @__PURE__ */w(Text,{style:t.noticeText,accessibilityLiveRegion:"polite",children:textingInputProblemText(T,l)}),
24
24
  /* @__PURE__ */w(AnnounceLine,{line:textingInputProblemText(T,l)})]});if(u==="unavailable")return P(
25
25
  /* @__PURE__ */C(S,{children:[
@@ -68,19 +68,19 @@ return w(f,{onPress:()=>o(t.petRef),disabled:n,accessibilityRole:"radio",accessi
68
68
  /* @__PURE__ */w(Button,{label:n?a.savingPet:a.savePet,kind:"secondary",busy:n,disabled:!u,styles:e,onPress:()=>{d!==null&&l(d)},testID:"texting-pet-save"}),i&&!u?/* @__PURE__ */w(Text,{style:e.footnote,children:a.petSaved}):null]})]})}function dn(e){let{color:t,radius:r,space:n,type:i,slots:o}=e,l=(t,r,n)=>({...face(e,n),fontSize:t,lineHeight:Math.round(t*i.lineHeight.snug),color:r}),a=o.card?.textColor;return h.create({card:{gap:n.md,padding:n.lg,borderRadius:r.lg,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,...k(o.card,1)},title:l(i.size.subtitle,a??t.text.primary,"bold"),subtitle:l(i.size.body,a??t.text.primary,"bold"),body:l(i.size.body,a??t.text.secondary,"regular"),footnote:l(i.size.caption,t.text.muted,"regular"),phone:l(i.size.body,a??t.text.primary,"bold"),label:l(i.size.caption,a??t.text.primary,"bold"),input:{minHeight:44,paddingHorizontal:n.md,borderRadius:r.md,borderWidth:1,borderColor:t.controlEdge,backgroundColor:t.surface,...l(i.size.body,t.text.primary,"regular"),...k(o.input,1),...x(o.input)},consentRow:{flexDirection:"row",alignItems:"flex-start",gap:n.sm,minHeight:44},box:{width:24,height:24,borderRadius:r.xs,borderWidth:2,borderColor:t.controlEdge,alignItems:"center",justifyContent:"center",backgroundColor:t.surface},boxChecked:{backgroundColor:t.brand,borderColor:t.brandInk},tick:{...l(i.size.caption,t.text.onBrand,"bold")},consentText:{flex:1,...l(i.size.caption,a??t.text.secondary,"regular")},primary:{minHeight:44,paddingHorizontal:n.lg,borderRadius:r.pill,alignItems:"center",justifyContent:"center",backgroundColor:t.brand,...k(o.primaryButton)},primaryLabel:{...l(i.size.body,t.text.onBrand,"bold"),...x(o.primaryButton)},secondary:{minHeight:44,paddingHorizontal:n.lg,borderRadius:r.pill,borderWidth:1,borderColor:t.brandBorder,alignItems:"center",justifyContent:"center",backgroundColor:t.surface},secondaryLabel:l(i.size.caption,t.brandInk,"bold"),link:{minHeight:44,justifyContent:"center",alignSelf:"flex-start"},linkLabel:{...l(i.size.caption,t.linkInk,"bold"),...x(o.link)},dimmed:{opacity:.5},links:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:n.md},notice:{gap:n.xs},noticeText:l(i.size.caption,t.errorRed,"regular"),confirm:{gap:n.sm,padding:n.md,borderRadius:r.md,backgroundColor:t.surfaceSubtle},petRow:{gap:n.xs},chips:{flexDirection:"row",flexWrap:"wrap",gap:n.sm},chip:{minHeight:44,paddingHorizontal:n.md,borderRadius:r.pill,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,justifyContent:"center",...k(o.chip,1)},chipPicked:{backgroundColor:t.brandSoft,borderColor:t.brandInk},chipLabel:{...l(i.size.caption,t.text.primary,"regular"),...x(o.chip)},chipLabelPicked:{...face(e,"bold"),color:t.brandInk}})}var un=/* @__PURE__ */Symbol.for("@everfur/sdk#IntroOpen@v1"),cn=globalThis;function pn(e){if(typeof e!="object"||e===null)return false;let t=e;return t.holds instanceof Set&&t.listeners instanceof Set}var fn=cn[un],hn=()=>({holds:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set}),bn=pn(fn)?fn:cn[un]=hn();function yn(){return bn.holds.size>0}function gn(e){return bn.listeners.add(e),()=>{bn.listeners.delete(e)}}function mn(){return o(gn,yn,yn)}function resolveTextingAskDue(e){let t=e.enabled&&e.capabilityGranted&&e.hasProfile&&e.signedIn&&e.scheduleEligible&&!e.offeredThisSession,r=t&&e.identity==="none"&&e.surfaceReady;return{readEnabled:t,due:r}}var vn=/* @__PURE__ */new Set(["emergency","schedule_soon"]);function textingAskThreadReady(e){if(e.isBootstrapping===true||e.isLoadingHistory===true||e.isStreaming===true||e.status==="error"||e.stopped===true)return false;let t=e.messages[e.messages.length-1];return t===void 0||t.role!=="assistant"||t.pending===true||t.checkin!==void 0||t.text.trim().length===0?false:!(typeof t.urgencyLevel=="string"&&vn.has(t.urgencyLevel))}var _n=/* @__PURE__ */new WeakSet;function Cn(e){return _n.has(e)}var wn="everfur.texting.askSchedule.v1",Sn=2880*60*1e3,kn=3,xn=/* @__PURE__ */Object.freeze({askCount:0,nextAskAt:null,completed:false});function isTextingAskEligible(e,t){if(e.status!=="ok")return false;let{entry:r}=e;return r.completed||r.askCount>=kn?false:r.nextAskAt===null||t>=r.nextAskAt}function Tn(e,t){return{askCount:Math.min(e.askCount+1,kn),nextAskAt:t+Sn,completed:e.completed}}function En(e,t){return{...e,nextAskAt:t+Sn}}function Fn(e){return{...e,completed:true}}function In(e){return e.askCount<=0?1:e.askCount===1?2:3}function Rn(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,{askCount:r,nextAskAt:n,completed:i}=t;return typeof r!="number"||!Number.isInteger(r)||r<0||n!==null&&(typeof n!="number"||!Number.isFinite(n))||typeof i!="boolean"?null:{askCount:Math.min(r,kn),nextAskAt:n,completed:i}}function On(e){let t;try{t=JSON.parse(e)}catch{return null}if(t===null||typeof t!="object"||Array.isArray(t))return null;let r={};for(let[e,n]of Object.entries(t)){let t=Rn(n);if(t===null)return null;r[e]=t}return r}var An=/* @__PURE__ */Symbol.for("@everfur/sdk/texting/ask-schedule@v1");function Dn(){let e=globalThis,t=e[An];return t===void 0&&(t={sessions:/* @__PURE__ */new Map,sessionListeners:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set,writeChain:Promise.resolve()},e[An]=t),t.sessionListeners===void 0&&(t.sessionListeners=/* @__PURE__ */new Set),t}async function Pn(e){if(Cn(e))return{status:"unreadable"};let t;try{t=await e.getItem(wn)}catch{return{status:"unreadable"}}if(t===null)try{return await e.setItem(wn,"{}"),await e.getItem(wn)===null?{status:"unreadable"}:{status:"ok",map:{}}}catch{return{status:"unreadable"}}let r=On(t);if(r!==null)return{status:"ok",map:r};try{await e.removeItem(wn)}catch{}return{status:"unreadable"}}function zn(e){let{listeners:t}=Dn();return t.add(e),()=>{t.delete(e)}}function Ln(e,userRef,t){let r=Dn(),n=async()=>{let n=await Pn(e);if(n.status!=="ok")return;let i=n.map[userRef]??xn;try{await e.setItem(wn,JSON.stringify({...n.map,[userRef]:t(i)}))}catch{return}for(let e of[...r.listeners])e()},i=r.writeChain.then(n,n);return r.writeChain=i.catch(()=>{}),i}async function jn(e,userRef){let t=await Pn(e);return t.status!=="ok"?{status:"unreadable"}:{status:"ok",entry:t.map[userRef]??xn}}function Nn(e,userRef,t=Date.now()){return Ln(e,userRef,e=>Tn(e,t))}function Bn(e,userRef,t=Date.now()){return Ln(e,userRef,e=>En(e,t))}function Mn(e,userRef){return Ln(e,userRef,Fn)}function qn(userRef){return Dn().sessions.get(userRef)??null}function Hn(userRef,e){let t=Dn();t.sessions.set(userRef,e);for(let e of[...t.sessionListeners])e()}function Un(e){let{sessionListeners:t}=Dn();return t.add(e),()=>{t.delete(e)}}var NO_SNAPSHOT=()=>null;function $n(){let{runtime:e}=Vt(),t=e.entitlements??null,n=l(e=>t===null?()=>{}:t.subscribe(e),[t]),i=t===null?NO_SNAPSHOT:t.getSnapshot,a=o(n,i,i);return r(()=>a!==null&&decideCapability("texting",a.decisions,{isPending:a.isPending}).enabled,[a])}var Vn=/* @__PURE__ */Object.freeze({status:"idle"});function Wn(userRef){let{runtime:e}=Vt(),t=e.registry.services.kv,[r,n]=a({user:null,value:Vn});return i(()=>{if(userRef===null)return;let e=true,r=()=>{jn(t,userRef).then(t=>{e&&n({user:userRef,value:{status:"ready",read:t}})})};r();let i=zn(r);return()=>{e=false,i()}},[t,userRef]),r.user===userRef?r.value:Vn}function Yn(e){switch(e.status){case"enroll":case"requesting":case"code":case"confirming":return"none";case"verified":case"optingOut":case"optedOut":return"exists";default:return"unknown"}}function useTextingAsk(e={}){let t=e.enabled!==false,n=e.ready!==false,s=e.surface??"prompt",d=e.entry===true,{runtime:u,userRef:userRef}=Vt(),c=u.registry.services.kv,p=$n(),f=Wn(t&&userRef!==null?userRef:null),h=l(()=>userRef===null?null:qn(userRef),[userRef]),b=o(Un,h,h),y=l(e=>{userRef!==null&&Hn(userRef,e)},[userRef]),g=b!==null&&b.surface===s,m=b!==null&&b.fromPrompt===true,v=g?b.stage==="handoff"?"hidden":b.stage:s==="prompt"&&m?"dismissed":"hidden",_=Date.now(),C=f.status==="ready"&&isTextingAskEligible(f.read,_),[w,S]=a(null),k=d&&userRef!==null&&p,x=Tr(userRef!==null&&w===userRef||v!=="hidden"||g||k),T=Yn(x),{readEnabled:E,due:F}=resolveTextingAskDue({enabled:t,capabilityGranted:p,hasProfile:x.profile!==null,signedIn:userRef!==null,scheduleEligible:C,offeredThisSession:b!==null,identity:T,surfaceReady:n});i(()=>{E&&userRef!==null&&S(userRef)},[E,userRef]);let I=b?.askNumber??(f.status==="ready"&&f.read.status==="ok"?In(f.read.entry):1);i(()=>{!F||userRef===null||qn(userRef)!==null||y({surface:s,stage:"offered",answered:false,askNumber:I})},[F,userRef,y,I,s]),i(()=>{!g||b.stage!=="handoff"||t&&n&&p&&x.profile!==null&&T==="none"&&y({...b,stage:"offered"})},[g,b,t,n,p,x.profile,T,y]);let R=f.status==="ready"&&f.read.status==="ok"&&f.read.entry.completed;i(()=>{userRef===null||T!=="exists"||R||f.status!=="ready"||Mn(c,userRef)},[T,R,f.status,c,userRef]),i(()=>{g&&b.stage==="enrolling"&&x.status==="verified"&&y({...b,stage:"verified"})},[g,b,x.status,y]);let O=l(e=>userRef===null||e.answered?e:(Nn(c,userRef),{...e,answered:true}),[c,userRef]),A=l(()=>{g&&b.stage==="offered"&&y({...b,stage:"enrolling"})},[g,b,y]),D=l(()=>{if(!g||b.stage!=="enrolling")return;let{back:e,...t}=b;y({...t,stage:e??"offered"})},[g,b,y]),P=l(()=>{if(!(!g||b.stage!=="offered"&&b.stage!=="enrolling")){if(s==="prompt"){y({...O(b),surface:"chat",stage:"handoff",fromPrompt:true});return}b.fromPrompt===true&&b.answered&&userRef!==null&&Bn(c,userRef),y({...O(b),stage:"dismissed"})}},[g,b,s,y,O,c,userRef]),{start:z}=x,L=l(async e=>!g||b.stage!=="enrolling"?false:(b.answered||y(O(b)),z(e)),[g,b,y,O,z]),j=k&&x.profile!==null&&T==="none"&&v!=="enrolling"&&v!=="verified",N=l(()=>{if(!j||userRef===null)return;let e=g?b:null;y({surface:s,stage:"enrolling",answered:e?.answered??false,askNumber:b?.askNumber??I,...e?.fromPrompt===true?{fromPrompt:true}:{},back:e?.stage==="offered"?"offered":"dismissed"})},[j,userRef,g,b,y,s,I]),B=x.profile?.brandName??"";return r(()=>({stage:userRef===null?"hidden":v,brand:B,askNumber:I,texting:x,accept:A,dismiss:P,close:D,start:L,canOpen:j,open:N}),[userRef,v,B,I,x,A,P,D,L,j,N])}var Kn=/* @__PURE__ */new Set(["signedOut","unavailable","failed","verified","optingOut","optedOut"]);function Gn(e,t,r,o){let{userRef:userRef}=Vt(),l=n(null),{canOpen:a,open:s,stage:d,texting:u}=e;i(()=>{if(!t){l.current=null;return}if(!(userRef===null||l.current===userRef)){if(a){l.current=userRef,s();return}if(d==="enrolling"||d==="verified"){l.current=userRef;return}(!r||Kn.has(u.status))&&(l.current=userRef,D(o,"skipped"))}},[t,userRef,a,s,d,u.status,r,o])}var Qn=/* @__PURE__ */Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});function ChatTextingAskController({enabled:e,ready:t,onAsk:r,entry:n=false}){let o=useTextingAsk({enabled:e,ready:t,surface:"chat",entry:n});return i(()=>{D(r,o)},[o,r]),null}function textingAskLines(e){return{line:Kt.chatAskLine(e.brand),accept:Yt.promptAccept,dismiss:Yt.promptDismiss,verified:Kt.chatAskVerified(e.brand)}}function ChatTextingAskComposer({ask:e}){let t=useEverfurTheme(),n=r(()=>Jn(t),[t]);/* @__PURE__ */
69
69
  return w(AskEntry,{ask:e,styles:n})}function AskEntry({ask:e,styles:t}){let{texting:r}=e,{status:o,profile:l,snapshot:s}=r,[d,u]=a(""),[p,h]=a(false),[b,y]=a(""),[g,m]=a(null),[v,_]=a(false),k={onFocus:()=>_(true),onBlur:()=>_(false)},x=v?[t.pill,t.pillFocused]:t.pill,T=o==="enroll"||o==="requesting"&&!s.resending,E=o==="code"||o==="confirming"||o==="requesting",F=n(null),I=n(null),R=o==="enroll",O=o==="code";i(()=>{m(null)},[o]),i(()=>{R?F.current?.focus():O&&I.current?.focus()},[R,O]);let A=/* @__PURE__ */C(f,{onPress:e.close,accessibilityRole:"button",accessibilityLabel:Yt.close,hitSlop:8,style:t.close,testID:"texting-ask-close",children:[
70
70
  /* @__PURE__ */w(c,{style:[t.closeBar,t.closeBarA]}),
71
- /* @__PURE__ */w(c,{style:[t.closeBar,t.closeBarB]})]}),D=s.error===null?null:textingErrorText(s.error,s.failedAction,s.codeRefusal),P=s.error===null?null:textingSupportText(s.error),z=D===null?null:/* @__PURE__ */C(c,{style:t.notice,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:[
72
- /* @__PURE__ */w(Text,{style:t.noticeText,children:D}),P===null?null:/* @__PURE__ */w(Text,{style:t.footnote,children:P}),
73
- /* @__PURE__ */w(AnnounceLine,{line:P===null?D:`${D} ${P}`})]}),L=g===null?null:/* @__PURE__ */C(S,{children:[
71
+ /* @__PURE__ */w(c,{style:[t.closeBar,t.closeBarB]})]}),D=s.error===null?null:textingErrorText(s.error,s.failedAction,s.codeRefusal),P=D===null?null:/* @__PURE__ */C(c,{style:t.notice,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:[
72
+ /* @__PURE__ */w(Text,{style:t.noticeText,children:D}),
73
+ /* @__PURE__ */w(AnnounceLine,{line:D})]}),z=g===null?null:/* @__PURE__ */C(S,{children:[
74
74
  /* @__PURE__ */w(Text,{style:t.noticeText,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:textingInputProblemText(g)}),
75
75
  /* @__PURE__ */w(AnnounceLine,{line:textingInputProblemText(g)})]});if(l===null)return null;if(o==="loading"||o==="failed"||o==="signedOut"||o==="unavailable")/* @__PURE__ */
76
76
  return w(c,{style:t.root,testID:"texting-ask-entry",accessibilityState:{busy:o==="loading"},children:/* @__PURE__ */C(c,{style:t.head,children:[
77
- /* @__PURE__ */w(c,{style:t.headBody,children:o==="failed"?z:null}),A]})});if(T){let r=o==="requesting",n=()=>{let t=validateTextingEnroll(d,p);m(t),t===null&&e.start(d)};/* @__PURE__ */
77
+ /* @__PURE__ */w(c,{style:t.headBody,children:o==="failed"?P:null}),A]})});if(T){let r=o==="requesting",n=()=>{let t=validateTextingEnroll(d,p);m(t),t===null&&e.start(d)};/* @__PURE__ */
78
78
  return C(c,{style:t.root,testID:"texting-ask-phone",children:[
79
79
  /* @__PURE__ */C(c,{style:t.head,children:[
80
80
  /* @__PURE__ */C(c,{style:t.headBody,children:[
81
81
  /* @__PURE__ */C(f,{onPress:()=>h(!p),disabled:r,accessibilityRole:"checkbox",accessibilityState:{checked:p,disabled:r},accessibilityLabel:l.consentText,style:t.consentRow,testID:"texting-ask-consent",children:[
82
82
  /* @__PURE__ */w(c,{style:[t.box,p?t.boxChecked:null],accessibilityElementsHidden:true,importantForAccessibility:"no",children:p?/* @__PURE__ */w(Text,{style:t.tick,children:"✓"}):null}),
83
- /* @__PURE__ */w(Text,{style:t.consentText,children:l.consentText})]}),l.helpContact===null?null:/* @__PURE__ */C(Text,{style:t.footnote,children:[Yt.helpContactLabel," ",l.helpContact]})]}),A]}),L,z,
83
+ /* @__PURE__ */w(Text,{style:t.consentText,children:l.consentText})]}),l.helpContact===null?null:/* @__PURE__ */C(Text,{style:t.footnote,children:[Yt.helpContactLabel," ",l.helpContact]})]}),A]}),z,P,
84
84
  /* @__PURE__ */C(c,{style:x,children:[
85
85
  /* @__PURE__ */w(Zr,{value:d,onChangeText:u,editable:!r,keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",accessibilityLabel:Yt.phoneLabel,placeholder:Yt.phoneLabel,placeholderTextColor:t.placeholder.color,ref:F,onSubmitEditing:n,...k,style:t.field,testID:"texting-ask-phone-input"},"phone"),
86
86
  /* @__PURE__ */w(f,{onPress:n,disabled:r,accessibilityRole:"button",accessibilityLabel:r?Yt.sendingCode:Yt.sendCode,accessibilityState:{disabled:r,busy:r},style:[t.primary,r?t.dimmed:null],testID:"texting-ask-send",children:/* @__PURE__ */w(Text,{tier:"control",style:t.primaryLabel,children:r?Yt.sendingCode:Yt.sendCode})})]})]})}if(E){let e=o==="confirming",n=o==="requesting",i=e||n,l=()=>{let e=validateTextingCode(b);m(e),e===null&&r.confirm(b)};/* @__PURE__ */
@@ -90,7 +90,7 @@ return C(c,{style:t.root,testID:"texting-ask-code",children:[
90
90
  /* @__PURE__ */C(Text,{style:t.body,children:[Yt.codeSentTo," ",formatTextingPhone(s.phoneE164)]}),
91
91
  /* @__PURE__ */C(c,{style:t.links,children:[
92
92
  /* @__PURE__ */w(f,{onPress:()=>{y(""),r.resend()},disabled:i,accessibilityRole:"button",accessibilityState:{disabled:i,busy:n},style:[t.link,i?t.dimmed:null],children:/* @__PURE__ */w(Text,{style:t.linkLabel,children:Yt.requestNewCode})}),
93
- /* @__PURE__ */w(f,{onPress:()=>{y(""),r.changeNumber()},disabled:i,accessibilityRole:"button",accessibilityState:{disabled:i},style:[t.link,i?t.dimmed:null],children:/* @__PURE__ */w(Text,{style:t.linkLabel,children:Yt.changeNumber})})]})]}),A]}),L,z,
93
+ /* @__PURE__ */w(f,{onPress:()=>{y(""),r.changeNumber()},disabled:i,accessibilityRole:"button",accessibilityState:{disabled:i},style:[t.link,i?t.dimmed:null],children:/* @__PURE__ */w(Text,{style:t.linkLabel,children:Yt.changeNumber})})]})]}),A]}),z,P,
94
94
  /* @__PURE__ */C(c,{style:x,children:[
95
95
  /* @__PURE__ */w(Zr,{value:b,onChangeText:e=>y(e.replace(/\D/g,"")),editable:!i,keyboardType:"number-pad",textContentType:"oneTimeCode",autoComplete:"sms-otp",maxLength:6,accessibilityLabel:Yt.codeLabel,placeholder:Yt.codeLabel,placeholderTextColor:t.placeholder.color,ref:I,onSubmitEditing:l,...k,style:[t.field,t.digits],testID:"texting-ask-code-input"},"code"),
96
96
  /* @__PURE__ */w(f,{onPress:l,disabled:i,accessibilityRole:"button",accessibilityLabel:e?Yt.confirmingCode:Yt.confirmCode,accessibilityState:{disabled:i,busy:e},style:[t.primary,i?t.dimmed:null],testID:"texting-ask-confirm",children:/* @__PURE__ */w(Text,{tier:"control",style:t.primaryLabel,children:e?Yt.confirmingCode:Yt.confirmCode})})]})]})}return null}function Jn(e,t="auto"){let{color:r,radius:n,space:i,type:o,slots:l}=e,a=(t,r,n)=>({...face(e,n),fontSize:t,lineHeight:Math.round(t*o.lineHeight.snug),color:r}),s={textAlign:t};return h.create({root:{gap:i.sm,width:"100%"},head:{flexDirection:"row",alignItems:"flex-start",gap:i.sm},headBody:{flex:1,minWidth:0,gap:i.xs},consentRow:{flexDirection:"row",alignItems:"flex-start",gap:i.sm,minHeight:44},box:{width:24,height:24,borderRadius:n.xs,borderWidth:2,borderColor:r.controlEdge,alignItems:"center",justifyContent:"center",backgroundColor:r.surface},boxChecked:{backgroundColor:r.brand,borderColor:r.brandInk},tick:a(o.size.caption,r.text.onBrand,"bold"),consentText:{...t==="center"?{flexShrink:1}:{flex:1},...a(o.size.caption,r.text.secondary,"regular"),...s},body:{...a(o.size.body,r.text.primary,"regular"),...s},footnote:{...a(o.size.caption,r.text.muted,"regular"),...s},placeholder:{color:r.text.placeholder},pill:{flexDirection:"row",alignItems:"center",gap:i.xs,minHeight:50,paddingVertical:i.xs,paddingLeft:i.md,paddingRight:i.xs,borderRadius:n.pill,borderWidth:1.5,borderColor:r.controlEdge,backgroundColor:r.surface,...k(l.input,1)},pillFocused:{borderWidth:1.5,borderColor:l.input?.borderColor??r.brandInk},field:{flex:1,minWidth:0,minHeight:44,padding:0,...a(o.size.body,r.text.primary,"regular"),...x(l.input)},digits:{fontVariant:["tabular-nums"]},primary:{minHeight:44,paddingHorizontal:i.lg,borderRadius:n.pill,alignItems:"center",justifyContent:"center",backgroundColor:r.brand,...k(l.primaryButton)},primaryLabel:{...a(o.size.caption,r.text.onBrand,"bold"),...x(l.primaryButton)},dimmed:{opacity:.5},close:{width:44,height:44,alignItems:"center",justifyContent:"center"},closeBar:{position:"absolute",width:18,height:2,borderRadius:1,backgroundColor:r.text.muted},closeBarA:{transform:[{rotate:"45deg"}]},closeBarB:{transform:[{rotate:"-45deg"}]},links:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:i.md},link:{minHeight:44,justifyContent:"center"},linkLabel:{...a(o.size.caption,r.linkInk,"bold"),...x(l.link)},notice:{gap:i.xs},noticeText:{...a(o.size.caption,r.errorRed,"regular"),...s}})}var Xn=["portrait","landscape"],Zn=/* @__PURE__ */new Set(["offered","enrolling"]);function EverfurTextingPrompt({onResolved:e,requested:t=false}){let o=mn(),l=useTextingAsk({surface:"prompt",ready:!o,entry:t});Gn(l,t,$n(),e);let s=useEverfurTheme(),d=r(()=>ei(s),[s]),u=r(()=>Jn(s,"center"),[s]),p=n(false),[h,v]=a(false);Zn.has(l.stage)&&(p.current=true);let _=p.current&&(Zn.has(l.stage)||l.stage==="verified")&&!h&&!o,k=()=>{h||(l.stage==="verified"?(v(true),D(e,"verified")):l.dismiss())};if(i(()=>{p.current&&l.stage==="dismissed"&&!h&&(v(true),D(e,"dismissed"))},[l.stage,e,h]),!_)return null;let x=l.stage==="verified"?Yt.verifiedTitle:Kt.promptTitle(l.brand);/* @__PURE__ */
@@ -3,7 +3,7 @@
3
3
  "use strict";var e=require("react"),t=require("react/jsx-runtime"),i=require("react-dom");function r(e){if(typeof e=="number")return a(e);if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;if(t.startsWith("#"))return n(t.slice(1));if(t.toLowerCase().startsWith("0x"))return n(t.slice(2));if(t.toLowerCase().startsWith("rgb"))return o(t);if(/^[0-9a-fA-F]+$/.test(t)){let e=n(t);if(e!==null)return e}return/^\d+$/.test(t)?a(Number.parseInt(t,10)):null}function n(e){let t=e.trim();if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===3)return{r:l(t[0]),g:l(t[1]),b:l(t[2]),a:1};if(t.length===6)return{r:s(t,0),g:s(t,2),b:s(t,4),a:1};if(t.length===8){let e=s(t,0);return{r:s(t,2),g:s(t,4),b:s(t,6),a:e/255}}return null}function o(e){let t=e.indexOf("("),i=e.indexOf(")");if(t<0||i<0||i<t)return null;let r=e.slice(t+1,i).split(",").map(e=>e.trim());if(r.length<3)return null;let n=u(Number(r[0])),o=u(Number(r[1])),a=u(Number(r[2]));if(n===null||o===null||a===null)return null;let s=1;if(r.length>=4){let e=Number(r[3]);if(!Number.isFinite(e))return null;s=Math.min(1,Math.max(0,e))}return{r:n,g:o,b:a,a:s}}function a(e){if(!Number.isFinite(e))return null;let t=Math.trunc(e)>>>0,i=t>>>24&255;return{r:t>>>16&255,g:t>>>8&255,b:t&255,a:i===0?1:i/255}}function s(e,t){return Number.parseInt(e.slice(t,t+2),16)}function l(e){return Number.parseInt(`${e??"0"}${e??"0"}`,16)}function u(e){return Number.isFinite(e)?Math.min(255,Math.max(0,Math.round(e))):null}function c(e,t,i){return`#${d(e)}${d(t)}${d(i)}`.toUpperCase()}function d(e){return e.toString(16).padStart(2,"0")}var p="#111111",f="#FFFFFF",m="#000000";function readableOn(e){let t=r(e);if(t===null)return f;let i=b(t),n=b({r:17,g:17,b:17}),o=b({r:255,g:255,b:255});return x(i,o)>=x(i,n)?f:p}function h(e,t){let i=readableOn(e);return contrastRatio(i,e)>=t?i:contrastRatio(f,e)>=contrastRatio(m,e)?f:m}function g(e){let t=t=>e.reduce((e,i)=>Math.min(e,contrastRatio(t,i)),Number.POSITIVE_INFINITY);return t(f)>=t(m)?f:m}function b(e){let t=v(e.r/255),i=v(e.g/255),r=v(e.b/255);return.2126*t+.7152*i+.0722*r}function v(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}function x(e,t){let i=Math.max(e,t),r=Math.min(e,t);return(i+.05)/(r+.05)}function contrastRatio(e,t){let i=r(e),n=r(t);if(i===null||n===null)return 1;let o=n.a>=1?n:{...n},a=i.a>=1?i:y(i,o);return x(b(a),b(o))}function y(e,t){let i=e.a,r=(e,t)=>Math.round(e*i+t*(1-i));return{r:r(e.r,t.r),g:r(e.g,t.g),b:r(e.b,t.b),a:1}}function w(e,t){let i=r(e),n=r(t);if(i===null||n===null)return null;let o=i.a>=1?i:y(i,{...n});return c(o.r,o.g,o.b)}function k(e,t){let i=r(e);if(i===null)return null;let n=Math.min(1,Math.max(0,t));return`rgba(${i.r}, ${i.g}, ${i.b}, ${n})`}var _=.05;function j(e,t,i,n){let o=t[0];if(o===void 0)return i;let a=e=>t.every(t=>contrastRatio(e,t)>=n);if(r(e)===null)return i;if(a(e))return e;let s=w(e,o),l=s===null?null:r(s),u=r(i);if(l===null||u===null)return i;for(let e=1;e<1/_;e+=1){let t=e*_,i=(e,i)=>Math.round(e+(i-e)*t),r=c(i(l.r,u.r),i(l.g,u.g),i(l.b,u.b));if(a(r))return r}return i}var z=/* @__PURE__ */Object.freeze({display:/* @__PURE__ */Object.freeze({size:29,lineHeight:1.06,weight:"800",face:"heading",letterSpacing:-.01,uppercase:false,tier:"heading"}),title:/* @__PURE__ */Object.freeze({size:23,lineHeight:1.12,weight:"800",face:"heading",letterSpacing:-.01,uppercase:false,tier:"heading"}),cardTitle:/* @__PURE__ */Object.freeze({size:19,lineHeight:1.22,weight:"800",face:"sans",letterSpacing:0,uppercase:false,tier:"heading"}),rowTitle:/* @__PURE__ */Object.freeze({size:15.5,lineHeight:1.4,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),body:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),message:/* @__PURE__ */Object.freeze({size:15.5,lineHeight:1.5,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),bodySmall:/* @__PURE__ */Object.freeze({size:14.5,lineHeight:1.4,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),caption:/* @__PURE__ */Object.freeze({size:13,lineHeight:1.4,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),label:/* @__PURE__ */Object.freeze({size:10.5,lineHeight:1.4,weight:"400",face:"mono",letterSpacing:.05,uppercase:true,tier:"compact"}),eyebrow:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"400",face:"mono",letterSpacing:.07,uppercase:true,tier:"compact"}),chip:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.3,weight:"600",face:"sans",letterSpacing:0,uppercase:false,tier:"compact"}),tab:/* @__PURE__ */Object.freeze({size:16,lineHeight:1.5,weight:"600",face:"sans",letterSpacing:0,uppercase:false,tier:"compact"}),button:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"control"}),badge:/* @__PURE__ */Object.freeze({size:12,lineHeight:1.5,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"badge"})});var C=Object.freeze;function deepFreeze(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){C(e);for(let t of Object.keys(e))deepFreeze(e[t])}return e}var S=/* @__PURE__ */Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3});var P={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},T={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},F={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},$={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},O={regular:"400",medium:"500",bold:"700"},E={eyebrow:1,monoWide:.9,headerBrand:-.42,tight:-.35},I=0,L="System",H="monospace",R=["content","heading","control","compact","badge"];function D(e){let t={};for(let i of R)t[i]=e;return t}var N=[];function B(){return{family:L,mono:H,fontUrl:null,families:{regular:L,medium:L,bold:L,mono:H,monoMedium:H,monoBold:H},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:F,tierSizes:D(F),lineHeight:$,weight:O,letterSpacing:E,scale:1,maxScale:I,scaleCaps:S,headingFamily:null,headingWeight:null,fontSources:N,roles:z,typeScale:1}}var A={},M=/* @__PURE__ */Object.freeze({standard:/* @__PURE__ */Object.freeze([.2,0,0,1]),emphasized:/* @__PURE__ */Object.freeze([.2,.8,.2,1]),exit:/* @__PURE__ */Object.freeze([.4,0,1,1])});function cssCubicBezier(e){return`cubic-bezier(${e.join(", ")})`}var W={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:cssCubicBezier(M.standard),emphasized:cssCubicBezier(M.emphasized),exit:cssCubicBezier(M.exit)},reducedMotion:false},q={brand:"#10462E",brandSoft:"rgba(16,70,46,0.10)",brandSofter:"rgba(16,70,46,0.15)",brandBorder:"rgba(16,70,46,0.18)",borderHairlineGreen:"rgba(16,70,46,0.25)",brandBorderStrong:"rgba(16,70,46,0.55)",brandInk:"#10462E",linkInk:"#10462E",surface:"#FFFFFF",surfaceCream:"#FFFFFF",surfaceSubtle:"#F1F5F2",background:"#FFFFFF",borderRingCream:"#E4E4E4",chatGround:"#FFFFFF",composerFill:"#FFFFFF",composerBorder:"rgba(16,70,46,0.75)",shadow:"#0B3421",text:{primary:"#000000",secondary:"#0E462E",muted:"#6B6B6B",placeholder:"rgba(61,61,61,0.75)",onBrand:"#FFFFFF",metaCool:"#3D3D3D",timestamp:"rgba(61,61,61,0.75)"},primary:"#10462E",onPrimary:"#FFFFFF",accent:"#10462E",onAccent:"#FFFFFF",accentEdge:"#07C168",success:"#07C168",danger:"#C03410",onDanger:"#FFFFFF",errorRed:"#C03410",warningStrong:"#A45610",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.12)",badgeBgCaution:"rgba(217,130,29,0.14)",badgeBgCritical:"rgba(192,52,16,0.06)",badgeBgNeutral:"rgba(107,107,107,0.12)",bubbleUser:"#10462E",bubbleAssistant:"#FFFFFF",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#E9F1E9",scanButtonPink:"#FFC3BC",highlight:"#FFC3BC",onHighlight:"#000000",mark:"#07C168",controlEdge:"rgba(16,70,46,0.18)",structureEdge:"rgba(16,70,46,0.25)",primaryEdge:"#10462E",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)",info:"#10462E",badgeBgInfo:"rgba(16,70,46,0.10)",infoEdge:"rgba(16,70,46,0.25)"},U=deepFreeze({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:q,space:P,radius:T,type:B(),motion:W,slots:A}),K={brand:"#6BD39A",brandSoft:"rgba(107,211,154,0.12)",brandSofter:"rgba(107,211,154,0.18)",brandBorder:"rgba(107,211,154,0.22)",borderHairlineGreen:"rgba(107,211,154,0.28)",brandBorderStrong:"rgba(107,211,154,0.55)",brandInk:"#6BD39A",linkInk:"#6BD39A",surface:"#1C1F23",surfaceCream:"#23272C",surfaceSubtle:"#23272C",background:"#15171A",borderRingCream:"#3A3F45",chatGround:"#1C1F23",composerFill:"#23272C",composerBorder:"rgba(107,211,154,0.75)",shadow:"#000000",text:{primary:"#F5F3F0",secondary:"#A9E4C4",muted:"#9A9A9A",placeholder:"rgba(255,255,255,0.55)",onBrand:"#0E1F17",metaCool:"#C9C9C9",timestamp:"rgba(245,243,240,0.7)"},primary:"#6BD39A",onPrimary:"#0E1F17",accent:"#6BD39A",onAccent:"#0E1F17",accentEdge:"#34D888",success:"#07C168",danger:"#F87171",onDanger:"#0E1F17",errorRed:"#FF6B5B",warningStrong:"#F0A35E",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.18)",badgeBgCaution:"rgba(217,130,29,0.20)",badgeBgCritical:"rgba(185,28,28,0.22)",badgeBgNeutral:"rgba(255,255,255,0.10)",bubbleUser:"#6BD39A",bubbleAssistant:"#1C1F23",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#23272C",scanButtonPink:"#FFC3BC",highlight:"#605051",onHighlight:"#F5F3F0",mark:"#07C168",controlEdge:"rgba(107,211,154,0.22)",structureEdge:"rgba(107,211,154,0.28)",primaryEdge:"#6BD39A",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)",info:"#6BD39A",badgeBgInfo:"rgba(107,211,154,0.12)",infoEdge:"rgba(107,211,154,0.28)"},V=deepFreeze({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:K,space:P,radius:T,type:B(),motion:W,slots:A});var G=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),Y=globalThis,X=Y[G]??(Y[G]=e.createContext(U));X.displayName??="EverfurThemeContext";function useEverfurTheme(){return e.useContext(X)}var Q={ink:"#10462E",go:"#07C168",alert:"#C03410",tintSage:"#E6ECE8"},Z=/* @__PURE__ */Symbol.for("@everfur-health/ui-core#ThemeContext@v1");function J(){let t=globalThis,i=t[Z];return i===void 0&&(i=e.createContext(null),i.displayName="EverfurThemeContext",t[Z]=i),i}var ee=(e,t)=>e.toUpperCase()===t.toUpperCase();function te(e){let t=r(e);return t!==null&&b(t)<.18}var ie=/* @__PURE__ */new WeakMap;function re(e,t){if(t===null)return e;let i=ie.get(e);i===void 0&&(i=/* @__PURE__ */new WeakMap,ie.set(e,i));let r=i.get(t);return r===void 0&&(r=ne(e,t),i.set(t,r)),r}function ne(e,t){let i=t.colors,r=!ee(i.ink,Q.ink),n=!ee(i.go,Q.go),o=e===U&&te(i.bg),a=o?V:e,s=a.color,l=e=>o||s[e]===U.color[e],u={};r&&l("primary")&&(Object.assign(u,{primary:i.ink,onPrimary:i.onInk,brand:i.ink,brandInk:i.ink}),l("linkInk")&&(u.linkInk=i.ink),!n&&l("accent")&&Object.assign(u,{accent:i.ink,onAccent:i.onInk})),n&&l("accent")&&Object.assign(u,{accent:i.go,onAccent:i.onGo}),!ee(i.alert,Q.alert)&&l("danger")&&(u.danger=i.alert),!ee(i.tintSage,Q.tintSage)&&l("brandSoft")&&(u.brandSoft=i.tintSage,l("brandSofter")&&(u.brandSofter=i.tintSage)),o&&Object.assign(u,{background:i.bg,surface:i.surface,text:{...s.text,primary:i.text,muted:i.muted},borderRingCream:i.line});let c=t.motion?.reduced===true&&!a.motion.reducedMotion;return!o&&!c&&Object.keys(u).length===0?e:{...a,color:{...s,...u},...c?{motion:{...a.motion,reducedMotion:true}}:{}}}function oe(){let t=useEverfurTheme(),i=e.useContext(J());return e.useMemo(()=>re(t,i),[t,i])}var ae=/* @__PURE__ */Object.freeze({loading:"Loading",retry:"Try again",signedOut:"Sign in required",addToCart:"Add to cart",added:"Added",remove:"Remove",checkout:"Checkout",subtotal:"Subtotal",sample:"Sample",cartEmpty:"Your cart is empty.",choosePet:"Choose a pet",emptyTitle:"",emptyBody:"",emptyAsk:""}),se=/* @__PURE__ */Object.freeze({emptyTitle:true,emptyBody:true,emptyAsk:true}),le=/* @__PURE__ */Object.freeze({dna:"",records:"Records",inside:"Inside",profile:""}),ue=/* @__PURE__ */Object.freeze({planTitle:e=>`${e}'s care plan`,cartLabel:e=>`${e} cart`}),ce=/* @__PURE__ */Object.freeze([...Object.keys(ae).filter(e=>se[e]===true&&ae[e]==="").map(e=>`HEALTH_PLAN_COPY.${e}`),...["profile"].filter(e=>le[e]==="").map(e=>`HEALTH_PLAN_REASON_LABELS.${e}`)]);var de=/* @__PURE__ */Object.freeze({imageVariant:"wide",reasonVariant:"pills",cartBarVisibility:"whenItems",cartBarPlacement:"sticky",addButtonSize:"full",addedVariant:"link",categoryVariant:"text",showCategory:false,cardShadow:false,cardBorder:true});function pe(e,t){return{setInPlan:t,addAll:async()=>{let i=(e?.items??[]).filter(e=>!e.inPlan);return(await Promise.all(i.map(e=>t(e.productId,true)))).every(Boolean)}}}function showHealthPlanCartBar(e,t){return(e??de.cartBarVisibility)==="always"||t>0}var fe=/* @__PURE__ */Object.freeze(["showCategory","cardShadow","cardBorder","addButtonSize","addButtonFontSize","addedVariant","categoryVariant","cardPadding","itemTitleSize","itemTitleWeight","priceSize","priceWeight","reasonTextSize","reasonLabelWidth","reasonGap"]);function me(e){let t={};for(let i of fe)e[i]!==void 0&&(t[i]=e[i]);return t}function he(e){let t=typeof e=="number"&&Number.isFinite(e)&&e>0?e:e==="compact"?32:44;return{height:t,hit:Math.max(44,t)}}function ge(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:null}function be(e,t){let i=ge(e);return i===null?0:i-t}function isHealthPlanSessionRequired(e){return e!==null&&(e.reasonCode==="session_required"||e.code==="sessionRequired")}var ve=/* @__PURE__ */Symbol.for("@everfur/sdk#HealthPlanCartDock@v1"),xe=globalThis,ye=xe[ve]??(xe[ve]=e.createContext(null));function HealthPlanCartScope({children:t}){let[i,r]=e.useState(null),n=e.useMemo(()=>({dock:i,publish:r}),[i]);return e.createElement(ye.Provider,{value:n},t)}function useHealthPlanCartDock(){return e.useContext(ye)?.dock??null}function we(t,i,r,petRef,n,o){let a=e.useContext(ye)?.publish,s=e.useRef(o);e.useEffect(()=>{s.current=o},[o]);let l=e.useMemo(()=>pe(n,(e,t)=>s.current(e,t)),[n]);e.useEffect(()=>{if(!(a===void 0||!t))return a(/* @__PURE__ */Object.freeze({cart:i,busy:r,petRef:petRef,plan:n,...l})),()=>a(null)},[a,t,i,r,petRef,n,l])}function healthPlanPetWords(e,t){let i=e?.trim()??"",r=i===""?"your pet":i,n=i===""?"Your pet":i;return t==="female"?{name:r,Name:n,poss:"her",Poss:"Her",obj:"her"}:t==="male"?{name:r,Name:n,poss:"his",Poss:"His",obj:"him"}:{name:r,Name:n,poss:`${r}'s`,Poss:`${n}'s`,obj:r}}var ke=e=>e===null?"":`${e.productName} renews every ${e.intervalDays} days at ${e.box??""} until you cancel; skip or cancel anytime in the app.`,_e=/* @__PURE__ */Object.freeze({onceFine:"",cartFine:ke,startedWhat:()=>""});function healthPlanFocusCopyFor(e){let t=healthPlanPetWords(e.name,e.sex),i=e=>e.petName?.trim()||t.name,NameOf=e=>e.petName?.trim()||t.Name,r=/* @__PURE__ */Object.freeze({jumpKicker:(e,i)=>i?`In ${t.poss} plan, every ${e.intervalDays} days`:e.offer?`${e.discountPercent}% off ${t.poss} first box`:e.intervalDays>0?`Ships every ${e.intervalDays} days`:r.onceLine(e),optionsLabel:"How to buy",subscribe:"Subscribe",bestValue:"Best value",subscribeLine:e=>e.offer?`First box, then ${e.box??""}`:`${e.box??""} every ${e.intervalDays} days`,priceLine:e=>e.offer?`${e.discountPercent}% off the first box. Ships every ${e.intervalDays} days.`:e.intervalDays>0?`Ships every ${e.intervalDays} days.`:r.onceOffer(e),once:"One box",onceLine:e=>e.onceDiscountPercent>0?`${e.onceDiscountPercent}% off, ships once`:"Ships once",buyOnce:e=>`Buy one box, ${e.once??e.box??""}`,subscribed:"Subscribed",subscribedLine:(e,t)=>t===null?`Every ${e.intervalDays} days`:`Every ${e.intervalDays} days · next box ${t}`,manage:"Manage",checkoutKicker:"Checkout",checkoutTitle:e=>`Checkout: ${e.productName}`,checkoutOffer:e=>`${e.discountPercent}% off your first box.`,shipsEvery:"Ships every",days:e=>`${e} days`,buyOnceOption:"Buy once",checkoutGo:(e,t,i)=>`${t?"Subscribe":"Buy now"} · ${i} today`,renews:e=>`Renews every ${e.intervalDays} days at ${e.box??""} until you cancel; skip or cancel anytime in the app.`,onceFine:"One box, ships tomorrow.",onceOffer:e=>e.onceDiscountPercent>0?`${e.onceDiscountPercent}% off, ships once.`:"Ships once.",checkoutNote:"",close:"Close",startedTitle:e=>`${NameOf(e)}'s plan has started.`,orderedTitle:()=>"Order placed.",startedWhat:e=>`${e.productName} ships tomorrow.`,startedNote:"",startedSteps:"What happens next",tomorrow:"Tomorrow",firstBoxShips:`${t.Poss} first box ships.`,trackingComesByText:"Tracking comes by text.",checkin:e=>e===null?"A 2-week check-in by text.":`A 2-week check-in by text: ${e}`,refill:`A text 3 days before ${t.poss} next box. Reply SKIP to skip it.`,nextBoxShips:e=>`${t.Poss} next box ships, ${e.box??""}.`,startedDone:`Back to ${t.poss} plan`,manageKicker:"Your subscription",manageTitle:e=>`Manage ${e.productName}`,skip:"Skip the next box",cancel:"Cancel subscription",skipped:(e,i)=>i===null?"Skipped.":`Skipped. ${t.Poss} next box ships ${i}.`,cancelled:e=>`${e.productName} is cancelled. Restart it from ${t.poss} plan anytime.`,orders:"Orders",startedHeader:"Subscribed",placedHeader:"Order placed",cartCheckoutTitle:"Checkout",orderNote:"",cartLabel:e=>e>0?`Cart, ${e} item${e>1?"s":""}`:"Cart, empty",addToCart:e=>`Add to cart · ${e}`,viewCart:"View cart",addedToCart:(e,t)=>`${e.productName} is in your cart${t?", as a subscription":""}.`,removedFromCart:e=>`${e} is out of your cart.`,cartTitle:"Cart",cartEmptyTitle:"Your cart is empty",cartEmptyBody:e=>`${NameOf(e)}'s plan pick lands here when you add it.`,seeOrders:`See ${t.poss} orders`,quantityLabel:e=>`How many: ${e}`,fewer:"One fewer",more:"One more",remove:"Remove",cartSubLine:e=>e.offer?`First box ${e.discountPercent}% off, then ${e.box??""} every ${e.intervalDays} days`:`Every ${e.intervalDays} days`,cartOnceLine:(e,i)=>i?`An extra box. ${t.Poss} plan keeps shipping.`:e.onceDiscountPercent>0?`One box, ${e.onceDiscountPercent}% off`:"One box",cartModeLabel:e=>`How to buy ${e}`,cartModeSubscribe:e=>e.offer?`Subscribe, ${e.discountPercent}% off the first box`:"Subscribe",cartModeOnce:e=>e.onceDiscountPercent>0?`One box, ${e.onceDiscountPercent}% off`:"One box",subtotal:"Subtotal",shipping:"Shipping",shippingValue:"",shippingTag:"",total:"Total",dueToday:"Due today",thenRenews:e=>`Then ${e.productName}`,renewsEvery:e=>`${e.box??""} every ${e.intervalDays} days`,checkoutCart:e=>`Checkout · ${e}`,cartOneAtATime:"",cartSubscriptionApart:"",cartItemSubscription:e=>`Subscription, every ${e.intervalDays} days`,cartItemQuantity:e=>`Qty ${e}`,placeOrder:(e,t)=>`${t?"Place order and subscribe":"Place order"} · ${e}`,cartFine:e=>`${e===null?"":`${ke(e)} `}Ships tomorrow.`,placedSteps:"What's coming",placedShips:"It ships.",placedArrives:"It arrives at home.",viewOrder:"View order",herSubscription:`${t.Poss} subscription`,nextBox:e=>`Next box ${e}`,everyDays:e=>`Every ${e} days`,ordersHeading:e=>e?"Orders":`${t.Poss} orders`,ordersFine:"",ordersEmptyTitle:"No orders yet",ordersEmptyBody:e=>`The boxes from ${i(e)}'s plan show up here.`,moreOrders:"",orderSteps:["Ordered","Shipped","Out for delivery","Delivered"],subscriptionBox:"Subscription box",orderTitle:e=>e===null?"Order":`Order ${e}`,arrivesBy:e=>`Arrives by ${e}`,deliveredOn:e=>`Delivered ${e}`,expected:e=>`Expected ${e}`,tracking:"Tracking",trackingByText:"The tracking number comes by text when it ships.",trackOn:e=>`Track on ${e}`,trackLink:"",inThisOrder:"In this order",orderItemLine:(e,t)=>`Qty ${e}${t?" · subscription box":""}`,paidWith:"Paid with",buyAgain:"Buy again",orderHelp:"Get help with this order",addWeightTitle:`Add ${t.poss} weight to size ${t.poss} dose`,addWeightBody:`From a home scale or ${t.poss} last vet visit.`,connectRecordsTitle:`Connect ${t.poss} vet records`,connectRecordsBody:`${t.Poss} weight, visits and labs make ${t.poss} plan sharper.`,weightKicker:`${t.Poss} weight`,weightTitle:e=>`Add ${i(e)}'s weight`,weightBody:`From a home scale or ${t.poss} last vet visit. ${t.Poss} plan uses it to size ${t.poss} dose.`,weightField:`${t.Poss} weight`,weightUnit:"lb",weightUnitKg:"kg",weightErrorKg:"Enter your pet’s weight",weightError:`Enter ${t.poss} weight in pounds, like 14.1.`,weightSave:`Save ${t.poss} weight`,weightSaved:e=>`Saved: ${e} lb. ${t.Poss} dose is sized for ${t.obj}.`,weightSavedKg:e=>`Saved: ${e} kg. ${t.Poss} dose is sized for ${t.obj}.`,checkoutFailed:"That didn't go through. Please try again.",builtWith:e=>`Built with ${e}`,fromVet:e=>`From ${e}`,waitVetTips:e=>`Free tips from ${e}, built around that risk`,signalsFit:e=>`${e} of ${e} signals fit ${t.Name}`,signalsValue:e=>`${e}/${e}`,noPick:`No supplement for this one. ${t.Poss} vet comes first.`,callYourVet:"Call your vet today",callAVet:"Call a vet today",saveForCheckup:`Save for ${t.poss} next checkup`,savedForCheckup:`Saved for ${t.poss} next checkup`,blanksLabel:`${t.Poss} three blanks`,blanksAsked:e=>`Asked ${e}`,blanksAskedNoClinic:"",blanksWaitPill:"2 to 5 days",blanksFilledKicker:`From ${t.poss} vet records`,blanksFilled:(e,t)=>`${e} of ${t} filled`,blanksWeight:`Keep ${t.obj} at `,blanksWeightSource:`From ${t.poss} vet visits`,blanksDose:(e,t)=>`${e} of ${t}`,blanksDoseSource:`Sized to ${t.poss} weight`,blanksShots:`${t.Poss} next shots are due `,blanksShotsSource:`From ${t.poss} clinic`,blankEmpty:"blank",recordsLanded:`${t.Poss} records are in. ${t.Poss} plan now uses ${t.poss} weight and ${t.poss} visits.`,todayLabel:`${t.Poss} Health Plan`,poweredBy:"powered by",poweredByName:"Everfur",seeMore:"See more",seeLess:"See less",reportActions:"Actions to take",openReport:`Open it in ${t.poss} report`,askReport:"Ask about it",fullOpen:`See ${t.poss} full plan`,fullOpenLine:`${t.Poss} vet, reviews and ${t.poss} checkup`,fullClose:`Show ${t.poss} brief plan`,fullCloseLine:`${t.Poss} risk, tips, pick and signs`,hopeNoted:e=>`Noted. When ${t.poss} results land, we'll start with ${e}.`,productLink:e=>`${e}, see the product`,productPhotos:e=>`${e} photos, swipe for more`,shopAll:"Shop all",madeFor:`Made for ${t.name}`,ratingLine:e=>`· ${e} reviews`,productOffer:e=>`${e.discountPercent}% off ${t.poss} first box`,productEvery:e=>`Every ${e.intervalDays} days`,productOnce:e=>e.onceDiscountPercent>0?`One box, ${e.onceDiscountPercent}% off`:"One box",productExtraBox:"An extra box",productOnPlan:e=>`On ${t.poss} plan, every ${e.intervalDays} days. This adds one extra box.`,quantity:"Quantity",description:"Description",readMore:"Read more",readLess:"Read less",whatsInside:"What's inside",howMuch:"How much",reviewsTitle:"Reviews",reviewCount:e=>`${e} reviews`,reviewsSwipe:"Reviews, swipe for more",readAllReviews:e=>`Read all ${e} reviews`,starsLabel:e=>`${e} out of 5 stars`,buyNow:"Buy now"});return r}var je=healthPlanFocusCopyFor({sex:"female"});function formatHealthPlanDay(e,t){if(e===null||!/^\d{4}-\d{2}-\d{2}$/.test(e))return null;let i=/* @__PURE__ */new Date(`${e}T00:00:00Z`);if(Number.isNaN(i.getTime()))return null;try{return new Intl.DateTimeFormat(t??"en-US",{month:"short",day:"numeric",timeZone:"UTC"}).format(i)}catch{return e}}function ze(e){return e!=null&&(e.wait!==void 0||e.pick.hidden===true)}function Ce(e){return{...e,pick:{...e.pick,none:true,hidden:true}}}var Se=/* @__PURE__ */Object.freeze({productId:"",partnerSku:null,title:"",description:null,category:null,price:null,currency:null,imageUrl:null,url:null,reasons:[],inPlan:false,sample:false});var Pe=/* @__PURE__ */Object.freeze({track(){},trackExpectedFailure(){}});function ok(e,t){/* @__PURE__ */
4
4
  return Object.freeze({ok:true,value:e})}function err(e){/* @__PURE__ */
5
5
  return Object.freeze({ok:false,error:e})}var Te=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var Fe=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),$e=globalThis,Oe=$e[Fe]??($e[Fe]=e.createContext(null));Oe.displayName??="EverfurContext";function Ee(){let t=e.useContext(Oe);if(t===null)throw new Te("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return t}var Ie=/* @__PURE__ */Object.freeze({opened:"health_plan.opened",productClicked:"health_plan.product_clicked",checkoutStarted:"health_plan.checkout_started"});function Le(){return e.useContext(Oe)?.runtime.registry.services.telemetry??Pe}var He=e.createContext(null);function HealthPlanPetScope({petRef:petRef,children:t}){return e.createElement(He.Provider,{value:petRef},t)}function Re(t){let i=e.useContext(He),r=e.useContext(Oe);return i??t??r?.activePet??null}function De(t,petRef,i){let r=Le(),n=e.useRef(null);e.useEffect(()=>{if(!t||petRef===null||n.current===petRef)return;n.current=petRef;let e=i?.items??[];r.track(Ie.opened,{petRef:petRef,itemsCount:e.length,inPlanCount:e.filter(e=>e.inPlan).length})},[t,petRef,i,r])}function Ne(e,petRef,t,i){e.track(Ie.productClicked,{petRef:petRef,productId:t,inPlan:i})}function Be(e,petRef,t){e.track(Ie.checkoutStarted,{petRef:petRef,itemsCount:t.count,subtotal:t.subtotal,currency:t.currency})}var Ae=[{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}],Me=/* @__PURE__ */Object.freeze(Ae.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(Me.map(e=>e.wireCode));var We=/* @__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"}),qe=/* @__PURE__ */Object.freeze(Me.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:We[e.wireCode]}))),Ue=new Map(qe.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),Ke=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(qe.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(e,t){if(typeof e!="string")return;let i=e.trim().toUpperCase();if(i.length!==0)for(let e of[t??"http_envelope",...Ke]){let t=Ue.get(e+i);if(t)return t}}var Ve=/* @__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 Ve[e]}function fromWire(e){let t=contractErrorFor(e);if(t)return t.normalized;let i=(e??"").trim().toUpperCase(),r=i.replace(/[^A-Z0-9]/g,"");if(r==="AUTHREJECTED")return"authRejected";if(i.startsWith("AUTH"))return"authExpired";switch(r){case"DAILYQUOTAEXCEEDED":case"QUOTAEXCEEDED":return"quotaExceeded";case"RATELIMITED":case"TOOMANYREQUESTS":case"TELEVETRATELIMITED":return"rateLimited";case"IDEMPOTENCYKEYCONFLICT":case"IDEMPOTENCYCONFLICT":return"idempotencyConflict";case"ACCESSDENIED":case"FORBIDDEN":return"accessDenied";case"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";case"RUNTIMEDISPOSED":return"runtimeDisposed";case"NOTFOUND":case"CONVERSATIONNOTFOUND":return"conversationNotFound";case"PETNOTFOUND":return"petNotFound";case"TIMEOUT":case"STREAMTIMEOUT":return"streamTimeout";case"MEDIAUPLOADFAILED":case"UNRECOGNIZEDVIDEOFORMAT":case"FILETOOSMALL":return"mediaUploadFailed";case"MODERATIONBLOCKED":return"moderationBlocked";case"UPSTREAMLLMTIMEOUT":return"upstreamLlmTimeout";case"INTERNALERROR":case"INTERNALSERVERERROR":return"internalError";case"STREAMINCOMPLETE":case"CHATSTREAMINCOMPLETE":return"streamIncomplete";case"INVALIDANALYSISTYPE":case"INVALIDUPLOADPURPOSE":return"unknown";default:return"unknown"}}var Ge=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return Ge.has(e)}var Ye=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||Ye.has(e)}var Xe=500,Qe=8e3,Ze=4;function backoffDelayMs(e,t=Math.random){let i=Math.max(0,e),r=Math.min(Xe*2**i,Qe);return Math.floor(t()*r)}var Je="This feature isn't available on your account right now.",et="Something in that request was not right. Check the details and try again.",tt=/* @__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:Je,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:et,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:Je,runtimeDisposed:et,unknown:"Something went wrong. Please try again."}),it="This session has ended. Please sign in again.",rt="linked_account_read_only";function nt(e,t,i){return e==="conflict"&&i===rt?Je:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?it:userFacingError(e)}function userFacingError(e){return tt[e]}function ot(e,t,i){Object.defineProperty(e,t,{value:i,enumerable:false,writable:false,configurable:false})}var at=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let i=contractErrorFor(t?.wireCode,t?.wireEnvelope),r=e==="conflict"&&t?.reasonCode===rt,n={code:e,category:categoryFor(e),retryable:t?.retryable??(r?false:isRetryableCode(e)),displayMessage:nt(e,t?.wireCode,r?rt:null)};t?.httpStatus!==void 0&&(n.httpStatus=t.httpStatus),t?.requestId&&(n.requestId=t.requestId),typeof t?.reasonCode=="string"&&at.test(t.reasonCode)&&(n.reasonCode=t.reasonCode);let o=t?.retryAfterSeconds;if(typeof o=="number"&&Number.isFinite(o)&&o>=0&&(n.retryAfterSeconds=Math.round(o)),i);return t?.wireMessage&&ot(n,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&ot(n,"raw",t.raw),/* @__PURE__ */Object.freeze(n)}function assertNever(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}function errorFrame(e){/* @__PURE__ */
6
- return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryable,wireMessage:e.wireMessage,synthesized:e.synthesized,lastEventId:e.lastEventId,serverRequestId:null,...e.freeCap?{freeCap:/* @__PURE__ */Object.freeze({...e.freeCap})}:{}})}var st="x-everfur-anon-token",lt="anonTokenInvalid";async function ut(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}function ct(e,t){let i=e instanceof Error?e.message:typeof e=="string"?e:null;return makeEverfurError("authRejected",{retryable:false,...t?.wireCode?{wireCode:t.wireCode}:{},...t?.requestId?{requestId:t.requestId}:{},...i?{wireMessage:i}:{},...e!=null?{raw:e}:{}})}function authHeaders(e){let t={};return e.mode==="personalized"?t.authorization=`Bearer ${e.token}`:(t["x-everfur-partner-key"]=e.publishableKey,e.anonToken&&(t[st]=e.anonToken)),e.userRef&&(t["x-everfur-user-ref"]=e.userRef),e.sessionId&&(t["x-everfur-session-id"]=e.sessionId),t}function withAuthHeaders(e,t){return{...e,headers:{...dt(e.headers),...authHeaders(t)}}}function dt(e){if(!e)return{};let t={};for(let[i,r]of Object.entries(e)){let e=i.toLowerCase();e==="authorization"||e==="x-everfur-partner-key"||e===st||(t[i]=r)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let i=await ut(t),r=await t.transport.request(withAuthHeaders(e,pt(t,i)));if(r.ok||mt(r.error.raw)!==lt||t.anonIdentity===void 0||t.userRef!==null)return r;let n=await t.anonIdentity.token({forceRefresh:true});return n===null||n===i?r:t.transport.request(withAuthHeaders(e,pt(t,n)))}let i;try{i=await t.identity.currentToken()}catch(e){return t.identity.reportRejected?.(),err(ct(e))}let r=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:i,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(r.ok||r.error.httpStatus!==401)return r;let n;try{n=await t.identity.currentToken({forceRefresh:!0})}catch(e){return t.identity.reportRejected?.(),err(ct(e,{wireCode:mt(r.error.raw),requestId:r.error.requestId}))}let o=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:n,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return!o.ok&&o.error.httpStatus===401?(t.identity.reportRejected?.(),err(ft(o.error))):o}function pt(e,t){return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}function ft(e){let t=e.raw,i=mt(t);return makeEverfurError("authRejected",{retryable:false,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId?{requestId:e.requestId}:{},...i?{wireCode:i}:{},...e.reasonCode?{reasonCode:e.reasonCode}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},...t!=null?{raw:t}:{}})}function mt(e){if(typeof e!="object"||e===null)return null;let t=e,i=(typeof t.error=="object"&&t.error!==null?t.error.code:void 0)??t.code;return typeof i=="string"&&i.length>0?i:null}function ht(e,t){let i=globalThis.URL;if(typeof i=="function"){let r;try{r=t===void 0?new i(e):new i(e,t)}catch{return null}try{if(r.protocol)return r}catch{}}return xt(e)}var gt=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,bt=/[\s\u0000-\u001f\u007f\\]/,vt={"http:":"80","https:":"443"};function xt(e,t){let i=e.trim();let r=bt.test(i)?null:gt.exec(i);if(r===null)return null;let[,n="",o="",a="",s="",l="",u="",c="",d=""]=r,p=`${n.toLowerCase()}:`,f=Number(l);if(f>65535)return null;let m=l===""||String(f)===vt[p]?"":String(f),h=vt[p]!==void 0,g=s.toLowerCase()+(m&&`:${m}`),b=u||(h?"/":""),v=o||a?`${o}${a&&`:${a}`}@`:"";return{href:`${p}//${v}${g}${b}${c}${d}`,protocol:p,username:o,password:a,hostname:s.toLowerCase(),port:m,origin:h?`${p}//${g}`:"null",pathname:b,search:c==="?"?"":c,hash:d==="#"?"":d}}var yt="1.5.2";function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:wt(e)})}function wt(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var kt=3e4,_t=Qe*2,jt="idempotency-key",zt=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),Ct=/* @__PURE__ */Object.freeze({onEvent(){}}),St=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function Pt(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}function createRequestFunnel(e){let t=e.observer??Ct,i=e.timers??St,r=e.rng??Math.random,n=e.sleep??((e,t)=>qt(e,i,t)),o=e.maxAttempts??Ze,a=e.unaryTimeoutMs??kt,s=e.newIdempotencyKey??Ft(),l=e=>{try{t.onEvent(e)}catch{}};async function u(t,u,c){let d=c?.maxAttempts,p=Math.max(1,d??o),f=c?.idempotent??zt.has(u.method),m=c?.idempotencyKey===void 0?null:Pt(c.idempotencyKey),h=f?m??s():null,g=Tt(u,h),b=0;for(;;){let o=e=>/* @__PURE__ */Object.freeze({call:t,method:u.method,path:u.path,attempt:b,...h?{idempotencyKey:h}:{},...e});l(o({phase:"attempt"}));let s=Mt(a,i),c=Wt(s.signal,u.signal),f;try{f=await authedSend({...g,signal:c.signal},e.auth)}catch(e){f=err(networkError(e))}finally{c.dispose(),s.cancel()}if(f.ok)return l(o({phase:"settled",ok:true,reason:"ok"})),f;let m=f.error,v=Ot(m,b,{maxAttempts:p,rng:r,now:i.now(),aborted:u.signal?.aborted===true,...d!==void 0?{perCallMaxAttempts:d}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),x={ok:false,code:m.code,reason:v.reason,...m.httpStatus!==void 0?{httpStatus:m.httpStatus}:{},...m.requestId!==void 0?{requestId:m.requestId}:{}};if(!v.retry)return l(o({phase:"settled",...x})),err(m);if(l(o({phase:"retry",...x,delayMs:v.delayMs})),await n(v.delayMs,u.signal),u.signal?.aborted===true)return l(o({phase:"settled",...x,reason:"aborted"})),err(m);b+=1}}async function c(t){return withAuthHeaders(t,await At(e.auth))}async function*d(t,i,r){l(
6
+ return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryable,wireMessage:e.wireMessage,synthesized:e.synthesized,lastEventId:e.lastEventId,serverRequestId:null,...e.freeCap?{freeCap:/* @__PURE__ */Object.freeze({...e.freeCap})}:{}})}var st="x-everfur-anon-token",lt="anonTokenInvalid";async function ut(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}function ct(e,t){let i=e instanceof Error?e.message:typeof e=="string"?e:null;return makeEverfurError("authRejected",{retryable:false,...t?.wireCode?{wireCode:t.wireCode}:{},...t?.requestId?{requestId:t.requestId}:{},...i?{wireMessage:i}:{},...e!=null?{raw:e}:{}})}function authHeaders(e){let t={};return e.mode==="personalized"?t.authorization=`Bearer ${e.token}`:(t["x-everfur-partner-key"]=e.publishableKey,e.anonToken&&(t[st]=e.anonToken)),e.userRef&&(t["x-everfur-user-ref"]=e.userRef),e.sessionId&&(t["x-everfur-session-id"]=e.sessionId),t}function withAuthHeaders(e,t){return{...e,headers:{...dt(e.headers),...authHeaders(t)}}}function dt(e){if(!e)return{};let t={};for(let[i,r]of Object.entries(e)){let e=i.toLowerCase();e==="authorization"||e==="x-everfur-partner-key"||e===st||(t[i]=r)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let i=await ut(t),r=await t.transport.request(withAuthHeaders(e,pt(t,i)));if(r.ok||mt(r.error.raw)!==lt||t.anonIdentity===void 0||t.userRef!==null)return r;let n=await t.anonIdentity.token({forceRefresh:true});return n===null||n===i?r:t.transport.request(withAuthHeaders(e,pt(t,n)))}let i;try{i=await t.identity.currentToken()}catch(e){return t.identity.reportRejected?.(),err(ct(e))}let r=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:i,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(r.ok||r.error.httpStatus!==401)return r;let n;try{n=await t.identity.currentToken({forceRefresh:!0})}catch(e){return t.identity.reportRejected?.(),err(ct(e,{wireCode:mt(r.error.raw),requestId:r.error.requestId}))}let o=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:n,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return!o.ok&&o.error.httpStatus===401?(t.identity.reportRejected?.(),err(ft(o.error))):o}function pt(e,t){return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}function ft(e){let t=e.raw,i=mt(t);return makeEverfurError("authRejected",{retryable:false,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId?{requestId:e.requestId}:{},...i?{wireCode:i}:{},...e.reasonCode?{reasonCode:e.reasonCode}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},...t!=null?{raw:t}:{}})}function mt(e){if(typeof e!="object"||e===null)return null;let t=e,i=(typeof t.error=="object"&&t.error!==null?t.error.code:void 0)??t.code;return typeof i=="string"&&i.length>0?i:null}function ht(e,t){let i=globalThis.URL;if(typeof i=="function"){let r;try{r=t===void 0?new i(e):new i(e,t)}catch{return null}try{if(r.protocol)return r}catch{}}return xt(e)}var gt=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,bt=/[\s\u0000-\u001f\u007f\\]/,vt={"http:":"80","https:":"443"};function xt(e,t){let i=e.trim();let r=bt.test(i)?null:gt.exec(i);if(r===null)return null;let[,n="",o="",a="",s="",l="",u="",c="",d=""]=r,p=`${n.toLowerCase()}:`,f=Number(l);if(f>65535)return null;let m=l===""||String(f)===vt[p]?"":String(f),h=vt[p]!==void 0,g=s.toLowerCase()+(m&&`:${m}`),b=u||(h?"/":""),v=o||a?`${o}${a&&`:${a}`}@`:"";return{href:`${p}//${v}${g}${b}${c}${d}`,protocol:p,username:o,password:a,hostname:s.toLowerCase(),port:m,origin:h?`${p}//${g}`:"null",pathname:b,search:c==="?"?"":c,hash:d==="#"?"":d}}var yt="1.5.3";function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:wt(e)})}function wt(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var kt=3e4,_t=Qe*2,jt="idempotency-key",zt=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),Ct=/* @__PURE__ */Object.freeze({onEvent(){}}),St=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function Pt(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}function createRequestFunnel(e){let t=e.observer??Ct,i=e.timers??St,r=e.rng??Math.random,n=e.sleep??((e,t)=>qt(e,i,t)),o=e.maxAttempts??Ze,a=e.unaryTimeoutMs??kt,s=e.newIdempotencyKey??Ft(),l=e=>{try{t.onEvent(e)}catch{}};async function u(t,u,c){let d=c?.maxAttempts,p=Math.max(1,d??o),f=c?.idempotent??zt.has(u.method),m=c?.idempotencyKey===void 0?null:Pt(c.idempotencyKey),h=f?m??s():null,g=Tt(u,h),b=0;for(;;){let o=e=>/* @__PURE__ */Object.freeze({call:t,method:u.method,path:u.path,attempt:b,...h?{idempotencyKey:h}:{},...e});l(o({phase:"attempt"}));let s=Mt(a,i),c=Wt(s.signal,u.signal),f;try{f=await authedSend({...g,signal:c.signal},e.auth)}catch(e){f=err(networkError(e))}finally{c.dispose(),s.cancel()}if(f.ok)return l(o({phase:"settled",ok:true,reason:"ok"})),f;let m=f.error,v=Ot(m,b,{maxAttempts:p,rng:r,now:i.now(),aborted:u.signal?.aborted===true,...d!==void 0?{perCallMaxAttempts:d}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),x={ok:false,code:m.code,reason:v.reason,...m.httpStatus!==void 0?{httpStatus:m.httpStatus}:{},...m.requestId!==void 0?{requestId:m.requestId}:{}};if(!v.retry)return l(o({phase:"settled",...x})),err(m);if(l(o({phase:"retry",...x,delayMs:v.delayMs})),await n(v.delayMs,u.signal),u.signal?.aborted===true)return l(o({phase:"settled",...x,reason:"aborted"})),err(m);b+=1}}async function c(t){return withAuthHeaders(t,await At(e.auth))}async function*d(t,i,r){l(
7
7
  /* @__PURE__ */Object.freeze({call:t,phase:"stream.open",method:i.method,path:i.path,attempt:0}));try{yield*e.auth.transport.stream(i,r)}catch{yield errorFrame({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}}/* @__PURE__ */
8
8
  return Object.freeze({send:u,authorize:c,stream:d})}function Tt(e,t){let i={};for(let[t,r]of Object.entries(e.headers??{}))t.toLowerCase()!==jt&&(i[t]=r);return t!==null&&(i["Idempotency-Key"]=t),{...e,headers:i}}function Ft(){let e=0;return()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var $t=10;function Ot(e,t,i){if(i.aborted)return{retry:false,reason:"aborted"};let r=Et(e);if(r==="quota")return{retry:false,reason:"daily-quota-exhausted"};if(r!=="burst"&&!isAutoRetryable(e.code))return{retry:false,reason:"terminal-code"};let n=r==="burst"?"burst-throttle":"retryable-code";if((()=>{if(i.policy===void 0)return false;try{return!i.policy.shouldRetry(e.code,t)}catch{return false}})())return{retry:false,reason:"terminal-code"};let o=()=>{if(i.policy===void 0)return null;let t;try{t=i.policy.maxAttempts(e.code)}catch{return null}return typeof t!="number"||!Number.isFinite(t)?null:Math.max(1,Math.min($t,Math.floor(t)))},a=i.perCallMaxAttempts??o()??i.maxAttempts;if(t+1>=a)return{retry:false,reason:"attempts-exhausted"};let s=It(e,i.now);return s!==null?s>_t?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:n,delayMs:s}:{retry:true,reason:n,delayMs:backoffDelayMs(t,i.rng)}}function Et(e){let t=e.code==="unknown"?fromWire(Nt(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}function It(e,t){let i=Ht(e.raw);if(i!==null){let e=i-t;return e>0?e:0}let r=Lt(e.raw);return r===null?null:Math.round(r*1e3)}function Lt(e){for(let t of Rt(e)){let e=t.retry_after_seconds;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e}return null}function Ht(e){for(let t of Rt(e)){let e=t.resets_at,i=Dt(e);if(i!==null)return i}return null}function Rt(e){if(!Bt(e))return[];let t=[e];for(let i of["error","detail"]){let r=e[i];Bt(r)&&t.push(r)}return t}function Dt(e){if(typeof e=="number"&&Number.isFinite(e))return e<1e11?Math.round(e*1e3):Math.round(e);if(typeof e=="string"&&e.trim().length>0){let t=Date.parse(e);return Number.isFinite(t)?t:null}return null}function Nt(e){for(let t of Rt(e)){let e=t.code;if(typeof e=="string"&&e.length>0)return e}return null}function Bt(e){return typeof e=="object"&&e!==null}async function At(e){if(e.mode==="anonymous"){let t=await ut(e);return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}return{mode:"personalized",token:await e.identity.currentToken(),userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{}}}function Mt(e,t){let i=new AbortController,r=t.setTimeout(()=>i.abort(),e);return{signal:i.signal,cancel:()=>t.clearTimeout(r)}}function Wt(e,t){let i=()=>{};if(!t)return{signal:e,dispose:i};let r=new AbortController;if(e.aborted||t.aborted)return r.abort(),{signal:r.signal,dispose:i};let n=()=>r.abort();return e.addEventListener("abort",n,{once:true}),t.addEventListener("abort",n,{once:true}),{signal:r.signal,dispose:()=>{e.removeEventListener("abort",n),t.removeEventListener("abort",n)}}}function qt(e,t,i){return e<=0||i?.aborted===true?Promise.resolve():new Promise(r=>{let n=t.setTimeout(()=>{i?.removeEventListener("abort",o),r()},e),o=()=>{t.clearTimeout(n),r()};i?.addEventListener("abort",o,{once:true})})}function Ut(e){return e!=null&&(e.httpStatus===404||e.category==="notFound")}function Kt(e){return e.code!=="conversationNotFound"?e:makeEverfurError("resourceNotFound",{retryable:false,...e.httpStatus===void 0?{}:{httpStatus:e.httpStatus},...e.requestId===void 0?{}:{requestId:e.requestId},...e.reasonCode===void 0?{}:{reasonCode:e.reasonCode},...e.wireMessage===void 0?{}:{wireMessage:e.wireMessage},...e.raw===void 0?{}:{raw:e.raw}})}function Vt(e){return e.ok?e:err(Kt(e.error))}function Gt(e){return{send:async(...t)=>Vt(await e.send(...t)),authorize:t=>e.authorize(t),stream:(t,i,r)=>e.stream(t,i,r)}}var Yt=/* @__PURE__ */Object.freeze(["dna","records","inside","profile"]),Xt=128;function Qt(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function Zt(e){return makeEverfurError("runtimeDisposed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}function Jt(e){return makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:`${e}: the response carried no plan`})}var ei=(e,t=4e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null;function ti(e){let t=ei(e,2048);return t===null?null:/^https:\/\/[^\s]+$/i.test(t)?t:null}function ii(e){let t=typeof e=="number"?e:typeof e=="string"&&/^\d+(\.\d+)?$/.test(e.trim())?Number(e):Number.NaN;return Number.isFinite(t)&&t>=0?t:null}function ri(e){return typeof e=="string"&&/^[A-Za-z]{3}$/.test(e)?e.toUpperCase():null}function ni(e){if(!Array.isArray(e))/* @__PURE__ */return Object.freeze([]);let t=[];for(let i of e){if(i===null||typeof i!="object")continue;let e=i,r=ei(e.text,1e3);if(r===null)continue;let n=typeof e.kind=="string"&&Yt.includes(e.kind)?e.kind:"profile";t.push(/* @__PURE__ */Object.freeze({kind:n,text:r}))}/* @__PURE__ */
9
9
  return Object.freeze(t)}var oi=6;function ai(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=400?e:null}function si(e,t,i){if(!Array.isArray(e))/* @__PURE__ */return Object.freeze([]);let r=[];for(let n of e){if(r.length>=i)break;if(n===null||typeof n!="object"||Array.isArray(n))continue;let e=t(n);e!==null&&r.push(e)}/* @__PURE__ */