@everfur/sdk 1.5.3 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chat-cards/package.json +8 -0
- package/dist/{Chat.d-BCfyvzX8.d.ts → Chat.d-B4GybUU4.d.ts} +1 -1
- package/dist/{Chat.d-Od44h51D.d.cts → Chat.d-DPM2ncxi.d.cts} +1 -1
- package/dist/chat/index.cjs +174 -174
- package/dist/chat/index.d.cts +4 -4
- package/dist/chat/index.d.ts +4 -4
- package/dist/chat/index.js +340 -340
- package/dist/chat/lite/index.cjs +174 -174
- package/dist/chat/lite/index.d.cts +4 -4
- package/dist/chat/lite/index.d.ts +4 -4
- package/dist/chat/lite/index.js +339 -339
- package/dist/chat-cards/index.cjs +18 -0
- package/dist/chat-cards/index.d.cts +15 -0
- package/dist/chat-cards/index.d.ts +15 -0
- package/dist/chat-cards/index.js +18 -0
- package/dist/{chatHandoffToken.d-BjfmIxXk.d.cts → chatHandoffToken.d-Cap2z62P.d.cts} +1 -1
- package/dist/{chatHandoffToken.d-CFiI6IMc.d.ts → chatHandoffToken.d-zdp23Ukr.d.ts} +1 -1
- package/dist/{checkin.d-CokpahFL.d.ts → checkin.d-BoZXWjxX.d.ts} +8 -0
- package/dist/{checkin.d-BP3ZWBfX.d.cts → checkin.d-CuIUahcd.d.cts} +8 -0
- package/dist/{chunk-CFEHTNKX.js → chunk-CQUKIPRU.js} +1 -1
- package/dist/{chunk-ZGL2GEEI.js → chunk-DBQYQLJT.js} +1 -1
- package/dist/{chunk-OU5RMGKD.js → chunk-RF4N4WUN.js} +18 -18
- package/dist/{chunk-XGF2HYNN.js → chunk-ZSCVH4UW.js} +14 -14
- package/dist/client/index.cjs +1 -1
- package/dist/client/index.d.cts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/{context.d-DS1GXUEY.d.ts → context.d-D7zX6Q0J.d.ts} +1 -1
- package/dist/{context.d-Bj6-xYPA.d.cts → context.d-guaLkx5t.d.cts} +1 -1
- package/dist/core/index.cjs +22 -22
- package/dist/core/index.d.cts +10 -4
- package/dist/core/index.d.ts +10 -4
- package/dist/core/index.js +31 -31
- package/dist/index.cjs +247 -247
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +364 -364
- package/dist/notifications/index.d.cts +3 -3
- package/dist/notifications/index.d.ts +3 -3
- package/dist/records/index.cjs +1 -1
- package/dist/records/index.js +1 -1
- package/dist/{route.d-DtuKY5dM.d.ts → route.d-B3u14HJT.d.ts} +1 -1
- package/dist/{route.d-Nt-r-7IO.d.cts → route.d-QBCoO62z.d.cts} +1 -1
- package/dist/{runtimeTypes.d-CL4l7ta4.d.cts → runtimeTypes.d-BSxuUCOX.d.cts} +1 -1
- package/dist/{runtimeTypes.d-BzUig75K.d.ts → runtimeTypes.d-hjN6xvxm.d.ts} +1 -1
- package/dist/server/events/index.cjs +1 -1
- package/dist/server/events/index.js +1 -1
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.js +1 -1
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/testing/rn/index.d.cts +2 -2
- package/dist/testing/rn/index.d.ts +2 -2
- package/dist/testing/web/index.d.cts +2 -2
- package/dist/testing/web/index.d.ts +2 -2
- package/dist/{useUnread.d-CedFK4k6.d.ts → useUnread.d-4SbFChbd.d.ts} +30 -3
- package/dist/{useUnread.d-DST1GMmL.d.cts → useUnread.d-B0YhhR_D.d.cts} +30 -3
- package/dist/web/health-plan/index.cjs +1 -1
- package/dist/web/health-plan/index.js +1 -1
- package/dist/web/index.cjs +173 -173
- package/dist/web/index.d.cts +7 -7
- package/dist/web/index.d.ts +7 -7
- package/dist/web/index.js +182 -182
- package/dist/web/notifications/index.d.cts +2 -2
- package/dist/web/notifications/index.d.ts +2 -2
- package/dist/web/records-sheet/index.cjs +1 -1
- package/dist/web/records-sheet/index.js +1 -1
- package/dist/web/shop/index.cjs +1 -1
- package/dist/web/shop/index.js +1 -1
- package/dist/web/televet/booking/index.cjs +1 -1
- package/dist/web/televet/booking/index.js +1 -1
- package/dist/web/televet/call/index.cjs +1 -1
- package/dist/web/televet/call/index.js +1 -1
- package/dist/web/ui/index.cjs +1 -1
- package/dist/web/ui/index.js +41 -41
- package/package.json +16 -1
package/dist/chat/index.js
CHANGED
|
@@ -1,355 +1,355 @@
|
|
|
1
1
|
/*! @everfur/sdk. Copyright (c) 2026 Strand Health Inc. dba Everfur. All rights reserved. Use is subject to the Everfur SDK License: https://docs.everfur.com/license */
|
|
2
|
-
import{createContext,forwardRef as e,createElement as t,
|
|
3
|
-
return c(i,{request:l.request,onClose:l.dismiss,...e?{onAddToCalendar:e}:{},...t?{onPickMedia:t}:{},...r?{primaryVet:r}:{},...n?{onFindEmergencyVet:n}:{}},l.serial)}var ee=/* @__PURE__ */Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function face(e,t){let r=e.type,n=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:n}:{fontFamily:n,fontWeight:r.weight[ee[t]]}}function headingFace(e,t="bold"){let{headingFamily:r,headingWeight:n}=e.type;if(r===null&&n===null)return face(e,t);if(r!==null)return{fontFamily:r,fontWeight:n??e.type.weight[ee[t]]};let l=face(e,t);return l.fontWeight===void 0||n===null?l:{fontFamily:l.fontFamily,fontWeight:n}}function te(e){return e<=450?"regular":e<=650?"medium":"bold"}var re={regular:"mono",medium:"monoMedium",bold:"monoBold"};function textRole(e,t){let r=ne.get(e);r===void 0&&(r=/* @__PURE__ */new Map,ne.set(e,r));let n=r.get(t);if(n!==void 0)return n;let l=le(e,t);return r.set(t,l),l}var ne=/* @__PURE__ */new WeakMap;function le(e,t){let r=e.type.roles[t],n=r.weight==="400"&&r.face!=="mono"?e.type.weight.regular:r.weight,l=te(Number(n)),i=r.face==="mono"?face(e,re[l]):r.face==="heading"?headingFace(e,l):face(e,l),o=r.face==="heading"?e.type.headingWeight??n:n,a=i.fontWeight===void 0?i:{fontFamily:i.fontFamily,fontWeight:o},s=r.size,u={...a,fontSize:s,lineHeight:Math.round(s*r.lineHeight*100)/100};return r.letterSpacing!==0&&(u.letterSpacing=Math.round(s*r.letterSpacing*100)/100),r.uppercase&&(u.textTransform="uppercase"),/* @__PURE__ */Object.freeze(u)}var ie=/* @__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 oe=Object.freeze;function deepFreeze(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){oe(e);for(let t of Object.keys(e))deepFreeze(e[t])}return e}var ae=/* @__PURE__ */Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3});var se={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},ue={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},de={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},ce={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},pe={regular:"400",medium:"500",bold:"700"},fe={eyebrow:1,monoWide:.9,headerBrand:-.42,tight:-.35},he=0,ge="System",be="monospace",ye=["content","heading","control","compact","badge"];function me(e){let t={};for(let r of ye)t[r]=e;return t}var ve=[];function we(){return{family:ge,mono:be,fontUrl:null,families:{regular:ge,medium:ge,bold:ge,mono:be,monoMedium:be,monoBold:be},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:de,tierSizes:me(de),lineHeight:ce,weight:pe,letterSpacing:fe,scale:1,maxScale:he,scaleCaps:ae,headingFamily:null,headingWeight:null,fontSources:ve,roles:ie,typeScale:1}}var ke={},Ce=/* @__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 Se={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:cssCubicBezier(Ce.standard),emphasized:cssCubicBezier(Ce.emphasized),exit:cssCubicBezier(Ce.exit)},reducedMotion:false},xe={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)"},Re=deepFreeze({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:xe,space:se,radius:ue,type:we(),motion:Se,slots:ke}),Te={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)"},_e=deepFreeze({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:Te,space:se,radius:ue,type:we(),motion:Se,slots:ke});var ze=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),Ie=globalThis,Pe=Ie[ze]??(Ie[ze]=createContext(Re));Pe.displayName??="EverfurThemeContext";function useEverfurTheme(){return s(Pe)}function Fe(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}function Text({tier:e,variant:r,...n}){let l=useEverfurTheme(),i=r===void 0?void 0:l.type.roles[r],o=Fe(l.type,e??i?.tier??"content"),a=r===void 0?n:{...n,style:[{...textRole(l,r),color:l.color.text.primary,flexShrink:1},n.style]};return t(w,o===void 0?a:{maxFontSizeMultiplier:o,...a})}var Le=e(function(e,r){return t(b,{...e,...r===null?{}:{ref:r}})});var Ee=640,Oe=600,Ae=/* @__PURE__ */Object.freeze({width:0,height:0}),je="useWindowDimensions"in g&&typeof g.useWindowDimensions=="function"?g.useWindowDimensions:()=>Ae,De=/* @__PURE__ */Object.freeze({width:"100%",maxWidth:Ee,alignSelf:"center"});/* @__PURE__ */Object.freeze({...De,flex:1});var Me=/* @__PURE__ */Object.freeze({...De,flexGrow:1,flexShrink:1});function Be(){return je().width>=Oe}function He(e="flow"){let{width:t}=je();if(t<Oe)return null;if(e==="flow")return De;let r=Math.max(0,Math.round((t-Ee)/2));return{left:r,right:r}}function We(e,t){return t===null?e:[e,t]}var Ne=/* @__PURE__ */Symbol.for("@everfur/sdk#InSdkColumn@v1"),Ue=globalThis,$e=Ue[Ne]??(Ue[Ne]=createContext(false));$e.displayName??="EverfurInSdkColumn";function SdkTabletColumn({children:e,style:t,testID:r}){let n=Be(),l=s($e);return!n||l?e:/* @__PURE__ */c(k,{style:t===void 0?Me:[Me,t],testID:r??"everfur-tablet-column",children:/* @__PURE__ */c($e.Provider,{value:true,children:e})})}var Ve=/* @__PURE__ */Object.freeze({chatAnswerStyle:"cards",chatHistoryStyle:"sheet",chatTopCard:"focus",chatFollowUpCount:3,chatFollowUpsExcludeTelevet:false,chatComposerMic:true,chatComposerUpload:true,safetyDisclaimerPlacement:"composer",healthPlanLayout:"focus_plan",recordsTopRiskLine:true,recordsClearResultsFilter:true,chatComposerStyle:"compact",chatComposerPlaceholder:"pet_name",chatHistoryBar:"scroll",chatGeneralBanner:true,chatSendButton:"always_dark",chatTextingAsk:true,serverSlots:false}),qe=/* @__PURE__ */Object.freeze({chatAnswerStyle:"chat_answer_style",chatHistoryStyle:"chat_history_style",chatTopCard:"chat_top_card",chatFollowUpCount:"chat_follow_up_count",chatFollowUpsExcludeTelevet:"chat_follow_ups_exclude_televet",chatComposerMic:"chat_composer_mic",chatComposerUpload:"chat_composer_upload",safetyDisclaimerPlacement:"safety_disclaimer_placement",healthPlanLayout:"health_plan_layout",recordsTopRiskLine:"records_top_risk_line",recordsClearResultsFilter:"records_clear_results_filter",chatComposerStyle:"chat_composer_style",chatComposerPlaceholder:"chat_composer_placeholder",chatHistoryBar:"chat_history_bar",chatGeneralBanner:"chat_general_banner",chatSendButton:"chat_send_button",chatTextingAsk:"chat_texting_ask",serverSlots:"server_slots"}),Ge=Object.keys(qe),Ke="presentation",Ye="presentation.";var Qe={chatAnswerStyle:["bubbles","cards"],chatHistoryStyle:["drawer","sheet"],chatTopCard:["none","focus"],safetyDisclaimerPlacement:["composer","answer_footer","none"],healthPlanLayout:["standard","focus_plan"],chatComposerStyle:["standard","compact"],chatComposerPlaceholder:["generic","pet_name"],chatHistoryBar:["pinned","scroll"],chatSendButton:["always_dark","dim_when_empty"]},Ze=/* @__PURE__ */new Set(["chatFollowUpsExcludeTelevet","chatComposerMic","chatComposerUpload","recordsTopRiskLine","recordsClearResultsFilter","chatGeneralBanner","chatTextingAsk","serverSlots"]);function Je(e,t){if(t==null)return;let r=Qe[e];return r!==void 0?typeof t=="string"&&r.includes(t)?t:void 0:Ze.has(e)?typeof t=="boolean"?t:void 0:typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<=3?t:void 0}function parsePresentation(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let e of Ge){let n=qe[e],l=Object.prototype.hasOwnProperty.call(t,n)?t[n]:t[e],i=Je(e,l);i!==void 0&&(r[e]=i)}return Object.keys(r).length===0?null:/* @__PURE__ */Object.freeze(r)}function isPresentationFieldLocked(e,t){if(t==null)return false;let r=`${Ye}${qe[e]}`;for(let e of t)if(e===Ke||e===r)return true;return false}function resolvePresentation(e){let t=parsePresentation(e?.server??null)??{},{safetyDisclaimerPlacement:r,...n}=t,l=r==="none"||r===void 0?n:{...n,safetyDisclaimerPlacement:r},i=parsePresentation(e?.client??null)??{},o=e?.locked?[...e.locked]:null,a={};for(let e of Ge){let t=l[e],r=isPresentationFieldLocked(e,o)?void 0:i[e];a[e]=r??t??Ve[e]}/* @__PURE__ */
|
|
4
|
-
return Object.freeze(a)}var
|
|
2
|
+
import{createContext,forwardRef as e,createElement as t,lazy as r,useCallback as n,useMemo as l,useRef as i,useState as o,useEffect as a,useSyncExternalStore as s,useContext as u,Component as d,Fragment as c,Suspense as p}from"react";import{jsx as f,jsxs as h,Fragment as g}from"react/jsx-runtime";import*as b from"@everfur/sdk/televet/booking";import*as m from"react-native";import{TextInput as y,StyleSheet as v,Platform as w,AppState as k,Text as C,View as S,Linking as x,KeyboardAvoidingView as R,Pressable as T,Dimensions as _,Keyboard as z,Modal as I,ScrollView as P,ActivityIndicator as F,Image as L,AccessibilityInfo as E,UIManager as O,LayoutAnimation as A,Animated as j,useWindowDimensions as D,FlatList as M}from"react-native";import{useSafeAreaInsets as B}from"react-native-safe-area-context";import*as H from"@everfur/sdk/texting";var W=createContext(null);function TelevetHostOutlet(){let e=u(W);return e===null?null:/* @__PURE__ */f(e,{})}var N=/* @__PURE__ */Symbol.for("@everfur/sdk/televet");function U(){let e=globalThis,t=e[N];if(t!==void 0)return t;let r={presenter:null,snapshot:/* @__PURE__ */Object.freeze({request:null,serial:0,activeHost:null}),hosts:[],nextHost:1,listeners:/* @__PURE__ */new Set,dailyRegistered:false};return e[N]=r,r}function $(e){let t=U();t.snapshot=/* @__PURE__ */Object.freeze({...t.snapshot,...e});for(let e of[...t.listeners])try{e()}catch{}}function V(e){let t=U().presenter;if(t===null)return"absent";try{return t(e)===!1?"declined":"presented"}catch(e){return console.warn("[everfur] Your registerEverfurTelevetFlow presenter threw; the in-app visit opened instead.",e),"threw"}}function q(e){let t=U();return t.listeners.add(e),()=>{t.listeners.delete(e)}}function G(){return U().snapshot}function K(){return U().hosts.length>0}function Y(e){if(!K())return false;let t=/* @__PURE__ */Object.freeze({...e});return $({request:t,serial:U().snapshot.serial+1}),true}function Q(){U().snapshot.request!==null&&$({request:null})}function Z(){let e=U(),t=e.nextHost;return e.nextHost+=1,e.hosts=[...e.hosts,t],$({activeHost:e.hosts[0]??null}),t}function J(e){let t=U();t.hosts=t.hosts.filter(t=>t!==e);let r=t.hosts[0]??null;$(r===null?{activeHost:r,request:null}:{activeHost:r})}function X(e){let t=null;return()=>{if(t!==null)return t;let r=e();return t=r,r.then(void 0,()=>{t===r&&(t=null)}),r}}function ee(e){let[t,r]=o(null);a(()=>{let e=Z();return r(e),()=>{J(e)}},[]);let n=s(q,G,G),l=t!==null&&n.activeHost===t?n.request:null,[i,u]=o(null),d=l!==null&&i===null;return a(()=>{if(!d)return;let t=true;return e().then(e=>{t&&u(()=>e)},e=>{t&&(console.warn("[everfur] The in-app vet visit could not load its screens.",e),Q())}),()=>{t=false}},[d,e]),l===null||i===null?null:{module:i,request:l,serial:n.serial,dismiss:Q}}var te=X(()=>Promise.resolve(b));function EverfurTelevetHost({onAddToCalendar:e,onPickMedia:t,primaryVet:r,onFindEmergencyVet:n}={}){let l=ee(te);if(l===null)return null;let{EverfurTelevetModal:i}=l.module;/* @__PURE__ */
|
|
3
|
+
return f(i,{request:l.request,onClose:l.dismiss,...e?{onAddToCalendar:e}:{},...t?{onPickMedia:t}:{},...r?{primaryVet:r}:{},...n?{onFindEmergencyVet:n}:{}},l.serial)}var re=/* @__PURE__ */Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function face(e,t){let r=e.type,n=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:n}:{fontFamily:n,fontWeight:r.weight[re[t]]}}function headingFace(e,t="bold"){let{headingFamily:r,headingWeight:n}=e.type;if(r===null&&n===null)return face(e,t);if(r!==null)return{fontFamily:r,fontWeight:n??e.type.weight[re[t]]};let l=face(e,t);return l.fontWeight===void 0||n===null?l:{fontFamily:l.fontFamily,fontWeight:n}}function ne(e){return e<=450?"regular":e<=650?"medium":"bold"}var le={regular:"mono",medium:"monoMedium",bold:"monoBold"};function textRole(e,t){let r=ie.get(e);r===void 0&&(r=/* @__PURE__ */new Map,ie.set(e,r));let n=r.get(t);if(n!==void 0)return n;let l=oe(e,t);return r.set(t,l),l}var ie=/* @__PURE__ */new WeakMap;function oe(e,t){let r=e.type.roles[t],n=r.weight==="400"&&r.face!=="mono"?e.type.weight.regular:r.weight,l=ne(Number(n)),i=r.face==="mono"?face(e,le[l]):r.face==="heading"?headingFace(e,l):face(e,l),o=r.face==="heading"?e.type.headingWeight??n:n,a=i.fontWeight===void 0?i:{fontFamily:i.fontFamily,fontWeight:o},s=r.size,u={...a,fontSize:s,lineHeight:Math.round(s*r.lineHeight*100)/100};return r.letterSpacing!==0&&(u.letterSpacing=Math.round(s*r.letterSpacing*100)/100),r.uppercase&&(u.textTransform="uppercase"),/* @__PURE__ */Object.freeze(u)}var ae=/* @__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 se=Object.freeze;function deepFreeze(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){se(e);for(let t of Object.keys(e))deepFreeze(e[t])}return e}var ue=/* @__PURE__ */Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3});var de={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},ce={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},pe={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},fe={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},he={regular:"400",medium:"500",bold:"700"},ge={eyebrow:1,monoWide:.9,headerBrand:-.42,tight:-.35},be=0,me="System",ye="monospace",ve=["content","heading","control","compact","badge"];function we(e){let t={};for(let r of ve)t[r]=e;return t}var ke=[];function Ce(){return{family:me,mono:ye,fontUrl:null,families:{regular:me,medium:me,bold:me,mono:ye,monoMedium:ye,monoBold:ye},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:pe,tierSizes:we(pe),lineHeight:fe,weight:he,letterSpacing:ge,scale:1,maxScale:be,scaleCaps:ue,headingFamily:null,headingWeight:null,fontSources:ke,roles:ae,typeScale:1}}var Se={},xe=/* @__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 Re={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:cssCubicBezier(xe.standard),emphasized:cssCubicBezier(xe.emphasized),exit:cssCubicBezier(xe.exit)},reducedMotion:false},Te={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)"},_e=deepFreeze({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:Te,space:de,radius:ce,type:Ce(),motion:Re,slots:Se}),ze={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)"},Ie=deepFreeze({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:ze,space:de,radius:ce,type:Ce(),motion:Re,slots:Se});var Pe=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),Fe=globalThis,Le=Fe[Pe]??(Fe[Pe]=createContext(_e));Le.displayName??="EverfurThemeContext";function useEverfurTheme(){return u(Le)}function Ee(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}function Text({tier:e,variant:r,...n}){let l=useEverfurTheme(),i=r===void 0?void 0:l.type.roles[r],o=Ee(l.type,e??i?.tier??"content"),a=r===void 0?n:{...n,style:[{...textRole(l,r),color:l.color.text.primary,flexShrink:1},n.style]};return t(C,o===void 0?a:{maxFontSizeMultiplier:o,...a})}var Oe=e(function(e,r){return t(y,{...e,...r===null?{}:{ref:r}})});var Ae=640,je=600,De=/* @__PURE__ */Object.freeze({width:0,height:0}),Me="useWindowDimensions"in m&&typeof m.useWindowDimensions=="function"?m.useWindowDimensions:()=>De,Be=/* @__PURE__ */Object.freeze({width:"100%",maxWidth:Ae,alignSelf:"center"});/* @__PURE__ */Object.freeze({...Be,flex:1});var He=/* @__PURE__ */Object.freeze({...Be,flexGrow:1,flexShrink:1});function We(){return Me().width>=je}function Ne(e="flow"){let{width:t}=Me();if(t<je)return null;if(e==="flow")return Be;let r=Math.max(0,Math.round((t-Ae)/2));return{left:r,right:r}}function Ue(e,t){return t===null?e:[e,t]}var $e=/* @__PURE__ */Symbol.for("@everfur/sdk#InSdkColumn@v1"),Ve=globalThis,qe=Ve[$e]??(Ve[$e]=createContext(false));qe.displayName??="EverfurInSdkColumn";function SdkTabletColumn({children:e,style:t,testID:r}){let n=We(),l=u(qe);return!n||l?e:/* @__PURE__ */f(S,{style:t===void 0?He:[He,t],testID:r??"everfur-tablet-column",children:/* @__PURE__ */f(qe.Provider,{value:true,children:e})})}var Ge=/* @__PURE__ */Object.freeze({chatAnswerStyle:"cards",chatHistoryStyle:"sheet",chatTopCard:"focus",chatFollowUpCount:3,chatFollowUpsExcludeTelevet:false,chatComposerMic:true,chatComposerUpload:true,safetyDisclaimerPlacement:"composer",healthPlanLayout:"focus_plan",recordsTopRiskLine:true,recordsClearResultsFilter:true,chatComposerStyle:"compact",chatComposerPlaceholder:"pet_name",chatHistoryBar:"scroll",chatGeneralBanner:true,chatSendButton:"always_dark",chatTextingAsk:true,serverSlots:false}),Ke=/* @__PURE__ */Object.freeze({chatAnswerStyle:"chat_answer_style",chatHistoryStyle:"chat_history_style",chatTopCard:"chat_top_card",chatFollowUpCount:"chat_follow_up_count",chatFollowUpsExcludeTelevet:"chat_follow_ups_exclude_televet",chatComposerMic:"chat_composer_mic",chatComposerUpload:"chat_composer_upload",safetyDisclaimerPlacement:"safety_disclaimer_placement",healthPlanLayout:"health_plan_layout",recordsTopRiskLine:"records_top_risk_line",recordsClearResultsFilter:"records_clear_results_filter",chatComposerStyle:"chat_composer_style",chatComposerPlaceholder:"chat_composer_placeholder",chatHistoryBar:"chat_history_bar",chatGeneralBanner:"chat_general_banner",chatSendButton:"chat_send_button",chatTextingAsk:"chat_texting_ask",serverSlots:"server_slots"}),Ye=Object.keys(Ke),Qe="presentation",Ze="presentation.";var Je={chatAnswerStyle:["bubbles","cards"],chatHistoryStyle:["drawer","sheet"],chatTopCard:["none","focus"],safetyDisclaimerPlacement:["composer","answer_footer","none"],healthPlanLayout:["standard","focus_plan"],chatComposerStyle:["standard","compact"],chatComposerPlaceholder:["generic","pet_name"],chatHistoryBar:["pinned","scroll"],chatSendButton:["always_dark","dim_when_empty"]},Xe=/* @__PURE__ */new Set(["chatFollowUpsExcludeTelevet","chatComposerMic","chatComposerUpload","recordsTopRiskLine","recordsClearResultsFilter","chatGeneralBanner","chatTextingAsk","serverSlots"]);function et(e,t){if(t==null)return;let r=Je[e];return r!==void 0?typeof t=="string"&&r.includes(t)?t:void 0:Xe.has(e)?typeof t=="boolean"?t:void 0:typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<=3?t:void 0}function parsePresentation(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let e of Ye){let n=Ke[e],l=Object.prototype.hasOwnProperty.call(t,n)?t[n]:t[e],i=et(e,l);i!==void 0&&(r[e]=i)}return Object.keys(r).length===0?null:/* @__PURE__ */Object.freeze(r)}function isPresentationFieldLocked(e,t){if(t==null)return false;let r=`${Ze}${Ke[e]}`;for(let e of t)if(e===Qe||e===r)return true;return false}function resolvePresentation(e){let t=parsePresentation(e?.server??null)??{},{safetyDisclaimerPlacement:r,...n}=t,l=r==="none"||r===void 0?n:{...n,safetyDisclaimerPlacement:r},i=parsePresentation(e?.client??null)??{},o=e?.locked?[...e.locked]:null,a={};for(let e of Ye){let t=l[e],r=isPresentationFieldLocked(e,o)?void 0:i[e];a[e]=r??t??Ge[e]}/* @__PURE__ */
|
|
4
|
+
return Object.freeze(a)}var tt="Go to the nearest emergency vet now.";var rt=/* @__PURE__ */Object.freeze({placeholder:"Ask anything about {petName}…",placeholderFollowUpWeb:"Ask a follow-up…",placeholderUrgentWeb:"Tell us what’s happening…",composerLabel:"Message",attachPhotoOrFileNative:"Add a photo or file",suggestions:"Suggestions",reading:"Reading {petName}’s records…",answered:"Everfur answered.",assistantName:"Everfur",followUpsHeadingNative:"Follow-up questions",turnFailedTitleWeb:"Everfur couldn’t answer that just now.",send:"Send",stop:"Stop",retry:"Try again",poweredBy:"powered by everfur",senderUser:"You",senderAssistant:"Assistant",senderVet:"Your vet",loading:"Loading",empty:"No messages yet",transcript:"Chat with Everfur",emptyTitle:"What can we help {petName} with today?",emptyTitlePetFallback:"your pet",copied:"Copied",copyUserMessage:"Copy your message",copyAssistantMessage:"Copy assistant message",feedbackHelpful:"Helpful",feedbackNeutral:"Neutral",feedbackNotHelpful:"Not helpful",feedbackTitle:"What went wrong?",feedbackSubtitle:"Your feedback helps make answers more reliable.",feedbackReasonInaccurate:"Inaccurate",feedbackReasonOutdated:"Out of date",feedbackReasonUnsafe:"Unsafe advice",feedbackReasonUnclear:"Confusing or unclear",feedbackReasonOther:"Something else",feedbackNotesPlaceholder:"Add details (optional)",feedbackSubmit:"Submit feedback",feedbackSkip:"Skip",feedbackSkipA11y:"Skip feedback",feedbackThanks:"Thanks for the feedback",feedbackFailed:"Couldn't send feedback. Please try again.",turnFailedTitle:"Message failed",turnRetry:"Retry",turnUnreachableTitle:"Couldn't reach this chat",turnStartNewChat:"Start a new chat",reconnecting:"Reconnecting…",turnStoppedTitle:"Response stopped",turnStoppedBody:"You stopped this response before it finished. Tap retry to try again.",sourceSingular:"source",sourcePlural:"sources",showSources:"Show",hideSources:"Hide",sourcesHeading:"Sources",openSource:"Open source",urgencyGeneralReason:"Just general info about {petName}. Nothing here needs action right now.",findVet:"Find a vet",findVetA11y:"Find a vet near you",nearestEmergencyVet:"Nearest emergency vet",goToNearestEmergencyVet:tt,poisonControlWeb:"ASPCA Poison Control",poisonControlNative:"ASPCA Animal Poison Control, (888) 426-4435",showLatestVetAlert:"Show latest vet alert",dismissBanner:"Dismiss {label} banner",openHistoryNative:"Chats and vet messages",openHistoryWeb:"Chats",showChatsWeb:"Show chats",hideChatsWeb:"Hide chats",newReplySuffix:", a new reply",yourPets:"Your pets",yourPet:"Your pet",switchActivePet:"{name}. Switch pet",petCurrentlyActive:"{name}, currently active",switchToPet:"Switch to {name}",activePrefix:"Active · ",close:"Close",addAnotherPet:"Add a pet",addPet:"Add a pet",capReached:"You've used your {cap} free messages this month.",attachmentPhoto:"Photo",attachmentCamera:"Camera",closeAttachmentPicker:"Close attachment picker",addAttachment:"Add attachment, {used} of {total} used",attachmentsFull:"Attachments full, {used} of {total} used",retryUpload:"Retry uploading {filename}",removeAttachment:"Remove {filename}",previewAttachment:"Preview {filename}",closePreview:"Close preview",attachedImage:"Attached image: {filename}, opens a full-screen preview",attachmentTooLarge:"Files must be under {max}. {filename} is {size}.",attachmentTooMany:"You can attach up to {max} files per message.",attachmentUnsupported:"{filename} isn't a supported file type yet.",attachmentNetwork:"Couldn't reach the server. Check your connection and try again.",attachmentServer:"Upload failed{status}. Please try again.",attachmentCancelled:"Upload cancelled.",attachmentRateLimited:"Slow down. Please wait a moment and try again.",attachmentQuota:"Daily image limit reached. Try again tomorrow.",attachmentConflict:"Something went wrong. Tap to retry.",attachmentUnknown:"Something went wrong. Please try again.",attachmentsFailedBlocked:"Some attachments failed to upload. Remove or retry them before sending.",dictate:"Dictate a message",stopDictation:"Stop dictation",listening:"Listening",micBlocked:"Microphone access is blocked. Allow it in your browser settings to dictate.",noSpeech:"We didn't catch that. Tap the mic and try again.",dictationUnavailable:"Voice typing isn't available right now."});function nt(e,t){return e.replace(/\{(\w+)\}/g,(e,r)=>{let n=t[r];return n===void 0?e:String(n)})}function lt(e){return e?.trim()||rt.emptyTitlePetFallback}function it(e,t){return nt(e,{petName:lt(t)})}var ot="tel:+18884264435";function ok(e,t){/* @__PURE__ */
|
|
5
5
|
return Object.freeze({ok:true,value:e})}function err(e){/* @__PURE__ */
|
|
6
|
-
return Object.freeze({ok:false,error:e})}var it=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var ot=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),at=globalThis,st=at[ot]??(at[ot]=createContext(null));st.displayName??="EverfurContext";function ut(){let e=s(st);if(e===null)throw new it("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}var dt=[{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}],ct=/* @__PURE__ */Object.freeze(dt.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(ct.map(e=>e.wireCode));var pt=/* @__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"}),ft=/* @__PURE__ */Object.freeze(ct.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:pt[e.wireCode]}))),ht=new Map(ft.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),gt=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(ft.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let e of[t??"http_envelope",...gt]){let t=ht.get(e+r);if(t)return t}}var bt=/* @__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 bt[e]}function fromWire(e){let t=contractErrorFor(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),n=r.replace(/[^A-Z0-9]/g,"");if(n==="AUTHREJECTED")return"authRejected";if(r.startsWith("AUTH"))return"authExpired";switch(n){case"DAILYQUOTAEXCEEDED":case"QUOTAEXCEEDED":return"quotaExceeded";case"RATELIMITED":case"TOOMANYREQUESTS":case"TELEVETRATELIMITED":return"rateLimited";case"IDEMPOTENCYKEYCONFLICT":case"IDEMPOTENCYCONFLICT":return"idempotencyConflict";case"ACCESSDENIED":case"FORBIDDEN":return"accessDenied";case"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";case"RUNTIMEDISPOSED":return"runtimeDisposed";case"NOTFOUND":case"CONVERSATIONNOTFOUND":return"conversationNotFound";case"PETNOTFOUND":return"petNotFound";case"TIMEOUT":case"STREAMTIMEOUT":return"streamTimeout";case"MEDIAUPLOADFAILED":case"UNRECOGNIZEDVIDEOFORMAT":case"FILETOOSMALL":return"mediaUploadFailed";case"MODERATIONBLOCKED":return"moderationBlocked";case"UPSTREAMLLMTIMEOUT":return"upstreamLlmTimeout";case"INTERNALERROR":case"INTERNALSERVERERROR":return"internalError";case"STREAMINCOMPLETE":case"CHATSTREAMINCOMPLETE":return"streamIncomplete";case"INVALIDANALYSISTYPE":case"INVALIDUPLOADPURPOSE":return"unknown";default:return"unknown"}}var yt=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return yt.has(e)}var mt=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||mt.has(e)}var vt=500,wt=8e3,kt=4;function backoffDelayMs(e,t=Math.random){let r=Math.max(0,e),n=Math.min(vt*2**r,wt);return Math.floor(t()*n)}var Ct="This feature isn't available on your account right now.",St="Something in that request was not right. Check the details and try again.",xt=/* @__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:Ct,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:St,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:Ct,runtimeDisposed:St,unknown:"Something went wrong. Please try again."}),Rt="This session has ended. Please sign in again.",Tt="linked_account_read_only";function _t(e,t,r){return e==="conflict"&&r===Tt?Ct:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?Rt:userFacingError(e)}function userFacingError(e){return xt[e]}function zt(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var It=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===Tt,l={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:_t(e,t?.wireCode,n?Tt:null)};t?.httpStatus!==void 0&&(l.httpStatus=t.httpStatus),t?.requestId&&(l.requestId=t.requestId),typeof t?.reasonCode=="string"&&It.test(t.reasonCode)&&(l.reasonCode=t.reasonCode);let i=t?.retryAfterSeconds;if(typeof i=="number"&&Number.isFinite(i)&&i>=0&&(l.retryAfterSeconds=Math.round(i)),r);return t?.wireMessage&&zt(l,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&zt(l,"raw",t.raw),/* @__PURE__ */Object.freeze(l)}function assertNever(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}function errorFrame(e){/* @__PURE__ */
|
|
7
|
-
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
|
|
8
|
-
return Object.freeze({limit:l,used:i,resetsAt:typeof o=="string"&&o.length>0?o:null,...typeof a=="string"&&a.trim().length>0?{emergencyGuidance:a}:{}})}function
|
|
6
|
+
return Object.freeze({ok:false,error:e})}var at=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var st=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),ut=globalThis,dt=ut[st]??(ut[st]=createContext(null));dt.displayName??="EverfurContext";function ct(){let e=u(dt);if(e===null)throw new at("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return e}var pt=[{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}],ft=/* @__PURE__ */Object.freeze(pt.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(ft.map(e=>e.wireCode));var ht=/* @__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"}),gt=/* @__PURE__ */Object.freeze(ft.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:ht[e.wireCode]}))),bt=new Map(gt.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),mt=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(gt.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let e of[t??"http_envelope",...mt]){let t=bt.get(e+r);if(t)return t}}var yt=/* @__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 yt[e]}function fromWire(e){let t=contractErrorFor(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),n=r.replace(/[^A-Z0-9]/g,"");if(n==="AUTHREJECTED")return"authRejected";if(r.startsWith("AUTH"))return"authExpired";switch(n){case"DAILYQUOTAEXCEEDED":case"QUOTAEXCEEDED":return"quotaExceeded";case"RATELIMITED":case"TOOMANYREQUESTS":case"TELEVETRATELIMITED":return"rateLimited";case"IDEMPOTENCYKEYCONFLICT":case"IDEMPOTENCYCONFLICT":return"idempotencyConflict";case"ACCESSDENIED":case"FORBIDDEN":return"accessDenied";case"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";case"RUNTIMEDISPOSED":return"runtimeDisposed";case"NOTFOUND":case"CONVERSATIONNOTFOUND":return"conversationNotFound";case"PETNOTFOUND":return"petNotFound";case"TIMEOUT":case"STREAMTIMEOUT":return"streamTimeout";case"MEDIAUPLOADFAILED":case"UNRECOGNIZEDVIDEOFORMAT":case"FILETOOSMALL":return"mediaUploadFailed";case"MODERATIONBLOCKED":return"moderationBlocked";case"UPSTREAMLLMTIMEOUT":return"upstreamLlmTimeout";case"INTERNALERROR":case"INTERNALSERVERERROR":return"internalError";case"STREAMINCOMPLETE":case"CHATSTREAMINCOMPLETE":return"streamIncomplete";case"INVALIDANALYSISTYPE":case"INVALIDUPLOADPURPOSE":return"unknown";default:return"unknown"}}var vt=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return vt.has(e)}var wt=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||wt.has(e)}var kt=500,Ct=8e3,St=4;function backoffDelayMs(e,t=Math.random){let r=Math.max(0,e),n=Math.min(kt*2**r,Ct);return Math.floor(t()*n)}var xt="This feature isn't available on your account right now.",Rt="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:xt,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:Rt,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:xt,runtimeDisposed:Rt,unknown:"Something went wrong. Please try again."}),_t="This session has ended. Please sign in again.",zt="linked_account_read_only";function It(e,t,r){return e==="conflict"&&r===zt?xt:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?_t:userFacingError(e)}function userFacingError(e){return Tt[e]}function Pt(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var Ft=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===zt,l={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:It(e,t?.wireCode,n?zt:null)};t?.httpStatus!==void 0&&(l.httpStatus=t.httpStatus),t?.requestId&&(l.requestId=t.requestId),typeof t?.reasonCode=="string"&&Ft.test(t.reasonCode)&&(l.reasonCode=t.reasonCode);let i=t?.retryAfterSeconds;if(typeof i=="number"&&Number.isFinite(i)&&i>=0&&(l.retryAfterSeconds=Math.round(i)),r);return t?.wireMessage&&Pt(l,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&Pt(l,"raw",t.raw),/* @__PURE__ */Object.freeze(l)}function assertNever(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}function errorFrame(e){/* @__PURE__ */
|
|
7
|
+
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 Lt="x-everfur-anon-token",Et="anonTokenInvalid";async function Ot(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}function At(e,t){let r=e instanceof Error?e.message:typeof e=="string"?e:null;return makeEverfurError("authRejected",{retryable:false,...t?.wireCode?{wireCode:t.wireCode}:{},...t?.requestId?{requestId:t.requestId}:{},...r?{wireMessage:r}:{},...e!=null?{raw:e}:{}})}function authHeaders(e){let t={};return e.mode==="personalized"?t.authorization=`Bearer ${e.token}`:(t["x-everfur-partner-key"]=e.publishableKey,e.anonToken&&(t[Lt]=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:{...jt(e.headers),...authHeaders(t)}}}function jt(e){if(!e)return{};let t={};for(let[r,n]of Object.entries(e)){let e=r.toLowerCase();e==="authorization"||e==="x-everfur-partner-key"||e===Lt||(t[r]=n)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let r=await Ot(t),n=await t.transport.request(withAuthHeaders(e,Dt(t,r)));if(n.ok||Bt(n.error.raw)!==Et||t.anonIdentity===void 0||t.userRef!==null)return n;let l=await t.anonIdentity.token({forceRefresh:true});return l===null||l===r?n:t.transport.request(withAuthHeaders(e,Dt(t,l)))}let r;try{r=await t.identity.currentToken()}catch(e){return t.identity.reportRejected?.(),err(At(e))}let n=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:r,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(n.ok||n.error.httpStatus!==401)return n;let l;try{l=await t.identity.currentToken({forceRefresh:!0})}catch(e){return t.identity.reportRejected?.(),err(At(e,{wireCode:Bt(n.error.raw),requestId:n.error.requestId}))}let i=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:l,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return!i.ok&&i.error.httpStatus===401?(t.identity.reportRejected?.(),err(Mt(i.error))):i}function Dt(e,t){return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}function Mt(e){let t=e.raw,r=Bt(t);return makeEverfurError("authRejected",{retryable:false,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId?{requestId:e.requestId}:{},...r?{wireCode:r}:{},...e.reasonCode?{reasonCode:e.reasonCode}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},...t!=null?{raw:t}:{}})}function Bt(e){if(typeof e!="object"||e===null)return null;let t=e,r=(typeof t.error=="object"&&t.error!==null?t.error.code:void 0)??t.code;return typeof r=="string"&&r.length>0?r:null}var Ht="free_cap_reached";function Wt(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function Nt(e){if(typeof e!="object"||e===null)return null;let t=e,r=t.detail,n=typeof r=="object"&&r!==null?r:t;if(n.error!==Ht&&n.code!==Ht)return null;let l=Wt(n.limit),i=Wt(n.used);if(l===null||i===null)return null;let o=n.resets_at,a=n.emergency_guidance;/* @__PURE__ */
|
|
8
|
+
return Object.freeze({limit:l,used:i,resetsAt:typeof o=="string"&&o.length>0?o:null,...typeof a=="string"&&a.trim().length>0?{emergencyGuidance:a}:{}})}function Ut(e){let t=e.raw;if(typeof t!="object"||t===null)return null;let r=t.freeCap;return typeof r=="object"&&r!==null?r:Nt(t)}function $t(e,t){let r=globalThis.URL;if(typeof r=="function"){let n;try{n=t===void 0?new r(e):new r(e,t)}catch{return null}try{if(n.protocol)return n}catch{}}return Kt(e)}var Vt=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,qt=/[\s\u0000-\u001f\u007f\\]/,Gt={"http:":"80","https:":"443"};function Kt(e,t){let r=e.trim();let n=qt.test(r)?null:Vt.exec(r);if(n===null)return null;let[,l="",i="",o="",a="",s="",u="",d="",c=""]=n,p=`${l.toLowerCase()}:`,f=Number(s);if(f>65535)return null;let h=s===""||String(f)===Gt[p]?"":String(f),g=Gt[p]!==void 0,b=a.toLowerCase()+(h&&`:${h}`),m=u||(g?"/":""),y=i||o?`${i}${o&&`:${o}`}@`:"";return{href:`${p}//${y}${b}${m}${d}${c}`,protocol:p,username:i,password:o,hostname:a.toLowerCase(),port:h,origin:g?`${p}//${b}`:"null",pathname:m,search:d==="?"?"":d,hash:c==="#"?"":c}}function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:Yt(e)})}function Yt(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var Qt=3e4,Zt=Ct*2,Jt="idempotency-key",Xt=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),er=/* @__PURE__ */Object.freeze({onEvent(){}}),tr=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function rr(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??er,r=e.timers??tr,n=e.rng??Math.random,l=e.sleep??((e,t)=>yr(e,r,t)),i=e.maxAttempts??St,o=e.unaryTimeoutMs??Qt,a=e.newIdempotencyKey??lr(),s=e=>{try{t.onEvent(e)}catch{}};async function u(t,u,d){let c=d?.maxAttempts,p=Math.max(1,c??i),f=d?.idempotent??Xt.has(u.method),h=d?.idempotencyKey===void 0?null:rr(d.idempotencyKey),g=f?h??a():null,b=nr(u,g),m=0;for(;;){let i=e=>/* @__PURE__ */Object.freeze({call:t,method:u.method,path:u.path,attempt:m,...g?{idempotencyKey:g}:{},...e});s(i({phase:"attempt"}));let a=br(o,r),d=mr(a.signal,u.signal),f;try{f=await authedSend({...b,signal:d.signal},e.auth)}catch(e){f=err(networkError(e))}finally{d.dispose(),a.cancel()}if(f.ok)return s(i({phase:"settled",ok:true,reason:"ok"})),f;let h=f.error,y=or(h,m,{maxAttempts:p,rng:n,now:r.now(),aborted:u.signal?.aborted===true,...c!==void 0?{perCallMaxAttempts:c}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),v={ok:false,code:h.code,reason:y.reason,...h.httpStatus!==void 0?{httpStatus:h.httpStatus}:{},...h.requestId!==void 0?{requestId:h.requestId}:{}};if(!y.retry)return s(i({phase:"settled",...v})),err(h);if(s(i({phase:"retry",...v,delayMs:y.delayMs})),await l(y.delayMs,u.signal),u.signal?.aborted===true)return s(i({phase:"settled",...v,reason:"aborted"})),err(h);m+=1}}async function d(t){return withAuthHeaders(t,await gr(e.auth))}async function*c(t,r,n){s(
|
|
9
9
|
/* @__PURE__ */Object.freeze({call:t,phase:"stream.open",method:r.method,path:r.path,attempt:0}));try{yield*e.auth.transport.stream(r,n)}catch{yield errorFrame({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}}/* @__PURE__ */
|
|
10
|
-
return Object.freeze({send:u,authorize:d,stream:c})}function
|
|
11
|
-
return Object.freeze(n)}function
|
|
12
|
-
return Object.freeze(Object.fromEntries(Object.entries(e).filter(([,e])=>e!=null)))}function
|
|
13
|
-
return Object.freeze({petRef:
|
|
10
|
+
return Object.freeze({send:u,authorize:d,stream:c})}function nr(e,t){let r={};for(let[t,n]of Object.entries(e.headers??{}))t.toLowerCase()!==Jt&&(r[t]=n);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}function lr(){let e=0;return()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var ir=10;function or(e,t,r){if(r.aborted)return{retry:false,reason:"aborted"};let n=ar(e);if(n==="quota")return{retry:false,reason:"daily-quota-exhausted"};if(n!=="burst"&&!isAutoRetryable(e.code))return{retry:false,reason:"terminal-code"};let l=n==="burst"?"burst-throttle":"retryable-code";if((()=>{if(r.policy===void 0)return false;try{return!r.policy.shouldRetry(e.code,t)}catch{return false}})())return{retry:false,reason:"terminal-code"};let i=()=>{if(r.policy===void 0)return null;let t;try{t=r.policy.maxAttempts(e.code)}catch{return null}return typeof t!="number"||!Number.isFinite(t)?null:Math.max(1,Math.min(ir,Math.floor(t)))},o=r.perCallMaxAttempts??i()??r.maxAttempts;if(t+1>=o)return{retry:false,reason:"attempts-exhausted"};let a=sr(e,r.now);return a!==null?a>Zt?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:l,delayMs:a}:{retry:true,reason:l,delayMs:backoffDelayMs(t,r.rng)}}function ar(e){let t=e.code==="unknown"?fromWire(fr(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}function sr(e,t){let r=dr(e.raw);if(r!==null){let e=r-t;return e>0?e:0}let n=ur(e.raw);return n===null?null:Math.round(n*1e3)}function ur(e){for(let t of cr(e)){let e=t.retry_after_seconds;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e}return null}function dr(e){for(let t of cr(e)){let e=t.resets_at,r=pr(e);if(r!==null)return r}return null}function cr(e){if(!hr(e))return[];let t=[e];for(let r of["error","detail"]){let n=e[r];hr(n)&&t.push(n)}return t}function pr(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 fr(e){for(let t of cr(e)){let e=t.code;if(typeof e=="string"&&e.length>0)return e}return null}function hr(e){return typeof e=="object"&&e!==null}async function gr(e){if(e.mode==="anonymous"){let t=await Ot(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 br(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return{signal:r.signal,cancel:()=>t.clearTimeout(n)}}function mr(e,t){let r=()=>{};if(!t)return{signal:e,dispose:r};let n=new AbortController;if(e.aborted||t.aborted)return n.abort(),{signal:n.signal,dispose:r};let l=()=>n.abort();return e.addEventListener("abort",l,{once:true}),t.addEventListener("abort",l,{once:true}),{signal:n.signal,dispose:()=>{e.removeEventListener("abort",l),t.removeEventListener("abort",l)}}}function yr(e,t,r){return e<=0||r?.aborted===true?Promise.resolve():new Promise(n=>{let l=t.setTimeout(()=>{r?.removeEventListener("abort",i),n()},e),i=()=>{t.clearTimeout(l),n()};r?.addEventListener("abort",i,{once:true})})}function vr(e){return e!=null&&(e.httpStatus===404||e.category==="notFound")}function wr(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 kr(e){return e.ok?e:err(wr(e.error))}function Cr(e){return{send:async(...t)=>kr(await e.send(...t)),authorize:t=>e.authorize(t),stream:(t,r,n)=>e.stream(t,r,n)}}var Sr=(e,t=4e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null;function xr(e){let t=Sr(e,2048);return t===null?null:/^https:\/\/[^\s]+$/i.test(t)?t:null}var Rr=6;function Tr(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=400?e:null}function _r(e,t,r){if(!Array.isArray(e))/* @__PURE__ */return Object.freeze([]);let n=[];for(let l of e){if(n.length>=r)break;if(l===null||typeof l!="object"||Array.isArray(l))continue;let e=t(l);e!==null&&n.push(e)}/* @__PURE__ */
|
|
11
|
+
return Object.freeze(n)}function zr(e){let t=Sr(e.title,80),r=Sr(e.body,600);return t===null||r===null?null:/* @__PURE__ */Object.freeze({title:t,body:r})}function Ir(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=e,r=[];if(Array.isArray(t.gallery))for(let e of t.gallery){let t=xr(e);t!==null&&r.length<Rr&&r.push(t)}let n=_r(t.doses,e=>{let t=Sr(e.label,60),r=Sr(e.amount,60);return t===null||r===null?null:/* @__PURE__ */Object.freeze({label:t,amount:r,minLb:Tr(e.minLb??e.min_lb),maxLb:Tr(e.maxLb??e.max_lb)})},Rr),l=_r(t.details,zr,Rr),i=t.fit,o=i!==null&&typeof i=="object"&&!Array.isArray(i)?zr(i):null,a=o!==null&&i.pet===true?/* @__PURE__ */Object.freeze({...o,pet:true}):o,s=/* @__PURE__ */Object.freeze({kicker:Sr(t.kicker,80),gallery:/* @__PURE__ */Object.freeze(r),doses:n,details:l,fine:Sr(t.fine,300),fit:a});return s.kicker===null&&r.length===0&&n.length===0&&l.length===0&&s.fine===null&&a===null?void 0:s}var Pr=128;var Fr=/* @__PURE__ */new Set(["shield","arrow","check","star","truck","refresh","card","alert","x","chat","repeat","calendar","flame","box","cart","minus","plus","chev","pulse","file","kit","dna","heart","bottle","harness","ramp"]),Lr=/* @__PURE__ */new Set(["y","c","g","r"]),Er=/* @__PURE__ */new Set(["done","now","next"]),Or=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null,Ar=(e,t=1e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null,jr=e=>typeof e=="string"&&/^[A-Za-z0-9_-]{1,40}$/.test(e)?e:null,Dr=e=>typeof e=="string"&&Fr.has(e)?e:null;function Mr(e){let t=Ar(e,2048);return t===null||/\s/.test(t)?null:/^https:\/\/[^/]/i.test(t)||/^\/(?![/\\])/.test(t)?t:null}var Br=e=>typeof e=="number"&&Number.isInteger(e)?String(e):Ar(e,Pr);function Hr(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function Wr(e){/* @__PURE__ */
|
|
12
|
+
return Object.freeze(Object.fromEntries(Object.entries(e).filter(([,e])=>e!=null)))}function Nr(e,t,r=20){if(!Array.isArray(e))return null;let n=[];for(let l of e){if(n.length>=r)break;let e=t(l);e!==null&&n.push(e)}return n.length===0?null:/* @__PURE__ */Object.freeze(n)}var Ur=(e,t=12,r=300)=>Nr(e,e=>Ar(e,r),t);function $r(e){let t=Or(e),r=Ar(t?.kicker,120),n=Ar(t?.title,300);if(t===null||r===null||n===null)return null;let l=Or(t.risk),i=Or(t.odds),o=Or(t.quote),a=Or(t.jump);return Wr({kicker:r,title:n,sources:Nr(t.sources,e=>{let t=Ar(Or(e)?.label,60);return t===null?null:Wr({label:t,kind:jr(Or(e)?.kind)})},6),risk:Ar(l?.lead,300)===null?null:Wr({lead:Ar(l?.lead,300),body:Ar(l?.body),kind:jr(l?.kind)}),odds:Ar(i?.label,120)===null||Ar(i?.from,20)===null||Ar(i?.to,20)===null?null:Wr({label:Ar(i?.label,120),tag:Ar(i?.tag,40),from:Ar(i?.from,20),to:Ar(i?.to,20),toLabel:Ar(i?.toLabel,120)}),quote:Ar(o?.text)===null?null:Wr({kicker:Ar(o?.kicker,120),tag:Ar(o?.tag,40),text:Ar(o?.text)}),jump:Ar(a?.title,300)===null||Ar(a?.go,60)===null?null:Wr({title:Ar(a?.title,300),go:Ar(a?.go,60)}),report:Vr(t.report)})}function Vr(e){let t=Or(e),r=Ar(t?.label,120),n=Ar(t?.text,1200);return r===null||n===null?null:Wr({label:r,text:n,actions:Ur(t?.actions,5,300)})}function qr(e){let t=Or(e),r=Ar(t?.title,300),n=Nr(t?.steps,e=>{let t=Or(e),r=Ar(t?.title,300),n=t?.tone;return r===null?null:Wr({title:r,body:Ar(t?.body),source:Ar(t?.source,200),tone:typeof n=="string"&&Lr.has(n)?n:null,icon:Dr(t?.icon),fromVet:t?.fromVet===true?true:null})});return r===null||n===null?null:Wr({title:r,label:Ar(t?.label,60),steps:n})}function Gr(e){let t=Or(e),r=Ar(t?.title,300);if(t===null||r===null)return null;let n=Or(t.rating),l=Or(t.reviews),i=Or(t.why),o=Or(i?.score),a=Or(t.dose),s=Or(t.ingredients),u=Nr(l?.items,e=>{let t=Or(e),r=t?.stars,n=Ar(t?.text),l=Ar(t?.by,80);return typeof r!="number"||!Number.isFinite(r)||r<1||r>5||n===null||l===null?null:Wr({stars:Math.round(r),text:n,by:l})},5),d=Nr(i?.rows,e=>{let t=Or(e),r=Ar(t?.chip,40),n=Ar(t?.title,300);return r===null||n===null?null:Wr({chip:r,kind:jr(t?.kind),title:n,body:Ar(t?.body)})}),c=Nr(a?.stats,e=>{let t=Or(e),r=Ar(t?.value,40),n=Ar(t?.label,120),l=t?.kind;return r===null||n===null?null:Wr({value:r,label:n,kind:l==="weight"||l==="dose"||l==="days"?l:null})},6),p=Ur(s?.items,12,80);return Wr({title:r,none:t.none===true?true:null,hidden:t.none===true&&t.hidden===true?true:null,productId:Br(t.productId),partnerSku:Ar(t.partnerSku,200),rating:Ar(n?.value,20)===null?null:Wr({value:Ar(n?.value,20),label:Ar(n?.label,120)}),line:Ar(t.line),reviews:Ar(l?.label,200)===null||u===null?null:Wr({label:Ar(l?.label,200),items:u}),checkoutLine:Ar(t.checkoutLine,300),why:Ar(i?.title,200)===null||d===null?null:Wr({title:Ar(i?.title,200),rows:d,score:Ar(o?.text,200)===null||Ar(o?.value,20)===null?null:Wr({text:Ar(o?.text,200),value:Ar(o?.value,20)})}),dose:Ar(a?.title,200)===null||c===null?null:Wr({title:Ar(a?.title,200),stats:c,note:Ar(a?.note)}),doseLabel:Ar(t.doseLabel,120),ingredients:p===null?null:Wr({label:Ar(s?.label,200),items:p}),proof:Ar(t.proof,300),trust:Nr(t.trust,e=>{let t=Or(e),r=Dr(t?.icon),n=Ar(t?.label,120);return r===null||n===null?null:Wr({icon:r,label:n})},6),more:Ar(t.more,120),fine:Ar(t.fine),checkin:Ar(t.checkin,200),detail:Ir(t.detail)??null})}function Kr(e){let t=Or(e),r=Ar(t?.title,200),n=Nr(t?.items,e=>{let t=Or(e),r=Ar(t?.title,300),n=Ar(t?.body);return r===null||n===null?null:Wr({title:r,body:n,urgent:t?.urgent===true?true:null,callVet:t?.callVet===true?true:null})});return r===null||n===null?null:Wr({title:r,items:n})}function Yr(e){let t=Or(e),r=Ar(t?.title,200),n=Ur(t?.questions,12,300),l=Ar(t?.add,80),i=Ar(t?.added,80);return r===null||n===null||l===null||i===null?null:Wr({title:r,questions:n,add:l,added:i})}function Qr(e){let t=Or(e),r=Ar(t?.title,200),n=Nr(t?.items,e=>{let t=Or(e),r=Ar(t?.key,Pr),n=Ar(t?.title,300),l=Ar(t?.action,80),i=Br(t?.productId),o=Ar(t?.added,80)??(i!==null?l:null);return r===null||n===null||l===null||o===null?null:Wr({key:r,productId:i,title:n,body:Ar(t?.body),price:Ar(t?.price,40),was:Ar(t?.was,40),tag:Ar(t?.tag,40),imageUrl:Mr(t?.imageUrl),icon:Dr(t?.icon),kind:jr(t?.kind),action:l,added:o,owned:t?.owned===true?true:null,detail:Ir(t?.detail)??null})},6);return r===null||n===null?null:Wr({title:r,items:n})}function Zr(e){let t=Or(e),r=Ar(t?.kicker,120),n=Ar(t?.title,120);return t===null||r===null||n===null?null:Wr({kicker:r,title:n,icon:Dr(t.icon),track:Nr(t.track,e=>{let t=Or(e),r=Ar(t?.title,120),n=t?.state;return r===null?null:Wr({title:r,detail:Ar(t?.detail,120),state:typeof n=="string"&&Er.has(n)?n:null,tag:Ar(t?.tag,40)})},6),heading:Ar(t.heading,200),rows:Nr(t.rows,e=>{let t=Or(e),r=Dr(t?.icon),n=Ar(t?.label,120);if(r===null||n===null)return null;if(t?.fromVet===true)return Wr({icon:r,label:n,text:"",fromVet:true});let l=Ar(t?.text,300);return l===null?null:Wr({icon:r,label:n,text:l})},6),note:Ar(t.note,300),action:Ar(t.action,80)})}function healthPlanFocusDesignFromWire(e){let t=Or(e),r=Ar(t?.title,300),n=Gr(t?.pick);if(t===null||r===null||n===null)return null;let l=Or(t.byline);return Wr({eyebrow:Ar(t.eyebrow,120),title:r,subtitle:Ar(t.subtitle,300),subtitleNoRecords:Ar(t.subtitleNoRecords,300),headImageUrl:Mr(t.headImageUrl),byline:Ar(l?.name,120)===null?null:Wr({name:Ar(l?.name,120),role:Ar(l?.role,120),imageUrl:Mr(l?.imageUrl),shortName:Ar(l?.shortName,60)}),focus:$r(t.focus),routine:qr(t.routine),pick:n,signs:Kr(t.signs),checkup:Yr(t.checkup),extras:Qr(t.extras),wait:Zr(t.wait),fine:Ar(t.fine),checkoutRows:Nr(t.checkoutRows,e=>{let t=Or(e),r=Dr(t?.icon),n=Ar(t?.label,60),l=Ar(t?.value,200);return r===null||n===null||l===null?null:Wr({icon:r,label:n,value:l})},6)})}function healthPlanPageFromWire(e,petRef){let t=Or(e);if(t===null||!("page"in t))return null;let r=Or(t.pet),n=r?.sex;/* @__PURE__ */
|
|
13
|
+
return Object.freeze({petRef:Ar(t.pet_ref,Pr)??petRef,pet:/* @__PURE__ */Object.freeze({name:Ar(r?.name,120),species:Ar(r?.species,60),sex:n==="female"||n==="male"?n:null,breed:Ar(r?.breed,120),weightKg:Hr(r?.weight_kg),weightLb:Hr(r?.weight_lb)}),checkout:t.checkout==="everfur_stripe"?"everfur_stripe":"partner",page:healthPlanFocusDesignFromWire(t.page),vetReviewed:t.vet_reviewed===true,trackingTextsEnabled:t.tracking_texts_enabled===true})}function Jr(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function Xr(e){return makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:`${e}: the response was not the expected shape`})}function en(e){return makeEverfurError("runtimeDisposed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}var tn=e=>typeof e=="string"&&e.length>0&&e.length<=Pr;function rn(petRef){return`/widget/v1/pets/${encodeURIComponent(petRef)}/plan`}async function nn(e,petRef,t){if(!tn(petRef))return err(Jr("petRef must be 1..128 characters"));let r=await e.send("healthPlan.page.read",{method:"GET",path:`${rn(petRef)}/page`,...t?.signal?{signal:t.signal}:{}});if(!r.ok)return err(r.error);let n=healthPlanPageFromWire(r.value,petRef);return n===null?err(Xr("healthPlan.page.read")):ok(n)}var ln=/* @__PURE__ */new WeakMap;function on(e){let t=ln.get(e);if(t!==void 0)return t;let r=an(e);return ln.set(e,r),r}function an(e){return{getPage:(petRef,t)=>{if(e.isDisposed)return Promise.resolve(err(en("getPage")));let{services:r}=e.registry,n=Cr(createRequestFunnel({auth:r.authFor(null),...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}));return nn(n,petRef,t)}}}function sn(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e)}catch{}}function un(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}function dn(e,...t){if(typeof e=="function")try{let r=e(...t);return un(r)&&Promise.resolve(r).then(void 0,sn),r}catch(e){sn(e);return}}var cn=/* @__PURE__ */new WeakMap;function pn(e){if(typeof e!="function")return;let t=cn.get(e);if(t!==void 0)return t;let r=(...t)=>{dn(e,...t)};return cn.set(e,r),r}function fn(e,...t){let r;try{r=e(...t)}catch(e){return sn(e),Promise.resolve({ok:false,error:e})}return Promise.resolve(r).then(e=>({ok:true,value:e}),e=>({ok:false,error:e}))}var hn=6e4;function gn({lifecycle:e,refreshKey:t,readyAt:r,revalidate:n,refresh:l,now:o=Date.now}){let s=i({readyAt:r,revalidate:n,refresh:l??n,now:o});s.current={readyAt:r,revalidate:n,refresh:l??n,now:o},a(()=>{if(e==null)return;let t=dn(()=>e.onForeground(()=>{let{readyAt:e,revalidate:t,now:r}=s.current;e!==null&&r()-e>=hn&&t()}));return()=>{typeof t=="function"&&dn(t)}},[e]);let u=i(t);a(()=>{Object.is(u.current,t)||(u.current=t,s.current.refresh())},[t])}var bn=hn,mn=/* @__PURE__ */Symbol.for("@everfur/sdk#HealthPlanPageReads@v1");function yn(){let e=globalThis,t=e[mn];if(t instanceof WeakMap)return t;let r=/* @__PURE__ */new WeakMap;return e[mn]=r,r}function vn(e,t,userRef,petRef,r){let n=yn(),l=n.get(t);l===void 0&&(l=/* @__PURE__ */new Map,n.set(t,l));let i=l,o=`${userRef}\0${petRef}`,a=i.get(o);if(!r&&a!==void 0&&(a.at===null||Date.now()-a.at<bn))return a.promise;let s={at:null,promise:e.getPage(petRef).then(e=>(i.get(o)===s&&(e.ok||vr(e.error)?s.at=Date.now():i.delete(o)),e))};return i.set(o,s),s.promise}function useHealthPlanPage(e){let{userRef:userRef,runtime:t}=ct(),r=l(()=>on(t),[t]),s=e.repository,u=s??r,d=n((e,n)=>s!==void 0||userRef==null?u.getPage(e):vn(r,t,userRef,e,n),[s,u,r,t,userRef]),{petRef:petRef}=e,c=e.enabled!==false&&userRef!=null&&petRef!==null,[p,f]=o({phase:"idle",petRef:null,page:null,error:null}),h=i(0),g=i(0),b=n(async e=>{let t=++h.current;if(!c||petRef===null){f(e=>e.phase==="idle"&&e.petRef===null?e:{phase:"idle",petRef:null,page:null,error:null});return}f(e=>({phase:"loading",petRef:petRef,page:e.petRef===petRef?e.page:null,error:null}));let r=await d(petRef,e);t===h.current&&(r.ok?f({phase:"ready",petRef:petRef,page:r.value,error:null,readyAt:Date.now()}):vr(r.error)?f({phase:"ready",petRef:petRef,page:null,error:null,missing:true,readyAt:Date.now()}):f({phase:"failed",petRef:petRef,page:null,error:r.error}))},[c,petRef,d]),m=n(()=>b(true),[b]),y=p.phase==="ready"&&p.petRef===petRef,v=n(async()=>{if(!c||petRef===null||!y)return;let e=h.current,t=++g.current,r=await d(petRef,true);e!==h.current||t!==g.current||!r.ok||f(e=>e.phase==="ready"&&e.petRef===petRef?{phase:"ready",petRef:petRef,page:r.value,error:null,readyAt:Date.now()}:e)},[c,petRef,y,d]);gn({lifecycle:e.lifecycle,refreshKey:e.refreshKey,readyAt:y?p.readyAt??null:null,revalidate:()=>{v()},refresh:()=>{y?v():m()}}),a(()=>(b(false),()=>{h.current+=1}),[b]);let w=c&&p.petRef!==petRef;return l(()=>({phase:w?"loading":p.phase,page:w?null:p.page,error:w?null:p.error,missing:!w&&p.missing===true,refresh:m}),[w,p,m])}var wn=/* @__PURE__ */Object.freeze({chat:/* @__PURE__ */Object.freeze(["chat.message.create"]),records:/* @__PURE__ */Object.freeze(["records.upload.create","records.record.read"]),recordsClinic:/* @__PURE__ */Object.freeze(["records.clinic.create"]),video:/* @__PURE__ */Object.freeze(["video.gait.execute"]),photo:/* @__PURE__ */Object.freeze(["photo.checkup.execute"]),animations:/* @__PURE__ */Object.freeze(["animations.state.read"]),televet:/* @__PURE__ */Object.freeze(["televet.visit.create"]),texting:/* @__PURE__ */Object.freeze(["sms.identity.read","sms.identity.update"]),healthPlan:/* @__PURE__ */Object.freeze(["shop.plan.read","shop.plan.update"])});function requires(e){return wn[e]}function decideCapability(e,t,r){let n=requires(e),l=/* @__PURE__ */new Map;for(let e of t)l.set(e.resource,e);if(r?.isPending===true&&n.some(e=>!l.has(e)))return Sn({name:e,enabled:false,isPending:true,limits:{}});let i=kn(n,l);return n.filter(e=>l.get(e)?.granted!==true).length===0?Sn({name:e,enabled:true,isPending:false,limits:i}):Sn({name:e,enabled:false,isPending:false,limits:i,disabled:Cn(n,l)})}function kn(e,t){let r={};for(let n of e){let e=t.get(n)?.limits;if(e)for(let[t,n]of Object.entries(e)){let e=r[t];r[t]=e===void 0?n:Math.min(e,n)}}return r}function Cn(e,t){for(let r of e){let e=t.get(r)?.disabled;if(e)/* @__PURE__ */
|
|
14
14
|
return Object.freeze({reason:e.reason,level:e.level,recoverable:e.recoverable})}/* @__PURE__ */
|
|
15
|
-
return Object.freeze({reason:userFacingError("accessDenied"),level:"user_entitlement",recoverable:false})}function
|
|
16
|
-
return Object.freeze(n)}var
|
|
17
|
-
return Object.freeze(a)}function
|
|
18
|
-
return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:
|
|
19
|
-
return Object.freeze({petRef
|
|
20
|
-
return Object.freeze(t.flatMap(e=>{let t=widgetPetFromWire(e);return t===null?[]:[t]}))}function createPetsRepository(e){return Yl(createRequestFunnel({auth:e}),createRequestFunnel({auth:e,unaryTimeoutMs:jl}))}function Yl(e,t=e){let r=(e,t)=>t?{...e,signal:t}:e,n=petRef=>Hl(petRef,void 0)??`/widget/v1/pets/${encodeURIComponent(petRef)}`;return{async list(t){let n=await e.send("pets.list",r({method:"GET",path:"/widget/v1/pets"},t?.signal));return n.ok?ok(Kl(n.value)):err(n.error)},async registerPet(petRef,t,r){let n=Hl(petRef,t);if(n!==null)return err(n);let l=Ul(t);if("error"in l)return err(l.error);let i={method:"POST",path:`/widget/v1/pets/${encodeURIComponent(petRef)}`,body:l.body},o=await e.send("pets.registerPet",r?.signal?{...i,signal:r.signal}:i);return o.ok?ok(ql(o.value,petRef)):err(o.error)},async updatePet(petRef,t,l){let i=n(petRef);if(typeof i!="string")return err(i);let o=Nl(t);if("error"in o)return err(o.error);let a=await e.send("pets.updatePet",r({method:"PATCH",path:i,body:o.body},l?.signal));return a.ok?ok(ql(a.value,petRef)):err(a.error)},async getPetProfile(petRef,t){let l=n(petRef);if(typeof l!="string")return err(l);let i=await e.send("pets.getPetProfile",r({method:"GET",path:`${l}/profile`},t?.signal));if(!i.ok)return err(i.error);let o=Gl(i.value);return o===null?err(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:"the pet profile response carried no pet_ref"})):ok(o)},async deletePet(petRef,t){let l=n(petRef);if(typeof l!="string")return err(l);let i=await e.send("pets.deletePet",r({method:"DELETE",path:l},t?.signal));return i.ok?ok(void 0):err(i.error)},async eraseUserData(e){let n=await t.send("pets.eraseUserData",r({method:"DELETE",path:"/widget/v1/me"},e?.signal),{maxAttempts:1});return n.ok?ok(void 0):err(n.error)}}}var Ql=/* @__PURE__ */new WeakMap,Zl=/* @__PURE__ */new Map;function Jl(e,t,petRef,r){let n=Ql.get(e);if(n===void 0)return null;let l;if(t.mode==="personalized"&&typeof t.userRef=="string")l=`u:${t.userRef}`;else if(t.mode==="anonymous"&&typeof t.sessionId=="string")l=`a:${t.sessionId}|${t.userRef??""}`;else return null;return`${n}|${l}|${petRef}|${ei(r)}`}function Xl(e,t){if(e===null)return t();let r=Zl.get(e);if(r!==void 0)return r;let n=t().finally(()=>{Zl.get(e)===n&&Zl.delete(e)});return Zl.set(e,n),n}function ei(e){return e===null||typeof e!="object"?JSON.stringify(e)??"undefined":Array.isArray(e)?`[${e.map(ei).join(",")}]`:`{${Object.entries(e).filter(([,e])=>e!==void 0).sort(([e],[t])=>e<t?-1:e>t?1:0).map(([e,t])=>`${JSON.stringify(e)}:${ei(t)}`).join(",")}}`}var ti="pet_not_registered";function ri(e){return e!=null&&e.reasonCode===ti}var ni=/* @__PURE__ */Object.freeze({status:"idle",error:null,registered:null,retry:()=>{}});function li(petRef,e,t){let{runtime:a,userRef:userRef,scopeEpoch:s}=ut(),u=r((e,t)=>{let r=a.registry.services.authFor(userRef);return Xl(Jl(a,r,e,t),()=>createPetsRepository(r).registerPet(e,t))},[a,userRef,s]),d=n(()=>e===void 0?null:ei(e),[e]),[c,p]=i({key:null,status:"idle",error:null,registered:null}),f=l(0),h=l(t);h.current=t;let g=petRef===null||d===null?null:`${String(userRef)}|${s}|${petRef}|${d}`,b=r(()=>{if(petRef===null||e===void 0||g===null)return;let t=++f.current;p({key:g,status:"registering",error:null,registered:null}),u(petRef,e).then(e=>{t===f.current&&(e.ok?(p({key:g,status:"registered",error:null,registered:e.value}),h.current?.()):p({key:g,status:"failed",error:e.error,registered:null}))})},[u,petRef,g]);o(()=>{if(g===null){f.current+=1;return}return b(),()=>{f.current+=1}},[g,b]);let y=r(()=>{c.status==="failed"&&b()},[c.status,b]);return n(()=>g===null?ni:c.key!==g?{status:"registering",error:null,registered:null,retry:y}:{status:c.status,error:c.error,registered:c.registered,retry:y},[g,c,y])}var ii=/* @__PURE__ */Object.freeze({});function oi(e){let[t,a]=i(ii),s=l(null),u=l([]);u.current=e.map(e=>e.id),o(()=>{if(e.length===0){s.current=null,a(e=>e===ii?e:ii);return}let t=s.current;if(t===null)return;let r=e.find(e=>e.role==="user"&&!t.known.has(e.id));r!==void 0&&(s.current=null,a(e=>({...e,[r.id]:t.images})))},[e]);let d=r(e=>{s.current=e.length===0?null:{images:e,known:new Set(u.current)}},[]);return n(()=>({byMessage:t,stage:d}),[t,d])}var ai=/* @__PURE__ */new WeakSet;function si(){let e=makeEverfurError("internalError",{retryable:true});return ai.add(e),err(e)}function ui(e){if(typeof e!="object"||e===null||e.ok!==false)return false;let t=e.error;return typeof t=="object"&&t!==null&&ai.has(t)}var di=500;function ci(e){if(!e)return null;let t=e.replace(/[\u0000-\u001F\u007F-\u009F\u200E\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g," ").replace(/\s+/g," ").trim();return t?t.slice(0,di):null}function pi(e,t,r,n){let i=ci(r),a=i===null?null:n!==void 0?`key:${String(n)}`:`prompt:${i}`,s=l(e);s.current=e;let u=l(null),d=l(null),c=l(a);c.current=a,o(()=>{if(i===null||a===null||t||u.current===a||d.current===a)return;let e=s.current;if(e===void 0)return;d.current=a;let r=e=>{d.current===a&&(d.current=null),!ui(e)&&c.current===a&&(u.current=a)};Promise.resolve(e(i)).then(r,()=>r(void 0))},[i,a,t,e])}var fi=/* @__PURE__ */Object.freeze({openUnreadHead:true,reportLoadFailures:true}),hi=/* @__PURE__ */Object.freeze({reportLoadFailures:true}),gi=/* @__PURE__ */Object.freeze({...fi,markRead:true}),bi=/* @__PURE__ */Object.freeze({...hi,markRead:true});function yi(e,t){return e?t?gi:fi:t?bi:hi}function mi(e,t){let r=e?.isVisible===void 0?t:e.isVisible.bind(e);return r===void 0?true:sn(()=>r()!==!1)===true}function vi(e,t){let r=l({target:e,isVisible:t});r.current={target:e,isVisible:t};let n=l(e.isStreaming);o(()=>{let t=n.current;if(n.current=e.isStreaming,!t||e.isStreaming)return;let{target:l,isVisible:i}=r.current;l.status!=="complete"||l.conversationId===null||l.unreadCount===null||!i()||l.markRead()},[e.isStreaming])}function wi(e,conversationId,t){if(e==="announced")return false;let r=t.lastRefresh;return r===null||r.conversationId!==conversationId?false:t.now-r.at<15e3}function ki(e,t){let conversationId=t.activeConversationId===null||t.activeConversationId.length===0?null:t.activeConversationId;return conversationId===null&&t.refreshesBlankThread!==true?{action:"skip",reason:"no_thread"}:t.isTurnInFlight?{action:"defer",reason:"turn_in_flight"}:t.isOffline?{action:"defer",reason:"offline"}:wi(e,conversationId,t)?{action:"skip",reason:"coalesced"}:{action:"refresh",conversationId:conversationId}}var Ci=3e5;function Si(e){if(e===null||typeof e!="object"||e.ok!==false)return false;let t=e.error;if(t===null||typeof t!="object")return false;if(t.category==="rateLimit"||t.category==="server")return true;let r=t.httpStatus;return typeof r=="number"&&(r===429||r>=500)}function xi(e,t,r){let n=l(t);n.current=t;let i=l(null),a=l(null),s=l(false),u=l(0),d=l(0),c=l(3e4),p=()=>e?.isOffline===void 0?false:sn(()=>e.isOffline?.()===!0)===true,f=p(),h=l(()=>{});h.current=e=>{let{conversationId:conversationId,isTurnInFlight:t,refresh:r,refreshesBlankThread:l}=n.current,o=ki(e,{activeConversationId:conversationId,isTurnInFlight:t,refreshesBlankThread:l===true,isOffline:p(),lastRefresh:i.current,now:Date.now()});if(o.action==="skip")return;if(o.action==="defer"){a.current!=="announced"&&(a.current=e);return}if(s.current){if(e==="poll")return;a.current!=="announced"&&(a.current=e);return}if(a.current=null,i.current={conversationId:o.conversationId,at:Date.now()},r===void 0)return;s.current=true;let f=e=>{s.current=false,Si(e)?(u.current=Math.min(u.current===0?c.current*2:u.current*2,Ci),d.current=Date.now()+u.current):(u.current=0,d.current=0);let t=a.current;t!==null&&h.current(t)};Promise.resolve(r()).then(f,()=>f({ok:false,error:{category:"server"}}))},o(()=>{if(t.isTurnInFlight||f)return;let e=a.current;e!==null&&h.current(e)},[t.isTurnInFlight,f]),o(()=>{if(e===void 0)return;let t=[],r=(e,r)=>{if(e===void 0)return;let n=sn(()=>e(()=>{h.current(r)}));typeof n=="function"&&t.push(n)};return r(e.onForeground?.bind(e),"foreground"),r(e.onOnline?.bind(e),"foreground"),r(e.onAnnounced?.bind(e),"announced"),()=>{for(let e of t)sn(e)}},[e]);let g=r?.intervalMs??null,b=r?.isVisibleFallback;o(()=>{if(e===void 0||g===null||!Number.isFinite(g)||g<=0)return;c.current=g;let t=setInterval(()=>{Date.now()<d.current||mi(e,b)&&h.current("poll")},g);return()=>clearInterval(t)},[e,g,b])}var Ri=/^efch_[A-Za-z0-9_-]{43}$/,Ti="efch";function _i(e){return typeof e=="string"&&Ri.test(e)}function chatHandoffTokenFromUrl(e){if(typeof e!="string")return null;let t=e.indexOf("#");if(t<0)return null;for(let r of e.slice(t+1).split("&")){if(!r.startsWith(`${Ti}=`))continue;let e=r.slice(Ti.length+1);return _i(e)?e:null}return null}var zi=/* @__PURE__ */Object.freeze(["better","same","worse"]),Ii=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var Pi="checkin",Fi=/^\d{4}-\d{2}-\d{2}$/,Li="watching";function isCheckinSettled(e){return e.status!=null&&e.status!==Li}function Ei(e){if(typeof e!="string")return null;let t=e.split(":");if(t.length!==3)return null;let[r,n,l]=t;return r!==Pi||n===void 0||l===void 0||!Ii.test(n)||!Fi.test(l)?null:{caseId:n,dueDay:l}}function Oi(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}function Ai(e,t,r){return makeEverfurError(e,{retryable:t,...{}})}var ji=128,Di=/[\u0000-\u001f\u007f]/;function Mi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function Bi(e){return typeof e!="string"||e.length===0||e.length>ji||Di.test(e)||e.includes("://")?null:e}function Hi(e){if(e===null)return null;let conversationId=e.conversation_id,petRef=Bi(e.pet_ref);return typeof conversationId!="string"||!Oi(conversationId)||petRef===null?null:{conversationId:conversationId,petRef:petRef}}function Wi(e,t,r){return _i(t)?createRequestFunnel({auth:e,...r?{errorPolicy:r}:{}}).send("chat.redeemHandoff",{method:"POST",path:"/widget/v1/chat/handoffs/redeem",body:{token:t}},{maxAttempts:1}).then(e=>e.ok?ok(Hi(Mi(e.value))):e.error.httpStatus===404?ok(null):err(e.error),()=>err(Ai("internalError",false))):Promise.resolve(ok(null))}function Ni(e,t){let r=t?.runtime??null,userRef=t?.userRef??null,n=_i(e)?e:null,l=n===null||userRef===null?null:`${String(userRef)}|${n}`,[a,s]=i(null);return o(()=>{if(l===null||n===null||userRef===null||r===null)return;let e=true,t=r.registry.services;return Wi(t.authFor(userRef),n,t.errorPolicy).then(t=>{!e||!t.ok||t.value===null||s({key:l,target:/* @__PURE__ */Object.freeze({kind:"chat",conversationId:t.value.conversationId,petRef:t.value.petRef})})}),()=>{e=false}},[l,r,n,userRef]),a!==null&&a.key===l?a.target:void 0}function Ui(e){if(e===void 0)return null;let conversationId=e.conversationId??"",petRef=e.petRef??"";return conversationId===""&&petRef===""?null:`${String(conversationId)}|${String(petRef)}`}function $i(e,t,r){let n=Ui(t),i=t?.kind==="chat",a=t?.petRef??null,s=i&&!r.pinned&&a!==null&&r.petRef!==null&&a!==r.petRef,u=l({openCheckin:e,target:t,selectPet:r.selectPet});u.current={openCheckin:e,target:t,selectPet:r.selectPet};let d=l(null),c=l(null),petRef=r.petRef;o(()=>{if(n===null||d.current===n)return;let{openCheckin:e,target:t,selectPet:l}=u.current;if(s&&a!==null){if(c.current?.key!==n){c.current={key:n,from:petRef},l(a);return}petRef!==c.current.from&&(d.current=n);return}i&&!r.ready||(d.current=n,!(e===void 0||t===void 0)&&Promise.resolve(e(t)).catch(()=>{}))},[n,i,s,a,petRef,r.ready])}var Vi=/* @__PURE__ */Object.freeze({heading:"Chats",empty:"No chats yet",emptyBody:"Start a new conversation to see it here.",noMatch:"No chats match that.",loading:"Loading your chats…",loadFailed:"Couldn’t load your chats",loadingMore:"Loading more…",untitled:"New conversation",newChat:"New chat",searchPlaceholder:"Search chats…",search:"Search chats",countLabel:"Chats and vet messages",countSeparator:" · ",newReply:"New reply · {date}",retry:"Try again",close:"Close",closeA11y:"Close history",more:"Load more",earlier:"Load earlier messages",loadingEarlier:"Loading earlier messages…",openConversation:"Open conversation",unreadPrefix:"Unread. "});function qi(e){let t=e?.replace(/\s+/g," ").trim();return t||Vi.untitled}function Gi(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString([],{month:"short",day:"numeric"})}function Ki(e){let t=Gi(e.updatedAt);return t===null?null:e.unreadCount!==null&&e.unreadCount>0?Vi.newReply.replace("{date}",t):t}function Yi(e,t){return t?`${Vi.countLabel}${Vi.countSeparator}${e}`:Vi.countLabel}function Qi(e){return`${e.unreadCount!==null&&e.unreadCount>0?Vi.unreadPrefix:""}${Vi.openConversation} ${qi(e.title)}`}function Zi(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').toLowerCase().trim().replace(/\s+/g," ")}function Ji(e,t){let r=Zi(t);if(r.length===0)return e;let n=[[],[],[]];for(let t of e){let e=Zi(qi(t.title)),l=e.indexOf(r);if(l<0)continue;let i=l===0?0:e.charAt(l-1)===" "?1:2;n[i]?.push(t)}return n.flat()}function Xi(e){return{scope:e,rows:[],cursor:null,loading:false,loadingMore:false,error:null}}function eo(e){let[t,a]=i(false),[s,u]=i(""),d=e.listConversations,c=l(0),[p,f]=i(()=>Xi(d)),h=p.scope===d?p:Xi(d);o(()=>(c.current+=1,a(false),u(""),f(Xi(d)),()=>{c.current+=1}),[d]);let g=r(async t=>{let r=++c.current,n=t!==void 0;f(e=>({...e,scope:d,loading:!n,loadingMore:n,error:null}));let l=await e.listConversations(t?{cursor:t}:void 0);if(r===c.current){if(!l.ok){f(e=>({...e,loading:false,loadingMore:false,error:l.error.displayMessage}));return}f(e=>{let r=t&&e.scope===d?e.rows:[],n=new Set(r.map(e=>e.id));return{scope:d,loading:false,loadingMore:false,error:null,rows:[...r,...l.value.conversations.filter(e=>!n.has(e.id))],cursor:l.value.nextCursor===t?null:l.value.nextCursor}})}},[e.listConversations,d]),b=()=>{a(true),u(""),g()},y=()=>{c.current+=1,a(false)},m=async t=>{let r=++c.current;f(e=>({...e,loading:true,error:null}));let n=await e.resumeConversation(t);r===c.current&&(f(e=>({...e,loading:false,error:n.ok?null:n.error.displayMessage})),n.ok&&a(false))},v=async()=>{let t=c.current,r=await e.loadOlderMessages();t===c.current&&!r.ok&&f(e=>({...e,error:r.error.displayMessage}))},w=()=>{e.newConversation(),c.current+=1,a(false)},k=()=>{h.cursor===null||h.loading||h.loadingMore||s.trim().length>0||g(h.cursor)},C=n(()=>Ji(h.rows,s),[h.rows,s]),S=s.trim().length>0;return{...h,open:t,show:b,close:y,load:g,resume:m,earlier:v,newConversation:w,loadMore:k,query:s,setQuery:u,searching:S,filtered:C,emptyKind:h.rows.length===0?"empty":"noMatch"}}var to="#111111",ro="#FFFFFF",no=/* @__PURE__ */Object.freeze({emergency:/* @__PURE__ */Object.freeze({level:"emergency",label:"Call a vet now",borderColor:"#FCA5A5",backgroundColor:"#FEF2F2",textColor:"#991B1B",reasonColor:to,pillColor:ro,showsVetAction:true}),schedule_soon:/* @__PURE__ */Object.freeze({level:"schedule_soon",label:"Vet care suggested soon",borderColor:"#FCD34D",backgroundColor:"#FFFBEB",textColor:"#92400E",reasonColor:to,pillColor:ro,showsVetAction:true}),home_care:/* @__PURE__ */Object.freeze({level:"home_care",label:"Monitor at home",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:to,pillColor:ro,showsVetAction:false}),general:/* @__PURE__ */Object.freeze({level:"general",label:"Good to know",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:to,pillColor:ro,showsVetAction:false})});function lo(e){return`${e.messageId}:${e.level}:${e.reason??""}`}function io(e){return tt(et.urgencyGeneralReason,{petName:e?.trim()||et.emptyTitlePetFallback})}function oo(e,t){for(let r=e.length-1;r>=0;r-=1){let n=e[r];if(n?.role!=="assistant"||n.responseId===void 0)continue;let l=n.urgencyLevel;return l?{messageId:n.id,level:l,reason:ao(n.urgencyReason)}:n.urgencyProvided===true?{messageId:n.id,level:"general",reason:io(t)}:null}return null}function ao(e){return typeof e=="string"&&e.trim().length>0?e:null}function so(e){let t=e===null?null:lo(e),[l,a]=i(null),[s,u]=i(false);o(()=>u(false),[t]);let d=e!==null&&(s||!(l!==null&&l===t)),c=e===null?null:no[e.level],p=e!==null&&!d&&e.level!=="general",f=r(()=>{t!==null&&a(t),u(false)},[t]),h=r(()=>u(true),[]);return n(()=>({source:e,tier:c,signature:t,showBanner:d,showCompactIcon:p,showVetAction:d&&c!==null&&c.showsVetAction,dismissLabel:c===null?null:tt(et.dismissBanner,{label:c.label}),dismiss:f,expand:h}),[e,c,t,d,p,f,h])}var uo=class extends u{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey}}static getDerivedStateFromError(){return{failed:true}}static getDerivedStateFromProps(e,t){return Object.is(e.resetKey,t.key)?null:{failed:false,key:e.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};function RenderHost({render:e}){return e()}function HostRender({render:e,fallback:r,resetKey:n}){return t(uo,{fallback:r,resetKey:n,children:t(RenderHost,{render:e})})}var co=48;function po(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}function CapabilityGate(e){let{capability:t,children:r,renderDisabled:l,renderPending:i,style:o}=e,a=useCapability(t),s=n(()=>po(a),[a]);switch(s){case"enabled":return r;case"pending":return i?/* @__PURE__ */c(HostRender,{render:i,fallback:/* @__PURE__ */c(PendingSkeleton,{capability:t,style:o})}):/* @__PURE__ */c(PendingSkeleton,{capability:t,style:o});case"disabled":return l?/* @__PURE__ */c(HostRender,{render:()=>l(a),fallback:/* @__PURE__ */c(OffState,{decision:a,style:o}),resetKey:a}):/* @__PURE__ */c(OffState,{decision:a,style:o});default:return assertNever(s)}}function PendingSkeleton({capability:e,style:t}){let r=useEverfurTheme(),l=n(()=>fo(r),[r]);/* @__PURE__ */
|
|
21
|
-
return
|
|
22
|
-
return
|
|
23
|
-
return Object.freeze([...t])}function
|
|
24
|
-
return Object.freeze({hosts:e,open:r!==void 0?e=>{
|
|
25
|
-
return
|
|
26
|
-
/* @__PURE__ */
|
|
27
|
-
/* @__PURE__ */
|
|
28
|
-
/* @__PURE__ */
|
|
29
|
-
return
|
|
30
|
-
/* @__PURE__ */
|
|
31
|
-
/* @__PURE__ */
|
|
32
|
-
return
|
|
33
|
-
return
|
|
34
|
-
return
|
|
35
|
-
return
|
|
36
|
-
return
|
|
37
|
-
/* @__PURE__ */
|
|
38
|
-
/* @__PURE__ */
|
|
39
|
-
return
|
|
40
|
-
/* @__PURE__ */
|
|
41
|
-
/* @__PURE__ */
|
|
42
|
-
return
|
|
43
|
-
/* @__PURE__ */
|
|
44
|
-
/* @__PURE__ */
|
|
45
|
-
return
|
|
46
|
-
/* @__PURE__ */
|
|
47
|
-
/* @__PURE__ */
|
|
48
|
-
/* @__PURE__ */
|
|
49
|
-
return
|
|
50
|
-
/* @__PURE__ */
|
|
51
|
-
/* @__PURE__ */
|
|
52
|
-
return
|
|
53
|
-
/* @__PURE__ */
|
|
54
|
-
/* @__PURE__ */
|
|
55
|
-
/* @__PURE__ */
|
|
56
|
-
return
|
|
57
|
-
/* @__PURE__ */
|
|
58
|
-
/* @__PURE__ */
|
|
59
|
-
return
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
/* @__PURE__ */
|
|
62
|
-
return
|
|
63
|
-
/* @__PURE__ */
|
|
64
|
-
/* @__PURE__ */
|
|
65
|
-
return
|
|
66
|
-
/* @__PURE__ */
|
|
67
|
-
/* @__PURE__ */
|
|
68
|
-
return
|
|
69
|
-
/* @__PURE__ */
|
|
70
|
-
/* @__PURE__ */
|
|
71
|
-
return
|
|
72
|
-
return
|
|
73
|
-
return
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
/* @__PURE__ */
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
return
|
|
78
|
-
return
|
|
79
|
-
/* @__PURE__ */
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
return
|
|
82
|
-
/* @__PURE__ */
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
return
|
|
85
|
-
/* @__PURE__ */
|
|
86
|
-
/* @__PURE__ */
|
|
87
|
-
/* @__PURE__ */
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
return
|
|
90
|
-
/* @__PURE__ */
|
|
91
|
-
/* @__PURE__ */
|
|
92
|
-
return Object.freeze({code:e,retryable:t,filename:r,...n??{}})}function attachmentSize(e){if(typeof e.sizeBytes=="number"&&Number.isFinite(e.sizeBytes)&&e.sizeBytes>=0)return e.sizeBytes;let t=e.blob;return t!==void 0&&typeof t.size=="number"&&Number.isFinite(t.size)?t.size:null}function validateAttachment(e){let t=sanitizeFilename(e.name),r=typeof e.mimeType=="string"?e.mimeType.trim().toLowerCase():"";if(!isAttachmentMime(r))return
|
|
93
|
-
return Object.freeze({upload_id:l,upload_url:i,upload_fields:/* @__PURE__ */Object.freeze(a),expires_in_seconds:n(t.expires_in_seconds)??0,max_content_length:n(t.max_content_length)??ya,s3_key:o,purpose:r(t.purpose)})}function Ra(e,t){let r=e.httpStatus;switch(e.code){case"quotaExceeded":return Sa("quota_exceeded",false,t,{cause:e});case"rateLimited":return Sa("rate_limited",true,t,{cause:e});case"idempotencyConflict":case"idempotencyInFlight":return Sa("idempotency_conflict",true,t,{cause:e});case"validationFailed":return Sa("unsupported_type",false,t,{cause:e});case"serviceUnavailable":case"streamTimeout":return Sa("network",true,t,{cause:e});default:return r===429?Sa("rate_limited",true,t,{cause:e}):r===503?Sa("network",true,t,{cause:e}):r===void 0?Sa("network",true,t,{cause:e}):Sa("server",e.retryable,t,{httpStatus:r,cause:e})}}async function initiateAttachmentUpload(e,t,r){let n=await e.send("chat.attachments.initiate",{method:"POST",path:wa,body:{filename:t.filename,content_type:t.contentType,file_size:t.sizeBytes},...r?.signal?{signal:r.signal}:{}});if(!n.ok)return Ca(Ra(n.error,t.filename));let l=xa(n.value);return l===null?Ca(Sa("server",false,t.filename)):ka(l)}async function uploadAttachmentBytes(e,t,r,n){let l=()=>n?.signal?.aborted===true;if(l())return Ca(Sa("cancelled",true,r.filename));try{return await e.postMultipart(t,r.file,{...n?.signal?{signal:n.signal}:{},...n?.onProgress?{onProgress:n.onProgress}:{}}),ka(void 0)}catch{return l()?Ca(Sa("cancelled",true,r.filename)):Ca(Sa("server",true,r.filename))}}var Ta=2,_a=3,za=/* @__PURE__ */Object.freeze([1e3,2e3,4e3]),Ia=0;function Pa(){return Ia+=1,`attachment-${Ia}`}function createAttachmentQueue(e){let t=Math.max(1,e.concurrency??Ta),r=Math.max(1,e.maxAttempts??_a),n=e.backoffMs??za,l=Math.max(1,e.maxPerMessage??ma),i=e.timers??pa,o=e.newId??Pa,a=ca(e.transport),s=/* @__PURE__ */new Map,u=[],d=[],c=/* @__PURE__ */new Set,p=/* @__PURE__ */new Set,f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])}),h=false,g=()=>{f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze(u.flatMap(e=>{let t=s.get(e);return t===void 0?[]:[t.state]}))});for(let e of p)e()},b=(e,t)=>{e.state=/* @__PURE__ */Object.freeze({...e.state,...t}),g()},y=()=>{for(;!h&&c.size<t&&d.length>0;){let e=d.shift(),t=s.get(e);t!==void 0&&(c.add(e),m(t).finally(()=>{c.delete(e),y()}))}},m=async t=>{let{attachment:l}=t;for(;t.attempts<r;){if(h||t.controller.signal.aborted)return;t.attempts+=1;let o=t.controller.signal;b(t,{status:"uploading",error:null,progress:0});let a=await initiateAttachmentUpload(e.funnel,l,{signal:o});if(h||o.aborted)return;let s;if(!a.ok)s=Ca(a.error);else{let r=await uploadAttachmentBytes(e.transport,a.value,l,{signal:o,onProgress:e=>{!o.aborted&&t.state.status==="uploading"&&b(t,{progress:Fa(e)})}});if(h||o.aborted)return;s=r.ok?ka(a.value.s3_key):Ca(r.error)}if(s.ok){b(t,{status:"uploaded",s3Key:s.value,error:null,progress:1});return}let u=s.error,d=u.retryable&&t.attempts<r;if(b(t,{status:d?"uploading":"failed",error:u,progress:0}),!d)return;let c=n[Math.min(t.attempts-1,n.length-1)]??0;await fa(c,o,i)}},v=e=>{d.push(e.state.id),y()},w={available:a,subscribe(e){return p.add(e),()=>{p.delete(e)}},getSnapshot:()=>f,get uploading(){return f.attachments.some(e=>e.status==="uploading")},get s3Keys(){return f.attachments.flatMap(e=>e.status==="uploaded"&&e.s3Key!==null?[e.s3Key]:[])},add(e){let t=validateAttachment(e);if(!t.ok)return t;if(h||u.length>=l)return Ca(Sa("too_many",false,t.value.filename));let r=o(),n={attachment:t.value,controller:new AbortController,attempts:0,state:/* @__PURE__ */Object.freeze({id:r,filename:t.value.filename,previewUri:e.uri,contentType:t.value.contentType,sizeBytes:t.value.sizeBytes,status:"uploading",s3Key:null,error:null,progress:0})};return s.set(r,n),u.push(r),g(),v(n),ka(n.state)},retry(e){let t=s.get(e);t===void 0||h||t.state.status!=="failed"||(t.controller=new AbortController,t.attempts=0,b(t,{status:"uploading",error:null,progress:0,s3Key:null}),v(t))},remove(e){let t=s.get(e);if(t===void 0)return;t.controller.abort(),s.delete(e);let r=u.indexOf(e);r>=0&&u.splice(r,1);let n=d.indexOf(e);n>=0&&d.splice(n,1),g()},clear(){for(let e of[...u])w.remove(e)},dispose(){h=true;for(let e of s.values())e.controller.abort();s.clear(),u.length=0,d.length=0,p.clear(),f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])})}};return w}function Fa(e){return Number.isNaN(e)||e<0?0:e>1?1:e}function La(e){switch(e.code){case"too_large":return tt(et.attachmentTooLarge,{max:formatBytes(ya),filename:e.filename,size:formatBytes(e.sizeBytes??0)});case"too_many":return tt(et.attachmentTooMany,{max:ma});case"unsupported_type":return tt(et.attachmentUnsupported,{filename:e.filename});case"network":return et.attachmentNetwork;case"server":return tt(et.attachmentServer,{status:""});case"cancelled":return et.attachmentCancelled;case"rate_limited":return et.attachmentRateLimited;case"quota_exceeded":return et.attachmentQuota;case"idempotency_conflict":return et.attachmentConflict;case"unknown":return et.attachmentUnknown}}function Ea(e,t){return tt(e>=t?et.attachmentsFull:et.addAttachment,{used:e,total:t})}var Oa=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])});function useChatAttachments(e={}){let{runtime:t,userRef:userRef,scopeEpoch:s}=ut(),u=e.maxPerMessage??ma,d=r(()=>{let{services:r}=t.registry;return createAttachmentQueue({funnel:createRequestFunnel({auth:r.authFor(userRef),...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}),transport:e.transport??r.uploadTransport,maxPerMessage:u})},[t,userRef,s,u,e.transport]),c=n(()=>e.queue??d(),[e.queue,d]),p=l(/* @__PURE__ */new WeakSet),[f,h]=i(null),g=f!==null&&f.of===c?f.queue:c;o(()=>{if(g!==e.queue){if(p.current.has(g)){h({of:c,queue:d()});return}return()=>{g.dispose(),p.current.add(g)}}},[g,c,d,e.queue]);let b=a(g.subscribe,g.getSnapshot,()=>Oa),[y,m]=i(null),v=r(e=>{let t=(Array.isArray(e)?e:[e]).map(e=>g.add(e)),r=t.find(e=>!e.ok);return r!==void 0&&!r.ok&&m(r.error),t},[g,m]),w=r(e=>g.retry(e),[g]),k=r(e=>g.remove(e),[g]),C=r(()=>g.clear(),[g]),S=r(()=>m(null),[m]),x=b.attachments.some(e=>e.status==="uploading"),R=b.attachments.some(e=>e.status==="failed");return n(()=>({available:g.available,attachments:b.attachments,maxPerMessage:u,uploading:x,failed:R,blocked:x||R,s3Keys:b.attachments.flatMap(e=>e.status==="uploaded"&&e.s3Key!==null?[e.s3Key]:[]),rejected:y,add:v,retry:w,remove:k,clear:C,dismissRejected:S}),[g.available,b,u,x,R,y,v,w,k,C,S])}var Aa=6e3;function ja(e,t,r){let n=t.trim();if(!n)return e;let l=e===""||/\s$/.test(e)?"":" ",i=`${e}${l}${n}`;return typeof r=="number"&&r>0?i.slice(0,r):i}function Da(e){let t=Math.max(0,Math.floor(e/1e3)),r=Math.floor(t/60),n=t%60;return`${r}:${n.toString().padStart(2,"0")}`}function Ma(e){switch(e){case"permissionDenied":return et.micBlocked;case"noSpeech":return et.noSpeech;case"unavailable":return et.dictationUnavailable}}function Ba(e,t,r){if(e)try{e.track(t,{...r})}catch{}}var Ha=["Apoquel","Cytopoint","Bravecto","NexGard","Simparica Trio","Credelio","Revolution","Heartgard","Interceptor","Sentinel","ProHeart","Rimadyl","carprofen","meloxicam","Metacam","Galliprant","gabapentin","trazodone","Librela","Solensia","Zenrelia","prednisone","prednisolone","amoxicillin","Clavamox","cephalexin","Convenia","metronidazole","doxycycline","Cerenia","maropitant","famotidine","omeprazole","Proin","Vetmedin","pimobendan","enalapril","furosemide","levothyroxine","methimazole","Vetsulin","fluoxetine","Sileo","tramadol","buprenorphine","Denamarin","Dasuquin","Cosequin","parvovirus","distemper","Bordetella","leptospirosis","heartworm","giardia","coccidia","pancreatitis","hypothyroidism","Cushing's disease","Addison's disease","IVDD","cruciate ligament","luxating patella","hip dysplasia","pyometra","kennel cough","otitis","FIV","FeLV","DHPP","FVRCP","Labrador Retriever","Golden Retriever","French Bulldog","German Shepherd","Dachshund","Cavalier King Charles Spaniel","Shih Tzu","Pomeranian","Chihuahua","Yorkshire Terrier","Bichon Frise","Havanese","Cockapoo","Goldendoodle","Labradoodle","Weimaraner","Vizsla","Shiba Inu","Springer Spaniel","Miniature Schnauzer","Corgi","Australian Shepherd","Border Collie","Siberian Husky","Beagle","Maine Coon","Ragdoll","Sphynx","Bengal cat","British Shorthair"];function Wa(e={}){let t=/* @__PURE__ */new Set,r=[];for(let n of[e.name,e.breed,...Ha]){let e=(n??"").trim();if(!e)continue;let l=e.toLowerCase();if(!t.has(l)&&(t.add(l),r.push(e),r.length>=100))break}return r}function Na(e,conversationId,t){let[n,l]=i({send:e,conversationId:conversationId,text:t??"",seeded:t??null}),a=n.send===e&&(n.conversationId===null||n.conversationId===conversationId);o(()=>{l(r=>{let n=r.send===e&&(r.conversationId===null||r.conversationId===conversationId),l=n?r.text:"",i=n?r.seeded:null,o=t!=null&&t!==i&&l.length===0;return{send:e,conversationId:conversationId,text:o?t:l,seeded:o?t:i}})},[e,conversationId,t]);let s=r(t=>l(r=>({send:e,conversationId:conversationId,text:t,seeded:r.seeded})),[e,conversationId]);return[a?n.text:"",s]}function Ua(e,conversationId,t,r,n=false){let a=l({draft:t,setDraft:r});a.current={draft:t,setDraft:r};let s=l(null),[u,d]=i(null);o(()=>{if(e===void 0)return;let t=`${conversationId??""}`;if(s.current===t)return;s.current=t;let r=true;return(async()=>{let n=await cn(()=>e.read(conversationId));if(!r)return;let l=n.ok&&typeof n.value=="string"?n.value:"";l.length>0&&a.current.draft.length===0&&a.current.setDraft(l),d(t)})(),()=>{r=false}},[e,conversationId]),o(()=>{e===void 0||n||u!==`${conversationId??""}`||sn(()=>e.write(conversationId,t))},[e,conversationId,t,u,n])}function $a(e){if(!(m.OS!=="ios"||e===""))try{let t=F?.announceForAccessibility;typeof t=="function"&&t.call(F,e)}catch{}}function AnnounceLine({line:e}){return o(()=>{$a(e)},[e]),null}var Va=12,qa=80,Ga=44,Ka=22,Ya=.14,Qa=18,Za=8,Ja=/* @__PURE__ */Object.freeze({photo:et.attachmentPhoto,camera:et.attachmentCamera});function AttachmentPickerPopover({sources:e,full:t,onPick:r,onClose:l}){let i=useEverfurTheme(),o=n(()=>Xa(i),[i]);/* @__PURE__ */
|
|
94
|
-
return
|
|
95
|
-
/* @__PURE__ */
|
|
96
|
-
/* @__PURE__ */
|
|
97
|
-
/* @__PURE__ */
|
|
98
|
-
/* @__PURE__ */
|
|
99
|
-
/* @__PURE__ */
|
|
100
|
-
/* @__PURE__ */
|
|
101
|
-
/* @__PURE__ */
|
|
102
|
-
/* @__PURE__ */
|
|
103
|
-
/* @__PURE__ */
|
|
104
|
-
/* @__PURE__ */
|
|
105
|
-
return
|
|
106
|
-
return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(
|
|
107
|
-
/* @__PURE__ */
|
|
108
|
-
/* @__PURE__ */
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
-
return Object.freeze({available:false,module:null,reason:e})}function
|
|
111
|
-
return
|
|
112
|
-
return
|
|
113
|
-
/* @__PURE__ */
|
|
114
|
-
/* @__PURE__ */
|
|
115
|
-
/* @__PURE__ */
|
|
116
|
-
/* @__PURE__ */
|
|
117
|
-
/* @__PURE__ */c(Le,{style:C?[_.input,z.input]:_.input,onFocus:D,onBlur:M,value:F,onChangeText:X,placeholder:W,placeholderTextColor:T.slots.composerInput?.textColor??T.color.text.placeholder,accessibilityLabel:et.composerLabel,onSubmitEditing:J,returnKeyType:"send",...ac,...C?sc:null,blurOnSubmit:false,multiline:true,editable:true}),U.supported?/* @__PURE__ */c(DictationButton,{active:U.active,listening:U.status==="listening",elapsedMs:U.elapsedMs,onToggle:U.toggle}):null,a?/* @__PURE__ */c(x,{onPress:ee,accessibilityRole:"button",accessibilityLabel:et.stop,style:_.sendControl,children:/* @__PURE__ */c(k,{style:C?z.disc:_.sendDisc,testID:"everfur-stop-disc",children:/* @__PURE__ */c(StopGlyph,{size:C?Qd:mu,color:C?ae:oe,testID:"everfur-stop-glyph"})})}):/* @__PURE__ */c(x,{onPress:J,disabled:ne,accessibilityRole:"button",accessibilityLabel:et.send,accessibilityState:{disabled:ne,busy:K},style:[_.sendControl,le?C?z.dimmed:_.sendControlDisabled:null],children:C?/* @__PURE__ */c(k,{style:z.disc,testID:"everfur-send-disc",children:/* @__PURE__ */c(ArrowUpGlyph,{size:Qd,color:ae,strokeWidth:2.25,testID:"everfur-send-arrow"})}):/* @__PURE__ */c(k,{style:_.sendDisc,testID:"everfur-send-disc",children:/* @__PURE__ */c(SendGlyph,{size:yu,color:oe,testID:"everfur-send-glyph"})})})]})]})]})}var ic=/* @__PURE__ */Object.freeze([]),oc=/* @__PURE__ */Object.freeze([]),ac=/* @__PURE__ */Object.freeze({submitBehavior:"submit"}),sc=/* @__PURE__ */Object.freeze(m.OS==="web"?{rows:1}:{}),uc=/* @__PURE__ */Object.freeze({code:"unknown",retryable:true,filename:""});function dc(e){let t=e.color,r=e.slots.sendButton,n=textRole(e,"body").fontSize+Xd;return y.create({bar:{marginTop:qd,marginHorizontal:Gd,marginBottom:Kd,minHeight:$d,paddingLeft:8,paddingRight:6,paddingVertical:0,borderWidth:Vd,borderColor:e.slots.composerInput?.borderColor??t.text.primary},barFocused:{borderWidth:Jd,paddingLeft:8-(Jd-Vd),paddingRight:6-(Jd-Vd)},input:{fontSize:n,lineHeight:Math.round(n*ec),minHeight:Math.round(n*ec),...m.OS==="web"?{outlineStyle:"none"}:null},add:{width:tc,height:tc,borderRadius:tc/2},disc:{width:Yd,height:Yd,borderRadius:Yd/2,alignItems:"center",justifyContent:"center",backgroundColor:r?.backgroundColor??t.text.primary,...aa(r)},dimmed:{opacity:Zd},tray:{marginHorizontal:Gd,marginTop:qd,paddingBottom:0}})}function cc(e){return y.create({tray:{marginHorizontal:e.space.md,marginTop:e.space.xs,paddingBottom:0}})}var pc=/* @__PURE__ */new WeakMap;function fc(e,t){let r=pc.get(e);return r===void 0&&(r=/* @__PURE__ */new Set,pc.set(e,r)),r.add(t),()=>{r?.delete(t)}}function useEverfurPets(){let{runtime:e,userRef:userRef,activePet:t,scopeEpoch:a}=ut(),s=n(()=>createPetsRepository(e.registry.services.authFor(userRef)),[e,userRef,a]),[u,d]=i({repository:s,pets:[],loading:true,error:null}),c=u.repository===s?u:{pets:[],loading:true,error:null},p=l(0),f=r(async()=>{let e=++p.current;d(e=>({...e,repository:s,loading:true,error:null,pets:e.repository===s?e.pets:[]}));let t=await s.list();e===p.current&&d(t.ok?{repository:s,pets:t.value,loading:false,error:null}:e=>({repository:s,pets:e.repository===s?e.pets:[],loading:false,error:t.error}))},[s]);o(()=>(f(),()=>{p.current+=1}),[f]),o(()=>fc(e,()=>{f()}),[e,f]);let h=n(()=>t===null?null:c.pets.find(e=>e.petRef===t)??null,[t,c.pets]);return n(()=>({pets:c.pets,activePet:h,loading:c.loading,error:c.error,refresh:f}),[c.pets,c.loading,c.error,h,f])}function hc(e,t){if(t!==null){let r=e.find(e=>e.petRef===t);if(r!==void 0)return r}return e[0]??null}var gc=/* @__PURE__ */Object.freeze({visitButton:"Vet"});var bc=false;function yc(e,t){return t!==void 0?(sn(t,e),"onStartInApp"):U(e)==="presented"?"presenter":G(e)?"experience":(bc||(bc=true,console.warn("[everfur] A vet visit had nowhere to open: mount <EverfurTelevetHost /> in your EverfurProvider, or pass prefer: 'redirect'.")),null)}var mc=/* @__PURE__ */Object.freeze(["visit","join","summary","messages"]);function isVetVisitIntent(e){return typeof e=="string"&&mc.includes(e)}var vc="/widget/v1/televet/handoffs",wc="/widget/v1/televet/availability",kc="/widget/v1/televet/chat-entry",Cc=/^[a-z0-9][a-z0-9_-]{0,39}$/,Sc=/^[A-Za-z0-9_-]{22}$/;var xc=32,Rc=128,Tc=64;function vetVisitErrorReasonOf(e){let t=e.httpStatus;switch(e.code){case"sessionRequired":return"sessionRequired";case"authExpired":case"authRejected":return"authRejected";case"sdkUpdateRequired":return"sdkUpdateRequired";case"validationFailed":return"invalidRequest";case"rateLimited":case"quotaExceeded":return"rateLimited"}return t===void 0?e.code==="internalError"?"network":"unknown":t===429?"rateLimited":t===404?"unavailable":t===403?"accessDenied":t===401?"authRejected":t===400||t===422?"invalidRequest":t>=500?"serverError":"unknown"}function _c(e){return err(makeEverfurError("validationFailed",{retryable:false,wireMessage:e}))}function zc(e){return err(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}function Ic(petRef,e){let t={};petRef!==void 0&&(t.pet_ref=petRef);let r=e?.returnTo;if(r!=null){if(typeof r!="string"||!Cc.test(r))return{ok:false,message:"returnTo must be a registered return destination key"};t.return_to=r}let n=e?.entry;if(n!=null){if(n!=="chat"||petRef===void 0)return{ok:false,message:"entry 'chat' needs the pet the chat is about"};t.entry=n}let l=e?.visitRef,i=e?.intent,o=l!=null;if(o){let e=typeof l=="string"?l.trim():"";if(e.length<1||[...e].length>Tc)return{ok:false,message:`visitRef must be 1..${Tc} characters`};t.visit_ref=e}if(i!=null){if(!o)return{ok:false,message:"intent needs the visitRef it opens"};if(!isVetVisitIntent(i))return{ok:false,message:`intent must be one of ${mc.join(", ")}`};t.intent=i}return{ok:true,body:t}}function Pc(e){if(typeof e!="object"||e===null)return null;let{visit_ref:t,intent:r}=e;return typeof t!="string"||t.length===0||!isVetVisitIntent(r)?null:/* @__PURE__ */Object.freeze({visitRef:t,intent:r})}function Fc(e){let t=e.funnel??createRequestFunnel({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e.telemetry,n=e=>(Dc(r,"televet.visit.handoff_failed",{reason:vetVisitErrorReasonOf(e)}),err(e));return{async createHandoff(petRef,e){let l;if(petRef!=null){let e=typeof petRef=="string"?[...petRef].length:0;if(e<1||e>Rc)return n(makeEverfurError("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${Rc} characters`}));l=petRef}let i=Ic(l,e);if(!i.ok){let e=_c(i.message);return e.ok?e:n(e.error)}let o=i.body,a=await t.send("televet.visit.handoff",{method:"POST",path:vc,body:o},{idempotent:false,maxAttempts:1});if(!a.ok)return n(a.error);let s=Lc(a.value),u=o.return_to!==void 0,d=u?a.value?.flow_id:void 0;if(u&&(typeof d!="string"||!Sc.test(d))){let e=zc("the handoff response carried no usable return flow id");return e.ok?e:n(e.error)}let c=o.visit_ref!==void 0,p=c?Pc(a.value?.visit):null;if(c&&p===null){let e=zc("the handoff response did not confirm the visit it opens");return e.ok?e:n(e.error)}let f=s===null?null:/* @__PURE__ */Object.freeze({...s,...u?{flowId:d}:{},...p!==null?{visit:p}:{}});return f===null?n(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(Dc(r,"televet.visit.handoff_created",{pet_scoped:o.pet_ref!==void 0}),ok(f))},async checkAvailability(e){if(typeof e!="string"||e.length>xc)return _c(`state must be at most ${xc} characters`);let r=await t.send("televet.visit.availability",{method:"POST",path:wc,body:{state:e}},{idempotent:false,maxAttempts:1});if(!r.ok)return err(r.error);let n=r.value?.available;return typeof n!="boolean"?zc("the availability response carried no usable answer"):ok(/* @__PURE__ */Object.freeze({available:n}))},async chatEntryOpen(){try{let e=await t.send("televet.visit.chat_entry",{method:"GET",path:kc},{maxAttempts:1});return e.ok&&e.value?.open===!0}catch{return false}}}}function Lc(e){if(typeof e!="object"||e===null)return null;let{url:t,expires_at:r}=e;return typeof t!="string"||typeof r!="string"||r.length===0||!jc(t)?null:/* @__PURE__ */Object.freeze({url:t,expiresAt:r})}var Ec=/* @__PURE__ */new Set(["localhost","127.0.0.1","[::1]"]),Oc=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,Ac=/[\s\u0000-\u001f\u007f]/;function jc(e){if(Ac.test(e))return false;let t=Oc.exec(e);if(t===null)return false;let r=(t[1]??"").toLowerCase(),n=t[2]??"";if(n.length===0||n.includes("@"))return false;let l=n.replace(/:\d+$/,"").toLowerCase(),i=r==="https",o=r==="http"&&Ec.has(l);if(!i&&!o)return false;let a=e.indexOf("#");if(a<0)return false;let s=e.slice(a);return s.startsWith("#h=")&&s.length>3}function Dc(e,t,r){if(e)try{e.track(t,r)}catch{}}var Mc=/* @__PURE__ */Object.freeze({status:"idle",error:null,errorReason:null});function Bc(e,t,r){let{usState:n,chat:l,scope:a}=r,s=t&&(n!==null||l),u=`${n??""}|${l?"chat":""}`,[d,c]=i(null);if(o(()=>{if(!s)return;let t=true,r=e.current;return c(null),(async()=>{try{if(l&&!(r.chatEntryOpen&&await r.chatEntryOpen()))return!1;if(n===null)return!0;if(!r.checkAvailability)return!1;let e=await r.checkAvailability(n);return e.ok&&e.value.available}catch{return false}})().then(e=>{t&&c({key:u,open:e})}),()=>{t=false}},[s,u,n,l,a,e]),!s)return null;let p=d!==null&&d.key===u;return{open:p&&d.open,pending:!p}}var Hc=/* @__PURE__ */Object.freeze({status:"opening",error:null,errorReason:null});function Wc(e,t={}){let{runtime:o,userRef:userRef,scopeEpoch:a}=ut(),s=useCapability("televet"),u=s.enabled&&userRef!==null,d=t.usState??null,c=t.entry==="chat",p=t.petRef??null,f=t.prefer==="redirect",h=n(()=>{if(t.controller)return t.controller;let{services:e}=o.registry;return Fc({auth:e.authFor(userRef),telemetry:e.telemetry,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}})},[o,userRef,a,t.controller]),g=l(h);g.current=h;let b=n(()=>({runtime:o,userRef:userRef,scopeEpoch:a}),[o,userRef,a]),y=Bc(g,u,{usState:d,chat:c,scope:b}),m=u&&(y===null||y.open)&&(!c||p!==null),v=t.returnTo??null,[w,k]=i(Mc),C=l(null),S=l({runtime:o,userRef:userRef,scopeEpoch:a});S.current={runtime:o,userRef:userRef,scopeEpoch:a};let x=l(h);x.current=h;let R=l(m);R.current=m;let T=r((petRef,t)=>{if(C.current)return C.current;let r=(e,t)=>(k({status:e==="cancelled"?"idle":"error",error:t,errorReason:e==="cancelled"?null:e}),/* @__PURE__ */Object.freeze({opened:false,reason:e,error:t}));if(!R.current)return Promise.resolve(r("unavailable",null));let n=e.prepare();if(!n.ok)return Promise.resolve(r(n.reason,null));let l=S.current,i=x.current;k(Hc);let o=(async()=>{let o,a={...v!==null?{returnTo:v}:{},...c?{entry:"chat"}:{},...t!==null?{visitRef:t.visitRef}:{},...t!==null&&t.intent!==null&&t.intent!==void 0?{intent:t.intent}:{}},s=Object.keys(a).length===0?void 0:a,u=petRef===void 0?p:petRef;try{o=await(s===void 0?i.createHandoff(u):i.createHandoff(u,s))}catch{return e.abandon(n.value),r("unknown",null)}let d=S.current;if(d.runtime!==l.runtime||d.userRef!==l.userRef||d.scopeEpoch!==l.scopeEpoch)return e.abandon(n.value),r("cancelled",null);if(!o.ok)return e.abandon(n.value),r(vetVisitErrorReasonOf(o.error),o.error);let f=await e.finish(n.value,o.value);return f!==null?r(f,null):(k(Mc),/* @__PURE__ */Object.freeze(o.value.flowId===void 0?{opened:true}:{opened:true,flowId:o.value.flowId}))})().finally(()=>{C.current===o&&(C.current=null)});return C.current=o,o},[e,p,v,c]),_=r((petRef,e)=>{if(!R.current)return k({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}));let t=petRef===void 0?p:petRef,r={...t!==null?{petRef:t}:{},...d!==null?{usState:d}:{},...e!==null&&"consultId"in e?{consultId:e.consultId}:{},...e!==null&&"visitRef"in e?{visitRef:e.visitRef,intent:e.intent}:{}};return yc(r)===null?(k({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}))):(k(Mc),Promise.resolve(/* @__PURE__ */Object.freeze({opened:true})))},[p,d]),z=r(petRef=>f?T(petRef,null):_(petRef,null),[f,T,_]),I=r((e,t)=>f?T(void 0,{visitRef:e,intent:t??null}):_(void 0,{visitRef:e,intent:t??null}),[f,T,_]),P=r(e=>f?T(void 0,null):_(void 0,{consultId:e.trim()}),[f,T,_]);return{available:m,isPending:s.isPending||(y?.pending??false),status:w.status,error:w.error,errorReason:w.errorReason,open:z,openVisit:I,joinVisit:P}}var Nc=e=>C.openURL(e);function useVetVisit(e={}){let{openUrl:t,...r}=e,l=n(()=>{let e=t??Nc;return{prepare:()=>({ok:true,value:null}),async finish(t,r){try{return await e(r.url),null}catch{return"openFailed"}},abandon:()=>{}}},[t]);return Wc(l,r)}var Uc=44,$c=.6;function VetVisitButtonCore(e){let{petRef:petRef,label:t,openUrl:r,onOpened:i,onError:o,style:a,labelStyle:s,controller:u,returnTo:d,usState:h,entry:g,visitRef:b,intent:y,onStartInApp:m,prefer:v}=e,w=v==="redirect",k=useVetVisit({...d!==void 0?{returnTo:d}:{},...h!==void 0?{usState:h}:{},...g!==void 0?{entry:g}:{},...petRef!==void 0?{petRef:petRef}:{},...r!==void 0?{openUrl:r}:{},...u!==void 0?{controller:u}:{},prefer:w?"redirect":"in-app"}),C=useEverfurTheme(),S=n(()=>Vc(C),[C]),R=l(false);if(!k.available)/* @__PURE__ */
|
|
118
|
-
return
|
|
119
|
-
/* @__PURE__ */
|
|
120
|
-
return
|
|
121
|
-
/* @__PURE__ */
|
|
122
|
-
/* @__PURE__ */
|
|
123
|
-
return
|
|
15
|
+
return Object.freeze({reason:userFacingError("accessDenied"),level:"user_entitlement",recoverable:false})}function Sn(e){let t={name:e.name,enabled:e.enabled,isPending:e.isPending,limits:/* @__PURE__ */Object.freeze({...e.limits})};return e.disabled!==void 0&&(t.disabled=e.disabled),/* @__PURE__ */Object.freeze(t)}function useCapability(e){let{runtime:t}=ct(),r=t.entitlements,n=s(r.subscribe,r.getSnapshot,r.getSnapshot);return l(()=>decideCapability(e,n.decisions,{isPending:n.isPending}),[e,n])}function xn(e){let{runtime:t}=ct(),r=t.entitlements,l=n(e=>r===void 0?()=>{}:r.subscribe(e),[r]),i=n(()=>{if(r===void 0)return false;let t=r.getSnapshot();return decideCapability(e,t.decisions,{isPending:t.isPending}).enabled},[r,e]);return s(l,i,i)}var Rn=()=>()=>{},Tn=()=>null;function _n(e,t){return s(t?.subscribe??Rn,t?.get??Tn,t?.get??Tn)??e}var zn=/* @__PURE__ */Object.freeze({branding:null}),In=/* @__PURE__ */Object.freeze({subscribe:()=>()=>{},getSnapshot:()=>zn});function Pn(e){return e?Object.keys(e).sort().map(t=>`${t}=${String(e[t])}`).join("&"):""}function Fn(e){let{runtime:t}=ct(),r=t?.entitlements??In,i=n(()=>r.getSnapshot()?.branding??null,[r]),o=_n(s(r.subscribe,i,i),t?.sdkConfigHost?.branding),a=Pn(e);return l(()=>{let t=o?.lockedFields??null;return{presentation:resolvePresentation({server:o?.presentation??null,locked:t,client:e??null}),isLocked:e=>isPresentationFieldLocked(e,t)}},[o,a])}function Ln(e){let t={};for(let[r,n]of Object.entries(e))n!==void 0&&(t[r]=n);return t}function En(e){return e.isBootstrapping?"loading":e.status==="error"&&e.error&&e.messages.length===0?"error":e.messages.length===0?"empty":"populated"}function On(e){let t=Ut(e);return t===null?null:{reached:rt.capReached.replace("{cap}",String(t.limit)),guidance:t.emergencyGuidance??null}}function An(e){return e.code==="accessDenied"||e.code==="conversationNotFound"}function jn(e,t="native"){if(e.messages.length===0)return null;let r=e.status==="error"?e.error:null;if(r!==null){let e=An(r),n=t==="web",l=On(r);return{tone:"error",title:l!==null?l.reached:e?rt.turnUnreachableTitle:n?rt.turnFailedTitleWeb:rt.turnFailedTitle,body:r.displayMessage,actionLabel:e?rt.turnStartNewChat:n?rt.retry:rt.turnRetry,action:e?"startNew":"retry",...l!==null&&l.guidance!==null?{guidance:l.guidance}:{}}}return e.stopped===true?{tone:"neutral",title:rt.turnStoppedTitle,body:rt.turnStoppedBody,actionLabel:rt.turnRetry,action:"retry"}:null}function Dn(e,t){let r=e[e.length-1];return t&&(r===void 0||r.role==="user")}var Mn=3,Bn=/* @__PURE__ */Object.freeze([]);function Hn(e){let t=e.messages[e.messages.length-1];if(e.isStreaming||e.status==="error"||t===void 0||t.role!=="assistant")return Bn;let r=/* @__PURE__ */new Set,n=[];for(let t of e.suggestedPrompts){let e=t.trim(),l=e.replace(/\s+/g," ").toLowerCase();if(!(l.length===0||r.has(l))&&(r.add(l),n.push(e),n.length===Mn))break}/* @__PURE__ */
|
|
16
|
+
return Object.freeze(n)}var Wn=5;function Nn(e,t){if(e===void 0)return false;if(typeof e=="function")try{return e(t)===!0}catch{return false}return e.lastIndex=0,e.test(t)}function Un(e,t){if(t===void 0)return Hn(e);let r=e.messages[e.messages.length-1];if(e.isStreaming||e.status==="error"||r===void 0||r.role!=="assistant")return Bn;let n=Math.max(1,Math.min(Wn,Math.floor(t.count??Mn))),l=null;for(let t=e.messages.length-1;t>=0;t-=1){let r=e.messages[t];if(r!==void 0&&r.role==="user"){l=r.text;break}}let i=e=>e.trim().replace(/\s+/g," ").toLowerCase(),o=new Set(l===null?[]:[i(l)]),a=[],s=e=>{let r=e.trim(),l=i(r);a.length>=n||l.length===0||o.has(l)||Nn(t.exclude,r)||(o.add(l),a.push(r))};for(let t of e.suggestedPrompts)s(t);let u=[];try{u=typeof t.fill=="function"?t.fill(l):t.fill??[]}catch{u=[]}for(let e of Array.isArray(u)?u:[])typeof e=="string"&&s(e);/* @__PURE__ */
|
|
17
|
+
return Object.freeze(a)}function $n(e){return e.sender?.displayName??rt.senderVet}function Vn(petRef,conversationId){let e={};return petRef!==void 0&&(e.petRef=petRef),conversationId!==void 0&&(e.conversationId=conversationId),e}var qn=new RegExp([String.raw`\b(book|booking|schedule|scheduling|arrange|set\s+up)\s+(an?\s+|the\s+|her\s+|his\s+|their\s+|my\s+|your\s+)?(next\s+)?((vet|veterinary|video|virtual|televet|follow-up|follow up)\s+)?(visit|appointment|appt|consult|consultation|call|vet|checkup|check-up|exam)\b`,String.raw`\bmake\s+(an?\s+|the\s+)?((vet|veterinary|video|virtual|follow-up|follow up)\s+)?(appointment|appt)\b`,String.raw`\bneed\s+(an?\s+)?((vet|veterinary|video|virtual)\s+)?(appointment|appt|visit|consult|consultation)\b`,String.raw`\b(video|virtual)\s+(visit|appointment|appt|consult|consultation|call)s?\b`,String.raw`\b(televet|telehealth|telemedicine)\b`,String.raw`\b(talk|speak|chat)\s+(to|with)\s+(an?|the|your|my)\s+vet\b`,String.raw`\bsee\s+(an?|the|your|my)\s+vet\b`].join("|"),"i"),NONE=()=>true;function Gn(e,t){if(e===void 0)return false;if(typeof e=="function")try{return e(t)===!0}catch{return false}return e.lastIndex=0,e.test(t)}function Kn(e,t,r){let n=t.chatFollowUpsExcludeTelevet,l=e?.count!==void 0&&!r?e.count:t.chatFollowUpCount;if(e===void 0&&l===Mn&&!n)return;if(l<=0)return{...e??{},count:1,exclude:NONE,fill:[]};let i=e?.exclude,o=n?e=>qn.test(e)||Gn(i,e):i;return{...e??{},count:l,...o!==void 0?{exclude:o}:{}}}function Yn(e){for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let r=e.charCodeAt(t+1);if(!(r>=56320&&r<=57343))return true;t+=1}else if(r>=56320&&r<=57343)return true}return false}function Qn(e){return[...e].length}var Zn=/* @__PURE__ */Object.freeze({dog:"dog",canine:"dog",k9:"dog",puppy:"dog",cat:"cat",feline:"cat",kitten:"cat"});function canonicalPetSpecies(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.prototype.hasOwnProperty.call(Zn,t)?Zn[t]:null}var Jn=50,Xn=128,el=120,tl=120,rl=2e3,nl=120,ll=80,il=/* @__PURE__ */new Set(["male","female","unknown"]),ol=/* @__PURE__ */new Set(["day","month","year"]),al=/* @__PURE__ */new Set(["low","medium","high","athletic"]),sl=/* @__PURE__ */new Set(["indoor","outdoor","both"]),ul=/* @__PURE__ */new Set(["mild","moderate","severe"]),dl=/^(\d{4})-(\d{2})-(\d{2})$/,cl=[["sex","sex"],["spayedNeutered","spayed_neutered"],["birthDate","birth_date"],["birthDatePrecision","birth_date_precision"],["activityLevel","activity_level"],["indoorOutdoor","indoor_outdoor"],["foodBrand","food_brand"],["foodType","food_type"],["microchipId","microchip_id"]],pl=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];/* @__PURE__ */Object.freeze([...cl,...pl].map(([e])=>e));function fl(e){let t=dl.exec(e);if(t===null)return false;let[r,n,l]=[Number(t[1]),Number(t[2]),Number(t[3])],i=new Date(Date.UTC(r,n-1,l));return i.getUTCFullYear()===r&&i.getUTCMonth()===n-1&&i.getUTCDate()===l}var hl=e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,gl=(e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,bl=(e,t)=>typeof t=="string"&&fl(t)?null:`${e} must be a real date written YYYY-MM-DD`,ml=(e,t={})=>(r,n)=>{if(typeof n!="string")return`${r} must be a string`;if(Yn(n))return`${r} contains an unpaired surrogate and cannot be encoded`;let l=t.trimmed?n.trim():n;if(t.required&&l.length===0)return`${r} is required and must not be blank`;let i=Qn(l);return i<=e?null:`${r} is ${i} characters; the server accepts at most ${e}`},yl={sex:hl(il),spayedNeutered:gl,birthDate:bl,birthDatePrecision:hl(ol),activityLevel:hl(al),indoorOutdoor:hl(sl),foodBrand:ml(nl),foodType:ml(nl),microchipId:ml(ll)},vl=["ref","ref",false,ml(Xn,{required:true,trimmed:true})],wl=["notes","notes",false,ml(rl,{trimmed:true})],kl=[vl,["name","name",true,ml(el,{required:true,trimmed:true})],["dose","dose",false,ml(tl,{trimmed:true})],["frequency","frequency",false,ml(tl,{trimmed:true})],["startDate","start_date",false,bl],["endDate","end_date",false,bl],wl],Cl={allergies:[vl,["allergen","allergen",true,ml(el,{required:true,trimmed:true})],["severity","severity",false,hl(ul)],wl],medications:kl,supplements:kl,conditions:[vl,["conditionName","condition_name",true,ml(el,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,bl],wl]};function Sl(e,t,r){let n=`${e}[${t}]`;if(typeof r!="object"||r===null||Array.isArray(r))return{error:`${n} must be an object`};let l=r,i={};for(let[t,r,o,a]of Cl[e]){let e=l[t];if(e==null){if(o)return{error:`${n}.${t} is required`};e===null&&(i[r]=null);continue}let s=a(`${n}.${t}`,e);if(s!==null)return{error:s};i[r]=e}let o=i.start_date,a=i.end_date;return typeof o=="string"&&typeof a=="string"&&a<o?{error:`${n}.endDate must not be before startDate`}:{item:i}}function xl(e,t){if(!Array.isArray(t))return{error:`${e} must be an array (send [] to clear it)`};if(t.length>Jn)return{error:`${e} has ${t.length} items; the server accepts at most ${Jn}`};let r=[],n=/* @__PURE__ */new Set;for(let l=0;l<t.length;l+=1){let i=Sl(e,l,t[l]);if("error"in i)return i;let o=i.item.ref;if(typeof o=="string"){let t=o.trim();if(n.has(t))return{error:`${e}: ref ${JSON.stringify(t)} is used twice; a ref names one item`};n.add(t)}r.push(i.item)}return{items:r}}function Rl(e,t){let r=e,n={};for(let[e,t]of cl){let l=r[e];if(l!==void 0){if(l!==null){let t=yl[e](e,l);if(t!==null)return{error:t}}n[t]=l}}let l=r.birthDate!==void 0,i=r.birthDatePrecision!==void 0;if(l!==i||l&&r.birthDate===null!=(r.birthDatePrecision===null))return{error:"birthDate and birthDatePrecision must be sent together, both set or both null"};for(let[e,t]of pl){let l=r[e];if(l===void 0)continue;let i=xl(e,l);if("error"in i)return i;n[t]=i.items}return Object.keys(n).length>0&&t!==void 0&&canonicalPetSpecies(t)===null?{error:"health fields need a pet Everfur reads as a dog or a cat (dog, canine, k9, puppy, cat, feline, kitten)"}:{body:n}}var Tl=e=>typeof e=="string"?e:null,_l=(e,t)=>typeof t=="string"&&e.has(t)?t:null,zl=e=>typeof e=="boolean"?e:null;function Il(e,t){return Array.isArray(e)?/* @__PURE__ */Object.freeze(e.flatMap(e=>{if(typeof e!="object"||e===null||Array.isArray(e))return[];let r=t(e);return r===null?[]:[r]})):/* @__PURE__ */Object.freeze([])}function Pl(e){let t=Tl(e.name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Tl(e.ref),name:t,dose:Tl(e.dose),frequency:Tl(e.frequency),startDate:Tl(e.start_date),endDate:Tl(e.end_date),notes:Tl(e.notes)})}function Fl(e){let t=e.profile_version;/* @__PURE__ */
|
|
18
|
+
return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:_l(il,e.sex),spayedNeutered:zl(e.spayed_neutered),birthDate:Tl(e.birth_date),birthDatePrecision:_l(ol,e.birth_date_precision),activityLevel:_l(al,e.activity_level),indoorOutdoor:_l(sl,e.indoor_outdoor),foodBrand:Tl(e.food_brand),foodType:Tl(e.food_type),microchipId:Tl(e.microchip_id),allergies:Il(e.allergies,e=>{let t=Tl(e.allergen);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Tl(e.ref),allergen:t,severity:_l(ul,e.severity),notes:Tl(e.notes)})}),medications:Il(e.medications,Pl),supplements:Il(e.supplements,Pl),conditions:Il(e.conditions,e=>{let t=Tl(e.condition_name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Tl(e.ref),conditionName:t,diagnosedDate:Tl(e.diagnosed_date),notes:Tl(e.notes)})})})}var Ll=100,El=50,Ol=100,Al=50,jl=500,Dl=128,Ml=6e4;function Bl(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function Hl(e,t,r){if(typeof t!="string")return Bl(`${e} must be a string`);let n=Qn(t);return n<=r?null:Bl(`${e} is ${n} characters; the server accepts at most ${r}`)}function Wl(e,t,r){return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=r?null:Bl(`${e} must be a finite number between 0 and ${r}`)}function Nl(petRef,e){if(typeof petRef!="string")return Bl("pet_ref must be a string");if(petRef.trim().length===0)return Bl("pet_ref must not be blank");if(Yn(petRef))return Bl("pet_ref contains an unpaired surrogate and cannot be encoded");if(e!=null&&typeof e!="object")return Bl("profile must be an object");let t=[Hl("pet_ref",petRef,Dl)];return e?.name!==void 0&&t.push(Hl("name",e.name,Ll)),e?.species!==void 0&&t.push(Hl("species",e.species,El)),e?.breed!==void 0&&t.push(Hl("breed",e.breed,Ol)),e?.ageYears!==void 0&&t.push(Wl("age_years",e.ageYears,Al)),e?.weightKg!==void 0&&t.push(Wl("weight_kg",e.weightKg,jl)),t.find(e=>e!==null)??null}function Ul(e,t){let r=Rl(e,t);return"error"in r?{error:Bl(r.error)}:r}function $l(e){if(typeof e!="object"||e===null)return{error:Bl("patch must be an object")};let t=e,r=[["name","name",e=>Hl("name",e,Ll)],["species","species",e=>Hl("species",e,El)],["breed","breed",e=>Hl("breed",e,Ol)],["ageYears","age_years",e=>Wl("age_years",e,Al)],["weightKg","weight_kg",e=>Wl("weight_kg",e,jl)]],n={};for(let[e,l,i]of r){let r=t[e];if(r!==void 0){if(r!==null){let e=i(r);if(e!==null)return{error:e}}n[l]=r}}let l=Ul(t,t.species);return"error"in l?l:(Object.assign(n,l.body),Object.keys(n).length===0?{error:Bl("patch must change at least one field")}:{body:n})}function Vl(e){if(e==null)return{body:{}};let t=Ul(e,e.species);return"error"in t?t:{body:{...e.name!==void 0?{name:e.name}:{},...e.species!==void 0?{species:e.species}:{},...e.breed!==void 0?{breed:e.breed}:{},...e.ageYears!==void 0?{age_years:e.ageYears}:{},...e.weightKg!==void 0?{weight_kg:e.weightKg}:{},...t.body}}}var ql=e=>typeof e=="string"?e:null,Gl=e=>typeof e=="number"&&Number.isFinite(e)?e:null;function Kl(e,petRef){let t=typeof e=="object"&&e!==null?e:{};/* @__PURE__ */
|
|
19
|
+
return Object.freeze({petRef:ql(t.pet_ref)??petRef,name:ql(t.name),species:ql(t.species),breed:ql(t.breed),ageYears:Gl(t.age_years),weightKg:Gl(t.weight_kg)})}function widgetPetFromWire(e){if(typeof e!="object"||e===null)return null;let t=e,petRef=ql(t.pet_ref);return petRef===null||petRef.length===0?null:/* @__PURE__ */Object.freeze({petId:ql(t.pet_id),petRef:petRef,name:ql(t.name),species:ql(t.species),breed:ql(t.breed),ageYears:Gl(t.age_years),weightKg:Gl(t.weight_kg),updatedAt:ql(t.updated_at)})}function Yl(e){let t=widgetPetFromWire(e);return t===null?null:/* @__PURE__ */Object.freeze({...t,...Fl(e)})}function Ql(e){let t=Array.isArray(e)?e:typeof e=="object"&&e!==null&&Array.isArray(e.pets)?e.pets:[];/* @__PURE__ */
|
|
20
|
+
return Object.freeze(t.flatMap(e=>{let t=widgetPetFromWire(e);return t===null?[]:[t]}))}function createPetsRepository(e){return Zl(createRequestFunnel({auth:e}),createRequestFunnel({auth:e,unaryTimeoutMs:Ml}))}function Zl(e,t=e){let r=(e,t)=>t?{...e,signal:t}:e,n=petRef=>Nl(petRef,void 0)??`/widget/v1/pets/${encodeURIComponent(petRef)}`;return{async list(t){let n=await e.send("pets.list",r({method:"GET",path:"/widget/v1/pets"},t?.signal));return n.ok?ok(Ql(n.value)):err(n.error)},async registerPet(petRef,t,r){let n=Nl(petRef,t);if(n!==null)return err(n);let l=Vl(t);if("error"in l)return err(l.error);let i={method:"POST",path:`/widget/v1/pets/${encodeURIComponent(petRef)}`,body:l.body},o=await e.send("pets.registerPet",r?.signal?{...i,signal:r.signal}:i);return o.ok?ok(Kl(o.value,petRef)):err(o.error)},async updatePet(petRef,t,l){let i=n(petRef);if(typeof i!="string")return err(i);let o=$l(t);if("error"in o)return err(o.error);let a=await e.send("pets.updatePet",r({method:"PATCH",path:i,body:o.body},l?.signal));return a.ok?ok(Kl(a.value,petRef)):err(a.error)},async getPetProfile(petRef,t){let l=n(petRef);if(typeof l!="string")return err(l);let i=await e.send("pets.getPetProfile",r({method:"GET",path:`${l}/profile`},t?.signal));if(!i.ok)return err(i.error);let o=Yl(i.value);return o===null?err(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:"the pet profile response carried no pet_ref"})):ok(o)},async deletePet(petRef,t){let l=n(petRef);if(typeof l!="string")return err(l);let i=await e.send("pets.deletePet",r({method:"DELETE",path:l},t?.signal));return i.ok?ok(void 0):err(i.error)},async eraseUserData(e){let n=await t.send("pets.eraseUserData",r({method:"DELETE",path:"/widget/v1/me"},e?.signal),{maxAttempts:1});return n.ok?ok(void 0):err(n.error)}}}var Jl=/* @__PURE__ */new WeakMap,Xl=/* @__PURE__ */new Map;function ei(e,t,petRef,r){let n=Jl.get(e);if(n===void 0)return null;let l;if(t.mode==="personalized"&&typeof t.userRef=="string")l=`u:${t.userRef}`;else if(t.mode==="anonymous"&&typeof t.sessionId=="string")l=`a:${t.sessionId}|${t.userRef??""}`;else return null;return`${n}|${l}|${petRef}|${ri(r)}`}function ti(e,t){if(e===null)return t();let r=Xl.get(e);if(r!==void 0)return r;let n=t().finally(()=>{Xl.get(e)===n&&Xl.delete(e)});return Xl.set(e,n),n}function ri(e){return e===null||typeof e!="object"?JSON.stringify(e)??"undefined":Array.isArray(e)?`[${e.map(ri).join(",")}]`:`{${Object.entries(e).filter(([,e])=>e!==void 0).sort(([e],[t])=>e<t?-1:e>t?1:0).map(([e,t])=>`${JSON.stringify(e)}:${ri(t)}`).join(",")}}`}var ni="pet_not_registered";function li(e){return e!=null&&e.reasonCode===ni}var ii=/* @__PURE__ */Object.freeze({status:"idle",error:null,registered:null,retry:()=>{}});function oi(petRef,e,t){let{runtime:r,userRef:userRef,scopeEpoch:s}=ct(),u=n((e,t)=>{let n=r.registry.services.authFor(userRef);return ti(ei(r,n,e,t),()=>createPetsRepository(n).registerPet(e,t))},[r,userRef,s]),d=l(()=>e===void 0?null:ri(e),[e]),[c,p]=o({key:null,status:"idle",error:null,registered:null}),f=i(0),h=i(t);h.current=t;let g=petRef===null||d===null?null:`${String(userRef)}|${s}|${petRef}|${d}`,b=n(()=>{if(petRef===null||e===void 0||g===null)return;let t=++f.current;p({key:g,status:"registering",error:null,registered:null}),u(petRef,e).then(e=>{t===f.current&&(e.ok?(p({key:g,status:"registered",error:null,registered:e.value}),h.current?.()):p({key:g,status:"failed",error:e.error,registered:null}))})},[u,petRef,g]);a(()=>{if(g===null){f.current+=1;return}return b(),()=>{f.current+=1}},[g,b]);let m=n(()=>{c.status==="failed"&&b()},[c.status,b]);return l(()=>g===null?ii:c.key!==g?{status:"registering",error:null,registered:null,retry:m}:{status:c.status,error:c.error,registered:c.registered,retry:m},[g,c,m])}var ai=/* @__PURE__ */Object.freeze({});function si(e){let[t,r]=o(ai),s=i(null),u=i([]);u.current=e.map(e=>e.id),a(()=>{if(e.length===0){s.current=null,r(e=>e===ai?e:ai);return}let t=s.current;if(t===null)return;let n=e.find(e=>e.role==="user"&&!t.known.has(e.id));n!==void 0&&(s.current=null,r(e=>({...e,[n.id]:t.images})))},[e]);let d=n(e=>{s.current=e.length===0?null:{images:e,known:new Set(u.current)}},[]);return l(()=>({byMessage:t,stage:d}),[t,d])}var ui=/* @__PURE__ */new WeakSet;function di(){let e=makeEverfurError("internalError",{retryable:true});return ui.add(e),err(e)}function ci(e){if(typeof e!="object"||e===null||e.ok!==false)return false;let t=e.error;return typeof t=="object"&&t!==null&&ui.has(t)}var pi=500;function fi(e){if(!e)return null;let t=e.replace(/[\u0000-\u001F\u007F-\u009F\u200E\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g," ").replace(/\s+/g," ").trim();return t?t.slice(0,pi):null}function hi(e,t,r,n){let l=fi(r),o=l===null?null:n!==void 0?`key:${String(n)}`:`prompt:${l}`,s=i(e);s.current=e;let u=i(null),d=i(null),c=i(o);c.current=o,a(()=>{if(l===null||o===null||t||u.current===o||d.current===o)return;let e=s.current;if(e===void 0)return;d.current=o;let r=e=>{d.current===o&&(d.current=null),!ci(e)&&c.current===o&&(u.current=o)};Promise.resolve(e(l)).then(r,()=>r(void 0))},[l,o,t,e])}var gi=/* @__PURE__ */Object.freeze({openUnreadHead:true,reportLoadFailures:true}),bi=/* @__PURE__ */Object.freeze({reportLoadFailures:true}),mi=/* @__PURE__ */Object.freeze({...gi,markRead:true}),yi=/* @__PURE__ */Object.freeze({...bi,markRead:true});function vi(e,t){return e?t?mi:gi:t?yi:bi}function wi(e,t){let r=e?.isVisible===void 0?t:e.isVisible.bind(e);return r===void 0?true:dn(()=>r()!==!1)===true}function ki(e,t){let r=i({target:e,isVisible:t});r.current={target:e,isVisible:t};let n=i(e.isStreaming);a(()=>{let t=n.current;if(n.current=e.isStreaming,!t||e.isStreaming)return;let{target:l,isVisible:i}=r.current;l.status!=="complete"||l.conversationId===null||l.unreadCount===null||!i()||l.markRead()},[e.isStreaming])}function Ci(e,conversationId,t){if(e==="announced")return false;let r=t.lastRefresh;return r===null||r.conversationId!==conversationId?false:t.now-r.at<15e3}function Si(e,t){let conversationId=t.activeConversationId===null||t.activeConversationId.length===0?null:t.activeConversationId;return conversationId===null&&t.refreshesBlankThread!==true?{action:"skip",reason:"no_thread"}:t.isTurnInFlight?{action:"defer",reason:"turn_in_flight"}:t.isOffline?{action:"defer",reason:"offline"}:Ci(e,conversationId,t)?{action:"skip",reason:"coalesced"}:{action:"refresh",conversationId:conversationId}}var xi=3e5;function Ri(e){if(e===null||typeof e!="object"||e.ok!==false)return false;let t=e.error;if(t===null||typeof t!="object")return false;if(t.category==="rateLimit"||t.category==="server")return true;let r=t.httpStatus;return typeof r=="number"&&(r===429||r>=500)}function Ti(e,t,r){let n=i(t);n.current=t;let l=i(null),o=i(null),s=i(false),u=i(0),d=i(0),c=i(3e4),p=()=>e?.isOffline===void 0?false:dn(()=>e.isOffline?.()===!0)===true,f=p(),h=i(()=>{});h.current=e=>{let{conversationId:conversationId,isTurnInFlight:t,refresh:r,refreshesBlankThread:i}=n.current,a=Si(e,{activeConversationId:conversationId,isTurnInFlight:t,refreshesBlankThread:i===true,isOffline:p(),lastRefresh:l.current,now:Date.now()});if(a.action==="skip")return;if(a.action==="defer"){o.current!=="announced"&&(o.current=e);return}if(s.current){if(e==="poll")return;o.current!=="announced"&&(o.current=e);return}if(o.current=null,l.current={conversationId:a.conversationId,at:Date.now()},r===void 0)return;s.current=true;let f=e=>{s.current=false,Ri(e)?(u.current=Math.min(u.current===0?c.current*2:u.current*2,xi),d.current=Date.now()+u.current):(u.current=0,d.current=0);let t=o.current;t!==null&&h.current(t)};Promise.resolve(r()).then(f,()=>f({ok:false,error:{category:"server"}}))},a(()=>{if(t.isTurnInFlight||f)return;let e=o.current;e!==null&&h.current(e)},[t.isTurnInFlight,f]),a(()=>{if(e===void 0)return;let t=[],r=(e,r)=>{if(e===void 0)return;let n=dn(()=>e(()=>{h.current(r)}));typeof n=="function"&&t.push(n)};return r(e.onForeground?.bind(e),"foreground"),r(e.onOnline?.bind(e),"foreground"),r(e.onAnnounced?.bind(e),"announced"),()=>{for(let e of t)dn(e)}},[e]);let g=r?.intervalMs??null,b=r?.isVisibleFallback;a(()=>{if(e===void 0||g===null||!Number.isFinite(g)||g<=0)return;c.current=g;let t=setInterval(()=>{Date.now()<d.current||wi(e,b)&&h.current("poll")},g);return()=>clearInterval(t)},[e,g,b])}var _i=/^efch_[A-Za-z0-9_-]{43}$/,zi="efch";function Ii(e){return typeof e=="string"&&_i.test(e)}function chatHandoffTokenFromUrl(e){if(typeof e!="string")return null;let t=e.indexOf("#");if(t<0)return null;for(let r of e.slice(t+1).split("&")){if(!r.startsWith(`${zi}=`))continue;let e=r.slice(zi.length+1);return Ii(e)?e:null}return null}var Pi=/* @__PURE__ */Object.freeze(["better","same","worse"]),Fi=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var Li="checkin",Ei=/^\d{4}-\d{2}-\d{2}$/,Oi="watching";function isCheckinSettled(e){return e.status!=null&&e.status!==Oi}function Ai(e){if(typeof e!="string")return null;let t=e.split(":");if(t.length!==3)return null;let[r,n,l]=t;return r!==Li||n===void 0||l===void 0||!Fi.test(n)||!Ei.test(l)?null:{caseId:n,dueDay:l}}function ji(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}function Di(e,t,r){return makeEverfurError(e,{retryable:t,...{}})}var Mi=128,Bi=/[\u0000-\u001f\u007f]/;function Hi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function Wi(e){return typeof e!="string"||e.length===0||e.length>Mi||Bi.test(e)||e.includes("://")?null:e}function Ni(e){if(e===null)return null;let conversationId=e.conversation_id,petRef=Wi(e.pet_ref);return typeof conversationId!="string"||!ji(conversationId)||petRef===null?null:{conversationId:conversationId,petRef:petRef}}function Ui(e,t,r){return Ii(t)?createRequestFunnel({auth:e,...r?{errorPolicy:r}:{}}).send("chat.redeemHandoff",{method:"POST",path:"/widget/v1/chat/handoffs/redeem",body:{token:t}},{maxAttempts:1}).then(e=>e.ok?ok(Ni(Hi(e.value))):e.error.httpStatus===404?ok(null):err(e.error),()=>err(Di("internalError",false))):Promise.resolve(ok(null))}function $i(e,t){let r=t?.runtime??null,userRef=t?.userRef??null,n=Ii(e)?e:null,l=n===null||userRef===null?null:`${String(userRef)}|${n}`,[i,s]=o(null);return a(()=>{if(l===null||n===null||userRef===null||r===null)return;let e=true,t=r.registry.services;return Ui(t.authFor(userRef),n,t.errorPolicy).then(t=>{!e||!t.ok||t.value===null||s({key:l,target:/* @__PURE__ */Object.freeze({kind:"chat",conversationId:t.value.conversationId,petRef:t.value.petRef})})}),()=>{e=false}},[l,r,n,userRef]),i!==null&&i.key===l?i.target:void 0}function Vi(e){if(e===void 0)return null;let conversationId=e.conversationId??"",petRef=e.petRef??"";return conversationId===""&&petRef===""?null:`${String(conversationId)}|${String(petRef)}`}function qi(e,t,r){let n=Vi(t),l=t?.kind==="chat",o=t?.petRef??null,s=l&&!r.pinned&&o!==null&&r.petRef!==null&&o!==r.petRef,u=i({openCheckin:e,target:t,selectPet:r.selectPet});u.current={openCheckin:e,target:t,selectPet:r.selectPet};let d=i(null),c=i(null),petRef=r.petRef;a(()=>{if(n===null||d.current===n)return;let{openCheckin:e,target:t,selectPet:i}=u.current;if(s&&o!==null){if(c.current?.key!==n){c.current={key:n,from:petRef},i(o);return}petRef!==c.current.from&&(d.current=n);return}l&&!r.ready||(d.current=n,!(e===void 0||t===void 0)&&Promise.resolve(e(t)).catch(()=>{}))},[n,l,s,o,petRef,r.ready])}var Gi=/* @__PURE__ */Object.freeze({heading:"Chats",empty:"No chats yet",emptyBody:"Start a new conversation to see it here.",noMatch:"No chats match that.",loading:"Loading your chats…",loadFailed:"Couldn’t load your chats",loadingMore:"Loading more…",untitled:"New conversation",newChat:"New chat",searchPlaceholder:"Search chats…",search:"Search chats",countLabel:"Chats and vet messages",countSeparator:" · ",newReply:"New reply · {date}",retry:"Try again",close:"Close",closeA11y:"Close history",more:"Load more",earlier:"Load earlier messages",loadingEarlier:"Loading earlier messages…",openConversation:"Open conversation",unreadPrefix:"Unread. "});function Ki(e){let t=e?.replace(/\s+/g," ").trim();return t||Gi.untitled}function Yi(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString([],{month:"short",day:"numeric"})}function Qi(e){let t=Yi(e.updatedAt);return t===null?null:e.unreadCount!==null&&e.unreadCount>0?Gi.newReply.replace("{date}",t):t}function Zi(e,t){return t?`${Gi.countLabel}${Gi.countSeparator}${e}`:Gi.countLabel}function Ji(e){return`${e.unreadCount!==null&&e.unreadCount>0?Gi.unreadPrefix:""}${Gi.openConversation} ${Ki(e.title)}`}function Xi(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').toLowerCase().trim().replace(/\s+/g," ")}function eo(e,t){let r=Xi(t);if(r.length===0)return e;let n=[[],[],[]];for(let t of e){let e=Xi(Ki(t.title)),l=e.indexOf(r);if(l<0)continue;let i=l===0?0:e.charAt(l-1)===" "?1:2;n[i]?.push(t)}return n.flat()}function to(e){return{scope:e,rows:[],cursor:null,loading:false,loadingMore:false,error:null}}function ro(e){let[t,r]=o(false),[s,u]=o(""),d=e.listConversations,c=i(0),[p,f]=o(()=>to(d)),h=p.scope===d?p:to(d);a(()=>(c.current+=1,r(false),u(""),f(to(d)),()=>{c.current+=1}),[d]);let g=n(async t=>{let r=++c.current,n=t!==void 0;f(e=>({...e,scope:d,loading:!n,loadingMore:n,error:null}));let l=await e.listConversations(t?{cursor:t}:void 0);if(r===c.current){if(!l.ok){f(e=>({...e,loading:false,loadingMore:false,error:l.error.displayMessage}));return}f(e=>{let r=t&&e.scope===d?e.rows:[],n=new Set(r.map(e=>e.id));return{scope:d,loading:false,loadingMore:false,error:null,rows:[...r,...l.value.conversations.filter(e=>!n.has(e.id))],cursor:l.value.nextCursor===t?null:l.value.nextCursor}})}},[e.listConversations,d]),b=()=>{r(true),u(""),g()},m=()=>{c.current+=1,r(false)},y=async t=>{let n=++c.current;f(e=>({...e,loading:true,error:null}));let l=await e.resumeConversation(t);n===c.current&&(f(e=>({...e,loading:false,error:l.ok?null:l.error.displayMessage})),l.ok&&r(false))},v=async()=>{let t=c.current,r=await e.loadOlderMessages();t===c.current&&!r.ok&&f(e=>({...e,error:r.error.displayMessage}))},w=()=>{e.newConversation(),c.current+=1,r(false)},k=()=>{h.cursor===null||h.loading||h.loadingMore||s.trim().length>0||g(h.cursor)},C=l(()=>eo(h.rows,s),[h.rows,s]),S=s.trim().length>0;return{...h,open:t,show:b,close:m,load:g,resume:y,earlier:v,newConversation:w,loadMore:k,query:s,setQuery:u,searching:S,filtered:C,emptyKind:h.rows.length===0?"empty":"noMatch"}}var no="#111111",lo="#FFFFFF",io=/* @__PURE__ */Object.freeze({emergency:/* @__PURE__ */Object.freeze({level:"emergency",label:"Call a vet now",borderColor:"#FCA5A5",backgroundColor:"#FEF2F2",textColor:"#991B1B",reasonColor:no,pillColor:lo,showsVetAction:true}),schedule_soon:/* @__PURE__ */Object.freeze({level:"schedule_soon",label:"Vet care suggested soon",borderColor:"#FCD34D",backgroundColor:"#FFFBEB",textColor:"#92400E",reasonColor:no,pillColor:lo,showsVetAction:true}),home_care:/* @__PURE__ */Object.freeze({level:"home_care",label:"Monitor at home",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:no,pillColor:lo,showsVetAction:false}),general:/* @__PURE__ */Object.freeze({level:"general",label:"Good to know",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:no,pillColor:lo,showsVetAction:false})});function oo(e){return`${e.messageId}:${e.level}:${e.reason??""}`}function ao(e){return nt(rt.urgencyGeneralReason,{petName:e?.trim()||rt.emptyTitlePetFallback})}function so(e,t){for(let r=e.length-1;r>=0;r-=1){let n=e[r];if(n?.role!=="assistant"||n.responseId===void 0)continue;let l=n.urgencyLevel;return l?{messageId:n.id,level:l,reason:uo(n.urgencyReason)}:n.urgencyProvided===true?{messageId:n.id,level:"general",reason:ao(t)}:null}return null}function uo(e){return typeof e=="string"&&e.trim().length>0?e:null}function co(e){let t=e===null?null:oo(e),[r,i]=o(null),[s,u]=o(false);a(()=>u(false),[t]);let d=e!==null&&(s||!(r!==null&&r===t)),c=e===null?null:io[e.level],p=e!==null&&!d&&e.level!=="general",f=n(()=>{t!==null&&i(t),u(false)},[t]),h=n(()=>u(true),[]);return l(()=>({source:e,tier:c,signature:t,showBanner:d,showCompactIcon:p,showVetAction:d&&c!==null&&c.showsVetAction,dismissLabel:c===null?null:nt(rt.dismissBanner,{label:c.label}),dismiss:f,expand:h}),[e,c,t,d,p,f,h])}var po=()=>globalThis[/* @__PURE__ */Symbol.for("everfur.sdk.chatCards.v1")]??={loader:null,lazy:null};var fo=po;function registerEverfurChatCards(e){let t=fo();t.loader=e;let n=e&&Promise.resolve().then(e).then(e=>typeof e.ServerCards=="function"?e.ServerCards:NONE3,()=>NONE3);t.lazy=n&&r(async()=>({default:await n}))}var NONE3=()=>null,ho=createContext(null);function ServerCardsSlot({message:e}){let r=u(ho),n=fo(),l=e.a2ui??n.frames?.get(e.responseId),i=n.lazy;return l===void 0||r===null||i===null?null:t(p,{fallback:null},t(i,{message:e,a2ui:l,host:r}))}var go=class extends d{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey}}static getDerivedStateFromError(){return{failed:true}}static getDerivedStateFromProps(e,t){return Object.is(e.resetKey,t.key)?null:{failed:false,key:e.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};function RenderHost({render:e}){return e()}function HostRender({render:e,fallback:r,resetKey:n}){return t(go,{fallback:r,resetKey:n,children:t(RenderHost,{render:e})})}var bo=48;function mo(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}function CapabilityGate(e){let{capability:t,children:r,renderDisabled:n,renderPending:i,style:o}=e,a=useCapability(t),s=l(()=>mo(a),[a]);switch(s){case"enabled":return r;case"pending":return i?/* @__PURE__ */f(HostRender,{render:i,fallback:/* @__PURE__ */f(PendingSkeleton,{capability:t,style:o})}):/* @__PURE__ */f(PendingSkeleton,{capability:t,style:o});case"disabled":return n?/* @__PURE__ */f(HostRender,{render:()=>n(a),fallback:/* @__PURE__ */f(OffState,{decision:a,style:o}),resetKey:a}):/* @__PURE__ */f(OffState,{decision:a,style:o});default:return assertNever(s)}}function PendingSkeleton({capability:e,style:t}){let r=useEverfurTheme(),n=l(()=>yo(r),[r]);/* @__PURE__ */
|
|
21
|
+
return f(S,{style:[n.offstate,t],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${e}`,children:/* @__PURE__ */f(S,{style:n.skeletonBar})})}function OffState({decision:e,style:t}){let r=useEverfurTheme(),n=l(()=>yo(r),[r]),i=e.disabled?.reason??"";/* @__PURE__ */
|
|
22
|
+
return f(S,{style:[n.offstate,t],accessible:true,accessibilityRole:"text",accessibilityLabel:i,children:i.length>0?/* @__PURE__ */f(Text,{style:n.offstateText,children:i}):null})}function yo(e){let{color:t,space:r,radius:n,type:l}=e;return v.create({offstate:{minHeight:bo,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:n.md,borderWidth:v.hairlineWidth,borderColor:t.brandBorder},offstateText:{...face(e,"regular"),fontSize:l.size.body,lineHeight:Math.round(l.size.body*l.lineHeight.normal),color:t.text.muted},skeletonBar:{height:r.md,borderRadius:n.xs,backgroundColor:t.brandSofter}})}var vo="everfur.com",wo=2048,ko=/^(\*\.)?(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;function Co(e){if(!Array.isArray(e))return[];let t=/* @__PURE__ */new Set;for(let r of e){if(typeof r!="string")continue;let e=r.trim().toLowerCase();e.length<=253&&ko.test(e)&&t.add(e)}/* @__PURE__ */
|
|
23
|
+
return Object.freeze([...t])}function So(e,t){if(e===vo||e.endsWith(`.${vo}`))return true;for(let r of t)if(r.startsWith("*.")?e.endsWith(r.slice(1)):e===r)return true;return false}function xo(e,t){if(typeof e!="string"||e.length===0||e.length>wo||!/^https:\/\//i.test(e))return null;let r=$t(e);return r===null||r.protocol!=="https:"||r.username!==""||r.password!==""||r.port!==""?null:So(r.hostname,t)?r.href:null}function Ro(e){try{Promise.resolve(x.openURL(e)).catch(()=>{})}catch{}}var To=createContext(null);function _o(){return u(To)??void 0}function MessageLinksScope({linkHosts:e,onOpenUrl:r,children:n}){let i=e===false?null:Array.isArray(e)?e.join(`\n`):"",o=l(()=>{if(i===null)return null;let e=Co(i===""?[]:i.split(`\n`));/* @__PURE__ */
|
|
24
|
+
return Object.freeze({hosts:e,open:r!==void 0?e=>{dn(r,e,"message")}:Ro})},[i,r]);return t(To.Provider,{value:o},n)}var zo={pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"};function Io(e){return{width:e,height:e,alignItems:"center",justifyContent:"center"}}function Po(e,t){return t??Math.max(1.5,Math.round(e/11*10)/10)}function MenuGlyph({size:e,color:t,strokeWidth:r}){let n=Po(e,r),l={width:e*.82,height:n,borderRadius:n,backgroundColor:t};/* @__PURE__ */
|
|
25
|
+
return h(S,{style:[Io(e),{gap:e*.22}],...zo,children:[
|
|
26
|
+
/* @__PURE__ */f(S,{style:l}),
|
|
27
|
+
/* @__PURE__ */f(S,{style:l}),
|
|
28
|
+
/* @__PURE__ */f(S,{style:l})]})}function Cross({size:e,color:t,strokeWidth:r,rotate:n}){let l=Po(e,r),i=e*.78;/* @__PURE__ */
|
|
29
|
+
return h(S,{style:[Io(e),{transform:[{rotate:n}]}],...zo,children:[
|
|
30
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",width:i,height:l,borderRadius:l,backgroundColor:t}}),
|
|
31
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",width:l,height:i,borderRadius:l,backgroundColor:t}})]})}function PlusGlyph(e){/* @__PURE__ */
|
|
32
|
+
return f(Cross,{...e,rotate:"0deg"})}function CloseGlyph(e){/* @__PURE__ */
|
|
33
|
+
return f(Cross,{...e,rotate:"45deg"})}function CheckGlyph({size:e,color:t,strokeWidth:r}){let n=Po(e,r);/* @__PURE__ */
|
|
34
|
+
return f(S,{style:Io(e),...zo,children:/* @__PURE__ */f(S,{style:{width:e*.36,height:e*.66,marginTop:-e*.14,borderBottomWidth:n,borderRightWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})})}var Fo={down:{rotate:"45deg",marginTop:-.4,marginLeft:0},up:{rotate:"225deg",marginTop:.4,marginLeft:0},right:{rotate:"-45deg",marginTop:0,marginLeft:-.4}};function ChevronGlyph({size:e,color:t,strokeWidth:r,direction:n}){let l=Po(e,r),i=e*.46,o=Fo[n];/* @__PURE__ */
|
|
35
|
+
return f(S,{style:Io(e),...zo,children:/* @__PURE__ */f(S,{style:{width:i,height:i,borderRightWidth:l,borderBottomWidth:l,borderColor:t,marginTop:i*o.marginTop,marginLeft:i*o.marginLeft,transform:[{rotate:o.rotate}]}})})}function BookGlyph({size:e,color:t,strokeWidth:r}){let n=Po(e,r),l={width:e*.42,height:e*.7,borderWidth:n,borderColor:t,borderRadius:n};/* @__PURE__ */
|
|
36
|
+
return h(S,{style:[Io(e),{flexDirection:"row",gap:1}],...zo,children:[
|
|
37
|
+
/* @__PURE__ */f(S,{style:[l,{borderTopLeftRadius:e*.2}]}),
|
|
38
|
+
/* @__PURE__ */f(S,{style:[l,{borderTopRightRadius:e*.2}]})]})}function ArrowUpRightGlyph({size:e,color:t,strokeWidth:r}){let n=Po(e,r),l=e*.5;/* @__PURE__ */
|
|
39
|
+
return h(S,{style:Io(e),...zo,children:[
|
|
40
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",width:e*.78,height:n,borderRadius:n,backgroundColor:t,transform:[{rotate:"-45deg"}]}}),
|
|
41
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",top:e*.16,right:e*.16,width:l,height:l,borderTopWidth:n,borderRightWidth:n,borderColor:t}})]})}function CopyGlyph({size:e,color:t,strokeWidth:r}){let n=Po(e,r),l=e*.6,i={position:"absolute",width:l,height:l,borderWidth:n,borderColor:t,borderRadius:e*.14};/* @__PURE__ */
|
|
42
|
+
return h(S,{style:Io(e),...zo,children:[
|
|
43
|
+
/* @__PURE__ */f(S,{style:[i,{top:0,left:0}]}),
|
|
44
|
+
/* @__PURE__ */f(S,{style:[i,{bottom:0,right:0}]})]})}function ThumbGlyph({size:e,color:t,strokeWidth:r,active:n,rotate:l}){let i=Po(e,r),o=n?t:"transparent";/* @__PURE__ */
|
|
45
|
+
return h(S,{style:[Io(e),{transform:[{rotate:l}]}],...zo,children:[
|
|
46
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",bottom:e*.08,left:e*.12,width:e*.62,height:e*.5,borderWidth:i,borderColor:t,backgroundColor:o,borderRadius:e*.12,borderTopLeftRadius:e*.04}}),
|
|
47
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",top:e*.04,left:e*.4,width:e*.3,height:e*.5,borderWidth:i,borderColor:t,backgroundColor:o,borderRadius:e*.15,transform:[{rotate:"-20deg"}]}}),
|
|
48
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",bottom:e*.08,left:0,width:e*.2,height:e*.5,borderWidth:i,borderColor:t,backgroundColor:o,borderRadius:e*.05}})]})}function InfoGlyph({size:e,color:t,strokeWidth:r}){let n=Po(e,r);/* @__PURE__ */
|
|
49
|
+
return h(S,{style:[Io(e),{borderRadius:e/2,borderWidth:n,borderColor:t}],...zo,children:[
|
|
50
|
+
/* @__PURE__ */f(S,{style:{width:n,height:n,borderRadius:n,backgroundColor:t,marginBottom:e*.1}}),
|
|
51
|
+
/* @__PURE__ */f(S,{style:{width:n,height:e*.34,borderRadius:n,backgroundColor:t}})]})}function UploadGlyph({size:e,color:t,strokeWidth:r}){let n=Po(e,r),l=e*.34;/* @__PURE__ */
|
|
52
|
+
return h(S,{style:Io(e),...zo,children:[
|
|
53
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",top:e*.06,width:l,height:l,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}}),
|
|
54
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",top:e*.1,width:n,height:e*.56,borderRadius:n,backgroundColor:t}}),
|
|
55
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",bottom:0,width:e*.84,height:e*.3,borderBottomWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderBottomLeftRadius:n,borderBottomRightRadius:n}})]})}function PhotoGlyph({size:e,color:t,strokeWidth:r}){let n=Po(e,r);/* @__PURE__ */
|
|
56
|
+
return h(S,{style:[Io(e),{borderWidth:n,borderColor:t,borderRadius:e*.14,overflow:"hidden"}],...zo,children:[
|
|
57
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",top:e*.16,left:e*.18,width:e*.16,height:e*.16,borderRadius:e,backgroundColor:t}}),
|
|
58
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",bottom:-e*.3,right:-e*.1,width:e*.7,height:e*.7,borderTopWidth:n,borderLeftWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}function CameraGlyph({size:e,color:t,strokeWidth:r}){let n=Po(e,r);/* @__PURE__ */
|
|
59
|
+
return h(S,{style:Io(e),...zo,children:[
|
|
60
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",top:e*.08,width:e*.34,height:e*.2,borderTopWidth:n,borderLeftWidth:n,borderRightWidth:n,borderColor:t,borderTopLeftRadius:n,borderTopRightRadius:n}}),
|
|
61
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",top:e*.22,width:e*.92,height:e*.66,borderWidth:n,borderColor:t,borderRadius:e*.16,alignItems:"center",justifyContent:"center"},children:/* @__PURE__ */f(S,{style:{width:e*.3,height:e*.3,borderRadius:e,borderWidth:n,borderColor:t}})})]})}function SearchGlyph({size:e,color:t,strokeWidth:r}){let n=Po(e,r),l=e/24,i=16*l+n,o=11*l-i/2,a=11+8/Math.SQRT2,s=(21-a)*Math.SQRT2*l,u=(a+21)/2*l;/* @__PURE__ */
|
|
62
|
+
return h(S,{style:Io(e),...zo,children:[
|
|
63
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",top:o,left:o,width:i,height:i,borderRadius:i,borderWidth:n,borderColor:t}}),
|
|
64
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",top:u-n/2,left:u-(s+n)/2,width:s+n,height:n,borderRadius:n,backgroundColor:t,transform:[{rotate:"45deg"}]}})]})}function EditGlyph({size:e,color:t,strokeWidth:r}){let n=Po(e,r);/* @__PURE__ */
|
|
65
|
+
return h(S,{style:Io(e),...zo,children:[
|
|
66
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",width:e*.3,height:e*.82,borderWidth:n,borderColor:t,borderRadius:n,transform:[{rotate:"45deg"}]}}),
|
|
67
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",bottom:0,left:0,width:e*.4,height:n,borderRadius:n,backgroundColor:t}})]})}function MapPinGlyph({size:e,color:t,strokeWidth:r}){let n=Po(e,r),l=e*.62;/* @__PURE__ */
|
|
68
|
+
return h(S,{style:Io(e),...zo,children:[
|
|
69
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",top:0,width:l,height:l,borderRadius:l,borderWidth:n,borderColor:t,alignItems:"center",justifyContent:"center"},children:/* @__PURE__ */f(S,{style:{width:n*1.4,height:n*1.4,borderRadius:n,backgroundColor:t}})}),
|
|
70
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",bottom:e*.04,width:l*.5,height:l*.5,borderRightWidth:n,borderBottomWidth:n,borderColor:t,transform:[{rotate:"45deg"}]}})]})}function SendGlyph({size:e,color:t,testID:r}){let n=e*.36;/* @__PURE__ */
|
|
71
|
+
return f(S,{style:Io(e),testID:r,...zo,children:/* @__PURE__ */f(S,{style:{width:0,height:0,marginLeft:e*.12,borderLeftWidth:e*.78,borderTopWidth:n,borderBottomWidth:n,borderLeftColor:t,borderTopColor:"transparent",borderBottomColor:"transparent",transform:[{rotate:"-45deg"}]}})})}function StopGlyph({size:e,color:t,testID:r}){/* @__PURE__ */
|
|
72
|
+
return f(S,{style:Io(e),testID:r,...zo,children:/* @__PURE__ */f(S,{style:{width:e*.5,height:e*.5,backgroundColor:t}})})}function MicGlyph({size:e,color:t,strokeWidth:r,testID:n}){let l=Po(e,r);/* @__PURE__ */
|
|
73
|
+
return h(S,{style:Io(e),testID:n,...zo,children:[
|
|
74
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",top:e*.08,width:e*.26,height:e*.48,borderWidth:l,borderColor:t,borderRadius:e*.13}}),
|
|
75
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",top:e*.38,width:e*.56,height:e*.36,borderBottomWidth:l,borderLeftWidth:l,borderRightWidth:l,borderColor:t,borderBottomLeftRadius:e*.28,borderBottomRightRadius:e*.28}}),
|
|
76
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",top:e*.74,width:l,height:e*.18,backgroundColor:t}})]})}function Ring({size:e,strokeWidth:t,color:r,children:n}){/* @__PURE__ */
|
|
77
|
+
return f(S,{style:[Io(e),{borderRadius:e/2,borderWidth:t??v.hairlineWidth,borderColor:r}],children:n})}function ArrowUpGlyph({size:e,color:t,strokeWidth:r,testID:n}){let l=Po(e,r),i=e*.46;/* @__PURE__ */
|
|
78
|
+
return h(S,{style:Io(e),testID:n,...zo,children:[
|
|
79
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",top:e*.16,bottom:e*.12,width:l,borderRadius:l,backgroundColor:t}}),
|
|
80
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",top:e*.16+l/2,width:i,height:i,borderLeftWidth:l,borderTopWidth:l,borderColor:t,transform:[{rotate:"45deg"}]}})]})}function ChatBubbleGlyph({size:e,color:t,strokeWidth:r}){let n=Po(e,r);/* @__PURE__ */
|
|
81
|
+
return h(S,{style:Io(e),...zo,children:[
|
|
82
|
+
/* @__PURE__ */f(S,{style:{width:e*.8,height:e*.6,marginTop:-e*.12,borderWidth:n,borderColor:t,borderRadius:e*.14}}),
|
|
83
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",bottom:e*.1,left:e*.22,width:e*.2,height:e*.2,borderLeftWidth:n,borderBottomWidth:n,borderColor:t}})]})}function HistoryGlyph({size:e,color:t,strokeWidth:r}){let n=Po(e,r),l=e*.72,i=e/2;/* @__PURE__ */
|
|
84
|
+
return h(S,{style:Io(e),...zo,children:[
|
|
85
|
+
/* @__PURE__ */f(S,{style:{width:l,height:l,borderRadius:l/2,borderWidth:n,borderColor:t,borderLeftColor:"transparent",transform:[{rotate:"45deg"}]}}),
|
|
86
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",top:e*.16,left:e*.12,width:e*.2,height:e*.2,borderLeftWidth:n,borderBottomWidth:n,borderColor:t}}),
|
|
87
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",top:i-e*.2,left:i-n/2,width:n,height:e*.2+n/2,borderRadius:n,backgroundColor:t}}),
|
|
88
|
+
/* @__PURE__ */f(S,{style:{position:"absolute",top:i-n/2,left:i-n/2,width:e*.15+n/2,height:n,borderRadius:n,backgroundColor:t}})]})}var Lo=/* @__PURE__ */Object.freeze({standard:xe.standard,emphasized:xe.emphasized,exit:xe.exit,outQuad:/* @__PURE__ */Object.freeze([.25,.46,.45,.94]),out:/* @__PURE__ */Object.freeze([.23,1,.32,1])});var Eo=/* @__PURE__ */Object.freeze({layoutMs:220,messageInMs:200,bannerInMs:220,bannerOutMs:160,iconInMs:180,iconOutMs:120,followUpInMs:180,followUpStaggerMs:70,citationsInMs:220,citationsRisePx:6,drawerMs:220,pressScale:.97,pressMs:140,revealTickMs:24,revealDivisor:12,dotsCycleMs:520,dotsMinOpacity:.44,dotsLiftPx:3.5,dotsStagger:/* @__PURE__ */Object.freeze([0,.18,.36]),copiedMs:1500,uploadFlashMs:600,bubbleInMs:280,bubbleFromScale:.94,bubbleRisePx:6,promptRisePx:8,reduced:false}),Oo=/* @__PURE__ */Object.freeze({...Eo,layoutMs:0,messageInMs:0,bannerInMs:0,bannerOutMs:0,iconInMs:0,iconOutMs:0,followUpInMs:0,followUpStaggerMs:0,citationsInMs:0,citationsRisePx:0,drawerMs:0,pressScale:1,pressMs:0,revealTickMs:0,dotsCycleMs:0,dotsMinOpacity:1,dotsLiftPx:0,bubbleInMs:0,bubbleFromScale:1,bubbleRisePx:0,promptRisePx:0,reduced:true});function Ao(e){return e.motion.reducedMotion?Oo:Eo}function jo(e,t){return Math.max(0,t)*e.followUpStaggerMs}function Do(e,t,r){if(e.reduced||t>=r)return r;let n=Math.max(1,Math.ceil((r-t)/e.revealDivisor));return Math.min(r,t+n)}function Mo(){let e=useEverfurTheme();return Ao(e)}var Bo=8;function Ho(e,t,r){return((1-3*r+3*t)*e+(3*r-6*t))*e*e+3*t*e}function Wo(e,t,r){return 3*(1-3*r+3*t)*e*e+2*(3*r-6*t)*e+3*t}function No(e){let[t,r,n,l]=e;return e=>{if(e<=0)return 0;if(e>=1)return 1;let i=e;for(let r=0;r<Bo;r+=1){let r=Wo(i,t,n);if(r===0)break;i-=(Ho(i,t,n)-e)/r}return Ho(Math.min(1,Math.max(0,i)),r,l)}}var Uo=No(Lo.standard),$o=No(Lo.outQuad),Vo=No(Lo.out);function qo(e){let t=i(null);return t.current===null&&(t.current=new j.Value(e)),t.current}function Go(e,t={}){let r=t.risePx??0,n=t.delayMs??0,i=qo(e>0?0:1);return a(()=>{if(e<=0){i.setValue(1);return}let t=j.timing(i,{toValue:1,duration:e,easing:$o,useNativeDriver:true}),r=n>0?j.sequence([j.delay(n),t]):t;return r.start(),()=>r.stop()},[i,e,n]),l(()=>({opacity:i,transform:[{translateY:i.interpolate({inputRange:[0,1],outputRange:[r,0]})}]}),[i,r])}function FadePresence({visible:e,inMs:t,outMs:r,style:n,children:l}){let[i,s]=o(e),u=qo(e&&t<=0?1:0);return a(()=>{if(e){s(true);let e=j.timing(u,{toValue:1,duration:Math.max(0,t),easing:Uo,useNativeDriver:true});return e.start(),()=>e.stop()}if(!i)return;if(r<=0){s(false);return}let n=j.timing(u,{toValue:0,duration:r,easing:Uo,useNativeDriver:true});return n.start(({finished:e})=>{e&&s(false)}),()=>n.stop()},[e,i,t,r,u]),!i&&!e?null:/* @__PURE__ */f(j.View,{style:[n,{opacity:u}],children:l})}var Ko=/* @__PURE__ */Object.freeze({opacity:1,transform:/* @__PURE__ */Object.freeze([{translateY:0},{scale:1}])});function Yo(e,t){let[r]=o(()=>e?t.bubbleInMs:0),n=r>0,i=qo(n?0:1);a(()=>{if(r<=0)return;let e=j.timing(i,{toValue:1,duration:r,easing:Vo,useNativeDriver:true});return e.start(),()=>e.stop()},[r,i]);let s=t.bubbleFromScale,u=t.bubbleRisePx;return l(()=>n?{opacity:i,transform:[{translateY:i.interpolate({inputRange:[0,1],outputRange:[u,0]})},{scale:i.interpolate({inputRange:[0,1],outputRange:[s,1]})}]}:Ko,[n,i,u,s])}function Qo(e){let t=i(null),r=i(null),l=e[0]?.id??null;if(t.current===null||r.current!==l){let n=t.current===null;t.current=new Map(e.map(e=>[e.id,n&&e.pending===true])),r.current=l}let o=t.current;for(let t of e)o.has(t.id)||o.set(t.id,true);return n(e=>o.get(e)===true,[o])}var Zo=12;function PressScale({style:e,containerStyle:t,children:r,onPressIn:l,onPressOut:i,hitSlop:o,...a}){let s=Mo(),u=qo(1),d=n(e=>{s.pressMs<=0||s.pressScale===1||j.timing(u,{toValue:e,duration:s.pressMs,easing:Uo,useNativeDriver:true}).start()},[u,s.pressMs,s.pressScale]);/* @__PURE__ */
|
|
89
|
+
return f(T,{...a,hitSlop:o??Zo,style:t,onPressIn:e=>{d(s.pressScale),l?.(e)},onPressOut:e=>{d(1),i?.(e)},children:/* @__PURE__ */f(j.View,{style:[e,{transform:[{scale:u}]}],children:r})})}function Jo(e,t,r){let n=t&&r.revealTickMs>0,[l,s]=o(0),u=i(e);return u.current=e,a(()=>{if(!n)return;let e=setInterval(()=>{s(e=>Do(r,e,u.current.length))},r.revealTickMs);return()=>clearInterval(e)},[n,r]),n?e.slice(0,Math.min(l,e.length)):e}var Xo=false;function ea(e){e.layoutMs<=0||(Xo||(Xo=true,w.OS==="android"&&typeof O.setLayoutAnimationEnabledExperimental=="function"&&O.setLayoutAnimationEnabledExperimental(true)),A.configureNext({duration:e.layoutMs,create:{type:"easeInEaseOut",property:"opacity"},update:{type:"easeInEaseOut"},delete:{type:"easeInEaseOut",property:"opacity"}}))}function ta(e,t){let r=i(e);r.current!==e&&(r.current=e,ea(t))}var ra=36,na=22,la=12,ia=12,oa=16,aa="#000",sa="rgba(0,0,0,0.45)";function AttachmentImageLightbox({uri:e,label:t,onClose:r}){let n=useEverfurTheme(),l=B();return e===null?null:/* @__PURE__ */h(I,{visible:true,animationType:n.motion.reducedMotion?"none":"fade",transparent:false,statusBarTranslucent:true,onRequestClose:r,children:[
|
|
90
|
+
/* @__PURE__ */f(T,{accessibilityRole:"button",accessibilityLabel:rt.closePreview,style:ua.backdrop,onPress:r,children:/* @__PURE__ */f(L,{source:{uri:e},style:ua.image,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,accessibilityIgnoresInvertColors:true})}),
|
|
91
|
+
/* @__PURE__ */f(S,{pointerEvents:"box-none",style:[ua.closeWrap,{top:l.top+ia}],children:/* @__PURE__ */f(PressScale,{accessibilityRole:"button",accessibilityLabel:rt.closePreview,hitSlop:la,style:ua.closeButton,onPress:r,children:/* @__PURE__ */f(CloseGlyph,{size:na,color:n.color.surface,strokeWidth:2})})})]})}var ua=v.create({backdrop:{flex:1,backgroundColor:aa,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"},closeWrap:{position:"absolute",right:oa},closeButton:{width:ra,height:ra,borderRadius:ra/2,backgroundColor:sa,alignItems:"center",justifyContent:"center"}});var da=()=>{};function ca(){try{return k.currentState==="active"}catch{return false}}function createAppStateLifecycle(){return{onForeground(e){let t;try{let r=k.currentState==="background";t=k.addEventListener("change",t=>{t==="background"?r=!0:t==="active"&&r&&(r=!1,e())})}catch{return da}return()=>t.remove()},isVisible:ca}}function pa(e,t){if(e===void 0)return{};let r={};return e.backgroundColor!==void 0&&(r.backgroundColor=e.backgroundColor),e.borderColor!==void 0&&(r.borderColor=e.borderColor,r.borderWidth=t??1),e.borderRadius!==void 0&&(r.borderRadius=e.borderRadius),r}function fa(e){return e===void 0||e.backgroundColor!==void 0?e:e.borderRadius===void 0?void 0:{borderRadius:e.borderRadius}}function ha(e){return e?.textColor===void 0?{}:{color:e.textColor}}var ga=/* @__PURE__ */Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function ba(e){return e!==ga}var ma=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function ya(e,t,r){return new Promise(n=>{if(t.aborted){n();return}let l={handle:void 0},i=()=>{r.clearTimeout(l.handle),t.removeEventListener("abort",i),n()};l.handle=r.setTimeout(i,e),t.addEventListener("abort",i,{once:true})})}var va=4e3;var wa=4e3;var ka=/* @__PURE__ */Object.freeze(["image/jpeg","image/jpg","image/png","image/heic","image/heif","image/webp"]);var Ca=10*1024*1024,Sa=5,xa=120,Ra="/widget/v1/uploads/initiate";function isAttachmentMime(e){return typeof e=="string"&&ka.includes(e.trim().toLowerCase())}function sanitizeFilename(e){if(!e)return"attachment";let t=e.replace(/[\\/]+/g," ").replace(/[\x00-\x1f\x7f"]/g,"").replace(/\s+/g," ").trim();if(!t)return"attachment";if(t.length<=xa)return t;let r=t.lastIndexOf(".");if(r===-1||r===t.length-1)return t.slice(0,xa);let n=t.slice(r);return n.length>=xa?t.slice(0,xa):`${t.slice(0,r).slice(0,xa-n.length)}${n}`}function formatBytes(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Ta=e=>/* @__PURE__ */Object.freeze({ok:true,value:e}),_a=e=>/* @__PURE__ */Object.freeze({ok:false,error:e});function za(e,t,r,n){/* @__PURE__ */
|
|
92
|
+
return Object.freeze({code:e,retryable:t,filename:r,...n??{}})}function attachmentSize(e){if(typeof e.sizeBytes=="number"&&Number.isFinite(e.sizeBytes)&&e.sizeBytes>=0)return e.sizeBytes;let t=e.blob;return t!==void 0&&typeof t.size=="number"&&Number.isFinite(t.size)?t.size:null}function validateAttachment(e){let t=sanitizeFilename(e.name),r=typeof e.mimeType=="string"?e.mimeType.trim().toLowerCase():"";if(!isAttachmentMime(r))return _a(za("unsupported_type",false,t));let n=attachmentSize(e);return n===null?_a(za("unknown",false,t)):n>Ca?_a(za("too_large",false,t,{sizeBytes:n})):Ta(/* @__PURE__ */Object.freeze({file:e,filename:t,contentType:r,sizeBytes:n}))}function Ia(e){if(typeof e!="object"||e===null)return null;let t=e,r=e=>typeof e=="string"&&e.length>0?e:null,n=e=>typeof e=="number"&&Number.isFinite(e)?e:null,l=r(t.upload_id),i=r(t.upload_url),o=r(t.s3_key);if(l===null||i===null||o===null)return null;let a={},s=t.upload_fields;if(typeof s=="object"&&s!==null)for(let[e,t]of Object.entries(s))typeof t=="string"&&(a[e]=t);/* @__PURE__ */
|
|
93
|
+
return Object.freeze({upload_id:l,upload_url:i,upload_fields:/* @__PURE__ */Object.freeze(a),expires_in_seconds:n(t.expires_in_seconds)??0,max_content_length:n(t.max_content_length)??Ca,s3_key:o,purpose:r(t.purpose)})}function Pa(e,t){let r=e.httpStatus;switch(e.code){case"quotaExceeded":return za("quota_exceeded",false,t,{cause:e});case"rateLimited":return za("rate_limited",true,t,{cause:e});case"idempotencyConflict":case"idempotencyInFlight":return za("idempotency_conflict",true,t,{cause:e});case"validationFailed":return za("unsupported_type",false,t,{cause:e});case"serviceUnavailable":case"streamTimeout":return za("network",true,t,{cause:e});default:return r===429?za("rate_limited",true,t,{cause:e}):r===503?za("network",true,t,{cause:e}):r===void 0?za("network",true,t,{cause:e}):za("server",e.retryable,t,{httpStatus:r,cause:e})}}async function initiateAttachmentUpload(e,t,r){let n=await e.send("chat.attachments.initiate",{method:"POST",path:Ra,body:{filename:t.filename,content_type:t.contentType,file_size:t.sizeBytes},...r?.signal?{signal:r.signal}:{}});if(!n.ok)return _a(Pa(n.error,t.filename));let l=Ia(n.value);return l===null?_a(za("server",false,t.filename)):Ta(l)}async function uploadAttachmentBytes(e,t,r,n){let l=()=>n?.signal?.aborted===true;if(l())return _a(za("cancelled",true,r.filename));try{return await e.postMultipart(t,r.file,{...n?.signal?{signal:n.signal}:{},...n?.onProgress?{onProgress:n.onProgress}:{}}),Ta(void 0)}catch{return l()?_a(za("cancelled",true,r.filename)):_a(za("server",true,r.filename))}}var Fa=2,La=3,Ea=/* @__PURE__ */Object.freeze([1e3,2e3,4e3]),Oa=0;function Aa(){return Oa+=1,`attachment-${Oa}`}function createAttachmentQueue(e){let t=Math.max(1,e.concurrency??Fa),r=Math.max(1,e.maxAttempts??La),n=e.backoffMs??Ea,l=Math.max(1,e.maxPerMessage??Sa),i=e.timers??ma,o=e.newId??Aa,a=ba(e.transport),s=/* @__PURE__ */new Map,u=[],d=[],c=/* @__PURE__ */new Set,p=/* @__PURE__ */new Set,f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])}),h=false,g=()=>{f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze(u.flatMap(e=>{let t=s.get(e);return t===void 0?[]:[t.state]}))});for(let e of p)e()},b=(e,t)=>{e.state=/* @__PURE__ */Object.freeze({...e.state,...t}),g()},m=()=>{for(;!h&&c.size<t&&d.length>0;){let e=d.shift(),t=s.get(e);t!==void 0&&(c.add(e),y(t).finally(()=>{c.delete(e),m()}))}},y=async t=>{let{attachment:l}=t;for(;t.attempts<r;){if(h||t.controller.signal.aborted)return;t.attempts+=1;let o=t.controller.signal;b(t,{status:"uploading",error:null,progress:0});let a=await initiateAttachmentUpload(e.funnel,l,{signal:o});if(h||o.aborted)return;let s;if(!a.ok)s=_a(a.error);else{let r=await uploadAttachmentBytes(e.transport,a.value,l,{signal:o,onProgress:e=>{!o.aborted&&t.state.status==="uploading"&&b(t,{progress:ja(e)})}});if(h||o.aborted)return;s=r.ok?Ta(a.value.s3_key):_a(r.error)}if(s.ok){b(t,{status:"uploaded",s3Key:s.value,error:null,progress:1});return}let u=s.error,d=u.retryable&&t.attempts<r;if(b(t,{status:d?"uploading":"failed",error:u,progress:0}),!d)return;let c=n[Math.min(t.attempts-1,n.length-1)]??0;await ya(c,o,i)}},v=e=>{d.push(e.state.id),m()},w={available:a,subscribe(e){return p.add(e),()=>{p.delete(e)}},getSnapshot:()=>f,get uploading(){return f.attachments.some(e=>e.status==="uploading")},get s3Keys(){return f.attachments.flatMap(e=>e.status==="uploaded"&&e.s3Key!==null?[e.s3Key]:[])},add(e){let t=validateAttachment(e);if(!t.ok)return t;if(h||u.length>=l)return _a(za("too_many",false,t.value.filename));let r=o(),n={attachment:t.value,controller:new AbortController,attempts:0,state:/* @__PURE__ */Object.freeze({id:r,filename:t.value.filename,previewUri:e.uri,contentType:t.value.contentType,sizeBytes:t.value.sizeBytes,status:"uploading",s3Key:null,error:null,progress:0})};return s.set(r,n),u.push(r),g(),v(n),Ta(n.state)},retry(e){let t=s.get(e);t===void 0||h||t.state.status!=="failed"||(t.controller=new AbortController,t.attempts=0,b(t,{status:"uploading",error:null,progress:0,s3Key:null}),v(t))},remove(e){let t=s.get(e);if(t===void 0)return;t.controller.abort(),s.delete(e);let r=u.indexOf(e);r>=0&&u.splice(r,1);let n=d.indexOf(e);n>=0&&d.splice(n,1),g()},clear(){for(let e of[...u])w.remove(e)},dispose(){h=true;for(let e of s.values())e.controller.abort();s.clear(),u.length=0,d.length=0,p.clear(),f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])})}};return w}function ja(e){return Number.isNaN(e)||e<0?0:e>1?1:e}function Da(e){switch(e.code){case"too_large":return nt(rt.attachmentTooLarge,{max:formatBytes(Ca),filename:e.filename,size:formatBytes(e.sizeBytes??0)});case"too_many":return nt(rt.attachmentTooMany,{max:Sa});case"unsupported_type":return nt(rt.attachmentUnsupported,{filename:e.filename});case"network":return rt.attachmentNetwork;case"server":return nt(rt.attachmentServer,{status:""});case"cancelled":return rt.attachmentCancelled;case"rate_limited":return rt.attachmentRateLimited;case"quota_exceeded":return rt.attachmentQuota;case"idempotency_conflict":return rt.attachmentConflict;case"unknown":return rt.attachmentUnknown}}function Ma(e,t){return nt(e>=t?rt.attachmentsFull:rt.addAttachment,{used:e,total:t})}var Ba=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])});function useChatAttachments(e={}){let{runtime:t,userRef:userRef,scopeEpoch:r}=ct(),u=e.maxPerMessage??Sa,d=n(()=>{let{services:r}=t.registry;return createAttachmentQueue({funnel:createRequestFunnel({auth:r.authFor(userRef),...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}),transport:e.transport??r.uploadTransport,maxPerMessage:u})},[t,userRef,r,u,e.transport]),c=l(()=>e.queue??d(),[e.queue,d]),p=i(/* @__PURE__ */new WeakSet),[f,h]=o(null),g=f!==null&&f.of===c?f.queue:c;a(()=>{if(g!==e.queue){if(p.current.has(g)){h({of:c,queue:d()});return}return()=>{g.dispose(),p.current.add(g)}}},[g,c,d,e.queue]);let b=s(g.subscribe,g.getSnapshot,()=>Ba),[m,y]=o(null),v=n(e=>{let t=(Array.isArray(e)?e:[e]).map(e=>g.add(e)),r=t.find(e=>!e.ok);return r!==void 0&&!r.ok&&y(r.error),t},[g,y]),w=n(e=>g.retry(e),[g]),k=n(e=>g.remove(e),[g]),C=n(()=>g.clear(),[g]),S=n(()=>y(null),[y]),x=b.attachments.some(e=>e.status==="uploading"),R=b.attachments.some(e=>e.status==="failed");return l(()=>({available:g.available,attachments:b.attachments,maxPerMessage:u,uploading:x,failed:R,blocked:x||R,s3Keys:b.attachments.flatMap(e=>e.status==="uploaded"&&e.s3Key!==null?[e.s3Key]:[]),rejected:m,add:v,retry:w,remove:k,clear:C,dismissRejected:S}),[g.available,b,u,x,R,m,v,w,k,C,S])}var Ha=6e3;function Wa(e,t,r){let n=t.trim();if(!n)return e;let l=e===""||/\s$/.test(e)?"":" ",i=`${e}${l}${n}`;return typeof r=="number"&&r>0?i.slice(0,r):i}function Na(e){let t=Math.max(0,Math.floor(e/1e3)),r=Math.floor(t/60),n=t%60;return`${r}:${n.toString().padStart(2,"0")}`}function Ua(e){switch(e){case"permissionDenied":return rt.micBlocked;case"noSpeech":return rt.noSpeech;case"unavailable":return rt.dictationUnavailable}}function $a(e,t,r){if(e)try{e.track(t,{...r})}catch{}}var Va=["Apoquel","Cytopoint","Bravecto","NexGard","Simparica Trio","Credelio","Revolution","Heartgard","Interceptor","Sentinel","ProHeart","Rimadyl","carprofen","meloxicam","Metacam","Galliprant","gabapentin","trazodone","Librela","Solensia","Zenrelia","prednisone","prednisolone","amoxicillin","Clavamox","cephalexin","Convenia","metronidazole","doxycycline","Cerenia","maropitant","famotidine","omeprazole","Proin","Vetmedin","pimobendan","enalapril","furosemide","levothyroxine","methimazole","Vetsulin","fluoxetine","Sileo","tramadol","buprenorphine","Denamarin","Dasuquin","Cosequin","parvovirus","distemper","Bordetella","leptospirosis","heartworm","giardia","coccidia","pancreatitis","hypothyroidism","Cushing's disease","Addison's disease","IVDD","cruciate ligament","luxating patella","hip dysplasia","pyometra","kennel cough","otitis","FIV","FeLV","DHPP","FVRCP","Labrador Retriever","Golden Retriever","French Bulldog","German Shepherd","Dachshund","Cavalier King Charles Spaniel","Shih Tzu","Pomeranian","Chihuahua","Yorkshire Terrier","Bichon Frise","Havanese","Cockapoo","Goldendoodle","Labradoodle","Weimaraner","Vizsla","Shiba Inu","Springer Spaniel","Miniature Schnauzer","Corgi","Australian Shepherd","Border Collie","Siberian Husky","Beagle","Maine Coon","Ragdoll","Sphynx","Bengal cat","British Shorthair"];function qa(e={}){let t=/* @__PURE__ */new Set,r=[];for(let n of[e.name,e.breed,...Va]){let e=(n??"").trim();if(!e)continue;let l=e.toLowerCase();if(!t.has(l)&&(t.add(l),r.push(e),r.length>=100))break}return r}function Ga(e,conversationId,t){let[r,l]=o({send:e,conversationId:conversationId,text:t??"",seeded:t??null}),i=r.send===e&&(r.conversationId===null||r.conversationId===conversationId);a(()=>{l(r=>{let n=r.send===e&&(r.conversationId===null||r.conversationId===conversationId),l=n?r.text:"",i=n?r.seeded:null,o=t!=null&&t!==i&&l.length===0;return{send:e,conversationId:conversationId,text:o?t:l,seeded:o?t:i}})},[e,conversationId,t]);let s=n(t=>l(r=>({send:e,conversationId:conversationId,text:t,seeded:r.seeded})),[e,conversationId]);return[i?r.text:"",s]}function Ka(e,conversationId,t,r,n=false){let l=i({draft:t,setDraft:r});l.current={draft:t,setDraft:r};let s=i(null),[u,d]=o(null);a(()=>{if(e===void 0)return;let t=`${conversationId??""}`;if(s.current===t)return;s.current=t;let r=true;return(async()=>{let n=await fn(()=>e.read(conversationId));if(!r)return;let i=n.ok&&typeof n.value=="string"?n.value:"";i.length>0&&l.current.draft.length===0&&l.current.setDraft(i),d(t)})(),()=>{r=false}},[e,conversationId]),a(()=>{e===void 0||n||u!==`${conversationId??""}`||dn(()=>e.write(conversationId,t))},[e,conversationId,t,u,n])}function Ya(e){if(!(w.OS!=="ios"||e===""))try{let t=E?.announceForAccessibility;typeof t=="function"&&t.call(E,e)}catch{}}function AnnounceLine({line:e}){return a(()=>{Ya(e)},[e]),null}var Qa=12,Za=80,Ja=44,Xa=22,es=.14,ts=18,rs=8,ns=/* @__PURE__ */Object.freeze({photo:rt.attachmentPhoto,camera:rt.attachmentCamera});function AttachmentPickerPopover({sources:e,full:t,onPick:r,onClose:n}){let i=useEverfurTheme(),o=l(()=>ls(i),[i]);/* @__PURE__ */
|
|
94
|
+
return h(S,{style:o.anchor,pointerEvents:"box-none",children:[
|
|
95
|
+
/* @__PURE__ */f(T,{style:o.dismissLayer,accessibilityRole:"button",accessibilityLabel:rt.closeAttachmentPicker,onPress:n}),
|
|
96
|
+
/* @__PURE__ */h(S,{style:o.bubble,children:[
|
|
97
|
+
/* @__PURE__ */f(S,{style:o.tilesRow,children:e.map(e=>/* @__PURE__ */h(PressScale,{accessibilityRole:"button",accessibilityLabel:ns[e],accessibilityState:{disabled:t},disabled:t,containerStyle:o.tile,style:o.tileInner,onPress:()=>r(e),children:[
|
|
98
|
+
/* @__PURE__ */f(S,{style:o.tileIconWrap,children:e==="photo"?/* @__PURE__ */f(PhotoGlyph,{size:Xa,color:i.color.brandInk,strokeWidth:1.5}):/* @__PURE__ */f(CameraGlyph,{size:Xa,color:i.color.brandInk,strokeWidth:1.5})}),
|
|
99
|
+
/* @__PURE__ */f(Text,{tier:"control",style:o.tileLabel,children:ns[e]})]},e))}),
|
|
100
|
+
/* @__PURE__ */f(S,{style:o.tail}),
|
|
101
|
+
/* @__PURE__ */f(S,{style:o.tailFill})]})]})}function ls(e){let t=e.color,r=e.radius;return v.create({anchor:{position:"absolute",left:0,right:0,bottom:"100%",paddingHorizontal:8,paddingBottom:10,alignItems:"flex-start"},dismissLayer:{position:"absolute",left:-1e3,right:-1e3,top:-2e3,bottom:0},bubble:{backgroundColor:t.surfaceCream,borderRadius:r.lg,borderWidth:1,borderColor:t.brandBorderStrong,paddingHorizontal:6,paddingVertical:8,shadowColor:t.shadow,shadowOpacity:es,shadowRadius:ts,shadowOffset:{width:0,height:rs},elevation:8},tilesRow:{flexDirection:"row",alignItems:"stretch"},tile:{minWidth:Za,borderRadius:r.md},tileInner:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:10,paddingVertical:8,gap:6},tileIconWrap:{width:Ja,height:Ja,borderRadius:Ja/2,backgroundColor:t.brandSoft,alignItems:"center",justifyContent:"center"},tileLabel:{...face(e,"medium"),fontSize:12,lineHeight:14,color:t.text.primary},tail:{position:"absolute",left:24,bottom:-Qa/2,width:Qa,height:Qa,backgroundColor:t.surfaceCream,borderRightWidth:1,borderBottomWidth:1,borderColor:t.brandBorderStrong,transform:[{rotate:"45deg"}]},tailFill:{position:"absolute",left:22,bottom:0,width:Qa+4,height:2,backgroundColor:t.surfaceCream}})}function parseColor(e){let t=is(e);return t===null?null:ps(t)}function is(e){if(typeof e=="number")return ss(e);if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;if(t.startsWith("#"))return os(t.slice(1));if(t.toLowerCase().startsWith("0x"))return os(t.slice(2));if(t.toLowerCase().startsWith("rgb"))return as(t);if(/^[0-9a-fA-F]+$/.test(t)){let e=os(t);if(e!==null)return e}return/^\d+$/.test(t)?ss(Number.parseInt(t,10)):null}function os(e){let t=e.trim();if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===3)return{r:ds(t[0]),g:ds(t[1]),b:ds(t[2]),a:1};if(t.length===6)return{r:us(t,0),g:us(t,2),b:us(t,4),a:1};if(t.length===8){let e=us(t,0);return{r:us(t,2),g:us(t,4),b:us(t,6),a:e/255}}return null}function as(e){let t=e.indexOf("("),r=e.indexOf(")");if(t<0||r<0||r<t)return null;let n=e.slice(t+1,r).split(",").map(e=>e.trim());if(n.length<3)return null;let l=cs(Number(n[0])),i=cs(Number(n[1])),o=cs(Number(n[2]));if(l===null||i===null||o===null)return null;let a=1;if(n.length>=4){let e=Number(n[3]);if(!Number.isFinite(e))return null;a=Math.min(1,Math.max(0,e))}return{r:l,g:i,b:o,a:a}}function ss(e){if(!Number.isFinite(e))return null;let t=Math.trunc(e)>>>0,r=t>>>24&255;return{r:t>>>16&255,g:t>>>8&255,b:t&255,a:r===0?1:r/255}}function us(e,t){return Number.parseInt(e.slice(t,t+2),16)}function ds(e){return Number.parseInt(`${e??"0"}${e??"0"}`,16)}function cs(e){return Number.isFinite(e)?Math.min(255,Math.max(0,Math.round(e))):null}function ps(e){if(e.a>=1)return fs(e.r,e.g,e.b);let t=Math.round(e.a*1e3)/1e3;return`rgba(${e.r},${e.g},${e.b},${t})`}function fs(e,t,r){return`#${hs(e)}${hs(t)}${hs(r)}`.toUpperCase()}function hs(e){return e.toString(16).padStart(2,"0")}var gs="#111111",bs="#FFFFFF",ms="#000000";function readableOn(e){let t=is(e);if(t===null)return bs;let r=ws(t),n=ws({r:17,g:17,b:17}),l=ws({r:255,g:255,b:255});return Cs(r,l)>=Cs(r,n)?bs:gs}function ys(e,t){let r=readableOn(e);return contrastRatio(r,e)>=t?r:contrastRatio(bs,e)>=contrastRatio(ms,e)?bs:ms}function vs(e){let t=t=>e.reduce((e,r)=>Math.min(e,contrastRatio(t,r)),Number.POSITIVE_INFINITY);return t(bs)>=t(ms)?bs:ms}function ws(e){let t=ks(e.r/255),r=ks(e.g/255),n=ks(e.b/255);return.2126*t+.7152*r+.0722*n}function ks(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Cs(e,t){let r=Math.max(e,t),n=Math.min(e,t);return(r+.05)/(n+.05)}function contrastRatio(e,t){let r=is(e),n=is(t);if(r===null||n===null)return 1;let l=n.a>=1?n:{...n},i=r.a>=1?r:Ss(r,l);return Cs(ws(i),ws(l))}function Ss(e,t){let r=e.a,n=(e,t)=>Math.round(e*r+t*(1-r));return{r:n(e.r,t.r),g:n(e.g,t.g),b:n(e.b,t.b),a:1}}function xs(e,t){let r=is(e),n=is(t);if(r===null||n===null)return null;let l=r.a>=1?r:Ss(r,{...n});return fs(l.r,l.g,l.b)}function Rs(e,t){let r=is(e);if(r===null)return null;let n=Math.min(1,Math.max(0,t));return`rgba(${r.r}, ${r.g}, ${r.b}, ${n})`}var Ts=.05;function _s(e,t,r,n){let l=t[0];if(l===void 0)return r;let i=e=>t.every(t=>contrastRatio(e,t)>=n);if(is(e)===null)return r;if(i(e))return e;let o=xs(e,l),a=o===null?null:is(o),s=is(r);if(a===null||s===null)return r;for(let e=1;e<1/Ts;e+=1){let t=e*Ts,r=(e,r)=>Math.round(e+(r-e)*t),n=fs(r(a.r,s.r),r(a.g,s.g),r(a.b,s.b));if(i(n))return n}return r}var zs=/* @__PURE__ */Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});var Is=56,Ps=12,Fs=14,Ls=10,Es=.45,Os="rgba(7,193,104,0.55)",As="rgba(185,28,28,0.55)",js=200,Ds=300,Ms=20,Bs=22,Hs=12,Ws="rgba(0,0,0,0.78)",Ns=220,Us=100,$s="rgba(255,255,255,0.15)";function AttachmentStrip({attachments:e,rejected:t,uploadFailed:r=false,onRetry:n,onRemove:i,onPreview:o,style:a}){let s=useEverfurTheme(),u=l(()=>Vs(s),[s]);return e.length===0&&t===null?null:/* @__PURE__ */h(S,{style:[u.strip,a],children:[e.length>0?/* @__PURE__ */f(S,{style:u.cards,children:e.map(e=>/* @__PURE__ */f(PreviewCard,{row:e,styles:u,onRetry:n,onRemove:i,onPreview:o},e.id))}):null,r?/* @__PURE__ */f(Text,{style:u.rejected,accessibilityRole:"alert",children:rt.attachmentsFailedBlocked}):null,t!==null?/* @__PURE__ */f(Text,{style:u.rejected,accessibilityRole:"alert",children:Da(t)}):null]})}function PreviewCard({row:e,styles:t,onRetry:r,onRemove:n,onPreview:l}){let s=useEverfurTheme(),u=e.status==="uploading",d=e.status==="failed",c=e.status==="uploaded",p=i(e.status),[g,b]=o(false);return a(()=>{let t=p.current;p.current=e.status,e.status==="uploaded"&&t==="uploading"&&b(true)},[e.status]),/* @__PURE__ */h(S,{style:t.card,children:[
|
|
102
|
+
/* @__PURE__ */f(T,{accessibilityRole:c?"button":"image",accessibilityLabel:c?nt(rt.previewAttachment,{filename:e.filename}):e.filename,accessibilityState:{busy:u,disabled:!c},disabled:!c,style:t.thumbHit,onPress:()=>l(e),children:/* @__PURE__ */h(S,{style:t.thumb,children:[
|
|
103
|
+
/* @__PURE__ */f(L,{source:{uri:e.previewUri},style:t.thumbImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true}),u?/* @__PURE__ */f(S,{style:t.uploadingOverlay,children:/* @__PURE__ */f(F,{size:"small",color:s.color.surface})}):null,g?/* @__PURE__ */f(SuccessFlash,{styles:t,onDone:()=>b(false)}):null]})}),d?/* @__PURE__ */f(T,{accessibilityRole:"button",accessibilityLabel:nt(rt.retryUpload,{filename:e.filename}),style:t.failedOverlay,onPress:()=>r(e.id),children:/* @__PURE__ */f(S,{style:t.failedInner,children:/* @__PURE__ */f(CloseGlyph,{size:Ms,color:s.color.surface,strokeWidth:2})})}):null,
|
|
104
|
+
/* @__PURE__ */f(PressScale,{accessibilityRole:"button",accessibilityLabel:nt(rt.removeAttachment,{filename:e.filename}),hitSlop:6,containerStyle:t.removeSlot,style:t.removeButton,onPress:()=>n(e.id),children:/* @__PURE__ */f(CloseGlyph,{size:Hs,color:s.color.surface,strokeWidth:1.5})})]})}function SuccessFlash({styles:e,onDone:t}){let r=useEverfurTheme(),n=Mo(),l=i(null);l.current===null&&(l.current=new j.Value(0));let o=l.current;return a(()=>{let e=j.sequence([j.timing(o,{toValue:1,duration:js,useNativeDriver:true}),j.delay(n.uploadFlashMs),j.timing(o,{toValue:0,duration:Ds,useNativeDriver:true})]);return e.start(({finished:e})=>{e&&t()}),()=>e.stop()},[o,n.uploadFlashMs,t]),/* @__PURE__ */f(j.View,{pointerEvents:"none",style:[e.successOverlay,{opacity:o}],children:/* @__PURE__ */f(CheckGlyph,{size:Ms,color:r.color.surface,strokeWidth:2})})}function SentImages({images:e,onPreview:t}){let r=useEverfurTheme(),n=l(()=>Vs(r),[r]);if(e.length===0)return null;let i=e.length===1;/* @__PURE__ */
|
|
105
|
+
return f(S,{style:i?n.sentSingle:n.sentGrid,children:e.map((e,r)=>/* @__PURE__ */f(T,{accessibilityRole:"button",accessibilityLabel:nt(rt.attachedImage,{filename:e.filename}),onPress:()=>t(e),children:/* @__PURE__ */f(L,{source:{uri:e.uri},style:i?n.singleImage:n.gridImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true})},`${e.uri}-${r}`))})}function Vs(e){let t=e.color,r=e.type;return v.create({strip:{gap:6,paddingBottom:8},cards:{flexDirection:"row",flexWrap:"wrap",gap:8},card:{width:Is,height:Is,overflow:"visible"},thumbHit:{width:"100%",height:"100%"},thumb:{width:"100%",height:"100%",borderRadius:Ps,overflow:"hidden",backgroundColor:t.composerFill,borderWidth:v.hairlineWidth,borderColor:t.brandBorder},thumbImage:{width:"100%",height:"100%"},uploadingOverlay:{...zs,alignItems:"center",justifyContent:"center",backgroundColor:Rs(e.color.brandInk,Es)??e.color.brandSofter},successOverlay:{...zs,alignItems:"center",justifyContent:"center",backgroundColor:Os},failedOverlay:{...zs,borderRadius:Ps,overflow:"hidden"},failedInner:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:As},removeSlot:{position:"absolute",top:4,right:4},removeButton:{width:Bs,height:Bs,borderRadius:Bs/2,backgroundColor:Ws,borderWidth:1.5,borderColor:t.surface,alignItems:"center",justifyContent:"center"},rejected:{...face(e,"regular"),fontSize:r.size.caption,lineHeight:r.size.caption*r.lineHeight.normal,color:t.danger},sentSingle:{marginBottom:6},sentGrid:{flexDirection:"row",flexWrap:"wrap",gap:6,marginBottom:6},singleImage:{width:Ns,height:Ns,borderRadius:Fs,backgroundColor:$s},gridImage:{width:Us,height:Us,borderRadius:Ls,backgroundColor:$s}})}var qs="file",Gs="multipart upload failed";function Ks(e){let t;try{t=new FormData;for(let[r,n]of Object.entries(e.fields))t.append(r,n);t.append(qs,e.file)}catch{return Promise.reject(new Error(Gs))}return e.fetch!==void 0?Zs(e.fetch,e.url,t,e.signal):Qs(e.url,t,e.signal)}function Ys(e){return e>=200&&e<300}function Qs(e,t,r){return new Promise((n,l)=>{let i=globalThis.XMLHttpRequest;if(typeof i!="function"||r?.aborted===true){l(new Error(Gs));return}let o=null,a=()=>{o!==null&&r?.removeEventListener("abort",o)},s=()=>{a(),l(new Error(Gs))};try{let l=new i;l.open("POST",e),l.withCredentials=!1,l.onload=()=>{a(),n(Ys(l.status))},l.onerror=s,l.ontimeout=s,l.onabort=s,r!==void 0&&(o=()=>{try{l.abort()}finally{s()}},r.addEventListener("abort",o,{once:!0})),l.send(t)}catch{s()}})}function Zs(e,t,r,n){return Promise.resolve().then(()=>e(t,{method:"POST",body:r,credentials:"omit",...n?{signal:n}:{}})).then(e=>e.ok)}var Js="chat attachment upload: the file handle has no uri",Xs="chat attachment upload failed";function eu(e){return{uri:e.uri,name:sanitizeFilename(e.name),type:e.mimeType}}function createRnChatAttachmentTransport(e={}){/* @__PURE__ */
|
|
106
|
+
return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(Js));let{signal:l,onProgress:i}=n,o=()=>Promise.reject(new Error(Xs));return l?.aborted===true?o():Ks({url:t.upload_url,fields:t.upload_fields,file:eu(r),signal:l,fetch:e.fetch}).then(e=>{if(!e)return o();i?.(1)},o)}})}var tu=300,ru=3e3,nu=120,lu=44,iu=120,ou="88%",au=520,su=2,uu=.5,du=1.5,cu=1.6,pu=.6,fu=56,hu=1.5,gu=5,bu=5,mu=36,yu=20,vu=14,wu=lu,ku=4,Cu=24,Su=22,xu=.4,Ru=lu,Tu=20,_u=.4,zu=480,Iu=12,Pu=.72,Fu=48,Lu=1.5,Eu=1.3,Ou=1,Au=1,ju="12%",Du=14,Mu=16,Bu=28,Hu=18,Wu="84%",Nu=10,Uu=15,$u=1.42,Vu=4,qu=3,Gu=14,Ku=20;function Yu(){let e=useEverfurTheme(),t=l(()=>Qu(e),[e]);return{theme:e,styles:t}}function Qu(e){let t=e.color,r=e.space,n=e.radius,l=e.type,i=Math.round(l.size.body*du),o=Math.round(l.size.body*cu),a=Math.round(yu*l.size.body/vu),s=t.borderRingCream,u=e.slots;return v.create({container:{flex:1,minHeight:nu,backgroundColor:t.chatGround},body:{flex:1},centered:{minHeight:nu,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl},homeEmpty:{flexGrow:1},emptyContent:{flexGrow:1,alignItems:"stretch",justifyContent:"flex-start",paddingTop:ju,paddingHorizontal:r.lg,paddingBottom:r.lg,minHeight:zu,gap:r.lg},errorText:{...face(e,"regular"),fontSize:l.size.subtitle,lineHeight:l.size.subtitle*l.lineHeight.snug,color:t.danger,textAlign:"center",marginBottom:r.md},retryButton:{minHeight:lu,minWidth:lu,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.brand,...pa(u.primaryButton)},retryLabel:{...face(e,"medium"),color:t.onPrimary,fontSize:l.size.body,...ha(u.primaryButton)},setupNotice:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm,paddingHorizontal:r.lg,paddingVertical:r.sm,backgroundColor:t.surfaceCream},setupNoticeText:{...face(e,"regular"),color:t.danger,fontSize:l.size.caption,flexShrink:1},turnNotice:{gap:r.xs,padding:r.md,borderRadius:n.md,backgroundColor:t.surfaceCream,borderWidth:Au,borderColor:t.borderRingCream,alignItems:"flex-start"},turnNoticeError:{borderColor:t.danger},turnNoticeTitle:{...face(e,"bold"),color:t.text.primary,fontSize:l.size.bodyTight},turnNoticeTitleError:{color:t.danger},turnNoticeBody:{...face(e,"regular"),color:t.text.muted,fontSize:l.size.caption,lineHeight:l.size.caption*l.lineHeight.normal},turnNoticeAction:{minHeight:lu,justifyContent:"center"},turnNoticeActionLabel:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.bodyTight},setupNoticeAction:{...face(e,"medium"),color:t.brandInk,fontSize:l.size.caption},reconnectingCaption:{...face(e,"medium"),color:t.text.secondary,fontSize:l.size.caption,lineHeight:l.size.caption*l.lineHeight.normal,textTransform:"uppercase",letterSpacing:.5},readingBox:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:r.xs,paddingVertical:r.md,paddingHorizontal:r.md+r.xs/2,backgroundColor:t.surfaceSubtle,borderRadius:n.md},readingDot:{width:6,height:6,borderRadius:n.pill,backgroundColor:t.brandInk},readingInline:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:qu,minHeight:Gu},readingDotInline:{width:Vu,height:Vu,borderRadius:n.pill,backgroundColor:t.text.muted},list:{flex:1},earlierButton:{alignSelf:"center",minHeight:lu,justifyContent:"center",paddingHorizontal:r.md+r.xs/2},earlierLabel:{...face(e,"monoBold"),color:t.linkInk,fontSize:l.size.caption},listContent:{padding:r.lg,gap:r.xl},listContentCards:{paddingTop:Du,paddingHorizontal:Mu,paddingBottom:Bu,gap:Hu},rowBlock:{gap:r.sm},rowBlockUser:{},rowBlockAssistant:{paddingRight:r.xl},row:{flexDirection:"row"},rowUser:{justifyContent:"flex-end"},rowAssistant:{justifyContent:"flex-start"},bubble:{maxWidth:ou,alignItems:"flex-start"},bubbleSideUser:{alignItems:"flex-end"},bubbleUser:{maxWidth:au,paddingVertical:r.md,paddingHorizontal:r.lg+su,backgroundColor:t.bubbleUser,...t.primaryEdge!==t.primary&&t.bubbleUser===t.primary?{borderWidth:uu,borderColor:t.primaryEdge}:{},borderRadius:n.lg,borderBottomRightRadius:n.xs,...pa(u.userBubble,uu)},bubbleAssistant:u.assistantBubble?.backgroundColor===void 0?{...pa(u.assistantBubble,uu)}:{paddingVertical:r.md,paddingHorizontal:r.lg+su,borderRadius:n.lg,...pa(u.assistantBubble,uu)},bubbleVet:{maxWidth:au,paddingVertical:r.md,paddingHorizontal:r.lg+su,backgroundColor:t.bubbleVet,borderRadius:n.lg,borderTopLeftRadius:n.xs,...pa(u.vetBubble,uu)},bubbleCards:{maxWidth:Wu},bubbleUserCards:{paddingVertical:Nu,paddingHorizontal:Uu},bubbleTextUserCards:{fontSize:textRole(e,"message").fontSize,lineHeight:Math.round(textRole(e,"message").fontSize*$u)},bubblePending:{opacity:pu},bubbleTextUser:{...face(e,"regular"),color:t.onPrimary,fontSize:l.size.body,lineHeight:i,...ha(u.userBubble)},bubbleTextAssistant:{...face(e,"regular"),color:t.text.primary,fontSize:l.size.body,lineHeight:o,...ha(u.assistantBubble)},bubbleTextVet:{...face(e,"regular"),color:t.onBubbleVet,fontSize:l.size.body,lineHeight:i,...ha(u.vetBubble)},assistantName:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.bodyTight,marginBottom:r.xs},assistantSender:{flexDirection:"row",alignItems:"center",gap:r.sm,marginBottom:r.xs},assistantAvatar:{width:Ku,height:Ku,borderRadius:Ku/2},assistantNameInRow:{marginBottom:0},vetHeader:{flexDirection:"row",alignItems:"baseline",gap:r.sm,marginBottom:r.xs},vetSender:{...face(e,"bold"),color:t.text.primary,fontSize:l.size.bodyTight},vetTime:{...face(e,"regular"),color:t.text.muted,fontSize:l.size.caption},bubbleBold:face(e,"bold"),bubbleItalic:{fontStyle:"italic"},bubbleCode:face(e,"mono"),followUps:{alignSelf:"stretch",marginTop:r.md},followUpsHeading:{...face(e,"monoBold"),color:t.text.muted,fontSize:Iu,textTransform:"uppercase",letterSpacing:Pu,paddingBottom:r.sm,borderBottomWidth:Ou,borderBottomColor:s},followUpSlot:{alignSelf:"stretch"},followUpSlotRuled:{borderTopWidth:Ou,borderTopColor:s},followUpRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.md,minHeight:Fu,paddingVertical:r.sm+su,...u.chip?.backgroundColor!==void 0||u.chip?.borderColor!==void 0?{paddingHorizontal:r.md}:{},...pa(u.chip)},followUpText:{...face(e,"bold"),flex:1,color:t.brandInk,fontSize:l.size.bodyTight,...ha(u.chip)},askChips:{flexDirection:"row",flexWrap:"wrap",gap:r.sm,marginTop:r.md},askChip:{minHeight:lu,maxWidth:"100%",justifyContent:"center",paddingVertical:r.sm,paddingHorizontal:r.lg,borderRadius:n.pill,borderWidth:Lu,borderColor:t.brandInk,backgroundColor:t.chatGround,...pa(u.chip,Lu)},askChipText:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.bodyTight,lineHeight:Math.round(l.size.bodyTight*Eu),...ha(u.chip)},composerOuter:{position:"relative"},askEntry:{marginHorizontal:r.md,marginTop:r.xs},composer:{marginHorizontal:r.md,marginTop:r.xs,minHeight:fu,justifyContent:"center",paddingLeft:r.sm,paddingRight:gu,paddingVertical:bu,backgroundColor:t.composerFill,borderWidth:hu,borderColor:t.composerBorder,borderRadius:n.pill,...pa(u.composerInput,hu)},composerRow:{flexDirection:"row",alignItems:"center",gap:r.xs,minHeight:mu},dictationError:{...face(e,"regular"),fontSize:l.size.caption,lineHeight:l.size.caption*l.lineHeight.normal,color:t.danger,paddingHorizontal:r.xs},attachControl:{width:Ru,height:Ru,alignItems:"center",justifyContent:"center"},attachControlDisabled:{opacity:_u},input:{flex:1,minHeight:mu,maxHeight:iu,paddingHorizontal:0,paddingVertical:0,...face(e,"regular"),fontSize:l.size.body,lineHeight:a,color:t.text.primary,...ha(u.composerInput)},sendControl:{minHeight:wu,minWidth:wu,alignItems:"center",justifyContent:"center"},sendDisc:{width:wu,height:wu,borderRadius:wu/2,alignItems:"center",justifyContent:"center",...pa(u.sendButton)},sendControlDisabled:{opacity:xu},poweredBy:{...face(e,"regular"),color:t.text.muted,fontSize:l.size.micro,textAlign:"center",paddingBottom:r.xs}})}var Zu=18,Ju=28,Xu=6,ed=1200,td=.4,rd=.4;function DictationButton({active:e,listening:t,elapsedMs:r,disabled:n=false,onToggle:i}){let o=useEverfurTheme(),s=l(()=>nd(o),[o]);return a(()=>{if(t)try{E.announceForAccessibility(rt.listening)}catch{}},[t]),/* @__PURE__ */h(S,{style:s.wrap,children:[t?/* @__PURE__ */f(Text,{style:s.timer,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",testID:"everfur-dictation-timer",children:Na(r)}):null,
|
|
107
|
+
/* @__PURE__ */f(T,{onPress:()=>i(),disabled:n,accessibilityRole:"button",accessibilityLabel:e?rt.stopDictation:rt.dictate,accessibilityState:{selected:e,disabled:n},style:[s.button,n?s.buttonDisabled:null],testID:"everfur-dictation-button",children:e?/* @__PURE__ */h(g,{children:[
|
|
108
|
+
/* @__PURE__ */f(Pulse,{style:s.pulse,reduced:o.motion.reducedMotion}),
|
|
109
|
+
/* @__PURE__ */f(StopGlyph,{size:Ju,color:o.color.brandInk,testID:"everfur-dictation-stop"})]}):/* @__PURE__ */f(MicGlyph,{size:Zu,color:o.color.brandInk,testID:"everfur-dictation-mic"})})]})}function Pulse({style:e,reduced:t}){let r=i(new j.Value(1)).current;return a(()=>{if(t)return;let e=j.loop(j.sequence([j.timing(r,{toValue:td,duration:ed/2,useNativeDriver:true}),j.timing(r,{toValue:1,duration:ed/2,useNativeDriver:true})]));return e.start(),()=>e.stop()},[r,t]),/* @__PURE__ */f(j.View,{style:[e,{opacity:r}],accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"})}function nd(e){let t=e.color,r=e.type.tierSizes.compact.micro;return v.create({wrap:{flexDirection:"row",flexShrink:0,alignItems:"center",gap:e.space.xs},timer:{...face(e,"mono"),fontSize:r,lineHeight:r+2,fontVariant:["tabular-nums"],color:t.text.muted},button:{width:lu,height:lu,borderRadius:e.radius.pill,alignItems:"center",justifyContent:"center"},buttonDisabled:{opacity:rd},pulse:{position:"absolute",top:Xu,right:Xu,bottom:Xu,left:Xu,borderRadius:e.radius.pill,backgroundColor:t.brandSofter}})}function optionalModule(e,t,r){let n;try{n=t()}catch(t){return id(`optional peer '${e}' is not installed: ${od(t)}`)}let l=ld(n);return l==null?id(`optional peer '${e}' resolved to no module`):r&&!r(l)?id(`optional peer '${e}' is present but failed its shape check`):/* @__PURE__ */Object.freeze({available:true,module:l})}function ld(e){return typeof e=="object"&&e!==null&&"default"in e&&Object.keys(e).length<=2?e.default:e}function id(e){/* @__PURE__ */
|
|
110
|
+
return Object.freeze({available:false,module:null,reason:e})}function od(e){return e instanceof Error?e.message:typeof e=="string"?e:"unknown load error"}var ad=/* @__PURE__ */Symbol.for("@everfur/sdk/rn-dictation");function sd(){let e=globalThis,t=e[ad];if(t!==void 0)return t;let r={loader:null,memo:void 0};return e[ad]=r,r}function registerEverfurDictation(e){let t=sd();t.loader=e,t.memo=void 0,t.version=(t.version??0)+1;for(let e of[...t.listeners??[]])try{e()}catch{}}function ud(){return sd().version??0}function dd(e){let t=sd(),r=t.listeners??/* @__PURE__ */new Set;t.listeners=r;let n=()=>e();return r.add(n),()=>{r.delete(n)}}function cd(e){if(typeof e!="object"||e===null)return false;let t=e;return typeof t.start=="function"&&typeof t.isRecognitionAvailable=="function"&&typeof t.addListener=="function"}function pd(e){return typeof e!="object"||e===null?null:e.ExpoSpeechRecognitionModule??e}function fd(){let e=sd();if(e.memo!==void 0)return e.memo;e.memo=null;let t=e.loader;if(t===null||w.OS!=="ios"&&w.OS!=="android")return e.memo;let r=optionalModule("expo-speech-recognition",()=>({box:pd(t())}),e=>typeof e=="object"&&e!==null&&cd(e.box));return r.available&&(e.memo=r.module.box),e.memo}function hd(e){if(e===null)return false;try{return e.isRecognitionAvailable()===!0}catch{return false}}function gd(){try{return Intl.DateTimeFormat().resolvedOptions().locale||md}catch{return md}}function bd(e){return e.replace(/_/g,"-").toLowerCase()}var md="en-US";function yd(e=gd()){let[t=""]=e.replace(/_/g,"-").split("-u-"),r=t.split("-");if(r[0]?.toLowerCase()!=="en")return md;let n=r.slice(1).find(e=>/^[A-Za-z]{2}$/.test(e));return n?`en-${n.toUpperCase()}`:md}function vd(e,t){if(t.length===0)return null;let r=e=>t.find(t=>bd(t)===bd(e));return r(e)??r(md)??t.find(e=>bd(e).startsWith("en-"))??null}async function wd(e,t){if(w.OS!=="ios")return t;try{let{locales:r}=await e.getSupportedLocales({});return vd(t,r??[])??t}catch{return t}}async function kd(e,t){let r=false;try{r=e.supportsOnDeviceRecognition()===!0}catch{r=false}if(!r)return"network";if(w.OS!=="android")return"on_device";try{let{installedLocales:r}=await e.getSupportedLocales({}),n=bd(t);return(r??[]).some(e=>bd(e)===n)?"on_device":"network"}catch{return"network"}}function Cd(){return w.OS!=="android"?true:Number(w.Version)>=Sd}var Sd=33;function xd(e,t,r){return{lang:t,interimResults:true,continuous:Cd(),maxAlternatives:1,addsPunctuation:true,requiresOnDeviceRecognition:e==="on_device",contextualStrings:r.slice(0,100),iosTaskHint:"dictation"}}var Rd=/* @__PURE__ */new Set(["not-allowed","no-speech","speech-timeout","aborted","interrupted"]),Td=/* @__PURE__ */new Set(["busy","client","network","audio-capture","too-many-requests","unknown"]);function _d(e){return Td.has(e)}var zd=600,Id=3;function Pd(e,t,r){if(Rd.has(r))return null;let n=_d(r)?zd:0;return r==="language-not-supported"&&bd(t)!==bd(md)?{mode:"network",lang:md,delayMs:n}:e==="on_device"?{mode:"network",lang:t,delayMs:n}:n>0?{mode:"network",lang:t,delayMs:n}:null}function Fd(e){return e==="not-allowed"?"permissionDenied":e==="no-speech"||e==="speech-timeout"?"noSpeech":"unavailable"}async function Ld(e){try{if((await e.getPermissionsAsync()).granted)return"granted"}catch{}try{return(await e.requestPermissionsAsync()).granted?"granted":"denied"}catch{return"error"}}var Ed=55e3,Od=3e3,Ad=1e3;function jd(e){return Dd.has(e)||_d(e)}var Dd=/* @__PURE__ */new Set(["no-speech","speech-timeout","aborted","interrupted"]),Md=/* @__PURE__ */Object.freeze({committed:/* @__PURE__ */Object.freeze([]),interim:""});function Bd(e){return e.replace(/\s+/g," ").trim()}function Hd(e,t,r){let n=Bd(t);return r?n?{committed:[...e.committed,n],interim:""}:{committed:e.committed,interim:""}:{committed:e.committed,interim:n}}function Wd(e){return Bd([...e.committed,e.interim].join(" "))}function Nd(e,t,r,n=Date.now){let l=0,i=null,o=Number.NEGATIVE_INFINITY,a=e=>i!==null&&i.token===e?i:null;function s(e){for(let t of e.subscriptions)try{t.remove()}catch{}e.subscriptions=[]}function u(e){s(e),e.autoStopTimer!==null&&clearTimeout(e.autoStopTimer),e.graceTimer!==null&&clearTimeout(e.graceTimer),e.retryTimer!==null&&clearTimeout(e.retryTimer),e.autoStopTimer=null,e.graceTimer=null,e.retryTimer=null,i===e&&(i=null)}function d(e){return!e.sawStart&&e.errorCode===null&&e.pendingRetry===null&&Wd(e.transcript)===""&&e.launchedAt-o<Ad}function c(e){return e.mode??"none"}function p(e,t){$a(r(),"chat_dictation_completed",{mode:c(e),duration_ms:e.startedAt===null?0:Math.max(0,n()-e.startedAt),char_count:t.length})}function f(e,n){$a(r(),"chat_dictation_failed",{mode:c(e),error:n}),t.onStatus("idle"),t.onError(n)}function h(e){if(a(e.token)===null)return;u(e);let r=Wd(e.transcript),n=e.errorCode;if(n!==null&&!(r&&jd(n))){f(e,Fd(n));return}if(!r){f(e,"noSpeech");return}p(e,r),t.onStatus("idle")}function g(l){l.subscriptions=[e.addListener("start",()=>{a(l.token)!==null&&(l.sawStart=true,l.startedAt===null&&(l.startedAt=n()),$a(r(),"chat_dictation_started",{mode:c(l)}),t.onStatus("listening"))}),e.addListener("result",e=>{if(a(l.token)===null)return;let r=e?.results?.[0]?.transcript??"";l.transcript=Hd(l.transcript,r,e?.isFinal===true),t.onText(Wd(l.transcript))}),e.addListener("error",e=>{if(a(l.token)===null)return;let t=e?.error??"unknown";if(l.userStopped&&(t==="aborted"||_d(t)))return;let r=Wd(l.transcript)==="",n=l.mode!==null&&!l.userStopped&&r&&l.retries<Id?Pd(l.mode,l.lang,t):null;if(n!==null){l.pendingRetry=n;return}l.errorCode===null&&(l.errorCode=t)}),e.addListener("end",()=>{if(a(l.token)!==null&&!d(l)){if(l.pendingRetry!==null){let e=l.pendingRetry;if(l.pendingRetry=null,l.retries+=1,l.lang=e.lang,e.delayMs<=0){b(l,e.mode);return}s(l),l.retryTimer=setTimeout(()=>{l.retryTimer=null,!(a(l.token)===null||l.userStopped)&&b(l,e.mode)},e.delayMs);return}h(l)}})]}function b(t,r){s(t),t.mode=r,t.sawStart=false,t.launchedAt=n(),t.transcript=Md,t.errorCode=null,g(t);try{e.start(xd(r,t.lang,t.phrases))}catch{t.errorCode="unknown",h(t)}}async function m(t){let r=await Ld(e);if(a(t.token)===null)return;if(r!=="granted"){u(t),f(t,r==="denied"?"permissionDenied":"unavailable");return}if(t.lang=await wd(e,t.lang),a(t.token)===null)return;let n=await kd(e,t.lang);a(t.token)!==null&&(t.autoStopTimer=setTimeout(()=>y(t),Ed),b(t,n))}function y(r){if(!(a(r.token)===null||r.userStopped)){if(r.userStopped=true,r.pendingRetry=null,r.mode===null||r.retryTimer!==null){u(r),t.onStatus("idle");return}r.graceTimer=setTimeout(()=>h(r),Od);try{e.stop()}catch{h(r)}}}return{start(e){if(i!==null)return;let r={token:++l,phrases:e,lang:yd(),mode:null,retries:0,pendingRetry:null,userStopped:false,transcript:Md,errorCode:null,startedAt:null,sawStart:false,launchedAt:0,subscriptions:[],autoStopTimer:null,graceTimer:null,retryTimer:null};i=r,t.onStatus("starting"),m(r)},stop(){i!==null&&y(i)},cancel(){let r=i;if(r===null)return;let l=r.mode!==null&&r.retryTimer===null,a=Wd(r.transcript);if(u(r),t.onStatus("idle"),!!l){a&&p(r,a),o=n();try{e.abort()}catch{}}},isActive:()=>i!==null,isPreparing:()=>i!==null&&i.mode===null}}function Ud({enabled:e,input:t,setInput:r,phrases:u,maxLength:d,telemetry:c}){let p=s(dd,ud,ud),f=l(()=>e?fd():null,[e,p]),h=l(()=>hd(f),[f]),[g,b]=o("idle"),[m,y]=o(null),[v,w]=o(0),C=i(t);C.current=t;let S=i(r);S.current=r;let x=i(c);x.current=c;let R=i(""),T=i(d);T.current=d;let _=i(null);f!==null&&_.current?.mod!==f&&(_.current?.controller.cancel(),_.current={mod:f,controller:Nd(f,{onStatus:e=>{b(t=>e==="idle"&&t==="error"?t:e)},onText:e=>S.current(Wa(R.current,e,T.current)),onError:e=>{y(e),b("error")}},()=>x.current)});let z=f===null?null:_.current?.controller??null,I=n(()=>{z?.cancel()},[z]),P=n(()=>{if(z!==null){if(z.isActive()){z.stop();return}y(null),w(0),R.current=C.current,z.start(u)}},[z,u]);a(()=>{if(g!=="listening")return;let e=Date.now();w(0);let t=setInterval(()=>w(Date.now()-e),1e3);return()=>clearInterval(t)},[g]),a(()=>{if(g!=="error")return;let e=setTimeout(()=>{y(null),b("idle")},Ha);return()=>clearTimeout(e)},[g]),a(()=>{if(z===null)return;let e=null;try{e=k.addEventListener("change",e=>{e==="background"&&!z.isPreparing()&&z.cancel()})}catch{}return()=>{e?.remove(),z.cancel()}},[z]);let F=e&&h;return a(()=>{F||z?.cancel()},[F,z]),{supported:F,status:g,active:g==="starting"||g==="listening",error:m,elapsedMs:v,toggle:P,cancel:I}}var $d=/* @__PURE__ */Symbol.for("everfur.sdk.rn.chatPaneShown");function Vd(){let e=globalThis,t=e[$d];if(t!==void 0)return t;let r=createContext(true);return e[$d]=r,r}var qd=Vd();function Gd(){return u(qd)}var Kd=/* @__PURE__ */Object.freeze(["photo"]),Yd=52,Qd=1.5,Zd=10,Jd=14,Xd=10,ec=40,tc=20,rc=.3,nc=2.5,lc=1,ic=1.5,oc=38,ac=22,sc=3;function uc(e,t,r,n="ask",l=false){let i=typeof t=="string"&&t.trim()!=="";return r&&i&&n!=="urgent"?it(rt.placeholder,t):e!==null?!l||!e.includes("{pet}")?e:i?e.split("{pet}").join(t.trim()):it(rt.placeholder,t):n==="urgent"?rt.placeholderUrgentWeb:n==="followUp"?rt.placeholderFollowUpWeb:it(rt.placeholder,t)}function ComposerWithAttachments({attachments:e,...t}){let r=l(()=>createRnChatAttachmentTransport(),[]),n=useChatAttachments({maxPerMessage:e.maxPerMessage??Sa,transport:r}),i=l(()=>({state:n,sources:e.sources??Kd,pick:e.pick}),[n,e.sources,e.pick]);/* @__PURE__ */
|
|
111
|
+
return f(Composer,{...t,attachments:i})}function Composer({send:e,stop:t,isStreaming:r,conversationId:conversationId,attachments:s,seed:u,draftStore:d,onStage:c,onPreview:p,petName:b,petBreed:m=null,mood:y="ask",dictation:v=false,telemetry:w=null,compact:k=false,petPlaceholder:C=false,dimEmptySend:x=false}){let{theme:R,styles:_}=Yu(),z=l(()=>gc(R),[R]),I=l(()=>bc(R),[R]),P=Mo(),[F,L]=Ga(e,conversationId,u),[E,O]=o(false),[A,j]=o(false),D=n(()=>j(true),[]),M=n(()=>j(false),[]),[B,H]=o(false);a(()=>{H(false)},[conversationId]);let W=uc(R.meta.placeholder,b,C,y,R.meta.placeholderFillsPet===true),N=l(()=>qa({name:b,breed:m}),[b,m]),U=Ud({enabled:v,input:F,setInput:L,phrases:N,maxLength:wa,telemetry:w}),$=U.cancel,V=U.active;Ka(d,conversationId===null?null:String(conversationId),F,L,V);let q=i(conversationId);a(()=>{q.current!==conversationId&&(q.current=conversationId,$())},[conversationId,$]);let G=Gd();a(()=>{G||$()},[G,$]);let K=s?.state.uploading??false,Y=s?.state.failed??false,Q=K||Y,Z=s?.state.attachments??dc;ta(Z.length,P);let J=n(()=>{let t=F.trim();if(t.length===0||Q||[...t].length>wa)return;V&&$();let r=s?.state.s3Keys??cc;s!==null&&r.length>0?(c(s.state.attachments.filter(e=>e.status==="uploaded").map(e=>({uri:e.previewUri,filename:e.filename}))),e(t,{imageS3Keys:r}),s.state.clear()):e(t),L(""),H(false)},[F,e,Q,V,$,s,c]),X=n(e=>{V&&$(),L(e)},[V,$,L]),ee=n(()=>{t()},[t]),te=n(e=>{O(false),s!==null&&(H(false),s.state.dismissRejected(),fn(s.pick,e).then(e=>{if(!e.ok){H(true);return}e.value!==null&&s.state.add(e.value)}))},[s]),re=l(()=>[...F.trim()].length>wa,[F]),ne=re||Q||F.trim().length===0,le=re||Q||x&&F.trim().length===0,ie=s!==null&&Z.length>=s.state.maxPerMessage,oe=R.slots.sendButton?.textColor??R.color.brandInk,ae=R.slots.sendButton?.textColor??R.color.surface;/* @__PURE__ */
|
|
112
|
+
return h(S,{style:_.composerOuter,children:[s!==null&&E?/* @__PURE__ */f(AttachmentPickerPopover,{sources:s.sources,full:ie,onPick:te,onClose:()=>O(false)}):null,s!==null?/* @__PURE__ */f(AttachmentStrip,{attachments:Z,rejected:B?hc:s.state.rejected,uploadFailed:Y,onRetry:s.state.retry,onRemove:s.state.remove,onPreview:e=>p({uri:e.previewUri,label:e.filename}),style:k?z.tray:I.tray}):null,
|
|
113
|
+
/* @__PURE__ */h(S,{style:k?[_.composer,z.bar,A?z.barFocused:null]:_.composer,children:[U.supported&&U.error!==null?/* @__PURE__ */h(g,{children:[
|
|
114
|
+
/* @__PURE__ */f(Text,{style:_.dictationError,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:Ua(U.error)}),
|
|
115
|
+
/* @__PURE__ */f(AnnounceLine,{line:Ua(U.error)})]}):null,
|
|
116
|
+
/* @__PURE__ */h(S,{style:_.composerRow,children:[s!==null?/* @__PURE__ */f(T,{accessibilityRole:"button",accessibilityLabel:ie?Ma(Z.length,s.state.maxPerMessage):rt.attachPhotoOrFileNative,accessibilityState:{disabled:ie,expanded:E},disabled:ie,style:[_.attachControl,k?z.add:null,ie?_.attachControlDisabled:null],hitSlop:k?sc:void 0,onPress:()=>O(e=>!e),children:/* @__PURE__ */f(UploadGlyph,{size:k?ac:Tu,color:ie?R.color.text.muted:k?R.color.text.primary:R.color.brandInk,strokeWidth:1.75})}):null,
|
|
117
|
+
/* @__PURE__ */f(Oe,{style:k?[_.input,z.input]:_.input,onFocus:D,onBlur:M,value:F,onChangeText:X,placeholder:W,placeholderTextColor:R.slots.composerInput?.textColor??R.color.text.placeholder,accessibilityLabel:rt.composerLabel,onSubmitEditing:J,returnKeyType:"send",...pc,...k?fc:null,blurOnSubmit:false,multiline:true,editable:true}),U.supported?/* @__PURE__ */f(DictationButton,{active:U.active,listening:U.status==="listening",elapsedMs:U.elapsedMs,onToggle:U.toggle}):null,r?/* @__PURE__ */f(T,{onPress:ee,accessibilityRole:"button",accessibilityLabel:rt.stop,style:_.sendControl,children:/* @__PURE__ */f(S,{style:k?z.disc:_.sendDisc,testID:"everfur-stop-disc",children:/* @__PURE__ */f(StopGlyph,{size:k?tc:Su,color:k?ae:oe,testID:"everfur-stop-glyph"})})}):/* @__PURE__ */f(T,{onPress:J,disabled:ne,accessibilityRole:"button",accessibilityLabel:rt.send,accessibilityState:{disabled:ne,busy:K},style:[_.sendControl,le?k?z.dimmed:_.sendControlDisabled:null],children:k?/* @__PURE__ */f(S,{style:z.disc,testID:"everfur-send-disc",children:/* @__PURE__ */f(ArrowUpGlyph,{size:tc,color:ae,strokeWidth:2.25,testID:"everfur-send-arrow"})}):/* @__PURE__ */f(S,{style:_.sendDisc,testID:"everfur-send-disc",children:/* @__PURE__ */f(SendGlyph,{size:Cu,color:oe,testID:"everfur-send-glyph"})})})]})]})]})}var dc=/* @__PURE__ */Object.freeze([]),cc=/* @__PURE__ */Object.freeze([]),pc=/* @__PURE__ */Object.freeze({submitBehavior:"submit"}),fc=/* @__PURE__ */Object.freeze(w.OS==="web"?{rows:1}:{}),hc=/* @__PURE__ */Object.freeze({code:"unknown",retryable:true,filename:""});function gc(e){let t=e.color,r=e.slots.sendButton,n=textRole(e,"body").fontSize+lc;return v.create({bar:{marginTop:Zd,marginHorizontal:Jd,marginBottom:Xd,minHeight:Yd,paddingLeft:8,paddingRight:6,paddingVertical:0,borderWidth:Qd,borderColor:e.slots.composerInput?.borderColor??t.text.primary},barFocused:{borderWidth:nc,paddingLeft:8-(nc-Qd),paddingRight:6-(nc-Qd)},input:{fontSize:n,lineHeight:Math.round(n*ic),minHeight:Math.round(n*ic),...w.OS==="web"?{outlineStyle:"none"}:null},add:{width:oc,height:oc,borderRadius:oc/2},disc:{width:ec,height:ec,borderRadius:ec/2,alignItems:"center",justifyContent:"center",backgroundColor:r?.backgroundColor??t.text.primary,...pa(r)},dimmed:{opacity:rc},tray:{marginHorizontal:Jd,marginTop:Zd,paddingBottom:0}})}function bc(e){return v.create({tray:{marginHorizontal:e.space.md,marginTop:e.space.xs,paddingBottom:0}})}var mc=/* @__PURE__ */new WeakMap;function yc(e,t){let r=mc.get(e);return r===void 0&&(r=/* @__PURE__ */new Set,mc.set(e,r)),r.add(t),()=>{r?.delete(t)}}function useEverfurPets(){let{runtime:e,userRef:userRef,activePet:t,scopeEpoch:r}=ct(),s=l(()=>createPetsRepository(e.registry.services.authFor(userRef)),[e,userRef,r]),[u,d]=o({repository:s,pets:[],loading:true,error:null}),c=u.repository===s?u:{pets:[],loading:true,error:null},p=i(0),f=n(async()=>{let e=++p.current;d(e=>({...e,repository:s,loading:true,error:null,pets:e.repository===s?e.pets:[]}));let t=await s.list();e===p.current&&d(t.ok?{repository:s,pets:t.value,loading:false,error:null}:e=>({repository:s,pets:e.repository===s?e.pets:[],loading:false,error:t.error}))},[s]);a(()=>(f(),()=>{p.current+=1}),[f]),a(()=>yc(e,()=>{f()}),[e,f]);let h=l(()=>t===null?null:c.pets.find(e=>e.petRef===t)??null,[t,c.pets]);return l(()=>({pets:c.pets,activePet:h,loading:c.loading,error:c.error,refresh:f}),[c.pets,c.loading,c.error,h,f])}function vc(e,t){if(t!==null){let r=e.find(e=>e.petRef===t);if(r!==void 0)return r}return e[0]??null}var wc=/* @__PURE__ */Object.freeze({visitButton:"Vet"});var kc=false;function Cc(e,t){return t!==void 0?(dn(t,e),"onStartInApp"):V(e)==="presented"?"presenter":Y(e)?"experience":(kc||(kc=true,console.warn("[everfur] A vet visit had nowhere to open: mount <EverfurTelevetHost /> in your EverfurProvider, or pass prefer: 'redirect'.")),null)}var Sc=/* @__PURE__ */Object.freeze(["visit","join","summary","messages"]);function isVetVisitIntent(e){return typeof e=="string"&&Sc.includes(e)}var xc="/widget/v1/televet/handoffs",Rc="/widget/v1/televet/availability",Tc="/widget/v1/televet/chat-entry",_c=/^[a-z0-9][a-z0-9_-]{0,39}$/,zc=/^[A-Za-z0-9_-]{22}$/;var Ic=32,Pc=128,Fc=64;function vetVisitErrorReasonOf(e){let t=e.httpStatus;switch(e.code){case"sessionRequired":return"sessionRequired";case"authExpired":case"authRejected":return"authRejected";case"sdkUpdateRequired":return"sdkUpdateRequired";case"validationFailed":return"invalidRequest";case"rateLimited":case"quotaExceeded":return"rateLimited"}return t===void 0?e.code==="internalError"?"network":"unknown":t===429?"rateLimited":t===404?"unavailable":t===403?"accessDenied":t===401?"authRejected":t===400||t===422?"invalidRequest":t>=500?"serverError":"unknown"}function Lc(e){return err(makeEverfurError("validationFailed",{retryable:false,wireMessage:e}))}function Ec(e){return err(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}function Oc(petRef,e){let t={};petRef!==void 0&&(t.pet_ref=petRef);let r=e?.returnTo;if(r!=null){if(typeof r!="string"||!_c.test(r))return{ok:false,message:"returnTo must be a registered return destination key"};t.return_to=r}let n=e?.entry;if(n!=null){if(n!=="chat"||petRef===void 0)return{ok:false,message:"entry 'chat' needs the pet the chat is about"};t.entry=n}let l=e?.visitRef,i=e?.intent,o=l!=null;if(o){let e=typeof l=="string"?l.trim():"";if(e.length<1||[...e].length>Fc)return{ok:false,message:`visitRef must be 1..${Fc} characters`};t.visit_ref=e}if(i!=null){if(!o)return{ok:false,message:"intent needs the visitRef it opens"};if(!isVetVisitIntent(i))return{ok:false,message:`intent must be one of ${Sc.join(", ")}`};t.intent=i}return{ok:true,body:t}}function Ac(e){if(typeof e!="object"||e===null)return null;let{visit_ref:t,intent:r}=e;return typeof t!="string"||t.length===0||!isVetVisitIntent(r)?null:/* @__PURE__ */Object.freeze({visitRef:t,intent:r})}function jc(e){let t=e.funnel??createRequestFunnel({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e.telemetry,n=e=>(Nc(r,"televet.visit.handoff_failed",{reason:vetVisitErrorReasonOf(e)}),err(e));return{async createHandoff(petRef,e){let l;if(petRef!=null){let e=typeof petRef=="string"?[...petRef].length:0;if(e<1||e>Pc)return n(makeEverfurError("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${Pc} characters`}));l=petRef}let i=Oc(l,e);if(!i.ok){let e=Lc(i.message);return e.ok?e:n(e.error)}let o=i.body,a=await t.send("televet.visit.handoff",{method:"POST",path:xc,body:o},{idempotent:false,maxAttempts:1});if(!a.ok)return n(a.error);let s=Dc(a.value),u=o.return_to!==void 0,d=u?a.value?.flow_id:void 0;if(u&&(typeof d!="string"||!zc.test(d))){let e=Ec("the handoff response carried no usable return flow id");return e.ok?e:n(e.error)}let c=o.visit_ref!==void 0,p=c?Ac(a.value?.visit):null;if(c&&p===null){let e=Ec("the handoff response did not confirm the visit it opens");return e.ok?e:n(e.error)}let f=s===null?null:/* @__PURE__ */Object.freeze({...s,...u?{flowId:d}:{},...p!==null?{visit:p}:{}});return f===null?n(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(Nc(r,"televet.visit.handoff_created",{pet_scoped:o.pet_ref!==void 0}),ok(f))},async checkAvailability(e){if(typeof e!="string"||e.length>Ic)return Lc(`state must be at most ${Ic} characters`);let r=await t.send("televet.visit.availability",{method:"POST",path:Rc,body:{state:e}},{idempotent:false,maxAttempts:1});if(!r.ok)return err(r.error);let n=r.value?.available;return typeof n!="boolean"?Ec("the availability response carried no usable answer"):ok(/* @__PURE__ */Object.freeze({available:n}))},async chatEntryOpen(){try{let e=await t.send("televet.visit.chat_entry",{method:"GET",path:Tc},{maxAttempts:1});return e.ok&&e.value?.open===!0}catch{return false}}}}function Dc(e){if(typeof e!="object"||e===null)return null;let{url:t,expires_at:r}=e;return typeof t!="string"||typeof r!="string"||r.length===0||!Wc(t)?null:/* @__PURE__ */Object.freeze({url:t,expiresAt:r})}var Mc=/* @__PURE__ */new Set(["localhost","127.0.0.1","[::1]"]),Bc=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,Hc=/[\s\u0000-\u001f\u007f]/;function Wc(e){if(Hc.test(e))return false;let t=Bc.exec(e);if(t===null)return false;let r=(t[1]??"").toLowerCase(),n=t[2]??"";if(n.length===0||n.includes("@"))return false;let l=n.replace(/:\d+$/,"").toLowerCase(),i=r==="https",o=r==="http"&&Mc.has(l);if(!i&&!o)return false;let a=e.indexOf("#");if(a<0)return false;let s=e.slice(a);return s.startsWith("#h=")&&s.length>3}function Nc(e,t,r){if(e)try{e.track(t,r)}catch{}}var Uc=/* @__PURE__ */Object.freeze({status:"idle",error:null,errorReason:null});function $c(e,t,r){let{usState:n,chat:l,scope:i}=r,s=t&&(n!==null||l),u=`${n??""}|${l?"chat":""}`,[d,c]=o(null);if(a(()=>{if(!s)return;let t=true,r=e.current;return c(null),(async()=>{try{if(l&&!(r.chatEntryOpen&&await r.chatEntryOpen()))return!1;if(n===null)return!0;if(!r.checkAvailability)return!1;let e=await r.checkAvailability(n);return e.ok&&e.value.available}catch{return false}})().then(e=>{t&&c({key:u,open:e})}),()=>{t=false}},[s,u,n,l,i,e]),!s)return null;let p=d!==null&&d.key===u;return{open:p&&d.open,pending:!p}}var Vc=/* @__PURE__ */Object.freeze({status:"opening",error:null,errorReason:null});function qc(e,t={}){let{runtime:r,userRef:userRef,scopeEpoch:a}=ct(),s=useCapability("televet"),u=s.enabled&&userRef!==null,d=t.usState??null,c=t.entry==="chat",p=t.petRef??null,f=t.prefer==="redirect",h=l(()=>{if(t.controller)return t.controller;let{services:e}=r.registry;return jc({auth:e.authFor(userRef),telemetry:e.telemetry,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}})},[r,userRef,a,t.controller]),g=i(h);g.current=h;let b=l(()=>({runtime:r,userRef:userRef,scopeEpoch:a}),[r,userRef,a]),m=$c(g,u,{usState:d,chat:c,scope:b}),y=u&&(m===null||m.open)&&(!c||p!==null),v=t.returnTo??null,[w,k]=o(Uc),C=i(null),S=i({runtime:r,userRef:userRef,scopeEpoch:a});S.current={runtime:r,userRef:userRef,scopeEpoch:a};let x=i(h);x.current=h;let R=i(y);R.current=y;let T=n((petRef,t)=>{if(C.current)return C.current;let r=(e,t)=>(k({status:e==="cancelled"?"idle":"error",error:t,errorReason:e==="cancelled"?null:e}),/* @__PURE__ */Object.freeze({opened:false,reason:e,error:t}));if(!R.current)return Promise.resolve(r("unavailable",null));let n=e.prepare();if(!n.ok)return Promise.resolve(r(n.reason,null));let l=S.current,i=x.current;k(Vc);let o=(async()=>{let o,a={...v!==null?{returnTo:v}:{},...c?{entry:"chat"}:{},...t!==null?{visitRef:t.visitRef}:{},...t!==null&&t.intent!==null&&t.intent!==void 0?{intent:t.intent}:{}},s=Object.keys(a).length===0?void 0:a,u=petRef===void 0?p:petRef;try{o=await(s===void 0?i.createHandoff(u):i.createHandoff(u,s))}catch{return e.abandon(n.value),r("unknown",null)}let d=S.current;if(d.runtime!==l.runtime||d.userRef!==l.userRef||d.scopeEpoch!==l.scopeEpoch)return e.abandon(n.value),r("cancelled",null);if(!o.ok)return e.abandon(n.value),r(vetVisitErrorReasonOf(o.error),o.error);let f=await e.finish(n.value,o.value);return f!==null?r(f,null):(k(Uc),/* @__PURE__ */Object.freeze(o.value.flowId===void 0?{opened:true}:{opened:true,flowId:o.value.flowId}))})().finally(()=>{C.current===o&&(C.current=null)});return C.current=o,o},[e,p,v,c]),_=n((petRef,e)=>{if(!R.current)return k({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}));let t=petRef===void 0?p:petRef,r={...t!==null?{petRef:t}:{},...d!==null?{usState:d}:{},...e!==null&&"consultId"in e?{consultId:e.consultId}:{},...e!==null&&"visitRef"in e?{visitRef:e.visitRef,intent:e.intent}:{}};return Cc(r)===null?(k({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}))):(k(Uc),Promise.resolve(/* @__PURE__ */Object.freeze({opened:true})))},[p,d]),z=n(petRef=>f?T(petRef,null):_(petRef,null),[f,T,_]),I=n((e,t)=>f?T(void 0,{visitRef:e,intent:t??null}):_(void 0,{visitRef:e,intent:t??null}),[f,T,_]),P=n(e=>f?T(void 0,null):_(void 0,{consultId:e.trim()}),[f,T,_]);return{available:y,isPending:s.isPending||(m?.pending??false),status:w.status,error:w.error,errorReason:w.errorReason,open:z,openVisit:I,joinVisit:P}}var Gc=e=>x.openURL(e);function useVetVisit(e={}){let{openUrl:t,...r}=e,n=l(()=>{let e=t??Gc;return{prepare:()=>({ok:true,value:null}),async finish(t,r){try{return await e(r.url),null}catch{return"openFailed"}},abandon:()=>{}}},[t]);return qc(n,r)}var Kc=44,Yc=.6;function VetVisitButtonCore(e){let{petRef:petRef,label:t,openUrl:r,onOpened:n,onError:o,style:a,labelStyle:s,controller:u,returnTo:d,usState:c,entry:p,visitRef:b,intent:m,onStartInApp:y,prefer:v}=e,w=v==="redirect",k=useVetVisit({...d!==void 0?{returnTo:d}:{},...c!==void 0?{usState:c}:{},...p!==void 0?{entry:p}:{},...petRef!==void 0?{petRef:petRef}:{},...r!==void 0?{openUrl:r}:{},...u!==void 0?{controller:u}:{},prefer:w?"redirect":"in-app"}),C=useEverfurTheme(),S=l(()=>Qc(C),[C]),x=i(false);if(!k.available)/* @__PURE__ */
|
|
118
|
+
return h(g,{children:[null,
|
|
119
|
+
/* @__PURE__ */f(TelevetHostOutlet,{})]});let R=k.status==="opening",_=t??wc.visitButton;/* @__PURE__ */
|
|
120
|
+
return h(g,{children:[
|
|
121
|
+
/* @__PURE__ */f(T,{onPress:()=>{if(!(R||x.current)){if(!w){let e={...petRef!==void 0?{petRef:petRef}:{},...c!==void 0?{usState:c}:{},...b!=null?{visitRef:b,intent:m??null}:{}};Cc(e,y)===null&&dn(o,"unavailable",null);return}x.current=true,(b==null?k.open():k.openVisit(b,m??null)).then(e=>{e.opened?dn(n,e.flowId??null):e.reason!=="cancelled"&&dn(o,e.reason,e.error)}).finally(()=>{x.current=false})}},accessibilityRole:"button",accessibilityLabel:_,accessibilityState:{busy:R,disabled:R},style:[S.button,R?S.busy:null,a],children:/* @__PURE__ */f(Text,{style:[S.label,s],children:_})}),
|
|
122
|
+
/* @__PURE__ */f(TelevetHostOutlet,{})]})}function Qc(e){let{color:t,space:r,radius:n,type:l,slots:i}=e;return v.create({button:{minHeight:Kc,minWidth:Kc,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:n.pill,backgroundColor:t.primary,...pa(i.vetVisitButton)},busy:{opacity:Yc},label:{...face(e,"medium"),color:t.onPrimary,fontSize:l.size.body,lineHeight:l.size.body*l.lineHeight.snug,...ha(i.vetVisitButton)}})}function Zc(e){let[t,r]=o(null);return{shown:e!==null&&t!==e,onError:()=>r(e)}}function BrandImage({uri:e,label:t,decorative:r=false,style:n,resizeMode:l="contain",fallback:i=null,onError:o,testID:a}){let s=Zc(e);if(e===null||!s.shown)return i;let u=r?{accessible:false,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"}:{accessible:true,accessibilityRole:"image",...t===void 0?{}:{accessibilityLabel:t}};/* @__PURE__ */
|
|
123
|
+
return f(L,{source:{uri:e},style:n,resizeMode:l,...u,onError:()=>{s.onError(),o?.()},...a===void 0?{}:{testID:a}})}function BrandLogo({logoUrl:e,name:t,barStyle:r,logoStyle:n,testID:l}){let i=Zc(e);return e===null||!i.shown?null:/* @__PURE__ */f(S,{style:r,...l===void 0?{}:{testID:l},children:/* @__PURE__ */f(L,{source:{uri:e},style:n,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:t,onError:i.onError})})}var Jc=/* @__PURE__ */Object.freeze({row:null,leading:null,trailing:null}),Xc=/* @__PURE__ */Object.freeze({leading:void 0,trailing:void 0});function ep(e,t,r){if(e.row===null||e.leading===null||e.trailing===null)return Xc;let n=Math.abs(e.leading-e.trailing);if(n<.5)return Xc;let l=e.row-t-e.leading-e.trailing,i=Math.min(n,Math.max(0,l-r));return i<.5?Xc:e.leading<e.trailing?{leading:e.leading+i,trailing:void 0}:{leading:void 0,trailing:e.trailing+i}}function tp(e,t,r){let n=e[t];return n!==null&&Math.abs(n-r)<.5?e:{...e,[t]:r}}function rp(e){return[e.surface,e.surfaceCream,e.surfaceSubtle,e.background,e.chatGround,e.composerFill]}function np(e){if(e.brightness!=="light")return false;let t=_e.color,r=e.color,n=(e,t)=>parseColor(e)===parseColor(t),l=new Set(rp(t));return n(r.brand,t.brand)&&n(r.accent,t.accent)&&rp(r).every(e=>l.has(e))}function lp(e){let t=(e.brightness==="dark"?Ie:_e).color,r=e.color,n=(e,t)=>parseColor(e)===parseColor(t);return{success:!n(r.success,t.success),warning:!n(r.warningStrong,t.warningStrong)||!n(r.cautionAccent,t.cautionAccent),info:!(n(r.info,r.brandInk)&&n(r.badgeBgInfo,r.brandSoft)&&n(r.infoEdge,r.structureEdge))}}function ip(e){return canonicalPetSpecies(e)==="cat"?"cat":"dog"}function op(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:Math.floor(e)}function ap(e){let t=op(e.ageYears),r=ip(e.species)==="cat"?"Cat":"Dog";if(t==null)return r;let n=t===1?"1 yr":`${t} yrs`;return`${r} · ${n}`}var sp=/* @__PURE__ */Object.freeze([
|
|
124
124
|
/* @__PURE__ */Object.freeze({background:"#ffbdbd",foreground:"#6d1d14"}),
|
|
125
125
|
/* @__PURE__ */Object.freeze({background:"#a0c4f6",foreground:"#0b3a73"}),
|
|
126
126
|
/* @__PURE__ */Object.freeze({background:"#fbc558",foreground:"#10462e"}),
|
|
127
127
|
/* @__PURE__ */Object.freeze({background:"#bde7c5",foreground:"#0e3b22"}),
|
|
128
128
|
/* @__PURE__ */Object.freeze({background:"#dcc7f4",foreground:"#3a1d6a"}),
|
|
129
|
-
/* @__PURE__ */Object.freeze({background:"#ffd8a8",foreground:"#5a2a04"})]);function
|
|
130
|
-
return
|
|
131
|
-
/* @__PURE__ */
|
|
132
|
-
/* @__PURE__ */
|
|
133
|
-
/* @__PURE__ */
|
|
134
|
-
/* @__PURE__ */
|
|
135
|
-
return
|
|
136
|
-
/* @__PURE__ */
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
/* @__PURE__ */
|
|
139
|
-
/* @__PURE__ */
|
|
140
|
-
/* @__PURE__ */
|
|
141
|
-
/* @__PURE__ */
|
|
142
|
-
/* @__PURE__ */
|
|
143
|
-
return
|
|
144
|
-
/* @__PURE__ */
|
|
145
|
-
/* @__PURE__ */
|
|
146
|
-
/* @__PURE__ */
|
|
147
|
-
/* @__PURE__ */
|
|
148
|
-
/* @__PURE__ */
|
|
149
|
-
/* @__PURE__ */
|
|
150
|
-
/* @__PURE__ */
|
|
151
|
-
/* @__PURE__ */
|
|
152
|
-
/* @__PURE__ */
|
|
153
|
-
/* @__PURE__ */
|
|
154
|
-
/* @__PURE__ */
|
|
155
|
-
return
|
|
156
|
-
/* @__PURE__ */Object.freeze({key:"inaccurate",label:
|
|
157
|
-
/* @__PURE__ */Object.freeze({key:"outdated",label:
|
|
158
|
-
/* @__PURE__ */Object.freeze({key:"unsafe",label:
|
|
159
|
-
/* @__PURE__ */Object.freeze({key:"unclear",label:
|
|
160
|
-
/* @__PURE__ */Object.freeze({key:"other",label:
|
|
161
|
-
/* @__PURE__ */Object.freeze({sentiment:"up",label:
|
|
162
|
-
/* @__PURE__ */Object.freeze({sentiment:"down",label:
|
|
163
|
-
return
|
|
164
|
-
/* @__PURE__ */
|
|
165
|
-
/* @__PURE__ */
|
|
166
|
-
/* @__PURE__ */
|
|
167
|
-
/* @__PURE__ */
|
|
168
|
-
/* @__PURE__ */
|
|
169
|
-
/* @__PURE__ */
|
|
170
|
-
/* @__PURE__ */
|
|
171
|
-
/* @__PURE__ */
|
|
172
|
-
/* @__PURE__ */
|
|
173
|
-
return
|
|
174
|
-
/* @__PURE__ */
|
|
175
|
-
/* @__PURE__ */
|
|
176
|
-
/* @__PURE__ */
|
|
177
|
-
/* @__PURE__ */
|
|
178
|
-
/* @__PURE__ */
|
|
179
|
-
/* @__PURE__ */
|
|
180
|
-
/* @__PURE__ */
|
|
181
|
-
return
|
|
182
|
-
/* @__PURE__ */
|
|
183
|
-
/* @__PURE__ */
|
|
184
|
-
/* @__PURE__ */
|
|
185
|
-
/* @__PURE__ */
|
|
186
|
-
/* @__PURE__ */
|
|
187
|
-
/* @__PURE__ */
|
|
188
|
-
/* @__PURE__ */
|
|
189
|
-
/* @__PURE__ */
|
|
190
|
-
/* @__PURE__ */
|
|
191
|
-
/* @__PURE__ */
|
|
192
|
-
/* @__PURE__ */
|
|
193
|
-
/* @__PURE__ */
|
|
194
|
-
return
|
|
195
|
-
/* @__PURE__ */
|
|
196
|
-
/* @__PURE__ */
|
|
197
|
-
/* @__PURE__ */
|
|
198
|
-
/* @__PURE__ */
|
|
199
|
-
/* @__PURE__ */
|
|
200
|
-
/* @__PURE__ */
|
|
201
|
-
/* @__PURE__ */
|
|
202
|
-
/* @__PURE__ */
|
|
203
|
-
/* @__PURE__ */
|
|
204
|
-
/* @__PURE__ */
|
|
205
|
-
/* @__PURE__ */
|
|
206
|
-
return
|
|
207
|
-
/* @__PURE__ */
|
|
208
|
-
/* @__PURE__ */
|
|
209
|
-
return
|
|
210
|
-
/* @__PURE__ */
|
|
211
|
-
/* @__PURE__ */
|
|
212
|
-
/* @__PURE__ */
|
|
213
|
-
/* @__PURE__ */
|
|
214
|
-
/* @__PURE__ */
|
|
215
|
-
/* @__PURE__ */
|
|
216
|
-
/* @__PURE__ */
|
|
217
|
-
/* @__PURE__ */
|
|
218
|
-
/* @__PURE__ */
|
|
219
|
-
/* @__PURE__ */
|
|
220
|
-
/* @__PURE__ */
|
|
221
|
-
return
|
|
222
|
-
/* @__PURE__ */
|
|
223
|
-
/* @__PURE__ */
|
|
224
|
-
/* @__PURE__ */
|
|
225
|
-
/* @__PURE__ */
|
|
226
|
-
/* @__PURE__ */
|
|
227
|
-
/* @__PURE__ */
|
|
228
|
-
return
|
|
229
|
-
/* @__PURE__ */
|
|
230
|
-
/* @__PURE__ */
|
|
231
|
-
/* @__PURE__ */
|
|
232
|
-
/* @__PURE__ */
|
|
233
|
-
/* @__PURE__ */
|
|
234
|
-
return
|
|
235
|
-
/* @__PURE__ */
|
|
236
|
-
/* @__PURE__ */c(Text,{tier:"control",style:o.pillText,numberOfLines:1,children:a})]})}var _h=4,HOME_CLOSE_GLYPH=e=>{let t=e.icon(".ask-focus__x svg").width;return typeof t=="number"?t:wh};function zh(e){let t=e.text(".hp-need__s",".ask-focus .hp-need__s"),r=typeof t.lineHeight=="number"?t.lineHeight:21,n=e.view(".dot",".dot--risk"),l=typeof n.height=="number"?n.height:kh;return{card:e.view(".ask-focus"),kickerRow:e.view(".hp-need__k"),kicker:[e.text(".hp-need__k"),{flexShrink:1}],badge:[e.view(".hp-srcs"),e.view(".hp-src",".hp-src--dna"),{flexShrink:1}],badgeText:e.text(".hp-src",".hp-src--dna"),close:e.view(".ask-focus__x"),title:[e.view(".ask-focus h3"),e.text(".ask-focus h3")],finding:[e.view(".hp-need__s"),{alignItems:"flex-start"}],dot:[e.col(".hp-need__s",0),n,{marginTop:Math.round((r-l)/2)}],findingText:[e.col(".hp-need__s",1),t],lead:(({fontFamily:e,fontWeight:t,color:r})=>({fontFamily:e,fontWeight:t,color:r}))(e.strong(".hp-need__s b")),actions:e.view(".ask-focus__acts"),action:[e.view(".emb-btn",".emb-btn--sm"),{maxWidth:"100%"}],actionText:e.text(".emb-btn",".emb-btn--sm"),ask:[e.view(".ask-focus__q"),{justifyContent:"center",maxWidth:"100%"}],askText:e.text(".ask-focus__q"),pill:[e.view(".ask-focus-pill"),{maxWidth:"100%"}],pillDot:e.view(".ask-focus-pill i"),pillText:[e.text(".ask-focus-pill"),{flexShrink:1}]}}function Ih(e){let t=e.color,r=e.space;return y.create({card:{paddingTop:uh,paddingHorizontal:dh,paddingBottom:dh,borderRadius:sh,backgroundColor:t.surface,borderWidth:1,borderColor:t.borderRingCream,alignSelf:"stretch"},kickerRow:{flexDirection:"row",alignItems:"center",gap:r.sm,minHeight:Xs-8},kicker:{...ah(e),fontSize:fh,color:t.text.primary,flexShrink:1},badge:{marginLeft:"auto",minHeight:gh,justifyContent:"center",paddingHorizontal:9,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,flexShrink:1},badgeText:{...face(e,"bold"),fontSize:hh,color:t.text.secondary},close:{width:Xs,height:Xs,marginVertical:-4,marginRight:-10,alignItems:"center",justifyContent:"center",borderRadius:Xs/2},title:{...ah(e),fontSize:ch,lineHeight:ph,color:t.text.primary,marginTop:r.xs},finding:{flexDirection:"row",gap:r.sm,marginTop:r.xs+2},dot:{width:kh,height:kh,borderRadius:kh/2,marginTop:7,backgroundColor:t.danger},findingText:{...face(e,"regular"),flex:1,fontSize:yh,lineHeight:mh,color:t.text.primary},lead:face(e,"bold"),actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.lg,marginTop:14},action:{minHeight:Math.max(Th,Xs),paddingHorizontal:r.lg,borderRadius:e.radius.pill,backgroundColor:t.primary,alignItems:"center",justifyContent:"center",maxWidth:"100%"},actionText:{...face(e,"bold"),fontSize:bh,color:t.onPrimary},ask:{minHeight:Xs,justifyContent:"center",maxWidth:"100%"},askText:{...face(e,"bold"),fontSize:vh,color:t.brandInk,textDecorationLine:"underline"},pill:{flexDirection:"row",alignItems:"center",gap:r.sm,minHeight:Math.max(Ch,Xs),paddingHorizontal:Sh,borderRadius:e.radius.pill,backgroundColor:t.badgeBgCritical,alignSelf:"flex-start",maxWidth:"100%"},pillDot:{width:Rh,height:Rh,borderRadius:Rh/2,backgroundColor:t.danger},pillText:{...face(e,"bold"),fontSize:xh,color:t.danger,flexShrink:1}})}var Ph=/* @__PURE__ */Object.freeze({ink:"#262523",ink2:"#4A4845",ink3:"#6B6863",paper:"#F8F7F4",card:"#FFFFFF",line:"#E7E6E2",tile:"#F2F1EE",shadow:"rgba(38, 37, 35, .07)",riskBg:"#FFE3E1",riskInk:"#B0231B",riskDot:"#E5372B",clearBg:"#E6F4D3",clearInk:"#2F6A12",clearDot:"#5FA82B",watchDot:"#E5A000"}),Fh=/* @__PURE__ */new WeakMap;function Lh(e){let t=Fh.get(e);if(t!==void 0)return t;let r=e.color,n=e.brightness==="dark",l=n?{dark:n,ink:r.text.primary,ink2:r.text.secondary,ink3:r.text.muted,paper:r.background,card:r.surface,line:r.borderRingCream,tile:r.surfaceSubtle,shadow:r.shadow,riskBg:r.badgeBgCritical,riskInk:r.danger,riskDot:r.danger,clearBg:r.badgeBgPositive,clearInk:r.success,clearDot:r.success,watchDot:r.warningStrong}:{dark:n,...Ph},i=(e,t)=>Cs(e,t,hs(t),Eh),o=(e,t)=>contrastRatio(e,t)>=Eh?e:fs(t,Eh),a=[l.card,l.paper].map(e=>vs(r.brandSoft,e)??e),s={primary:r.primary,onPrimary:o(r.onPrimary,r.primary),accent:r.accent,onAccent:o(r.onAccent,r.accent),link:i(r.linkInk,[l.card,l.paper,l.tile]),badge:r.brandSoft,onBadge:i(r.brandInk,a)},u=/* @__PURE__ */Object.freeze({...l,...s});return Fh.set(e,u),u}var Eh=4.5;function Oh(e,t){for(let r of t)if(contrastRatio(r,e)>=Eh)return r;return fs(e,Eh)}function Ah(e,t,r){let n=ws(e,t);return(n===null?null:vs(n,r))??r}function jh(e){let t=Lh(e),r=e.color,n=t.card;return{ink:t.ink,ink2:t.ink2,ink3:t.ink3,paper:t.paper,tile:t.tile,line:t.line,card:n,onInk:t.dark?r.background:"#FFFFFF",primary:t.primary,onPrimary:t.onPrimary,accent:t.accent,onAccent:Oh(t.accent,[t.ink,t.onAccent]),accent2:Ah(t.accent,.75,n),accent4:Ah(t.accent,.17,n),accentChip:Ah(t.accent,.47,n),link:t.link,linkChip:Ah(t.link,.2,n),riskDot:t.riskDot,riskChip:t.dark?r.badgeBgCritical:"#FFD8D6",clearBg:t.clearBg,clearInk:t.clearInk,clearChip:t.dark?r.badgeBgPositive:"#DDEFC4",byInk:r.brandInk}}var Dh=/* @__PURE__ */new Set(["color","fontSize","fontWeight","fontStyle","lh","ls","family","textAlign","textTransform","textDecorationLine"]),Mh=/* @__PURE__ */new Set(["dur","delay","stagger","ease","tint","k","cols","nowrap"]),Bh=["paddingTop","paddingRight","paddingBottom","paddingLeft"],Hh=17,Wh=1.5,Nh=400,Uh=700;function $h(e){return e<=450?"regular":e<=650?"medium":"bold"}function Vh(e){let t=Math.min(900,Math.max(100,Math.round(e/100)*100));return String(t)}function qh(e,t,r){if(t==="$mono"){let t=r<=450?"mono":r<=650?"monoMedium":"monoBold",n=face(e,t);return n.fontWeight===void 0?{fontFamily:n.fontFamily}:{fontFamily:n.fontFamily,fontWeight:Vh(r)}}let n=t==="$serif"?headingFace(e,$h(r)):face(e,$h(r));return n.fontWeight===void 0?{fontFamily:n.fontFamily}:{fontFamily:n.fontFamily,fontWeight:Vh(r)}}function Gh(e,t,r={}){let n=jh(e),l=e.brightness==="dark",i=e.motion.reducedMotion,o=e=>{if(typeof e=="string"&&e.startsWith("$")){let t=e.slice(1);return t.startsWith("n_")?l?n.line??e:`#${t.slice(2)}`:t==="sans"||t==="serif"||t==="mono"?e:n[t]??e}return Array.isArray(e)?e.map(e=>o(e)):e},a=/* @__PURE__ */new Map,s=e=>{let n=e.filter(e=>typeof e=="string"&&e!==""),l=n.join("|"),s=a.get(l);if(s!==void 0)return s;let u={},d=e=>{if(e!==void 0)for(let[t,r]of Object.entries(e))u[t]=o(r)};for(let e of n)d(t[e]),i&&d(r[e]);let c=/* @__PURE__ */Object.freeze(u);return a.set(l,c),c},u=/* @__PURE__ */new Map,d=(...e)=>{let t=e.filter(Boolean).join("|"),r=u.get(t);if(r!==void 0)return r;let n=s(e),l={};for(let[e,t]of Object.entries(n))Dh.has(e)||Mh.has(e)||e==="ring"||e==="edge"||e==="shadow"||e==="round"||e==="zIndex"&&typeof t=="number"&&t<0||t!==null&&(l[e]=t);if((typeof n.fontSize=="number"||n.flexDirection==="row")&&n.position!=="absolute"&&typeof n.height=="number"&&typeof n.width!="number"){let e=l.height;delete l.height,typeof l.minHeight!="number"&&(l.minHeight=e)}let i=n.ring;if(Array.isArray(i)){let[e,t]=i;l.borderWidth=e,l.borderColor=t;for(let t of Bh){let r=l[t];typeof r=="number"&&(l[t]=Math.max(0,r-e))}}let o=n.edge;if(Array.isArray(o)){let[e,t]=o;l.borderBottomWidth=e,l.borderBottomColor=t}let a=n.shadow;if(Array.isArray(a)){let[e,t,r,n]=a;l.shadowColor=n,l.shadowOffset={width:e,height:t},l.shadowOpacity=1,l.shadowRadius=r/2}if(n.round===1){let e=typeof n.width=="number"?n.width:typeof n.height=="number"?n.height:999;l.borderRadius=e/2}let d=/* @__PURE__ */Object.freeze(l);return u.set(t,d),d},c=/* @__PURE__ */new Map,p=(t,r)=>{let l=`${t}|${r.filter(Boolean).join("|")}`,i=c.get(l);if(i!==void 0)return i;let o=s(r),a=typeof o.fontSize=="number"?o.fontSize:Hh,u=typeof o.lh=="number"?o.lh:Wh,d=typeof o.fontWeight=="string"?Number(o.fontWeight):t,p=typeof o.family=="string"?o.family:"$sans",f={...qh(e,p,d),fontSize:a,lineHeight:Math.round(a*u*100)/100,color:typeof o.color=="string"?o.color:n.ink};typeof o.ls=="number"&&(f.letterSpacing=Math.round(o.ls*a*100)/100);for(let e of["fontStyle","textAlign","textTransform","textDecorationLine"])typeof o[e]=="string"&&(f[e]=o[e]);let h=/* @__PURE__ */Object.freeze(f);return c.set(l,h),h};return{reduced:i,colors:n,view:d,text:(...e)=>p(Nh,e),strong:(...e)=>p(Uh,e),icon:(...e)=>{let t=s(e),r={tintColor:typeof t.color=="string"?t.color:n.ink};for(let e of["width","height","opacity"])typeof t[e]=="number"&&(r[e]=t[e]);return r},col:(e,t)=>{let r=s([e]).cols;if(!Array.isArray(r))return{};let n=r[Math.min(t,r.length-1)];if(typeof n=="number")return{width:n,flexShrink:0};let l=typeof n=="string"?Number.parseFloat(n):1;return{flex:Number.isFinite(l)?l:1,minWidth:0}},motion:(...e)=>{let t=s(e),r=t.ease;return{dur:typeof t.dur=="number"?t.dur:0,delay:typeof t.delay=="number"?t.delay:0,stagger:typeof t.stagger=="number"?t.stagger:0,ease:Array.isArray(r)&&r.length===4?r:null}},raw:(e,...t)=>s(t)[e]}}var Kh={".serif":{family:"$serif",fontWeight:"800",ls:-.01},".emb-btn":{flexDirection:"row",alignItems:"center",justifyContent:"center",minHeight:48,paddingTop:0,paddingRight:22,paddingBottom:0,paddingLeft:22,borderRadius:999,backgroundColor:"$primary",color:"$onPrimary",fontWeight:"700",fontSize:16,textDecorationLine:"none",dur:160,ease:[.23,1,.32,1],gap:8},".emb-btn--sm":{minHeight:40,paddingTop:0,paddingRight:16,paddingBottom:0,paddingLeft:16,fontSize:15},".dot":{width:9,height:9,round:1,flexGrow:0,flexShrink:0},".dot--risk":{backgroundColor:"$riskDot"},".ask-chips":{flexDirection:"column",alignItems:"center",marginTop:22,gap:10},".chip":{paddingTop:10,paddingRight:16,paddingBottom:10,paddingLeft:16,borderRadius:999,fontSize:15,fontWeight:"600",lh:1.3,textAlign:"center",dur:160,ease:[.23,1,.32,1]},".ask-empty":{minHeight:"100%",flexDirection:"column",alignItems:"center",paddingTop:14,paddingRight:16,paddingBottom:22,paddingLeft:16,textAlign:"center"},".ask-empty h2":{fontSize:23,lh:1.12},".ask-start":{width:"100%",marginTop:"auto",marginRight:0,marginBottom:"auto",marginLeft:0,paddingTop:18,paddingRight:0,paddingBottom:18,paddingLeft:0,flexDirection:"column",alignItems:"center"},".ask-empty .ask-chips":{marginTop:14,alignSelf:"center",alignItems:"stretch",width:"100%",maxWidth:340},".hp-need__k":{flexDirection:"row",alignItems:"center",fontSize:15,fontWeight:"800",gap:8},".hp-srcs":{marginLeft:"auto",flexDirection:"row",gap:4},".hp-src":{height:24,paddingTop:0,paddingRight:9,paddingBottom:0,paddingLeft:9,borderRadius:999,backgroundColor:"$tile",color:"$ink2",fontSize:12,fontWeight:"700",flexDirection:"row",alignItems:"center",nowrap:1},".hp-src--dna":{backgroundColor:"$n_E0FDFF",color:"$link"},".hp-need__s":{alignItems:"baseline",marginTop:6,fontSize:15,lh:1.45,color:"$ink2",flexDirection:"row",cols:[9,"1fr"],gap:9},".hp-need__s b":{color:"$ink",fontWeight:"800"},".ask-focus":{width:"100%",paddingTop:14,paddingRight:16,paddingBottom:16,paddingLeft:16,borderRadius:20,backgroundColor:"$card",textAlign:"left",shadow:[0,1,3,"rgba(38, 37, 35, .07)"]},".ask-focus h3":{marginTop:10,fontSize:18,fontWeight:"800",lh:1.22},".ask-focus__x":{width:36,height:36,marginTop:-8,marginRight:-10,marginBottom:-8,marginLeft:-2,alignItems:"center",justifyContent:"center",round:1,color:"$ink2"},".ask-focus__x svg":{width:18,height:18},".ask-focus-pill":{marginLeft:"auto",flexDirection:"row",alignItems:"center",minHeight:36,paddingTop:0,paddingRight:14,paddingBottom:0,paddingLeft:14,borderRadius:999,backgroundColor:"$n_FFE3E1",color:"$n_B0231B",fontSize:15,fontWeight:"800",gap:7},".ask-focus-pill i":{width:8,height:8,round:1,backgroundColor:"$riskDot"},".ask-focus .hp-need__s":{fontSize:14.5},".ask-focus__acts":{flexDirection:"row",flexWrap:"wrap",alignItems:"center",marginTop:12,rowGap:4,columnGap:16},".ask-focus__q":{minHeight:36,fontSize:14.5,fontWeight:"700",color:"$link",textDecorationLine:"underline"},".ask-top":{alignSelf:"stretch",flexDirection:"row",marginTop:-8,marginRight:0,marginBottom:6,marginLeft:0},".thread__hist":{flexDirection:"row",alignItems:"center",minHeight:36,paddingTop:0,paddingRight:4,paddingBottom:0,paddingLeft:4,fontSize:15,fontWeight:"700",color:"$link",gap:6},".thread__hist svg":{width:18,height:18},".thread__count":{minWidth:22,height:20,paddingTop:0,paddingRight:6,paddingBottom:0,paddingLeft:6,borderRadius:999,backgroundColor:"$card",color:"$ink2",fontSize:12,fontWeight:"800",alignItems:"center",justifyContent:"center",ring:[1,"$line"]}},Yh=16;var Qh=4e3,Zh=.5;function Jh(e,t,r){let n=1,l=-1;for(let i of e)l<0?l=i:l+t+i<=r?l+=t+i:(n+=1,l=i);return n}function Xh(e,t,r){if(e.length===0)return r;let n=Jh(e,t,r),l=[];for(let n=0;n<e.length;n+=1){let i=0;for(let o=n;o<e.length;o+=1)i+=(o>n?t:0)+e[o],i<=r&&l.push(i)}l.sort((e,t)=>e-t);let i=Zh*e.length+1;for(let o of l)if(Jh(e,t,o)<=n)return Math.min(r,o+i);return r}function BalancedTitle({text:e,style:t,measureCh:r}){let o=n(()=>e.split(/\s+/).filter(e=>e!==""),[e]),a=y.flatten(t),s=[e,a.fontFamily,a.fontSize,a.fontWeight,a.letterSpacing].join("|"),u=l({key:"",ch:null,line:null,words:[]});u.current.key!==s&&(u.current={key:s,ch:null,line:null,words:o.map(()=>null)});let[d,f]=i(null),h=d!==null&&d.key===s?d.value:null,g=()=>{let e=u.current;if(e.ch===null||e.line===null||e.words.some(e=>e===null))return;let t=e.words,n=t.reduce((e,t)=>e+t,0),l=t.length>1?Math.max(0,(e.line-n)/(t.length-1)):0,i=Xh(t,l,(e.ch+Zh)*r);f(t=>t!==null&&t.key===e.key&&t.value===i?t:{key:e.key,value:i})},b=e=>t=>{u.current.key===s&&(e(u.current,t.nativeEvent.layout.width),g())};/* @__PURE__ */
|
|
237
|
-
return
|
|
238
|
-
/* @__PURE__ */
|
|
239
|
-
/* @__PURE__ */
|
|
240
|
-
/* @__PURE__ */
|
|
241
|
-
/* @__PURE__ */
|
|
242
|
-
return Object.freeze({...e,borderColor:o,backgroundColor:l,textColor:a,reasonColor:
|
|
243
|
-
return
|
|
244
|
-
/* @__PURE__ */
|
|
245
|
-
/* @__PURE__ */
|
|
246
|
-
return
|
|
247
|
-
/* @__PURE__ */
|
|
248
|
-
return
|
|
249
|
-
return
|
|
250
|
-
/* @__PURE__ */
|
|
251
|
-
/* @__PURE__ */
|
|
252
|
-
return
|
|
253
|
-
/* @__PURE__ */
|
|
254
|
-
/* @__PURE__ */
|
|
255
|
-
/* @__PURE__ */
|
|
256
|
-
return Object.freeze({title:o,sourceName:r,section:n,authorityTier:l,tierLabel:i,meta:s.length===0?null:s,url:
|
|
257
|
-
return
|
|
258
|
-
return
|
|
259
|
-
return
|
|
260
|
-
/* @__PURE__ */
|
|
261
|
-
/* @__PURE__ */
|
|
262
|
-
return
|
|
263
|
-
return
|
|
264
|
-
return
|
|
265
|
-
/* @__PURE__ */
|
|
266
|
-
/* @__PURE__ */
|
|
267
|
-
/* @__PURE__ */
|
|
268
|
-
/* @__PURE__ */
|
|
269
|
-
/* @__PURE__ */
|
|
270
|
-
return
|
|
271
|
-
/* @__PURE__ */
|
|
272
|
-
/* @__PURE__ */
|
|
273
|
-
return
|
|
274
|
-
return
|
|
275
|
-
return
|
|
276
|
-
/* @__PURE__ */
|
|
277
|
-
/* @__PURE__ */
|
|
278
|
-
/* @__PURE__ */
|
|
279
|
-
/* @__PURE__ */
|
|
280
|
-
/* @__PURE__ */
|
|
281
|
-
return
|
|
282
|
-
return
|
|
283
|
-
/* @__PURE__ */
|
|
284
|
-
/* @__PURE__ */
|
|
285
|
-
return
|
|
286
|
-
return
|
|
287
|
-
/* @__PURE__ */
|
|
288
|
-
/* @__PURE__ */
|
|
289
|
-
/* @__PURE__ */
|
|
290
|
-
/* @__PURE__ */
|
|
291
|
-
return
|
|
292
|
-
/* @__PURE__ */
|
|
293
|
-
/* @__PURE__ */
|
|
294
|
-
/* @__PURE__ */
|
|
295
|
-
return
|
|
296
|
-
return
|
|
297
|
-
/* @__PURE__ */
|
|
298
|
-
/* @__PURE__ */
|
|
299
|
-
/* @__PURE__ */
|
|
300
|
-
return
|
|
301
|
-
/* @__PURE__ */
|
|
302
|
-
/* @__PURE__ */
|
|
303
|
-
/* @__PURE__ */
|
|
129
|
+
/* @__PURE__ */Object.freeze({background:"#ffd8a8",foreground:"#5a2a04"})]);function up(e){let t=0;for(let r=0;r<e.length;r+=1)t=t*31+e.charCodeAt(r)>>>0;return sp[t%sp.length]}function dp(e){let t=(e??"").trim();return(Array.from(t)[0]??"?").toUpperCase()}function cp(e){return{...up(e.petRef),initial:dp(e.name)}}function pp(e,t,r){let n=cp(e);return t?n:{background:r.fill,foreground:r.ink,initial:n.initial}}function fp(e){return Math.max(12,Math.round(e*.42))}function PetDisc({pet:e,size:t,ringStroke:r}){let n=useEverfurTheme(),i=l(()=>hp(n),[n]),o=t-r*2,a=e===null?null:pp(e,np(n),{fill:n.color.highlight,ink:n.color.onHighlight}),s=fp(o);/* @__PURE__ */
|
|
130
|
+
return f(Ring,{size:t,strokeWidth:r,color:n.color.mark,children:/* @__PURE__ */f(S,{style:[i.disc,{width:o,height:o,borderRadius:o/2},a===null?i.discEmpty:{backgroundColor:a.background}],children:/* @__PURE__ */f(Text,{tier:"badge",style:[i.letter,{fontSize:s,lineHeight:Math.round(s*1.2),color:a===null?n.color.text.muted:a.foreground}],children:a===null?dp(null):a.initial})})})}function hp(e){return v.create({disc:{alignItems:"center",justifyContent:"center",overflow:"hidden"},discEmpty:{backgroundColor:e.color.brandSoft},letter:{...face(e,"bold"),textAlign:"center",includeFontPadding:false}})}function gp(e,t){let{borderRadius:r,...n}=pa(e,t);return r===void 0?n:{...n,borderTopLeftRadius:r,borderTopRightRadius:r}}function bp(e,t){let{backgroundColor:r,borderColor:n,borderWidth:l,borderRadius:i}=pa(e,t);return{...r===void 0?{}:{backgroundColor:r},...n===void 0?{}:{borderRightColor:n,borderRightWidth:l??1},...i===void 0?{}:{borderTopRightRadius:i,borderBottomRightRadius:i}}}var mp=48,yp=2,vp=320,wp="80%",kp="rgba(17,17,17,0.45)",Cp=18,Sp=22,xp=12,Rp=.4,Tp=44;function _p(e){return e?.name?.trim()||rt.yourPet}function PetSwitcherSheet({visible:e,pets:t,activePetRef:r,onSelect:n,onAddPet:i=null,onClose:o}){let a=useEverfurTheme(),s=l(()=>zp(a),[a]),u=Ne();return e?/* @__PURE__ */f(I,{visible:true,transparent:true,animationType:a.motion.reducedMotion?"none":"fade",onRequestClose:o,children:/* @__PURE__ */h(S,{style:s.root,children:[
|
|
131
|
+
/* @__PURE__ */f(T,{style:zs,onPress:o,accessibilityRole:"button",accessibilityLabel:rt.close,children:/* @__PURE__ */f(S,{style:s.backdrop})}),
|
|
132
|
+
/* @__PURE__ */h(S,{style:Ue(s.panel,u),accessibilityViewIsModal:true,children:[
|
|
133
|
+
/* @__PURE__ */f(Text,{tier:"heading",style:s.title,accessibilityRole:"header",children:rt.yourPets}),
|
|
134
|
+
/* @__PURE__ */f(P,{style:s.list,contentContainerStyle:s.listContent,showsVerticalScrollIndicator:true,children:t.map(e=>{let t=e.petRef===r,l=_p(e),i=ap(e);/* @__PURE__ */
|
|
135
|
+
return h(PressScale,{accessibilityRole:"button",accessibilityLabel:nt(t?rt.petCurrentlyActive:rt.switchToPet,{name:l}),accessibilityState:{selected:t},style:[s.row,t?s.rowActive:null],onPress:()=>n(e.petRef),children:[
|
|
136
|
+
/* @__PURE__ */f(PetDisc,{pet:e,size:mp,ringStroke:yp}),
|
|
137
|
+
/* @__PURE__ */h(S,{style:s.copy,children:[
|
|
138
|
+
/* @__PURE__ */f(Text,{style:s.name,numberOfLines:1,children:l}),
|
|
139
|
+
/* @__PURE__ */f(Text,{tier:"compact",style:s.meta,numberOfLines:1,children:t?`${rt.activePrefix}${i}`:i})]}),t?/* @__PURE__ */f(CheckGlyph,{size:Cp,color:a.color.brandInk}):null]},e.petRef)})}),i!==null?/* @__PURE__ */h(PressScale,{accessibilityRole:"button",accessibilityLabel:rt.addAnotherPet,style:s.addRow,onPress:i,children:[
|
|
140
|
+
/* @__PURE__ */f(S,{style:s.addDisc,children:/* @__PURE__ */f(Text,{tier:"control",style:s.addPlus,children:"+"})}),
|
|
141
|
+
/* @__PURE__ */f(Text,{style:s.addLabel,children:rt.addAnotherPet})]}):null,
|
|
142
|
+
/* @__PURE__ */f(PressScale,{accessibilityRole:"button",accessibilityLabel:rt.close,containerStyle:s.closeSlot,style:s.closeButton,onPress:o,children:/* @__PURE__ */f(Text,{tier:"control",style:s.closeText,children:rt.close})})]})]})}):null}function zp(e){let t=e.color,r=e.radius,n=ha(e.slots.dialog);return v.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{flex:1,backgroundColor:kp},panel:{backgroundColor:t.surface,paddingHorizontal:20,paddingTop:20,paddingBottom:32,borderTopLeftRadius:Sp,borderTopRightRadius:Sp,gap:14,maxHeight:wp,...gp(e.slots.dialog)},title:{...headingFace(e,"bold"),fontSize:18,lineHeight:22,color:t.brandInk,...n},list:{maxHeight:vp,flexShrink:1},listContent:{gap:10},addRow:{flexDirection:"row",alignItems:"center",gap:12,minHeight:Tp,paddingHorizontal:8},addDisc:{width:mp,height:mp,borderRadius:r.pill,alignItems:"center",justifyContent:"center",borderWidth:yp,borderStyle:"dashed",borderColor:t.brandBorder,backgroundColor:t.surfaceCream},addPlus:{...face(e,"bold"),fontSize:20,lineHeight:22,color:t.brandInk},addLabel:{...face(e,"bold"),fontSize:15,lineHeight:20,color:t.text.primary,...n},row:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:r.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface},rowActive:{borderColor:t.brandInk,backgroundColor:t.brandSoft},copy:{flex:1,gap:2},name:{...face(e,"bold"),fontSize:15,lineHeight:18,color:t.text.primary},meta:{...face(e,"monoBold"),fontSize:11,lineHeight:13,color:t.text.muted,textTransform:"uppercase",letterSpacing:Rp},closeSlot:{alignSelf:"flex-end"},closeButton:{paddingHorizontal:18,paddingVertical:10,borderRadius:xp,backgroundColor:t.brandSoft},closeText:{...face(e,"bold"),color:t.brandInk,fontSize:13,lineHeight:16,letterSpacing:Rp}})}var Ip=44,Pp=36,Fp=22,Lp=20,Ep=9,Op=1.5,Ap=6,jp=35,Dp=1.75,Mp=12.4,Bp=.5,Hp=8,Wp=28,Np=160,Up=16,$p=8;function Vp(e,petRef){return vc(e,petRef)}function ChatHeader({pets:e,petRef:petRef,historyUnread:t,onOpenHistory:r,onNewChat:i,onPetChange:a,onAddPet:s,vet:u,textingEntry:d=null}){let c=useEverfurTheme(),p=l(()=>qp(c),[c]),[b,m]=o(false),y=Vp(e.pets,petRef),v=y!==null&&(e.pets.length>=2||s!==void 0),w=petRef??y?.petRef??null,k=_p(y),[C,x]=o(Jc),R=n(e=>t=>{let r=t.nativeEvent.layout.width;x(t=>tp(t,e,r))},[]),T=l(()=>R("row"),[R]),_=l(()=>R("leading"),[R]),z=l(()=>R("trailing"),[R]),I=2*Up+2*(c.slots.header?.borderColor!==void 0?1:0)+2*$p,P=ep(C,I,Np),F=t=>{m(false),e.setActivePet(t),dn(a,t)},L=s===void 0?null:()=>{m(false),dn(s)};/* @__PURE__ */
|
|
143
|
+
return h(g,{children:[
|
|
144
|
+
/* @__PURE__ */h(S,{style:p.row,onLayout:T,children:[
|
|
145
|
+
/* @__PURE__ */f(S,{style:[p.leading,P.leading===void 0?null:{minWidth:P.leading}],children:/* @__PURE__ */h(S,{style:p.sideContent,onLayout:_,children:[i!==void 0?/* @__PURE__ */f(PressScale,{accessibilityRole:"button",accessibilityLabel:Gi.newChat,containerStyle:p.iconSlot,style:p.iconButton,onPress:i,children:/* @__PURE__ */f(EditGlyph,{size:Lp,color:c.slots.header?.textColor??c.color.text.primary,strokeWidth:2})}):null,
|
|
146
|
+
/* @__PURE__ */h(PressScale,{accessibilityRole:"button",accessibilityLabel:t?`${rt.openHistoryNative}${rt.newReplySuffix}`:rt.openHistoryNative,containerStyle:p.iconSlot,style:p.iconButton,onPress:r,children:[
|
|
147
|
+
/* @__PURE__ */f(MenuGlyph,{size:Fp,color:c.slots.header?.textColor??c.color.text.primary,strokeWidth:2}),t?/* @__PURE__ */f(S,{style:p.unreadDot,pointerEvents:"none"}):null]})]})}),
|
|
148
|
+
/* @__PURE__ */f(S,{style:p.centre,pointerEvents:"box-none",children:/* @__PURE__ */f(BrandLogo,{logoUrl:c.meta.logoUrl,name:c.meta.displayName,barStyle:p.logoBar,logoStyle:p.logo})}),
|
|
149
|
+
/* @__PURE__ */f(S,{style:[p.trailing,P.trailing===void 0?null:{minWidth:P.trailing}],children:/* @__PURE__ */h(S,{style:p.trailingContent,onLayout:z,children:[w===null?null:/* @__PURE__ */f(VetVisitButtonCore,{entry:"chat",petRef:w,...u?.returnTo!==void 0?{returnTo:u.returnTo}:{},...u?.usState!==void 0?{usState:u.usState}:{},...u?.prefer!==void 0?{prefer:u.prefer}:{},style:p.vetEntry,labelStyle:p.vetEntryLabel}),
|
|
150
|
+
/* @__PURE__ */f(S,{style:p.right,children:v?/* @__PURE__ */h(PressScale,{accessibilityRole:"button",accessibilityLabel:nt(rt.switchActivePet,{name:k}),containerStyle:p.avatarSlot,style:p.avatarWrap,onPress:()=>m(true),children:[
|
|
151
|
+
/* @__PURE__ */f(PetDisc,{pet:y,size:jp,ringStroke:Dp}),
|
|
152
|
+
/* @__PURE__ */f(S,{style:p.addBadge,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:/* @__PURE__ */f(PlusGlyph,{size:Hp,color:c.color.brandInk,strokeWidth:2})})]}):e.loading&&y===null?
|
|
153
|
+
/* @__PURE__ */f(S,{style:p.avatarWrap,accessible:true,accessibilityLabel:rt.yourPet,children:/* @__PURE__ */f(Ring,{size:jp,strokeWidth:Dp,color:c.color.mark,children:/* @__PURE__ */f(S,{style:p.placeholderDisc})})}):/* @__PURE__ */f(S,{style:p.avatarWrap,accessible:true,accessibilityRole:"image",accessibilityLabel:y===null?rt.yourPet:k,children:/* @__PURE__ */f(PetDisc,{pet:y,size:jp,ringStroke:Dp})})})]})}),
|
|
154
|
+
/* @__PURE__ */f(PetSwitcherSheet,{visible:b,pets:e.pets,activePetRef:y?.petRef??null,onSelect:F,onAddPet:L,onClose:()=>m(false)})]}),d===null?null:/* @__PURE__ */f(TextingEntryRow,{entry:d,place:"header"})]})}function TextingEntryRow({entry:e,place:t}){let r=useEverfurTheme(),n=l(()=>qp(r),[r]);/* @__PURE__ */
|
|
155
|
+
return f(S,{style:t==="header"?n.textingEntryRowHeader:n.textingEntryRowThread,children:/* @__PURE__ */f(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,containerStyle:n.textingEntrySlot,style:n.vetEntry,onPress:e.onOpen,testID:"everfur-texting-entry",children:/* @__PURE__ */f(Text,{tier:"control",style:n.vetEntryLabel,numberOfLines:1,children:e.label})})})}function qp(e){let t=e.color,r=jp-Dp*2,n=e.slots.header;return v.create({vetEntry:{minHeight:Ip,justifyContent:"center",paddingHorizontal:12,borderRadius:e.radius.pill,backgroundColor:t.surfaceCream,borderWidth:v.hairlineWidth,borderColor:t.controlEdge},vetEntryLabel:{...face(e,"bold"),color:t.brandInk,fontSize:e.type.size.caption},textingEntrySlot:{borderRadius:e.radius.pill,maxWidth:"100%"},textingEntryRowHeader:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:Up,paddingBottom:10,backgroundColor:n?.backgroundColor??t.surface},textingEntryRowThread:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:Up,paddingTop:e.space.md,paddingBottom:e.space.xs},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:Up,paddingVertical:10,backgroundColor:t.surface,...pa(n)},iconSlot:{borderRadius:Pp/2},iconButton:{width:Pp,height:Pp,borderRadius:Pp/2,alignItems:"center",justifyContent:"center"},unreadDot:{position:"absolute",top:Ap,right:Ap,width:Ep,height:Ep,borderRadius:Ep,backgroundColor:t.danger,borderWidth:Op,borderColor:n?.backgroundColor??t.surface},leading:{flexShrink:0,alignItems:"flex-start"},trailing:{flexShrink:0,alignItems:"flex-end"},sideContent:{flexDirection:"row",alignItems:"center"},trailingContent:{flexDirection:"row",alignItems:"center",gap:e.space.sm},centre:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0,marginHorizontal:$p,alignItems:"center",justifyContent:"center"},logoBar:{alignSelf:"stretch",alignItems:"center"},logo:{height:Wp,width:Np,maxWidth:"100%"},right:{alignItems:"flex-end"},avatarSlot:{borderRadius:jp/2},avatarWrap:{width:jp,height:jp,position:"relative"},placeholderDisc:{width:r,height:r,borderRadius:r/2,backgroundColor:t.brandSoft},addBadge:{position:"absolute",bottom:0,right:0,width:Mp,height:Mp,borderRadius:Mp/2,borderWidth:Bp,borderColor:t.mark,backgroundColor:t.surface,alignItems:"center",justifyContent:"center"}})}var Gp=/* @__PURE__ */Object.freeze([
|
|
156
|
+
/* @__PURE__ */Object.freeze({key:"inaccurate",label:rt.feedbackReasonInaccurate,feedbackType:"wrong"}),
|
|
157
|
+
/* @__PURE__ */Object.freeze({key:"outdated",label:rt.feedbackReasonOutdated,feedbackType:"outdated"}),
|
|
158
|
+
/* @__PURE__ */Object.freeze({key:"unsafe",label:rt.feedbackReasonUnsafe,feedbackType:"dangerous"}),
|
|
159
|
+
/* @__PURE__ */Object.freeze({key:"unclear",label:rt.feedbackReasonUnclear,feedbackType:"unclear"}),
|
|
160
|
+
/* @__PURE__ */Object.freeze({key:"other",label:rt.feedbackReasonOther,feedbackType:"not_helpful"})]),Kp=/* @__PURE__ */Object.freeze([
|
|
161
|
+
/* @__PURE__ */Object.freeze({sentiment:"up",label:rt.feedbackHelpful}),
|
|
162
|
+
/* @__PURE__ */Object.freeze({sentiment:"down",label:rt.feedbackNotHelpful})]);function Yp(e){switch(e){case"up":return"helpful";case"neutral":return"neutral";case"down":return"not_helpful"}}function Qp(e,t){if(e==="down"&&t!==null){let e=Gp.find(e=>e.key===t);if(e!==void 0)return e.feedbackType}return Yp(e)}var Zp=44,Jp="rgba(17,17,17,0.55)",Xp=26,ef=36,tf=4,rf=20,nf=38,lf=18,of=12;function FeedbackReasons({visible:e,onSubmit:t,onSkip:r}){let n=useEverfurTheme(),i=l(()=>af(n),[n]),a=Ne(),[s,u]=o(null),[d,c]=o(""),[p,g]=o(false),[b,m]=o(false),y=()=>{u(null),c(""),g(false),m(false)},v=()=>{p||(y(),r())},k=async()=>{if(p)return;g(true),m(false);let e=d.trim();await t(s,e.length>0?e:null)?y():(g(false),m(true))};if(!e)return null;let C=[...d].length>va;/* @__PURE__ */
|
|
163
|
+
return f(I,{visible:true,transparent:true,animationType:n.motion.reducedMotion?"none":"slide",onRequestClose:v,children:/* @__PURE__ */h(R,{behavior:w.OS==="ios"?"padding":void 0,style:i.root,children:[
|
|
164
|
+
/* @__PURE__ */f(T,{style:i.scrim,onPress:v,accessibilityRole:"button",accessibilityLabel:rt.feedbackSkipA11y}),
|
|
165
|
+
/* @__PURE__ */h(S,{style:Ue(i.sheet,a),accessibilityViewIsModal:true,accessibilityLiveRegion:"polite",children:[
|
|
166
|
+
/* @__PURE__ */f(S,{style:i.handle}),
|
|
167
|
+
/* @__PURE__ */h(S,{style:i.header,children:[
|
|
168
|
+
/* @__PURE__ */f(S,{style:i.iconBadge,children:/* @__PURE__ */f(ThumbGlyph,{size:lf,color:n.color.brandInk,active:false,rotate:"180deg"})}),
|
|
169
|
+
/* @__PURE__ */h(S,{style:i.headerText,children:[
|
|
170
|
+
/* @__PURE__ */f(Text,{tier:"heading",style:i.title,accessibilityRole:"header",children:rt.feedbackTitle}),
|
|
171
|
+
/* @__PURE__ */f(Text,{style:i.subtitle,children:rt.feedbackSubtitle})]})]}),
|
|
172
|
+
/* @__PURE__ */f(S,{style:i.options,children:Gp.map(e=>{let t=s===e.key;/* @__PURE__ */
|
|
173
|
+
return h(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,accessibilityState:{selected:t},style:[i.option,t?i.optionSelected:null],onPress:()=>u(t=>t===e.key?null:e.key),children:[
|
|
174
|
+
/* @__PURE__ */f(Text,{style:[i.optionLabel,t?i.optionLabelSelected:null],children:e.label}),
|
|
175
|
+
/* @__PURE__ */f(S,{style:[i.radio,t?i.radioSelected:null],children:t?/* @__PURE__ */f(CheckGlyph,{size:of,color:n.color.surface,strokeWidth:2}):null})]},e.key)})}),
|
|
176
|
+
/* @__PURE__ */h(S,{style:i.inputWrap,children:[
|
|
177
|
+
/* @__PURE__ */f(Oe,{style:i.input,placeholder:rt.feedbackNotesPlaceholder,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:rt.feedbackNotesPlaceholder,value:d,onChangeText:c,multiline:true,editable:!p}),d.length>0?/* @__PURE__ */f(Text,{tier:"compact",style:[i.counter,C?i.counterOver:null],children:`${[...d].length}/${va}`}):null]}),b?/* @__PURE__ */f(Text,{style:i.failed,accessibilityRole:"alert",children:rt.feedbackFailed}):null,
|
|
178
|
+
/* @__PURE__ */h(S,{style:i.actions,children:[
|
|
179
|
+
/* @__PURE__ */f(PressScale,{accessibilityRole:"button",accessibilityLabel:rt.feedbackSubmit,accessibilityState:{busy:p,disabled:p||C},disabled:p||C,style:[i.submit,p||C?i.submitDisabled:null],onPress:()=>{k()},children:/* @__PURE__ */f(Text,{tier:"control",style:i.submitLabel,children:rt.feedbackSubmit})}),
|
|
180
|
+
/* @__PURE__ */f(T,{accessibilityRole:"button",accessibilityLabel:rt.feedbackSkipA11y,hitSlop:8,onPress:v,style:i.skip,children:/* @__PURE__ */f(Text,{tier:"control",style:i.skipLabel,children:rt.feedbackSkip})})]})]})]})})}function af(e){let t=e.color,r=e.type,n=e.radius,l=e.slots,i=ha(l.dialog);return v.create({root:{flex:1,justifyContent:"flex-end"},scrim:{...zs,backgroundColor:Jp},sheet:{backgroundColor:t.surface,borderTopLeftRadius:Xp,borderTopRightRadius:Xp,paddingHorizontal:22,paddingTop:12,paddingBottom:34,gap:14,...gp(l.dialog)},handle:{alignSelf:"center",width:ef,height:tf,borderRadius:tf/2,backgroundColor:t.brandBorder,marginBottom:2},header:{flexDirection:"row",alignItems:"center",gap:12},iconBadge:{width:nf,height:nf,borderRadius:nf/2,alignItems:"center",justifyContent:"center",backgroundColor:t.brandSoft},headerText:{flex:1,gap:2},title:{...headingFace(e,"bold"),fontSize:20,lineHeight:28,color:t.text.primary,letterSpacing:r.letterSpacing.tight,...i},subtitle:{...face(e,"regular"),fontSize:r.size.body,lineHeight:r.size.body*r.lineHeight.relaxed,color:t.text.muted,...i},options:{gap:8},option:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:14,paddingVertical:13,borderRadius:n.md,borderWidth:v.hairlineWidth,borderColor:t.controlEdge,backgroundColor:t.surface,...pa(l.chip,v.hairlineWidth)},optionSelected:{borderColor:t.brandInk,backgroundColor:t.brandSoft},optionLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.text.primary,...ha(l.chip)},optionLabelSelected:{color:t.brandInk},radio:{width:rf,height:rf,borderRadius:rf/2,borderWidth:2,borderColor:t.brandBorderStrong,alignItems:"center",justifyContent:"center"},radioSelected:{borderColor:t.brandInk,backgroundColor:t.brandInk},inputWrap:{gap:4},input:{minHeight:72,maxHeight:132,borderRadius:n.md,borderWidth:1,borderColor:t.brandBorderStrong,paddingHorizontal:14,paddingTop:12,paddingBottom:12,...face(e,"regular"),fontSize:r.size.body,color:t.text.primary,textAlignVertical:"top",...pa(l.input,1),...ha(l.input)},counter:{...face(e,"mono"),alignSelf:"flex-end",fontSize:r.size.caption,letterSpacing:.3,color:t.text.placeholder},counterOver:{color:t.danger},failed:{...face(e,"regular"),fontSize:r.size.caption,lineHeight:r.size.caption*r.lineHeight.normal,color:t.danger},actions:{gap:10,alignItems:"center"},submit:{alignSelf:"stretch",minHeight:Zp,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.xl,borderRadius:n.pill,backgroundColor:t.brand,...pa(l.primaryButton)},submitDisabled:{opacity:.6},submitLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.onPrimary,...ha(l.primaryButton)},skip:{minHeight:Zp,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},skipLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.text.muted}})}var sf=/* @__PURE__ */Symbol.for("everfur.sdk.rn.askHome");function uf(){let e=globalThis,t=e[sf];if(t!==void 0)return t;let r={factory:createContext(null),home:createContext(null)};return e[sf]=r,r}var df=uf().factory,cf=uf().home;function pf(){return u(df)}function ff(){return u(cf)?.kit??null}function hf(){return u(cf)}var gf=15,bf=8;function HistoryBar({bar:e,history:t,empty:r,unread:n,extra:i}){let o=useEverfurTheme(),a=ff(),s=l(()=>a!==null?vf(o,a):wf(o),[o,a]),u=t.cursor===null?t.rows.length:0,d=t=>{let r=e.renderIcon;if(r!==void 0)/* @__PURE__ */return f(HostRender,{render:()=>r(t),fallback:null});if(a===null)return null;let n=String(v.flatten(s.label).color??o.color.linkInk);return t==="history"?/* @__PURE__ */f(HistoryGlyph,{size:yf,color:n,strokeWidth:1.8}):/* @__PURE__ */f(EditGlyph,{size:yf,color:n,strokeWidth:1.8})};/* @__PURE__ */
|
|
181
|
+
return h(S,{style:s.bar,testID:"everfur-history-bar",children:[
|
|
182
|
+
/* @__PURE__ */h(T,{accessibilityRole:"button",accessibilityLabel:u>0?`${e.chats} ${u}`:e.chats,accessibilityState:{expanded:t.open},onPress:t.open?t.close:t.show,style:s.control,hitSlop:a!==null?mf:void 0,children:[d("history"),
|
|
183
|
+
/* @__PURE__ */f(Text,{tier:"control",style:s.label,children:e.chats}),u>0?/* @__PURE__ */f(S,{style:s.count,children:/* @__PURE__ */f(Text,{tier:"badge",style:s.countText,children:String(u)})}):null,n?/* @__PURE__ */f(S,{style:s.dot,testID:"everfur-chat-history-bar-unread"}):null]}),e.extra??null,i??null,
|
|
184
|
+
/* @__PURE__ */f(S,{style:s.spacer}),r?null:/* @__PURE__ */h(T,{accessibilityRole:"button",accessibilityLabel:e.newChat,onPress:t.newConversation,style:s.control,hitSlop:a!==null?mf:void 0,children:[d("edit"),
|
|
185
|
+
/* @__PURE__ */f(Text,{tier:"control",style:s.label,children:e.newChat})]})]})}var mf=4,yf=18;function vf(e,t){return{...wf(e),bar:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:e.space.sm},control:t.view(".thread__hist"),label:t.text(".thread__hist"),count:t.view(".thread__count"),countText:t.text(".thread__count")}}function wf(e){let t=e.color,r=e.space;return v.create({bar:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.sm,paddingHorizontal:r.lg,paddingVertical:r.xs},control:{flexDirection:"row",alignItems:"center",gap:6,minHeight:lu},label:{...face(e,"bold"),fontSize:gf,color:t.brandInk},count:{minWidth:22,paddingHorizontal:7,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,alignItems:"center"},countText:{...face(e,"bold"),fontSize:e.type.size.caption,color:t.text.primary},dot:{width:bf,height:bf,borderRadius:bf/2,backgroundColor:t.danger},spacer:{flexGrow:1}})}var kf=.88,Cf=420,Sf=58,xf="rgba(17,17,17,0.28)",Rf=.15,Tf=14,_f=12,zf=44,If=16,Pf=14,Ff=12,Lf=14,Ef=8,Of=2,Af=.5,jf=No(Lo.standard);function Df(e){return Math.min(Math.round(e*kf),Cf)}function HistoryDrawer({chat:e,history:t}){let[r,l]=o(t.open),i=n(()=>l(false),[]);return t.open&&!r&&l(true),r?/* @__PURE__ */f(DrawerModal,{chat:e,history:t,onHidden:i}):null}function DrawerModal({chat:e,history:t,onHidden:r}){let n=useEverfurTheme(),o=l(()=>Mf(n),[n]),s=Mo(),u=B(),{width:d}=D(),c=Df(d),p=t.open,g=i(null);g.current===null&&(g.current=new j.Value(s.drawerMs<=0&&p?1:0));let b=g.current;a(()=>{if(!p&&s.drawerMs<=0){r();return}let e=j.timing(b,{toValue:p?1:0,duration:s.drawerMs,easing:jf,useNativeDriver:true});return e.start(({finished:e})=>{e&&!p&&r()}),()=>e.stop()},[p,b,s.drawerMs,r]);let m=b.interpolate({inputRange:[0,1],outputRange:[-c,0]}),y=t.filtered,v=t.rows.length===0,k=t.cursor===null&&!t.loading&&t.error===null,C=v&&t.loading?/* @__PURE__ */h(S,{style:o.emptyCard,accessibilityLabel:Gi.loading,accessibilityState:{busy:true},children:[
|
|
186
|
+
/* @__PURE__ */f(F,{color:o.emptyTitle.color}),
|
|
187
|
+
/* @__PURE__ */f(Text,{style:o.emptyBody,children:Gi.loading})]}):v&&t.error!==null?/* @__PURE__ */h(S,{style:o.emptyCard,children:[
|
|
188
|
+
/* @__PURE__ */f(Text,{style:o.emptyTitle,accessibilityRole:"alert",children:Gi.loadFailed}),
|
|
189
|
+
/* @__PURE__ */f(Text,{style:o.emptyBody,children:t.error}),
|
|
190
|
+
/* @__PURE__ */f(PressScale,{accessibilityRole:"button",accessibilityLabel:Gi.retry,containerStyle:o.retrySlot,style:o.retryButton,onPress:()=>{t.load()},children:/* @__PURE__ */f(Text,{tier:"control",style:o.retryText,children:Gi.retry})})]}):t.emptyKind==="empty"?/* @__PURE__ */h(S,{style:o.emptyCard,children:[
|
|
191
|
+
/* @__PURE__ */f(Text,{style:o.emptyTitle,children:Gi.empty}),
|
|
192
|
+
/* @__PURE__ */f(Text,{style:o.emptyBody,children:Gi.emptyBody})]}):
|
|
193
|
+
/* @__PURE__ */f(Text,{style:o.noMatch,children:Gi.noMatch}),x=!t.searching&&t.loadingMore?/* @__PURE__ */f(S,{style:o.loadMoreFooter,children:/* @__PURE__ */f(Text,{style:o.loadMoreLabel,children:Gi.loadingMore})}):null;/* @__PURE__ */
|
|
194
|
+
return f(I,{visible:true,transparent:true,animationType:"none",onRequestClose:t.close,children:/* @__PURE__ */h(S,{style:o.root,children:[
|
|
195
|
+
/* @__PURE__ */f(T,{style:zs,onPress:t.close,accessibilityRole:"button",accessibilityLabel:Gi.closeA11y,children:/* @__PURE__ */f(j.View,{style:[o.backdrop,{opacity:b}]})}),
|
|
196
|
+
/* @__PURE__ */f(j.View,{style:[o.panel,{width:c,paddingTop:Math.max(Sf,u.top+n.space.md),transform:[{translateX:m}]}],accessibilityViewIsModal:true,children:/* @__PURE__ */h(R,{style:o.keyboardAvoider,behavior:w.OS==="ios"?"padding":"height",children:[
|
|
197
|
+
/* @__PURE__ */h(S,{style:o.header,children:[
|
|
198
|
+
/* @__PURE__ */f(Text,{tier:"heading",style:o.heading,accessibilityRole:"header",children:Gi.heading}),
|
|
199
|
+
/* @__PURE__ */f(T,{accessibilityRole:"button",accessibilityLabel:Gi.newChat,style:o.newChat,onPress:t.newConversation,children:/* @__PURE__ */f(Text,{tier:"control",style:o.newChatLabel,children:Gi.newChat})}),
|
|
200
|
+
/* @__PURE__ */f(PressScale,{accessibilityRole:"button",accessibilityLabel:Gi.close,hitSlop:0,style:o.closeButton,onPress:t.close,children:/* @__PURE__ */f(CloseGlyph,{size:If,color:n.color.text.muted,strokeWidth:1.75})})]}),
|
|
201
|
+
/* @__PURE__ */h(S,{style:o.searchPill,children:[
|
|
202
|
+
/* @__PURE__ */f(SearchGlyph,{size:Lf,color:n.color.text.muted,strokeWidth:1.5}),
|
|
203
|
+
/* @__PURE__ */f(Oe,{value:t.query,onChangeText:e=>t.setQuery(e.replace(/^\s+/,"")),style:o.searchInput,placeholder:Gi.searchPlaceholder,placeholderTextColor:n.color.text.placeholder,accessibilityLabel:Gi.search,autoCorrect:false,autoCapitalize:"none",returnKeyType:"search"})]}),
|
|
204
|
+
/* @__PURE__ */f(Text,{tier:"compact",style:o.countLabel,children:Zi(t.rows.length,k)}),t.error!==null&&!v?/* @__PURE__ */f(S,{style:o.errorCard,children:/* @__PURE__ */f(Text,{style:o.errorText,accessibilityRole:"alert",children:t.error})}):null,
|
|
205
|
+
/* @__PURE__ */f(M,{data:y,keyExtractor:e=>e.id,renderItem:({item:r})=>/* @__PURE__ */f(Row,{row:r,active:r.id===e.conversationId,disabled:t.loading,styles:o,onPress:()=>{t.resume(r.id)}}),contentContainerStyle:y.length===0?o.listEmpty:o.list,keyboardShouldPersistTaps:"handled",ListEmptyComponent:C,ListFooterComponent:x,onEndReached:t.loadMore,onEndReachedThreshold:Af})]})})]})})}function Row({row:e,active:t,disabled:r,styles:n,onPress:l}){let i=e.unreadCount!==null&&e.unreadCount>0,o=Qi(e);/* @__PURE__ */
|
|
206
|
+
return h(PressScale,{accessibilityRole:"button",accessibilityLabel:Ji(e),accessibilityState:{selected:t,disabled:r},disabled:r,style:[n.item,t?n.itemActive:null],onPress:l,children:[
|
|
207
|
+
/* @__PURE__ */h(S,{style:n.itemRow,children:[
|
|
208
|
+
/* @__PURE__ */f(Text,{tier:"control",style:n.itemTitle,numberOfLines:1,children:Ki(e.title)}),i?/* @__PURE__ */f(S,{style:n.unreadDot}):null]}),o!==null?/* @__PURE__ */f(Text,{tier:"compact",style:n.itemMeta,numberOfLines:1,children:o}):null]})}function Mf(e){let t=e.color,r=e.space,n=e.type,l=e.slots,i=t.text.primary,o=ha(l.card);return v.create({root:{flex:1},backdrop:{flex:1,backgroundColor:xf},panel:{position:"absolute",left:0,top:0,bottom:0,backgroundColor:t.surface,paddingHorizontal:r.lg,borderRightWidth:v.hairlineWidth,borderRightColor:t.borderRingCream,gap:r.md,...bp(l.dialog,v.hairlineWidth)},keyboardAvoider:{flex:1,gap:r.md},header:{flexDirection:"row",alignItems:"center",gap:r.sm},heading:{...headingFace(e,"bold"),flex:1,fontSize:n.size.subtitle,color:i,...ha(l.dialog)},newChat:{minHeight:zf,justifyContent:"center",paddingHorizontal:r.xs},newChatLabel:{...face(e,"bold"),fontSize:Tf,color:t.brandInk},closeButton:{width:zf,height:zf,alignItems:"center",justifyContent:"center"},searchPill:{flexDirection:"row",alignItems:"center",gap:r.sm,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,paddingHorizontal:r.md+Of,paddingVertical:r.sm+Of,borderWidth:1,borderColor:t.borderRingCream,...pa(l.input,1)},searchInput:{...face(e,"regular"),flex:1,fontSize:n.size.bodyTight,color:t.text.primary,padding:0,...ha(l.input)},countLabel:{...face(e,"mono"),fontSize:_f,color:t.text.muted},list:{gap:r.xs,paddingBottom:r.xl},listEmpty:{flexGrow:1},item:{paddingVertical:r.sm+Of,paddingHorizontal:r.sm,borderRadius:e.radius.md,gap:Of},itemActive:{backgroundColor:Rs(t.highlight,Rf)??t.surfaceSubtle},itemRow:{flexDirection:"row",alignItems:"center",gap:r.sm},itemTitle:{...face(e,"bold"),flex:1,fontSize:n.size.bodyTight,color:i},itemMeta:{...face(e,"regular"),fontSize:n.size.caption,color:t.text.muted},unreadDot:{width:Ef,height:Ef,borderRadius:Ef/2,backgroundColor:t.danger},errorCard:{borderRadius:Ff,borderWidth:v.hairlineWidth,borderColor:t.danger,backgroundColor:t.surface,padding:r.md},errorText:{...face(e,"regular"),fontSize:n.size.caption,color:t.danger},emptyCard:{borderRadius:Pf,padding:r.md+Of,gap:r.xs+Of,backgroundColor:t.surfaceSubtle,borderWidth:v.hairlineWidth,borderColor:t.borderRingCream,...pa(l.card,v.hairlineWidth)},emptyTitle:{...headingFace(e,"bold"),fontSize:n.size.bodyTight,color:i,...o},emptyBody:{...face(e,"regular"),fontSize:n.size.caption,color:t.text.secondary,...o},noMatch:{...face(e,"regular"),fontSize:n.size.bodyTight,color:t.text.muted,paddingVertical:r.sm},retrySlot:{marginTop:r.sm,alignSelf:"flex-start"},retryButton:{borderRadius:e.radius.pill,paddingHorizontal:r.md+Of,paddingVertical:r.sm,borderWidth:1,borderColor:t.brandInk,...pa(l.primaryButton)},retryText:{...face(e,"bold"),fontSize:n.size.caption,color:t.brandInk,...ha(l.primaryButton)},loadMoreFooter:{paddingVertical:r.md+Of,alignItems:"center"},loadMoreLabel:{...face(e,"regular"),fontSize:n.size.caption,color:t.text.muted}})}function Bf(e,t=/* @__PURE__ */new Date,r){let n=new Date(e);if(Number.isNaN(n.getTime()))return null;let l=new Date(t);l.setHours(0,0,0,0);let i=new Date(n);i.setHours(0,0,0,0);let o=Math.round((l.getTime()-i.getTime())/864e5);if(o===0||o===1)try{let e=new Intl.RelativeTimeFormat(r,{numeric:"auto"}).format(-o,"day");return e.charAt(0).toLocaleUpperCase(r)+e.slice(1)}catch{}return n.toLocaleDateString(r,{month:"short",day:"numeric"})}function Hf(e,t){let r=new Date(e);return Number.isNaN(r.getTime())?null:r.toLocaleTimeString(t,{hour:"numeric",minute:"2-digit"})}function Wf(e,t=/* @__PURE__ */new Date){let r=[];for(let n of e){let e=Bf(n.updatedAt,t)??"",l=r[r.length-1];l!==void 0&&l.day===e?l.rows.push(n):r.push({day:e,rows:[n]})}return r}var Nf="rgba(38,37,35,0.38)",Uf=28,$f=40,Vf=5,qf=11,Gf=10.5,Kf=36,Yf=11,Qf=14,Zf=15,Jf=13.5,Xf=48,eh=2,th=1.3,rh=.12,nh=16,lh=8,ih="80%";function oh(e,t,r){let n=e?.renderIcon;return n===void 0?r:/* @__PURE__ */f(HostRender,{render:()=>n(t),fallback:r})}function HistorySheet({chat:e,history:t,sheet:r}){let n=useEverfurTheme(),i=l(()=>ah(n),[n]),o=B(),a=l(()=>Wf(t.rows),[t.rows]),s=Ne();if(!t.open)return null;let u=n.color,d=r?.title?.trim(),p=d!==void 0&&d!==""?d:Gi.heading;/* @__PURE__ */
|
|
209
|
+
return f(I,{visible:true,transparent:true,animationType:"slide",onRequestClose:t.close,children:/* @__PURE__ */h(S,{style:i.root,children:[
|
|
210
|
+
/* @__PURE__ */f(T,{style:[zs,i.scrim],onPress:t.close,accessibilityRole:"button",accessibilityLabel:Gi.closeA11y}),
|
|
211
|
+
/* @__PURE__ */h(S,{style:Ue([i.sheet,{paddingBottom:Math.max(40,o.bottom+n.space.lg)}],s),accessibilityViewIsModal:true,testID:"everfur-history-sheet",children:[
|
|
212
|
+
/* @__PURE__ */f(S,{style:i.grab}),
|
|
213
|
+
/* @__PURE__ */h(S,{style:i.top,children:[
|
|
214
|
+
/* @__PURE__ */f(Text,{tier:"compact",style:i.kicker,accessibilityRole:"header",children:p}),
|
|
215
|
+
/* @__PURE__ */f(T,{accessibilityRole:"button",accessibilityLabel:Gi.closeA11y,onPress:t.close,style:i.close,children:oh(r,"close",/* @__PURE__ */f(CloseGlyph,{size:22,color:u.text.primary,strokeWidth:2}))})]}),
|
|
216
|
+
/* @__PURE__ */h(P,{style:i.scroll,contentContainerStyle:i.scrollContent,keyboardShouldPersistTaps:"handled",children:[t.loading&&t.rows.length===0?/* @__PURE__ */h(S,{style:i.state,accessibilityLabel:Gi.loading,accessibilityState:{busy:true},children:[
|
|
217
|
+
/* @__PURE__ */f(F,{color:u.brandInk}),
|
|
218
|
+
/* @__PURE__ */f(Text,{tier:"compact",style:i.mono,children:Gi.loading})]}):null,t.error!==null?/* @__PURE__ */h(S,{style:i.state,children:[
|
|
219
|
+
/* @__PURE__ */f(Text,{style:i.stateText,accessibilityRole:"alert",children:Gi.loadFailed}),
|
|
220
|
+
/* @__PURE__ */f(T,{accessibilityRole:"button",accessibilityLabel:Gi.retry,onPress:()=>{t.load()},style:i.link,children:/* @__PURE__ */f(Text,{tier:"control",style:i.linkText,children:Gi.retry})})]}):null,!t.loading&&t.error===null&&t.rows.length===0?/* @__PURE__ */f(Text,{style:[i.stateText,i.state],children:Gi.empty}):null,a.map((n,l)=>/* @__PURE__ */h(c,{children:[n.day?/* @__PURE__ */f(Text,{tier:"compact",style:[i.mono,i.day,l===0?i.dayFirst:null],children:n.day}):null,n.rows.map(n=>{let l=n.id===e.conversationId,o=n.unreadCount!==null&&n.unreadCount>0,a=Hf(n.updatedAt);/* @__PURE__ */
|
|
221
|
+
return h(T,{accessibilityRole:"button",accessibilityLabel:Ji(n),accessibilityState:{selected:l},onPress:()=>{t.resume(n.id)},style:[i.row,l?i.rowCurrent:null],children:[
|
|
222
|
+
/* @__PURE__ */f(S,{style:i.icon,children:oh(r,"chat",/* @__PURE__ */f(ChatBubbleGlyph,{size:19,color:u.linkInk,strokeWidth:1.75}))}),
|
|
223
|
+
/* @__PURE__ */h(S,{style:i.rowWords,children:[
|
|
224
|
+
/* @__PURE__ */f(Text,{tier:"control",style:i.rowTitle,numberOfLines:1,children:Ki(n.title)}),n.preview!==void 0?/* @__PURE__ */f(Text,{tier:"compact",style:i.preview,numberOfLines:1,children:n.preview}):null]}),
|
|
225
|
+
/* @__PURE__ */h(S,{style:i.rowEnd,children:[a!==null?/* @__PURE__ */f(Text,{tier:"compact",style:[i.mono,i.time,o?i.timeUnread:null],children:a}):null,o?/* @__PURE__ */f(S,{style:i.unreadDot,testID:`everfur-history-sheet-unread-${String(n.id)}`}):null]})]},String(n.id))})]},n.day)),t.cursor!==null&&!t.loadingMore?/* @__PURE__ */f(T,{accessibilityRole:"button",accessibilityLabel:Gi.more,onPress:t.loadMore,style:i.link,children:/* @__PURE__ */f(Text,{tier:"control",style:i.linkText,children:Gi.more})}):null]}),
|
|
226
|
+
/* @__PURE__ */h(T,{accessibilityRole:"button",accessibilityLabel:Gi.newChat,onPress:t.newConversation,style:i.newChat,children:[oh(r,"edit",/* @__PURE__ */f(EditGlyph,{size:18,color:n.slots.primaryButton?.textColor??u.onPrimary,strokeWidth:1.75})),
|
|
227
|
+
/* @__PURE__ */f(Text,{tier:"control",style:i.newChatText,children:Gi.newChat})]})]})]})})}function ah(e){let t=e.color,r=e.space,n={...face(e,"mono"),fontSize:Gf,letterSpacing:Gf*.06,textTransform:"uppercase",color:t.text.muted};return v.create({root:{flex:1,justifyContent:"flex-end"},scrim:{backgroundColor:Nf},sheet:{maxHeight:ih,backgroundColor:t.surface,borderTopLeftRadius:Uf,borderTopRightRadius:Uf,paddingTop:10,paddingHorizontal:20},grab:{width:$f,height:Vf,borderRadius:3,backgroundColor:t.borderRingCream,alignSelf:"center",marginBottom:10},top:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},kicker:{...n,fontSize:qf,letterSpacing:qf*.08,flexShrink:1},close:{width:lu,height:lu,marginRight:-10,alignItems:"center",justifyContent:"center",borderRadius:lu/2},scroll:{flexGrow:0},scrollContent:{paddingBottom:r.xs},mono:n,day:{marginTop:r.lg,marginBottom:r.xs},dayFirst:{marginTop:eh},state:{marginVertical:r.md,gap:r.sm,alignItems:"flex-start"},stateText:{...face(e,"regular"),fontSize:e.type.size.body,color:t.text.primary},link:{minHeight:lu,justifyContent:"center"},linkText:{...face(e,"bold"),fontSize:e.type.size.body,color:t.brandInk},row:{flexDirection:"row",alignItems:"center",gap:r.md,paddingVertical:10,paddingHorizontal:r.sm,borderRadius:Qf,minHeight:lu},rowCurrent:{backgroundColor:t.surfaceSubtle},icon:{width:Kf,height:Kf,borderRadius:Yf,backgroundColor:Rs(t.linkInk,rh)??t.surfaceSubtle,alignItems:"center",justifyContent:"center"},rowWords:{flex:1,minWidth:0},rowTitle:{...face(e,"bold"),fontSize:Zf,lineHeight:Zf*th,color:t.text.primary},preview:{...face(e,"regular"),fontSize:Jf,color:t.text.muted,marginTop:2},rowEnd:{alignSelf:"flex-start",alignItems:"flex-end",gap:6},time:{marginTop:3,letterSpacing:Gf*.04,textTransform:"none"},timeUnread:{...face(e,"monoBold"),color:t.text.primary},unreadDot:{width:lh,height:lh,borderRadius:lh/2,backgroundColor:t.danger},newChat:{marginTop:r.lg,minHeight:Xf,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:r.sm,borderRadius:e.radius.pill,backgroundColor:t.primary,...pa(e.slots.primaryButton)},newChatText:{...face(e,"bold"),fontSize:nh,color:t.onPrimary,...ha(e.slots.primaryButton)}})}var sh="Close",uh=/* @__PURE__ */Object.freeze({action:e=>e.possessive===null?null:`See ${e.possessive} Health Plan`,ask:"What does it mean?",askPrompt:(e,t)=>e.risk?.lead?`${e.risk.lead} ${t}`:`${e.title}: ${t}`,close:e=>e.possessive===null?null:`Close ${e.possessive} focus`,resultsKicker:e=>e.possessive===null?null:`${dh(e.possessive)} results`,resultsClose:e=>e.possessive===null?null:`Close ${e.possessive} results`,resultsTopRisk:"Top risk"});function dh(e){return e.charAt(0).toUpperCase()+e.slice(1)}function healthPlanPossessive(e){let t=typeof e.sex=="string"?e.sex.trim().toLowerCase():null;if(t==="female")return"her";if(t==="male")return"his";let r=typeof e.name=="string"?e.name.trim():"";return r!==""?`${r}'s`:null}function healthPlanTopCard(e,t={}){let r=e?.page?.focus;if(e===null||r===void 0||r.title.trim()===""||r.kicker.trim()==="")return;let n={...uh,...t.copy},l={pet:e.pet,possessive:healthPlanPossessive(e.pet)},i=r.sources?.find(e=>e.label.trim()!=="")?.label,o=t.onOpenPlan,a=o===void 0?null:n.action(l),s=n.close(l),u=n.ask.trim(),d=t.results!==void 0&&r.report!==void 0?t.results:void 0;if(d!==void 0){let e=n.resultsKicker(l)?.trim()||r.kicker,s=n.resultsClose(l),c=d.onTopRisk??o,p={key:"top-risk",label:n.resultsTopRisk,title:r.title,...r.risk?.lead?{line:r.risk.lead}:{},tone:"risk",...c===void 0?{}:{onPress:c}};return{kicker:e,...i===void 0?{}:{badge:i},title:r.title,results:[p,...d.rows??[]],...a===null||a.trim()===""||o===void 0?{}:{action:{label:a,onPress:o}},...u===""?{}:{ask:{label:u,prompt:n.askPrompt(r,u)}},closeLabel:s===null||s.trim()===""?sh:s,pill:e,...t.renderIcon===void 0?{}:{renderIcon:t.renderIcon}}}return{kicker:r.kicker,...i===void 0?{}:{badge:i},title:r.title,...r.risk?.lead?{lead:r.risk.lead}:{},...r.risk?.body?{body:r.risk.body}:{},...a===null||a.trim()===""||o===void 0?{}:{action:{label:a,onPress:o}},...u===""?{}:{ask:{label:u,prompt:n.askPrompt(r,u)}},closeLabel:s===null||s.trim()===""?sh:s,pill:r.kicker,...t.renderIcon===void 0?{}:{renderIcon:t.renderIcon}}}function ch(e){let t=face(e,"medium");return t.fontWeight===void 0?t:{fontFamily:t.fontFamily,fontWeight:"600"}}function ph(e){let t=face(e,"bold");return t.fontWeight===void 0?t:{fontFamily:t.fontFamily,fontWeight:"800"}}var fh=20,hh=14,gh=16,bh=18,mh=22,yh=15,vh=12,wh=24,kh=15,Ch=14.5,Sh=21,xh=14.5,Rh=18,Th=9,_h=36,zh=14,Ih=15,Ph=8,Fh=40;function TopCard({card:e,open:t,onOpenChange:r,ask:n}){let i=useEverfurTheme(),o=ff(),a=l(()=>o!==null?Eh(o):Oh(i),[i,o]),s=l(()=>pa(i.slots.card),[i.slots.card]);if(!t)return null;let u=e.closeLabel===void 0?null:e.closeLabel.trim()!==""?e.closeLabel:rt.close,d=e.action,c=e.ask,p=/* @__PURE__ */f(CloseGlyph,{size:o!==null?HOME_CLOSE_GLYPH(o):Rh,color:o!==null?String(o.text(".ask-focus__x").color):i.color.text.primary,strokeWidth:2});/* @__PURE__ */
|
|
228
|
+
return h(S,{style:[a.card,s],testID:"everfur-top-card",children:[
|
|
229
|
+
/* @__PURE__ */h(S,{style:a.kickerRow,children:[
|
|
230
|
+
/* @__PURE__ */f(Text,{tier:"control",style:a.kicker,children:e.kicker}),e.badge!==void 0?/* @__PURE__ */f(S,{style:a.badge,children:/* @__PURE__ */f(Text,{tier:"compact",style:a.badgeText,numberOfLines:1,children:e.badge})}):null,u!==null?/* @__PURE__ */f(T,{onPress:()=>r(false),accessibilityRole:"button",accessibilityLabel:u,style:a.close,hitSlop:o!==null?Lh:void 0,testID:"everfur-top-card-close",children:e.renderIcon!==void 0?/* @__PURE__ */f(HostRender,{render:()=>e.renderIcon?.("close"),fallback:p}):p}):null]}),
|
|
231
|
+
/* @__PURE__ */f(Text,{tier:"heading",style:a.title,accessibilityRole:"header",children:e.title}),e.lead!==void 0||e.body!==void 0?/* @__PURE__ */h(S,{style:a.finding,children:[
|
|
232
|
+
/* @__PURE__ */f(S,{style:a.dot}),
|
|
233
|
+
/* @__PURE__ */h(Text,{style:a.findingText,children:[e.lead!==void 0?/* @__PURE__ */f(Text,{style:a.lead,children:e.lead}):null,e.lead!==void 0&&e.body!==void 0?" ":null,e.body??null]})]}):null,d!==void 0||c!==void 0?/* @__PURE__ */h(S,{style:a.actions,children:[d!==void 0?/* @__PURE__ */f(T,{onPress:()=>{dn(d.onPress)},accessibilityRole:"button",accessibilityLabel:d.label,style:a.action,hitSlop:o!==null?Lh:void 0,children:/* @__PURE__ */f(Text,{tier:"control",style:a.actionText,children:d.label})}):null,c!==void 0?/* @__PURE__ */f(T,{onPress:()=>n(c.prompt),accessibilityRole:"button",accessibilityLabel:c.label,style:a.ask,hitSlop:o!==null?Lh:void 0,children:/* @__PURE__ */f(Text,{tier:"control",style:a.askText,children:c.label})}):null]}):null]})}function TopCardPill({card:e,open:t,onOpenChange:r}){let n=useEverfurTheme(),i=ff(),o=l(()=>i!==null?Eh(i):Oh(n),[n,i]);if(t||e.closeLabel===void 0)return null;let a=e.pill??e.kicker;/* @__PURE__ */
|
|
234
|
+
return h(T,{onPress:()=>r(true),accessibilityRole:"button",accessibilityLabel:a,accessibilityState:{expanded:false},style:o.pill,hitSlop:i!==null?Lh:void 0,testID:"everfur-top-card-pill",children:[
|
|
235
|
+
/* @__PURE__ */f(S,{style:o.pillDot}),
|
|
236
|
+
/* @__PURE__ */f(Text,{tier:"control",style:o.pillText,numberOfLines:1,children:a})]})}var Lh=4,HOME_CLOSE_GLYPH=e=>{let t=e.icon(".ask-focus__x svg").width;return typeof t=="number"?t:Rh};function Eh(e){let t=e.text(".hp-need__s",".ask-focus .hp-need__s"),r=typeof t.lineHeight=="number"?t.lineHeight:21,n=e.view(".dot",".dot--risk"),l=typeof n.height=="number"?n.height:Th;return{card:e.view(".ask-focus"),kickerRow:e.view(".hp-need__k"),kicker:[e.text(".hp-need__k"),{flexShrink:1}],badge:[e.view(".hp-srcs"),e.view(".hp-src",".hp-src--dna"),{flexShrink:1}],badgeText:e.text(".hp-src",".hp-src--dna"),close:e.view(".ask-focus__x"),title:[e.view(".ask-focus h3"),e.text(".ask-focus h3")],finding:[e.view(".hp-need__s"),{alignItems:"flex-start"}],dot:[e.col(".hp-need__s",0),n,{marginTop:Math.round((r-l)/2)}],findingText:[e.col(".hp-need__s",1),t],lead:(({fontFamily:e,fontWeight:t,color:r})=>({fontFamily:e,fontWeight:t,color:r}))(e.strong(".hp-need__s b")),actions:e.view(".ask-focus__acts"),action:[e.view(".emb-btn",".emb-btn--sm"),{maxWidth:"100%"}],actionText:e.text(".emb-btn",".emb-btn--sm"),ask:[e.view(".ask-focus__q"),{justifyContent:"center",maxWidth:"100%"}],askText:e.text(".ask-focus__q"),pill:[e.view(".ask-focus-pill"),{maxWidth:"100%"}],pillDot:e.view(".ask-focus-pill i"),pillText:[e.text(".ask-focus-pill"),{flexShrink:1}]}}function Oh(e){let t=e.color,r=e.space;return v.create({card:{paddingTop:hh,paddingHorizontal:gh,paddingBottom:gh,borderRadius:fh,backgroundColor:t.surface,borderWidth:1,borderColor:t.borderRingCream,alignSelf:"stretch"},kickerRow:{flexDirection:"row",alignItems:"center",gap:r.sm,minHeight:lu-8},kicker:{...ph(e),fontSize:yh,color:t.text.primary,flexShrink:1},badge:{marginLeft:"auto",minHeight:wh,justifyContent:"center",paddingHorizontal:9,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,flexShrink:1},badgeText:{...face(e,"bold"),fontSize:vh,color:t.text.secondary},close:{width:lu,height:lu,marginVertical:-4,marginRight:-10,alignItems:"center",justifyContent:"center",borderRadius:lu/2},title:{...ph(e),fontSize:bh,lineHeight:mh,color:t.text.primary,marginTop:r.xs},finding:{flexDirection:"row",gap:r.sm,marginTop:r.xs+2},dot:{width:Th,height:Th,borderRadius:Th/2,marginTop:7,backgroundColor:t.danger},findingText:{...face(e,"regular"),flex:1,fontSize:Ch,lineHeight:Sh,color:t.text.primary},lead:face(e,"bold"),actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.lg,marginTop:14},action:{minHeight:Math.max(Fh,lu),paddingHorizontal:r.lg,borderRadius:e.radius.pill,backgroundColor:t.primary,alignItems:"center",justifyContent:"center",maxWidth:"100%"},actionText:{...face(e,"bold"),fontSize:kh,color:t.onPrimary},ask:{minHeight:lu,justifyContent:"center",maxWidth:"100%"},askText:{...face(e,"bold"),fontSize:xh,color:t.brandInk,textDecorationLine:"underline"},pill:{flexDirection:"row",alignItems:"center",gap:r.sm,minHeight:Math.max(_h,lu),paddingHorizontal:zh,borderRadius:e.radius.pill,backgroundColor:t.badgeBgCritical,alignSelf:"flex-start",maxWidth:"100%"},pillDot:{width:Ph,height:Ph,borderRadius:Ph/2,backgroundColor:t.danger},pillText:{...face(e,"bold"),fontSize:Ih,color:t.danger,flexShrink:1}})}var Ah=/* @__PURE__ */Object.freeze({ink:"#262523",ink2:"#4A4845",ink3:"#6B6863",paper:"#F8F7F4",card:"#FFFFFF",line:"#E7E6E2",tile:"#F2F1EE",shadow:"rgba(38, 37, 35, .07)",riskBg:"#FFE3E1",riskInk:"#B0231B",riskDot:"#E5372B",clearBg:"#E6F4D3",clearInk:"#2F6A12",clearDot:"#5FA82B",watchDot:"#E5A000"}),jh=/* @__PURE__ */new WeakMap;function Dh(e){let t=jh.get(e);if(t!==void 0)return t;let r=e.color,n=e.brightness==="dark",l=n?{dark:n,ink:r.text.primary,ink2:r.text.secondary,ink3:r.text.muted,paper:r.background,card:r.surface,line:r.borderRingCream,tile:r.surfaceSubtle,shadow:r.shadow,riskBg:r.badgeBgCritical,riskInk:r.danger,riskDot:r.danger,clearBg:r.badgeBgPositive,clearInk:r.success,clearDot:r.success,watchDot:r.warningStrong}:{dark:n,...Ah},i=(e,t)=>_s(e,t,vs(t),Mh),o=(e,t)=>contrastRatio(e,t)>=Mh?e:ys(t,Mh),a=[l.card,l.paper].map(e=>xs(r.brandSoft,e)??e),s={primary:r.primary,onPrimary:o(r.onPrimary,r.primary),accent:r.accent,onAccent:o(r.onAccent,r.accent),link:i(r.linkInk,[l.card,l.paper,l.tile]),badge:r.brandSoft,onBadge:i(r.brandInk,a)},u=/* @__PURE__ */Object.freeze({...l,...s});return jh.set(e,u),u}var Mh=4.5;function Bh(e,t){for(let r of t)if(contrastRatio(r,e)>=Mh)return r;return ys(e,Mh)}function Hh(e,t,r){let n=Rs(e,t);return(n===null?null:xs(n,r))??r}function Wh(e){let t=Dh(e),r=e.color,n=t.card;return{ink:t.ink,ink2:t.ink2,ink3:t.ink3,paper:t.paper,tile:t.tile,line:t.line,card:n,onInk:t.dark?r.background:"#FFFFFF",primary:t.primary,onPrimary:t.onPrimary,accent:t.accent,onAccent:Bh(t.accent,[t.ink,t.onAccent]),accent2:Hh(t.accent,.75,n),accent4:Hh(t.accent,.17,n),accentChip:Hh(t.accent,.47,n),link:t.link,linkChip:Hh(t.link,.2,n),riskDot:t.riskDot,riskChip:t.dark?r.badgeBgCritical:"#FFD8D6",clearBg:t.clearBg,clearInk:t.clearInk,clearChip:t.dark?r.badgeBgPositive:"#DDEFC4",byInk:r.brandInk}}var Nh=/* @__PURE__ */new Set(["color","fontSize","fontWeight","fontStyle","lh","ls","family","textAlign","textTransform","textDecorationLine"]),Uh=/* @__PURE__ */new Set(["dur","delay","stagger","ease","tint","k","cols","nowrap"]),$h=["paddingTop","paddingRight","paddingBottom","paddingLeft"],Vh=17,qh=1.5,Gh=400,Kh=700;function Yh(e){return e<=450?"regular":e<=650?"medium":"bold"}function Qh(e){let t=Math.min(900,Math.max(100,Math.round(e/100)*100));return String(t)}function Zh(e,t,r){if(t==="$mono"){let t=r<=450?"mono":r<=650?"monoMedium":"monoBold",n=face(e,t);return n.fontWeight===void 0?{fontFamily:n.fontFamily}:{fontFamily:n.fontFamily,fontWeight:Qh(r)}}let n=t==="$serif"?headingFace(e,Yh(r)):face(e,Yh(r));return n.fontWeight===void 0?{fontFamily:n.fontFamily}:{fontFamily:n.fontFamily,fontWeight:Qh(r)}}function Jh(e,t,r={}){let n=Wh(e),l=e.brightness==="dark",i=e.motion.reducedMotion,o=e=>{if(typeof e=="string"&&e.startsWith("$")){let t=e.slice(1);return t.startsWith("n_")?l?n.line??e:`#${t.slice(2)}`:t==="sans"||t==="serif"||t==="mono"?e:n[t]??e}return Array.isArray(e)?e.map(e=>o(e)):e},a=/* @__PURE__ */new Map,s=e=>{let n=e.filter(e=>typeof e=="string"&&e!==""),l=n.join("|"),s=a.get(l);if(s!==void 0)return s;let u={},d=e=>{if(e!==void 0)for(let[t,r]of Object.entries(e))u[t]=o(r)};for(let e of n)d(t[e]),i&&d(r[e]);let c=/* @__PURE__ */Object.freeze(u);return a.set(l,c),c},u=/* @__PURE__ */new Map,d=(...e)=>{let t=e.filter(Boolean).join("|"),r=u.get(t);if(r!==void 0)return r;let n=s(e),l={};for(let[e,t]of Object.entries(n))Nh.has(e)||Uh.has(e)||e==="ring"||e==="edge"||e==="shadow"||e==="round"||e==="zIndex"&&typeof t=="number"&&t<0||t!==null&&(l[e]=t);if((typeof n.fontSize=="number"||n.flexDirection==="row")&&n.position!=="absolute"&&typeof n.height=="number"&&typeof n.width!="number"){let e=l.height;delete l.height,typeof l.minHeight!="number"&&(l.minHeight=e)}let i=n.ring;if(Array.isArray(i)){let[e,t]=i;l.borderWidth=e,l.borderColor=t;for(let t of $h){let r=l[t];typeof r=="number"&&(l[t]=Math.max(0,r-e))}}let o=n.edge;if(Array.isArray(o)){let[e,t]=o;l.borderBottomWidth=e,l.borderBottomColor=t}let a=n.shadow;if(Array.isArray(a)){let[e,t,r,n]=a;l.shadowColor=n,l.shadowOffset={width:e,height:t},l.shadowOpacity=1,l.shadowRadius=r/2}if(n.round===1){let e=typeof n.width=="number"?n.width:typeof n.height=="number"?n.height:999;l.borderRadius=e/2}let d=/* @__PURE__ */Object.freeze(l);return u.set(t,d),d},c=/* @__PURE__ */new Map,p=(t,r)=>{let l=`${t}|${r.filter(Boolean).join("|")}`,i=c.get(l);if(i!==void 0)return i;let o=s(r),a=typeof o.fontSize=="number"?o.fontSize:Vh,u=typeof o.lh=="number"?o.lh:qh,d=typeof o.fontWeight=="string"?Number(o.fontWeight):t,p=typeof o.family=="string"?o.family:"$sans",f={...Zh(e,p,d),fontSize:a,lineHeight:Math.round(a*u*100)/100,color:typeof o.color=="string"?o.color:n.ink};typeof o.ls=="number"&&(f.letterSpacing=Math.round(o.ls*a*100)/100);for(let e of["fontStyle","textAlign","textTransform","textDecorationLine"])typeof o[e]=="string"&&(f[e]=o[e]);let h=/* @__PURE__ */Object.freeze(f);return c.set(l,h),h};return{reduced:i,colors:n,view:d,text:(...e)=>p(Gh,e),strong:(...e)=>p(Kh,e),icon:(...e)=>{let t=s(e),r={tintColor:typeof t.color=="string"?t.color:n.ink};for(let e of["width","height","opacity"])typeof t[e]=="number"&&(r[e]=t[e]);return r},col:(e,t)=>{let r=s([e]).cols;if(!Array.isArray(r))return{};let n=r[Math.min(t,r.length-1)];if(typeof n=="number")return{width:n,flexShrink:0};let l=typeof n=="string"?Number.parseFloat(n):1;return{flex:Number.isFinite(l)?l:1,minWidth:0}},motion:(...e)=>{let t=s(e),r=t.ease;return{dur:typeof t.dur=="number"?t.dur:0,delay:typeof t.delay=="number"?t.delay:0,stagger:typeof t.stagger=="number"?t.stagger:0,ease:Array.isArray(r)&&r.length===4?r:null}},raw:(e,...t)=>s(t)[e]}}var Xh={".serif":{family:"$serif",fontWeight:"800",ls:-.01},".emb-btn":{flexDirection:"row",alignItems:"center",justifyContent:"center",minHeight:48,paddingTop:0,paddingRight:22,paddingBottom:0,paddingLeft:22,borderRadius:999,backgroundColor:"$primary",color:"$onPrimary",fontWeight:"700",fontSize:16,textDecorationLine:"none",dur:160,ease:[.23,1,.32,1],gap:8},".emb-btn--sm":{minHeight:40,paddingTop:0,paddingRight:16,paddingBottom:0,paddingLeft:16,fontSize:15},".dot":{width:9,height:9,round:1,flexGrow:0,flexShrink:0},".dot--risk":{backgroundColor:"$riskDot"},".ask-chips":{flexDirection:"column",alignItems:"center",marginTop:22,gap:10},".chip":{paddingTop:10,paddingRight:16,paddingBottom:10,paddingLeft:16,borderRadius:999,fontSize:15,fontWeight:"600",lh:1.3,textAlign:"center",dur:160,ease:[.23,1,.32,1]},".ask-empty":{minHeight:"100%",flexDirection:"column",alignItems:"center",paddingTop:14,paddingRight:16,paddingBottom:22,paddingLeft:16,textAlign:"center"},".ask-empty h2":{fontSize:23,lh:1.12},".ask-start":{width:"100%",marginTop:"auto",marginRight:0,marginBottom:"auto",marginLeft:0,paddingTop:18,paddingRight:0,paddingBottom:18,paddingLeft:0,flexDirection:"column",alignItems:"center"},".ask-empty .ask-chips":{marginTop:14,alignSelf:"center",alignItems:"stretch",width:"100%",maxWidth:340},".hp-need__k":{flexDirection:"row",alignItems:"center",fontSize:15,fontWeight:"800",gap:8},".hp-srcs":{marginLeft:"auto",flexDirection:"row",gap:4},".hp-src":{height:24,paddingTop:0,paddingRight:9,paddingBottom:0,paddingLeft:9,borderRadius:999,backgroundColor:"$tile",color:"$ink2",fontSize:12,fontWeight:"700",flexDirection:"row",alignItems:"center",nowrap:1},".hp-src--dna":{backgroundColor:"$n_E0FDFF",color:"$link"},".hp-need__s":{alignItems:"baseline",marginTop:6,fontSize:15,lh:1.45,color:"$ink2",flexDirection:"row",cols:[9,"1fr"],gap:9},".hp-need__s b":{color:"$ink",fontWeight:"800"},".ask-focus":{width:"100%",paddingTop:14,paddingRight:16,paddingBottom:16,paddingLeft:16,borderRadius:20,backgroundColor:"$card",textAlign:"left",shadow:[0,1,3,"rgba(38, 37, 35, .07)"]},".ask-focus h3":{marginTop:10,fontSize:18,fontWeight:"800",lh:1.22},".ask-focus__x":{width:36,height:36,marginTop:-8,marginRight:-10,marginBottom:-8,marginLeft:-2,alignItems:"center",justifyContent:"center",round:1,color:"$ink2"},".ask-focus__x svg":{width:18,height:18},".ask-focus-pill":{marginLeft:"auto",flexDirection:"row",alignItems:"center",minHeight:36,paddingTop:0,paddingRight:14,paddingBottom:0,paddingLeft:14,borderRadius:999,backgroundColor:"$n_FFE3E1",color:"$n_B0231B",fontSize:15,fontWeight:"800",gap:7},".ask-focus-pill i":{width:8,height:8,round:1,backgroundColor:"$riskDot"},".ask-focus .hp-need__s":{fontSize:14.5},".ask-focus__acts":{flexDirection:"row",flexWrap:"wrap",alignItems:"center",marginTop:12,rowGap:4,columnGap:16},".ask-focus__q":{minHeight:36,fontSize:14.5,fontWeight:"700",color:"$link",textDecorationLine:"underline"},".ask-top":{alignSelf:"stretch",flexDirection:"row",marginTop:-8,marginRight:0,marginBottom:6,marginLeft:0},".thread__hist":{flexDirection:"row",alignItems:"center",minHeight:36,paddingTop:0,paddingRight:4,paddingBottom:0,paddingLeft:4,fontSize:15,fontWeight:"700",color:"$link",gap:6},".thread__hist svg":{width:18,height:18},".thread__count":{minWidth:22,height:20,paddingTop:0,paddingRight:6,paddingBottom:0,paddingLeft:6,borderRadius:999,backgroundColor:"$card",color:"$ink2",fontSize:12,fontWeight:"800",alignItems:"center",justifyContent:"center",ring:[1,"$line"]}},eg=16;var tg=4e3,rg=.5;function ng(e,t,r){let n=1,l=-1;for(let i of e)l<0?l=i:l+t+i<=r?l+=t+i:(n+=1,l=i);return n}function lg(e,t,r){if(e.length===0)return r;let n=ng(e,t,r),l=[];for(let n=0;n<e.length;n+=1){let i=0;for(let o=n;o<e.length;o+=1)i+=(o>n?t:0)+e[o],i<=r&&l.push(i)}l.sort((e,t)=>e-t);let i=rg*e.length+1;for(let o of l)if(ng(e,t,o)<=n)return Math.min(r,o+i);return r}function BalancedTitle({text:e,style:t,measureCh:r}){let n=l(()=>e.split(/\s+/).filter(e=>e!==""),[e]),a=v.flatten(t),s=[e,a.fontFamily,a.fontSize,a.fontWeight,a.letterSpacing].join("|"),u=i({key:"",ch:null,line:null,words:[]});u.current.key!==s&&(u.current={key:s,ch:null,line:null,words:n.map(()=>null)});let[d,c]=o(null),p=d!==null&&d.key===s?d.value:null,g=()=>{let e=u.current;if(e.ch===null||e.line===null||e.words.some(e=>e===null))return;let t=e.words,n=t.reduce((e,t)=>e+t,0),l=t.length>1?Math.max(0,(e.line-n)/(t.length-1)):0,i=lg(t,l,(e.ch+rg)*r);c(t=>t!==null&&t.key===e.key&&t.value===i?t:{key:e.key,value:i})},b=e=>t=>{u.current.key===s&&(e(u.current,t.nativeEvent.layout.width),g())};/* @__PURE__ */
|
|
237
|
+
return h(S,{style:ig.wrap,children:[
|
|
238
|
+
/* @__PURE__ */f(Text,{tier:"heading",style:p===null?t:[t,{maxWidth:p}],accessibilityRole:"header",children:e}),
|
|
239
|
+
/* @__PURE__ */f(S,{style:ig.probeClip,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:/* @__PURE__ */h(S,{style:ig.probeRow,children:[
|
|
240
|
+
/* @__PURE__ */f(Text,{tier:"heading",style:t,onLayout:b((e,t)=>{e.ch=t}),children:"0"}),
|
|
241
|
+
/* @__PURE__ */f(Text,{tier:"heading",style:t,onLayout:b((e,t)=>{e.line=t}),children:n.join(" ")}),n.map((e,r)=>/* @__PURE__ */f(Text,{tier:"heading",style:t,onLayout:b((e,t)=>{e.words[r]=t}),children:e},`${r}:${e}`))]})})]})}var ig=v.create({wrap:{alignSelf:"stretch",alignItems:"center"},probeClip:{position:"absolute",left:0,top:0,width:0,height:0,overflow:"hidden",opacity:0},probeRow:{width:tg,flexDirection:"row",alignItems:"flex-start"}});function og(e){return{kit:Jh(e,Xh),Title:BalancedTitle,titleCh:eg}}var ag=/* @__PURE__ */Symbol.for("everfur.sdk.rn.poweredBy");function sg(){let e=globalThis,t=e[ag];if(t!==void 0)return t;let r={count:0,listeners:/* @__PURE__ */new Set};return e[ag]=r,r}var ug=e=>{let t=sg();return t.listeners.add(e),()=>t.listeners.delete(e)},dg=()=>sg().count>0;function useHostPoweredBy(){return s(ug,dg,dg)}function EverfurPoweredBy({children:e,style:t}){let r=useEverfurTheme().meta.hidePoweredBy;return a(()=>{if(r)return;let e=sg();return e.count+=1,e.listeners.forEach(e=>e()),()=>{e.count-=1,e.listeners.forEach(e=>e())}},[r]),r?null:e??/* @__PURE__ */f(Text,{tier:"compact",style:t,accessibilityRole:"text",children:rt.poweredBy})}var cg=/* @__PURE__ */Object.freeze({}),pg=100,fg=20;function hg(e,t,r,n){return![e,t,r,n].every(Number.isFinite)||e+r>n+1?null:{chatTop:Math.max(0,e),parentTop:Math.max(0,e-t)}}function gg(e,t){let r=typeof e=="number"&&Number.isFinite(e),s=i(null),[u,d]=o(null),c=i(null),p=i(null),f=i(true),h=n(()=>{p.current!==null&&clearTimeout(p.current),p.current=null},[]);a(()=>(f.current=true,()=>{f.current=false,h()}),[h]);let g=n(function e(t){s.current?.measureInWindow((r,n)=>{let l=c.current;if(!f.current||l===null)return;let i=hg(n,l.y,l.height,_.get("window").height);if(i!==null){d(e=>e!==null&&e.chatTop===i.chatTop&&e.parentTop===i.parentTop?e:i);return}t>=fg||(p.current=setTimeout(()=>{p.current=null,e(t+1)},pg))})},[]),b=n(e=>{let{y:t,height:r}=e.nativeEvent.layout;c.current={y:t,height:r},h(),g(0)},[g,h]);return l(()=>{if(!t)return{avoidingProps:r?{keyboardVerticalOffset:e}:cg,probeRef:null,topInWindow:null};let n=u?.parentTop??0;return{avoidingProps:r?{keyboardVerticalOffset:e,onLayout:b}:n>0?{keyboardVerticalOffset:n,onLayout:b}:{onLayout:b},probeRef:s,topInWindow:u?.chatTop??null}},[t,r,e,u,b])}function KeyboardOffsetProbe({probeRef:e}){return e===null?null:/* @__PURE__ */f(S,{ref:e,collapsable:false,pointerEvents:"none",style:bg})}var bg=/* @__PURE__ */Object.freeze({position:"absolute",top:0,left:0,width:0,height:0});function mg(){let[e,t]=o(false);return a(()=>{let e=z;if(typeof e?.addListener!="function")return;let r=w.OS==="ios",n=e.addListener(r?"keyboardWillShow":"keyboardDidShow",()=>t(true)),l=e.addListener(r?"keyboardWillHide":"keyboardDidHide",()=>t(false));return()=>{n.remove(),l.remove()}},[]),e}var yg=4.5;var vg=3;function wg(e,t,r){return _s(e,t,vs(t),r)}function kg(e,t){if(e.level==="emergency")return e;let r=e.level==="schedule_soon",n=lp(t),l=r?n.warning:n.info,i=np(t)&&!l?e:Cg(e,t,r);return Sg(i,t.slots.banner)}function Cg(e,t,r){let n=t.color,l=xs(r?n.badgeBgCaution:n.badgeBgInfo,n.surface)??n.surface,i=r?n.cautionAccent:n.infoEdge,o=wg(xs(i,n.surface)??i,[n.surface,n.chatGround],vg),a=wg(r?n.warningStrong:n.info,[l,n.surface],yg);/* @__PURE__ */
|
|
242
|
+
return Object.freeze({...e,borderColor:o,backgroundColor:l,textColor:a,reasonColor:wg(n.text.primary,[l],yg),pillColor:n.surface})}function Sg(e,t){if(t===void 0)return e;let r={...e};return t.backgroundColor!==void 0&&(r.backgroundColor=t.backgroundColor),t.borderColor!==void 0&&(r.borderColor=t.borderColor),t.textColor!==void 0&&(r.textColor=t.textColor,r.reasonColor=t.textColor),/* @__PURE__ */Object.freeze(r)}function xg(petRef,e){let t={entry:"chat",petRef:petRef};return e?.returnTo!==void 0&&(t.returnTo=e.returnTo),e?.usState!==void 0&&(t.usState=e.usState),e?.prefer!==void 0&&(t.prefer=e.prefer),t}var Rg=.75,Tg=1.5,_g=.4,zg=4,Ig=1.5,Pg=22,Fg=14,Lg=8,Eg=20,Og=10,Ag=13,jg=12,Dg=15,Mg=44,Bg=14,Hg=1.25,Wg=14,Ng=6,Ug=2;function $g(e,t){let r=e.color;if(t.level==="emergency")return{card:{backgroundColor:r.badgeBgCritical,borderColor:Rs(r.danger,_g)??r.danger,borderWidth:Tg},label:r.danger,reason:r.text.primary,close:r.danger,action:{fill:r.surface,edge:r.danger,ink:r.danger}};let n=e.slots.banner?.borderRadius;return{card:{backgroundColor:t.backgroundColor,borderColor:t.borderColor,borderWidth:Rg,...n===void 0?{}:{borderRadius:n}},label:t.textColor,reason:t.reasonColor,close:t.textColor,action:null}}function UrgencyBanner({surface:e,petRef:petRef,renderVetAction:t,onFindVet:r,vet:n,compact:i=false}){let o=useEverfurTheme(),a=l(()=>Vg(o),[o]),s=Mo(),u=e.tier===null?null:kg(e.tier,o),d=e.source;/* @__PURE__ */
|
|
243
|
+
return h(g,{children:[
|
|
244
|
+
/* @__PURE__ */f(FadePresence,{visible:e.showBanner&&u!==null,inMs:s.bannerInMs,outMs:s.bannerOutMs,style:a.pinned,children:u!==null&&d!==null?/* @__PURE__ */f(BannerCard,{tier:u,reason:d.reason,surface:e,petRef:petRef,renderVetAction:t,onFindVet:r,vet:n,styles:a,compact:i}):null}),
|
|
245
|
+
/* @__PURE__ */f(FadePresence,{visible:e.showCompactIcon,inMs:s.iconInMs,outMs:s.iconOutMs,style:a.indicatorRow,children:/* @__PURE__ */f(PressScale,{accessibilityRole:"button",accessibilityLabel:rt.showLatestVetAlert,hitSlop:Og,onPress:e.expand,children:/* @__PURE__ */f(InfoGlyph,{size:Eg,color:o.color.text.muted,strokeWidth:2})})})]})}function BannerCard({tier:e,reason:t,surface:r,petRef:petRef,renderVetAction:n,onFindVet:l,vet:i,styles:o,compact:a}){let s=useEverfurTheme(),u=$g(s,e),d=/* @__PURE__ */f(VetAction,{tier:e,paint:u,petRef:petRef,onFindVet:l,vet:i,styles:o}),c=r.showVetAction?n!==void 0?/* @__PURE__ */f(HostRender,{render:()=>n(e.level),fallback:d,resetKey:e.level}):d:null,p=u.action!==null?/* @__PURE__ */f(PoisonControl,{paint:u.action,styles:o}):null,g=e.level==="emergency"&&l===void 0,b=e.level==="emergency"||e.level==="schedule_soon";/* @__PURE__ */
|
|
246
|
+
return h(S,{...b?{accessibilityRole:"alert"}:{accessibilityLiveRegion:"polite"},style:[o.card,u.card,a?o.cardCompact:null],testID:a?"chat-urgency-compact":void 0,children:[
|
|
247
|
+
/* @__PURE__ */f(Text,{tier:"control",style:[o.label,{color:u.label}],children:e.label}),t!==null?/* @__PURE__ */f(Text,{style:[o.reason,{color:u.reason}],numberOfLines:a?Ug:void 0,accessibilityLabel:a?t:void 0,children:t}):null,g?/* @__PURE__ */f(Text,{style:[o.reason,o.erLine,{color:u.reason}],children:rt.goToNearestEmergencyVet}):null,c!==null||p!==null?/* @__PURE__ */h(S,{style:o.actions,children:[c,p]}):null,r.dismissLabel!==null?/* @__PURE__ */f(PressScale,{accessibilityRole:"button",accessibilityLabel:r.dismissLabel,hitSlop:Lg,containerStyle:o.closeSlot,style:o.closeButton,onPress:r.dismiss,children:/* @__PURE__ */f(CloseGlyph,{size:Fg,color:u.close,strokeWidth:1.5})}):null]})}function PoisonControl({paint:e,styles:t}){let r=()=>{try{x.openURL(ot).catch(()=>{})}catch{}};/* @__PURE__ */
|
|
248
|
+
return f(PressScale,{accessibilityRole:"button",accessibilityLabel:rt.poisonControlNative,hitSlop:0,style:[t.action,{backgroundColor:e.fill,borderColor:e.edge}],onPress:r,children:/* @__PURE__ */f(Text,{tier:"control",style:[t.actionLabel,{color:e.ink}],children:rt.poisonControlNative})})}function VetAction({tier:e,paint:t,petRef:petRef,onFindVet:r,vet:n,styles:l}){let i=useEverfurTheme(),o=useVetVisit(xg(petRef,n)),a=o.status==="opening",s=!o.available&&r!==void 0,u=o.available?()=>{o.open()}:r!==void 0?()=>{dn(r,e.level)}:null;if(u===null)return null;let d=t.action;if(d!==null){let e=s?rt.nearestEmergencyVet:rt.findVet,t=fa(i.slots.vetVisitButton)?.textColor??d.ink;/* @__PURE__ */
|
|
249
|
+
return h(PressScale,{accessibilityRole:"button",accessibilityLabel:s?rt.nearestEmergencyVet:rt.findVetA11y,accessibilityState:{busy:a},hitSlop:0,style:[l.action,{backgroundColor:d.fill,borderColor:d.edge},l.findVetSlotBox,a?l.findVetBusy:null],onPress:u,children:[
|
|
250
|
+
/* @__PURE__ */f(MapPinGlyph,{size:Ag,color:t,strokeWidth:1.5}),
|
|
251
|
+
/* @__PURE__ */f(Text,{tier:"control",style:[l.actionLabel,{color:t}],children:e})]})}let c=fa(i.slots.vetVisitButton)?.textColor??e.textColor;/* @__PURE__ */
|
|
252
|
+
return h(PressScale,{accessibilityRole:"button",accessibilityLabel:rt.findVetA11y,accessibilityState:{busy:a},style:[l.findVetButton,{borderColor:e.borderColor,backgroundColor:e.pillColor},l.findVetSlotBox,a?l.findVetBusy:null],onPress:u,children:[
|
|
253
|
+
/* @__PURE__ */f(MapPinGlyph,{size:Ag,color:c,strokeWidth:1.5}),
|
|
254
|
+
/* @__PURE__ */f(Text,{tier:"control",style:[l.findVetLabel,{color:c}],children:rt.findVet})]})}function Vg(e){let t=fa(e.slots.vetVisitButton),r=e.space,n=e.type;return v.create({pinned:{marginTop:0,marginBottom:r.xs,paddingHorizontal:r.lg},card:{borderRadius:e.radius.lg,paddingHorizontal:r.lg+zg,paddingVertical:r.lg,gap:r.sm},cardCompact:{paddingVertical:r.md,gap:r.xs},label:{...face(e,"bold"),fontSize:n.size.body,paddingRight:Pg},reason:{...face(e,"regular"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*Ig),paddingRight:Pg},erLine:{...face(e,"bold")},actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.sm},action:{flexDirection:"row",alignItems:"center",gap:Ng,minHeight:Mg,paddingHorizontal:Bg,borderRadius:e.radius.pill,borderWidth:Hg},actionLabel:{...face(e,"bold"),fontSize:Wg},findVetButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:e.radius.pill,borderWidth:1},findVetSlotBox:{...pa(t,1)},findVetBusy:{opacity:.6},findVetLabel:{...face(e,"monoBold"),fontSize:jg,lineHeight:Dg},closeSlot:{position:"absolute",top:r.md,right:r.md},closeButton:{width:Pg,height:Pg,borderRadius:Pg/2,alignItems:"center",justifyContent:"center"},indicatorRow:{alignItems:"flex-end",paddingHorizontal:r.lg,paddingTop:2,paddingBottom:r.xs}})}function qg(e,userRef,petRef,t){let[r,n]=o({pet:petRef,user:userRef}),l=r.pet!==petRef||r.user===null&&userRef!==null;l&&n({pet:petRef,user:userRef});let i=l?{user:userRef}:r,s=petRef!==null&&i.user!==null&&i.user!==userRef;return a(()=>{if(!s||userRef===null||petRef===null)return;let t=true,r=createPetsRepository(e.registry.services.authFor(userRef)),l=async()=>{let e=await r.list();t&&e.ok&&e.value.some(e=>e.petRef===petRef)&&n({pet:petRef,user:userRef})};l();let i=yc(e,()=>{l()});return()=>{t=false,i()}},[s,e,userRef,petRef,t]),s}var Gg=/* @__PURE__ */Object.freeze({status:"idle",messages:/* @__PURE__ */Object.freeze([]),conversationId:null,error:null,isStreaming:false,isBootstrapping:true,suggestedPrompts:/* @__PURE__ */Object.freeze([]),unreadCount:null});function useEverfurChat(e){let{runtime:t,userRef:userRef,activePet:r,scopeEpoch:u}=ct(),petRef=e?.petRef??r??null,conversationId=e?.conversationId??null,d=qg(t,userRef,petRef,u),c=l(()=>({runtime:t,userRef:userRef,petRef:petRef,conversationId:conversationId,scopeEpoch:u,held:d}),[t,userRef,petRef,conversationId,u,d]),[p,f]=o(null),h=d?null:p?.scope===c?p.controller:t.registry.peekChat({userRef:userRef,petRef:petRef,conversationId:conversationId}),g=i(null);a(()=>{if(d)return;let e=t.registry.acquireChat({userRef:userRef,petRef:petRef,conversationId:conversationId});return g.current=e,f({scope:c,controller:e}),()=>{g.current=null,f(t=>t?.controller===e?null:t),t.registry.releaseChat(e)}},[t,userRef,petRef,conversationId,u,d,c]);let b=n(e=>h?h.subscribe(e):NOOP_UNSUBSCRIBE,[h]),m=n(()=>h?h.getSnapshot():Gg,[h]),y=s(b,m,m),v=n((e,t)=>h&&g.current===h&&!h.getSnapshot().isBootstrapping?Yg(h,h.send(e,t?.imageS3Keys===void 0?{}:{imageS3Keys:t.imageS3Keys}),()=>g.current===h):Promise.resolve(Zg()),[h]),w=n(e=>h&&g.current===h&&!h.getSnapshot().isBootstrapping?Yg(h,h.askEverfur(e),()=>g.current===h):Promise.resolve(Zg()),[h]),k=n(()=>h&&g.current===h?Yg(h,h.retryLast(),()=>g.current===h):Promise.resolve(Zg()),[h]),C=n(()=>{h&&g.current===h&&h.stop()},[h]),S=n(()=>{h&&g.current===h&&h.newConversation()},[h]),[x,R]=o({controller:null,byMessage:{}}),T=x.controller===h?x.byMessage:Kg,_=n(async(e,t,r,n)=>{if(!h||g.current!==h)return err(makeEverfurError("accessDenied"));let l=String(e),i=x.controller===h?x.byMessage[l]:void 0;if(i===t&&r==null)return R(e=>{let t={...e.controller===h?e.byMessage:{}};return delete t[l],{controller:h,byMessage:t}}),ok(/* @__PURE__ */Object.freeze({feedbackId:""}));R(e=>({controller:h,byMessage:{...e.controller===h?e.byMessage:{},[l]:t}}));let o=await h.submitFeedback(e,Qp(t,r??null),n??null);return g.current!==h?err(makeEverfurError("accessDenied")):(o.ok||R(e=>{let t={...e.controller===h?e.byMessage:{}};return i===void 0?delete t[l]:t[l]=i,{controller:h,byMessage:t}}),o)},[h,x]),z=l(()=>{let e=async e=>{if(!h||g.current!==h)return err(makeEverfurError("accessDenied"));let t=await e(h);return g.current===h?t:err(makeEverfurError("accessDenied"))};return{listConversations:t=>e(e=>e.listConversations({...petRef?{petRef:petRef}:{},...t})),getMessages:(t,r)=>e(e=>e.getMessages(t,r)),resumeConversation:t=>e(e=>e.resumeConversation(t)),loadOlderMessages:()=>e(e=>e.loadOlderMessages()),markRead:()=>e(e=>e.markRead()),refreshActiveThread:t=>e(e=>e.refreshActiveThread(t)),answerCheckin:(t,r)=>e(e=>e.answerCheckin(t,r)),openCheckin:t=>e(e=>e.openCheckin(t))}},[h,petRef]);return l(()=>({status:y.status,messages:y.messages,conversationId:y.conversationId,petRef:petRef,error:y.error,isStreaming:y.isStreaming,isBootstrapping:y.isBootstrapping,historyCursor:y.historyCursor??null,isLoadingHistory:y.isLoadingHistory??false,stopped:y.stopped??false,reconnecting:y.reconnecting??false,...z,suggestedPrompts:y.suggestedPrompts,unreadCount:y.unreadCount,hasUnreadThreads:y.hasUnreadThreads??false,pendingCheckin:y.pendingCheckin??null,newConversation:S,sentimentByMessage:T,feedback:_,send:v,askEverfur:w,retryLast:k,stop:C}),[y,petRef,v,w,k,C,z,S,T,_])}var NOOP_UNSUBSCRIBE=()=>{},Kg=/* @__PURE__ */Object.freeze({});async function Yg(e,t,r){for await(let e of t);if(!r())return err(makeEverfurError("accessDenied"));let n=e.getSnapshot();return n.status==="error"&&n.error!==null?err(n.error):ok(Qg(n.messages))}function Qg(e){for(let t=e.length-1;t>=0;t-=1){let r=e[t];if(r&&r.role==="assistant"&&r.responseId!==void 0)return r.responseId}return null}function Zg(){return di()}function Jg(){let e=useEverfurPets(),{handle:t}=ct(),r=n(petRef=>t.setActivePet(petRef),[t]);return l(()=>({...e,setActivePet:r}),[e,r])}function Xg(){try{let e=E?.announceForAccessibility;typeof e=="function"&&e.call(E,rt.answered)}catch{}}function eb(e){let t=i(false),r=i({send:e.send,id:e.conversationId});a(()=>{let n=r.current;if((n.send!==e.send||n.id!==null&&n.id!==e.conversationId)&&(t.current=false),r.current={send:e.send,id:e.conversationId},t.current&&!e.isStreaming){let t=e.messages[e.messages.length-1];t!==void 0&&t.role==="assistant"&&Xg()}t.current=e.isStreaming},[e.isStreaming,e.messages,e.send,e.conversationId])}var tb=/* @__PURE__ */Object.freeze({kind:"live"}),rb=/* @__PURE__ */Object.freeze({kind:"folded"});function nb(e){if(e.role!=="assistant"||e.checkin===void 0)return null;let t=e.checkin.caseId,r=Ai(e.proactiveOriginRef);return{caseId:t,dueDay:r!==null&&r.caseId===t?r.dueDay:""}}function lb(e){let t=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;for(let t of e){let e=nb(t);if(e===null)continue;let n=r.get(e.caseId);(n===void 0||e.dueDay>=n.dueDay)&&r.set(e.caseId,{messageId:t.id,dueDay:e.dueDay})}if(r.size===0)return t;let n=null;for(let l of e){let e=nb(l);if(e===null){n=null;continue}if(r.get(e.caseId)?.messageId===l.id){t.set(l.id,tb),n=null;continue}if(n!==null&&n.caseId===e.caseId){n.days.push(e.dueDay),t.set(l.id,rb);continue}let i=[e.dueDay];n={id:l.id,caseId:e.caseId,days:i},t.set(l.id,{kind:"past",runDueDays:i})}return t}function ib(e){let t=/* @__PURE__ */new Set;for(let[r,n]of e)n.kind==="live"&&t.add(r);return t}var ob=864e5,ab=365;function sb(e,t){if(typeof e!="string"||typeof t!="string")return null;let r=Date.parse(e),n=Date.parse(t);if(Number.isNaN(r)||Number.isNaN(n))return null;let l=Math.floor(n/ob)-Math.floor(r/ob);return l<1||l>ab?null:l}function ub(e){return nb(e)?.dueDay||null}function db(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}function AssistantSender({avatarUrl:e,named:t,styles:r}){let n=Zc(e);return n.shown?/* @__PURE__ */h(S,{style:r.assistantSender,testID:"everfur-assistant-sender",children:[
|
|
255
|
+
/* @__PURE__ */f(BrandImage,{uri:e,decorative:true,style:r.assistantAvatar,resizeMode:"cover",onError:n.onError,testID:"everfur-assistant-avatar"}),t?/* @__PURE__ */f(Text,{tier:"control",style:[r.assistantName,r.assistantNameInRow],children:rt.assistantName}):null]}):t?/* @__PURE__ */f(Text,{tier:"control",style:r.assistantName,children:rt.assistantName}):null}var cb=/* @__PURE__ */Object.freeze({TIER_1:"#07C168",TIER_2:"#27A9FF",TIER_3:"#FBC558"}),pb="#C8BEB4";function fb(e){return e?cb[e.toUpperCase()]??pb:pb}function hb(e){if(!e)return null;let t=/^tier[_\s-]?(\d+)$/i.exec(e.trim());return t?`Tier ${t[1]}`:e}function gb(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}function bb(e){let t=gb(e);return t!==null&&/^https:\/\/\S+$/i.test(t)?t:null}function mb(e,t){let r=gb(e.source_name)??gb(e.sourceName),n=gb(e.section),l=gb(e.authority_tier)??gb(e.authorityTier),i=hb(l),o=r??gb(e.title)??`Source ${t+1}`,a=gb(e.monograph_chunk_id)??gb(e.chunkId),s=[n,i].filter(e=>e!==null).join(" · ");/* @__PURE__ */
|
|
256
|
+
return Object.freeze({title:o,sourceName:r,section:n,authorityTier:l,tierLabel:i,meta:s.length===0?null:s,url:bb(e.url),excerpt:gb(e.excerpt),tierColor:fb(l),key:`${o}-${a??"none"}-${t}`})}function yb(e){return e===void 0||e.length===0?vb:/* @__PURE__ */Object.freeze(e.map((e,t)=>mb(e,t)))}var vb=/* @__PURE__ */Object.freeze([]);function wb(e){return e===1?`1 ${rt.sourceSingular}`:`${e} ${rt.sourcePlural}`}function kb(e,t){return`${t?rt.hideSources:rt.showSources} ${wb(e)}`}function Cb(e){return[e.url!==null?`${rt.openSource}: ${e.title}`:e.title,e.meta,e.excerpt].filter(e=>e!==null&&e.length>0).join(". ")}var Sb="https:\\/\\/sdk(?:-[a-z]+)?\\.everfur\\.com";function xb(e){return e.replace(/[.*+?^${}()|[\]\\/]/g,"\\$&")}typeof __EVERFUR_BRAND_CDN_ORIGIN__=="string"&&__EVERFUR_BRAND_CDN_ORIGIN__.length>0?xb(__EVERFUR_BRAND_CDN_ORIGIN__):Sb;function hardenHttpsUrl(e){if(e===null)return null;let t=e.trim();return t.length===0?null:/^https:\/\/\S+$/i.test(t)?t:null}function Rb(e){let t=e.split(/\n\s*\n/).map(e=>e.trim()).filter(e=>e.length>0);return t.length>0?t:[e]}var Tb=/^\s*[-*]\s+(\S.*)$/,_b=/^\s*(\d{1,3})[.)]\s+(\S.*)$/;function zb(e){let t=[],r=[],n=null,l=()=>{r.length>0&&t.push({kind:"text",text:r.join(`\n`)}),r=[]},i=()=>{n!==null&&t.push(n.ordered?{kind:"list",ordered:true,start:n.start,items:n.items}:{kind:"list",ordered:false,items:n.items}),n=null};for(let t of e.split(`\n`)){let e=Tb.exec(t),o=e===null?_b.exec(t):null,a=e?.[1]??o?.[2];if(a===void 0){i(),r.push(t);continue}let s=o!==null;l(),n!==null&&n.ordered!==s&&i(),n===null&&(n={ordered:s,start:o===null?1:Number(o[1]),items:[]}),n.items.push(a.trim())}return l(),i(),t}function Ib(e,t){let r=e.findIndex(e=>e.id===t);for(let t=r-1;t>=0;t-=1){let r=e[t];if(r!==void 0&&r.role==="user")return r.text}return null}function Pb(e,t){if(e===void 0)return[];try{let r=e(t);return Array.isArray(r)?r:[]}catch{return[]}}function Fb(e){return hardenHttpsUrl(e.trim())}function Lb(e,t){if(t?.followUpActions===void 0||e.isStreaming||e.status==="error")return[];let r=e.messages[e.messages.length-1];return r===void 0||r.role!=="assistant"||r.pending===true?[]:Pb(t.followUpActions,{answer:r.text,question:Ib(e.messages,r.id),messageId:r.id})}var Eb=/\*\*([^*]+?)\*\*|\*([^*]+?)\*|`([^`]+?)`/g,Ob=new RegExp(`\\[([^\\]\\n]{1,300})\\]\\((https:\\/\\/[^\\s()<>]{1,${wo}})\\)|(https:\\/\\/[^\\s<>"'\`*\\[\\]]{1,${wo}})`,"gi"),Ab=/https:\/\//i,jb=`.,;:!?'"`;function Db(e,t){return e.includes("*")||e.includes("`")||t!==void 0&&Ab.test(e)}function Mb(e,t){let r=[],n=e=>{t===void 0?r.push({kind:"text",text:e}):Wb(r,e,t)},l=0;Eb.lastIndex=0;for(let t=Eb.exec(e);t!==null;t=Eb.exec(e)){t.index>l&&n(e.slice(l,t.index));let i=t[1],o=t[2],a=t[3];i!==void 0?r.push({kind:"bold",text:i}):o!==void 0?r.push({kind:"italic",text:o}):a!==void 0&&r.push({kind:"code",text:a}),l=t.index+t[0].length}return l<e.length&&n(e.slice(l)),r}function Bb(e){let t=e.length;for(;;){let r=e[t-1];if(r===void 0)break;if(jb.includes(r))t-=1;else if(r===")"&&Hb(e,"(",t)<Hb(e,")",t))t-=1;else break}return e.slice(0,t)}function Hb(e,t,r){let n=0;for(let l=0;l<r;l+=1)e[l]===t&&(n+=1);return n}function Wb(e,t,r){if(!Ab.test(t)){e.push({kind:"text",text:t});return}let n=0;Ob.lastIndex=0;for(let l=Ob.exec(t);l!==null;l=Ob.exec(t)){let i=l[1],o=l[2],a=l[3],s,u,d;if(i!==void 0&&o!==void 0)s=i.trim(),u=s.length>0?xo(o,r):null,d=l[0].length;else if(a!==void 0)s=Bb(a),u=xo(s,r),d=s.length;else continue;u!==null&&(l.index>n&&e.push({kind:"text",text:t.slice(n,l.index)}),e.push({kind:"link",text:s,href:u}),n=l.index+d,Ob.lastIndex=n)}n<t.length&&e.push({kind:"text",text:t.slice(n)})}var Nb=/* @__PURE__ */Object.freeze({textDecorationLine:"underline"});function Ub(e,t){return t===void 0||!Db(e,t.hosts)?false:Mb(e,t.hosts).some(e=>e.kind==="link")}function $b(e,t,r){let n=r?.hosts;return Db(e,n)?Mb(e,n).map((e,n)=>{switch(e.kind){case"bold":/* @__PURE__ */
|
|
257
|
+
return f(Text,{style:t.bold,children:e.text},n);case"italic":return t.italic?/* @__PURE__ */f(Text,{style:t.italic,children:e.text},n):e.text;case"code":return t.code?/* @__PURE__ */f(Text,{style:t.code,children:e.text},n):e.text;case"link":{if(r===void 0)return e.text;let{href:t}=e;/* @__PURE__ */
|
|
258
|
+
return f(Text,{style:Nb,accessibilityRole:"link",accessibilityLabel:e.text,onPress:()=>r.open(t),children:e.text},n)}default:return e.text}}):e}var Vb=10.5,qb=16,Gb=12,Kb=38,Yb=11,Qb=15,Zb=22,Jb=32,Xb=13.5,em=14,tm=15,rm=16,nm=13,lm=13,im=26,om=21,am=42,sm=1,um=.06,dm=.07,cm=.12,pm="45%";function fm(){let e=useEverfurTheme(),t=l(()=>hm(e),[e]);return{theme:e,styles:t}}function Chevron({options:e,color:t}){let r=/* @__PURE__ */f(ChevronGlyph,{size:rm,color:t,strokeWidth:2,direction:"right"}),n=e?.renderIcon;return n===void 0?r:/* @__PURE__ */f(HostRender,{render:()=>n("chevron"),fallback:r})}function AnswerCard({card:e,options:t}){let{theme:r,styles:n}=fm();if(e.render!==void 0){let r=e.render;/* @__PURE__ */
|
|
259
|
+
return f(S,{style:[n.card,e.variant!==void 0?t?.styles?.cardVariant?.[e.variant]:null],accessible:false,accessibilityLabel:e.title,testID:"everfur-answer-host-card",children:/* @__PURE__ */f(HostRender,{render:r,fallback:null})})}let l=e.value!==void 0,i=t?.styles,o=[n.card,l?i?.cardStat:null,e.variant!==void 0?i?.cardVariant?.[e.variant]:null],a=e.tile?.tone,s=e.pill?.tone,u=e.tile?.imageUrl!==void 0?Fb(e.tile.imageUrl):null,d=/* @__PURE__ */h(g,{children:[l?null:/* @__PURE__ */f(S,{style:[n.tile,a!==void 0?i?.tileTone?.[a]:null],children:u!==null?/* @__PURE__ */f(L,{source:{uri:u},style:n.tileImage,accessibilityIgnoresInvertColors:true}):e.tile?.icon??null}),
|
|
260
|
+
/* @__PURE__ */h(S,{style:n.cardWords,children:[
|
|
261
|
+
/* @__PURE__ */f(Text,{tier:"control",style:n.cardTitle,children:e.title}),e.meta!==void 0?/* @__PURE__ */f(Text,{tier:"compact",style:n.cardMeta,children:e.meta}):null]}),l?/* @__PURE__ */h(Text,{tier:"control",style:n.stat,children:[e.value?.amount,e.value?.unit!==void 0?/* @__PURE__ */f(Text,{style:n.statUnit,children:e.value.unit}):null]}):/* @__PURE__ */h(g,{children:[e.pill!==void 0?/* @__PURE__ */f(S,{style:[n.pill,s!==void 0?i?.pillTone?.[s]:null],children:/* @__PURE__ */f(Text,{tier:"badge",style:[n.pillText,s!==void 0?i?.pillToneText?.[s]:null],numberOfLines:1,ellipsizeMode:"tail",children:e.pill.label})}):null,e.onPress!==void 0?/* @__PURE__ */f(Chevron,{options:t,color:r.color.text.muted}):null]})]});if(e.onPress!==void 0){let t=e.onPress;/* @__PURE__ */
|
|
262
|
+
return f(T,{onPress:()=>{dn(t)},accessibilityRole:"button",accessibilityLabel:e.title,style:o,children:d})}/* @__PURE__ */
|
|
263
|
+
return f(S,{style:o,children:d})}function CardsAnswer({message:e,text:t,streaming:r,messages:n,options:i,sentiment:o,onSentiment:a,sender:s,footer:u,onOpenUrl:d}){let{styles:c}=fm(),p=l(()=>({answer:e.text,question:Ib(n,e.id),messageId:e.id}),[e.text,e.id,n]),g=!r&&e.pending!==true,b=g?Pb(i?.cards,p):[],m=l(()=>g?yb(e.citations):[],[g,e.citations]),y=i?.byline,v=i?.feedback!==void 0&&e.responseId!==void 0&&a!==void 0?i.feedback:null,w={bold:c.bold,italic:c.italic,code:c.code},k=_o(),C=g?k:void 0;/* @__PURE__ */
|
|
264
|
+
return h(S,{style:c.answer,testID:"everfur-answer-cards",children:[y!==void 0?/* @__PURE__ */h(S,{style:c.byline,children:[y.icon??null,
|
|
265
|
+
/* @__PURE__ */f(Text,{tier:"compact",style:c.bylineText,children:y.label})]}):s,
|
|
266
|
+
/* @__PURE__ */f(S,{style:c.body,children:Rb(t).flatMap((e,t)=>zb(e).map((e,r)=>{let n=`${t}-${r}`;return e.kind==="text"?/* @__PURE__ */f(Text,{style:c.paragraph,children:$b(e.text,w,C)},n):/* @__PURE__ */f(S,{style:c.list,children:e.items.map((t,r)=>/* @__PURE__ */h(S,{style:c.listItem,children:[
|
|
267
|
+
/* @__PURE__ */f(Text,{style:c.paragraph,children:e.ordered?`${e.start+r}.`:"•"}),
|
|
268
|
+
/* @__PURE__ */f(Text,{style:[c.paragraph,c.listText],children:$b(t,w,C)})]},r))},n)}))}),b.length>0?/* @__PURE__ */f(S,{style:c.cards,children:b.map(e=>/* @__PURE__ */f(AnswerCard,{card:e,options:i},e.key))}):null,g?/* @__PURE__ */f(ServerCardsSlot,{message:e}):null,m.length>0?/* @__PURE__ */h(S,{style:c.cards,accessibilityLabel:wb(m.length),children:[
|
|
269
|
+
/* @__PURE__ */f(Text,{tier:"compact",style:c.label,children:rt.sourcesHeading}),m.map(e=>{let t=e.url;/* @__PURE__ */
|
|
270
|
+
return f(AnswerCard,{card:{key:e.key,title:e.title,...e.meta!==null?{meta:e.meta}:{},tile:{icon:/* @__PURE__ */f(SourceTileGlyph,{})},...d!==void 0&&t!==null?{onPress:()=>d(t)}:{}},options:i},e.key)})]}):null,g&&v!==null&&a!==void 0?/* @__PURE__ */h(S,{style:[c.feedback,i?.styles?.feedback],children:[
|
|
271
|
+
/* @__PURE__ */f(FeedbackChip,{label:v.helpful,on:o==="up",onPress:()=>a("up"),styles:c,host:i?.styles}),
|
|
272
|
+
/* @__PURE__ */f(FeedbackChip,{label:v.notHelpful,on:o==="down",onPress:()=>a("down"),styles:c,host:i?.styles})]}):null,g?u(v===null):null]})}function SourceTileGlyph(){let e=useEverfurTheme();/* @__PURE__ */
|
|
273
|
+
return f(BookGlyph,{size:om,color:e.color.linkInk,strokeWidth:1.5})}function FeedbackChip({label:e,on:t,onPress:r,styles:n,host:l}){/* @__PURE__ */
|
|
274
|
+
return f(T,{onPress:r,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{selected:t},style:[n.chip,l?.feedbackChip,t?n.chipOn:null],hitSlop:(lu-Jb)/2,children:/* @__PURE__ */f(Text,{tier:"control",style:[n.chipText,l?.feedbackChipText],children:e})})}function CardsFollowUps({prompts:e,onSelectPrompt:t,label:r,actions:n,options:l}){let{theme:i,styles:o}=fm();if(e.length===0&&n.length===0)return null;let a=l?.styles,s=r??rt.followUpsHeadingNative;/* @__PURE__ */
|
|
275
|
+
return h(S,{style:[o.followUps,a?.followUps],accessibilityLabel:s,testID:"everfur-cards-follow-ups",children:[
|
|
276
|
+
/* @__PURE__ */f(Text,{tier:"compact",style:[o.label,a?.followUpsLabel],accessibilityRole:"header",children:s}),n.map(e=>/* @__PURE__ */h(T,{onPress:()=>{dn(e.onPress)},accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:sm,style:[o.row,o.rowAction,a?.followUp,a?.followUpAction],children:[e.icon??null,
|
|
277
|
+
/* @__PURE__ */f(Text,{tier:"control",style:[o.rowText,o.rowTextAction,a?.followUpText,a?.followUpActionText],children:e.label}),
|
|
278
|
+
/* @__PURE__ */f(Chevron,{options:l,color:i.color.text.primary})]},`action:${e.key}`)),e.map(e=>/* @__PURE__ */h(T,{onPress:()=>t(e),accessibilityRole:"button",accessibilityLabel:e,hitSlop:sm,style:[o.row,a?.followUp],children:[
|
|
279
|
+
/* @__PURE__ */f(Text,{tier:"control",style:[o.rowText,a?.followUpText],children:e}),
|
|
280
|
+
/* @__PURE__ */f(Chevron,{options:l,color:i.color.linkInk})]},e))]})}function CardsByline({label:e}){let{styles:t}=fm();/* @__PURE__ */
|
|
281
|
+
return f(S,{style:t.byline,children:/* @__PURE__ */f(Text,{tier:"compact",style:t.bylineText,children:e})})}function hm(e){let t=e.color,r=e.space,n={...face(e,"mono"),fontSize:Vb,textTransform:"uppercase",color:t.text.muted},l={borderWidth:1,borderColor:t.borderRingCream},i={borderWidth:1,borderColor:Rs(t.text.primary,um)??t.borderRingCream},o={shadowColor:t.text.primary,shadowOffset:{width:0,height:1},shadowOpacity:dm,shadowRadius:2,elevation:1},a=textRole(e,"message"),chipInk=ha(e.slots.chip);return v.create({answer:{gap:r.md,alignSelf:"stretch"},byline:{flexDirection:"row",alignItems:"center",gap:10,minHeight:14},bylineText:{...n,letterSpacing:Vb*.06,flexShrink:1},body:{gap:10},paragraph:{...face(e,"regular"),fontSize:a.fontSize,lineHeight:Math.round(a.lineHeight),color:t.text.primary},list:{gap:4},listItem:{flexDirection:"row",gap:r.sm,paddingLeft:r.xs},listText:{flex:1},bold:face(e,"bold"),italic:{fontStyle:"italic"},code:face(e,"mono"),cards:{gap:r.sm},card:{flexDirection:"row",alignItems:"center",gap:r.md,padding:Gb,borderRadius:qb,backgroundColor:t.surface,...i,...o,minHeight:lu,...pa(e.slots.card)},tile:{width:Kb,height:Kb,borderRadius:Yb,backgroundColor:Rs(t.linkInk,cm)??t.surfaceSubtle,alignItems:"center",justifyContent:"center",overflow:"hidden"},tileImage:{width:Kb,height:Kb},cardWords:{flex:1,minWidth:0},cardTitle:{...face(e,"bold"),fontSize:Qb,lineHeight:Math.round(Qb*1.25),color:t.text.primary,...ha(e.slots.card)},cardMeta:{...n,letterSpacing:Vb*.04,marginTop:3},stat:{...face(e,"mono"),fontSize:Zb,color:t.text.primary},statUnit:{...face(e,"mono"),fontSize:Vb+2,color:t.text.muted},pill:{minHeight:im,paddingHorizontal:10,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,justifyContent:"center",flexShrink:1,maxWidth:pm},pillText:{...face(e,"bold"),fontSize:lm,color:t.text.primary},feedback:{flexDirection:"row",flexWrap:"wrap",gap:r.sm,alignItems:"center"},chip:{minHeight:Jb,paddingHorizontal:12,borderRadius:e.radius.pill,...l,justifyContent:"center"},chipOn:{backgroundColor:t.surfaceSubtle},chipText:{...ch(e),fontSize:Xb,color:t.text.primary,...chipInk},followUps:{gap:r.sm,alignSelf:"stretch",marginTop:r.xs},label:{...face(e,"bold"),fontSize:nm,lineHeight:Math.round(nm*1.5),color:t.text.muted,marginTop:2},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:am,paddingTop:11,paddingBottom:11,paddingRight:12,paddingLeft:14,borderRadius:em,backgroundColor:t.surface,...i},rowAction:{},rowText:{...ch(e),flex:1,fontSize:tm,lineHeight:Math.round(tm*1.3),color:t.linkInk},rowTextAction:{color:t.text.primary}})}var gm=/* @__PURE__ */Object.freeze({eyebrow:"Checking in",logged:"Logged",findVet:"Find a vet now",day:"Day {day}",daySeparator:" · ",answers:/* @__PURE__ */Object.freeze({better:"Better",same:"Same",worse:"Worse"})}),bm=/* @__PURE__ */Object.freeze(Pi.map(e=>/* @__PURE__ */Object.freeze({answer:e,label:gm.answers[e]})));function mm(e,t){let[r,l]=o(null),[i,a]=o(null),[s,u]=o(null),d=n(r=>{t!==null&&(l(r),a(null),t(e.caseId,r).then(e=>{l(null),e.ok?u(r):a(e.error)}))},[t,e.caseId]),c=s??e.answer;return{answer:c,answerable:!isCheckinSettled(e),escalated:c==="worse",pending:r,error:i,choose:d}}var ym=44,vm=.6,wm=/* @__PURE__ */Object.freeze({caseId:"",answer:null,resolutionText:null,status:null});function CheckinCard({message:e,checkin:t,onAnswer:r,petRef:petRef,onFindVet:n,vet:i,onLayout:o,onOpen:a}){let s=useEverfurTheme(),u=l(()=>km(s),[s]),d=mm(t??wm,t===null?null:r),c=d.answer!==null||d.pending!==null,p=t!==null&&r!==null&&d.answerable,g=t===null?null:sb(t.openedAt,ub(e));/* @__PURE__ */
|
|
282
|
+
return h(S,{style:u.card,accessibilityLabel:gm.eyebrow,onLayout:o,children:[
|
|
283
|
+
/* @__PURE__ */h(S,{style:u.head,children:[
|
|
284
|
+
/* @__PURE__ */f(Text,{tier:"compact",style:u.eyebrow,children:gm.eyebrow}),g!==null?/* @__PURE__ */f(Text,{tier:"compact",style:u.headDay,children:nt(gm.day,{day:g})}):null]}),a?/* @__PURE__ */f(T,{onPress:a,accessibilityRole:"button",accessibilityLabel:e.text,style:u.open,children:/* @__PURE__ */f(Text,{style:[u.question,u.openText],children:e.text})}):/* @__PURE__ */f(Text,{style:u.question,accessibilityRole:"text",children:e.text}),p?/* @__PURE__ */f(S,{style:[u.row,d.pending?u.rowPending:null],children:bm.map(({answer:e,label:t})=>{let r=(d.pending??d.answer)===e;/* @__PURE__ */
|
|
285
|
+
return f(T,{onPress:()=>d.choose(e),disabled:c,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{selected:r,disabled:c,busy:d.pending===e},style:[u.pill,r?u.pillSelected:null],children:/* @__PURE__ */f(Text,{tier:"control",style:[u.pillLabel,r?u.pillLabelSelected:null],children:t})},e)})}):null,d.answer!==null?/* @__PURE__ */f(Text,{style:u.logged,children:gm.logged}):null,d.escalated?/* @__PURE__ */f(CheckinFindVet,{petRef:petRef??null,onFindVet:n,vet:i,styles:u}):null,t?.resolutionText?/* @__PURE__ */f(Text,{style:u.resolution,children:t.resolutionText}):null,d.error?/* @__PURE__ */f(Text,{style:u.error,accessibilityRole:"alert",children:d.error.displayMessage}):null]})}function CheckinFindVet({petRef:petRef,onFindVet:e,vet:t,styles:r}){return useVetVisit(xg(petRef,t)).available&&petRef!==null?/* @__PURE__ */f(VetVisitButtonCore,{entry:"chat",petRef:petRef,label:gm.findVet,...t?.returnTo!==void 0?{returnTo:t.returnTo}:{},...t?.usState!==void 0?{usState:t.usState}:{},...t?.prefer!==void 0?{prefer:t.prefer}:{},style:r.findVet,labelStyle:r.findVetLabel}):e===void 0?null:/* @__PURE__ */f(T,{onPress:e,accessibilityRole:"button",accessibilityLabel:gm.findVet,style:r.findVet,children:/* @__PURE__ */f(Text,{tier:"control",style:r.findVetLabel,children:gm.findVet})})}function km(e){let t=e.color,r=e.space,n=e.radius,l=e.type,i=fa(e.slots.card),o=ha(i);return v.create({card:{maxWidth:"92%",padding:r.md,gap:r.sm,borderRadius:n.lg,backgroundColor:t.brandSoft,borderWidth:v.hairlineWidth,borderColor:t.brandBorder,...pa(i,v.hairlineWidth)},head:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},eyebrow:{...face(e,"regular"),color:t.text.secondary,fontSize:l.size.caption,letterSpacing:l.letterSpacing.eyebrow,textTransform:"uppercase",...o},headDay:{...face(e,"bold"),color:t.text.primary,fontSize:l.size.caption,letterSpacing:l.letterSpacing.eyebrow,textTransform:"uppercase",...o},question:{...face(e,"regular"),color:t.text.primary,fontSize:l.size.body,lineHeight:l.size.body*l.lineHeight.normal,...o},open:{minHeight:ym,justifyContent:"center"},openText:{textDecorationLine:"underline"},row:{flexDirection:"row",gap:r.sm,marginTop:r.xs},rowPending:{opacity:vm},pill:{flex:1,minHeight:ym,alignItems:"center",justifyContent:"center",paddingHorizontal:r.md,borderRadius:n.pill,borderWidth:1,borderColor:t.controlEdge,backgroundColor:t.surface},pillSelected:{backgroundColor:t.brand,borderColor:t.brandInk},pillLabel:{...face(e,"regular"),color:t.text.primary,fontSize:l.size.body},pillLabelSelected:{color:t.onPrimary},logged:{...face(e,"regular"),color:t.text.secondary,fontSize:l.size.caption,...o},resolution:{...face(e,"regular"),color:t.text.primary,fontSize:l.size.body,lineHeight:l.size.body*l.lineHeight.normal,...o},error:{...face(e,"regular"),color:t.danger,fontSize:l.size.caption},findVet:{alignSelf:"stretch",minHeight:ym,alignItems:"center",justifyContent:"center",borderRadius:n.pill,borderWidth:1.5,borderColor:t.controlEdge,backgroundColor:t.surface},findVetLabel:{...face(e,"bold"),color:t.brandInk,fontSize:l.size.body}})}var Cm=244,Sm=8,xm=13,Rm=14,Tm=.3,_m=-.24,zm=22,Im=10,Pm=15;function CitationCards({citations:e,onOpenUrl:t}){let r=useEverfurTheme(),n=l(()=>Fm(r),[r]),i=l(()=>yb(e),[e]),[a,s]=o(false);if(i.length===0)return null;let u=i.length;/* @__PURE__ */
|
|
286
|
+
return h(S,{style:n.block,children:[
|
|
287
|
+
/* @__PURE__ */h(PressScale,{accessibilityRole:"button",accessibilityLabel:kb(u,a),accessibilityState:{expanded:a},containerStyle:n.toggleSlot,style:n.togglePill,onPress:()=>s(e=>!e),children:[
|
|
288
|
+
/* @__PURE__ */f(BookGlyph,{size:xm,color:r.color.brandInk,strokeWidth:1.5}),
|
|
289
|
+
/* @__PURE__ */f(Text,{tier:"compact",style:n.toggleLabel,children:wb(u)}),
|
|
290
|
+
/* @__PURE__ */f(ChevronGlyph,{size:xm,color:r.color.brandInk,strokeWidth:1.5,direction:a?"up":"down"})]}),a?/* @__PURE__ */f(Deck,{cards:i,styles:n,open:t}):null]})}function Deck({cards:e,styles:t,open:r}){let n=Mo(),l=Go(n.citationsInMs,{risePx:n.citationsRisePx});/* @__PURE__ */
|
|
291
|
+
return f(j.View,{style:l,children:/* @__PURE__ */f(P,{horizontal:true,nestedScrollEnabled:true,showsHorizontalScrollIndicator:false,contentContainerStyle:t.row,children:e.map(e=>/* @__PURE__ */f(Card,{card:e,styles:t,open:r},e.key))})})}function Card({card:e,styles:t,open:r}){let n=useEverfurTheme(),l=e.url!==null&&r!==void 0,i=Cb(l?e:{...e,url:null}),o=/* @__PURE__ */h(g,{children:[
|
|
292
|
+
/* @__PURE__ */h(S,{style:t.cardHeader,children:[
|
|
293
|
+
/* @__PURE__ */f(S,{style:[t.tierDot,{backgroundColor:e.tierColor}]}),
|
|
294
|
+
/* @__PURE__ */f(Text,{style:[t.cardTitle,l?t.cardTitleLink:null],numberOfLines:2,children:e.title}),l?/* @__PURE__ */f(ArrowUpRightGlyph,{size:Rm,color:n.color.linkInk,strokeWidth:1.5}):null]}),e.meta!==null?/* @__PURE__ */f(Text,{tier:"compact",style:t.cardMeta,numberOfLines:1,children:e.meta}):null,e.excerpt!==null?/* @__PURE__ */f(Text,{style:t.cardExcerpt,numberOfLines:3,children:e.excerpt}):null]});if(e.url!==null&&r!==void 0){let n=e.url;/* @__PURE__ */
|
|
295
|
+
return f(PressScale,{accessibilityRole:"link",accessibilityLabel:i,style:t.card,onPress:()=>r(n),children:o})}/* @__PURE__ */
|
|
296
|
+
return f(S,{accessible:true,accessibilityRole:"text",accessibilityLabel:i,style:t.card,children:o})}function Fm(e){let t=e.color,r=e.space,n=e.radius,l=e.type.size,i=ha(e.slots.card);return v.create({block:{gap:r.sm},toggleSlot:{alignSelf:"flex-start",borderRadius:n.pill},togglePill:{flexDirection:"row",alignItems:"center",gap:r.xs+2,paddingHorizontal:r.md,paddingVertical:r.xs+2,borderRadius:n.pill,backgroundColor:t.brandSoft},toggleLabel:{...face(e,"monoBold"),fontSize:l.micro,lineHeight:l.micro,letterSpacing:Tm,color:t.brandInk,textTransform:"uppercase"},row:{gap:r.sm,paddingRight:r.xl,paddingTop:r.xs},card:{width:Cm,borderRadius:n.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,padding:r.md,gap:r.xs+2,...pa(e.slots.card,1)},cardHeader:{flexDirection:"row",alignItems:"center",gap:r.sm},tierDot:{width:Sm,height:Sm,borderRadius:n.pill},cardTitle:{...headingFace(e,"bold"),flex:1,fontSize:l.bodyTight,lineHeight:zm,color:t.text.primary,letterSpacing:_m,...i},cardTitleLink:{color:t.linkInk},cardMeta:{...face(e,"monoMedium"),fontSize:l.nano,lineHeight:Im,letterSpacing:e.type.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase",...i},cardExcerpt:{...face(e,"regular"),fontSize:l.tiny,lineHeight:Pm,color:t.text.muted,...i}})}var Lm=15,Em=44,Om=16,Am=/* @__PURE__ */Object.freeze({up:"0deg",neutral:"270deg",down:"180deg"});function MessageFooter({message:e,onCopy:t,sentiment:r=null,onSentiment:n,note:s=null}){let u=useEverfurTheme(),d=l(()=>jm(u),[u]),c=Mo(),p=e.role==="user",b=l(()=>db(e.createdAt),[e.createdAt]),m=t!==void 0&&e.role!=="vet"&&e.text.length>0,y=e.role==="assistant"&&n!==void 0&&e.responseId!==void 0,[v,w]=o(false),k=i(null);a(()=>()=>{k.current&&clearTimeout(k.current)},[]);let C=()=>{t!==void 0&&(fn(t,e.text),w(true),k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{w(false),k.current=null},c.copiedMs))};return b===null&&!m&&!y?null:/* @__PURE__ */h(S,{style:d.wrap,children:[
|
|
297
|
+
/* @__PURE__ */h(S,{style:[d.row,p?d.rowUser:d.rowAssistant],children:[b!==null?/* @__PURE__ */f(Text,{tier:"compact",style:d.timestamp,children:b}):null,m?/* @__PURE__ */f(T,{accessibilityRole:"button",accessibilityLabel:v?rt.copied:p?rt.copyUserMessage:rt.copyAssistantMessage,onPress:C,style:d.iconHit,children:v?/* @__PURE__ */f(CheckGlyph,{size:Lm,color:u.color.success,strokeWidth:2}):/* @__PURE__ */f(CopyGlyph,{size:Lm,color:u.color.text.timestamp,strokeWidth:1.5})}):null,y?Kp.map(({sentiment:e,label:t})=>/* @__PURE__ */f(T,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{selected:r===e},onPress:()=>n?.(e),style:d.iconHit,children:/* @__PURE__ */f(ThumbGlyph,{size:Lm,color:r===e?u.color.sentiment[e]:u.color.text.timestamp,active:r===e,rotate:Am[e],strokeWidth:1.5})},e)):null]}),s==="thanks"?/* @__PURE__ */f(Text,{style:d.thanks,accessibilityLiveRegion:"polite",children:rt.feedbackThanks}):null,s==="failed"?/* @__PURE__ */h(g,{children:[
|
|
298
|
+
/* @__PURE__ */f(Text,{style:d.failed,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:rt.feedbackFailed}),
|
|
299
|
+
/* @__PURE__ */f(AnnounceLine,{line:rt.feedbackFailed})]}):null]})}function jm(e){let t=e.type;return v.create({wrap:{gap:4},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:Om,paddingTop:6},rowAssistant:{alignSelf:"flex-start"},rowUser:{alignSelf:"flex-end"},timestamp:{...face(e,"monoMedium"),fontSize:t.size.nano,lineHeight:t.size.nano+2,color:e.color.text.timestamp,textAlign:"center"},iconHit:{width:Em,height:Em,marginVertical:-28/2,alignItems:"center",justifyContent:"center"},thanks:{...face(e,"regular"),fontSize:t.size.caption,lineHeight:t.size.caption*t.lineHeight.normal,color:e.color.text.secondary},failed:{...face(e,"regular"),fontSize:t.size.caption,lineHeight:t.size.caption*t.lineHeight.normal,color:e.color.danger}})}var Dm=16,Mm=10,Bm=12,Hm=10,Wm=2,Nm=.06,Um=34,$m=9,Vm=10.5,qm=.06,Gm=15,Km=19.5,Ym=14,Qm=19.6;function OpeningCard({card:e,onLayout:t}){let r=useEverfurTheme(),n=l(()=>Zm(r),[r]),i=e.styles;/* @__PURE__ */
|
|
300
|
+
return h(S,{testID:"everfur-opening-card",onLayout:t,accessible:true,accessibilityLabel:[e.kicker,e.title,e.body].filter(e=>e!==void 0).join(", "),style:[n.card,i?.card],children:[e.icon!==void 0?/* @__PURE__ */f(S,{style:[n.icon,i?.icon],children:e.icon}):null,
|
|
301
|
+
/* @__PURE__ */h(S,{style:n.words,children:[
|
|
302
|
+
/* @__PURE__ */f(Text,{tier:"compact",style:[n.kicker,i?.kicker],children:e.kicker}),
|
|
303
|
+
/* @__PURE__ */f(Text,{tier:"control",style:[n.title,i?.title],children:e.title}),e.body!==void 0?/* @__PURE__ */f(Text,{style:[n.body,i?.body],children:e.body}):null]})]})}function Zm(e){let t=e.color;return v.create({card:{flexDirection:"row",alignItems:"flex-start",gap:Hm,paddingVertical:Mm,paddingHorizontal:Bm,alignSelf:"stretch",borderRadius:Dm,backgroundColor:t.surface,borderWidth:1,borderColor:Rs(t.text.primary,Nm)??t.borderRingCream},icon:{flexShrink:0,width:Um,height:Um,borderRadius:$m,backgroundColor:t.highlight,alignItems:"center",justifyContent:"center",overflow:"hidden"},words:{flex:1,minWidth:0,gap:Wm},kicker:{...face(e,"mono"),fontSize:Vm,letterSpacing:Vm*qm,textTransform:"uppercase",color:t.text.muted},title:{...face(e,"bold"),fontSize:Gm,lineHeight:Km,color:t.text.primary},body:{...face(e,"regular"),fontSize:Ym,lineHeight:Qm,color:t.text.secondary}})}var Jm="#10462E",Xm="Book a video visit",ey="#000000",ty="#83E0B4",ry=/* @__PURE__ */Object.freeze([
|
|
304
304
|
/* @__PURE__ */Object.freeze({id:"breed-health-miss",intent:"send",label:"What {breed} health issue do owners miss most?",fallbackLabel:"What {species} health issue do owners miss most?",background:"#A0C4F6",borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),
|
|
305
|
-
/* @__PURE__ */Object.freeze({id:"attention-at-age",intent:"send",label:"What changes should I expect at {ageYears} years old?",fallbackLabel:"What changes should I expect as my {species} ages?",background:
|
|
306
|
-
/* @__PURE__ */Object.freeze({id:"early-pain-signs",intent:"send",label:"What are early signs of pain?",background:"#FBC558",borderColor:
|
|
307
|
-
/* @__PURE__ */Object.freeze({id:"vet-prep",intent:"vet_report",label:"Help me prep for {petName}’s vet visit",background:"#FFBDBD",borderColor:"#6D1D14",borderWidth:1.25})]);function
|
|
308
|
-
return Object.freeze(
|
|
305
|
+
/* @__PURE__ */Object.freeze({id:"attention-at-age",intent:"send",label:"What changes should I expect at {ageYears} years old?",fallbackLabel:"What changes should I expect as my {species} ages?",background:ty,borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),
|
|
306
|
+
/* @__PURE__ */Object.freeze({id:"early-pain-signs",intent:"send",label:"What are early signs of pain?",background:"#FBC558",borderColor:Jm,brandEdge:true,borderWidth:1}),
|
|
307
|
+
/* @__PURE__ */Object.freeze({id:"vet-prep",intent:"vet_report",label:"Help me prep for {petName}’s vet visit",background:"#FFBDBD",borderColor:"#6D1D14",borderWidth:1.25})]);function ny(e,t){return e?null:{fill:t.fill,ink:t.ink}}var ly=8;function iy(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0&&t.length<=64&&!/[;{}<>]/u.test(t)?t:null}function oy(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(t.length>=ly)break;if(r===null||typeof r!="object"||typeof r.label!="string")continue;let e=r.label.trim();if(e.length===0)continue;let n=typeof r.prompt=="string"&&r.prompt.trim().length>0?r.prompt.trim():e,l=iy(r.tint);t.push(/* @__PURE__ */Object.freeze({id:`starter-${t.length}`,label:e,prompt:n,tint:l,ink:l===null?null:iy(r.ink)}))}return t.length>0?/* @__PURE__ */Object.freeze(t):null}var ay=/\s*-\s*(?:small|medium|large|giant|toy)\s*$/i;function sy(e){return e==null?e:e.replace(ay,"").trim()}var uy=/* @__PURE__ */new Set(["","?","-","--",".","n/a","na","none","null","nil","unknown","unspecified","unsure","not sure","not specified","not applicable","no idea","dunno","idk","tbd","other","i dont know","i don't know","dont know","don't know","do not know","i do not know","not known","no clue"]);function dy(e){let t=String(e??"").replace(/\s+/gu," ").trim().toLowerCase().replace(/\u2019/g,"'");return uy.has(t)}function cy(e){return e==="cat"?"Domestic Short Hair Mix":"Mixed Breed"}function py(e,t){let r=e?.trim();if(r===void 0||r==="")return fy(t);let n=t?.name?.trim()||rt.emptyTitlePetFallback,l=n.charAt(0).toUpperCase()+n.slice(1);return r.replace(/\{(pet|petName)\}/g,(e,t,r)=>r===0?l:n)}function fy(e){let t=e?.name?.trim()||rt.emptyTitlePetFallback;return nt(rt.emptyTitle,{petName:t})}function hy(e){let t=e.toLowerCase();return t===cy("dog").toLowerCase()||t===cy("cat").toLowerCase()}function gy(e){let t=sy(e);if(dy(t))return null;let r=String(t).replace(/\s+/gu," ").trim();return hy(r)?null:r}function by(e,t=Jm,r){let n=canonicalPetSpecies(e?.species),l=e?.name?.trim()||null,i=gy(e?.breed),o=op(e?.ageYears),a=o===null?null:String(o),s=r?.vetPrepLabel?.trim()||null;/* @__PURE__ */
|
|
308
|
+
return Object.freeze(ry.flatMap(e=>{let r=e.intent==="vet_report"&&s!==null?s:e.label,o=r.includes("{breed}"),u=r.includes("{ageYears}"),d=e.fallbackLabel!==void 0&&(o&&!i||u&&!a)&&e.fallbackLabel?e.fallbackLabel:r;if(d.includes("{breed}")&&i===null||d.includes("{ageYears}")&&a===null||n===null&&(d.includes("{species}")||d.includes("{petName}")&&l===null))return[];let c=nt(d,{petName:l??(n==="cat"?"my cat":"my dog"),breed:i??"",species:n??"",ageYears:a??""}),p=!l&&d.startsWith("{petName}")?c.charAt(0).toUpperCase()+c.slice(1):c;return[/* @__PURE__ */Object.freeze({id:e.id,intent:e.intent,label:p,background:e.background,borderColor:e.brandEdge===true?t:e.borderColor,borderWidth:e.borderWidth})]}))}var my=44,yy=0,vy={top:3,bottom:3},wy=1,ky=.28,Cy=2,Sy=2,xy=1.3,Ry=-.015,Ty=/* @__PURE__ */Object.freeze([
|
|
309
309
|
/* @__PURE__ */Object.freeze({tint:"#FFE7A1",ink:"#262523"}),
|
|
310
310
|
/* @__PURE__ */Object.freeze({tint:"#C8F4F8",ink:"#262523"}),
|
|
311
311
|
/* @__PURE__ */Object.freeze({tint:"#DDEFC4",ink:"#262523"}),
|
|
312
|
-
/* @__PURE__ */Object.freeze({tint:"#FFD8D6",ink:"#262523"})]);function QuickPrompts({pet:e,petRef:petRef,onSend:t,onVetPrep:r,vet:
|
|
313
|
-
return
|
|
314
|
-
/* @__PURE__ */
|
|
315
|
-
return
|
|
316
|
-
return
|
|
317
|
-
return
|
|
318
|
-
return
|
|
319
|
-
/* @__PURE__ */
|
|
312
|
+
/* @__PURE__ */Object.freeze({tint:"#FFD8D6",ink:"#262523"})]);function QuickPrompts({pet:e,petRef:petRef,onSend:t,onVetPrep:r,vet:n,starterPrompts:i,emptyState:o,centered:a=false}){let s=useEverfurTheme(),u=l(()=>_y(s),[s]),d=l(()=>oy(i),[i]),c=l(()=>d!==null?d.map(e=>({prompt:{id:e.id,intent:"send",label:e.label,background:e.tint??s.color.highlight,borderColor:"transparent",borderWidth:1},send:e.prompt,paint:e.tint===null?null:{fill:e.tint,ink:e.ink??s.color.text.primary}})):by(e,s.color.brandInk,{vetPrepLabel:Xm}).map(e=>({prompt:e,send:e.label,paint:null})),[d,e,s.color.brandInk,s.color.highlight,s.color.text.primary]),p=o?.chipTints!==void 0,g=l(()=>(o?.chipTints??(s.brightness==="light"?Ty:[])).filter(e=>typeof e.tint=="string"&&e.tint.trim()!==""),[o?.chipTints,s.brightness]),b=l(()=>g.length===0?c:c.map((e,t)=>{if(e.paint!==null)return e;let r=g[t%g.length];return{...e,paint:{fill:r.tint,ink:r.ink??s.color.text.primary},...p?{}:{cycleDefault:true}}}),[c,g,p,s.color.text.primary]),m=l(()=>ny(np(s),{fill:s.color.highlight,ink:s.color.onHighlight}),[s]),y=l(()=>({fill:s.color.highlight,ink:s.color.onHighlight}),[s.color.highlight,s.color.onHighlight]),v=py(o?.title,e),w=ff(),k=hf(),C=w!==null&&k!==null?/* @__PURE__ */f(k.Title,{text:v,style:[u.title,w.text(".serif",".ask-empty h2"),u.centerText],measureCh:k.titleCh}):/* @__PURE__ */f(Text,{tier:"heading",style:a?[u.title,u.centerText]:u.title,accessibilityRole:"header",children:v});/* @__PURE__ */
|
|
313
|
+
return h(S,{style:w!==null?u.homeBlock:u.block,children:[C,
|
|
314
|
+
/* @__PURE__ */f(S,{style:w!==null?[u.list,u.listCentered,w.view(".ask-chips",".ask-empty .ask-chips")]:a?[u.list,u.listCentered]:u.list,accessibilityLabel:rt.suggestions,children:b.map(({prompt:l,send:i,paint:o,cycleDefault:s},c)=>/* @__PURE__ */f(Chip,{prompt:l,send:i,themed:o??(d!==null?y:m),index:c,petRef:petRef,onSend:t,onVetPrep:r,vet:n,pet:e,styles:u,tinted:o!==null&&s!==true,soft:o!==null,centered:a},l.id))})]})}function Chip({prompt:e,send:t,themed:r,index:n,pet:l,petRef:petRef,onSend:i,onVetPrep:o,vet:a,styles:s,tinted:u,soft:d,centered:c}){let p=Mo(),h=Go(p.followUpInMs,{delayMs:jo(p,n),risePx:p.promptRisePx}),g=ff(),b=g!==null?[s.chipHome,g.view(".chip")]:c&&d?s.chipNoEdge:s.chipEdge,m={backgroundColor:r?.fill??e.background},y=s.chipSlot===null?m:u?{...s.chipSlot,...m}:{...m,...s.chipSlot},v=g!==null?[s.chipLabel,g.text(".chip")]:c?[s.chipLabel,s.centerText]:[s.chipLabel],w=g!==null?vy:yy,k=r===null?s.chipSlotLabel===null?v:[...v,s.chipSlotLabel]:u?[...v,...s.chipSlotLabel===null?[]:[s.chipSlotLabel],{color:r.ink}]:[...v,{color:r.ink},...s.chipSlotLabel===null?[]:[s.chipSlotLabel]];return e.intent==="vet_report"?o!==void 0?/* @__PURE__ */f(j.View,{style:h,children:/* @__PURE__ */f(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:w,style:[s.chip,b,y],onPress:()=>{dn(o,l)},children:/* @__PURE__ */f(Text,{tier:"compact",style:k,children:e.label})})}):petRef===null?null:/* @__PURE__ */f(j.View,{style:h,children:/* @__PURE__ */f(VetVisitButtonCore,{entry:"chat",petRef:petRef,label:e.label,...a?.returnTo!==void 0?{returnTo:a.returnTo}:{},...a?.usState!==void 0?{usState:a.usState}:{},...a?.prefer!==void 0?{prefer:a.prefer}:{},style:[s.chip,b,y],labelStyle:k})}):/* @__PURE__ */f(j.View,{style:h,children:/* @__PURE__ */f(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:w,style:[s.chip,b,y],onPress:()=>i(t),children:/* @__PURE__ */f(Text,{tier:"compact",style:k,children:e.label})})})}function _y(e){let t=fa(e.slots.chip),r=ha(t);return{chipSlot:t===void 0?null:pa(t,wy),chipSlotLabel:r.color===void 0?null:r,...zy(e)}}function zy(e){let t=e.color,r=e.space,n=e.type;return v.create({block:{gap:r.lg,alignItems:"stretch",width:"100%"},homeBlock:{alignItems:"stretch",width:"100%"},chipHome:{borderWidth:0,minHeight:0},title:{...headingFace(e,"medium"),fontSize:n.size.heading,lineHeight:Math.round(n.size.heading*n.lineHeight.snug),color:t.brandInk,letterSpacing:n.size.heading*Ry,textAlign:"left"},list:{width:"100%",flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-start",gap:r.sm+Cy},listCentered:{flexDirection:"column",flexWrap:"nowrap",alignItems:"stretch"},centerText:{textAlign:"center"},chipNoEdge:{borderWidth:wy,borderColor:"transparent"},chip:{borderRadius:e.radius.pill,paddingHorizontal:r.lg+Sy,paddingVertical:r.sm,minHeight:my,minWidth:0,alignItems:"center",justifyContent:"center",maxWidth:"100%"},chipEdge:{borderWidth:wy,borderColor:Rs(t.brandInk,ky)??t.borderRingCream},chipLabel:{...face(e,"bold"),fontSize:n.size.bodyTight,lineHeight:Math.round(n.size.bodyTight*xy),color:ey,textAlign:"left"}})}var Iy=1e3,Py=150,Fy=.25,Ly=.5,Ey=3;function TypingIndicator({petName:e=null,inline:t=false}){let{theme:r,styles:n}=Yu(),l=r.motion.reducedMotion,o=it(rt.reading,e),s=i(Array.from({length:Ey},()=>new j.Value(0))).current;return a(()=>{if(l)return;let e=s.map((e,t)=>j.loop(j.sequence([j.delay(t*Py),j.timing(e,{toValue:1,duration:Iy*.4,useNativeDriver:true}),j.timing(e,{toValue:0,duration:Iy*.6,useNativeDriver:true}),j.delay((Ey-t-1)*Py)])));for(let t of e)t.start();return()=>{for(let t of e)t.stop()}},[l,s]),/* @__PURE__ */f(S,{style:t?n.readingInline:n.readingBox,accessible:true,accessibilityRole:"text",accessibilityLabel:o,accessibilityLiveRegion:"polite",accessibilityState:{busy:true},children:s.map((e,r)=>/* @__PURE__ */f(j.View,{accessibilityElementsHidden:true,importantForAccessibility:"no",style:[t?n.readingDotInline:n.readingDot,l?{opacity:Ly}:{opacity:e.interpolate({inputRange:[0,1],outputRange:[Fy,1]}),transform:[{translateY:e.interpolate({inputRange:[0,1],outputRange:[0,-3]})}]}]},r))})}function Oy(e,t,r){let n=e-r,l=t!=null?Math.min(n,t):n;return Math.max(0,l)}function Ay(e){let t=e.length-1,r=e[t];if(r===void 0||r.role!=="assistant")return null;let n=e[t-1];return{assistantIndex:t,userIndex:n!==void 0&&n.role==="user"?t-1:null}}function jy(e,t,r){let n=Math.max(0,r),l=e===null?n:Math.min(Math.max(0,e),n);return l>t+1?l:null}var Dy=16;function My(e,t,r=null){let l=i(null),o=i(true),s=i(t),u=i(0),d=i(0),c=i(0),p=i(/* @__PURE__ */new Map),f=i(null),h=i(false),g=e[0]?.id??null,b=i(g),m=i(null);a(()=>{let t=b.current;if(b.current=g,t===null||t===g||(m.current=null,o.current||!e.some(e=>e.id===t)))return;let r=p.current.get(t);r!==void 0&&(m.current={id:t,top:r,offset:u.current})},[g,e]);let y=Ay(e),v=y===null?null:e[y.assistantIndex]?.id??null,w=y===null||y.userIndex===null?null:e[y.userIndex]?.id??null,k=n(()=>{let e=l.current;if(e===null||!o.current||d.current===0)return;let t=null;if(v!==null){let e=p.current.get(v);if(e===void 0)return;let r=w===null?null:p.current.get(w)??null;t=Oy(e,r,96)}let r=jy(t,u.current,c.current-d.current);if(r!==null&&(u.current=r,e.scrollTo({y:r,animated:false})),!h.current||f.current===null)return;let n=jy(f.current+Dy-d.current,u.current,c.current-d.current);n!==null&&(u.current=n,e.scrollTo({y:n,animated:false}))},[v,w]);a(()=>{h.current=r!==null,r===null&&(f.current=null),k()},[r,k]),a(()=>{t&&!s.current&&(o.current=true,h.current=false),s.current=t,k()},[e,t,k]);let C=n(e=>{d.current=e.nativeEvent.layout.height,k()},[k]),S=n((e,t)=>{c.current=t,d.current>0&&(u.current=Math.min(u.current,Math.max(0,t-d.current))),k()},[k]),x=n(e=>{u.current=e.nativeEvent.contentOffset.y},[]),R=n(()=>{o.current=false,h.current=false},[]),T=n(e=>{let{contentOffset:t,contentSize:r,layoutMeasurement:n}=e.nativeEvent;u.current=t.y,o.current=r.height-t.y-n.height<=24},[]),_=n(e=>t=>{let r=t.nativeEvent.layout.y;p.current.set(e,r);let n=m.current;if(n!==null&&n.id===e&&r!==n.top){m.current=null;let e=Math.max(0,n.offset+r-n.top);u.current=e,l.current?.scrollTo({y:e,animated:false})}(e===v||e===w)&&k()},[v,w,k]),z=n(e=>{let{y:t,height:r}=e.nativeEvent.layout;f.current=t+r,k()},[k]);return{ref:l,onLayout:C,onContentSizeChange:S,onScroll:x,onScrollBeginDrag:R,onScrollEnd:T,rowLayout:_,asideLayout:z}}function By(e,t,r){switch(e){case"loading":return r.renderPending?/* @__PURE__ */f(HostRender,{render:r.renderPending,fallback:/* @__PURE__ */f(LoadingState,{})}):/* @__PURE__ */f(LoadingState,{});case"empty":/* @__PURE__ */
|
|
315
|
+
return f(EmptyState,{pet:r.shownPet,petRef:t.petRef,onSelectPrompt:r.onSelectPrompt,onVetPrep:r.onVetPrep,vet:r.vet,top:r.threadTop,pendingCheckin:r.pendingCheckin??null,topCard:r.topCard,starterPrompts:r.starterPrompts,emptyState:r.emptyState,centered:r.emptyCentered===true,renderEmptyHeader:r.renderEmptyHeader});case"error":/* @__PURE__ */
|
|
316
|
+
return f(ErrorState,{error:t.error,onRetry:t.retryLast,onAddPet:r.onAddPet});case"populated":/* @__PURE__ */
|
|
317
|
+
return f(PopulatedState,{messages:t.messages,prompts:Un(t,r.followUpPolicy),actions:r.answerCards?Lb(t,r.answerCards):Wy,answerCards:r.answerCards??null,threadTop:r.threadTop,pendingCheckin:r.pendingCheckin??null,threadAside:r.threadAside,threadAsideKey:r.threadAsideKey??null,onSelectPrompt:r.onSelectPrompt,isStreaming:t.isStreaming,onAnswerCheckin:t.petRef?t.answerCheckin:null,onCopy:r.onCopy,sentimentByMessage:t.sentimentByMessage,onSentiment:r.onSentiment,feedbackNote:r.feedbackNote,imagesByMessage:r.imagesByMessage,onPreview:r.onPreview,notice:r.notice,reconnecting:t.reconnecting===true,onRetry:t.retryLast,onStartNew:t.newConversation,petRef:t.petRef,onFindVet:r.onCheckinFindVet,vet:r.vet,onOpenUrl:r.onOpenUrl,petName:r.shownPet?.name??null,followUpLabel:r.followUpPolicy?.label,openingCard:r.openingCard,earlier:t.historyCursor?{loading:t.isLoadingHistory,load:t.loadOlderMessages}:null});default:return assertNever(e)}}function LoadingState(){let{theme:e,styles:t}=Yu(),[r,n]=o(false);return a(()=>{let e=setTimeout(()=>n(true),tu);return()=>clearTimeout(e)},[]),/* @__PURE__ */f(S,{style:t.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:rt.loading,children:r?/* @__PURE__ */f(F,{color:e.color.brandInk}):null})}function EmptyState({pet:e,petRef:petRef,onSelectPrompt:t,onVetPrep:r,vet:n,top:l,topCard:i,pendingCheckin:o,starterPrompts:a,emptyState:s,centered:u,renderEmptyHeader:d}){let{styles:c}=Yu(),p=ff(),g=d===void 0?null:/* @__PURE__ */f(S,{testID:"everfur-empty-header",children:/* @__PURE__ */f(HostRender,{render:()=>d({ask:t}),fallback:null})});if(p!==null){let{minHeight:u,...d}=p.view(".ask-empty");/* @__PURE__ */
|
|
318
|
+
return h(P,{contentContainerStyle:[d,c.homeEmpty],keyboardShouldPersistTaps:"handled",keyboardDismissMode:Uy,nestedScrollEnabled:true,accessibilityLabel:rt.empty,children:[l!=null?/* @__PURE__ */f(S,{style:p.view(".ask-top"),children:l}):null,o,i??null,g,
|
|
319
|
+
/* @__PURE__ */f(S,{style:p.view(".ask-start"),children:/* @__PURE__ */f(QuickPrompts,{pet:e,petRef:petRef,onSend:t,onVetPrep:r,vet:n,starterPrompts:a,emptyState:s,centered:true})})]})}
|
|
320
320
|
/* @__PURE__ */
|
|
321
|
-
return
|
|
322
|
-
/* @__PURE__ */
|
|
323
|
-
/* @__PURE__ */
|
|
324
|
-
return
|
|
325
|
-
/* @__PURE__ */
|
|
326
|
-
/* @__PURE__ */
|
|
327
|
-
return
|
|
328
|
-
/* @__PURE__ */
|
|
329
|
-
return
|
|
330
|
-
return
|
|
331
|
-
/* @__PURE__ */
|
|
332
|
-
/* @__PURE__ */
|
|
333
|
-
/* @__PURE__ */
|
|
334
|
-
/* @__PURE__ */
|
|
335
|
-
/* @__PURE__ */
|
|
336
|
-
/* @__PURE__ */
|
|
337
|
-
/* @__PURE__ */
|
|
338
|
-
return
|
|
339
|
-
/* @__PURE__ */
|
|
340
|
-
/* @__PURE__ */
|
|
341
|
-
return
|
|
342
|
-
return
|
|
343
|
-
return
|
|
344
|
-
/* @__PURE__ */
|
|
321
|
+
return h(P,{contentContainerStyle:c.emptyContent,keyboardShouldPersistTaps:"handled",keyboardDismissMode:Uy,nestedScrollEnabled:true,accessibilityLabel:rt.empty,children:[l??null,o,i??null,g,
|
|
322
|
+
/* @__PURE__ */f(QuickPrompts,{pet:e,petRef:petRef,onSend:t,onVetPrep:r,vet:n,starterPrompts:a,emptyState:s,centered:u})]})}function FollowUps({prompts:e,onSelectPrompt:t,label:r}){let{styles:n}=Yu();return e.length===0?null:/* @__PURE__ */h(S,{style:n.followUps,children:[
|
|
323
|
+
/* @__PURE__ */f(Text,{tier:"compact",style:n.followUpsHeading,accessibilityRole:"header",children:r??rt.followUpsHeadingNative}),e.map((e,r)=>/* @__PURE__ */f(FollowUpRow,{prompt:e,index:r,onSelectPrompt:t},e))]})}function FollowUpRow({prompt:e,index:t,onSelectPrompt:r}){let{theme:n,styles:l}=Yu(),i=Mo(),o=Go(i.followUpInMs,{delayMs:jo(i,t)});/* @__PURE__ */
|
|
324
|
+
return f(j.View,{style:o,children:/* @__PURE__ */h(PressScale,{onPress:()=>r(e),accessibilityRole:"button",accessibilityLabel:e,containerStyle:[l.followUpSlot,t>0?l.followUpSlotRuled:null],style:l.followUpRow,children:[
|
|
325
|
+
/* @__PURE__ */f(Text,{tier:"control",style:l.followUpText,children:e}),
|
|
326
|
+
/* @__PURE__ */f(PlusGlyph,{size:$y,color:n.slots.chip?.textColor??n.color.text.muted,strokeWidth:1.75})]})})}function ErrorState({error:e,onRetry:t,onAddPet:r}){let{styles:n}=Yu(),l=li(e)?pn(r):void 0,i=On(e);/* @__PURE__ */
|
|
327
|
+
return h(S,{style:n.centered,accessible:true,accessibilityRole:"alert",children:[i!==null?/* @__PURE__ */f(Text,{style:n.errorText,testID:"everfur-chat-cap-reached",children:i.reached}):null,
|
|
328
|
+
/* @__PURE__ */f(Text,{style:n.errorText,children:e.displayMessage}),i!==null&&i.guidance!==null?/* @__PURE__ */f(Text,{style:n.errorText,testID:"everfur-chat-cap-guidance",children:i.guidance}):null,l!==void 0?/* @__PURE__ */f(T,{onPress:l,accessibilityRole:"button",accessibilityLabel:rt.addPet,style:n.retryButton,children:/* @__PURE__ */f(Text,{tier:"control",style:n.retryLabel,children:rt.addPet})}):null,e.retryable?/* @__PURE__ */f(T,{onPress:t,accessibilityRole:"button",accessibilityLabel:rt.retry,style:n.retryButton,children:/* @__PURE__ */f(Text,{tier:"control",style:n.retryLabel,children:rt.retry})}):null]})}function PopulatedState({messages:e,prompts:t,onSelectPrompt:r,isStreaming:n,onAnswerCheckin:i,onCopy:o,sentimentByMessage:a,onSentiment:s,feedbackNote:u,imagesByMessage:d,onPreview:c,notice:p,reconnecting:g,onRetry:b,onStartNew:m,petRef:petRef,onFindVet:y,vet:v,onOpenUrl:w,petName:k,actions:C,answerCards:x,threadTop:R,pendingCheckin:_,threadAside:z,threadAsideKey:I,followUpLabel:F,openingCard:L,earlier:E}){let{styles:O}=Yu(),A=Mo();ta(e.length,A);let j=l(()=>ib(lb(e)),[e]),D=Dn(e,n),M=e[e.length-1],B=z??null,H=My(e,n,B===null?null:I??"shown"),W=Qo(e),N=e[0],U=L!==void 0&&N!==void 0&&N.role==="user"&&N.text.trim()===L.prompt?N.id:null;/* @__PURE__ */
|
|
329
|
+
return h(P,{ref:H.ref,style:O.list,contentContainerStyle:x!==null?O.listContentCards:O.listContent,accessibilityLabel:rt.transcript,keyboardShouldPersistTaps:"handled",keyboardDismissMode:Uy,nestedScrollEnabled:true,onLayout:H.onLayout,onContentSizeChange:H.onContentSizeChange,onScroll:H.onScroll,scrollEventThrottle:Ny,onScrollBeginDrag:H.onScrollBeginDrag,onScrollEndDrag:H.onScrollEnd,onMomentumScrollEnd:H.onScrollEnd,children:[R??null,_,E!==null?/* @__PURE__ */f(T,{onPress:()=>{E.load()},disabled:E.loading,accessibilityRole:"button",accessibilityLabel:E.loading?Gi.loadingEarlier:Gi.earlier,accessibilityState:{disabled:E.loading,busy:E.loading},hitSlop:ku,style:O.earlierButton,children:/* @__PURE__ */f(Text,{tier:"compact",style:O.earlierLabel,children:E.loading?Gi.loadingEarlier:Gi.earlier})}):null,e.map(t=>t.id===U&&L!==void 0?/* @__PURE__ */f(OpeningCard,{card:L.card,onLayout:H.rowLayout(t.id)},t.id):t.checkin&&j.has(t.id)?/* @__PURE__ */f(CheckinCard,{message:t,checkin:t.checkin,onAnswer:i,petRef:petRef,onFindVet:y,vet:v,onLayout:H.rowLayout(t.id)},t.id):/* @__PURE__ */f(MessageRow,{onLayout:H.rowLayout(t.id),message:t,revealing:n&&t===M&&t.role==="assistant",onCopy:o,sentiment:t.responseId===void 0?null:a[String(t.responseId)]??null,onSentiment:s,note:t.responseId!==void 0&&u?.responseId===String(t.responseId)?u.kind:null,images:d[t.id]??Hy,onPreview:c,onOpenUrl:w,entering:W(t.id),answerCards:x,messages:e},t.id)),g?/* @__PURE__ */f(Text,{tier:"compact",style:O.reconnectingCaption,accessibilityRole:"text",children:rt.reconnecting}):null,D?/* @__PURE__ */f(TypingIndicator,{petName:k,inline:x!==null}):null,p!==null?/* @__PURE__ */f(TurnNoticeCard,{notice:p,onRetry:b,onStartNew:m}):null,x!==null?/* @__PURE__ */f(CardsFollowUps,{prompts:t,onSelectPrompt:r,label:F,actions:C,options:x}):/* @__PURE__ */f(FollowUps,{prompts:t,onSelectPrompt:r,label:F}),B!==null?/* @__PURE__ */f(S,{onLayout:H.asideLayout,children:B}):null]})}function TurnNoticeCard({notice:e,onRetry:t,onStartNew:r}){let{styles:n}=Yu(),l=e.tone==="error";/* @__PURE__ */
|
|
330
|
+
return h(S,{style:[n.turnNotice,l?n.turnNoticeError:null],accessible:true,accessibilityRole:"alert",children:[
|
|
331
|
+
/* @__PURE__ */f(Text,{tier:"control",style:[n.turnNoticeTitle,l?n.turnNoticeTitleError:null],children:e.title}),
|
|
332
|
+
/* @__PURE__ */f(Text,{tier:"compact",style:n.turnNoticeBody,children:e.body}),e.guidance!==void 0?/* @__PURE__ */f(Text,{tier:"compact",style:n.turnNoticeBody,testID:"everfur-chat-cap-guidance",children:e.guidance}):null,
|
|
333
|
+
/* @__PURE__ */f(T,{onPress:e.action==="startNew"?r:t,accessibilityRole:"button",accessibilityLabel:e.actionLabel,hitSlop:ku,style:n.turnNoticeAction,children:/* @__PURE__ */f(Text,{tier:"control",style:n.turnNoticeActionLabel,children:e.actionLabel})})]})}var Hy=/* @__PURE__ */Object.freeze([]),Wy=/* @__PURE__ */Object.freeze([]),Ny=16,Uy=w.OS==="ios"?"interactive":"on-drag",$y=18;function MessageRow({message:e,revealing:t,onCopy:r,sentiment:l,onSentiment:i,note:o,images:a,onPreview:s,onOpenUrl:u,onLayout:d,entering:c,answerCards:p,messages:g}){let{theme:b,styles:m}=Yu(),y=Mo(),v=Yo(c,y),w=Jo(e.text,t,y),k=e.role==="user",C=e.role==="vet",x=e.role==="assistant",R=_o(),T=x&&!t?R:void 0,_=T!==void 0&&Ub(e.text,T),z=x&&!b.meta.hidePoweredBy,I=k?rt.senderUser:C?$n(e):z?rt.assistantName:rt.senderAssistant,P=C?db(e.createdAt):null,F=n(t=>i(e,t),[i,e]),L=e.pending!==true,E=x&&b.meta.assistantAvatarUrl!==null?/* @__PURE__ */f(AssistantSender,{avatarUrl:b.meta.assistantAvatarUrl,named:z,styles:m}):z?p!==null?/* @__PURE__ */f(CardsByline,{label:rt.assistantName}):/* @__PURE__ */f(Text,{tier:"control",style:m.assistantName,children:rt.assistantName}):null,O=p!==null;return x&&p!==null?/* @__PURE__ */f(j.View,{style:[m.rowBlock,v],onLayout:d,accessibilityLabel:`${I}: ${e.text}`,children:/* @__PURE__ */f(CardsAnswer,{message:e,text:w,streaming:t,messages:g,options:p,sentiment:l,onSentiment:e.responseId===void 0?void 0:F,sender:E,onOpenUrl:u,footer:t=>/* @__PURE__ */f(MessageFooter,{message:e,onCopy:r,sentiment:l,onSentiment:t&&e.responseId!==void 0?F:void 0,note:o})})}):/* @__PURE__ */h(S,{style:[m.rowBlock,k?m.rowBlockUser:m.rowBlockAssistant],onLayout:d,children:[
|
|
334
|
+
/* @__PURE__ */f(S,{style:[m.row,k?m.rowUser:m.rowAssistant],accessible:!_,accessibilityRole:_?void 0:"text",accessibilityLabel:_?void 0:`${I}: ${e.text}`,accessibilityState:e.pending===true?{busy:true}:void 0,children:/* @__PURE__ */h(j.View,{style:[m.bubble,O?m.bubbleCards:null,k?m.bubbleSideUser:null,v],children:[E,C?/* @__PURE__ */h(S,{style:m.vetHeader,children:[
|
|
335
|
+
/* @__PURE__ */f(Text,{tier:"control",style:m.vetSender,children:I}),P!==null?/* @__PURE__ */f(Text,{tier:"compact",style:m.vetTime,children:P}):null]}):null,
|
|
336
|
+
/* @__PURE__ */h(S,{style:[k?m.bubbleUser:C?m.bubbleVet:m.bubbleAssistant,k&&O?m.bubbleUserCards:null,e.pending?m.bubblePending:null],children:[k&&a.length>0?/* @__PURE__ */f(SentImages,{images:a,onPreview:e=>s({uri:e.uri,label:e.filename})}):null,
|
|
337
|
+
/* @__PURE__ */f(Text,{style:k?O?[m.bubbleTextUser,m.bubbleTextUserCards]:m.bubbleTextUser:C?m.bubbleTextVet:m.bubbleTextAssistant,children:x?$b(w,{bold:m.bubbleBold,italic:m.bubbleItalic,code:m.bubbleCode},T):e.text})]})]})}),x&&!t?/* @__PURE__ */f(ServerCardsSlot,{message:e}):null,x&&!t?/* @__PURE__ */f(CitationCards,{citations:e.citations,onOpenUrl:u}):null,L&&!(k&&p!==null)?/* @__PURE__ */f(MessageFooter,{message:e,onCopy:r,sentiment:l,onSentiment:e.responseId===void 0?void 0:F,note:o}):null]})}var Vy=/* @__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"&&Vy.has(t.urgencyLevel))}var NO_SNAPSHOT2=()=>null;function qy(){let{runtime:e}=ct(),t=e.entitlements??null,r=n(e=>t===null?()=>{}:t.subscribe(e),[t]),i=t===null?NO_SNAPSHOT2:t.getSnapshot,o=s(r,i,i);return l(()=>o!==null&&decideCapability("texting",o.decisions,{isPending:o.isPending}).enabled,[o])}var Gy=/* @__PURE__ */Object.freeze({runner:null,line:null,entry:null,stage:null,headerEntry:null});function Ky(e,t,r=false){let[n,l]=o(null);if(!e)return Gy;let i=/* @__PURE__ */f(AskRunner,{ready:textingAskThreadReady(t),onAsk:l,entry:r}),a=r&&n!==null&&n.canOpen?{label:H.textingAskLines(n).accept,onOpen:n.open}:null;if(n===null||n.stage==="hidden"||n.stage==="dismissed")return{runner:i,line:null,entry:null,stage:null,headerEntry:a};let s=H.textingAskLines(n),u=/* @__PURE__ */f(AskLine,{stage:n.stage,text:n.stage==="verified"?s.verified:s.line,accept:s.accept,dismiss:s.dismiss,onAccept:n.accept,onDismiss:n.dismiss}),d=n.stage==="enrolling"?/* @__PURE__ */f(H.ChatTextingAskComposer,{ask:n}):null;return{runner:i,line:u,entry:d,stage:n.stage,headerEntry:a}}function AskRunner({ready:e,onAsk:t,entry:r}){let{userRef:userRef}=ct(),n=qy(),l=userRef!==null&&n;return a(()=>{l||t(null)},[l,t]),l?/* @__PURE__ */f(H.ChatTextingAskController,{enabled:true,ready:e,onAsk:t,entry:r}):null}function AskLine({stage:e,text:t,accept:r,dismiss:n,onAccept:l,onDismiss:i}){let{theme:o,styles:a}=Yu(),s=!o.meta.hidePoweredBy,u=s?rt.assistantName:rt.senderAssistant,d=o.meta.assistantAvatarUrl!==null?/* @__PURE__ */f(AssistantSender,{avatarUrl:o.meta.assistantAvatarUrl,named:s,styles:a}):s?/* @__PURE__ */f(Text,{tier:"control",style:a.assistantName,children:rt.assistantName}):null;/* @__PURE__ */
|
|
338
|
+
return h(S,{style:[a.rowBlock,a.rowBlockAssistant],testID:`everfur-texting-ask-${e}`,children:[
|
|
339
|
+
/* @__PURE__ */f(S,{style:[a.row,a.rowAssistant],accessible:true,accessibilityRole:"text",accessibilityLabel:`${u}: ${t}`,children:/* @__PURE__ */h(S,{style:a.bubble,children:[d,
|
|
340
|
+
/* @__PURE__ */f(S,{style:a.bubbleAssistant,children:/* @__PURE__ */f(Text,{style:a.bubbleTextAssistant,children:t})})]})}),e==="offered"?/* @__PURE__ */f(S,{style:a.askChips,children:[{label:r,onPress:l,testID:"everfur-texting-ask-accept"},{label:n,onPress:i,testID:"everfur-texting-ask-dismiss"}].map(e=>/* @__PURE__ */f(PressScale,{onPress:e.onPress,accessibilityRole:"button",accessibilityLabel:e.label,style:a.askChip,testID:e.testID,children:/* @__PURE__ */f(Text,{tier:"control",style:a.askChipText,children:e.label})},e.testID))}):null]})}function Yy(){let e=/* @__PURE__ */Symbol.for("@everfur/sdk#SdkSurfaceHooks@v1"),t=globalThis;return t[e]??(t[e]=createContext(null))}var Qy=/* @__PURE__ */Yy();function Zy(e){return typeof e=="object"&&e!==null&&e.ok===true}function Jy(e){if(typeof e!="object"||e===null)return null;let t=e;return t.ok!==false||typeof t.error!="object"||t.error===null?null:Ut(t.error)}function Xy(e){let t=u(Qy),r=t?.onMessageSent,l=t?.onFreeCapReached,i=n((...t)=>{let n=e(...t);return Promise.resolve(n).then(e=>{try{if(Zy(e)){r?.();return}let t=l===void 0?null:Jy(e);t!==null&&l?.(t)}catch{}},()=>{}),n},[e,r,l]);return r===void 0&&l===void 0?e:i}function EverfurChatCore(e){let{style:t,renderPending:r}=e;/* @__PURE__ */
|
|
341
|
+
return f(CapabilityGate,{capability:"chat",style:t,...r?{renderPending:r}:{},children:/* @__PURE__ */f(MessageLinksScope,{linkHosts:e.linkHosts,onOpenUrl:e.onOpenUrl,children:/* @__PURE__ */f(ChatBody,{...e})})})}function ev(){try{return ct()}catch{return null}}function tv(e){return Ln({...e.presentation,chatComposerMic:e.presentation?.chatComposerMic??(e.dictation===void 0?void 0:e.dictation!==false),chatComposerUpload:e.presentation?.chatComposerUpload??(e.attachments===void 0?void 0:true)})}function ChatBody(e){let t=ev();return t===null?/* @__PURE__ */f(ChatBodyAlone,{...e}):/* @__PURE__ */f(ChatBodyInProvider,{...e,activePet:t.activePet,telemetry:t.runtime.registry?.services?.telemetry??null})}function ChatBodyAlone(e){let t=tv(e),r=JSON.stringify(t),n=e.petRef??null,i=l(()=>({presentation:resolvePresentation({server:null,locked:null,client:t}),isLocked:()=>false,planPage:null,planPetRef:n,inProvider:false,telemetry:null}),[r,n]);/* @__PURE__ */
|
|
342
|
+
return f(ChatSurface,{...e,settings:i})}function ChatBodyInProvider({activePet:e,telemetry:t,...r}){let{presentation:n,isLocked:isLocked}=Fn(tv(r)),i=xn("healthPlan"),o=n.chatTopCard==="focus"&&r.topCard===void 0&&i,a=r.petRef??e??null,s=useHealthPlanPage({petRef:a,enabled:o}),u=o&&s.phase==="ready"?s.page:null,d=l(()=>({presentation:n,isLocked:isLocked,planPage:u,planPetRef:a,inProvider:true,telemetry:t}),[n,isLocked,u,a,t]);/* @__PURE__ */
|
|
343
|
+
return f(ChatSurface,{...r,settings:d})}function ChatSurface({settings:e,petRef:petRef,conversationId:conversationId,style:t,renderPending:r,onCopy:s,onPetChange:u,onVetPrep:d,onFindVet:c,renderVetAction:p,attachments:b,pet:m,onAddPet:y,checkinTarget:v,handoffToken:k,initialAsk:C,initialAskKey:x,composerSeed:T,lifecycle:_,refreshIntervalMs:z,refreshesBlankThread:I,openUnreadOnRefresh:P,draftStore:F,vetReturnTo:L,vetUsState:E,vetPrefer:O,onOpenUrl:A,keyboardVerticalOffset:j,topCard:D,onOpenHealthPlan:M,answerCards:H,historySheet:W,historyBar:N,starterPrompts:U,emptyState:$,header:V=true,textingEntry:q=true,renderEmptyHeader:G,followUpPolicy:K,initialAskCard:Y}){let{presentation:Q,isLocked:isLocked,planPage:Z,planPetRef:J}=e,{theme:X,styles:ee}=Yu(),te=pf()??(Q.chatAnswerStyle==="cards"?og:null),re=l(()=>te===null?null:te(X),[te,X]),ne=useHostPoweredBy(),le=Mo(),ie=l(()=>Vn(petRef,conversationId),[petRef,conversationId]),oe=useEverfurChat(ie),ae=Xy(oe.send),se=l(()=>ae===oe.send?oe:{...oe,send:ae},[oe,ae]),ue=En(se),de=Jg(),ce=ro(se),pe=B(),fe=jn(se,"web"),he=l(()=>c===void 0?void 0:()=>{dn(c,"emergency")},[c]),ge=l(()=>L===void 0&&E===void 0&&O===void 0?void 0:{returnTo:L,usState:E,prefer:O},[L,E,O]),be=Vp(de.pets,se.petRef),[me,ye]=o(null),ve=l(()=>{let e=so(se.messages,be?.name??null);return e?.level==="schedule_soon"&&e.messageId===me?null:e},[se.messages,be?.name,me]),we=co(ve);eb(se),ta(we.showBanner,le);let ke=ev(),Ce=$i(k,ke);qi(se.openCheckin,v??Ce,{petRef:se.petRef,pinned:petRef!==void 0,ready:!se.isBootstrapping,selectPet:e=>{de.setActivePet(e),dn(u,e)}}),hi(se.askEverfur,se.isBootstrapping,C,x);let Se=l(()=>fi(T),[T]),xe=l(()=>fi(C),[C]),Re=l(()=>Y!==void 0&&xe!==null?{card:Y,prompt:xe}:void 0,[Y,xe]),Te=l(()=>_===void 0?createAppStateLifecycle():_??void 0,[_]);Ti(Te,{conversationId:se.conversationId===null?null:String(se.conversationId),isTurnInFlight:se.isStreaming,refreshesBlankThread:I===true||P===true,refresh:se.refreshActiveThread===void 0?void 0:()=>se.refreshActiveThread?.(vi(P===true,wi(Te,ca)))??Promise.resolve()},{intervalMs:z===void 0?3e4:z,isVisibleFallback:ca}),ki({isStreaming:se.isStreaming,status:se.status,conversationId:se.conversationId===null?null:String(se.conversationId),unreadCount:se.unreadCount,markRead:se.markRead},()=>wi(Te,ca));let _e=se.pendingCheckin??null,ze=_e===null?null:/* @__PURE__ */f(S,{testID:"everfur-pending-checkin",accessibilityLiveRegion:"polite",children:/* @__PURE__ */f(CheckinCard,{message:_e.message,checkin:_e.checkin,onAnswer:se.petRef?se.answerCheckin:null,petRef:se.petRef,onFindVet:he,vet:ge,onOpen:()=>{se.resumeConversation(_e.conversationId)}})}),Ie=(se.hasUnreadThreads??false)||ce.rows.some(e=>e.unreadCount!==null&&e.unreadCount>0)||(se.unreadCount??0)>0,Pe=si(se.messages),[Fe,Le]=o(null),Ee=n(()=>Le(null),[]),[Oe,Ae]=o(null),[je,De]=o(null),Me=i(null);a(()=>()=>{Me.current&&clearTimeout(Me.current)},[]);let Be=n((e,t)=>{De({responseId:String(e),kind:t}),Me.current&&clearTimeout(Me.current),Me.current=t==="thanks"?setTimeout(()=>{De(null),Me.current=null},ru):null},[]),He=n((e,t)=>{let r=e.responseId;if(r===void 0)return;let n=se.sentimentByMessage[String(r)];De(e=>e?.responseId===String(r)?null:e),se.feedback(r,t).then(e=>{e.ok||Be(r,"failed")}),t==="down"&&n!=="down"&&Ae(r)},[se,Be]),We=n(async(e,t)=>Oe===null||!(e==null&&t===null?{ok:true}:await se.feedback(Oe,"down",e??"other",t)).ok?false:(Ae(null),Be(Oe,"thanks"),true),[se,Oe,Be]),Ne=n(()=>Ae(null),[]),Ue=n(e=>{se.send(e)},[se.send]),$e=l(()=>A===void 0?void 0:e=>{dn(A,e,"citation")},[A]),Ve=w.OS==="ios"?"padding":void 0,qe=gg(j,Ve!==void 0),Ge=qe.topInWindow===null?pe.top:Math.max(0,pe.top-qe.topInWindow),Ke=mg(),Ye=l(()=>M===void 0?void 0:()=>{dn(M,J)},[M,J]),Qe=l(()=>({petRef:se.petRef,vet:ge,cover:ye}),[se.petRef,ge]),Ze=l(()=>D===void 0?healthPlanTopCard(Z,{onOpenPlan:Ye}):void 0,[D,Z,Ye]),Je=Q.chatTopCard==="focus"?D??Ze:void 0,[Xe,et]=o(true),tt=n(e=>{se.send(e)},[se.send]),nt=l(()=>Kn(K,Q,isLocked("chatFollowUpCount")),[K,Q,isLocked]),lt=Q.chatAnswerStyle==="cards",it=l(()=>lt&&se.messages.length===0?lv(se.suggestedPrompts):void 0,[lt,se.messages.length,se.suggestedPrompts]),ot=Q.chatHistoryStyle==="sheet",at=se.messages.length===0,st=Je!==void 0?/* @__PURE__ */f(TopCardPill,{card:Je,open:Xe,onOpenChange:et}):null,ut=N??(V?void 0:iv),dt=ut!==void 0?/* @__PURE__ */f(HistoryBar,{bar:ut,history:ce,empty:at,unread:Ie,extra:st}):null,ct=Q.chatHistoryBar==="scroll"&&(ue==="empty"||ue==="populated"),pt=Je===void 0?null:/* @__PURE__ */h(g,{children:[
|
|
344
|
+
/* @__PURE__ */f(TopCard,{card:Je,open:Xe,onOpenChange:et,ask:tt}),ut===void 0?st:null]}),ft=ut!==void 0,ht=ce.load,gt=ce.open;a(()=>{ft&&!gt&&ht()},[ft,gt,se.conversationId,ht]);let bt={send:se.send,stop:se.stop,isStreaming:se.isStreaming,conversationId:se.conversationId,seed:Se,draftStore:F,onStage:Pe.stage,onPreview:Le,petName:be?.name??null,petBreed:be?.breed??null,compact:Q.chatComposerStyle==="compact",petPlaceholder:Q.chatComposerPlaceholder==="pet_name",dimEmptySend:Q.chatSendButton==="dim_when_empty",mood:ov(ue,we.source?.level??null),dictation:Q.chatComposerMic,telemetry:e.telemetry},mt=Ky(Q.chatTextingAsk&&e.inProvider,se,q),yt=b!==void 0&&Q.chatComposerUpload,vt=!Q.chatGeneralBanner&&we.source?.level==="general";
|
|
345
345
|
/* @__PURE__ */
|
|
346
|
-
return
|
|
347
|
-
/* @__PURE__ */
|
|
348
|
-
/* @__PURE__ */
|
|
349
|
-
/* @__PURE__ */
|
|
350
|
-
/* @__PURE__ */
|
|
351
|
-
/* @__PURE__ */
|
|
352
|
-
/* @__PURE__ */
|
|
353
|
-
/* @__PURE__ */
|
|
354
|
-
/* @__PURE__ */
|
|
355
|
-
return
|
|
346
|
+
return f(cf.Provider,{value:re,children:/* @__PURE__ */h(R,{style:[ee.container,{paddingTop:Ge},t],behavior:Ve,...qe.avoidingProps,children:[
|
|
347
|
+
/* @__PURE__ */f(KeyboardOffsetProbe,{probeRef:qe.probeRef}),
|
|
348
|
+
/* @__PURE__ */h(SdkTabletColumn,{children:[V?/* @__PURE__ */f(ChatHeader,{pets:de,petRef:se.petRef,historyUnread:Ie,onOpenHistory:ce.show,onNewChat:ce.newConversation,onPetChange:u,onAddPet:y,vet:ge,textingEntry:mt.headerEntry}):null,m!==void 0?/* @__PURE__ */f(PetSetupNotice,{petRef:petRef??null,pet:m,onRegistered:de.refresh}):null,!V&&mt.headerEntry!==null?/* @__PURE__ */f(TextingEntryRow,{entry:mt.headerEntry,place:"thread"}):null,ct?null:dt,vt?null:/* @__PURE__ */f(UrgencyBanner,{surface:we,petRef:se.petRef,renderVetAction:p,onFindVet:c,vet:ge,compact:Ke}),
|
|
349
|
+
/* @__PURE__ */f(S,{style:ee.body,children:/* @__PURE__ */f(ho.Provider,{value:Qe,children:By(ue,se,{notice:fe,vet:ge,onCheckinFindVet:he,onSelectPrompt:Ue,renderPending:r,shownPet:be,onVetPrep:d,onCopy:s,onSentiment:He,feedbackNote:je,imagesByMessage:Pe.byMessage,onPreview:Le,onAddPet:y,onOpenUrl:$e,threadTop:ct?dt:null,pendingCheckin:ze,topCard:pt,starterPrompts:U??it,emptyState:$,emptyCentered:Q.chatAnswerStyle==="cards",followUpPolicy:nt,answerCards:Q.chatAnswerStyle==="cards"?H??rv:null,threadAside:mt.line,threadAsideKey:mt.stage,renderEmptyHeader:G,openingCard:Re})})}),mt.runner,mt.entry!==null?/* @__PURE__ */f(S,{style:ee.composerOuter,children:/* @__PURE__ */f(S,{style:ee.askEntry,children:mt.entry})}):yt&&b!==void 0?/* @__PURE__ */f(ComposerWithAttachments,{...bt,attachments:b}):/* @__PURE__ */f(Composer,{...bt,attachments:null}),X.meta.hidePoweredBy||ne?null:/* @__PURE__ */f(Text,{tier:"compact",style:ee.poweredBy,accessibilityRole:"text",accessibilityLabel:rt.poweredBy,children:rt.poweredBy})]}),ot?/* @__PURE__ */f(HistorySheet,{chat:se,history:ce,sheet:W}):/* @__PURE__ */f(HistoryDrawer,{chat:se,history:ce}),
|
|
350
|
+
/* @__PURE__ */f(FeedbackReasons,{visible:Oe!==null,onSubmit:We,onSkip:Ne}),
|
|
351
|
+
/* @__PURE__ */f(AttachmentImageLightbox,{uri:Fe?.uri??null,label:Fe?.label??"",onClose:Ee}),
|
|
352
|
+
/* @__PURE__ */f(TelevetHostOutlet,{})]})})}function PetSetupNotice({petRef:petRef,pet:e,onRegistered:t}){let{styles:r}=Yu(),n=oi(petRef,e,t);return n.status!=="failed"||n.error===null?null:/* @__PURE__ */h(S,{style:r.setupNotice,accessible:true,accessibilityRole:"alert",children:[
|
|
353
|
+
/* @__PURE__ */f(Text,{tier:"compact",style:r.setupNoticeText,children:n.error.displayMessage}),
|
|
354
|
+
/* @__PURE__ */f(T,{onPress:n.retry,accessibilityRole:"button",accessibilityLabel:rt.retry,hitSlop:ku,children:/* @__PURE__ */f(Text,{tier:"control",style:r.setupNoticeAction,children:rt.retry})})]})}var rv=/* @__PURE__ */Object.freeze({}),nv=3;function lv(e){let t=[];for(let r of e){let e=r.trim();if(e.length>0&&!t.some(t=>t.label===e)&&t.push(/* @__PURE__ */Object.freeze({label:e})),t.length===nv)break}return t.length>0?/* @__PURE__ */Object.freeze(t):void 0}var iv=/* @__PURE__ */Object.freeze({chats:Gi.heading,newChat:Gi.newChat});function ov(e,t){return t==="emergency"?"urgent":e==="populated"?"followUp":"ask"}function EverfurChat(e){/* @__PURE__ */
|
|
355
|
+
return f(W.Provider,{value:EverfurTelevetHost,children:/* @__PURE__ */f(EverfurChatCore,{...e})})}var av=/* @__PURE__ */Object.freeze({hasUnread:null,unreadCount:null,conversationId:null,petRef:null}),NO_SUBSCRIPTION=()=>()=>{};function sv(e,t){let{runtime:r,userRef:userRef,activePet:i,scopeEpoch:o}=ct(),u=r.unread??null,petRef=e===void 0?i:e,d=n(e=>u===null?NO_SUBSCRIPTION():u.subscribe(e),[u]),c=n(()=>u===null||userRef===null?av:u.get(petRef),[u,userRef,petRef]),p=s(d,c,c),f=n(()=>u===null||userRef===null?Promise.resolve():u.refresh(petRef),[u,userRef,petRef]);return a(()=>{f()},[f,o]),Ti(t,{conversationId:null,isTurnInFlight:false,refreshesBlankThread:true,refresh:f}),l(()=>({...p,refresh:f}),[p,f])}function useEverfurUnread(e={}){let{lifecycle:t}=e,r=l(()=>t===void 0?createAppStateLifecycle():t??void 0,[t]);return sv(e.petRef,r)}export{EverfurChat,EverfurPoweredBy,chatHandoffTokenFromUrl,createAppStateLifecycle,createRnChatAttachmentTransport,registerEverfurChatCards,registerEverfurDictation,useChatAttachments,useEverfurChat,useEverfurPets,useEverfurUnread,useHostPoweredBy};
|