@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/lite/index.cjs
CHANGED
|
@@ -16,172 +16,172 @@ return Object.freeze(n)}var qr=5;function Gr(e,t){if(e===void 0)return false;if(
|
|
|
16
16
|
return Object.freeze(a)}function Yr(e){return e.sender?.displayName??se.senderVet}function Qr(petRef,conversationId){let e={};return petRef!==void 0&&(e.petRef=petRef),conversationId!==void 0&&(e.conversationId=conversationId),e}var Zr=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 Jr(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 Xr(e,t,r){let n=t.chatFollowUpsExcludeTelevet,l=e?.count!==void 0&&!r?e.count:t.chatFollowUpCount;if(e===void 0&&l===Nr&&!n)return;if(l<=0)return{...e??{},count:1,exclude:NONE,fill:[]};let i=e?.exclude,o=n?e=>Zr.test(e)||Jr(i,e):i;return{...e??{},count:l,...o!==void 0?{exclude:o}:{}}}function en(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 tn(e){return[...e].length}var rn=/* @__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(rn,t)?rn[t]:null}var nn=50,ln=128,on=120,an=120,sn=2e3,un=120,cn=80,dn=/* @__PURE__ */new Set(["male","female","unknown"]),pn=/* @__PURE__ */new Set(["day","month","year"]),fn=/* @__PURE__ */new Set(["low","medium","high","athletic"]),hn=/* @__PURE__ */new Set(["indoor","outdoor","both"]),bn=/* @__PURE__ */new Set(["mild","moderate","severe"]),gn=/^(\d{4})-(\d{2})-(\d{2})$/,mn=[["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"]],yn=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];/* @__PURE__ */Object.freeze([...mn,...yn].map(([e])=>e));function vn(e){let t=gn.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 xn=e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,wn=(e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,kn=(e,t)=>typeof t=="string"&&vn(t)?null:`${e} must be a real date written YYYY-MM-DD`,Sn=(e,t={})=>(r,n)=>{if(typeof n!="string")return`${r} must be a string`;if(en(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=tn(l);return i<=e?null:`${r} is ${i} characters; the server accepts at most ${e}`},Cn={sex:xn(dn),spayedNeutered:wn,birthDate:kn,birthDatePrecision:xn(pn),activityLevel:xn(fn),indoorOutdoor:xn(hn),foodBrand:Sn(un),foodType:Sn(un),microchipId:Sn(cn)},jn=["ref","ref",false,Sn(ln,{required:true,trimmed:true})],Rn=["notes","notes",false,Sn(sn,{trimmed:true})],Tn=[jn,["name","name",true,Sn(on,{required:true,trimmed:true})],["dose","dose",false,Sn(an,{trimmed:true})],["frequency","frequency",false,Sn(an,{trimmed:true})],["startDate","start_date",false,kn],["endDate","end_date",false,kn],Rn],_n={allergies:[jn,["allergen","allergen",true,Sn(on,{required:true,trimmed:true})],["severity","severity",false,xn(bn)],Rn],medications:Tn,supplements:Tn,conditions:[jn,["conditionName","condition_name",true,Sn(on,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,kn],Rn]};function zn(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 _n[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 In(e,t){if(!Array.isArray(t))return{error:`${e} must be an array (send [] to clear it)`};if(t.length>nn)return{error:`${e} has ${t.length} items; the server accepts at most ${nn}`};let r=[],n=/* @__PURE__ */new Set;for(let l=0;l<t.length;l+=1){let i=zn(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 Pn(e,t){let r=e,n={};for(let[e,t]of mn){let l=r[e];if(l!==void 0){if(l!==null){let t=Cn[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 yn){let l=r[e];if(l===void 0)continue;let i=In(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 En=e=>typeof e=="string"?e:null,Mn=(e,t)=>typeof t=="string"&&e.has(t)?t:null,Fn=e=>typeof e=="boolean"?e:null;function An(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 Ln(e){let t=En(e.name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:En(e.ref),name:t,dose:En(e.dose),frequency:En(e.frequency),startDate:En(e.start_date),endDate:En(e.end_date),notes:En(e.notes)})}function On(e){let t=e.profile_version;/* @__PURE__ */
|
|
17
17
|
return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:Mn(dn,e.sex),spayedNeutered:Fn(e.spayed_neutered),birthDate:En(e.birth_date),birthDatePrecision:Mn(pn,e.birth_date_precision),activityLevel:Mn(fn,e.activity_level),indoorOutdoor:Mn(hn,e.indoor_outdoor),foodBrand:En(e.food_brand),foodType:En(e.food_type),microchipId:En(e.microchip_id),allergies:An(e.allergies,e=>{let t=En(e.allergen);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:En(e.ref),allergen:t,severity:Mn(bn,e.severity),notes:En(e.notes)})}),medications:An(e.medications,Ln),supplements:An(e.supplements,Ln),conditions:An(e.conditions,e=>{let t=En(e.condition_name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:En(e.ref),conditionName:t,diagnosedDate:En(e.diagnosed_date),notes:En(e.notes)})})})}var Vn=100,Dn=50,Bn=100,Hn=50,Wn=500,Nn=128,Un=6e4;function $n(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function qn(e,t,r){if(typeof t!="string")return $n(`${e} must be a string`);let n=tn(t);return n<=r?null:$n(`${e} is ${n} characters; the server accepts at most ${r}`)}function Gn(e,t,r){return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=r?null:$n(`${e} must be a finite number between 0 and ${r}`)}function Kn(petRef,e){if(typeof petRef!="string")return $n("pet_ref must be a string");if(petRef.trim().length===0)return $n("pet_ref must not be blank");if(en(petRef))return $n("pet_ref contains an unpaired surrogate and cannot be encoded");if(e!=null&&typeof e!="object")return $n("profile must be an object");let t=[qn("pet_ref",petRef,Nn)];return e?.name!==void 0&&t.push(qn("name",e.name,Vn)),e?.species!==void 0&&t.push(qn("species",e.species,Dn)),e?.breed!==void 0&&t.push(qn("breed",e.breed,Bn)),e?.ageYears!==void 0&&t.push(Gn("age_years",e.ageYears,Hn)),e?.weightKg!==void 0&&t.push(Gn("weight_kg",e.weightKg,Wn)),t.find(e=>e!==null)??null}function Yn(e,t){let r=Pn(e,t);return"error"in r?{error:$n(r.error)}:r}function Qn(e){if(typeof e!="object"||e===null)return{error:$n("patch must be an object")};let t=e,r=[["name","name",e=>qn("name",e,Vn)],["species","species",e=>qn("species",e,Dn)],["breed","breed",e=>qn("breed",e,Bn)],["ageYears","age_years",e=>Gn("age_years",e,Hn)],["weightKg","weight_kg",e=>Gn("weight_kg",e,Wn)]],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=Yn(t,t.species);return"error"in l?l:(Object.assign(n,l.body),Object.keys(n).length===0?{error:$n("patch must change at least one field")}:{body:n})}function Zn(e){if(e==null)return{body:{}};let t=Yn(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 Jn=e=>typeof e=="string"?e:null,Xn=e=>typeof e=="number"&&Number.isFinite(e)?e:null;function el(e,petRef){let t=typeof e=="object"&&e!==null?e:{};/* @__PURE__ */
|
|
18
18
|
return Object.freeze({petRef:Jn(t.pet_ref)??petRef,name:Jn(t.name),species:Jn(t.species),breed:Jn(t.breed),ageYears:Xn(t.age_years),weightKg:Xn(t.weight_kg)})}function widgetPetFromWire(e){if(typeof e!="object"||e===null)return null;let t=e,petRef=Jn(t.pet_ref);return petRef===null||petRef.length===0?null:/* @__PURE__ */Object.freeze({petId:Jn(t.pet_id),petRef:petRef,name:Jn(t.name),species:Jn(t.species),breed:Jn(t.breed),ageYears:Xn(t.age_years),weightKg:Xn(t.weight_kg),updatedAt:Jn(t.updated_at)})}function tl(e){let t=widgetPetFromWire(e);return t===null?null:/* @__PURE__ */Object.freeze({...t,...On(e)})}function rl(e){let t=Array.isArray(e)?e:typeof e=="object"&&e!==null&&Array.isArray(e.pets)?e.pets:[];/* @__PURE__ */
|
|
19
|
-
return Object.freeze(t.flatMap(e=>{let t=widgetPetFromWire(e);return t===null?[]:[t]}))}function createPetsRepository(e){return nl(createRequestFunnel({auth:e}),createRequestFunnel({auth:e,unaryTimeoutMs:Un}))}function nl(e,t=e){let r=(e,t)=>t?{...e,signal:t}:e,n=petRef=>Kn(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(rl(n.value)):err(n.error)},async registerPet(petRef,t,r){let n=Kn(petRef,t);if(n!==null)return err(n);let l=Zn(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(el(o.value,petRef)):err(o.error)},async updatePet(petRef,t,l){let i=n(petRef);if(typeof i!="string")return err(i);let o=Qn(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(el(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=tl(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 ll=/* @__PURE__ */new WeakMap,il=/* @__PURE__ */new Map;function ol(e,t,petRef,r){let n=ll.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}|${sl(r)}`}function al(e,t){if(e===null)return t();let r=il.get(e);if(r!==void 0)return r;let n=t().finally(()=>{il.get(e)===n&&il.delete(e)});return il.set(e,n),n}function sl(e){return e===null||typeof e!="object"?JSON.stringify(e)??"undefined":Array.isArray(e)?`[${e.map(sl).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)}:${sl(t)}`).join(",")}}`}var ul="pet_not_registered";function cl(e){return e!=null&&e.reasonCode===ul}var dl=/* @__PURE__ */Object.freeze({status:"idle",error:null,registered:null,retry:()=>{}});function pl(petRef,t,r){let{runtime:n,userRef:userRef,scopeEpoch:l}=me(),i=e.useCallback((e,t)=>{let r=n.registry.services.authFor(userRef);return al(ol(n,r,e,t),()=>createPetsRepository(r).registerPet(e,t))},[n,userRef,l]),o=e.useMemo(()=>t===void 0?null:sl(t),[t]),[a,s]=e.useState({key:null,status:"idle",error:null,registered:null}),u=e.useRef(0),c=e.useRef(r);c.current=r;let d=petRef===null||o===null?null:`${String(userRef)}|${l}|${petRef}|${o}`,p=e.useCallback(()=>{if(petRef===null||t===void 0||d===null)return;let e=++u.current;s({key:d,status:"registering",error:null,registered:null}),i(petRef,t).then(t=>{e===u.current&&(t.ok?(s({key:d,status:"registered",error:null,registered:t.value}),c.current?.()):s({key:d,status:"failed",error:t.error,registered:null}))})},[i,petRef,d]);e.useEffect(()=>{if(d===null){u.current+=1;return}return p(),()=>{u.current+=1}},[d,p]);let f=e.useCallback(()=>{a.status==="failed"&&p()},[a.status,p]);return e.useMemo(()=>d===null?dl:a.key!==d?{status:"registering",error:null,registered:null,retry:f}:{status:a.status,error:a.error,registered:a.registered,retry:f},[d,a,f])}var fl=/* @__PURE__ */Object.freeze({});function hl(t){let[r,n]=e.useState(fl),l=e.useRef(null),i=e.useRef([]);i.current=t.map(e=>e.id),e.useEffect(()=>{if(t.length===0){l.current=null,n(e=>e===fl?e:fl);return}let e=l.current;if(e===null)return;let r=t.find(t=>t.role==="user"&&!e.known.has(t.id));r!==void 0&&(l.current=null,n(t=>({...t,[r.id]:e.images})))},[t]);let o=e.useCallback(e=>{l.current=e.length===0?null:{images:e,known:new Set(i.current)}},[]);return e.useMemo(()=>({byMessage:r,stage:o}),[r,o])}var bl=/* @__PURE__ */new WeakSet;function gl(){let e=makeEverfurError("internalError",{retryable:true});return bl.add(e),err(e)}function ml(e){if(typeof e!="object"||e===null||e.ok!==false)return false;let t=e.error;return typeof t=="object"&&t!==null&&bl.has(t)}var yl=500;function vl(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,yl):null}function xl(t,r,n,l){let i=vl(n),o=i===null?null:l!==void 0?`key:${String(l)}`:`prompt:${i}`,a=e.useRef(t);a.current=t;let s=e.useRef(null),u=e.useRef(null),c=e.useRef(o);c.current=o,e.useEffect(()=>{if(i===null||o===null||r||s.current===o||u.current===o)return;let e=a.current;if(e===void 0)return;u.current=o;let t=e=>{u.current===o&&(u.current=null),!ml(e)&&c.current===o&&(s.current=o)};Promise.resolve(e(i)).then(t,()=>t(void 0))},[i,o,r,t])}var wl=/* @__PURE__ */Object.freeze({openUnreadHead:true,reportLoadFailures:true}),kl=/* @__PURE__ */Object.freeze({reportLoadFailures:true}),Sl=/* @__PURE__ */Object.freeze({...wl,markRead:true}),Cl=/* @__PURE__ */Object.freeze({...kl,markRead:true});function jl(e,t){return e?t?Sl:wl:t?Cl:kl}function Rl(e,t){let r=e?.isVisible===void 0?t:e.isVisible.bind(e);return r===void 0?true:br(()=>r()!==!1)===true}function Tl(t,r){let n=e.useRef({target:t,isVisible:r});n.current={target:t,isVisible:r};let l=e.useRef(t.isStreaming);e.useEffect(()=>{let e=l.current;if(l.current=t.isStreaming,!e||t.isStreaming)return;let{target:r,isVisible:i}=n.current;r.status!=="complete"||r.conversationId===null||r.unreadCount===null||!i()||r.markRead()},[t.isStreaming])}function _l(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 zl(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"}:_l(e,conversationId,t)?{action:"skip",reason:"coalesced"}:{action:"refresh",conversationId:conversationId}}var Il=3e5;function Pl(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 El(t,r,n){let l=e.useRef(r);l.current=r;let i=e.useRef(null),o=e.useRef(null),a=e.useRef(false),s=e.useRef(0),u=e.useRef(0),c=e.useRef(3e4),d=()=>t?.isOffline===void 0?false:br(()=>t.isOffline?.()===!0)===true,p=d(),f=e.useRef(()=>{});f.current=e=>{let{conversationId:conversationId,isTurnInFlight:t,refresh:r,refreshesBlankThread:n}=l.current,p=zl(e,{activeConversationId:conversationId,isTurnInFlight:t,refreshesBlankThread:n===true,isOffline:d(),lastRefresh:i.current,now:Date.now()});if(p.action==="skip")return;if(p.action==="defer"){o.current!=="announced"&&(o.current=e);return}if(a.current){if(e==="poll")return;o.current!=="announced"&&(o.current=e);return}if(o.current=null,i.current={conversationId:p.conversationId,at:Date.now()},r===void 0)return;a.current=true;let h=e=>{a.current=false,Pl(e)?(s.current=Math.min(s.current===0?c.current*2:s.current*2,Il),u.current=Date.now()+s.current):(s.current=0,u.current=0);let t=o.current;t!==null&&f.current(t)};Promise.resolve(r()).then(h,()=>h({ok:false,error:{category:"server"}}))},e.useEffect(()=>{if(r.isTurnInFlight||p)return;let e=o.current;e!==null&&f.current(e)},[r.isTurnInFlight,p]),e.useEffect(()=>{if(t===void 0)return;let e=[],r=(t,r)=>{if(t===void 0)return;let n=br(()=>t(()=>{f.current(r)}));typeof n=="function"&&e.push(n)};return r(t.onForeground?.bind(t),"foreground"),r(t.onOnline?.bind(t),"foreground"),r(t.onAnnounced?.bind(t),"announced"),()=>{for(let t of e)br(t)}},[t]);let h=n?.intervalMs??null,b=n?.isVisibleFallback;e.useEffect(()=>{if(t===void 0||h===null||!Number.isFinite(h)||h<=0)return;c.current=h;let e=setInterval(()=>{Date.now()<u.current||Rl(t,b)&&f.current("poll")},h);return()=>clearInterval(e)},[t,h,b])}var Ml=/^efch_[A-Za-z0-9_-]{43}$/,Fl="efch";function Al(e){return typeof e=="string"&&Ml.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(`${Fl}=`))continue;let e=r.slice(Fl.length+1);return Al(e)?e:null}return null}var Ll=/* @__PURE__ */Object.freeze(["better","same","worse"]),Ol=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var Vl="checkin",Dl=/^\d{4}-\d{2}-\d{2}$/,Bl="watching";function isCheckinSettled(e){return e.status!=null&&e.status!==Bl}function Hl(e){if(typeof e!="string")return null;let t=e.split(":");if(t.length!==3)return null;let[r,n,l]=t;return r!==Vl||n===void 0||l===void 0||!Ol.test(n)||!Dl.test(l)?null:{caseId:n,dueDay:l}}function Wl(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 Nl(e,t,r){return makeEverfurError(e,{retryable:t,...{}})}var Ul=128,$l=/[\u0000-\u001f\u007f]/;function ql(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function Gl(e){return typeof e!="string"||e.length===0||e.length>Ul||$l.test(e)||e.includes("://")?null:e}function Kl(e){if(e===null)return null;let conversationId=e.conversation_id,petRef=Gl(e.pet_ref);return typeof conversationId!="string"||!Wl(conversationId)||petRef===null?null:{conversationId:conversationId,petRef:petRef}}function Yl(e,t,r){return Al(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(Kl(ql(e.value))):e.error.httpStatus===404?ok(null):err(e.error),()=>err(Nl("internalError",false))):Promise.resolve(ok(null))}function Ql(t,r){let n=r?.runtime??null,userRef=r?.userRef??null,l=Al(t)?t:null,i=l===null||userRef===null?null:`${String(userRef)}|${l}`,[o,a]=e.useState(null);return e.useEffect(()=>{if(i===null||l===null||userRef===null||n===null)return;let e=true,t=n.registry.services;return Yl(t.authFor(userRef),l,t.errorPolicy).then(t=>{!e||!t.ok||t.value===null||a({key:i,target:/* @__PURE__ */Object.freeze({kind:"chat",conversationId:t.value.conversationId,petRef:t.value.petRef})})}),()=>{e=false}},[i,n,l,userRef]),o!==null&&o.key===i?o.target:void 0}function Zl(e){if(e===void 0)return null;let conversationId=e.conversationId??"",petRef=e.petRef??"";return conversationId===""&&petRef===""?null:`${String(conversationId)}|${String(petRef)}`}function Jl(t,r,n){let l=Zl(r),i=r?.kind==="chat",o=r?.petRef??null,a=i&&!n.pinned&&o!==null&&n.petRef!==null&&o!==n.petRef,s=e.useRef({openCheckin:t,target:r,selectPet:n.selectPet});s.current={openCheckin:t,target:r,selectPet:n.selectPet};let u=e.useRef(null),c=e.useRef(null),petRef=n.petRef;e.useEffect(()=>{if(l===null||u.current===l)return;let{openCheckin:e,target:t,selectPet:r}=s.current;if(a&&o!==null){if(c.current?.key!==l){c.current={key:l,from:petRef},r(o);return}petRef!==c.current.from&&(u.current=l);return}i&&!n.ready||(u.current=l,!(e===void 0||t===void 0)&&Promise.resolve(e(t)).catch(()=>{}))},[l,i,a,o,petRef,n.ready])}var Xl=/* @__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 ei(e){let t=e?.replace(/\s+/g," ").trim();return t||Xl.untitled}function ti(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString([],{month:"short",day:"numeric"})}function ri(e){let t=ti(e.updatedAt);return t===null?null:e.unreadCount!==null&&e.unreadCount>0?Xl.newReply.replace("{date}",t):t}function ni(e,t){return t?`${Xl.countLabel}${Xl.countSeparator}${e}`:Xl.countLabel}function li(e){return`${e.unreadCount!==null&&e.unreadCount>0?Xl.unreadPrefix:""}${Xl.openConversation} ${ei(e.title)}`}function ii(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').toLowerCase().trim().replace(/\s+/g," ")}function oi(e,t){let r=ii(t);if(r.length===0)return e;let n=[[],[],[]];for(let t of e){let e=ii(ei(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 ai(e){return{scope:e,rows:[],cursor:null,loading:false,loadingMore:false,error:null}}function si(t){let[r,n]=e.useState(false),[l,i]=e.useState(""),o=t.listConversations,a=e.useRef(0),[s,u]=e.useState(()=>ai(o)),c=s.scope===o?s:ai(o);e.useEffect(()=>(a.current+=1,n(false),i(""),u(ai(o)),()=>{a.current+=1}),[o]);let d=e.useCallback(async e=>{let r=++a.current,n=e!==void 0;u(e=>({...e,scope:o,loading:!n,loadingMore:n,error:null}));let l=await t.listConversations(e?{cursor:e}:void 0);if(r===a.current){if(!l.ok){u(e=>({...e,loading:false,loadingMore:false,error:l.error.displayMessage}));return}u(t=>{let r=e&&t.scope===o?t.rows:[],n=new Set(r.map(e=>e.id));return{scope:o,loading:false,loadingMore:false,error:null,rows:[...r,...l.value.conversations.filter(e=>!n.has(e.id))],cursor:l.value.nextCursor===e?null:l.value.nextCursor}})}},[t.listConversations,o]),p=()=>{n(true),i(""),d()},f=()=>{a.current+=1,n(false)},h=async e=>{let r=++a.current;u(e=>({...e,loading:true,error:null}));let l=await t.resumeConversation(e);r===a.current&&(u(e=>({...e,loading:false,error:l.ok?null:l.error.displayMessage})),l.ok&&n(false))},b=async()=>{let e=a.current,r=await t.loadOlderMessages();e===a.current&&!r.ok&&u(e=>({...e,error:r.error.displayMessage}))},g=()=>{t.newConversation(),a.current+=1,n(false)},m=()=>{c.cursor===null||c.loading||c.loadingMore||l.trim().length>0||d(c.cursor)},y=e.useMemo(()=>oi(c.rows,l),[c.rows,l]),v=l.trim().length>0;return{...c,open:r,show:p,close:f,load:d,resume:h,earlier:b,newConversation:g,loadMore:m,query:l,setQuery:i,searching:v,filtered:y,emptyKind:c.rows.length===0?"empty":"noMatch"}}var ui="#111111",ci="#FFFFFF",di=/* @__PURE__ */Object.freeze({emergency:/* @__PURE__ */Object.freeze({level:"emergency",label:"Call a vet now",borderColor:"#FCA5A5",backgroundColor:"#FEF2F2",textColor:"#991B1B",reasonColor:ui,pillColor:ci,showsVetAction:true}),schedule_soon:/* @__PURE__ */Object.freeze({level:"schedule_soon",label:"Vet care suggested soon",borderColor:"#FCD34D",backgroundColor:"#FFFBEB",textColor:"#92400E",reasonColor:ui,pillColor:ci,showsVetAction:true}),home_care:/* @__PURE__ */Object.freeze({level:"home_care",label:"Monitor at home",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:ui,pillColor:ci,showsVetAction:false}),general:/* @__PURE__ */Object.freeze({level:"general",label:"Good to know",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:ui,pillColor:ci,showsVetAction:false})});function pi(e){return`${e.messageId}:${e.level}:${e.reason??""}`}function fi(e){return ue(se.urgencyGeneralReason,{petName:e?.trim()||se.emptyTitlePetFallback})}function hi(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:bi(n.urgencyReason)}:n.urgencyProvided===true?{messageId:n.id,level:"general",reason:fi(t)}:null}return null}function bi(e){return typeof e=="string"&&e.trim().length>0?e:null}function gi(t){let r=t===null?null:pi(t),[n,l]=e.useState(null),[i,o]=e.useState(false);e.useEffect(()=>o(false),[r]);let a=t!==null&&(i||!(n!==null&&n===r)),s=t===null?null:di[t.level],u=t!==null&&!a&&t.level!=="general",c=e.useCallback(()=>{r!==null&&l(r),o(false)},[r]),d=e.useCallback(()=>o(true),[]);return e.useMemo(()=>({source:t,tier:s,signature:r,showBanner:a,showCompactIcon:u,showVetAction:a&&s!==null&&s.showsVetAction,dismissLabel:s===null?null:ue(se.dismissBanner,{label:s.label}),dismiss:c,expand:d}),[t,s,r,a,u,c,d])}var mi=class extends e.Component{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:t,fallback:r,resetKey:n}){return e.createElement(mi,{fallback:r,resetKey:n,children:e.createElement(RenderHost,{render:t})})}var yi=48;function vi(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}function CapabilityGate(t){let{capability:n,children:l,renderDisabled:i,renderPending:o,style:a}=t,s=useCapability(n),u=e.useMemo(()=>vi(s),[s]);switch(u){case"enabled":return l;case"pending":return o?/* @__PURE__ */r.jsx(HostRender,{render:o,fallback:/* @__PURE__ */r.jsx(PendingSkeleton,{capability:n,style:a})}):/* @__PURE__ */r.jsx(PendingSkeleton,{capability:n,style:a});case"disabled":return i?/* @__PURE__ */r.jsx(HostRender,{render:()=>i(s),fallback:/* @__PURE__ */r.jsx(OffState,{decision:s,style:a}),resetKey:s}):/* @__PURE__ */r.jsx(OffState,{decision:s,style:a});default:return assertNever(u)}}function PendingSkeleton({capability:n,style:l}){let i=useEverfurTheme(),o=e.useMemo(()=>xi(i),[i]);/* @__PURE__ */
|
|
20
|
-
return r.jsx(t.View,{style:[o.offstate,l],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${n}`,children:/* @__PURE__ */r.jsx(t.View,{style:o.skeletonBar})})}function OffState({decision:n,style:l}){let i=useEverfurTheme(),o=e.useMemo(()=>
|
|
21
|
-
return r.jsx(t.View,{style:[o.offstate,l],accessible:true,accessibilityRole:"text",accessibilityLabel:a,children:a.length>0?/* @__PURE__ */r.jsx(Text,{style:o.offstateText,children:a}):null})}function
|
|
22
|
-
return Object.freeze([...t])}function
|
|
23
|
-
return Object.freeze({hosts:e,open:r!==void 0?e=>{br(r,e,"message")}:
|
|
24
|
-
return r.jsxs(t.View,{style:[
|
|
19
|
+
return Object.freeze(t.flatMap(e=>{let t=widgetPetFromWire(e);return t===null?[]:[t]}))}function createPetsRepository(e){return nl(createRequestFunnel({auth:e}),createRequestFunnel({auth:e,unaryTimeoutMs:Un}))}function nl(e,t=e){let r=(e,t)=>t?{...e,signal:t}:e,n=petRef=>Kn(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(rl(n.value)):err(n.error)},async registerPet(petRef,t,r){let n=Kn(petRef,t);if(n!==null)return err(n);let l=Zn(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(el(o.value,petRef)):err(o.error)},async updatePet(petRef,t,l){let i=n(petRef);if(typeof i!="string")return err(i);let o=Qn(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(el(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=tl(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 ll=/* @__PURE__ */new WeakMap,il=/* @__PURE__ */new Map;function ol(e,t,petRef,r){let n=ll.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}|${sl(r)}`}function al(e,t){if(e===null)return t();let r=il.get(e);if(r!==void 0)return r;let n=t().finally(()=>{il.get(e)===n&&il.delete(e)});return il.set(e,n),n}function sl(e){return e===null||typeof e!="object"?JSON.stringify(e)??"undefined":Array.isArray(e)?`[${e.map(sl).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)}:${sl(t)}`).join(",")}}`}var ul="pet_not_registered";function cl(e){return e!=null&&e.reasonCode===ul}var dl=/* @__PURE__ */Object.freeze({status:"idle",error:null,registered:null,retry:()=>{}});function pl(petRef,t,r){let{runtime:n,userRef:userRef,scopeEpoch:l}=me(),i=e.useCallback((e,t)=>{let r=n.registry.services.authFor(userRef);return al(ol(n,r,e,t),()=>createPetsRepository(r).registerPet(e,t))},[n,userRef,l]),o=e.useMemo(()=>t===void 0?null:sl(t),[t]),[a,s]=e.useState({key:null,status:"idle",error:null,registered:null}),u=e.useRef(0),c=e.useRef(r);c.current=r;let d=petRef===null||o===null?null:`${String(userRef)}|${l}|${petRef}|${o}`,p=e.useCallback(()=>{if(petRef===null||t===void 0||d===null)return;let e=++u.current;s({key:d,status:"registering",error:null,registered:null}),i(petRef,t).then(t=>{e===u.current&&(t.ok?(s({key:d,status:"registered",error:null,registered:t.value}),c.current?.()):s({key:d,status:"failed",error:t.error,registered:null}))})},[i,petRef,d]);e.useEffect(()=>{if(d===null){u.current+=1;return}return p(),()=>{u.current+=1}},[d,p]);let f=e.useCallback(()=>{a.status==="failed"&&p()},[a.status,p]);return e.useMemo(()=>d===null?dl:a.key!==d?{status:"registering",error:null,registered:null,retry:f}:{status:a.status,error:a.error,registered:a.registered,retry:f},[d,a,f])}var fl=/* @__PURE__ */Object.freeze({});function hl(t){let[r,n]=e.useState(fl),l=e.useRef(null),i=e.useRef([]);i.current=t.map(e=>e.id),e.useEffect(()=>{if(t.length===0){l.current=null,n(e=>e===fl?e:fl);return}let e=l.current;if(e===null)return;let r=t.find(t=>t.role==="user"&&!e.known.has(t.id));r!==void 0&&(l.current=null,n(t=>({...t,[r.id]:e.images})))},[t]);let o=e.useCallback(e=>{l.current=e.length===0?null:{images:e,known:new Set(i.current)}},[]);return e.useMemo(()=>({byMessage:r,stage:o}),[r,o])}var bl=/* @__PURE__ */new WeakSet;function gl(){let e=makeEverfurError("internalError",{retryable:true});return bl.add(e),err(e)}function ml(e){if(typeof e!="object"||e===null||e.ok!==false)return false;let t=e.error;return typeof t=="object"&&t!==null&&bl.has(t)}var yl=500;function vl(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,yl):null}function xl(t,r,n,l){let i=vl(n),o=i===null?null:l!==void 0?`key:${String(l)}`:`prompt:${i}`,a=e.useRef(t);a.current=t;let s=e.useRef(null),u=e.useRef(null),c=e.useRef(o);c.current=o,e.useEffect(()=>{if(i===null||o===null||r||s.current===o||u.current===o)return;let e=a.current;if(e===void 0)return;u.current=o;let t=e=>{u.current===o&&(u.current=null),!ml(e)&&c.current===o&&(s.current=o)};Promise.resolve(e(i)).then(t,()=>t(void 0))},[i,o,r,t])}var wl=/* @__PURE__ */Object.freeze({openUnreadHead:true,reportLoadFailures:true}),kl=/* @__PURE__ */Object.freeze({reportLoadFailures:true}),Sl=/* @__PURE__ */Object.freeze({...wl,markRead:true}),Cl=/* @__PURE__ */Object.freeze({...kl,markRead:true});function jl(e,t){return e?t?Sl:wl:t?Cl:kl}function Rl(e,t){let r=e?.isVisible===void 0?t:e.isVisible.bind(e);return r===void 0?true:br(()=>r()!==!1)===true}function Tl(t,r){let n=e.useRef({target:t,isVisible:r});n.current={target:t,isVisible:r};let l=e.useRef(t.isStreaming);e.useEffect(()=>{let e=l.current;if(l.current=t.isStreaming,!e||t.isStreaming)return;let{target:r,isVisible:i}=n.current;r.status!=="complete"||r.conversationId===null||r.unreadCount===null||!i()||r.markRead()},[t.isStreaming])}function _l(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 zl(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"}:_l(e,conversationId,t)?{action:"skip",reason:"coalesced"}:{action:"refresh",conversationId:conversationId}}var Il=3e5;function Pl(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 El(t,r,n){let l=e.useRef(r);l.current=r;let i=e.useRef(null),o=e.useRef(null),a=e.useRef(false),s=e.useRef(0),u=e.useRef(0),c=e.useRef(3e4),d=()=>t?.isOffline===void 0?false:br(()=>t.isOffline?.()===!0)===true,p=d(),f=e.useRef(()=>{});f.current=e=>{let{conversationId:conversationId,isTurnInFlight:t,refresh:r,refreshesBlankThread:n}=l.current,p=zl(e,{activeConversationId:conversationId,isTurnInFlight:t,refreshesBlankThread:n===true,isOffline:d(),lastRefresh:i.current,now:Date.now()});if(p.action==="skip")return;if(p.action==="defer"){o.current!=="announced"&&(o.current=e);return}if(a.current){if(e==="poll")return;o.current!=="announced"&&(o.current=e);return}if(o.current=null,i.current={conversationId:p.conversationId,at:Date.now()},r===void 0)return;a.current=true;let h=e=>{a.current=false,Pl(e)?(s.current=Math.min(s.current===0?c.current*2:s.current*2,Il),u.current=Date.now()+s.current):(s.current=0,u.current=0);let t=o.current;t!==null&&f.current(t)};Promise.resolve(r()).then(h,()=>h({ok:false,error:{category:"server"}}))},e.useEffect(()=>{if(r.isTurnInFlight||p)return;let e=o.current;e!==null&&f.current(e)},[r.isTurnInFlight,p]),e.useEffect(()=>{if(t===void 0)return;let e=[],r=(t,r)=>{if(t===void 0)return;let n=br(()=>t(()=>{f.current(r)}));typeof n=="function"&&e.push(n)};return r(t.onForeground?.bind(t),"foreground"),r(t.onOnline?.bind(t),"foreground"),r(t.onAnnounced?.bind(t),"announced"),()=>{for(let t of e)br(t)}},[t]);let h=n?.intervalMs??null,b=n?.isVisibleFallback;e.useEffect(()=>{if(t===void 0||h===null||!Number.isFinite(h)||h<=0)return;c.current=h;let e=setInterval(()=>{Date.now()<u.current||Rl(t,b)&&f.current("poll")},h);return()=>clearInterval(e)},[t,h,b])}var Ml=/^efch_[A-Za-z0-9_-]{43}$/,Fl="efch";function Al(e){return typeof e=="string"&&Ml.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(`${Fl}=`))continue;let e=r.slice(Fl.length+1);return Al(e)?e:null}return null}var Ll=/* @__PURE__ */Object.freeze(["better","same","worse"]),Ol=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var Vl="checkin",Dl=/^\d{4}-\d{2}-\d{2}$/,Bl="watching";function isCheckinSettled(e){return e.status!=null&&e.status!==Bl}function Hl(e){if(typeof e!="string")return null;let t=e.split(":");if(t.length!==3)return null;let[r,n,l]=t;return r!==Vl||n===void 0||l===void 0||!Ol.test(n)||!Dl.test(l)?null:{caseId:n,dueDay:l}}function Wl(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 Nl(e,t,r){return makeEverfurError(e,{retryable:t,...{}})}var Ul=128,$l=/[\u0000-\u001f\u007f]/;function ql(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function Gl(e){return typeof e!="string"||e.length===0||e.length>Ul||$l.test(e)||e.includes("://")?null:e}function Kl(e){if(e===null)return null;let conversationId=e.conversation_id,petRef=Gl(e.pet_ref);return typeof conversationId!="string"||!Wl(conversationId)||petRef===null?null:{conversationId:conversationId,petRef:petRef}}function Yl(e,t,r){return Al(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(Kl(ql(e.value))):e.error.httpStatus===404?ok(null):err(e.error),()=>err(Nl("internalError",false))):Promise.resolve(ok(null))}function Ql(t,r){let n=r?.runtime??null,userRef=r?.userRef??null,l=Al(t)?t:null,i=l===null||userRef===null?null:`${String(userRef)}|${l}`,[o,a]=e.useState(null);return e.useEffect(()=>{if(i===null||l===null||userRef===null||n===null)return;let e=true,t=n.registry.services;return Yl(t.authFor(userRef),l,t.errorPolicy).then(t=>{!e||!t.ok||t.value===null||a({key:i,target:/* @__PURE__ */Object.freeze({kind:"chat",conversationId:t.value.conversationId,petRef:t.value.petRef})})}),()=>{e=false}},[i,n,l,userRef]),o!==null&&o.key===i?o.target:void 0}function Zl(e){if(e===void 0)return null;let conversationId=e.conversationId??"",petRef=e.petRef??"";return conversationId===""&&petRef===""?null:`${String(conversationId)}|${String(petRef)}`}function Jl(t,r,n){let l=Zl(r),i=r?.kind==="chat",o=r?.petRef??null,a=i&&!n.pinned&&o!==null&&n.petRef!==null&&o!==n.petRef,s=e.useRef({openCheckin:t,target:r,selectPet:n.selectPet});s.current={openCheckin:t,target:r,selectPet:n.selectPet};let u=e.useRef(null),c=e.useRef(null),petRef=n.petRef;e.useEffect(()=>{if(l===null||u.current===l)return;let{openCheckin:e,target:t,selectPet:r}=s.current;if(a&&o!==null){if(c.current?.key!==l){c.current={key:l,from:petRef},r(o);return}petRef!==c.current.from&&(u.current=l);return}i&&!n.ready||(u.current=l,!(e===void 0||t===void 0)&&Promise.resolve(e(t)).catch(()=>{}))},[l,i,a,o,petRef,n.ready])}var Xl=/* @__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 ei(e){let t=e?.replace(/\s+/g," ").trim();return t||Xl.untitled}function ti(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString([],{month:"short",day:"numeric"})}function ri(e){let t=ti(e.updatedAt);return t===null?null:e.unreadCount!==null&&e.unreadCount>0?Xl.newReply.replace("{date}",t):t}function ni(e,t){return t?`${Xl.countLabel}${Xl.countSeparator}${e}`:Xl.countLabel}function li(e){return`${e.unreadCount!==null&&e.unreadCount>0?Xl.unreadPrefix:""}${Xl.openConversation} ${ei(e.title)}`}function ii(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').toLowerCase().trim().replace(/\s+/g," ")}function oi(e,t){let r=ii(t);if(r.length===0)return e;let n=[[],[],[]];for(let t of e){let e=ii(ei(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 ai(e){return{scope:e,rows:[],cursor:null,loading:false,loadingMore:false,error:null}}function si(t){let[r,n]=e.useState(false),[l,i]=e.useState(""),o=t.listConversations,a=e.useRef(0),[s,u]=e.useState(()=>ai(o)),c=s.scope===o?s:ai(o);e.useEffect(()=>(a.current+=1,n(false),i(""),u(ai(o)),()=>{a.current+=1}),[o]);let d=e.useCallback(async e=>{let r=++a.current,n=e!==void 0;u(e=>({...e,scope:o,loading:!n,loadingMore:n,error:null}));let l=await t.listConversations(e?{cursor:e}:void 0);if(r===a.current){if(!l.ok){u(e=>({...e,loading:false,loadingMore:false,error:l.error.displayMessage}));return}u(t=>{let r=e&&t.scope===o?t.rows:[],n=new Set(r.map(e=>e.id));return{scope:o,loading:false,loadingMore:false,error:null,rows:[...r,...l.value.conversations.filter(e=>!n.has(e.id))],cursor:l.value.nextCursor===e?null:l.value.nextCursor}})}},[t.listConversations,o]),p=()=>{n(true),i(""),d()},f=()=>{a.current+=1,n(false)},h=async e=>{let r=++a.current;u(e=>({...e,loading:true,error:null}));let l=await t.resumeConversation(e);r===a.current&&(u(e=>({...e,loading:false,error:l.ok?null:l.error.displayMessage})),l.ok&&n(false))},b=async()=>{let e=a.current,r=await t.loadOlderMessages();e===a.current&&!r.ok&&u(e=>({...e,error:r.error.displayMessage}))},g=()=>{t.newConversation(),a.current+=1,n(false)},m=()=>{c.cursor===null||c.loading||c.loadingMore||l.trim().length>0||d(c.cursor)},y=e.useMemo(()=>oi(c.rows,l),[c.rows,l]),v=l.trim().length>0;return{...c,open:r,show:p,close:f,load:d,resume:h,earlier:b,newConversation:g,loadMore:m,query:l,setQuery:i,searching:v,filtered:y,emptyKind:c.rows.length===0?"empty":"noMatch"}}var ui="#111111",ci="#FFFFFF",di=/* @__PURE__ */Object.freeze({emergency:/* @__PURE__ */Object.freeze({level:"emergency",label:"Call a vet now",borderColor:"#FCA5A5",backgroundColor:"#FEF2F2",textColor:"#991B1B",reasonColor:ui,pillColor:ci,showsVetAction:true}),schedule_soon:/* @__PURE__ */Object.freeze({level:"schedule_soon",label:"Vet care suggested soon",borderColor:"#FCD34D",backgroundColor:"#FFFBEB",textColor:"#92400E",reasonColor:ui,pillColor:ci,showsVetAction:true}),home_care:/* @__PURE__ */Object.freeze({level:"home_care",label:"Monitor at home",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:ui,pillColor:ci,showsVetAction:false}),general:/* @__PURE__ */Object.freeze({level:"general",label:"Good to know",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:ui,pillColor:ci,showsVetAction:false})});function pi(e){return`${e.messageId}:${e.level}:${e.reason??""}`}function fi(e){return ue(se.urgencyGeneralReason,{petName:e?.trim()||se.emptyTitlePetFallback})}function hi(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:bi(n.urgencyReason)}:n.urgencyProvided===true?{messageId:n.id,level:"general",reason:fi(t)}:null}return null}function bi(e){return typeof e=="string"&&e.trim().length>0?e:null}function gi(t){let r=t===null?null:pi(t),[n,l]=e.useState(null),[i,o]=e.useState(false);e.useEffect(()=>o(false),[r]);let a=t!==null&&(i||!(n!==null&&n===r)),s=t===null?null:di[t.level],u=t!==null&&!a&&t.level!=="general",c=e.useCallback(()=>{r!==null&&l(r),o(false)},[r]),d=e.useCallback(()=>o(true),[]);return e.useMemo(()=>({source:t,tier:s,signature:r,showBanner:a,showCompactIcon:u,showVetAction:a&&s!==null&&s.showsVetAction,dismissLabel:s===null?null:ue(se.dismissBanner,{label:s.label}),dismiss:c,expand:d}),[t,s,r,a,u,c,d])}var mi=()=>globalThis[/* @__PURE__ */Symbol.for("everfur.sdk.chatCards.v1")]??={loader:null,lazy:null};var yi=mi;function registerEverfurChatCards(t){let r=yi();r.loader=t;let n=t&&Promise.resolve().then(t).then(e=>typeof e.ServerCards=="function"?e.ServerCards:NONE3,()=>NONE3);r.lazy=n&&e.lazy(async()=>({default:await n}))}var NONE3=()=>null,vi=e.createContext(null);function ServerCardsSlot({message:t}){let r=e.useContext(vi),n=yi(),l=t.a2ui??n.frames?.get(t.responseId),i=n.lazy;return l===void 0||r===null||i===null?null:e.createElement(e.Suspense,{fallback:null},e.createElement(i,{message:t,a2ui:l,host:r}))}var xi=class extends e.Component{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:t,fallback:r,resetKey:n}){return e.createElement(xi,{fallback:r,resetKey:n,children:e.createElement(RenderHost,{render:t})})}var wi=48;function ki(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}function CapabilityGate(t){let{capability:n,children:l,renderDisabled:i,renderPending:o,style:a}=t,s=useCapability(n),u=e.useMemo(()=>ki(s),[s]);switch(u){case"enabled":return l;case"pending":return o?/* @__PURE__ */r.jsx(HostRender,{render:o,fallback:/* @__PURE__ */r.jsx(PendingSkeleton,{capability:n,style:a})}):/* @__PURE__ */r.jsx(PendingSkeleton,{capability:n,style:a});case"disabled":return i?/* @__PURE__ */r.jsx(HostRender,{render:()=>i(s),fallback:/* @__PURE__ */r.jsx(OffState,{decision:s,style:a}),resetKey:s}):/* @__PURE__ */r.jsx(OffState,{decision:s,style:a});default:return assertNever(u)}}function PendingSkeleton({capability:n,style:l}){let i=useEverfurTheme(),o=e.useMemo(()=>Si(i),[i]);/* @__PURE__ */
|
|
20
|
+
return r.jsx(t.View,{style:[o.offstate,l],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${n}`,children:/* @__PURE__ */r.jsx(t.View,{style:o.skeletonBar})})}function OffState({decision:n,style:l}){let i=useEverfurTheme(),o=e.useMemo(()=>Si(i),[i]),a=n.disabled?.reason??"";/* @__PURE__ */
|
|
21
|
+
return r.jsx(t.View,{style:[o.offstate,l],accessible:true,accessibilityRole:"text",accessibilityLabel:a,children:a.length>0?/* @__PURE__ */r.jsx(Text,{style:o.offstateText,children:a}):null})}function Si(e){let{color:r,space:n,radius:l,type:i}=e;return t.StyleSheet.create({offstate:{minHeight:wi,justifyContent:"center",paddingHorizontal:n.lg,paddingVertical:n.md,backgroundColor:r.surfaceCream,borderRadius:l.md,borderWidth:t.StyleSheet.hairlineWidth,borderColor:r.brandBorder},offstateText:{...face(e,"regular"),fontSize:i.size.body,lineHeight:Math.round(i.size.body*i.lineHeight.normal),color:r.text.muted},skeletonBar:{height:n.md,borderRadius:l.xs,backgroundColor:r.brandSofter}})}var Ci="everfur.com",ji=2048,Ri=/^(\*\.)?(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;function Ti(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&&Ri.test(e)&&t.add(e)}/* @__PURE__ */
|
|
22
|
+
return Object.freeze([...t])}function _i(e,t){if(e===Ci||e.endsWith(`.${Ci}`))return true;for(let r of t)if(r.startsWith("*.")?e.endsWith(r.slice(1)):e===r)return true;return false}function zi(e,t){if(typeof e!="string"||e.length===0||e.length>ji||!/^https:\/\//i.test(e))return null;let r=Qe(e);return r===null||r.protocol!=="https:"||r.username!==""||r.password!==""||r.port!==""?null:_i(r.hostname,t)?r.href:null}function Ii(e){try{Promise.resolve(t.Linking.openURL(e)).catch(()=>{})}catch{}}var Pi=e.createContext(null);function Ei(){return e.useContext(Pi)??void 0}function MessageLinksScope({linkHosts:t,onOpenUrl:r,children:n}){let l=t===false?null:Array.isArray(t)?t.join(`\n`):"",i=e.useMemo(()=>{if(l===null)return null;let e=Ti(l===""?[]:l.split(`\n`));/* @__PURE__ */
|
|
23
|
+
return Object.freeze({hosts:e,open:r!==void 0?e=>{br(r,e,"message")}:Ii})},[l,r]);return e.createElement(Pi.Provider,{value:i},n)}var Mi={pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"};function Fi(e){return{width:e,height:e,alignItems:"center",justifyContent:"center"}}function Ai(e,t){return t??Math.max(1.5,Math.round(e/11*10)/10)}function MenuGlyph({size:e,color:n,strokeWidth:l}){let i=Ai(e,l),o={width:e*.82,height:i,borderRadius:i,backgroundColor:n};/* @__PURE__ */
|
|
24
|
+
return r.jsxs(t.View,{style:[Fi(e),{gap:e*.22}],...Mi,children:[
|
|
25
25
|
/* @__PURE__ */r.jsx(t.View,{style:o}),
|
|
26
26
|
/* @__PURE__ */r.jsx(t.View,{style:o}),
|
|
27
|
-
/* @__PURE__ */r.jsx(t.View,{style:o})]})}function Cross({size:e,color:n,strokeWidth:l,rotate:i}){let o=
|
|
28
|
-
return r.jsxs(t.View,{style:[
|
|
27
|
+
/* @__PURE__ */r.jsx(t.View,{style:o})]})}function Cross({size:e,color:n,strokeWidth:l,rotate:i}){let o=Ai(e,l),a=e*.78;/* @__PURE__ */
|
|
28
|
+
return r.jsxs(t.View,{style:[Fi(e),{transform:[{rotate:i}]}],...Mi,children:[
|
|
29
29
|
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",width:a,height:o,borderRadius:o,backgroundColor:n}}),
|
|
30
30
|
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",width:o,height:a,borderRadius:o,backgroundColor:n}})]})}function PlusGlyph(e){/* @__PURE__ */
|
|
31
31
|
return r.jsx(Cross,{...e,rotate:"0deg"})}function CloseGlyph(e){/* @__PURE__ */
|
|
32
|
-
return r.jsx(Cross,{...e,rotate:"45deg"})}function CheckGlyph({size:e,color:n,strokeWidth:l}){let i=
|
|
33
|
-
return r.jsx(t.View,{style:
|
|
34
|
-
return r.jsx(t.View,{style:
|
|
35
|
-
return r.jsxs(t.View,{style:[
|
|
32
|
+
return r.jsx(Cross,{...e,rotate:"45deg"})}function CheckGlyph({size:e,color:n,strokeWidth:l}){let i=Ai(e,l);/* @__PURE__ */
|
|
33
|
+
return r.jsx(t.View,{style:Fi(e),...Mi,children:/* @__PURE__ */r.jsx(t.View,{style:{width:e*.36,height:e*.66,marginTop:-e*.14,borderBottomWidth:i,borderRightWidth:i,borderColor:n,transform:[{rotate:"45deg"}]}})})}var Li={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:n,strokeWidth:l,direction:i}){let o=Ai(e,l),a=e*.46,s=Li[i];/* @__PURE__ */
|
|
34
|
+
return r.jsx(t.View,{style:Fi(e),...Mi,children:/* @__PURE__ */r.jsx(t.View,{style:{width:a,height:a,borderRightWidth:o,borderBottomWidth:o,borderColor:n,marginTop:a*s.marginTop,marginLeft:a*s.marginLeft,transform:[{rotate:s.rotate}]}})})}function BookGlyph({size:e,color:n,strokeWidth:l}){let i=Ai(e,l),o={width:e*.42,height:e*.7,borderWidth:i,borderColor:n,borderRadius:i};/* @__PURE__ */
|
|
35
|
+
return r.jsxs(t.View,{style:[Fi(e),{flexDirection:"row",gap:1}],...Mi,children:[
|
|
36
36
|
/* @__PURE__ */r.jsx(t.View,{style:[o,{borderTopLeftRadius:e*.2}]}),
|
|
37
|
-
/* @__PURE__ */r.jsx(t.View,{style:[o,{borderTopRightRadius:e*.2}]})]})}function ArrowUpRightGlyph({size:e,color:n,strokeWidth:l}){let i=
|
|
38
|
-
return r.jsxs(t.View,{style:
|
|
37
|
+
/* @__PURE__ */r.jsx(t.View,{style:[o,{borderTopRightRadius:e*.2}]})]})}function ArrowUpRightGlyph({size:e,color:n,strokeWidth:l}){let i=Ai(e,l),o=e*.5;/* @__PURE__ */
|
|
38
|
+
return r.jsxs(t.View,{style:Fi(e),...Mi,children:[
|
|
39
39
|
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",width:e*.78,height:i,borderRadius:i,backgroundColor:n,transform:[{rotate:"-45deg"}]}}),
|
|
40
|
-
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:e*.16,right:e*.16,width:o,height:o,borderTopWidth:i,borderRightWidth:i,borderColor:n}})]})}function CopyGlyph({size:e,color:n,strokeWidth:l}){let i=
|
|
41
|
-
return r.jsxs(t.View,{style:
|
|
40
|
+
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:e*.16,right:e*.16,width:o,height:o,borderTopWidth:i,borderRightWidth:i,borderColor:n}})]})}function CopyGlyph({size:e,color:n,strokeWidth:l}){let i=Ai(e,l),o=e*.6,a={position:"absolute",width:o,height:o,borderWidth:i,borderColor:n,borderRadius:e*.14};/* @__PURE__ */
|
|
41
|
+
return r.jsxs(t.View,{style:Fi(e),...Mi,children:[
|
|
42
42
|
/* @__PURE__ */r.jsx(t.View,{style:[a,{top:0,left:0}]}),
|
|
43
|
-
/* @__PURE__ */r.jsx(t.View,{style:[a,{bottom:0,right:0}]})]})}function ThumbGlyph({size:e,color:n,strokeWidth:l,active:i,rotate:o}){let a=
|
|
44
|
-
return r.jsxs(t.View,{style:[
|
|
43
|
+
/* @__PURE__ */r.jsx(t.View,{style:[a,{bottom:0,right:0}]})]})}function ThumbGlyph({size:e,color:n,strokeWidth:l,active:i,rotate:o}){let a=Ai(e,l),s=i?n:"transparent";/* @__PURE__ */
|
|
44
|
+
return r.jsxs(t.View,{style:[Fi(e),{transform:[{rotate:o}]}],...Mi,children:[
|
|
45
45
|
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",bottom:e*.08,left:e*.12,width:e*.62,height:e*.5,borderWidth:a,borderColor:n,backgroundColor:s,borderRadius:e*.12,borderTopLeftRadius:e*.04}}),
|
|
46
46
|
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:e*.04,left:e*.4,width:e*.3,height:e*.5,borderWidth:a,borderColor:n,backgroundColor:s,borderRadius:e*.15,transform:[{rotate:"-20deg"}]}}),
|
|
47
|
-
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",bottom:e*.08,left:0,width:e*.2,height:e*.5,borderWidth:a,borderColor:n,backgroundColor:s,borderRadius:e*.05}})]})}function InfoGlyph({size:e,color:n,strokeWidth:l}){let i=
|
|
48
|
-
return r.jsxs(t.View,{style:[
|
|
47
|
+
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",bottom:e*.08,left:0,width:e*.2,height:e*.5,borderWidth:a,borderColor:n,backgroundColor:s,borderRadius:e*.05}})]})}function InfoGlyph({size:e,color:n,strokeWidth:l}){let i=Ai(e,l);/* @__PURE__ */
|
|
48
|
+
return r.jsxs(t.View,{style:[Fi(e),{borderRadius:e/2,borderWidth:i,borderColor:n}],...Mi,children:[
|
|
49
49
|
/* @__PURE__ */r.jsx(t.View,{style:{width:i,height:i,borderRadius:i,backgroundColor:n,marginBottom:e*.1}}),
|
|
50
|
-
/* @__PURE__ */r.jsx(t.View,{style:{width:i,height:e*.34,borderRadius:i,backgroundColor:n}})]})}function UploadGlyph({size:e,color:n,strokeWidth:l}){let i=
|
|
51
|
-
return r.jsxs(t.View,{style:
|
|
50
|
+
/* @__PURE__ */r.jsx(t.View,{style:{width:i,height:e*.34,borderRadius:i,backgroundColor:n}})]})}function UploadGlyph({size:e,color:n,strokeWidth:l}){let i=Ai(e,l),o=e*.34;/* @__PURE__ */
|
|
51
|
+
return r.jsxs(t.View,{style:Fi(e),...Mi,children:[
|
|
52
52
|
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:e*.06,width:o,height:o,borderTopWidth:i,borderLeftWidth:i,borderColor:n,transform:[{rotate:"45deg"}]}}),
|
|
53
53
|
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:e*.1,width:i,height:e*.56,borderRadius:i,backgroundColor:n}}),
|
|
54
|
-
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",bottom:0,width:e*.84,height:e*.3,borderBottomWidth:i,borderLeftWidth:i,borderRightWidth:i,borderColor:n,borderBottomLeftRadius:i,borderBottomRightRadius:i}})]})}function PhotoGlyph({size:e,color:n,strokeWidth:l}){let i=
|
|
55
|
-
return r.jsxs(t.View,{style:[
|
|
54
|
+
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",bottom:0,width:e*.84,height:e*.3,borderBottomWidth:i,borderLeftWidth:i,borderRightWidth:i,borderColor:n,borderBottomLeftRadius:i,borderBottomRightRadius:i}})]})}function PhotoGlyph({size:e,color:n,strokeWidth:l}){let i=Ai(e,l);/* @__PURE__ */
|
|
55
|
+
return r.jsxs(t.View,{style:[Fi(e),{borderWidth:i,borderColor:n,borderRadius:e*.14,overflow:"hidden"}],...Mi,children:[
|
|
56
56
|
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:e*.16,left:e*.18,width:e*.16,height:e*.16,borderRadius:e,backgroundColor:n}}),
|
|
57
|
-
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",bottom:-e*.3,right:-e*.1,width:e*.7,height:e*.7,borderTopWidth:i,borderLeftWidth:i,borderColor:n,transform:[{rotate:"45deg"}]}})]})}function CameraGlyph({size:e,color:n,strokeWidth:l}){let i=
|
|
58
|
-
return r.jsxs(t.View,{style:
|
|
57
|
+
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",bottom:-e*.3,right:-e*.1,width:e*.7,height:e*.7,borderTopWidth:i,borderLeftWidth:i,borderColor:n,transform:[{rotate:"45deg"}]}})]})}function CameraGlyph({size:e,color:n,strokeWidth:l}){let i=Ai(e,l);/* @__PURE__ */
|
|
58
|
+
return r.jsxs(t.View,{style:Fi(e),...Mi,children:[
|
|
59
59
|
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:e*.08,width:e*.34,height:e*.2,borderTopWidth:i,borderLeftWidth:i,borderRightWidth:i,borderColor:n,borderTopLeftRadius:i,borderTopRightRadius:i}}),
|
|
60
|
-
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:e*.22,width:e*.92,height:e*.66,borderWidth:i,borderColor:n,borderRadius:e*.16,alignItems:"center",justifyContent:"center"},children:/* @__PURE__ */r.jsx(t.View,{style:{width:e*.3,height:e*.3,borderRadius:e,borderWidth:i,borderColor:n}})})]})}function SearchGlyph({size:e,color:n,strokeWidth:l}){let i=
|
|
61
|
-
return r.jsxs(t.View,{style:
|
|
60
|
+
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:e*.22,width:e*.92,height:e*.66,borderWidth:i,borderColor:n,borderRadius:e*.16,alignItems:"center",justifyContent:"center"},children:/* @__PURE__ */r.jsx(t.View,{style:{width:e*.3,height:e*.3,borderRadius:e,borderWidth:i,borderColor:n}})})]})}function SearchGlyph({size:e,color:n,strokeWidth:l}){let i=Ai(e,l),o=e/24,a=16*o+i,s=11*o-a/2,u=11+8/Math.SQRT2,c=(21-u)*Math.SQRT2*o,d=(u+21)/2*o;/* @__PURE__ */
|
|
61
|
+
return r.jsxs(t.View,{style:Fi(e),...Mi,children:[
|
|
62
62
|
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:s,left:s,width:a,height:a,borderRadius:a,borderWidth:i,borderColor:n}}),
|
|
63
|
-
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:d-i/2,left:d-(c+i)/2,width:c+i,height:i,borderRadius:i,backgroundColor:n,transform:[{rotate:"45deg"}]}})]})}function EditGlyph({size:e,color:n,strokeWidth:l}){let i=
|
|
64
|
-
return r.jsxs(t.View,{style:
|
|
63
|
+
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:d-i/2,left:d-(c+i)/2,width:c+i,height:i,borderRadius:i,backgroundColor:n,transform:[{rotate:"45deg"}]}})]})}function EditGlyph({size:e,color:n,strokeWidth:l}){let i=Ai(e,l);/* @__PURE__ */
|
|
64
|
+
return r.jsxs(t.View,{style:Fi(e),...Mi,children:[
|
|
65
65
|
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",width:e*.3,height:e*.82,borderWidth:i,borderColor:n,borderRadius:i,transform:[{rotate:"45deg"}]}}),
|
|
66
|
-
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",bottom:0,left:0,width:e*.4,height:i,borderRadius:i,backgroundColor:n}})]})}function MapPinGlyph({size:e,color:n,strokeWidth:l}){let i=
|
|
67
|
-
return r.jsxs(t.View,{style:
|
|
66
|
+
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",bottom:0,left:0,width:e*.4,height:i,borderRadius:i,backgroundColor:n}})]})}function MapPinGlyph({size:e,color:n,strokeWidth:l}){let i=Ai(e,l),o=e*.62;/* @__PURE__ */
|
|
67
|
+
return r.jsxs(t.View,{style:Fi(e),...Mi,children:[
|
|
68
68
|
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:0,width:o,height:o,borderRadius:o,borderWidth:i,borderColor:n,alignItems:"center",justifyContent:"center"},children:/* @__PURE__ */r.jsx(t.View,{style:{width:i*1.4,height:i*1.4,borderRadius:i,backgroundColor:n}})}),
|
|
69
69
|
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",bottom:e*.04,width:o*.5,height:o*.5,borderRightWidth:i,borderBottomWidth:i,borderColor:n,transform:[{rotate:"45deg"}]}})]})}function SendGlyph({size:e,color:n,testID:l}){let i=e*.36;/* @__PURE__ */
|
|
70
|
-
return r.jsx(t.View,{style:
|
|
71
|
-
return r.jsx(t.View,{style:
|
|
72
|
-
return r.jsxs(t.View,{style:
|
|
70
|
+
return r.jsx(t.View,{style:Fi(e),testID:l,...Mi,children:/* @__PURE__ */r.jsx(t.View,{style:{width:0,height:0,marginLeft:e*.12,borderLeftWidth:e*.78,borderTopWidth:i,borderBottomWidth:i,borderLeftColor:n,borderTopColor:"transparent",borderBottomColor:"transparent",transform:[{rotate:"-45deg"}]}})})}function StopGlyph({size:e,color:n,testID:l}){/* @__PURE__ */
|
|
71
|
+
return r.jsx(t.View,{style:Fi(e),testID:l,...Mi,children:/* @__PURE__ */r.jsx(t.View,{style:{width:e*.5,height:e*.5,backgroundColor:n}})})}function MicGlyph({size:e,color:n,strokeWidth:l,testID:i}){let o=Ai(e,l);/* @__PURE__ */
|
|
72
|
+
return r.jsxs(t.View,{style:Fi(e),testID:i,...Mi,children:[
|
|
73
73
|
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:e*.08,width:e*.26,height:e*.48,borderWidth:o,borderColor:n,borderRadius:e*.13}}),
|
|
74
74
|
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:e*.38,width:e*.56,height:e*.36,borderBottomWidth:o,borderLeftWidth:o,borderRightWidth:o,borderColor:n,borderBottomLeftRadius:e*.28,borderBottomRightRadius:e*.28}}),
|
|
75
75
|
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:e*.74,width:o,height:e*.18,backgroundColor:n}})]})}function Ring({size:e,strokeWidth:n,color:l,children:i}){/* @__PURE__ */
|
|
76
|
-
return r.jsx(t.View,{style:[
|
|
77
|
-
return r.jsxs(t.View,{style:
|
|
76
|
+
return r.jsx(t.View,{style:[Fi(e),{borderRadius:e/2,borderWidth:n??t.StyleSheet.hairlineWidth,borderColor:l}],children:i})}function ArrowUpGlyph({size:e,color:n,strokeWidth:l,testID:i}){let o=Ai(e,l),a=e*.46;/* @__PURE__ */
|
|
77
|
+
return r.jsxs(t.View,{style:Fi(e),testID:i,...Mi,children:[
|
|
78
78
|
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:e*.16,bottom:e*.12,width:o,borderRadius:o,backgroundColor:n}}),
|
|
79
|
-
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:e*.16+o/2,width:a,height:a,borderLeftWidth:o,borderTopWidth:o,borderColor:n,transform:[{rotate:"45deg"}]}})]})}function ChatBubbleGlyph({size:e,color:n,strokeWidth:l}){let i=
|
|
80
|
-
return r.jsxs(t.View,{style:
|
|
79
|
+
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:e*.16+o/2,width:a,height:a,borderLeftWidth:o,borderTopWidth:o,borderColor:n,transform:[{rotate:"45deg"}]}})]})}function ChatBubbleGlyph({size:e,color:n,strokeWidth:l}){let i=Ai(e,l);/* @__PURE__ */
|
|
80
|
+
return r.jsxs(t.View,{style:Fi(e),...Mi,children:[
|
|
81
81
|
/* @__PURE__ */r.jsx(t.View,{style:{width:e*.8,height:e*.6,marginTop:-e*.12,borderWidth:i,borderColor:n,borderRadius:e*.14}}),
|
|
82
|
-
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",bottom:e*.1,left:e*.22,width:e*.2,height:e*.2,borderLeftWidth:i,borderBottomWidth:i,borderColor:n}})]})}function HistoryGlyph({size:e,color:n,strokeWidth:l}){let i=
|
|
83
|
-
return r.jsxs(t.View,{style:
|
|
82
|
+
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",bottom:e*.1,left:e*.22,width:e*.2,height:e*.2,borderLeftWidth:i,borderBottomWidth:i,borderColor:n}})]})}function HistoryGlyph({size:e,color:n,strokeWidth:l}){let i=Ai(e,l),o=e*.72,a=e/2;/* @__PURE__ */
|
|
83
|
+
return r.jsxs(t.View,{style:Fi(e),...Mi,children:[
|
|
84
84
|
/* @__PURE__ */r.jsx(t.View,{style:{width:o,height:o,borderRadius:o/2,borderWidth:i,borderColor:n,borderLeftColor:"transparent",transform:[{rotate:"45deg"}]}}),
|
|
85
85
|
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:e*.16,left:e*.12,width:e*.2,height:e*.2,borderLeftWidth:i,borderBottomWidth:i,borderColor:n}}),
|
|
86
86
|
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:a-e*.2,left:a-i/2,width:i,height:e*.2+i/2,borderRadius:i,backgroundColor:n}}),
|
|
87
|
-
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:a-i/2,left:a-i/2,width:e*.15+i/2,height:i,borderRadius:i,backgroundColor:n}})]})}var
|
|
88
|
-
return r.jsx(t.Pressable,{...u,hitSlop:s??
|
|
89
|
-
/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:"button",accessibilityLabel:se.closePreview,style:
|
|
90
|
-
/* @__PURE__ */r.jsx(t.View,{pointerEvents:"box-none",style:[
|
|
91
|
-
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
|
|
92
|
-
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)??jo,s3_key:o,purpose:r(t.purpose)})}function Mo(e,t){let r=e.httpStatus;switch(e.code){case"quotaExceeded":return Po("quota_exceeded",false,t,{cause:e});case"rateLimited":return Po("rate_limited",true,t,{cause:e});case"idempotencyConflict":case"idempotencyInFlight":return Po("idempotency_conflict",true,t,{cause:e});case"validationFailed":return Po("unsupported_type",false,t,{cause:e});case"serviceUnavailable":case"streamTimeout":return Po("network",true,t,{cause:e});default:return r===429?Po("rate_limited",true,t,{cause:e}):r===503?Po("network",true,t,{cause:e}):r===void 0?Po("network",true,t,{cause:e}):Po("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:_o,body:{filename:t.filename,content_type:t.contentType,file_size:t.sizeBytes},...r?.signal?{signal:r.signal}:{}});if(!n.ok)return Io(Mo(n.error,t.filename));let l=Eo(n.value);return l===null?Io(Po("server",false,t.filename)):zo(l)}async function uploadAttachmentBytes(e,t,r,n){let l=()=>n?.signal?.aborted===true;if(l())return Io(Po("cancelled",true,r.filename));try{return await e.postMultipart(t,r.file,{...n?.signal?{signal:n.signal}:{},...n?.onProgress?{onProgress:n.onProgress}:{}}),zo(void 0)}catch{return l()?Io(Po("cancelled",true,r.filename)):Io(Po("server",true,r.filename))}}var Fo=2,Ao=3,Lo=/* @__PURE__ */Object.freeze([1e3,2e3,4e3]),Oo=0;function Vo(){return Oo+=1,`attachment-${Oo}`}function createAttachmentQueue(e){let t=Math.max(1,e.concurrency??Fo),r=Math.max(1,e.maxAttempts??Ao),n=e.backoffMs??Lo,l=Math.max(1,e.maxPerMessage??Ro),i=e.timers??xo,o=e.newId??Vo,a=vo(e.transport),s=/* @__PURE__ */new Map,u=[],c=[],d=/* @__PURE__ */new Set,p=/* @__PURE__ */new Set,f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])}),h=false,b=()=>{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()},g=(e,t)=>{e.state=/* @__PURE__ */Object.freeze({...e.state,...t}),b()},m=()=>{for(;!h&&d.size<t&&c.length>0;){let e=c.shift(),t=s.get(e);t!==void 0&&(d.add(e),y(t).finally(()=>{d.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;g(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=Io(a.error);else{let r=await uploadAttachmentBytes(e.transport,a.value,l,{signal:o,onProgress:e=>{!o.aborted&&t.state.status==="uploading"&&g(t,{progress:Do(e)})}});if(h||o.aborted)return;s=r.ok?zo(a.value.s3_key):Io(r.error)}if(s.ok){g(t,{status:"uploaded",s3Key:s.value,error:null,progress:1});return}let u=s.error,c=u.retryable&&t.attempts<r;if(g(t,{status:c?"uploading":"failed",error:u,progress:0}),!c)return;let d=n[Math.min(t.attempts-1,n.length-1)]??0;await wo(d,o,i)}},v=e=>{c.push(e.state.id),m()},x={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 Io(Po("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),b(),v(n),zo(n.state)},retry(e){let t=s.get(e);t===void 0||h||t.state.status!=="failed"||(t.controller=new AbortController,t.attempts=0,g(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=c.indexOf(e);n>=0&&c.splice(n,1),b()},clear(){for(let e of[...u])x.remove(e)},dispose(){h=true;for(let e of s.values())e.controller.abort();s.clear(),u.length=0,c.length=0,p.clear(),f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])})}};return x}function Do(e){return Number.isNaN(e)||e<0?0:e>1?1:e}function Bo(e){switch(e.code){case"too_large":return ue(se.attachmentTooLarge,{max:formatBytes(jo),filename:e.filename,size:formatBytes(e.sizeBytes??0)});case"too_many":return ue(se.attachmentTooMany,{max:Ro});case"unsupported_type":return ue(se.attachmentUnsupported,{filename:e.filename});case"network":return se.attachmentNetwork;case"server":return ue(se.attachmentServer,{status:""});case"cancelled":return se.attachmentCancelled;case"rate_limited":return se.attachmentRateLimited;case"quota_exceeded":return se.attachmentQuota;case"idempotency_conflict":return se.attachmentConflict;case"unknown":return se.attachmentUnknown}}function Ho(e,t){return ue(e>=t?se.attachmentsFull:se.addAttachment,{used:e,total:t})}var Wo=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])});function useChatAttachments(t={}){let{runtime:r,userRef:userRef,scopeEpoch:n}=me(),l=t.maxPerMessage??Ro,i=e.useCallback(()=>{let{services:e}=r.registry;return createAttachmentQueue({funnel:createRequestFunnel({auth:e.authFor(userRef),...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),transport:t.transport??e.uploadTransport,maxPerMessage:l})},[r,userRef,n,l,t.transport]),o=e.useMemo(()=>t.queue??i(),[t.queue,i]),a=e.useRef(/* @__PURE__ */new WeakSet),[s,u]=e.useState(null),c=s!==null&&s.of===o?s.queue:o;e.useEffect(()=>{if(c!==t.queue){if(a.current.has(c)){u({of:o,queue:i()});return}return()=>{c.dispose(),a.current.add(c)}}},[c,o,i,t.queue]);let d=e.useSyncExternalStore(c.subscribe,c.getSnapshot,()=>Wo),[p,f]=e.useState(null),h=e.useCallback(e=>{let t=(Array.isArray(e)?e:[e]).map(e=>c.add(e)),r=t.find(e=>!e.ok);return r!==void 0&&!r.ok&&f(r.error),t},[c,f]),b=e.useCallback(e=>c.retry(e),[c]),g=e.useCallback(e=>c.remove(e),[c]),m=e.useCallback(()=>c.clear(),[c]),y=e.useCallback(()=>f(null),[f]),v=d.attachments.some(e=>e.status==="uploading"),x=d.attachments.some(e=>e.status==="failed");return e.useMemo(()=>({available:c.available,attachments:d.attachments,maxPerMessage:l,uploading:v,failed:x,blocked:v||x,s3Keys:d.attachments.flatMap(e=>e.status==="uploaded"&&e.s3Key!==null?[e.s3Key]:[]),rejected:p,add:h,retry:b,remove:g,clear:m,dismissRejected:y}),[c.available,d,l,v,x,p,h,b,g,m,y])}var No=6e3;function Uo(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 $o(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 qo(e){switch(e){case"permissionDenied":return se.micBlocked;case"noSpeech":return se.noSpeech;case"unavailable":return se.dictationUnavailable}}function Go(e,t,r){if(e)try{e.track(t,{...r})}catch{}}var Ko=["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 Yo(e={}){let t=/* @__PURE__ */new Set,r=[];for(let n of[e.name,e.breed,...Ko]){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 Qo(t,conversationId,r){let[n,l]=e.useState({send:t,conversationId:conversationId,text:r??"",seeded:r??null}),i=n.send===t&&(n.conversationId===null||n.conversationId===conversationId);e.useEffect(()=>{l(e=>{let n=e.send===t&&(e.conversationId===null||e.conversationId===conversationId),l=n?e.text:"",i=n?e.seeded:null,o=r!=null&&r!==i&&l.length===0;return{send:t,conversationId:conversationId,text:o?r:l,seeded:o?r:i}})},[t,conversationId,r]);let o=e.useCallback(e=>l(r=>({send:t,conversationId:conversationId,text:e,seeded:r.seeded})),[t,conversationId]);return[i?n.text:"",o]}function Zo(t,conversationId,r,n,l=false){let i=e.useRef({draft:r,setDraft:n});i.current={draft:r,setDraft:n};let o=e.useRef(null),[a,s]=e.useState(null);e.useEffect(()=>{if(t===void 0)return;let e=`${conversationId??""}`;if(o.current===e)return;o.current=e;let r=true;return(async()=>{let n=await yr(()=>t.read(conversationId));if(!r)return;let l=n.ok&&typeof n.value=="string"?n.value:"";l.length>0&&i.current.draft.length===0&&i.current.setDraft(l),s(e)})(),()=>{r=false}},[t,conversationId]),e.useEffect(()=>{t===void 0||l||a!==`${conversationId??""}`||br(()=>t.write(conversationId,r))},[t,conversationId,r,a,l])}function Jo(e){if(!(t.Platform.OS!=="ios"||e===""))try{let r=t.AccessibilityInfo?.announceForAccessibility;typeof r=="function"&&r.call(t.AccessibilityInfo,e)}catch{}}function AnnounceLine({line:t}){return e.useEffect(()=>{Jo(t)},[t]),null}var Xo=12,ea=80,ta=44,ra=22,na=.14,la=18,ia=8,oa=/* @__PURE__ */Object.freeze({photo:se.attachmentPhoto,camera:se.attachmentCamera});function AttachmentPickerPopover({sources:n,full:l,onPick:i,onClose:o}){let a=useEverfurTheme(),s=e.useMemo(()=>aa(a),[a]);/* @__PURE__ */
|
|
87
|
+
/* @__PURE__ */r.jsx(t.View,{style:{position:"absolute",top:a-i/2,left:a-i/2,width:e*.15+i/2,height:i,borderRadius:i,backgroundColor:n}})]})}var Oi=/* @__PURE__ */Object.freeze({standard:I.standard,emphasized:I.emphasized,exit:I.exit,outQuad:/* @__PURE__ */Object.freeze([.25,.46,.45,.94]),out:/* @__PURE__ */Object.freeze([.23,1,.32,1])});var Vi=/* @__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}),Di=/* @__PURE__ */Object.freeze({...Vi,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 Bi(e){return e.motion.reducedMotion?Di:Vi}function Hi(e,t){return Math.max(0,t)*e.followUpStaggerMs}function Wi(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 Ni(){let e=useEverfurTheme();return Bi(e)}var Ui=8;function $i(e,t,r){return((1-3*r+3*t)*e+(3*r-6*t))*e*e+3*t*e}function qi(e,t,r){return 3*(1-3*r+3*t)*e*e+2*(3*r-6*t)*e+3*t}function Gi(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<Ui;r+=1){let r=qi(i,t,n);if(r===0)break;i-=($i(i,t,n)-e)/r}return $i(Math.min(1,Math.max(0,i)),r,l)}}var Ki=Gi(Oi.standard),Yi=Gi(Oi.outQuad),Qi=Gi(Oi.out);function Zi(r){let n=e.useRef(null);return n.current===null&&(n.current=new t.Animated.Value(r)),n.current}function Ji(r,n={}){let l=n.risePx??0,i=n.delayMs??0,o=Zi(r>0?0:1);return e.useEffect(()=>{if(r<=0){o.setValue(1);return}let e=t.Animated.timing(o,{toValue:1,duration:r,easing:Yi,useNativeDriver:true}),n=i>0?t.Animated.sequence([t.Animated.delay(i),e]):e;return n.start(),()=>n.stop()},[o,r,i]),e.useMemo(()=>({opacity:o,transform:[{translateY:o.interpolate({inputRange:[0,1],outputRange:[l,0]})}]}),[o,l])}function FadePresence({visible:n,inMs:l,outMs:i,style:o,children:a}){let[s,u]=e.useState(n),c=Zi(n&&l<=0?1:0);return e.useEffect(()=>{if(n){u(true);let e=t.Animated.timing(c,{toValue:1,duration:Math.max(0,l),easing:Ki,useNativeDriver:true});return e.start(),()=>e.stop()}if(!s)return;if(i<=0){u(false);return}let e=t.Animated.timing(c,{toValue:0,duration:i,easing:Ki,useNativeDriver:true});return e.start(({finished:e})=>{e&&u(false)}),()=>e.stop()},[n,s,l,i,c]),!s&&!n?null:/* @__PURE__ */r.jsx(t.Animated.View,{style:[o,{opacity:c}],children:a})}var Xi=/* @__PURE__ */Object.freeze({opacity:1,transform:/* @__PURE__ */Object.freeze([{translateY:0},{scale:1}])});function eo(r,n){let[l]=e.useState(()=>r?n.bubbleInMs:0),i=l>0,o=Zi(i?0:1);e.useEffect(()=>{if(l<=0)return;let e=t.Animated.timing(o,{toValue:1,duration:l,easing:Qi,useNativeDriver:true});return e.start(),()=>e.stop()},[l,o]);let a=n.bubbleFromScale,s=n.bubbleRisePx;return e.useMemo(()=>i?{opacity:o,transform:[{translateY:o.interpolate({inputRange:[0,1],outputRange:[s,0]})},{scale:o.interpolate({inputRange:[0,1],outputRange:[a,1]})}]}:Xi,[i,o,s,a])}function to(t){let r=e.useRef(null),n=e.useRef(null),l=t[0]?.id??null;if(r.current===null||n.current!==l){let e=r.current===null;r.current=new Map(t.map(t=>[t.id,e&&t.pending===true])),n.current=l}let i=r.current;for(let e of t)i.has(e.id)||i.set(e.id,true);return e.useCallback(e=>i.get(e)===true,[i])}var ro=12;function PressScale({style:n,containerStyle:l,children:i,onPressIn:o,onPressOut:a,hitSlop:s,...u}){let c=Ni(),d=Zi(1),p=e.useCallback(e=>{c.pressMs<=0||c.pressScale===1||t.Animated.timing(d,{toValue:e,duration:c.pressMs,easing:Ki,useNativeDriver:true}).start()},[d,c.pressMs,c.pressScale]);/* @__PURE__ */
|
|
88
|
+
return r.jsx(t.Pressable,{...u,hitSlop:s??ro,style:l,onPressIn:e=>{p(c.pressScale),o?.(e)},onPressOut:e=>{p(1),a?.(e)},children:/* @__PURE__ */r.jsx(t.Animated.View,{style:[n,{transform:[{scale:d}]}],children:i})})}function no(t,r,n){let l=r&&n.revealTickMs>0,[i,o]=e.useState(0),a=e.useRef(t);return a.current=t,e.useEffect(()=>{if(!l)return;let e=setInterval(()=>{o(e=>Wi(n,e,a.current.length))},n.revealTickMs);return()=>clearInterval(e)},[l,n]),l?t.slice(0,Math.min(i,t.length)):t}var lo=false;function io(e){e.layoutMs<=0||(lo||(lo=true,t.Platform.OS==="android"&&typeof t.UIManager.setLayoutAnimationEnabledExperimental=="function"&&t.UIManager.setLayoutAnimationEnabledExperimental(true)),t.LayoutAnimation.configureNext({duration:e.layoutMs,create:{type:"easeInEaseOut",property:"opacity"},update:{type:"easeInEaseOut"},delete:{type:"easeInEaseOut",property:"opacity"}}))}function oo(t,r){let n=e.useRef(t);n.current!==t&&(n.current=t,io(r))}var ao=36,so=22,uo=12,co=12,po=16,fo="#000",ho="rgba(0,0,0,0.45)";function AttachmentImageLightbox({uri:e,label:l,onClose:i}){let o=useEverfurTheme(),a=n.useSafeAreaInsets();return e===null?null:/* @__PURE__ */r.jsxs(t.Modal,{visible:true,animationType:o.motion.reducedMotion?"none":"fade",transparent:false,statusBarTranslucent:true,onRequestClose:i,children:[
|
|
89
|
+
/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:"button",accessibilityLabel:se.closePreview,style:bo.backdrop,onPress:i,children:/* @__PURE__ */r.jsx(t.Image,{source:{uri:e},style:bo.image,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:l,accessibilityIgnoresInvertColors:true})}),
|
|
90
|
+
/* @__PURE__ */r.jsx(t.View,{pointerEvents:"box-none",style:[bo.closeWrap,{top:a.top+co}],children:/* @__PURE__ */r.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:se.closePreview,hitSlop:uo,style:bo.closeButton,onPress:i,children:/* @__PURE__ */r.jsx(CloseGlyph,{size:so,color:o.color.surface,strokeWidth:2})})})]})}var bo=t.StyleSheet.create({backdrop:{flex:1,backgroundColor:fo,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"},closeWrap:{position:"absolute",right:po},closeButton:{width:ao,height:ao,borderRadius:ao/2,backgroundColor:ho,alignItems:"center",justifyContent:"center"}});var go=()=>{};function mo(){try{return t.AppState.currentState==="active"}catch{return false}}function createAppStateLifecycle(){return{onForeground(e){let r;try{let n=t.AppState.currentState==="background";r=t.AppState.addEventListener("change",t=>{t==="background"?n=!0:t==="active"&&n&&(n=!1,e())})}catch{return go}return()=>r.remove()},isVisible:mo}}function yo(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 vo(e){return e===void 0||e.backgroundColor!==void 0?e:e.borderRadius===void 0?void 0:{borderRadius:e.borderRadius}}function xo(e){return e?.textColor===void 0?{}:{color:e.textColor}}var wo=/* @__PURE__ */Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function ko(e){return e!==wo}var So=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function Co(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 jo=4e3;var Ro=4e3;var To=/* @__PURE__ */Object.freeze(["image/jpeg","image/jpg","image/png","image/heic","image/heif","image/webp"]);var _o=10*1024*1024,zo=5,Io=120,Po="/widget/v1/uploads/initiate";function isAttachmentMime(e){return typeof e=="string"&&To.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<=Io)return t;let r=t.lastIndexOf(".");if(r===-1||r===t.length-1)return t.slice(0,Io);let n=t.slice(r);return n.length>=Io?t.slice(0,Io):`${t.slice(0,r).slice(0,Io-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 Eo=e=>/* @__PURE__ */Object.freeze({ok:true,value:e}),Mo=e=>/* @__PURE__ */Object.freeze({ok:false,error:e});function Fo(e,t,r,n){/* @__PURE__ */
|
|
91
|
+
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 Mo(Fo("unsupported_type",false,t));let n=attachmentSize(e);return n===null?Mo(Fo("unknown",false,t)):n>_o?Mo(Fo("too_large",false,t,{sizeBytes:n})):Eo(/* @__PURE__ */Object.freeze({file:e,filename:t,contentType:r,sizeBytes:n}))}function Ao(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__ */
|
|
92
|
+
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)??_o,s3_key:o,purpose:r(t.purpose)})}function Lo(e,t){let r=e.httpStatus;switch(e.code){case"quotaExceeded":return Fo("quota_exceeded",false,t,{cause:e});case"rateLimited":return Fo("rate_limited",true,t,{cause:e});case"idempotencyConflict":case"idempotencyInFlight":return Fo("idempotency_conflict",true,t,{cause:e});case"validationFailed":return Fo("unsupported_type",false,t,{cause:e});case"serviceUnavailable":case"streamTimeout":return Fo("network",true,t,{cause:e});default:return r===429?Fo("rate_limited",true,t,{cause:e}):r===503?Fo("network",true,t,{cause:e}):r===void 0?Fo("network",true,t,{cause:e}):Fo("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:Po,body:{filename:t.filename,content_type:t.contentType,file_size:t.sizeBytes},...r?.signal?{signal:r.signal}:{}});if(!n.ok)return Mo(Lo(n.error,t.filename));let l=Ao(n.value);return l===null?Mo(Fo("server",false,t.filename)):Eo(l)}async function uploadAttachmentBytes(e,t,r,n){let l=()=>n?.signal?.aborted===true;if(l())return Mo(Fo("cancelled",true,r.filename));try{return await e.postMultipart(t,r.file,{...n?.signal?{signal:n.signal}:{},...n?.onProgress?{onProgress:n.onProgress}:{}}),Eo(void 0)}catch{return l()?Mo(Fo("cancelled",true,r.filename)):Mo(Fo("server",true,r.filename))}}var Oo=2,Vo=3,Do=/* @__PURE__ */Object.freeze([1e3,2e3,4e3]),Bo=0;function Ho(){return Bo+=1,`attachment-${Bo}`}function createAttachmentQueue(e){let t=Math.max(1,e.concurrency??Oo),r=Math.max(1,e.maxAttempts??Vo),n=e.backoffMs??Do,l=Math.max(1,e.maxPerMessage??zo),i=e.timers??So,o=e.newId??Ho,a=ko(e.transport),s=/* @__PURE__ */new Map,u=[],c=[],d=/* @__PURE__ */new Set,p=/* @__PURE__ */new Set,f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])}),h=false,b=()=>{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()},g=(e,t)=>{e.state=/* @__PURE__ */Object.freeze({...e.state,...t}),b()},m=()=>{for(;!h&&d.size<t&&c.length>0;){let e=c.shift(),t=s.get(e);t!==void 0&&(d.add(e),y(t).finally(()=>{d.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;g(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=Mo(a.error);else{let r=await uploadAttachmentBytes(e.transport,a.value,l,{signal:o,onProgress:e=>{!o.aborted&&t.state.status==="uploading"&&g(t,{progress:Wo(e)})}});if(h||o.aborted)return;s=r.ok?Eo(a.value.s3_key):Mo(r.error)}if(s.ok){g(t,{status:"uploaded",s3Key:s.value,error:null,progress:1});return}let u=s.error,c=u.retryable&&t.attempts<r;if(g(t,{status:c?"uploading":"failed",error:u,progress:0}),!c)return;let d=n[Math.min(t.attempts-1,n.length-1)]??0;await Co(d,o,i)}},v=e=>{c.push(e.state.id),m()},x={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 Mo(Fo("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),b(),v(n),Eo(n.state)},retry(e){let t=s.get(e);t===void 0||h||t.state.status!=="failed"||(t.controller=new AbortController,t.attempts=0,g(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=c.indexOf(e);n>=0&&c.splice(n,1),b()},clear(){for(let e of[...u])x.remove(e)},dispose(){h=true;for(let e of s.values())e.controller.abort();s.clear(),u.length=0,c.length=0,p.clear(),f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])})}};return x}function Wo(e){return Number.isNaN(e)||e<0?0:e>1?1:e}function No(e){switch(e.code){case"too_large":return ue(se.attachmentTooLarge,{max:formatBytes(_o),filename:e.filename,size:formatBytes(e.sizeBytes??0)});case"too_many":return ue(se.attachmentTooMany,{max:zo});case"unsupported_type":return ue(se.attachmentUnsupported,{filename:e.filename});case"network":return se.attachmentNetwork;case"server":return ue(se.attachmentServer,{status:""});case"cancelled":return se.attachmentCancelled;case"rate_limited":return se.attachmentRateLimited;case"quota_exceeded":return se.attachmentQuota;case"idempotency_conflict":return se.attachmentConflict;case"unknown":return se.attachmentUnknown}}function Uo(e,t){return ue(e>=t?se.attachmentsFull:se.addAttachment,{used:e,total:t})}var $o=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])});function useChatAttachments(t={}){let{runtime:r,userRef:userRef,scopeEpoch:n}=me(),l=t.maxPerMessage??zo,i=e.useCallback(()=>{let{services:e}=r.registry;return createAttachmentQueue({funnel:createRequestFunnel({auth:e.authFor(userRef),...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),transport:t.transport??e.uploadTransport,maxPerMessage:l})},[r,userRef,n,l,t.transport]),o=e.useMemo(()=>t.queue??i(),[t.queue,i]),a=e.useRef(/* @__PURE__ */new WeakSet),[s,u]=e.useState(null),c=s!==null&&s.of===o?s.queue:o;e.useEffect(()=>{if(c!==t.queue){if(a.current.has(c)){u({of:o,queue:i()});return}return()=>{c.dispose(),a.current.add(c)}}},[c,o,i,t.queue]);let d=e.useSyncExternalStore(c.subscribe,c.getSnapshot,()=>$o),[p,f]=e.useState(null),h=e.useCallback(e=>{let t=(Array.isArray(e)?e:[e]).map(e=>c.add(e)),r=t.find(e=>!e.ok);return r!==void 0&&!r.ok&&f(r.error),t},[c,f]),b=e.useCallback(e=>c.retry(e),[c]),g=e.useCallback(e=>c.remove(e),[c]),m=e.useCallback(()=>c.clear(),[c]),y=e.useCallback(()=>f(null),[f]),v=d.attachments.some(e=>e.status==="uploading"),x=d.attachments.some(e=>e.status==="failed");return e.useMemo(()=>({available:c.available,attachments:d.attachments,maxPerMessage:l,uploading:v,failed:x,blocked:v||x,s3Keys:d.attachments.flatMap(e=>e.status==="uploaded"&&e.s3Key!==null?[e.s3Key]:[]),rejected:p,add:h,retry:b,remove:g,clear:m,dismissRejected:y}),[c.available,d,l,v,x,p,h,b,g,m,y])}var qo=6e3;function Go(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 Ko(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 Yo(e){switch(e){case"permissionDenied":return se.micBlocked;case"noSpeech":return se.noSpeech;case"unavailable":return se.dictationUnavailable}}function Qo(e,t,r){if(e)try{e.track(t,{...r})}catch{}}var Zo=["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 Jo(e={}){let t=/* @__PURE__ */new Set,r=[];for(let n of[e.name,e.breed,...Zo]){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 Xo(t,conversationId,r){let[n,l]=e.useState({send:t,conversationId:conversationId,text:r??"",seeded:r??null}),i=n.send===t&&(n.conversationId===null||n.conversationId===conversationId);e.useEffect(()=>{l(e=>{let n=e.send===t&&(e.conversationId===null||e.conversationId===conversationId),l=n?e.text:"",i=n?e.seeded:null,o=r!=null&&r!==i&&l.length===0;return{send:t,conversationId:conversationId,text:o?r:l,seeded:o?r:i}})},[t,conversationId,r]);let o=e.useCallback(e=>l(r=>({send:t,conversationId:conversationId,text:e,seeded:r.seeded})),[t,conversationId]);return[i?n.text:"",o]}function ea(t,conversationId,r,n,l=false){let i=e.useRef({draft:r,setDraft:n});i.current={draft:r,setDraft:n};let o=e.useRef(null),[a,s]=e.useState(null);e.useEffect(()=>{if(t===void 0)return;let e=`${conversationId??""}`;if(o.current===e)return;o.current=e;let r=true;return(async()=>{let n=await yr(()=>t.read(conversationId));if(!r)return;let l=n.ok&&typeof n.value=="string"?n.value:"";l.length>0&&i.current.draft.length===0&&i.current.setDraft(l),s(e)})(),()=>{r=false}},[t,conversationId]),e.useEffect(()=>{t===void 0||l||a!==`${conversationId??""}`||br(()=>t.write(conversationId,r))},[t,conversationId,r,a,l])}function ta(e){if(!(t.Platform.OS!=="ios"||e===""))try{let r=t.AccessibilityInfo?.announceForAccessibility;typeof r=="function"&&r.call(t.AccessibilityInfo,e)}catch{}}function AnnounceLine({line:t}){return e.useEffect(()=>{ta(t)},[t]),null}var ra=12,na=80,la=44,ia=22,oa=.14,aa=18,sa=8,ua=/* @__PURE__ */Object.freeze({photo:se.attachmentPhoto,camera:se.attachmentCamera});function AttachmentPickerPopover({sources:n,full:l,onPick:i,onClose:o}){let a=useEverfurTheme(),s=e.useMemo(()=>ca(a),[a]);/* @__PURE__ */
|
|
93
93
|
return r.jsxs(t.View,{style:s.anchor,pointerEvents:"box-none",children:[
|
|
94
94
|
/* @__PURE__ */r.jsx(t.Pressable,{style:s.dismissLayer,accessibilityRole:"button",accessibilityLabel:se.closeAttachmentPicker,onPress:o}),
|
|
95
95
|
/* @__PURE__ */r.jsxs(t.View,{style:s.bubble,children:[
|
|
96
|
-
/* @__PURE__ */r.jsx(t.View,{style:s.tilesRow,children:n.map(e=>/* @__PURE__ */r.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:
|
|
97
|
-
/* @__PURE__ */r.jsx(t.View,{style:s.tileIconWrap,children:e==="photo"?/* @__PURE__ */r.jsx(PhotoGlyph,{size:
|
|
98
|
-
/* @__PURE__ */r.jsx(Text,{tier:"control",style:s.tileLabel,children:
|
|
96
|
+
/* @__PURE__ */r.jsx(t.View,{style:s.tilesRow,children:n.map(e=>/* @__PURE__ */r.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:ua[e],accessibilityState:{disabled:l},disabled:l,containerStyle:s.tile,style:s.tileInner,onPress:()=>i(e),children:[
|
|
97
|
+
/* @__PURE__ */r.jsx(t.View,{style:s.tileIconWrap,children:e==="photo"?/* @__PURE__ */r.jsx(PhotoGlyph,{size:ia,color:a.color.brandInk,strokeWidth:1.5}):/* @__PURE__ */r.jsx(CameraGlyph,{size:ia,color:a.color.brandInk,strokeWidth:1.5})}),
|
|
98
|
+
/* @__PURE__ */r.jsx(Text,{tier:"control",style:s.tileLabel,children:ua[e]})]},e))}),
|
|
99
99
|
/* @__PURE__ */r.jsx(t.View,{style:s.tail}),
|
|
100
|
-
/* @__PURE__ */r.jsx(t.View,{style:s.tailFill})]})]})}function
|
|
100
|
+
/* @__PURE__ */r.jsx(t.View,{style:s.tailFill})]})]})}function ca(e){let r=e.color,n=e.radius;return t.StyleSheet.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:r.surfaceCream,borderRadius:n.lg,borderWidth:1,borderColor:r.brandBorderStrong,paddingHorizontal:6,paddingVertical:8,shadowColor:r.shadow,shadowOpacity:oa,shadowRadius:aa,shadowOffset:{width:0,height:sa},elevation:8},tilesRow:{flexDirection:"row",alignItems:"stretch"},tile:{minWidth:na,borderRadius:n.md},tileInner:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:10,paddingVertical:8,gap:6},tileIconWrap:{width:la,height:la,borderRadius:la/2,backgroundColor:r.brandSoft,alignItems:"center",justifyContent:"center"},tileLabel:{...face(e,"medium"),fontSize:12,lineHeight:14,color:r.text.primary},tail:{position:"absolute",left:24,bottom:-ra/2,width:ra,height:ra,backgroundColor:r.surfaceCream,borderRightWidth:1,borderBottomWidth:1,borderColor:r.brandBorderStrong,transform:[{rotate:"45deg"}]},tailFill:{position:"absolute",left:22,bottom:0,width:ra+4,height:2,backgroundColor:r.surfaceCream}})}function parseColor(e){let t=da(e);return t===null?null:ya(t)}function da(e){if(typeof e=="number")return ha(e);if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;if(t.startsWith("#"))return pa(t.slice(1));if(t.toLowerCase().startsWith("0x"))return pa(t.slice(2));if(t.toLowerCase().startsWith("rgb"))return fa(t);if(/^[0-9a-fA-F]+$/.test(t)){let e=pa(t);if(e!==null)return e}return/^\d+$/.test(t)?ha(Number.parseInt(t,10)):null}function pa(e){let t=e.trim();if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===3)return{r:ga(t[0]),g:ga(t[1]),b:ga(t[2]),a:1};if(t.length===6)return{r:ba(t,0),g:ba(t,2),b:ba(t,4),a:1};if(t.length===8){let e=ba(t,0);return{r:ba(t,2),g:ba(t,4),b:ba(t,6),a:e/255}}return null}function fa(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=ma(Number(n[0])),i=ma(Number(n[1])),o=ma(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 ha(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 ba(e,t){return Number.parseInt(e.slice(t,t+2),16)}function ga(e){return Number.parseInt(`${e??"0"}${e??"0"}`,16)}function ma(e){return Number.isFinite(e)?Math.min(255,Math.max(0,Math.round(e))):null}function ya(e){if(e.a>=1)return va(e.r,e.g,e.b);let t=Math.round(e.a*1e3)/1e3;return`rgba(${e.r},${e.g},${e.b},${t})`}function va(e,t,r){return`#${xa(e)}${xa(t)}${xa(r)}`.toUpperCase()}function xa(e){return e.toString(16).padStart(2,"0")}var wa="#111111",ka="#FFFFFF",Sa="#000000";function readableOn(e){let t=da(e);if(t===null)return ka;let r=Ra(t),n=Ra({r:17,g:17,b:17}),l=Ra({r:255,g:255,b:255});return _a(r,l)>=_a(r,n)?ka:wa}function Ca(e,t){let r=readableOn(e);return contrastRatio(r,e)>=t?r:contrastRatio(ka,e)>=contrastRatio(Sa,e)?ka:Sa}function ja(e){let t=t=>e.reduce((e,r)=>Math.min(e,contrastRatio(t,r)),Number.POSITIVE_INFINITY);return t(ka)>=t(Sa)?ka:Sa}function Ra(e){let t=Ta(e.r/255),r=Ta(e.g/255),n=Ta(e.b/255);return.2126*t+.7152*r+.0722*n}function Ta(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}function _a(e,t){let r=Math.max(e,t),n=Math.min(e,t);return(r+.05)/(n+.05)}function contrastRatio(e,t){let r=da(e),n=da(t);if(r===null||n===null)return 1;let l=n.a>=1?n:{...n},i=r.a>=1?r:za(r,l);return _a(Ra(i),Ra(l))}function za(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 Ia(e,t){let r=da(e),n=da(t);if(r===null||n===null)return null;let l=r.a>=1?r:za(r,{...n});return va(l.r,l.g,l.b)}function Pa(e,t){let r=da(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 Ea=.05;function Ma(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(da(e)===null)return r;if(i(e))return e;let o=Ia(e,l),a=o===null?null:da(o),s=da(r);if(a===null||s===null)return r;for(let e=1;e<1/Ea;e+=1){let t=e*Ea,r=(e,r)=>Math.round(e+(r-e)*t),n=va(r(a.r,s.r),r(a.g,s.g),r(a.b,s.b));if(i(n))return n}return r}var Fa=/* @__PURE__ */Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});var Aa=56,La=12,Oa=14,Va=10,Da=.45,Ba="rgba(7,193,104,0.55)",Ha="rgba(185,28,28,0.55)",Wa=200,Na=300,Ua=20,$a=22,qa=12,Ga="rgba(0,0,0,0.78)",Ka=220,Ya=100,Qa="rgba(255,255,255,0.15)";function AttachmentStrip({attachments:n,rejected:l,uploadFailed:i=false,onRetry:o,onRemove:a,onPreview:s,style:u}){let c=useEverfurTheme(),d=e.useMemo(()=>Za(c),[c]);return n.length===0&&l===null?null:/* @__PURE__ */r.jsxs(t.View,{style:[d.strip,u],children:[n.length>0?/* @__PURE__ */r.jsx(t.View,{style:d.cards,children:n.map(e=>/* @__PURE__ */r.jsx(PreviewCard,{row:e,styles:d,onRetry:o,onRemove:a,onPreview:s},e.id))}):null,i?/* @__PURE__ */r.jsx(Text,{style:d.rejected,accessibilityRole:"alert",children:se.attachmentsFailedBlocked}):null,l!==null?/* @__PURE__ */r.jsx(Text,{style:d.rejected,accessibilityRole:"alert",children:No(l)}):null]})}function PreviewCard({row:n,styles:l,onRetry:i,onRemove:o,onPreview:a}){let s=useEverfurTheme(),u=n.status==="uploading",c=n.status==="failed",d=n.status==="uploaded",p=e.useRef(n.status),[f,h]=e.useState(false);return e.useEffect(()=>{let e=p.current;p.current=n.status,n.status==="uploaded"&&e==="uploading"&&h(true)},[n.status]),/* @__PURE__ */r.jsxs(t.View,{style:l.card,children:[
|
|
101
101
|
/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:d?"button":"image",accessibilityLabel:d?ue(se.previewAttachment,{filename:n.filename}):n.filename,accessibilityState:{busy:u,disabled:!d},disabled:!d,style:l.thumbHit,onPress:()=>a(n),children:/* @__PURE__ */r.jsxs(t.View,{style:l.thumb,children:[
|
|
102
|
-
/* @__PURE__ */r.jsx(t.Image,{source:{uri:n.previewUri},style:l.thumbImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true}),u?/* @__PURE__ */r.jsx(t.View,{style:l.uploadingOverlay,children:/* @__PURE__ */r.jsx(t.ActivityIndicator,{size:"small",color:s.color.surface})}):null,f?/* @__PURE__ */r.jsx(SuccessFlash,{styles:l,onDone:()=>h(false)}):null]})}),c?/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:"button",accessibilityLabel:ue(se.retryUpload,{filename:n.filename}),style:l.failedOverlay,onPress:()=>i(n.id),children:/* @__PURE__ */r.jsx(t.View,{style:l.failedInner,children:/* @__PURE__ */r.jsx(CloseGlyph,{size:
|
|
103
|
-
/* @__PURE__ */r.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:ue(se.removeAttachment,{filename:n.filename}),hitSlop:6,containerStyle:l.removeSlot,style:l.removeButton,onPress:()=>o(n.id),children:/* @__PURE__ */r.jsx(CloseGlyph,{size:
|
|
104
|
-
return r.jsx(t.View,{style:a?o.sentSingle:o.sentGrid,children:n.map((e,n)=>/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:"button",accessibilityLabel:ue(se.attachedImage,{filename:e.filename}),onPress:()=>l(e),children:/* @__PURE__ */r.jsx(t.Image,{source:{uri:e.uri},style:a?o.singleImage:o.gridImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true})},`${e.uri}-${n}`))})}function
|
|
105
|
-
return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(
|
|
102
|
+
/* @__PURE__ */r.jsx(t.Image,{source:{uri:n.previewUri},style:l.thumbImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true}),u?/* @__PURE__ */r.jsx(t.View,{style:l.uploadingOverlay,children:/* @__PURE__ */r.jsx(t.ActivityIndicator,{size:"small",color:s.color.surface})}):null,f?/* @__PURE__ */r.jsx(SuccessFlash,{styles:l,onDone:()=>h(false)}):null]})}),c?/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:"button",accessibilityLabel:ue(se.retryUpload,{filename:n.filename}),style:l.failedOverlay,onPress:()=>i(n.id),children:/* @__PURE__ */r.jsx(t.View,{style:l.failedInner,children:/* @__PURE__ */r.jsx(CloseGlyph,{size:Ua,color:s.color.surface,strokeWidth:2})})}):null,
|
|
103
|
+
/* @__PURE__ */r.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:ue(se.removeAttachment,{filename:n.filename}),hitSlop:6,containerStyle:l.removeSlot,style:l.removeButton,onPress:()=>o(n.id),children:/* @__PURE__ */r.jsx(CloseGlyph,{size:qa,color:s.color.surface,strokeWidth:1.5})})]})}function SuccessFlash({styles:n,onDone:l}){let i=useEverfurTheme(),o=Ni(),a=e.useRef(null);a.current===null&&(a.current=new t.Animated.Value(0));let s=a.current;return e.useEffect(()=>{let e=t.Animated.sequence([t.Animated.timing(s,{toValue:1,duration:Wa,useNativeDriver:true}),t.Animated.delay(o.uploadFlashMs),t.Animated.timing(s,{toValue:0,duration:Na,useNativeDriver:true})]);return e.start(({finished:e})=>{e&&l()}),()=>e.stop()},[s,o.uploadFlashMs,l]),/* @__PURE__ */r.jsx(t.Animated.View,{pointerEvents:"none",style:[n.successOverlay,{opacity:s}],children:/* @__PURE__ */r.jsx(CheckGlyph,{size:Ua,color:i.color.surface,strokeWidth:2})})}function SentImages({images:n,onPreview:l}){let i=useEverfurTheme(),o=e.useMemo(()=>Za(i),[i]);if(n.length===0)return null;let a=n.length===1;/* @__PURE__ */
|
|
104
|
+
return r.jsx(t.View,{style:a?o.sentSingle:o.sentGrid,children:n.map((e,n)=>/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:"button",accessibilityLabel:ue(se.attachedImage,{filename:e.filename}),onPress:()=>l(e),children:/* @__PURE__ */r.jsx(t.Image,{source:{uri:e.uri},style:a?o.singleImage:o.gridImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true})},`${e.uri}-${n}`))})}function Za(e){let r=e.color,n=e.type;return t.StyleSheet.create({strip:{gap:6,paddingBottom:8},cards:{flexDirection:"row",flexWrap:"wrap",gap:8},card:{width:Aa,height:Aa,overflow:"visible"},thumbHit:{width:"100%",height:"100%"},thumb:{width:"100%",height:"100%",borderRadius:La,overflow:"hidden",backgroundColor:r.composerFill,borderWidth:t.StyleSheet.hairlineWidth,borderColor:r.brandBorder},thumbImage:{width:"100%",height:"100%"},uploadingOverlay:{...Fa,alignItems:"center",justifyContent:"center",backgroundColor:Pa(e.color.brandInk,Da)??e.color.brandSofter},successOverlay:{...Fa,alignItems:"center",justifyContent:"center",backgroundColor:Ba},failedOverlay:{...Fa,borderRadius:La,overflow:"hidden"},failedInner:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:Ha},removeSlot:{position:"absolute",top:4,right:4},removeButton:{width:$a,height:$a,borderRadius:$a/2,backgroundColor:Ga,borderWidth:1.5,borderColor:r.surface,alignItems:"center",justifyContent:"center"},rejected:{...face(e,"regular"),fontSize:n.size.caption,lineHeight:n.size.caption*n.lineHeight.normal,color:r.danger},sentSingle:{marginBottom:6},sentGrid:{flexDirection:"row",flexWrap:"wrap",gap:6,marginBottom:6},singleImage:{width:Ka,height:Ka,borderRadius:Oa,backgroundColor:Qa},gridImage:{width:Ya,height:Ya,borderRadius:Va,backgroundColor:Qa}})}var Ja="file",Xa="multipart upload failed";function es(e){let t;try{t=new FormData;for(let[r,n]of Object.entries(e.fields))t.append(r,n);t.append(Ja,e.file)}catch{return Promise.reject(new Error(Xa))}return e.fetch!==void 0?ns(e.fetch,e.url,t,e.signal):rs(e.url,t,e.signal)}function ts(e){return e>=200&&e<300}function rs(e,t,r){return new Promise((n,l)=>{let i=globalThis.XMLHttpRequest;if(typeof i!="function"||r?.aborted===true){l(new Error(Xa));return}let o=null,a=()=>{o!==null&&r?.removeEventListener("abort",o)},s=()=>{a(),l(new Error(Xa))};try{let l=new i;l.open("POST",e),l.withCredentials=!1,l.onload=()=>{a(),n(ts(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 ns(e,t,r,n){return Promise.resolve().then(()=>e(t,{method:"POST",body:r,credentials:"omit",...n?{signal:n}:{}})).then(e=>e.ok)}var ls="chat attachment upload: the file handle has no uri",is="chat attachment upload failed";function os(e){return{uri:e.uri,name:sanitizeFilename(e.name),type:e.mimeType}}function createRnChatAttachmentTransport(e={}){/* @__PURE__ */
|
|
105
|
+
return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(ls));let{signal:l,onProgress:i}=n,o=()=>Promise.reject(new Error(is));return l?.aborted===true?o():es({url:t.upload_url,fields:t.upload_fields,file:os(r),signal:l,fetch:e.fetch}).then(e=>{if(!e)return o();i?.(1)},o)}})}var as=300,ss=3e3,us=120,cs=44,ds=120,ps="88%",fs=520,hs=2,bs=.5,gs=1.5,ms=1.6,ys=.6,vs=56,xs=1.5,ws=5,ks=5,Ss=36,Cs=20,js=14,Rs=cs,Ts=4,_s=24,zs=22,Is=.4,Ps=cs,Es=20,Ms=.4,Fs=480,As=12,Ls=.72,Os=48,Vs=1.5,Ds=1.3,Bs=1,Hs=1,Ws="12%",Ns=14,Us=16,$s=28,qs=18,Gs="84%",Ks=10,Ys=15,Qs=1.42,Zs=4,Js=3,Xs=14,eu=20;function tu(){let t=useEverfurTheme(),r=e.useMemo(()=>ru(t),[t]);return{theme:t,styles:r}}function ru(e){let r=e.color,n=e.space,l=e.radius,i=e.type,o=Math.round(i.size.body*gs),a=Math.round(i.size.body*ms),s=Math.round(Cs*i.size.body/js),u=r.borderRingCream,c=e.slots;return t.StyleSheet.create({container:{flex:1,minHeight:us,backgroundColor:r.chatGround},body:{flex:1},centered:{minHeight:us,flexGrow:1,alignItems:"center",justifyContent:"center",padding:n.xl},homeEmpty:{flexGrow:1},emptyContent:{flexGrow:1,alignItems:"stretch",justifyContent:"flex-start",paddingTop:Ws,paddingHorizontal:n.lg,paddingBottom:n.lg,minHeight:Fs,gap:n.lg},errorText:{...face(e,"regular"),fontSize:i.size.subtitle,lineHeight:i.size.subtitle*i.lineHeight.snug,color:r.danger,textAlign:"center",marginBottom:n.md},retryButton:{minHeight:cs,minWidth:cs,alignItems:"center",justifyContent:"center",paddingHorizontal:n.xl,paddingVertical:n.sm,borderRadius:l.pill,backgroundColor:r.brand,...yo(c.primaryButton)},retryLabel:{...face(e,"medium"),color:r.onPrimary,fontSize:i.size.body,...xo(c.primaryButton)},setupNotice:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:n.sm,paddingHorizontal:n.lg,paddingVertical:n.sm,backgroundColor:r.surfaceCream},setupNoticeText:{...face(e,"regular"),color:r.danger,fontSize:i.size.caption,flexShrink:1},turnNotice:{gap:n.xs,padding:n.md,borderRadius:l.md,backgroundColor:r.surfaceCream,borderWidth:Hs,borderColor:r.borderRingCream,alignItems:"flex-start"},turnNoticeError:{borderColor:r.danger},turnNoticeTitle:{...face(e,"bold"),color:r.text.primary,fontSize:i.size.bodyTight},turnNoticeTitleError:{color:r.danger},turnNoticeBody:{...face(e,"regular"),color:r.text.muted,fontSize:i.size.caption,lineHeight:i.size.caption*i.lineHeight.normal},turnNoticeAction:{minHeight:cs,justifyContent:"center"},turnNoticeActionLabel:{...face(e,"bold"),color:r.brandInk,fontSize:i.size.bodyTight},setupNoticeAction:{...face(e,"medium"),color:r.brandInk,fontSize:i.size.caption},reconnectingCaption:{...face(e,"medium"),color:r.text.secondary,fontSize:i.size.caption,lineHeight:i.size.caption*i.lineHeight.normal,textTransform:"uppercase",letterSpacing:.5},readingBox:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:n.xs,paddingVertical:n.md,paddingHorizontal:n.md+n.xs/2,backgroundColor:r.surfaceSubtle,borderRadius:l.md},readingDot:{width:6,height:6,borderRadius:l.pill,backgroundColor:r.brandInk},readingInline:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:Js,minHeight:Xs},readingDotInline:{width:Zs,height:Zs,borderRadius:l.pill,backgroundColor:r.text.muted},list:{flex:1},earlierButton:{alignSelf:"center",minHeight:cs,justifyContent:"center",paddingHorizontal:n.md+n.xs/2},earlierLabel:{...face(e,"monoBold"),color:r.linkInk,fontSize:i.size.caption},listContent:{padding:n.lg,gap:n.xl},listContentCards:{paddingTop:Ns,paddingHorizontal:Us,paddingBottom:$s,gap:qs},rowBlock:{gap:n.sm},rowBlockUser:{},rowBlockAssistant:{paddingRight:n.xl},row:{flexDirection:"row"},rowUser:{justifyContent:"flex-end"},rowAssistant:{justifyContent:"flex-start"},bubble:{maxWidth:ps,alignItems:"flex-start"},bubbleSideUser:{alignItems:"flex-end"},bubbleUser:{maxWidth:fs,paddingVertical:n.md,paddingHorizontal:n.lg+hs,backgroundColor:r.bubbleUser,...r.primaryEdge!==r.primary&&r.bubbleUser===r.primary?{borderWidth:bs,borderColor:r.primaryEdge}:{},borderRadius:l.lg,borderBottomRightRadius:l.xs,...yo(c.userBubble,bs)},bubbleAssistant:c.assistantBubble?.backgroundColor===void 0?{...yo(c.assistantBubble,bs)}:{paddingVertical:n.md,paddingHorizontal:n.lg+hs,borderRadius:l.lg,...yo(c.assistantBubble,bs)},bubbleVet:{maxWidth:fs,paddingVertical:n.md,paddingHorizontal:n.lg+hs,backgroundColor:r.bubbleVet,borderRadius:l.lg,borderTopLeftRadius:l.xs,...yo(c.vetBubble,bs)},bubbleCards:{maxWidth:Gs},bubbleUserCards:{paddingVertical:Ks,paddingHorizontal:Ys},bubbleTextUserCards:{fontSize:textRole(e,"message").fontSize,lineHeight:Math.round(textRole(e,"message").fontSize*Qs)},bubblePending:{opacity:ys},bubbleTextUser:{...face(e,"regular"),color:r.onPrimary,fontSize:i.size.body,lineHeight:o,...xo(c.userBubble)},bubbleTextAssistant:{...face(e,"regular"),color:r.text.primary,fontSize:i.size.body,lineHeight:a,...xo(c.assistantBubble)},bubbleTextVet:{...face(e,"regular"),color:r.onBubbleVet,fontSize:i.size.body,lineHeight:o,...xo(c.vetBubble)},assistantName:{...face(e,"bold"),color:r.brandInk,fontSize:i.size.bodyTight,marginBottom:n.xs},assistantSender:{flexDirection:"row",alignItems:"center",gap:n.sm,marginBottom:n.xs},assistantAvatar:{width:eu,height:eu,borderRadius:eu/2},assistantNameInRow:{marginBottom:0},vetHeader:{flexDirection:"row",alignItems:"baseline",gap:n.sm,marginBottom:n.xs},vetSender:{...face(e,"bold"),color:r.text.primary,fontSize:i.size.bodyTight},vetTime:{...face(e,"regular"),color:r.text.muted,fontSize:i.size.caption},bubbleBold:face(e,"bold"),bubbleItalic:{fontStyle:"italic"},bubbleCode:face(e,"mono"),followUps:{alignSelf:"stretch",marginTop:n.md},followUpsHeading:{...face(e,"monoBold"),color:r.text.muted,fontSize:As,textTransform:"uppercase",letterSpacing:Ls,paddingBottom:n.sm,borderBottomWidth:Bs,borderBottomColor:u},followUpSlot:{alignSelf:"stretch"},followUpSlotRuled:{borderTopWidth:Bs,borderTopColor:u},followUpRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:n.md,minHeight:Os,paddingVertical:n.sm+hs,...c.chip?.backgroundColor!==void 0||c.chip?.borderColor!==void 0?{paddingHorizontal:n.md}:{},...yo(c.chip)},followUpText:{...face(e,"bold"),flex:1,color:r.brandInk,fontSize:i.size.bodyTight,...xo(c.chip)},askChips:{flexDirection:"row",flexWrap:"wrap",gap:n.sm,marginTop:n.md},askChip:{minHeight:cs,maxWidth:"100%",justifyContent:"center",paddingVertical:n.sm,paddingHorizontal:n.lg,borderRadius:l.pill,borderWidth:Vs,borderColor:r.brandInk,backgroundColor:r.chatGround,...yo(c.chip,Vs)},askChipText:{...face(e,"bold"),color:r.brandInk,fontSize:i.size.bodyTight,lineHeight:Math.round(i.size.bodyTight*Ds),...xo(c.chip)},composerOuter:{position:"relative"},askEntry:{marginHorizontal:n.md,marginTop:n.xs},composer:{marginHorizontal:n.md,marginTop:n.xs,minHeight:vs,justifyContent:"center",paddingLeft:n.sm,paddingRight:ws,paddingVertical:ks,backgroundColor:r.composerFill,borderWidth:xs,borderColor:r.composerBorder,borderRadius:l.pill,...yo(c.composerInput,xs)},composerRow:{flexDirection:"row",alignItems:"center",gap:n.xs,minHeight:Ss},dictationError:{...face(e,"regular"),fontSize:i.size.caption,lineHeight:i.size.caption*i.lineHeight.normal,color:r.danger,paddingHorizontal:n.xs},attachControl:{width:Ps,height:Ps,alignItems:"center",justifyContent:"center"},attachControlDisabled:{opacity:Ms},input:{flex:1,minHeight:Ss,maxHeight:ds,paddingHorizontal:0,paddingVertical:0,...face(e,"regular"),fontSize:i.size.body,lineHeight:s,color:r.text.primary,...xo(c.composerInput)},sendControl:{minHeight:Rs,minWidth:Rs,alignItems:"center",justifyContent:"center"},sendDisc:{width:Rs,height:Rs,borderRadius:Rs/2,alignItems:"center",justifyContent:"center",...yo(c.sendButton)},sendControlDisabled:{opacity:Is},poweredBy:{...face(e,"regular"),color:r.text.muted,fontSize:i.size.micro,textAlign:"center",paddingBottom:n.xs}})}var nu=18,lu=28,iu=6,ou=1200,au=.4,su=.4;function DictationButton({active:n,listening:l,elapsedMs:i,disabled:o=false,onToggle:a}){let s=useEverfurTheme(),u=e.useMemo(()=>uu(s),[s]);return e.useEffect(()=>{if(l)try{t.AccessibilityInfo.announceForAccessibility(se.listening)}catch{}},[l]),/* @__PURE__ */r.jsxs(t.View,{style:u.wrap,children:[l?/* @__PURE__ */r.jsx(Text,{style:u.timer,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",testID:"everfur-dictation-timer",children:Ko(i)}):null,
|
|
106
106
|
/* @__PURE__ */r.jsx(t.Pressable,{onPress:()=>a(),disabled:o,accessibilityRole:"button",accessibilityLabel:n?se.stopDictation:se.dictate,accessibilityState:{selected:n,disabled:o},style:[u.button,o?u.buttonDisabled:null],testID:"everfur-dictation-button",children:n?/* @__PURE__ */r.jsxs(r.Fragment,{children:[
|
|
107
107
|
/* @__PURE__ */r.jsx(Pulse,{style:u.pulse,reduced:s.motion.reducedMotion}),
|
|
108
|
-
/* @__PURE__ */r.jsx(StopGlyph,{size:
|
|
109
|
-
return Object.freeze({available:false,module:null,reason:e})}function
|
|
110
|
-
return r.jsx(Composer,{...n,attachments:o})}function Composer({send:n,stop:l,isStreaming:i,conversationId:conversationId,attachments:o,seed:a,draftStore:s,onStage:u,onPreview:c,petName:d,petBreed:p=null,mood:f="ask",dictation:h=false,telemetry:b=null,compact:g=false,petPlaceholder:m=false,dimEmptySend:y=false}){let{theme:v,styles:x}=
|
|
111
|
-
return r.jsxs(t.View,{style:x.composerOuter,children:[o!==null&&R?/* @__PURE__ */r.jsx(AttachmentPickerPopover,{sources:o.sources,full:X,onPick:Y,onClose:()=>T(false)}):null,o!==null?/* @__PURE__ */r.jsx(AttachmentStrip,{attachments:$,rejected:E?
|
|
108
|
+
/* @__PURE__ */r.jsx(StopGlyph,{size:lu,color:s.color.brandInk,testID:"everfur-dictation-stop"})]}):/* @__PURE__ */r.jsx(MicGlyph,{size:nu,color:s.color.brandInk,testID:"everfur-dictation-mic"})})]})}function Pulse({style:n,reduced:l}){let i=e.useRef(new t.Animated.Value(1)).current;return e.useEffect(()=>{if(l)return;let e=t.Animated.loop(t.Animated.sequence([t.Animated.timing(i,{toValue:au,duration:ou/2,useNativeDriver:true}),t.Animated.timing(i,{toValue:1,duration:ou/2,useNativeDriver:true})]));return e.start(),()=>e.stop()},[i,l]),/* @__PURE__ */r.jsx(t.Animated.View,{style:[n,{opacity:i}],accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"})}function uu(e){let r=e.color,n=e.type.tierSizes.compact.micro;return t.StyleSheet.create({wrap:{flexDirection:"row",flexShrink:0,alignItems:"center",gap:e.space.xs},timer:{...face(e,"mono"),fontSize:n,lineHeight:n+2,fontVariant:["tabular-nums"],color:r.text.muted},button:{width:cs,height:cs,borderRadius:e.radius.pill,alignItems:"center",justifyContent:"center"},buttonDisabled:{opacity:su},pulse:{position:"absolute",top:iu,right:iu,bottom:iu,left:iu,borderRadius:e.radius.pill,backgroundColor:r.brandSofter}})}function optionalModule(e,t,r){let n;try{n=t()}catch(t){return du(`optional peer '${e}' is not installed: ${pu(t)}`)}let l=cu(n);return l==null?du(`optional peer '${e}' resolved to no module`):r&&!r(l)?du(`optional peer '${e}' is present but failed its shape check`):/* @__PURE__ */Object.freeze({available:true,module:l})}function cu(e){return typeof e=="object"&&e!==null&&"default"in e&&Object.keys(e).length<=2?e.default:e}function du(e){/* @__PURE__ */
|
|
109
|
+
return Object.freeze({available:false,module:null,reason:e})}function pu(e){return e instanceof Error?e.message:typeof e=="string"?e:"unknown load error"}var fu=/* @__PURE__ */Symbol.for("@everfur/sdk/rn-dictation");function hu(){let e=globalThis,t=e[fu];if(t!==void 0)return t;let r={loader:null,memo:void 0};return e[fu]=r,r}function registerEverfurDictation(e){let t=hu();t.loader=e,t.memo=void 0,t.version=(t.version??0)+1;for(let e of[...t.listeners??[]])try{e()}catch{}}function bu(){return hu().version??0}function gu(e){let t=hu(),r=t.listeners??/* @__PURE__ */new Set;t.listeners=r;let n=()=>e();return r.add(n),()=>{r.delete(n)}}function mu(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 yu(e){return typeof e!="object"||e===null?null:e.ExpoSpeechRecognitionModule??e}function vu(){let e=hu();if(e.memo!==void 0)return e.memo;e.memo=null;let r=e.loader;if(r===null||t.Platform.OS!=="ios"&&t.Platform.OS!=="android")return e.memo;let n=optionalModule("expo-speech-recognition",()=>({box:yu(r())}),e=>typeof e=="object"&&e!==null&&mu(e.box));return n.available&&(e.memo=n.module.box),e.memo}function xu(e){if(e===null)return false;try{return e.isRecognitionAvailable()===!0}catch{return false}}function wu(){try{return Intl.DateTimeFormat().resolvedOptions().locale||Su}catch{return Su}}function ku(e){return e.replace(/_/g,"-").toLowerCase()}var Su="en-US";function Cu(e=wu()){let[t=""]=e.replace(/_/g,"-").split("-u-"),r=t.split("-");if(r[0]?.toLowerCase()!=="en")return Su;let n=r.slice(1).find(e=>/^[A-Za-z]{2}$/.test(e));return n?`en-${n.toUpperCase()}`:Su}function ju(e,t){if(t.length===0)return null;let r=e=>t.find(t=>ku(t)===ku(e));return r(e)??r(Su)??t.find(e=>ku(e).startsWith("en-"))??null}async function Ru(e,r){if(t.Platform.OS!=="ios")return r;try{let{locales:t}=await e.getSupportedLocales({});return ju(r,t??[])??r}catch{return r}}async function Tu(e,r){let n=false;try{n=e.supportsOnDeviceRecognition()===!0}catch{n=false}if(!n)return"network";if(t.Platform.OS!=="android")return"on_device";try{let{installedLocales:t}=await e.getSupportedLocales({}),n=ku(r);return(t??[]).some(e=>ku(e)===n)?"on_device":"network"}catch{return"network"}}function _u(){return t.Platform.OS!=="android"?true:Number(t.Platform.Version)>=zu}var zu=33;function Iu(e,t,r){return{lang:t,interimResults:true,continuous:_u(),maxAlternatives:1,addsPunctuation:true,requiresOnDeviceRecognition:e==="on_device",contextualStrings:r.slice(0,100),iosTaskHint:"dictation"}}var Pu=/* @__PURE__ */new Set(["not-allowed","no-speech","speech-timeout","aborted","interrupted"]),Eu=/* @__PURE__ */new Set(["busy","client","network","audio-capture","too-many-requests","unknown"]);function Mu(e){return Eu.has(e)}var Fu=600,Au=3;function Lu(e,t,r){if(Pu.has(r))return null;let n=Mu(r)?Fu:0;return r==="language-not-supported"&&ku(t)!==ku(Su)?{mode:"network",lang:Su,delayMs:n}:e==="on_device"?{mode:"network",lang:t,delayMs:n}:n>0?{mode:"network",lang:t,delayMs:n}:null}function Ou(e){return e==="not-allowed"?"permissionDenied":e==="no-speech"||e==="speech-timeout"?"noSpeech":"unavailable"}async function Vu(e){try{if((await e.getPermissionsAsync()).granted)return"granted"}catch{}try{return(await e.requestPermissionsAsync()).granted?"granted":"denied"}catch{return"error"}}var Du=55e3,Bu=3e3,Hu=1e3;function Wu(e){return Nu.has(e)||Mu(e)}var Nu=/* @__PURE__ */new Set(["no-speech","speech-timeout","aborted","interrupted"]),Uu=/* @__PURE__ */Object.freeze({committed:/* @__PURE__ */Object.freeze([]),interim:""});function $u(e){return e.replace(/\s+/g," ").trim()}function qu(e,t,r){let n=$u(t);return r?n?{committed:[...e.committed,n],interim:""}:{committed:e.committed,interim:""}:{committed:e.committed,interim:n}}function Gu(e){return $u([...e.committed,e.interim].join(" "))}function Ku(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 c(e){return!e.sawStart&&e.errorCode===null&&e.pendingRetry===null&&Gu(e.transcript)===""&&e.launchedAt-o<Hu}function d(e){return e.mode??"none"}function p(e,t){Qo(r(),"chat_dictation_completed",{mode:d(e),duration_ms:e.startedAt===null?0:Math.max(0,n()-e.startedAt),char_count:t.length})}function f(e,n){Qo(r(),"chat_dictation_failed",{mode:d(e),error:n}),t.onStatus("idle"),t.onError(n)}function h(e){if(a(e.token)===null)return;u(e);let r=Gu(e.transcript),n=e.errorCode;if(n!==null&&!(r&&Wu(n))){f(e,Ou(n));return}if(!r){f(e,"noSpeech");return}p(e,r),t.onStatus("idle")}function b(l){l.subscriptions=[e.addListener("start",()=>{a(l.token)!==null&&(l.sawStart=true,l.startedAt===null&&(l.startedAt=n()),Qo(r(),"chat_dictation_started",{mode:d(l)}),t.onStatus("listening"))}),e.addListener("result",e=>{if(a(l.token)===null)return;let r=e?.results?.[0]?.transcript??"";l.transcript=qu(l.transcript,r,e?.isFinal===true),t.onText(Gu(l.transcript))}),e.addListener("error",e=>{if(a(l.token)===null)return;let t=e?.error??"unknown";if(l.userStopped&&(t==="aborted"||Mu(t)))return;let r=Gu(l.transcript)==="",n=l.mode!==null&&!l.userStopped&&r&&l.retries<Au?Lu(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&&!c(l)){if(l.pendingRetry!==null){let e=l.pendingRetry;if(l.pendingRetry=null,l.retries+=1,l.lang=e.lang,e.delayMs<=0){g(l,e.mode);return}s(l),l.retryTimer=setTimeout(()=>{l.retryTimer=null,!(a(l.token)===null||l.userStopped)&&g(l,e.mode)},e.delayMs);return}h(l)}})]}function g(t,r){s(t),t.mode=r,t.sawStart=false,t.launchedAt=n(),t.transcript=Uu,t.errorCode=null,b(t);try{e.start(Iu(r,t.lang,t.phrases))}catch{t.errorCode="unknown",h(t)}}async function m(t){let r=await Vu(e);if(a(t.token)===null)return;if(r!=="granted"){u(t),f(t,r==="denied"?"permissionDenied":"unavailable");return}if(t.lang=await Ru(e,t.lang),a(t.token)===null)return;let n=await Tu(e,t.lang);a(t.token)!==null&&(t.autoStopTimer=setTimeout(()=>y(t),Du),g(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),Bu);try{e.stop()}catch{h(r)}}}return{start(e){if(i!==null)return;let r={token:++l,phrases:e,lang:Cu(),mode:null,retries:0,pendingRetry:null,userStopped:false,transcript:Uu,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=Gu(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 Yu({enabled:r,input:n,setInput:l,phrases:i,maxLength:o,telemetry:a}){let s=e.useSyncExternalStore(gu,bu,bu),u=e.useMemo(()=>r?vu():null,[r,s]),c=e.useMemo(()=>xu(u),[u]),[d,p]=e.useState("idle"),[f,h]=e.useState(null),[b,g]=e.useState(0),m=e.useRef(n);m.current=n;let y=e.useRef(l);y.current=l;let v=e.useRef(a);v.current=a;let x=e.useRef(""),w=e.useRef(o);w.current=o;let k=e.useRef(null);u!==null&&k.current?.mod!==u&&(k.current?.controller.cancel(),k.current={mod:u,controller:Ku(u,{onStatus:e=>{p(t=>e==="idle"&&t==="error"?t:e)},onText:e=>y.current(Go(x.current,e,w.current)),onError:e=>{h(e),p("error")}},()=>v.current)});let S=u===null?null:k.current?.controller??null,C=e.useCallback(()=>{S?.cancel()},[S]),j=e.useCallback(()=>{if(S!==null){if(S.isActive()){S.stop();return}h(null),g(0),x.current=m.current,S.start(i)}},[S,i]);e.useEffect(()=>{if(d!=="listening")return;let e=Date.now();g(0);let t=setInterval(()=>g(Date.now()-e),1e3);return()=>clearInterval(t)},[d]),e.useEffect(()=>{if(d!=="error")return;let e=setTimeout(()=>{h(null),p("idle")},qo);return()=>clearTimeout(e)},[d]),e.useEffect(()=>{if(S===null)return;let e=null;try{e=t.AppState.addEventListener("change",e=>{e==="background"&&!S.isPreparing()&&S.cancel()})}catch{}return()=>{e?.remove(),S.cancel()}},[S]);let R=r&&c;return e.useEffect(()=>{R||S?.cancel()},[R,S]),{supported:R,status:d,active:d==="starting"||d==="listening",error:f,elapsedMs:b,toggle:j,cancel:C}}var Qu=/* @__PURE__ */Symbol.for("everfur.sdk.rn.chatPaneShown");function Zu(){let t=globalThis,r=t[Qu];if(r!==void 0)return r;let n=e.createContext(true);return t[Qu]=n,n}var Ju=Zu();function Xu(){return e.useContext(Ju)}var ec=/* @__PURE__ */Object.freeze(["photo"]),tc=52,rc=1.5,nc=10,lc=14,ic=10,oc=40,ac=20,sc=.3,uc=2.5,cc=1,dc=1.5,pc=38,fc=22,hc=3;function bc(e,t,r,n="ask",l=false){let i=typeof t=="string"&&t.trim()!=="";return r&&i&&n!=="urgent"?de(se.placeholder,t):e!==null?!l||!e.includes("{pet}")?e:i?e.split("{pet}").join(t.trim()):de(se.placeholder,t):n==="urgent"?se.placeholderUrgentWeb:n==="followUp"?se.placeholderFollowUpWeb:de(se.placeholder,t)}function ComposerWithAttachments({attachments:t,...n}){let l=e.useMemo(()=>createRnChatAttachmentTransport(),[]),i=useChatAttachments({maxPerMessage:t.maxPerMessage??zo,transport:l}),o=e.useMemo(()=>({state:i,sources:t.sources??ec,pick:t.pick}),[i,t.sources,t.pick]);/* @__PURE__ */
|
|
110
|
+
return r.jsx(Composer,{...n,attachments:o})}function Composer({send:n,stop:l,isStreaming:i,conversationId:conversationId,attachments:o,seed:a,draftStore:s,onStage:u,onPreview:c,petName:d,petBreed:p=null,mood:f="ask",dictation:h=false,telemetry:b=null,compact:g=false,petPlaceholder:m=false,dimEmptySend:y=false}){let{theme:v,styles:x}=tu(),w=e.useMemo(()=>wc(v),[v]),k=e.useMemo(()=>kc(v),[v]),S=Ni(),[C,j]=Xo(n,conversationId,a),[R,T]=e.useState(false),[_,z]=e.useState(false),I=e.useCallback(()=>z(true),[]),P=e.useCallback(()=>z(false),[]),[E,M]=e.useState(false);e.useEffect(()=>{M(false)},[conversationId]);let F=bc(v.meta.placeholder,d,m,f,v.meta.placeholderFillsPet===true),A=e.useMemo(()=>Jo({name:d,breed:p}),[d,p]),L=Yu({enabled:h,input:C,setInput:j,phrases:A,maxLength:Ro,telemetry:b}),O=L.cancel,V=L.active;ea(s,conversationId===null?null:String(conversationId),C,j,V);let D=e.useRef(conversationId);e.useEffect(()=>{D.current!==conversationId&&(D.current=conversationId,O())},[conversationId,O]);let H=Xu();e.useEffect(()=>{H||O()},[H,O]);let W=o?.state.uploading??false,N=o?.state.failed??false,U=W||N,$=o?.state.attachments??gc;oo($.length,S);let q=e.useCallback(()=>{let e=C.trim();if(e.length===0||U||[...e].length>Ro)return;V&&O();let t=o?.state.s3Keys??mc;o!==null&&t.length>0?(u(o.state.attachments.filter(e=>e.status==="uploaded").map(e=>({uri:e.previewUri,filename:e.filename}))),n(e,{imageS3Keys:t}),o.state.clear()):n(e),j(""),M(false)},[C,n,U,V,O,o,u]),G=e.useCallback(e=>{V&&O(),j(e)},[V,O,j]),K=e.useCallback(()=>{l()},[l]),Y=e.useCallback(e=>{T(false),o!==null&&(M(false),o.state.dismissRejected(),yr(o.pick,e).then(e=>{if(!e.ok){M(true);return}e.value!==null&&o.state.add(e.value)}))},[o]),Q=e.useMemo(()=>[...C.trim()].length>Ro,[C]),Z=Q||U||C.trim().length===0,J=Q||U||y&&C.trim().length===0,X=o!==null&&$.length>=o.state.maxPerMessage,ee=v.slots.sendButton?.textColor??v.color.brandInk,te=v.slots.sendButton?.textColor??v.color.surface;/* @__PURE__ */
|
|
111
|
+
return r.jsxs(t.View,{style:x.composerOuter,children:[o!==null&&R?/* @__PURE__ */r.jsx(AttachmentPickerPopover,{sources:o.sources,full:X,onPick:Y,onClose:()=>T(false)}):null,o!==null?/* @__PURE__ */r.jsx(AttachmentStrip,{attachments:$,rejected:E?xc:o.state.rejected,uploadFailed:N,onRetry:o.state.retry,onRemove:o.state.remove,onPreview:e=>c({uri:e.previewUri,label:e.filename}),style:g?w.tray:k.tray}):null,
|
|
112
112
|
/* @__PURE__ */r.jsxs(t.View,{style:g?[x.composer,w.bar,_?w.barFocused:null]:x.composer,children:[L.supported&&L.error!==null?/* @__PURE__ */r.jsxs(r.Fragment,{children:[
|
|
113
|
-
/* @__PURE__ */r.jsx(Text,{style:x.dictationError,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:
|
|
114
|
-
/* @__PURE__ */r.jsx(AnnounceLine,{line:
|
|
115
|
-
/* @__PURE__ */r.jsxs(t.View,{style:x.composerRow,children:[o!==null?/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:"button",accessibilityLabel:X?
|
|
116
|
-
/* @__PURE__ */r.jsx(B,{style:g?[x.input,w.input]:x.input,onFocus:I,onBlur:P,value:C,onChangeText:G,placeholder:F,placeholderTextColor:v.slots.composerInput?.textColor??v.color.text.placeholder,accessibilityLabel:se.composerLabel,onSubmitEditing:q,returnKeyType:"send",...bc,...g?gc:null,blurOnSubmit:false,multiline:true,editable:true}),L.supported?/* @__PURE__ */r.jsx(DictationButton,{active:L.active,listening:L.status==="listening",elapsedMs:L.elapsedMs,onToggle:L.toggle}):null,i?/* @__PURE__ */r.jsx(t.Pressable,{onPress:K,accessibilityRole:"button",accessibilityLabel:se.stop,style:x.sendControl,children:/* @__PURE__ */r.jsx(t.View,{style:g?w.disc:x.sendDisc,testID:"everfur-stop-disc",children:/* @__PURE__ */r.jsx(StopGlyph,{size:g?lc:Rs,color:g?te:ee,testID:"everfur-stop-glyph"})})}):/* @__PURE__ */r.jsx(t.Pressable,{onPress:q,disabled:Z,accessibilityRole:"button",accessibilityLabel:se.send,accessibilityState:{disabled:Z,busy:W},style:[x.sendControl,J?g?w.dimmed:x.sendControlDisabled:null],children:g?/* @__PURE__ */r.jsx(t.View,{style:w.disc,testID:"everfur-send-disc",children:/* @__PURE__ */r.jsx(ArrowUpGlyph,{size:lc,color:te,strokeWidth:2.25,testID:"everfur-send-arrow"})}):/* @__PURE__ */r.jsx(t.View,{style:x.sendDisc,testID:"everfur-send-disc",children:/* @__PURE__ */r.jsx(SendGlyph,{size:js,color:ee,testID:"everfur-send-glyph"})})})]})]})]})}var fc=/* @__PURE__ */Object.freeze([]),hc=/* @__PURE__ */Object.freeze([]),bc=/* @__PURE__ */Object.freeze({submitBehavior:"submit"}),gc=/* @__PURE__ */Object.freeze(t.Platform.OS==="web"?{rows:1}:{}),mc=/* @__PURE__ */Object.freeze({code:"unknown",retryable:true,filename:""});function yc(e){let r=e.color,n=e.slots.sendButton,l=textRole(e,"body").fontSize+ac;return t.StyleSheet.create({bar:{marginTop:ec,marginHorizontal:tc,marginBottom:rc,minHeight:Ju,paddingLeft:8,paddingRight:6,paddingVertical:0,borderWidth:Xu,borderColor:e.slots.composerInput?.borderColor??r.text.primary},barFocused:{borderWidth:oc,paddingLeft:8-(oc-Xu),paddingRight:6-(oc-Xu)},input:{fontSize:l,lineHeight:Math.round(l*sc),minHeight:Math.round(l*sc),...t.Platform.OS==="web"?{outlineStyle:"none"}:null},add:{width:uc,height:uc,borderRadius:uc/2},disc:{width:nc,height:nc,borderRadius:nc/2,alignItems:"center",justifyContent:"center",backgroundColor:n?.backgroundColor??r.text.primary,...bo(n)},dimmed:{opacity:ic},tray:{marginHorizontal:tc,marginTop:ec,paddingBottom:0}})}function vc(e){return t.StyleSheet.create({tray:{marginHorizontal:e.space.md,marginTop:e.space.xs,paddingBottom:0}})}var xc=/* @__PURE__ */new WeakMap;function wc(e,t){let r=xc.get(e);return r===void 0&&(r=/* @__PURE__ */new Set,xc.set(e,r)),r.add(t),()=>{r?.delete(t)}}function useEverfurPets(){let{runtime:t,userRef:userRef,activePet:r,scopeEpoch:n}=me(),l=e.useMemo(()=>createPetsRepository(t.registry.services.authFor(userRef)),[t,userRef,n]),[i,o]=e.useState({repository:l,pets:[],loading:true,error:null}),a=i.repository===l?i:{pets:[],loading:true,error:null},s=e.useRef(0),u=e.useCallback(async()=>{let e=++s.current;o(e=>({...e,repository:l,loading:true,error:null,pets:e.repository===l?e.pets:[]}));let t=await l.list();e===s.current&&o(t.ok?{repository:l,pets:t.value,loading:false,error:null}:e=>({repository:l,pets:e.repository===l?e.pets:[],loading:false,error:t.error}))},[l]);e.useEffect(()=>(u(),()=>{s.current+=1}),[u]),e.useEffect(()=>wc(t,()=>{u()}),[t,u]);let c=e.useMemo(()=>r===null?null:a.pets.find(e=>e.petRef===r)??null,[r,a.pets]);return e.useMemo(()=>({pets:a.pets,activePet:c,loading:a.loading,error:a.error,refresh:u}),[a.pets,a.loading,a.error,c,u])}function kc(e,t){if(t!==null){let r=e.find(e=>e.petRef===t);if(r!==void 0)return r}return e[0]??null}var Sc=/* @__PURE__ */Object.freeze({visitButton:"Vet"});var Cc=/* @__PURE__ */Symbol.for("@everfur/sdk/televet");function jc(){let e=globalThis,t=e[Cc];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[Cc]=r,r}function Rc(e){let t=jc();t.snapshot=/* @__PURE__ */Object.freeze({...t.snapshot,...e});for(let e of[...t.listeners])try{e()}catch{}}function Tc(e){let t=jc().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 _c(){return jc().hosts.length>0}function zc(e){if(!_c())return false;let t=/* @__PURE__ */Object.freeze({...e});return Rc({request:t,serial:jc().snapshot.serial+1}),true}var Ic=false;function Pc(e,t){return t!==void 0?(br(t,e),"onStartInApp"):Tc(e)==="presented"?"presenter":zc(e)?"experience":(Ic||(Ic=true,console.warn("[everfur] A vet visit had nowhere to open: mount <EverfurTelevetHost /> in your EverfurProvider, or pass prefer: 'redirect'.")),null)}var Ec=e.createContext(null);function TelevetHostOutlet(){let t=e.useContext(Ec);return t===null?null:/* @__PURE__ */r.jsx(t,{})}var Mc=/* @__PURE__ */Object.freeze(["visit","join","summary","messages"]);function isVetVisitIntent(e){return typeof e=="string"&&Mc.includes(e)}var Fc="/widget/v1/televet/handoffs",Ac="/widget/v1/televet/availability",Lc="/widget/v1/televet/chat-entry",Oc=/^[a-z0-9][a-z0-9_-]{0,39}$/,Vc=/^[A-Za-z0-9_-]{22}$/;var Dc=32,Bc=128,Hc=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 Wc(e){return err(makeEverfurError("validationFailed",{retryable:false,wireMessage:e}))}function Nc(e){return err(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}function Uc(petRef,e){let t={};petRef!==void 0&&(t.pet_ref=petRef);let r=e?.returnTo;if(r!=null){if(typeof r!="string"||!Oc.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>Hc)return{ok:false,message:`visitRef must be 1..${Hc} 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 $c(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 qc(e){let t=e.funnel??createRequestFunnel({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e.telemetry,n=e=>(Jc(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>Bc)return n(makeEverfurError("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${Bc} characters`}));l=petRef}let i=Uc(l,e);if(!i.ok){let e=Wc(i.message);return e.ok?e:n(e.error)}let o=i.body,a=await t.send("televet.visit.handoff",{method:"POST",path:Fc,body:o},{idempotent:false,maxAttempts:1});if(!a.ok)return n(a.error);let s=Gc(a.value),u=o.return_to!==void 0,c=u?a.value?.flow_id:void 0;if(u&&(typeof c!="string"||!Vc.test(c))){let e=Nc("the handoff response carried no usable return flow id");return e.ok?e:n(e.error)}let d=o.visit_ref!==void 0,p=d?$c(a.value?.visit):null;if(d&&p===null){let e=Nc("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:c}:{},...p!==null?{visit:p}:{}});return f===null?n(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(Jc(r,"televet.visit.handoff_created",{pet_scoped:o.pet_ref!==void 0}),ok(f))},async checkAvailability(e){if(typeof e!="string"||e.length>Dc)return Wc(`state must be at most ${Dc} characters`);let r=await t.send("televet.visit.availability",{method:"POST",path:Ac,body:{state:e}},{idempotent:false,maxAttempts:1});if(!r.ok)return err(r.error);let n=r.value?.available;return typeof n!="boolean"?Nc("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:Lc},{maxAttempts:1});return e.ok&&e.value?.open===!0}catch{return false}}}}function Gc(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||!Zc(t)?null:/* @__PURE__ */Object.freeze({url:t,expiresAt:r})}var Kc=/* @__PURE__ */new Set(["localhost","127.0.0.1","[::1]"]),Yc=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,Qc=/[\s\u0000-\u001f\u007f]/;function Zc(e){if(Qc.test(e))return false;let t=Yc.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"&&Kc.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 Jc(e,t,r){if(e)try{e.track(t,r)}catch{}}var Xc=/* @__PURE__ */Object.freeze({status:"idle",error:null,errorReason:null});function ed(t,r,n){let{usState:l,chat:i,scope:o}=n,a=r&&(l!==null||i),s=`${l??""}|${i?"chat":""}`,[u,c]=e.useState(null);if(e.useEffect(()=>{if(!a)return;let e=true,r=t.current;return c(null),(async()=>{try{if(i&&!(r.chatEntryOpen&&await r.chatEntryOpen()))return!1;if(l===null)return!0;if(!r.checkAvailability)return!1;let e=await r.checkAvailability(l);return e.ok&&e.value.available}catch{return false}})().then(t=>{e&&c({key:s,open:t})}),()=>{e=false}},[a,s,l,i,o,t]),!a)return null;let d=u!==null&&u.key===s;return{open:d&&u.open,pending:!d}}var td=/* @__PURE__ */Object.freeze({status:"opening",error:null,errorReason:null});function rd(t,r={}){let{runtime:n,userRef:userRef,scopeEpoch:l}=me(),i=useCapability("televet"),o=i.enabled&&userRef!==null,a=r.usState??null,s=r.entry==="chat",u=r.petRef??null,c=r.prefer==="redirect",d=e.useMemo(()=>{if(r.controller)return r.controller;let{services:e}=n.registry;return qc({auth:e.authFor(userRef),telemetry:e.telemetry,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}})},[n,userRef,l,r.controller]),p=e.useRef(d);p.current=d;let f=e.useMemo(()=>({runtime:n,userRef:userRef,scopeEpoch:l}),[n,userRef,l]),h=ed(p,o,{usState:a,chat:s,scope:f}),b=o&&(h===null||h.open)&&(!s||u!==null),g=r.returnTo??null,[m,y]=e.useState(Xc),v=e.useRef(null),x=e.useRef({runtime:n,userRef:userRef,scopeEpoch:l});x.current={runtime:n,userRef:userRef,scopeEpoch:l};let w=e.useRef(d);w.current=d;let k=e.useRef(b);k.current=b;let S=e.useCallback((petRef,e)=>{if(v.current)return v.current;let r=(e,t)=>(y({status:e==="cancelled"?"idle":"error",error:t,errorReason:e==="cancelled"?null:e}),/* @__PURE__ */Object.freeze({opened:false,reason:e,error:t}));if(!k.current)return Promise.resolve(r("unavailable",null));let n=t.prepare();if(!n.ok)return Promise.resolve(r(n.reason,null));let l=x.current,i=w.current;y(td);let o=(async()=>{let o,a={...g!==null?{returnTo:g}:{},...s?{entry:"chat"}:{},...e!==null?{visitRef:e.visitRef}:{},...e!==null&&e.intent!==null&&e.intent!==void 0?{intent:e.intent}:{}},c=Object.keys(a).length===0?void 0:a,d=petRef===void 0?u:petRef;try{o=await(c===void 0?i.createHandoff(d):i.createHandoff(d,c))}catch{return t.abandon(n.value),r("unknown",null)}let p=x.current;if(p.runtime!==l.runtime||p.userRef!==l.userRef||p.scopeEpoch!==l.scopeEpoch)return t.abandon(n.value),r("cancelled",null);if(!o.ok)return t.abandon(n.value),r(vetVisitErrorReasonOf(o.error),o.error);let f=await t.finish(n.value,o.value);return f!==null?r(f,null):(y(Xc),/* @__PURE__ */Object.freeze(o.value.flowId===void 0?{opened:true}:{opened:true,flowId:o.value.flowId}))})().finally(()=>{v.current===o&&(v.current=null)});return v.current=o,o},[t,u,g,s]),C=e.useCallback((petRef,e)=>{if(!k.current)return y({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}));let t=petRef===void 0?u:petRef,r={...t!==null?{petRef:t}:{},...a!==null?{usState:a}:{},...e!==null&&"consultId"in e?{consultId:e.consultId}:{},...e!==null&&"visitRef"in e?{visitRef:e.visitRef,intent:e.intent}:{}};return Pc(r)===null?(y({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}))):(y(Xc),Promise.resolve(/* @__PURE__ */Object.freeze({opened:true})))},[u,a]),j=e.useCallback(petRef=>c?S(petRef,null):C(petRef,null),[c,S,C]),R=e.useCallback((e,t)=>c?S(void 0,{visitRef:e,intent:t??null}):C(void 0,{visitRef:e,intent:t??null}),[c,S,C]),T=e.useCallback(e=>c?S(void 0,null):C(void 0,{consultId:e.trim()}),[c,S,C]);return{available:b,isPending:i.isPending||(h?.pending??false),status:m.status,error:m.error,errorReason:m.errorReason,open:j,openVisit:R,joinVisit:T}}var nd=e=>t.Linking.openURL(e);function useVetVisit(t={}){let{openUrl:r,...n}=t,l=e.useMemo(()=>{let e=r??nd;return{prepare:()=>({ok:true,value:null}),async finish(t,r){try{return await e(r.url),null}catch{return"openFailed"}},abandon:()=>{}}},[r]);return rd(l,n)}var ld=44,id=.6;function VetVisitButtonCore(n){let{petRef:petRef,label:l,openUrl:i,onOpened:o,onError:a,style:s,labelStyle:u,controller:c,returnTo:d,usState:p,entry:f,visitRef:h,intent:b,onStartInApp:g,prefer:m}=n,y=m==="redirect",v=useVetVisit({...d!==void 0?{returnTo:d}:{},...p!==void 0?{usState:p}:{},...f!==void 0?{entry:f}:{},...petRef!==void 0?{petRef:petRef}:{},...i!==void 0?{openUrl:i}:{},...c!==void 0?{controller:c}:{},prefer:y?"redirect":"in-app"}),x=useEverfurTheme(),w=e.useMemo(()=>od(x),[x]),k=e.useRef(false);if(!v.available)/* @__PURE__ */
|
|
113
|
+
/* @__PURE__ */r.jsx(Text,{style:x.dictationError,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:Yo(L.error)}),
|
|
114
|
+
/* @__PURE__ */r.jsx(AnnounceLine,{line:Yo(L.error)})]}):null,
|
|
115
|
+
/* @__PURE__ */r.jsxs(t.View,{style:x.composerRow,children:[o!==null?/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:"button",accessibilityLabel:X?Uo($.length,o.state.maxPerMessage):se.attachPhotoOrFileNative,accessibilityState:{disabled:X,expanded:R},disabled:X,style:[x.attachControl,g?w.add:null,X?x.attachControlDisabled:null],hitSlop:g?hc:void 0,onPress:()=>T(e=>!e),children:/* @__PURE__ */r.jsx(UploadGlyph,{size:g?fc:Es,color:X?v.color.text.muted:g?v.color.text.primary:v.color.brandInk,strokeWidth:1.75})}):null,
|
|
116
|
+
/* @__PURE__ */r.jsx(B,{style:g?[x.input,w.input]:x.input,onFocus:I,onBlur:P,value:C,onChangeText:G,placeholder:F,placeholderTextColor:v.slots.composerInput?.textColor??v.color.text.placeholder,accessibilityLabel:se.composerLabel,onSubmitEditing:q,returnKeyType:"send",...yc,...g?vc:null,blurOnSubmit:false,multiline:true,editable:true}),L.supported?/* @__PURE__ */r.jsx(DictationButton,{active:L.active,listening:L.status==="listening",elapsedMs:L.elapsedMs,onToggle:L.toggle}):null,i?/* @__PURE__ */r.jsx(t.Pressable,{onPress:K,accessibilityRole:"button",accessibilityLabel:se.stop,style:x.sendControl,children:/* @__PURE__ */r.jsx(t.View,{style:g?w.disc:x.sendDisc,testID:"everfur-stop-disc",children:/* @__PURE__ */r.jsx(StopGlyph,{size:g?ac:zs,color:g?te:ee,testID:"everfur-stop-glyph"})})}):/* @__PURE__ */r.jsx(t.Pressable,{onPress:q,disabled:Z,accessibilityRole:"button",accessibilityLabel:se.send,accessibilityState:{disabled:Z,busy:W},style:[x.sendControl,J?g?w.dimmed:x.sendControlDisabled:null],children:g?/* @__PURE__ */r.jsx(t.View,{style:w.disc,testID:"everfur-send-disc",children:/* @__PURE__ */r.jsx(ArrowUpGlyph,{size:ac,color:te,strokeWidth:2.25,testID:"everfur-send-arrow"})}):/* @__PURE__ */r.jsx(t.View,{style:x.sendDisc,testID:"everfur-send-disc",children:/* @__PURE__ */r.jsx(SendGlyph,{size:_s,color:ee,testID:"everfur-send-glyph"})})})]})]})]})}var gc=/* @__PURE__ */Object.freeze([]),mc=/* @__PURE__ */Object.freeze([]),yc=/* @__PURE__ */Object.freeze({submitBehavior:"submit"}),vc=/* @__PURE__ */Object.freeze(t.Platform.OS==="web"?{rows:1}:{}),xc=/* @__PURE__ */Object.freeze({code:"unknown",retryable:true,filename:""});function wc(e){let r=e.color,n=e.slots.sendButton,l=textRole(e,"body").fontSize+cc;return t.StyleSheet.create({bar:{marginTop:nc,marginHorizontal:lc,marginBottom:ic,minHeight:tc,paddingLeft:8,paddingRight:6,paddingVertical:0,borderWidth:rc,borderColor:e.slots.composerInput?.borderColor??r.text.primary},barFocused:{borderWidth:uc,paddingLeft:8-(uc-rc),paddingRight:6-(uc-rc)},input:{fontSize:l,lineHeight:Math.round(l*dc),minHeight:Math.round(l*dc),...t.Platform.OS==="web"?{outlineStyle:"none"}:null},add:{width:pc,height:pc,borderRadius:pc/2},disc:{width:oc,height:oc,borderRadius:oc/2,alignItems:"center",justifyContent:"center",backgroundColor:n?.backgroundColor??r.text.primary,...yo(n)},dimmed:{opacity:sc},tray:{marginHorizontal:lc,marginTop:nc,paddingBottom:0}})}function kc(e){return t.StyleSheet.create({tray:{marginHorizontal:e.space.md,marginTop:e.space.xs,paddingBottom:0}})}var Sc=/* @__PURE__ */new WeakMap;function Cc(e,t){let r=Sc.get(e);return r===void 0&&(r=/* @__PURE__ */new Set,Sc.set(e,r)),r.add(t),()=>{r?.delete(t)}}function useEverfurPets(){let{runtime:t,userRef:userRef,activePet:r,scopeEpoch:n}=me(),l=e.useMemo(()=>createPetsRepository(t.registry.services.authFor(userRef)),[t,userRef,n]),[i,o]=e.useState({repository:l,pets:[],loading:true,error:null}),a=i.repository===l?i:{pets:[],loading:true,error:null},s=e.useRef(0),u=e.useCallback(async()=>{let e=++s.current;o(e=>({...e,repository:l,loading:true,error:null,pets:e.repository===l?e.pets:[]}));let t=await l.list();e===s.current&&o(t.ok?{repository:l,pets:t.value,loading:false,error:null}:e=>({repository:l,pets:e.repository===l?e.pets:[],loading:false,error:t.error}))},[l]);e.useEffect(()=>(u(),()=>{s.current+=1}),[u]),e.useEffect(()=>Cc(t,()=>{u()}),[t,u]);let c=e.useMemo(()=>r===null?null:a.pets.find(e=>e.petRef===r)??null,[r,a.pets]);return e.useMemo(()=>({pets:a.pets,activePet:c,loading:a.loading,error:a.error,refresh:u}),[a.pets,a.loading,a.error,c,u])}function jc(e,t){if(t!==null){let r=e.find(e=>e.petRef===t);if(r!==void 0)return r}return e[0]??null}var Rc=/* @__PURE__ */Object.freeze({visitButton:"Vet"});var Tc=/* @__PURE__ */Symbol.for("@everfur/sdk/televet");function _c(){let e=globalThis,t=e[Tc];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[Tc]=r,r}function zc(e){let t=_c();t.snapshot=/* @__PURE__ */Object.freeze({...t.snapshot,...e});for(let e of[...t.listeners])try{e()}catch{}}function Ic(e){let t=_c().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 Pc(){return _c().hosts.length>0}function Ec(e){if(!Pc())return false;let t=/* @__PURE__ */Object.freeze({...e});return zc({request:t,serial:_c().snapshot.serial+1}),true}var Mc=false;function Fc(e,t){return t!==void 0?(br(t,e),"onStartInApp"):Ic(e)==="presented"?"presenter":Ec(e)?"experience":(Mc||(Mc=true,console.warn("[everfur] A vet visit had nowhere to open: mount <EverfurTelevetHost /> in your EverfurProvider, or pass prefer: 'redirect'.")),null)}var Ac=e.createContext(null);function TelevetHostOutlet(){let t=e.useContext(Ac);return t===null?null:/* @__PURE__ */r.jsx(t,{})}var Lc=/* @__PURE__ */Object.freeze(["visit","join","summary","messages"]);function isVetVisitIntent(e){return typeof e=="string"&&Lc.includes(e)}var Oc="/widget/v1/televet/handoffs",Vc="/widget/v1/televet/availability",Dc="/widget/v1/televet/chat-entry",Bc=/^[a-z0-9][a-z0-9_-]{0,39}$/,Hc=/^[A-Za-z0-9_-]{22}$/;var Wc=32,Nc=128,Uc=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 qc(e){return err(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}function Gc(petRef,e){let t={};petRef!==void 0&&(t.pet_ref=petRef);let r=e?.returnTo;if(r!=null){if(typeof r!="string"||!Bc.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>Uc)return{ok:false,message:`visitRef must be 1..${Uc} 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 ${Lc.join(", ")}`};t.intent=i}return{ok:true,body:t}}function Kc(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 Yc(e){let t=e.funnel??createRequestFunnel({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e.telemetry,n=e=>(td(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>Nc)return n(makeEverfurError("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${Nc} characters`}));l=petRef}let i=Gc(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:Oc,body:o},{idempotent:false,maxAttempts:1});if(!a.ok)return n(a.error);let s=Qc(a.value),u=o.return_to!==void 0,c=u?a.value?.flow_id:void 0;if(u&&(typeof c!="string"||!Hc.test(c))){let e=qc("the handoff response carried no usable return flow id");return e.ok?e:n(e.error)}let d=o.visit_ref!==void 0,p=d?Kc(a.value?.visit):null;if(d&&p===null){let e=qc("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:c}:{},...p!==null?{visit:p}:{}});return f===null?n(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(td(r,"televet.visit.handoff_created",{pet_scoped:o.pet_ref!==void 0}),ok(f))},async checkAvailability(e){if(typeof e!="string"||e.length>Wc)return $c(`state must be at most ${Wc} characters`);let r=await t.send("televet.visit.availability",{method:"POST",path:Vc,body:{state:e}},{idempotent:false,maxAttempts:1});if(!r.ok)return err(r.error);let n=r.value?.available;return typeof n!="boolean"?qc("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:Dc},{maxAttempts:1});return e.ok&&e.value?.open===!0}catch{return false}}}}function Qc(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||!ed(t)?null:/* @__PURE__ */Object.freeze({url:t,expiresAt:r})}var Zc=/* @__PURE__ */new Set(["localhost","127.0.0.1","[::1]"]),Jc=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,Xc=/[\s\u0000-\u001f\u007f]/;function ed(e){if(Xc.test(e))return false;let t=Jc.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"&&Zc.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 td(e,t,r){if(e)try{e.track(t,r)}catch{}}var rd=/* @__PURE__ */Object.freeze({status:"idle",error:null,errorReason:null});function nd(t,r,n){let{usState:l,chat:i,scope:o}=n,a=r&&(l!==null||i),s=`${l??""}|${i?"chat":""}`,[u,c]=e.useState(null);if(e.useEffect(()=>{if(!a)return;let e=true,r=t.current;return c(null),(async()=>{try{if(i&&!(r.chatEntryOpen&&await r.chatEntryOpen()))return!1;if(l===null)return!0;if(!r.checkAvailability)return!1;let e=await r.checkAvailability(l);return e.ok&&e.value.available}catch{return false}})().then(t=>{e&&c({key:s,open:t})}),()=>{e=false}},[a,s,l,i,o,t]),!a)return null;let d=u!==null&&u.key===s;return{open:d&&u.open,pending:!d}}var ld=/* @__PURE__ */Object.freeze({status:"opening",error:null,errorReason:null});function id(t,r={}){let{runtime:n,userRef:userRef,scopeEpoch:l}=me(),i=useCapability("televet"),o=i.enabled&&userRef!==null,a=r.usState??null,s=r.entry==="chat",u=r.petRef??null,c=r.prefer==="redirect",d=e.useMemo(()=>{if(r.controller)return r.controller;let{services:e}=n.registry;return Yc({auth:e.authFor(userRef),telemetry:e.telemetry,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}})},[n,userRef,l,r.controller]),p=e.useRef(d);p.current=d;let f=e.useMemo(()=>({runtime:n,userRef:userRef,scopeEpoch:l}),[n,userRef,l]),h=nd(p,o,{usState:a,chat:s,scope:f}),b=o&&(h===null||h.open)&&(!s||u!==null),g=r.returnTo??null,[m,y]=e.useState(rd),v=e.useRef(null),x=e.useRef({runtime:n,userRef:userRef,scopeEpoch:l});x.current={runtime:n,userRef:userRef,scopeEpoch:l};let w=e.useRef(d);w.current=d;let k=e.useRef(b);k.current=b;let S=e.useCallback((petRef,e)=>{if(v.current)return v.current;let r=(e,t)=>(y({status:e==="cancelled"?"idle":"error",error:t,errorReason:e==="cancelled"?null:e}),/* @__PURE__ */Object.freeze({opened:false,reason:e,error:t}));if(!k.current)return Promise.resolve(r("unavailable",null));let n=t.prepare();if(!n.ok)return Promise.resolve(r(n.reason,null));let l=x.current,i=w.current;y(ld);let o=(async()=>{let o,a={...g!==null?{returnTo:g}:{},...s?{entry:"chat"}:{},...e!==null?{visitRef:e.visitRef}:{},...e!==null&&e.intent!==null&&e.intent!==void 0?{intent:e.intent}:{}},c=Object.keys(a).length===0?void 0:a,d=petRef===void 0?u:petRef;try{o=await(c===void 0?i.createHandoff(d):i.createHandoff(d,c))}catch{return t.abandon(n.value),r("unknown",null)}let p=x.current;if(p.runtime!==l.runtime||p.userRef!==l.userRef||p.scopeEpoch!==l.scopeEpoch)return t.abandon(n.value),r("cancelled",null);if(!o.ok)return t.abandon(n.value),r(vetVisitErrorReasonOf(o.error),o.error);let f=await t.finish(n.value,o.value);return f!==null?r(f,null):(y(rd),/* @__PURE__ */Object.freeze(o.value.flowId===void 0?{opened:true}:{opened:true,flowId:o.value.flowId}))})().finally(()=>{v.current===o&&(v.current=null)});return v.current=o,o},[t,u,g,s]),C=e.useCallback((petRef,e)=>{if(!k.current)return y({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}));let t=petRef===void 0?u:petRef,r={...t!==null?{petRef:t}:{},...a!==null?{usState:a}:{},...e!==null&&"consultId"in e?{consultId:e.consultId}:{},...e!==null&&"visitRef"in e?{visitRef:e.visitRef,intent:e.intent}:{}};return Fc(r)===null?(y({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}))):(y(rd),Promise.resolve(/* @__PURE__ */Object.freeze({opened:true})))},[u,a]),j=e.useCallback(petRef=>c?S(petRef,null):C(petRef,null),[c,S,C]),R=e.useCallback((e,t)=>c?S(void 0,{visitRef:e,intent:t??null}):C(void 0,{visitRef:e,intent:t??null}),[c,S,C]),T=e.useCallback(e=>c?S(void 0,null):C(void 0,{consultId:e.trim()}),[c,S,C]);return{available:b,isPending:i.isPending||(h?.pending??false),status:m.status,error:m.error,errorReason:m.errorReason,open:j,openVisit:R,joinVisit:T}}var od=e=>t.Linking.openURL(e);function useVetVisit(t={}){let{openUrl:r,...n}=t,l=e.useMemo(()=>{let e=r??od;return{prepare:()=>({ok:true,value:null}),async finish(t,r){try{return await e(r.url),null}catch{return"openFailed"}},abandon:()=>{}}},[r]);return id(l,n)}var ad=44,sd=.6;function VetVisitButtonCore(n){let{petRef:petRef,label:l,openUrl:i,onOpened:o,onError:a,style:s,labelStyle:u,controller:c,returnTo:d,usState:p,entry:f,visitRef:h,intent:b,onStartInApp:g,prefer:m}=n,y=m==="redirect",v=useVetVisit({...d!==void 0?{returnTo:d}:{},...p!==void 0?{usState:p}:{},...f!==void 0?{entry:f}:{},...petRef!==void 0?{petRef:petRef}:{},...i!==void 0?{openUrl:i}:{},...c!==void 0?{controller:c}:{},prefer:y?"redirect":"in-app"}),x=useEverfurTheme(),w=e.useMemo(()=>ud(x),[x]),k=e.useRef(false);if(!v.available)/* @__PURE__ */
|
|
117
117
|
return r.jsxs(r.Fragment,{children:[null,
|
|
118
|
-
/* @__PURE__ */r.jsx(TelevetHostOutlet,{})]});let S=v.status==="opening",C=l??
|
|
118
|
+
/* @__PURE__ */r.jsx(TelevetHostOutlet,{})]});let S=v.status==="opening",C=l??Rc.visitButton;/* @__PURE__ */
|
|
119
119
|
return r.jsxs(r.Fragment,{children:[
|
|
120
|
-
/* @__PURE__ */r.jsx(t.Pressable,{onPress:()=>{if(!(S||k.current)){if(!y){let e={...petRef!==void 0?{petRef:petRef}:{},...p!==void 0?{usState:p}:{},...h!=null?{visitRef:h,intent:b??null}:{}};
|
|
121
|
-
/* @__PURE__ */r.jsx(TelevetHostOutlet,{})]})}function
|
|
122
|
-
return r.jsx(t.Image,{source:{uri:e},style:i,resizeMode:o,...d,onError:()=>{c.onError(),s?.()},...u===void 0?{}:{testID:u}})}function BrandLogo({logoUrl:e,name:n,barStyle:l,logoStyle:i,testID:o}){let a=
|
|
120
|
+
/* @__PURE__ */r.jsx(t.Pressable,{onPress:()=>{if(!(S||k.current)){if(!y){let e={...petRef!==void 0?{petRef:petRef}:{},...p!==void 0?{usState:p}:{},...h!=null?{visitRef:h,intent:b??null}:{}};Fc(e,g)===null&&br(a,"unavailable",null);return}k.current=true,(h==null?v.open():v.openVisit(h,b??null)).then(e=>{e.opened?br(o,e.flowId??null):e.reason!=="cancelled"&&br(a,e.reason,e.error)}).finally(()=>{k.current=false})}},accessibilityRole:"button",accessibilityLabel:C,accessibilityState:{busy:S,disabled:S},style:[w.button,S?w.busy:null,s],children:/* @__PURE__ */r.jsx(Text,{style:[w.label,u],children:C})}),
|
|
121
|
+
/* @__PURE__ */r.jsx(TelevetHostOutlet,{})]})}function ud(e){let{color:r,space:n,radius:l,type:i,slots:o}=e;return t.StyleSheet.create({button:{minHeight:ad,minWidth:ad,alignItems:"center",justifyContent:"center",paddingHorizontal:n.xl,paddingVertical:n.sm,borderRadius:l.pill,backgroundColor:r.primary,...yo(o.vetVisitButton)},busy:{opacity:sd},label:{...face(e,"medium"),color:r.onPrimary,fontSize:i.size.body,lineHeight:i.size.body*i.lineHeight.snug,...xo(o.vetVisitButton)}})}function cd(t){let[r,n]=e.useState(null);return{shown:t!==null&&r!==t,onError:()=>n(t)}}function BrandImage({uri:e,label:n,decorative:l=false,style:i,resizeMode:o="contain",fallback:a=null,onError:s,testID:u}){let c=cd(e);if(e===null||!c.shown)return a;let d=l?{accessible:false,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"}:{accessible:true,accessibilityRole:"image",...n===void 0?{}:{accessibilityLabel:n}};/* @__PURE__ */
|
|
122
|
+
return r.jsx(t.Image,{source:{uri:e},style:i,resizeMode:o,...d,onError:()=>{c.onError(),s?.()},...u===void 0?{}:{testID:u}})}function BrandLogo({logoUrl:e,name:n,barStyle:l,logoStyle:i,testID:o}){let a=cd(e);return e===null||!a.shown?null:/* @__PURE__ */r.jsx(t.View,{style:l,...o===void 0?{}:{testID:o},children:/* @__PURE__ */r.jsx(t.Image,{source:{uri:e},style:i,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:n,onError:a.onError})})}var dd=/* @__PURE__ */Object.freeze({row:null,leading:null,trailing:null}),pd=/* @__PURE__ */Object.freeze({leading:void 0,trailing:void 0});function fd(e,t,r){if(e.row===null||e.leading===null||e.trailing===null)return pd;let n=Math.abs(e.leading-e.trailing);if(n<.5)return pd;let l=e.row-t-e.leading-e.trailing,i=Math.min(n,Math.max(0,l-r));return i<.5?pd:e.leading<e.trailing?{leading:e.leading+i,trailing:void 0}:{leading:void 0,trailing:e.trailing+i}}function hd(e,t,r){let n=e[t];return n!==null&&Math.abs(n-r)<.5?e:{...e,[t]:r}}function bd(e){return[e.surface,e.surfaceCream,e.surfaceSubtle,e.background,e.chatGround,e.composerFill]}function gd(e){if(e.brightness!=="light")return false;let t=M.color,r=e.color,n=(e,t)=>parseColor(e)===parseColor(t),l=new Set(bd(t));return n(r.brand,t.brand)&&n(r.accent,t.accent)&&bd(r).every(e=>l.has(e))}function md(e){let t=(e.brightness==="dark"?A:M).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 yd(e){return canonicalPetSpecies(e)==="cat"?"cat":"dog"}function vd(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:Math.floor(e)}function xd(e){let t=vd(e.ageYears),r=yd(e.species)==="cat"?"Cat":"Dog";if(t==null)return r;let n=t===1?"1 yr":`${t} yrs`;return`${r} · ${n}`}var wd=/* @__PURE__ */Object.freeze([
|
|
123
123
|
/* @__PURE__ */Object.freeze({background:"#ffbdbd",foreground:"#6d1d14"}),
|
|
124
124
|
/* @__PURE__ */Object.freeze({background:"#a0c4f6",foreground:"#0b3a73"}),
|
|
125
125
|
/* @__PURE__ */Object.freeze({background:"#fbc558",foreground:"#10462e"}),
|
|
126
126
|
/* @__PURE__ */Object.freeze({background:"#bde7c5",foreground:"#0e3b22"}),
|
|
127
127
|
/* @__PURE__ */Object.freeze({background:"#dcc7f4",foreground:"#3a1d6a"}),
|
|
128
|
-
/* @__PURE__ */Object.freeze({background:"#ffd8a8",foreground:"#5a2a04"})]);function
|
|
129
|
-
return r.jsx(Ring,{size:l,strokeWidth:i,color:o.color.mark,children:/* @__PURE__ */r.jsx(t.View,{style:[a.disc,{width:s,height:s,borderRadius:s/2},u===null?a.discEmpty:{backgroundColor:u.background}],children:/* @__PURE__ */r.jsx(Text,{tier:"badge",style:[a.letter,{fontSize:c,lineHeight:Math.round(c*1.2),color:u===null?o.color.text.muted:u.foreground}],children:u===null?
|
|
130
|
-
/* @__PURE__ */r.jsx(t.Pressable,{style:
|
|
128
|
+
/* @__PURE__ */Object.freeze({background:"#ffd8a8",foreground:"#5a2a04"})]);function kd(e){let t=0;for(let r=0;r<e.length;r+=1)t=t*31+e.charCodeAt(r)>>>0;return wd[t%wd.length]}function Sd(e){let t=(e??"").trim();return(Array.from(t)[0]??"?").toUpperCase()}function Cd(e){return{...kd(e.petRef),initial:Sd(e.name)}}function jd(e,t,r){let n=Cd(e);return t?n:{background:r.fill,foreground:r.ink,initial:n.initial}}function Rd(e){return Math.max(12,Math.round(e*.42))}function PetDisc({pet:n,size:l,ringStroke:i}){let o=useEverfurTheme(),a=e.useMemo(()=>Td(o),[o]),s=l-i*2,u=n===null?null:jd(n,gd(o),{fill:o.color.highlight,ink:o.color.onHighlight}),c=Rd(s);/* @__PURE__ */
|
|
129
|
+
return r.jsx(Ring,{size:l,strokeWidth:i,color:o.color.mark,children:/* @__PURE__ */r.jsx(t.View,{style:[a.disc,{width:s,height:s,borderRadius:s/2},u===null?a.discEmpty:{backgroundColor:u.background}],children:/* @__PURE__ */r.jsx(Text,{tier:"badge",style:[a.letter,{fontSize:c,lineHeight:Math.round(c*1.2),color:u===null?o.color.text.muted:u.foreground}],children:u===null?Sd(null):u.initial})})})}function Td(e){return t.StyleSheet.create({disc:{alignItems:"center",justifyContent:"center",overflow:"hidden"},discEmpty:{backgroundColor:e.color.brandSoft},letter:{...face(e,"bold"),textAlign:"center",includeFontPadding:false}})}function _d(e,t){let{borderRadius:r,...n}=yo(e,t);return r===void 0?n:{...n,borderTopLeftRadius:r,borderTopRightRadius:r}}function zd(e,t){let{backgroundColor:r,borderColor:n,borderWidth:l,borderRadius:i}=yo(e,t);return{...r===void 0?{}:{backgroundColor:r},...n===void 0?{}:{borderRightColor:n,borderRightWidth:l??1},...i===void 0?{}:{borderTopRightRadius:i,borderBottomRightRadius:i}}}var Id=48,Pd=2,Ed=320,Md="80%",Fd="rgba(17,17,17,0.45)",Ad=18,Ld=22,Od=12,Vd=.4,Dd=44;function Bd(e){return e?.name?.trim()||se.yourPet}function PetSwitcherSheet({visible:n,pets:l,activePetRef:i,onSelect:o,onAddPet:a=null,onClose:s}){let u=useEverfurTheme(),c=e.useMemo(()=>Hd(u),[u]),d=K();return n?/* @__PURE__ */r.jsx(t.Modal,{visible:true,transparent:true,animationType:u.motion.reducedMotion?"none":"fade",onRequestClose:s,children:/* @__PURE__ */r.jsxs(t.View,{style:c.root,children:[
|
|
130
|
+
/* @__PURE__ */r.jsx(t.Pressable,{style:Fa,onPress:s,accessibilityRole:"button",accessibilityLabel:se.close,children:/* @__PURE__ */r.jsx(t.View,{style:c.backdrop})}),
|
|
131
131
|
/* @__PURE__ */r.jsxs(t.View,{style:Y(c.panel,d),accessibilityViewIsModal:true,children:[
|
|
132
132
|
/* @__PURE__ */r.jsx(Text,{tier:"heading",style:c.title,accessibilityRole:"header",children:se.yourPets}),
|
|
133
|
-
/* @__PURE__ */r.jsx(t.ScrollView,{style:c.list,contentContainerStyle:c.listContent,showsVerticalScrollIndicator:true,children:l.map(e=>{let n=e.petRef===i,l=
|
|
133
|
+
/* @__PURE__ */r.jsx(t.ScrollView,{style:c.list,contentContainerStyle:c.listContent,showsVerticalScrollIndicator:true,children:l.map(e=>{let n=e.petRef===i,l=Bd(e),a=xd(e);/* @__PURE__ */
|
|
134
134
|
return r.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:ue(n?se.petCurrentlyActive:se.switchToPet,{name:l}),accessibilityState:{selected:n},style:[c.row,n?c.rowActive:null],onPress:()=>o(e.petRef),children:[
|
|
135
|
-
/* @__PURE__ */r.jsx(PetDisc,{pet:e,size:
|
|
135
|
+
/* @__PURE__ */r.jsx(PetDisc,{pet:e,size:Id,ringStroke:Pd}),
|
|
136
136
|
/* @__PURE__ */r.jsxs(t.View,{style:c.copy,children:[
|
|
137
137
|
/* @__PURE__ */r.jsx(Text,{style:c.name,numberOfLines:1,children:l}),
|
|
138
|
-
/* @__PURE__ */r.jsx(Text,{tier:"compact",style:c.meta,numberOfLines:1,children:n?`${se.activePrefix}${a}`:a})]}),n?/* @__PURE__ */r.jsx(CheckGlyph,{size:
|
|
138
|
+
/* @__PURE__ */r.jsx(Text,{tier:"compact",style:c.meta,numberOfLines:1,children:n?`${se.activePrefix}${a}`:a})]}),n?/* @__PURE__ */r.jsx(CheckGlyph,{size:Ad,color:u.color.brandInk}):null]},e.petRef)})}),a!==null?/* @__PURE__ */r.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:se.addAnotherPet,style:c.addRow,onPress:a,children:[
|
|
139
139
|
/* @__PURE__ */r.jsx(t.View,{style:c.addDisc,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:c.addPlus,children:"+"})}),
|
|
140
140
|
/* @__PURE__ */r.jsx(Text,{style:c.addLabel,children:se.addAnotherPet})]}):null,
|
|
141
|
-
/* @__PURE__ */r.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:se.close,containerStyle:c.closeSlot,style:c.closeButton,onPress:s,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:c.closeText,children:se.close})})]})]})}):null}function
|
|
141
|
+
/* @__PURE__ */r.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:se.close,containerStyle:c.closeSlot,style:c.closeButton,onPress:s,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:c.closeText,children:se.close})})]})]})}):null}function Hd(e){let r=e.color,n=e.radius,l=xo(e.slots.dialog);return t.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{flex:1,backgroundColor:Fd},panel:{backgroundColor:r.surface,paddingHorizontal:20,paddingTop:20,paddingBottom:32,borderTopLeftRadius:Ld,borderTopRightRadius:Ld,gap:14,maxHeight:Md,..._d(e.slots.dialog)},title:{...headingFace(e,"bold"),fontSize:18,lineHeight:22,color:r.brandInk,...l},list:{maxHeight:Ed,flexShrink:1},listContent:{gap:10},addRow:{flexDirection:"row",alignItems:"center",gap:12,minHeight:Dd,paddingHorizontal:8},addDisc:{width:Id,height:Id,borderRadius:n.pill,alignItems:"center",justifyContent:"center",borderWidth:Pd,borderStyle:"dashed",borderColor:r.brandBorder,backgroundColor:r.surfaceCream},addPlus:{...face(e,"bold"),fontSize:20,lineHeight:22,color:r.brandInk},addLabel:{...face(e,"bold"),fontSize:15,lineHeight:20,color:r.text.primary,...l},row:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:n.md,borderWidth:1,borderColor:r.brandBorder,backgroundColor:r.surface},rowActive:{borderColor:r.brandInk,backgroundColor:r.brandSoft},copy:{flex:1,gap:2},name:{...face(e,"bold"),fontSize:15,lineHeight:18,color:r.text.primary},meta:{...face(e,"monoBold"),fontSize:11,lineHeight:13,color:r.text.muted,textTransform:"uppercase",letterSpacing:Vd},closeSlot:{alignSelf:"flex-end"},closeButton:{paddingHorizontal:18,paddingVertical:10,borderRadius:Od,backgroundColor:r.brandSoft},closeText:{...face(e,"bold"),color:r.brandInk,fontSize:13,lineHeight:16,letterSpacing:Vd}})}var Wd=44,Nd=36,Ud=22,$d=20,qd=9,Gd=1.5,Kd=6,Yd=35,Qd=1.75,Zd=12.4,Jd=.5,Xd=8,ep=28,tp=160,rp=16,np=8;function lp(e,petRef){return jc(e,petRef)}function ChatHeader({pets:n,petRef:petRef,historyUnread:l,onOpenHistory:i,onNewChat:o,onPetChange:a,onAddPet:s,vet:u,textingEntry:c=null}){let d=useEverfurTheme(),p=e.useMemo(()=>ip(d),[d]),[f,h]=e.useState(false),b=lp(n.pets,petRef),g=b!==null&&(n.pets.length>=2||s!==void 0),m=petRef??b?.petRef??null,y=Bd(b),[v,x]=e.useState(dd),w=e.useCallback(e=>t=>{let r=t.nativeEvent.layout.width;x(t=>hd(t,e,r))},[]),k=e.useMemo(()=>w("row"),[w]),S=e.useMemo(()=>w("leading"),[w]),C=e.useMemo(()=>w("trailing"),[w]),j=2*rp+2*(d.slots.header?.borderColor!==void 0?1:0)+2*np,R=fd(v,j,tp),T=e=>{h(false),n.setActivePet(e),br(a,e)},_=s===void 0?null:()=>{h(false),br(s)};/* @__PURE__ */
|
|
142
142
|
return r.jsxs(r.Fragment,{children:[
|
|
143
143
|
/* @__PURE__ */r.jsxs(t.View,{style:p.row,onLayout:k,children:[
|
|
144
|
-
/* @__PURE__ */r.jsx(t.View,{style:[p.leading,R.leading===void 0?null:{minWidth:R.leading}],children:/* @__PURE__ */r.jsxs(t.View,{style:p.sideContent,onLayout:S,children:[o!==void 0?/* @__PURE__ */r.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:Xl.newChat,containerStyle:p.iconSlot,style:p.iconButton,onPress:o,children:/* @__PURE__ */r.jsx(EditGlyph,{size
|
|
144
|
+
/* @__PURE__ */r.jsx(t.View,{style:[p.leading,R.leading===void 0?null:{minWidth:R.leading}],children:/* @__PURE__ */r.jsxs(t.View,{style:p.sideContent,onLayout:S,children:[o!==void 0?/* @__PURE__ */r.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:Xl.newChat,containerStyle:p.iconSlot,style:p.iconButton,onPress:o,children:/* @__PURE__ */r.jsx(EditGlyph,{size:$d,color:d.slots.header?.textColor??d.color.text.primary,strokeWidth:2})}):null,
|
|
145
145
|
/* @__PURE__ */r.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:l?`${se.openHistoryNative}${se.newReplySuffix}`:se.openHistoryNative,containerStyle:p.iconSlot,style:p.iconButton,onPress:i,children:[
|
|
146
|
-
/* @__PURE__ */r.jsx(MenuGlyph,{size:
|
|
146
|
+
/* @__PURE__ */r.jsx(MenuGlyph,{size:Ud,color:d.slots.header?.textColor??d.color.text.primary,strokeWidth:2}),l?/* @__PURE__ */r.jsx(t.View,{style:p.unreadDot,pointerEvents:"none"}):null]})]})}),
|
|
147
147
|
/* @__PURE__ */r.jsx(t.View,{style:p.centre,pointerEvents:"box-none",children:/* @__PURE__ */r.jsx(BrandLogo,{logoUrl:d.meta.logoUrl,name:d.meta.displayName,barStyle:p.logoBar,logoStyle:p.logo})}),
|
|
148
148
|
/* @__PURE__ */r.jsx(t.View,{style:[p.trailing,R.trailing===void 0?null:{minWidth:R.trailing}],children:/* @__PURE__ */r.jsxs(t.View,{style:p.trailingContent,onLayout:C,children:[m===null?null:/* @__PURE__ */r.jsx(VetVisitButtonCore,{entry:"chat",petRef:m,...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}),
|
|
149
149
|
/* @__PURE__ */r.jsx(t.View,{style:p.right,children:g?/* @__PURE__ */r.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:ue(se.switchActivePet,{name:y}),containerStyle:p.avatarSlot,style:p.avatarWrap,onPress:()=>h(true),children:[
|
|
150
|
-
/* @__PURE__ */r.jsx(PetDisc,{pet:b,size:
|
|
151
|
-
/* @__PURE__ */r.jsx(t.View,{style:p.addBadge,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:/* @__PURE__ */r.jsx(PlusGlyph,{size:
|
|
152
|
-
/* @__PURE__ */r.jsx(t.View,{style:p.avatarWrap,accessible:true,accessibilityLabel:se.yourPet,children:/* @__PURE__ */r.jsx(Ring,{size:
|
|
153
|
-
/* @__PURE__ */r.jsx(PetSwitcherSheet,{visible:f,pets:n.pets,activePetRef:b?.petRef??null,onSelect:T,onAddPet:_,onClose:()=>h(false)})]}),c===null?null:/* @__PURE__ */r.jsx(TextingEntryRow,{entry:c,place:"header"})]})}function TextingEntryRow({entry:n,place:l}){let i=useEverfurTheme(),o=e.useMemo(()=>
|
|
154
|
-
return r.jsx(t.View,{style:l==="header"?o.textingEntryRowHeader:o.textingEntryRowThread,children:/* @__PURE__ */r.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:n.label,containerStyle:o.textingEntrySlot,style:o.vetEntry,onPress:n.onOpen,testID:"everfur-texting-entry",children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:o.vetEntryLabel,numberOfLines:1,children:n.label})})})}function
|
|
150
|
+
/* @__PURE__ */r.jsx(PetDisc,{pet:b,size:Yd,ringStroke:Qd}),
|
|
151
|
+
/* @__PURE__ */r.jsx(t.View,{style:p.addBadge,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:/* @__PURE__ */r.jsx(PlusGlyph,{size:Xd,color:d.color.brandInk,strokeWidth:2})})]}):n.loading&&b===null?
|
|
152
|
+
/* @__PURE__ */r.jsx(t.View,{style:p.avatarWrap,accessible:true,accessibilityLabel:se.yourPet,children:/* @__PURE__ */r.jsx(Ring,{size:Yd,strokeWidth:Qd,color:d.color.mark,children:/* @__PURE__ */r.jsx(t.View,{style:p.placeholderDisc})})}):/* @__PURE__ */r.jsx(t.View,{style:p.avatarWrap,accessible:true,accessibilityRole:"image",accessibilityLabel:b===null?se.yourPet:y,children:/* @__PURE__ */r.jsx(PetDisc,{pet:b,size:Yd,ringStroke:Qd})})})]})}),
|
|
153
|
+
/* @__PURE__ */r.jsx(PetSwitcherSheet,{visible:f,pets:n.pets,activePetRef:b?.petRef??null,onSelect:T,onAddPet:_,onClose:()=>h(false)})]}),c===null?null:/* @__PURE__ */r.jsx(TextingEntryRow,{entry:c,place:"header"})]})}function TextingEntryRow({entry:n,place:l}){let i=useEverfurTheme(),o=e.useMemo(()=>ip(i),[i]);/* @__PURE__ */
|
|
154
|
+
return r.jsx(t.View,{style:l==="header"?o.textingEntryRowHeader:o.textingEntryRowThread,children:/* @__PURE__ */r.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:n.label,containerStyle:o.textingEntrySlot,style:o.vetEntry,onPress:n.onOpen,testID:"everfur-texting-entry",children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:o.vetEntryLabel,numberOfLines:1,children:n.label})})})}function ip(e){let r=e.color,n=Yd-Qd*2,l=e.slots.header;return t.StyleSheet.create({vetEntry:{minHeight:Wd,justifyContent:"center",paddingHorizontal:12,borderRadius:e.radius.pill,backgroundColor:r.surfaceCream,borderWidth:t.StyleSheet.hairlineWidth,borderColor:r.controlEdge},vetEntryLabel:{...face(e,"bold"),color:r.brandInk,fontSize:e.type.size.caption},textingEntrySlot:{borderRadius:e.radius.pill,maxWidth:"100%"},textingEntryRowHeader:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:rp,paddingBottom:10,backgroundColor:l?.backgroundColor??r.surface},textingEntryRowThread:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:rp,paddingTop:e.space.md,paddingBottom:e.space.xs},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:rp,paddingVertical:10,backgroundColor:r.surface,...yo(l)},iconSlot:{borderRadius:Nd/2},iconButton:{width:Nd,height:Nd,borderRadius:Nd/2,alignItems:"center",justifyContent:"center"},unreadDot:{position:"absolute",top:Kd,right:Kd,width:qd,height:qd,borderRadius:qd,backgroundColor:r.danger,borderWidth:Gd,borderColor:l?.backgroundColor??r.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:np,alignItems:"center",justifyContent:"center"},logoBar:{alignSelf:"stretch",alignItems:"center"},logo:{height:ep,width:tp,maxWidth:"100%"},right:{alignItems:"flex-end"},avatarSlot:{borderRadius:Yd/2},avatarWrap:{width:Yd,height:Yd,position:"relative"},placeholderDisc:{width:n,height:n,borderRadius:n/2,backgroundColor:r.brandSoft},addBadge:{position:"absolute",bottom:0,right:0,width:Zd,height:Zd,borderRadius:Zd/2,borderWidth:Jd,borderColor:r.mark,backgroundColor:r.surface,alignItems:"center",justifyContent:"center"}})}var op=/* @__PURE__ */Object.freeze([
|
|
155
155
|
/* @__PURE__ */Object.freeze({key:"inaccurate",label:se.feedbackReasonInaccurate,feedbackType:"wrong"}),
|
|
156
156
|
/* @__PURE__ */Object.freeze({key:"outdated",label:se.feedbackReasonOutdated,feedbackType:"outdated"}),
|
|
157
157
|
/* @__PURE__ */Object.freeze({key:"unsafe",label:se.feedbackReasonUnsafe,feedbackType:"dangerous"}),
|
|
158
158
|
/* @__PURE__ */Object.freeze({key:"unclear",label:se.feedbackReasonUnclear,feedbackType:"unclear"}),
|
|
159
|
-
/* @__PURE__ */Object.freeze({key:"other",label:se.feedbackReasonOther,feedbackType:"not_helpful"})]),
|
|
159
|
+
/* @__PURE__ */Object.freeze({key:"other",label:se.feedbackReasonOther,feedbackType:"not_helpful"})]),ap=/* @__PURE__ */Object.freeze([
|
|
160
160
|
/* @__PURE__ */Object.freeze({sentiment:"up",label:se.feedbackHelpful}),
|
|
161
|
-
/* @__PURE__ */Object.freeze({sentiment:"down",label:se.feedbackNotHelpful})]);function
|
|
161
|
+
/* @__PURE__ */Object.freeze({sentiment:"down",label:se.feedbackNotHelpful})]);function sp(e){switch(e){case"up":return"helpful";case"neutral":return"neutral";case"down":return"not_helpful"}}function up(e,t){if(e==="down"&&t!==null){let e=op.find(e=>e.key===t);if(e!==void 0)return e.feedbackType}return sp(e)}var cp=44,dp="rgba(17,17,17,0.55)",pp=26,fp=36,hp=4,bp=20,gp=38,mp=18,yp=12;function FeedbackReasons({visible:n,onSubmit:l,onSkip:i}){let o=useEverfurTheme(),a=e.useMemo(()=>vp(o),[o]),s=K(),[u,c]=e.useState(null),[d,p]=e.useState(""),[f,h]=e.useState(false),[b,g]=e.useState(false),m=()=>{c(null),p(""),h(false),g(false)},y=()=>{f||(m(),i())},v=async()=>{if(f)return;h(true),g(false);let e=d.trim();await l(u,e.length>0?e:null)?m():(h(false),g(true))};if(!n)return null;let x=[...d].length>jo;/* @__PURE__ */
|
|
162
162
|
return r.jsx(t.Modal,{visible:true,transparent:true,animationType:o.motion.reducedMotion?"none":"slide",onRequestClose:y,children:/* @__PURE__ */r.jsxs(t.KeyboardAvoidingView,{behavior:t.Platform.OS==="ios"?"padding":void 0,style:a.root,children:[
|
|
163
163
|
/* @__PURE__ */r.jsx(t.Pressable,{style:a.scrim,onPress:y,accessibilityRole:"button",accessibilityLabel:se.feedbackSkipA11y}),
|
|
164
164
|
/* @__PURE__ */r.jsxs(t.View,{style:Y(a.sheet,s),accessibilityViewIsModal:true,accessibilityLiveRegion:"polite",children:[
|
|
165
165
|
/* @__PURE__ */r.jsx(t.View,{style:a.handle}),
|
|
166
166
|
/* @__PURE__ */r.jsxs(t.View,{style:a.header,children:[
|
|
167
|
-
/* @__PURE__ */r.jsx(t.View,{style:a.iconBadge,children:/* @__PURE__ */r.jsx(ThumbGlyph,{size:
|
|
167
|
+
/* @__PURE__ */r.jsx(t.View,{style:a.iconBadge,children:/* @__PURE__ */r.jsx(ThumbGlyph,{size:mp,color:o.color.brandInk,active:false,rotate:"180deg"})}),
|
|
168
168
|
/* @__PURE__ */r.jsxs(t.View,{style:a.headerText,children:[
|
|
169
169
|
/* @__PURE__ */r.jsx(Text,{tier:"heading",style:a.title,accessibilityRole:"header",children:se.feedbackTitle}),
|
|
170
170
|
/* @__PURE__ */r.jsx(Text,{style:a.subtitle,children:se.feedbackSubtitle})]})]}),
|
|
171
|
-
/* @__PURE__ */r.jsx(t.View,{style:a.options,children:
|
|
171
|
+
/* @__PURE__ */r.jsx(t.View,{style:a.options,children:op.map(e=>{let n=u===e.key;/* @__PURE__ */
|
|
172
172
|
return r.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,accessibilityState:{selected:n},style:[a.option,n?a.optionSelected:null],onPress:()=>c(t=>t===e.key?null:e.key),children:[
|
|
173
173
|
/* @__PURE__ */r.jsx(Text,{style:[a.optionLabel,n?a.optionLabelSelected:null],children:e.label}),
|
|
174
|
-
/* @__PURE__ */r.jsx(t.View,{style:[a.radio,n?a.radioSelected:null],children:n?/* @__PURE__ */r.jsx(CheckGlyph,{size:
|
|
174
|
+
/* @__PURE__ */r.jsx(t.View,{style:[a.radio,n?a.radioSelected:null],children:n?/* @__PURE__ */r.jsx(CheckGlyph,{size:yp,color:o.color.surface,strokeWidth:2}):null})]},e.key)})}),
|
|
175
175
|
/* @__PURE__ */r.jsxs(t.View,{style:a.inputWrap,children:[
|
|
176
|
-
/* @__PURE__ */r.jsx(B,{style:a.input,placeholder:se.feedbackNotesPlaceholder,placeholderTextColor:o.color.text.placeholder,accessibilityLabel:se.feedbackNotesPlaceholder,value:d,onChangeText:p,multiline:true,editable:!f}),d.length>0?/* @__PURE__ */r.jsx(Text,{tier:"compact",style:[a.counter,x?a.counterOver:null],children:`${[...d].length}/${
|
|
176
|
+
/* @__PURE__ */r.jsx(B,{style:a.input,placeholder:se.feedbackNotesPlaceholder,placeholderTextColor:o.color.text.placeholder,accessibilityLabel:se.feedbackNotesPlaceholder,value:d,onChangeText:p,multiline:true,editable:!f}),d.length>0?/* @__PURE__ */r.jsx(Text,{tier:"compact",style:[a.counter,x?a.counterOver:null],children:`${[...d].length}/${jo}`}):null]}),b?/* @__PURE__ */r.jsx(Text,{style:a.failed,accessibilityRole:"alert",children:se.feedbackFailed}):null,
|
|
177
177
|
/* @__PURE__ */r.jsxs(t.View,{style:a.actions,children:[
|
|
178
178
|
/* @__PURE__ */r.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:se.feedbackSubmit,accessibilityState:{busy:f,disabled:f||x},disabled:f||x,style:[a.submit,f||x?a.submitDisabled:null],onPress:()=>{v()},children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:a.submitLabel,children:se.feedbackSubmit})}),
|
|
179
|
-
/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:"button",accessibilityLabel:se.feedbackSkipA11y,hitSlop:8,onPress:y,style:a.skip,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:a.skipLabel,children:se.feedbackSkip})})]})]})]})})}function
|
|
179
|
+
/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:"button",accessibilityLabel:se.feedbackSkipA11y,hitSlop:8,onPress:y,style:a.skip,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:a.skipLabel,children:se.feedbackSkip})})]})]})]})})}function vp(e){let r=e.color,n=e.type,l=e.radius,i=e.slots,o=xo(i.dialog);return t.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},scrim:{...Fa,backgroundColor:dp},sheet:{backgroundColor:r.surface,borderTopLeftRadius:pp,borderTopRightRadius:pp,paddingHorizontal:22,paddingTop:12,paddingBottom:34,gap:14,..._d(i.dialog)},handle:{alignSelf:"center",width:fp,height:hp,borderRadius:hp/2,backgroundColor:r.brandBorder,marginBottom:2},header:{flexDirection:"row",alignItems:"center",gap:12},iconBadge:{width:gp,height:gp,borderRadius:gp/2,alignItems:"center",justifyContent:"center",backgroundColor:r.brandSoft},headerText:{flex:1,gap:2},title:{...headingFace(e,"bold"),fontSize:20,lineHeight:28,color:r.text.primary,letterSpacing:n.letterSpacing.tight,...o},subtitle:{...face(e,"regular"),fontSize:n.size.body,lineHeight:n.size.body*n.lineHeight.relaxed,color:r.text.muted,...o},options:{gap:8},option:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:14,paddingVertical:13,borderRadius:l.md,borderWidth:t.StyleSheet.hairlineWidth,borderColor:r.controlEdge,backgroundColor:r.surface,...yo(i.chip,t.StyleSheet.hairlineWidth)},optionSelected:{borderColor:r.brandInk,backgroundColor:r.brandSoft},optionLabel:{...face(e,"medium"),fontSize:n.size.body,color:r.text.primary,...xo(i.chip)},optionLabelSelected:{color:r.brandInk},radio:{width:bp,height:bp,borderRadius:bp/2,borderWidth:2,borderColor:r.brandBorderStrong,alignItems:"center",justifyContent:"center"},radioSelected:{borderColor:r.brandInk,backgroundColor:r.brandInk},inputWrap:{gap:4},input:{minHeight:72,maxHeight:132,borderRadius:l.md,borderWidth:1,borderColor:r.brandBorderStrong,paddingHorizontal:14,paddingTop:12,paddingBottom:12,...face(e,"regular"),fontSize:n.size.body,color:r.text.primary,textAlignVertical:"top",...yo(i.input,1),...xo(i.input)},counter:{...face(e,"mono"),alignSelf:"flex-end",fontSize:n.size.caption,letterSpacing:.3,color:r.text.placeholder},counterOver:{color:r.danger},failed:{...face(e,"regular"),fontSize:n.size.caption,lineHeight:n.size.caption*n.lineHeight.normal,color:r.danger},actions:{gap:10,alignItems:"center"},submit:{alignSelf:"stretch",minHeight:cp,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.xl,borderRadius:l.pill,backgroundColor:r.brand,...yo(i.primaryButton)},submitDisabled:{opacity:.6},submitLabel:{...face(e,"medium"),fontSize:n.size.body,color:r.onPrimary,...xo(i.primaryButton)},skip:{minHeight:cp,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},skipLabel:{...face(e,"medium"),fontSize:n.size.body,color:r.text.muted}})}var xp=/* @__PURE__ */Symbol.for("everfur.sdk.rn.askHome");function wp(){let t=globalThis,r=t[xp];if(r!==void 0)return r;let n={factory:e.createContext(null),home:e.createContext(null)};return t[xp]=n,n}var kp=wp().factory,Sp=wp().home;function Cp(){return e.useContext(kp)}function jp(){return e.useContext(Sp)?.kit??null}function Rp(){return e.useContext(Sp)}var Tp=15,_p=8;function HistoryBar({bar:n,history:l,empty:i,unread:o,extra:a}){let s=useEverfurTheme(),u=jp(),c=e.useMemo(()=>u!==null?Pp(s,u):Ep(s),[s,u]),d=l.cursor===null?l.rows.length:0,p=e=>{let l=n.renderIcon;if(l!==void 0)/* @__PURE__ */return r.jsx(HostRender,{render:()=>l(e),fallback:null});if(u===null)return null;let i=String(t.StyleSheet.flatten(c.label).color??s.color.linkInk);return e==="history"?/* @__PURE__ */r.jsx(HistoryGlyph,{size:Ip,color:i,strokeWidth:1.8}):/* @__PURE__ */r.jsx(EditGlyph,{size:Ip,color:i,strokeWidth:1.8})};/* @__PURE__ */
|
|
180
180
|
return r.jsxs(t.View,{style:c.bar,testID:"everfur-history-bar",children:[
|
|
181
|
-
/* @__PURE__ */r.jsxs(t.Pressable,{accessibilityRole:"button",accessibilityLabel:d>0?`${n.chats} ${d}`:n.chats,accessibilityState:{expanded:l.open},onPress:l.open?l.close:l.show,style:c.control,hitSlop:u!==null?
|
|
181
|
+
/* @__PURE__ */r.jsxs(t.Pressable,{accessibilityRole:"button",accessibilityLabel:d>0?`${n.chats} ${d}`:n.chats,accessibilityState:{expanded:l.open},onPress:l.open?l.close:l.show,style:c.control,hitSlop:u!==null?zp:void 0,children:[p("history"),
|
|
182
182
|
/* @__PURE__ */r.jsx(Text,{tier:"control",style:c.label,children:n.chats}),d>0?/* @__PURE__ */r.jsx(t.View,{style:c.count,children:/* @__PURE__ */r.jsx(Text,{tier:"badge",style:c.countText,children:String(d)})}):null,o?/* @__PURE__ */r.jsx(t.View,{style:c.dot,testID:"everfur-chat-history-bar-unread"}):null]}),n.extra??null,a??null,
|
|
183
|
-
/* @__PURE__ */r.jsx(t.View,{style:c.spacer}),i?null:/* @__PURE__ */r.jsxs(t.Pressable,{accessibilityRole:"button",accessibilityLabel:n.newChat,onPress:l.newConversation,style:c.control,hitSlop:u!==null?
|
|
184
|
-
/* @__PURE__ */r.jsx(Text,{tier:"control",style:c.label,children:n.newChat})]})]})}var
|
|
183
|
+
/* @__PURE__ */r.jsx(t.View,{style:c.spacer}),i?null:/* @__PURE__ */r.jsxs(t.Pressable,{accessibilityRole:"button",accessibilityLabel:n.newChat,onPress:l.newConversation,style:c.control,hitSlop:u!==null?zp:void 0,children:[p("edit"),
|
|
184
|
+
/* @__PURE__ */r.jsx(Text,{tier:"control",style:c.label,children:n.newChat})]})]})}var zp=4,Ip=18;function Pp(e,t){return{...Ep(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 Ep(e){let r=e.color,n=e.space;return t.StyleSheet.create({bar:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:n.sm,paddingHorizontal:n.lg,paddingVertical:n.xs},control:{flexDirection:"row",alignItems:"center",gap:6,minHeight:cs},label:{...face(e,"bold"),fontSize:Tp,color:r.brandInk},count:{minWidth:22,paddingHorizontal:7,borderRadius:e.radius.pill,backgroundColor:r.surfaceSubtle,alignItems:"center"},countText:{...face(e,"bold"),fontSize:e.type.size.caption,color:r.text.primary},dot:{width:_p,height:_p,borderRadius:_p/2,backgroundColor:r.danger},spacer:{flexGrow:1}})}var Mp=.88,Fp=420,Ap=58,Lp="rgba(17,17,17,0.28)",Op=.15,Vp=14,Dp=12,Bp=44,Hp=16,Wp=14,Np=12,Up=14,$p=8,qp=2,Gp=.5,Kp=Gi(Oi.standard);function Yp(e){return Math.min(Math.round(e*Mp),Fp)}function HistoryDrawer({chat:t,history:n}){let[l,i]=e.useState(n.open),o=e.useCallback(()=>i(false),[]);return n.open&&!l&&i(true),l?/* @__PURE__ */r.jsx(DrawerModal,{chat:t,history:n,onHidden:o}):null}function DrawerModal({chat:l,history:i,onHidden:o}){let a=useEverfurTheme(),s=e.useMemo(()=>Qp(a),[a]),u=Ni(),c=n.useSafeAreaInsets(),{width:d}=t.useWindowDimensions(),p=Yp(d),f=i.open,h=e.useRef(null);h.current===null&&(h.current=new t.Animated.Value(u.drawerMs<=0&&f?1:0));let b=h.current;e.useEffect(()=>{if(!f&&u.drawerMs<=0){o();return}let e=t.Animated.timing(b,{toValue:f?1:0,duration:u.drawerMs,easing:Kp,useNativeDriver:true});return e.start(({finished:e})=>{e&&!f&&o()}),()=>e.stop()},[f,b,u.drawerMs,o]);let g=b.interpolate({inputRange:[0,1],outputRange:[-p,0]}),m=i.filtered,y=i.rows.length===0,v=i.cursor===null&&!i.loading&&i.error===null,x=y&&i.loading?/* @__PURE__ */r.jsxs(t.View,{style:s.emptyCard,accessibilityLabel:Xl.loading,accessibilityState:{busy:true},children:[
|
|
185
185
|
/* @__PURE__ */r.jsx(t.ActivityIndicator,{color:s.emptyTitle.color}),
|
|
186
186
|
/* @__PURE__ */r.jsx(Text,{style:s.emptyBody,children:Xl.loading})]}):y&&i.error!==null?/* @__PURE__ */r.jsxs(t.View,{style:s.emptyCard,children:[
|
|
187
187
|
/* @__PURE__ */r.jsx(Text,{style:s.emptyTitle,accessibilityRole:"alert",children:Xl.loadFailed}),
|
|
@@ -191,164 +191,164 @@ return r.jsxs(t.View,{style:c.bar,testID:"everfur-history-bar",children:[
|
|
|
191
191
|
/* @__PURE__ */r.jsx(Text,{style:s.emptyBody,children:Xl.emptyBody})]}):
|
|
192
192
|
/* @__PURE__ */r.jsx(Text,{style:s.noMatch,children:Xl.noMatch}),w=!i.searching&&i.loadingMore?/* @__PURE__ */r.jsx(t.View,{style:s.loadMoreFooter,children:/* @__PURE__ */r.jsx(Text,{style:s.loadMoreLabel,children:Xl.loadingMore})}):null;/* @__PURE__ */
|
|
193
193
|
return r.jsx(t.Modal,{visible:true,transparent:true,animationType:"none",onRequestClose:i.close,children:/* @__PURE__ */r.jsxs(t.View,{style:s.root,children:[
|
|
194
|
-
/* @__PURE__ */r.jsx(t.Pressable,{style:
|
|
195
|
-
/* @__PURE__ */r.jsx(t.Animated.View,{style:[s.panel,{width:p,paddingTop:Math.max(
|
|
194
|
+
/* @__PURE__ */r.jsx(t.Pressable,{style:Fa,onPress:i.close,accessibilityRole:"button",accessibilityLabel:Xl.closeA11y,children:/* @__PURE__ */r.jsx(t.Animated.View,{style:[s.backdrop,{opacity:b}]})}),
|
|
195
|
+
/* @__PURE__ */r.jsx(t.Animated.View,{style:[s.panel,{width:p,paddingTop:Math.max(Ap,c.top+a.space.md),transform:[{translateX:g}]}],accessibilityViewIsModal:true,children:/* @__PURE__ */r.jsxs(t.KeyboardAvoidingView,{style:s.keyboardAvoider,behavior:t.Platform.OS==="ios"?"padding":"height",children:[
|
|
196
196
|
/* @__PURE__ */r.jsxs(t.View,{style:s.header,children:[
|
|
197
197
|
/* @__PURE__ */r.jsx(Text,{tier:"heading",style:s.heading,accessibilityRole:"header",children:Xl.heading}),
|
|
198
198
|
/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:"button",accessibilityLabel:Xl.newChat,style:s.newChat,onPress:i.newConversation,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:s.newChatLabel,children:Xl.newChat})}),
|
|
199
|
-
/* @__PURE__ */r.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:Xl.close,hitSlop:0,style:s.closeButton,onPress:i.close,children:/* @__PURE__ */r.jsx(CloseGlyph,{size:
|
|
199
|
+
/* @__PURE__ */r.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:Xl.close,hitSlop:0,style:s.closeButton,onPress:i.close,children:/* @__PURE__ */r.jsx(CloseGlyph,{size:Hp,color:a.color.text.muted,strokeWidth:1.75})})]}),
|
|
200
200
|
/* @__PURE__ */r.jsxs(t.View,{style:s.searchPill,children:[
|
|
201
|
-
/* @__PURE__ */r.jsx(SearchGlyph,{size:
|
|
201
|
+
/* @__PURE__ */r.jsx(SearchGlyph,{size:Up,color:a.color.text.muted,strokeWidth:1.5}),
|
|
202
202
|
/* @__PURE__ */r.jsx(B,{value:i.query,onChangeText:e=>i.setQuery(e.replace(/^\s+/,"")),style:s.searchInput,placeholder:Xl.searchPlaceholder,placeholderTextColor:a.color.text.placeholder,accessibilityLabel:Xl.search,autoCorrect:false,autoCapitalize:"none",returnKeyType:"search"})]}),
|
|
203
203
|
/* @__PURE__ */r.jsx(Text,{tier:"compact",style:s.countLabel,children:ni(i.rows.length,v)}),i.error!==null&&!y?/* @__PURE__ */r.jsx(t.View,{style:s.errorCard,children:/* @__PURE__ */r.jsx(Text,{style:s.errorText,accessibilityRole:"alert",children:i.error})}):null,
|
|
204
|
-
/* @__PURE__ */r.jsx(t.FlatList,{data:m,keyExtractor:e=>e.id,renderItem:({item:e})=>/* @__PURE__ */r.jsx(Row,{row:e,active:e.id===l.conversationId,disabled:i.loading,styles:s,onPress:()=>{i.resume(e.id)}}),contentContainerStyle:m.length===0?s.listEmpty:s.list,keyboardShouldPersistTaps:"handled",ListEmptyComponent:x,ListFooterComponent:w,onEndReached:i.loadMore,onEndReachedThreshold:
|
|
204
|
+
/* @__PURE__ */r.jsx(t.FlatList,{data:m,keyExtractor:e=>e.id,renderItem:({item:e})=>/* @__PURE__ */r.jsx(Row,{row:e,active:e.id===l.conversationId,disabled:i.loading,styles:s,onPress:()=>{i.resume(e.id)}}),contentContainerStyle:m.length===0?s.listEmpty:s.list,keyboardShouldPersistTaps:"handled",ListEmptyComponent:x,ListFooterComponent:w,onEndReached:i.loadMore,onEndReachedThreshold:Gp})]})})]})})}function Row({row:e,active:n,disabled:l,styles:i,onPress:o}){let a=e.unreadCount!==null&&e.unreadCount>0,s=ri(e);/* @__PURE__ */
|
|
205
205
|
return r.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:li(e),accessibilityState:{selected:n,disabled:l},disabled:l,style:[i.item,n?i.itemActive:null],onPress:o,children:[
|
|
206
206
|
/* @__PURE__ */r.jsxs(t.View,{style:i.itemRow,children:[
|
|
207
|
-
/* @__PURE__ */r.jsx(Text,{tier:"control",style:i.itemTitle,numberOfLines:1,children:ei(e.title)}),a?/* @__PURE__ */r.jsx(t.View,{style:i.unreadDot}):null]}),s!==null?/* @__PURE__ */r.jsx(Text,{tier:"compact",style:i.itemMeta,numberOfLines:1,children:s}):null]})}function
|
|
207
|
+
/* @__PURE__ */r.jsx(Text,{tier:"control",style:i.itemTitle,numberOfLines:1,children:ei(e.title)}),a?/* @__PURE__ */r.jsx(t.View,{style:i.unreadDot}):null]}),s!==null?/* @__PURE__ */r.jsx(Text,{tier:"compact",style:i.itemMeta,numberOfLines:1,children:s}):null]})}function Qp(e){let r=e.color,n=e.space,l=e.type,i=e.slots,o=r.text.primary,a=xo(i.card);return t.StyleSheet.create({root:{flex:1},backdrop:{flex:1,backgroundColor:Lp},panel:{position:"absolute",left:0,top:0,bottom:0,backgroundColor:r.surface,paddingHorizontal:n.lg,borderRightWidth:t.StyleSheet.hairlineWidth,borderRightColor:r.borderRingCream,gap:n.md,...zd(i.dialog,t.StyleSheet.hairlineWidth)},keyboardAvoider:{flex:1,gap:n.md},header:{flexDirection:"row",alignItems:"center",gap:n.sm},heading:{...headingFace(e,"bold"),flex:1,fontSize:l.size.subtitle,color:o,...xo(i.dialog)},newChat:{minHeight:Bp,justifyContent:"center",paddingHorizontal:n.xs},newChatLabel:{...face(e,"bold"),fontSize:Vp,color:r.brandInk},closeButton:{width:Bp,height:Bp,alignItems:"center",justifyContent:"center"},searchPill:{flexDirection:"row",alignItems:"center",gap:n.sm,borderRadius:e.radius.pill,backgroundColor:r.surfaceSubtle,paddingHorizontal:n.md+qp,paddingVertical:n.sm+qp,borderWidth:1,borderColor:r.borderRingCream,...yo(i.input,1)},searchInput:{...face(e,"regular"),flex:1,fontSize:l.size.bodyTight,color:r.text.primary,padding:0,...xo(i.input)},countLabel:{...face(e,"mono"),fontSize:Dp,color:r.text.muted},list:{gap:n.xs,paddingBottom:n.xl},listEmpty:{flexGrow:1},item:{paddingVertical:n.sm+qp,paddingHorizontal:n.sm,borderRadius:e.radius.md,gap:qp},itemActive:{backgroundColor:Pa(r.highlight,Op)??r.surfaceSubtle},itemRow:{flexDirection:"row",alignItems:"center",gap:n.sm},itemTitle:{...face(e,"bold"),flex:1,fontSize:l.size.bodyTight,color:o},itemMeta:{...face(e,"regular"),fontSize:l.size.caption,color:r.text.muted},unreadDot:{width:$p,height:$p,borderRadius:$p/2,backgroundColor:r.danger},errorCard:{borderRadius:Np,borderWidth:t.StyleSheet.hairlineWidth,borderColor:r.danger,backgroundColor:r.surface,padding:n.md},errorText:{...face(e,"regular"),fontSize:l.size.caption,color:r.danger},emptyCard:{borderRadius:Wp,padding:n.md+qp,gap:n.xs+qp,backgroundColor:r.surfaceSubtle,borderWidth:t.StyleSheet.hairlineWidth,borderColor:r.borderRingCream,...yo(i.card,t.StyleSheet.hairlineWidth)},emptyTitle:{...headingFace(e,"bold"),fontSize:l.size.bodyTight,color:o,...a},emptyBody:{...face(e,"regular"),fontSize:l.size.caption,color:r.text.secondary,...a},noMatch:{...face(e,"regular"),fontSize:l.size.bodyTight,color:r.text.muted,paddingVertical:n.sm},retrySlot:{marginTop:n.sm,alignSelf:"flex-start"},retryButton:{borderRadius:e.radius.pill,paddingHorizontal:n.md+qp,paddingVertical:n.sm,borderWidth:1,borderColor:r.brandInk,...yo(i.primaryButton)},retryText:{...face(e,"bold"),fontSize:l.size.caption,color:r.brandInk,...xo(i.primaryButton)},loadMoreFooter:{paddingVertical:n.md+qp,alignItems:"center"},loadMoreLabel:{...face(e,"regular"),fontSize:l.size.caption,color:r.text.muted}})}function Zp(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 Jp(e,t){let r=new Date(e);return Number.isNaN(r.getTime())?null:r.toLocaleTimeString(t,{hour:"numeric",minute:"2-digit"})}function Xp(e,t=/* @__PURE__ */new Date){let r=[];for(let n of e){let e=Zp(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 ef="rgba(38,37,35,0.38)",tf=28,rf=40,nf=5,lf=11,of=10.5,af=36,sf=11,uf=14,cf=15,df=13.5,pf=48,ff=2,hf=1.3,bf=.12,gf=16,mf=8,yf="80%";function vf(e,t,n){let l=e?.renderIcon;return l===void 0?n:/* @__PURE__ */r.jsx(HostRender,{render:()=>l(t),fallback:n})}function HistorySheet({chat:l,history:i,sheet:o}){let a=useEverfurTheme(),s=e.useMemo(()=>xf(a),[a]),u=n.useSafeAreaInsets(),c=e.useMemo(()=>Xp(i.rows),[i.rows]),d=K();if(!i.open)return null;let p=a.color,f=o?.title?.trim(),h=f!==void 0&&f!==""?f:Xl.heading;/* @__PURE__ */
|
|
208
208
|
return r.jsx(t.Modal,{visible:true,transparent:true,animationType:"slide",onRequestClose:i.close,children:/* @__PURE__ */r.jsxs(t.View,{style:s.root,children:[
|
|
209
|
-
/* @__PURE__ */r.jsx(t.Pressable,{style:[
|
|
209
|
+
/* @__PURE__ */r.jsx(t.Pressable,{style:[Fa,s.scrim],onPress:i.close,accessibilityRole:"button",accessibilityLabel:Xl.closeA11y}),
|
|
210
210
|
/* @__PURE__ */r.jsxs(t.View,{style:Y([s.sheet,{paddingBottom:Math.max(40,u.bottom+a.space.lg)}],d),accessibilityViewIsModal:true,testID:"everfur-history-sheet",children:[
|
|
211
211
|
/* @__PURE__ */r.jsx(t.View,{style:s.grab}),
|
|
212
212
|
/* @__PURE__ */r.jsxs(t.View,{style:s.top,children:[
|
|
213
213
|
/* @__PURE__ */r.jsx(Text,{tier:"compact",style:s.kicker,accessibilityRole:"header",children:h}),
|
|
214
|
-
/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:"button",accessibilityLabel:Xl.closeA11y,onPress:i.close,style:s.close,children:
|
|
214
|
+
/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:"button",accessibilityLabel:Xl.closeA11y,onPress:i.close,style:s.close,children:vf(o,"close",/* @__PURE__ */r.jsx(CloseGlyph,{size:22,color:p.text.primary,strokeWidth:2}))})]}),
|
|
215
215
|
/* @__PURE__ */r.jsxs(t.ScrollView,{style:s.scroll,contentContainerStyle:s.scrollContent,keyboardShouldPersistTaps:"handled",children:[i.loading&&i.rows.length===0?/* @__PURE__ */r.jsxs(t.View,{style:s.state,accessibilityLabel:Xl.loading,accessibilityState:{busy:true},children:[
|
|
216
216
|
/* @__PURE__ */r.jsx(t.ActivityIndicator,{color:p.brandInk}),
|
|
217
217
|
/* @__PURE__ */r.jsx(Text,{tier:"compact",style:s.mono,children:Xl.loading})]}):null,i.error!==null?/* @__PURE__ */r.jsxs(t.View,{style:s.state,children:[
|
|
218
218
|
/* @__PURE__ */r.jsx(Text,{style:s.stateText,accessibilityRole:"alert",children:Xl.loadFailed}),
|
|
219
|
-
/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:"button",accessibilityLabel:Xl.retry,onPress:()=>{i.load()},style:s.link,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:s.linkText,children:Xl.retry})})]}):null,!i.loading&&i.error===null&&i.rows.length===0?/* @__PURE__ */r.jsx(Text,{style:[s.stateText,s.state],children:Xl.empty}):null,c.map((n,a)=>/* @__PURE__ */r.jsxs(e.Fragment,{children:[n.day?/* @__PURE__ */r.jsx(Text,{tier:"compact",style:[s.mono,s.day,a===0?s.dayFirst:null],children:n.day}):null,n.rows.map(e=>{let n=e.id===l.conversationId,a=e.unreadCount!==null&&e.unreadCount>0,u=
|
|
219
|
+
/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:"button",accessibilityLabel:Xl.retry,onPress:()=>{i.load()},style:s.link,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:s.linkText,children:Xl.retry})})]}):null,!i.loading&&i.error===null&&i.rows.length===0?/* @__PURE__ */r.jsx(Text,{style:[s.stateText,s.state],children:Xl.empty}):null,c.map((n,a)=>/* @__PURE__ */r.jsxs(e.Fragment,{children:[n.day?/* @__PURE__ */r.jsx(Text,{tier:"compact",style:[s.mono,s.day,a===0?s.dayFirst:null],children:n.day}):null,n.rows.map(e=>{let n=e.id===l.conversationId,a=e.unreadCount!==null&&e.unreadCount>0,u=Jp(e.updatedAt);/* @__PURE__ */
|
|
220
220
|
return r.jsxs(t.Pressable,{accessibilityRole:"button",accessibilityLabel:li(e),accessibilityState:{selected:n},onPress:()=>{i.resume(e.id)},style:[s.row,n?s.rowCurrent:null],children:[
|
|
221
|
-
/* @__PURE__ */r.jsx(t.View,{style:s.icon,children:
|
|
221
|
+
/* @__PURE__ */r.jsx(t.View,{style:s.icon,children:vf(o,"chat",/* @__PURE__ */r.jsx(ChatBubbleGlyph,{size:19,color:p.linkInk,strokeWidth:1.75}))}),
|
|
222
222
|
/* @__PURE__ */r.jsxs(t.View,{style:s.rowWords,children:[
|
|
223
223
|
/* @__PURE__ */r.jsx(Text,{tier:"control",style:s.rowTitle,numberOfLines:1,children:ei(e.title)}),e.preview!==void 0?/* @__PURE__ */r.jsx(Text,{tier:"compact",style:s.preview,numberOfLines:1,children:e.preview}):null]}),
|
|
224
224
|
/* @__PURE__ */r.jsxs(t.View,{style:s.rowEnd,children:[u!==null?/* @__PURE__ */r.jsx(Text,{tier:"compact",style:[s.mono,s.time,a?s.timeUnread:null],children:u}):null,a?/* @__PURE__ */r.jsx(t.View,{style:s.unreadDot,testID:`everfur-history-sheet-unread-${String(e.id)}`}):null]})]},String(e.id))})]},n.day)),i.cursor!==null&&!i.loadingMore?/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:"button",accessibilityLabel:Xl.more,onPress:i.loadMore,style:s.link,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:s.linkText,children:Xl.more})}):null]}),
|
|
225
|
-
/* @__PURE__ */r.jsxs(t.Pressable,{accessibilityRole:"button",accessibilityLabel:Xl.newChat,onPress:i.newConversation,style:s.newChat,children:[
|
|
226
|
-
/* @__PURE__ */r.jsx(Text,{tier:"control",style:s.newChatText,children:Xl.newChat})]})]})]})})}function
|
|
225
|
+
/* @__PURE__ */r.jsxs(t.Pressable,{accessibilityRole:"button",accessibilityLabel:Xl.newChat,onPress:i.newConversation,style:s.newChat,children:[vf(o,"edit",/* @__PURE__ */r.jsx(EditGlyph,{size:18,color:a.slots.primaryButton?.textColor??p.onPrimary,strokeWidth:1.75})),
|
|
226
|
+
/* @__PURE__ */r.jsx(Text,{tier:"control",style:s.newChatText,children:Xl.newChat})]})]})]})})}function xf(e){let r=e.color,n=e.space,l={...face(e,"mono"),fontSize:of,letterSpacing:of*.06,textTransform:"uppercase",color:r.text.muted};return t.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},scrim:{backgroundColor:ef},sheet:{maxHeight:yf,backgroundColor:r.surface,borderTopLeftRadius:tf,borderTopRightRadius:tf,paddingTop:10,paddingHorizontal:20},grab:{width:rf,height:nf,borderRadius:3,backgroundColor:r.borderRingCream,alignSelf:"center",marginBottom:10},top:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},kicker:{...l,fontSize:lf,letterSpacing:lf*.08,flexShrink:1},close:{width:cs,height:cs,marginRight:-10,alignItems:"center",justifyContent:"center",borderRadius:cs/2},scroll:{flexGrow:0},scrollContent:{paddingBottom:n.xs},mono:l,day:{marginTop:n.lg,marginBottom:n.xs},dayFirst:{marginTop:ff},state:{marginVertical:n.md,gap:n.sm,alignItems:"flex-start"},stateText:{...face(e,"regular"),fontSize:e.type.size.body,color:r.text.primary},link:{minHeight:cs,justifyContent:"center"},linkText:{...face(e,"bold"),fontSize:e.type.size.body,color:r.brandInk},row:{flexDirection:"row",alignItems:"center",gap:n.md,paddingVertical:10,paddingHorizontal:n.sm,borderRadius:uf,minHeight:cs},rowCurrent:{backgroundColor:r.surfaceSubtle},icon:{width:af,height:af,borderRadius:sf,backgroundColor:Pa(r.linkInk,bf)??r.surfaceSubtle,alignItems:"center",justifyContent:"center"},rowWords:{flex:1,minWidth:0},rowTitle:{...face(e,"bold"),fontSize:cf,lineHeight:cf*hf,color:r.text.primary},preview:{...face(e,"regular"),fontSize:df,color:r.text.muted,marginTop:2},rowEnd:{alignSelf:"flex-start",alignItems:"flex-end",gap:6},time:{marginTop:3,letterSpacing:of*.04,textTransform:"none"},timeUnread:{...face(e,"monoBold"),color:r.text.primary},unreadDot:{width:mf,height:mf,borderRadius:mf/2,backgroundColor:r.danger},newChat:{marginTop:n.lg,minHeight:pf,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:n.sm,borderRadius:e.radius.pill,backgroundColor:r.primary,...yo(e.slots.primaryButton)},newChatText:{...face(e,"bold"),fontSize:gf,color:r.onPrimary,...xo(e.slots.primaryButton)}})}var wf="Close",kf=/* @__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:`${Sf(e.possessive)} results`,resultsClose:e=>e.possessive===null?null:`Close ${e.possessive} results`,resultsTopRisk:"Top risk"});function Sf(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={...kf,...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(),c=t.results!==void 0&&r.report!==void 0?t.results:void 0;if(c!==void 0){let e=n.resultsKicker(l)?.trim()||r.kicker,s=n.resultsClose(l),d=c.onTopRisk??o,p={key:"top-risk",label:n.resultsTopRisk,title:r.title,...r.risk?.lead?{line:r.risk.lead}:{},tone:"risk",...d===void 0?{}:{onPress:d}};return{kicker:e,...i===void 0?{}:{badge:i},title:r.title,results:[p,...c.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()===""?wf: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()===""?wf:s,pill:r.kicker,...t.renderIcon===void 0?{}:{renderIcon:t.renderIcon}}}function Cf(e){let t=face(e,"medium");return t.fontWeight===void 0?t:{fontFamily:t.fontFamily,fontWeight:"600"}}function jf(e){let t=face(e,"bold");return t.fontWeight===void 0?t:{fontFamily:t.fontFamily,fontWeight:"800"}}var Rf=20,Tf=14,_f=16,zf=18,If=22,Pf=15,Ef=12,Mf=24,Ff=15,Af=14.5,Lf=21,Of=14.5,Vf=18,Df=9,Bf=36,Hf=14,Wf=15,Nf=8,Uf=40;function TopCard({card:n,open:l,onOpenChange:i,ask:o}){let a=useEverfurTheme(),s=jp(),u=e.useMemo(()=>s!==null?qf(s):Gf(a),[a,s]),c=e.useMemo(()=>yo(a.slots.card),[a.slots.card]);if(!l)return null;let d=n.closeLabel===void 0?null:n.closeLabel.trim()!==""?n.closeLabel:se.close,p=n.action,f=n.ask,h=/* @__PURE__ */r.jsx(CloseGlyph,{size:s!==null?HOME_CLOSE_GLYPH(s):Vf,color:s!==null?String(s.text(".ask-focus__x").color):a.color.text.primary,strokeWidth:2});/* @__PURE__ */
|
|
227
227
|
return r.jsxs(t.View,{style:[u.card,c],testID:"everfur-top-card",children:[
|
|
228
228
|
/* @__PURE__ */r.jsxs(t.View,{style:u.kickerRow,children:[
|
|
229
|
-
/* @__PURE__ */r.jsx(Text,{tier:"control",style:u.kicker,children:n.kicker}),n.badge!==void 0?/* @__PURE__ */r.jsx(t.View,{style:u.badge,children:/* @__PURE__ */r.jsx(Text,{tier:"compact",style:u.badgeText,numberOfLines:1,children:n.badge})}):null,d!==null?/* @__PURE__ */r.jsx(t.Pressable,{onPress:()=>i(false),accessibilityRole:"button",accessibilityLabel:d,style:u.close,hitSlop:s!==null
|
|
229
|
+
/* @__PURE__ */r.jsx(Text,{tier:"control",style:u.kicker,children:n.kicker}),n.badge!==void 0?/* @__PURE__ */r.jsx(t.View,{style:u.badge,children:/* @__PURE__ */r.jsx(Text,{tier:"compact",style:u.badgeText,numberOfLines:1,children:n.badge})}):null,d!==null?/* @__PURE__ */r.jsx(t.Pressable,{onPress:()=>i(false),accessibilityRole:"button",accessibilityLabel:d,style:u.close,hitSlop:s!==null?$f:void 0,testID:"everfur-top-card-close",children:n.renderIcon!==void 0?/* @__PURE__ */r.jsx(HostRender,{render:()=>n.renderIcon?.("close"),fallback:h}):h}):null]}),
|
|
230
230
|
/* @__PURE__ */r.jsx(Text,{tier:"heading",style:u.title,accessibilityRole:"header",children:n.title}),n.lead!==void 0||n.body!==void 0?/* @__PURE__ */r.jsxs(t.View,{style:u.finding,children:[
|
|
231
231
|
/* @__PURE__ */r.jsx(t.View,{style:u.dot}),
|
|
232
|
-
/* @__PURE__ */r.jsxs(Text,{style:u.findingText,children:[n.lead!==void 0?/* @__PURE__ */r.jsx(Text,{style:u.lead,children:n.lead}):null,n.lead!==void 0&&n.body!==void 0?" ":null,n.body??null]})]}):null,p!==void 0||f!==void 0?/* @__PURE__ */r.jsxs(t.View,{style:u.actions,children:[p!==void 0?/* @__PURE__ */r.jsx(t.Pressable,{onPress:()=>{br(p.onPress)},accessibilityRole:"button",accessibilityLabel:p.label,style:u.action,hitSlop:s!==null
|
|
233
|
-
return r.jsxs(t.Pressable,{onPress:()=>i(true),accessibilityRole:"button",accessibilityLabel:u,accessibilityState:{expanded:false},style:s.pill,hitSlop:a!==null
|
|
232
|
+
/* @__PURE__ */r.jsxs(Text,{style:u.findingText,children:[n.lead!==void 0?/* @__PURE__ */r.jsx(Text,{style:u.lead,children:n.lead}):null,n.lead!==void 0&&n.body!==void 0?" ":null,n.body??null]})]}):null,p!==void 0||f!==void 0?/* @__PURE__ */r.jsxs(t.View,{style:u.actions,children:[p!==void 0?/* @__PURE__ */r.jsx(t.Pressable,{onPress:()=>{br(p.onPress)},accessibilityRole:"button",accessibilityLabel:p.label,style:u.action,hitSlop:s!==null?$f:void 0,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:u.actionText,children:p.label})}):null,f!==void 0?/* @__PURE__ */r.jsx(t.Pressable,{onPress:()=>o(f.prompt),accessibilityRole:"button",accessibilityLabel:f.label,style:u.ask,hitSlop:s!==null?$f:void 0,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:u.askText,children:f.label})}):null]}):null]})}function TopCardPill({card:n,open:l,onOpenChange:i}){let o=useEverfurTheme(),a=jp(),s=e.useMemo(()=>a!==null?qf(a):Gf(o),[o,a]);if(l||n.closeLabel===void 0)return null;let u=n.pill??n.kicker;/* @__PURE__ */
|
|
233
|
+
return r.jsxs(t.Pressable,{onPress:()=>i(true),accessibilityRole:"button",accessibilityLabel:u,accessibilityState:{expanded:false},style:s.pill,hitSlop:a!==null?$f:void 0,testID:"everfur-top-card-pill",children:[
|
|
234
234
|
/* @__PURE__ */r.jsx(t.View,{style:s.pillDot}),
|
|
235
|
-
/* @__PURE__ */r.jsx(Text,{tier:"control",style:s.pillText,numberOfLines:1,children:u})]})}var Wf=4,HOME_CLOSE_GLYPH=e=>{let t=e.icon(".ask-focus__x svg").width;return typeof t=="number"?t:Af};function Nf(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:Lf;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 Uf(e){let r=e.color,n=e.space;return t.StyleSheet.create({card:{paddingTop:Cf,paddingHorizontal:jf,paddingBottom:jf,borderRadius:Sf,backgroundColor:r.surface,borderWidth:1,borderColor:r.borderRingCream,alignSelf:"stretch"},kickerRow:{flexDirection:"row",alignItems:"center",gap:n.sm,minHeight:as-8},kicker:{...kf(e),fontSize:_f,color:r.text.primary,flexShrink:1},badge:{marginLeft:"auto",minHeight:If,justifyContent:"center",paddingHorizontal:9,borderRadius:e.radius.pill,backgroundColor:r.surfaceSubtle,flexShrink:1},badgeText:{...face(e,"bold"),fontSize:zf,color:r.text.secondary},close:{width:as,height:as,marginVertical:-4,marginRight:-10,alignItems:"center",justifyContent:"center",borderRadius:as/2},title:{...kf(e),fontSize:Rf,lineHeight:Tf,color:r.text.primary,marginTop:n.xs},finding:{flexDirection:"row",gap:n.sm,marginTop:n.xs+2},dot:{width:Lf,height:Lf,borderRadius:Lf/2,marginTop:7,backgroundColor:r.danger},findingText:{...face(e,"regular"),flex:1,fontSize:Ef,lineHeight:Mf,color:r.text.primary},lead:face(e,"bold"),actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:n.lg,marginTop:14},action:{minHeight:Math.max(Hf,as),paddingHorizontal:n.lg,borderRadius:e.radius.pill,backgroundColor:r.primary,alignItems:"center",justifyContent:"center",maxWidth:"100%"},actionText:{...face(e,"bold"),fontSize:Pf,color:r.onPrimary},ask:{minHeight:as,justifyContent:"center",maxWidth:"100%"},askText:{...face(e,"bold"),fontSize:Ff,color:r.brandInk,textDecorationLine:"underline"},pill:{flexDirection:"row",alignItems:"center",gap:n.sm,minHeight:Math.max(Of,as),paddingHorizontal:Vf,borderRadius:e.radius.pill,backgroundColor:r.badgeBgCritical,alignSelf:"flex-start",maxWidth:"100%"},pillDot:{width:Bf,height:Bf,borderRadius:Bf/2,backgroundColor:r.danger},pillText:{...face(e,"bold"),fontSize:Df,color:r.danger,flexShrink:1}})}var $f=/* @__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"}),qf=/* @__PURE__ */new WeakMap;function Gf(e){let t=qf.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,...$f},i=(e,t)=>Ia(e,t,ka(t),Kf),o=(e,t)=>contrastRatio(e,t)>=Kf?e:wa(t,Kf),a=[l.card,l.paper].map(e=>Ta(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 qf.set(e,u),u}var Kf=4.5;function Yf(e,t){for(let r of t)if(contrastRatio(r,e)>=Kf)return r;return wa(e,Kf)}function Qf(e,t,r){let n=_a(e,t);return(n===null?null:Ta(n,r))??r}function Zf(e){let t=Gf(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:Yf(t.accent,[t.ink,t.onAccent]),accent2:Qf(t.accent,.75,n),accent4:Qf(t.accent,.17,n),accentChip:Qf(t.accent,.47,n),link:t.link,linkChip:Qf(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 Jf=/* @__PURE__ */new Set(["color","fontSize","fontWeight","fontStyle","lh","ls","family","textAlign","textTransform","textDecorationLine"]),Xf=/* @__PURE__ */new Set(["dur","delay","stagger","ease","tint","k","cols","nowrap"]),eh=["paddingTop","paddingRight","paddingBottom","paddingLeft"],th=17,rh=1.5,nh=400,lh=700;function ih(e){return e<=450?"regular":e<=650?"medium":"bold"}function oh(e){let t=Math.min(900,Math.max(100,Math.round(e/100)*100));return String(t)}function ah(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:oh(r)}}let n=t==="$serif"?headingFace(e,ih(r)):face(e,ih(r));return n.fontWeight===void 0?{fontFamily:n.fontFamily}:{fontFamily:n.fontFamily,fontWeight:oh(r)}}function sh(e,t,r={}){let n=Zf(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={},c=e=>{if(e!==void 0)for(let[t,r]of Object.entries(e))u[t]=o(r)};for(let e of n)c(t[e]),i&&c(r[e]);let d=/* @__PURE__ */Object.freeze(u);return a.set(l,d),d},u=/* @__PURE__ */new Map,c=(...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))Jf.has(e)||Xf.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 eh){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 c=/* @__PURE__ */Object.freeze(l);return u.set(t,c),c},d=/* @__PURE__ */new Map,p=(t,r)=>{let l=`${t}|${r.filter(Boolean).join("|")}`,i=d.get(l);if(i!==void 0)return i;let o=s(r),a=typeof o.fontSize=="number"?o.fontSize:th,u=typeof o.lh=="number"?o.lh:rh,c=typeof o.fontWeight=="string"?Number(o.fontWeight):t,p=typeof o.family=="string"?o.family:"$sans",f={...ah(e,p,c),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 d.set(l,h),h};return{reduced:i,colors:n,view:c,text:(...e)=>p(nh,e),strong:(...e)=>p(lh,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 uh={".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"]}},ch=16;var dh=4e3,ph=.5;function fh(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 hh(e,t,r){if(e.length===0)return r;let n=fh(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=ph*e.length+1;for(let o of l)if(fh(e,t,o)<=n)return Math.min(r,o+i);return r}function BalancedTitle({text:n,style:l,measureCh:i}){let o=e.useMemo(()=>n.split(/\s+/).filter(e=>e!==""),[n]),a=t.StyleSheet.flatten(l),s=[n,a.fontFamily,a.fontSize,a.fontWeight,a.letterSpacing].join("|"),u=e.useRef({key:"",ch:null,line:null,words:[]});u.current.key!==s&&(u.current={key:s,ch:null,line:null,words:o.map(()=>null)});let[c,d]=e.useState(null),p=c!==null&&c.key===s?c.value:null,f=()=>{let e=u.current;if(e.ch===null||e.line===null||e.words.some(e=>e===null))return;let t=e.words,r=t.reduce((e,t)=>e+t,0),n=t.length>1?Math.max(0,(e.line-r)/(t.length-1)):0,l=hh(t,n,(e.ch+ph)*i);d(t=>t!==null&&t.key===e.key&&t.value===l?t:{key:e.key,value:l})},h=e=>t=>{u.current.key===s&&(e(u.current,t.nativeEvent.layout.width),f())};/* @__PURE__ */
|
|
236
|
-
return r.jsxs(t.View,{style:
|
|
235
|
+
/* @__PURE__ */r.jsx(Text,{tier:"control",style:s.pillText,numberOfLines:1,children:u})]})}var $f=4,HOME_CLOSE_GLYPH=e=>{let t=e.icon(".ask-focus__x svg").width;return typeof t=="number"?t:Vf};function qf(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:Df;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 Gf(e){let r=e.color,n=e.space;return t.StyleSheet.create({card:{paddingTop:Tf,paddingHorizontal:_f,paddingBottom:_f,borderRadius:Rf,backgroundColor:r.surface,borderWidth:1,borderColor:r.borderRingCream,alignSelf:"stretch"},kickerRow:{flexDirection:"row",alignItems:"center",gap:n.sm,minHeight:cs-8},kicker:{...jf(e),fontSize:Pf,color:r.text.primary,flexShrink:1},badge:{marginLeft:"auto",minHeight:Mf,justifyContent:"center",paddingHorizontal:9,borderRadius:e.radius.pill,backgroundColor:r.surfaceSubtle,flexShrink:1},badgeText:{...face(e,"bold"),fontSize:Ef,color:r.text.secondary},close:{width:cs,height:cs,marginVertical:-4,marginRight:-10,alignItems:"center",justifyContent:"center",borderRadius:cs/2},title:{...jf(e),fontSize:zf,lineHeight:If,color:r.text.primary,marginTop:n.xs},finding:{flexDirection:"row",gap:n.sm,marginTop:n.xs+2},dot:{width:Df,height:Df,borderRadius:Df/2,marginTop:7,backgroundColor:r.danger},findingText:{...face(e,"regular"),flex:1,fontSize:Af,lineHeight:Lf,color:r.text.primary},lead:face(e,"bold"),actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:n.lg,marginTop:14},action:{minHeight:Math.max(Uf,cs),paddingHorizontal:n.lg,borderRadius:e.radius.pill,backgroundColor:r.primary,alignItems:"center",justifyContent:"center",maxWidth:"100%"},actionText:{...face(e,"bold"),fontSize:Ff,color:r.onPrimary},ask:{minHeight:cs,justifyContent:"center",maxWidth:"100%"},askText:{...face(e,"bold"),fontSize:Of,color:r.brandInk,textDecorationLine:"underline"},pill:{flexDirection:"row",alignItems:"center",gap:n.sm,minHeight:Math.max(Bf,cs),paddingHorizontal:Hf,borderRadius:e.radius.pill,backgroundColor:r.badgeBgCritical,alignSelf:"flex-start",maxWidth:"100%"},pillDot:{width:Nf,height:Nf,borderRadius:Nf/2,backgroundColor:r.danger},pillText:{...face(e,"bold"),fontSize:Wf,color:r.danger,flexShrink:1}})}var Kf=/* @__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"}),Yf=/* @__PURE__ */new WeakMap;function Qf(e){let t=Yf.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,...Kf},i=(e,t)=>Ma(e,t,ja(t),Zf),o=(e,t)=>contrastRatio(e,t)>=Zf?e:Ca(t,Zf),a=[l.card,l.paper].map(e=>Ia(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 Yf.set(e,u),u}var Zf=4.5;function Jf(e,t){for(let r of t)if(contrastRatio(r,e)>=Zf)return r;return Ca(e,Zf)}function Xf(e,t,r){let n=Pa(e,t);return(n===null?null:Ia(n,r))??r}function eh(e){let t=Qf(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:Jf(t.accent,[t.ink,t.onAccent]),accent2:Xf(t.accent,.75,n),accent4:Xf(t.accent,.17,n),accentChip:Xf(t.accent,.47,n),link:t.link,linkChip:Xf(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 th=/* @__PURE__ */new Set(["color","fontSize","fontWeight","fontStyle","lh","ls","family","textAlign","textTransform","textDecorationLine"]),rh=/* @__PURE__ */new Set(["dur","delay","stagger","ease","tint","k","cols","nowrap"]),nh=["paddingTop","paddingRight","paddingBottom","paddingLeft"],lh=17,ih=1.5,oh=400,ah=700;function sh(e){return e<=450?"regular":e<=650?"medium":"bold"}function uh(e){let t=Math.min(900,Math.max(100,Math.round(e/100)*100));return String(t)}function ch(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:uh(r)}}let n=t==="$serif"?headingFace(e,sh(r)):face(e,sh(r));return n.fontWeight===void 0?{fontFamily:n.fontFamily}:{fontFamily:n.fontFamily,fontWeight:uh(r)}}function dh(e,t,r={}){let n=eh(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={},c=e=>{if(e!==void 0)for(let[t,r]of Object.entries(e))u[t]=o(r)};for(let e of n)c(t[e]),i&&c(r[e]);let d=/* @__PURE__ */Object.freeze(u);return a.set(l,d),d},u=/* @__PURE__ */new Map,c=(...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))th.has(e)||rh.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 nh){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 c=/* @__PURE__ */Object.freeze(l);return u.set(t,c),c},d=/* @__PURE__ */new Map,p=(t,r)=>{let l=`${t}|${r.filter(Boolean).join("|")}`,i=d.get(l);if(i!==void 0)return i;let o=s(r),a=typeof o.fontSize=="number"?o.fontSize:lh,u=typeof o.lh=="number"?o.lh:ih,c=typeof o.fontWeight=="string"?Number(o.fontWeight):t,p=typeof o.family=="string"?o.family:"$sans",f={...ch(e,p,c),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 d.set(l,h),h};return{reduced:i,colors:n,view:c,text:(...e)=>p(oh,e),strong:(...e)=>p(ah,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 ph={".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"]}},fh=16;var hh=4e3,bh=.5;function gh(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 mh(e,t,r){if(e.length===0)return r;let n=gh(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=bh*e.length+1;for(let o of l)if(gh(e,t,o)<=n)return Math.min(r,o+i);return r}function BalancedTitle({text:n,style:l,measureCh:i}){let o=e.useMemo(()=>n.split(/\s+/).filter(e=>e!==""),[n]),a=t.StyleSheet.flatten(l),s=[n,a.fontFamily,a.fontSize,a.fontWeight,a.letterSpacing].join("|"),u=e.useRef({key:"",ch:null,line:null,words:[]});u.current.key!==s&&(u.current={key:s,ch:null,line:null,words:o.map(()=>null)});let[c,d]=e.useState(null),p=c!==null&&c.key===s?c.value:null,f=()=>{let e=u.current;if(e.ch===null||e.line===null||e.words.some(e=>e===null))return;let t=e.words,r=t.reduce((e,t)=>e+t,0),n=t.length>1?Math.max(0,(e.line-r)/(t.length-1)):0,l=mh(t,n,(e.ch+bh)*i);d(t=>t!==null&&t.key===e.key&&t.value===l?t:{key:e.key,value:l})},h=e=>t=>{u.current.key===s&&(e(u.current,t.nativeEvent.layout.width),f())};/* @__PURE__ */
|
|
236
|
+
return r.jsxs(t.View,{style:yh.wrap,children:[
|
|
237
237
|
/* @__PURE__ */r.jsx(Text,{tier:"heading",style:p===null?l:[l,{maxWidth:p}],accessibilityRole:"header",children:n}),
|
|
238
|
-
/* @__PURE__ */r.jsx(t.View,{style:
|
|
238
|
+
/* @__PURE__ */r.jsx(t.View,{style:yh.probeClip,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:/* @__PURE__ */r.jsxs(t.View,{style:yh.probeRow,children:[
|
|
239
239
|
/* @__PURE__ */r.jsx(Text,{tier:"heading",style:l,onLayout:h((e,t)=>{e.ch=t}),children:"0"}),
|
|
240
|
-
/* @__PURE__ */r.jsx(Text,{tier:"heading",style:l,onLayout:h((e,t)=>{e.line=t}),children:o.join(" ")}),o.map((e,t)=>/* @__PURE__ */r.jsx(Text,{tier:"heading",style:l,onLayout:h((e,r)=>{e.words[t]=r}),children:e},`${t}:${e}`))]})})]})}var
|
|
241
|
-
return Object.freeze({...e,borderColor:o,backgroundColor:l,textColor:a,reasonColor:
|
|
240
|
+
/* @__PURE__ */r.jsx(Text,{tier:"heading",style:l,onLayout:h((e,t)=>{e.line=t}),children:o.join(" ")}),o.map((e,t)=>/* @__PURE__ */r.jsx(Text,{tier:"heading",style:l,onLayout:h((e,r)=>{e.words[t]=r}),children:e},`${t}:${e}`))]})})]})}var yh=t.StyleSheet.create({wrap:{alignSelf:"stretch",alignItems:"center"},probeClip:{position:"absolute",left:0,top:0,width:0,height:0,overflow:"hidden",opacity:0},probeRow:{width:hh,flexDirection:"row",alignItems:"flex-start"}});function vh(e){return{kit:dh(e,ph),Title:BalancedTitle,titleCh:fh}}var xh=/* @__PURE__ */Symbol.for("everfur.sdk.rn.poweredBy");function wh(){let e=globalThis,t=e[xh];if(t!==void 0)return t;let r={count:0,listeners:/* @__PURE__ */new Set};return e[xh]=r,r}var kh=e=>{let t=wh();return t.listeners.add(e),()=>t.listeners.delete(e)},Sh=()=>wh().count>0;function useHostPoweredBy(){return e.useSyncExternalStore(kh,Sh,Sh)}function EverfurPoweredBy({children:t,style:n}){let l=useEverfurTheme().meta.hidePoweredBy;return e.useEffect(()=>{if(l)return;let e=wh();return e.count+=1,e.listeners.forEach(e=>e()),()=>{e.count-=1,e.listeners.forEach(e=>e())}},[l]),l?null:t??/* @__PURE__ */r.jsx(Text,{tier:"compact",style:n,accessibilityRole:"text",children:se.poweredBy})}var Ch=/* @__PURE__ */Object.freeze({}),jh=100,Rh=20;function Th(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 _h(r,n){let l=typeof r=="number"&&Number.isFinite(r),i=e.useRef(null),[o,a]=e.useState(null),s=e.useRef(null),u=e.useRef(null),c=e.useRef(true),d=e.useCallback(()=>{u.current!==null&&clearTimeout(u.current),u.current=null},[]);e.useEffect(()=>(c.current=true,()=>{c.current=false,d()}),[d]);let p=e.useCallback(function e(r){i.current?.measureInWindow((n,l)=>{let i=s.current;if(!c.current||i===null)return;let o=Th(l,i.y,i.height,t.Dimensions.get("window").height);if(o!==null){a(e=>e!==null&&e.chatTop===o.chatTop&&e.parentTop===o.parentTop?e:o);return}r>=Rh||(u.current=setTimeout(()=>{u.current=null,e(r+1)},jh))})},[]),f=e.useCallback(e=>{let{y:t,height:r}=e.nativeEvent.layout;s.current={y:t,height:r},d(),p(0)},[p,d]);return e.useMemo(()=>{if(!n)return{avoidingProps:l?{keyboardVerticalOffset:r}:Ch,probeRef:null,topInWindow:null};let e=o?.parentTop??0;return{avoidingProps:l?{keyboardVerticalOffset:r,onLayout:f}:e>0?{keyboardVerticalOffset:e,onLayout:f}:{onLayout:f},probeRef:i,topInWindow:o?.chatTop??null}},[n,l,r,o,f])}function KeyboardOffsetProbe({probeRef:e}){return e===null?null:/* @__PURE__ */r.jsx(t.View,{ref:e,collapsable:false,pointerEvents:"none",style:zh})}var zh=/* @__PURE__ */Object.freeze({position:"absolute",top:0,left:0,width:0,height:0});function Ih(){let[r,n]=e.useState(false);return e.useEffect(()=>{let e=t.Keyboard;if(typeof e?.addListener!="function")return;let r=t.Platform.OS==="ios",l=e.addListener(r?"keyboardWillShow":"keyboardDidShow",()=>n(true)),i=e.addListener(r?"keyboardWillHide":"keyboardDidHide",()=>n(false));return()=>{l.remove(),i.remove()}},[]),r}var Ph=4.5;var Eh=3;function Mh(e,t,r){return Ma(e,t,ja(t),r)}function Fh(e,t){if(e.level==="emergency")return e;let r=e.level==="schedule_soon",n=md(t),l=r?n.warning:n.info,i=gd(t)&&!l?e:Ah(e,t,r);return Lh(i,t.slots.banner)}function Ah(e,t,r){let n=t.color,l=Ia(r?n.badgeBgCaution:n.badgeBgInfo,n.surface)??n.surface,i=r?n.cautionAccent:n.infoEdge,o=Mh(Ia(i,n.surface)??i,[n.surface,n.chatGround],Eh),a=Mh(r?n.warningStrong:n.info,[l,n.surface],Ph);/* @__PURE__ */
|
|
241
|
+
return Object.freeze({...e,borderColor:o,backgroundColor:l,textColor:a,reasonColor:Mh(n.text.primary,[l],Ph),pillColor:n.surface})}function Lh(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 Oh(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 Vh=.75,Dh=1.5,Bh=.4,Hh=4,Wh=1.5,Nh=22,Uh=14,$h=8,qh=20,Gh=10,Kh=13,Yh=12,Qh=15,Zh=44,Jh=14,Xh=1.25,eb=14,tb=6,rb=2;function nb(e,t){let r=e.color;if(t.level==="emergency")return{card:{backgroundColor:r.badgeBgCritical,borderColor:Pa(r.danger,Bh)??r.danger,borderWidth:Dh},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:Vh,...n===void 0?{}:{borderRadius:n}},label:t.textColor,reason:t.reasonColor,close:t.textColor,action:null}}function UrgencyBanner({surface:t,petRef:petRef,renderVetAction:n,onFindVet:l,vet:i,compact:o=false}){let a=useEverfurTheme(),s=e.useMemo(()=>lb(a),[a]),u=Ni(),c=t.tier===null?null:Fh(t.tier,a),d=t.source;/* @__PURE__ */
|
|
242
242
|
return r.jsxs(r.Fragment,{children:[
|
|
243
243
|
/* @__PURE__ */r.jsx(FadePresence,{visible:t.showBanner&&c!==null,inMs:u.bannerInMs,outMs:u.bannerOutMs,style:s.pinned,children:c!==null&&d!==null?/* @__PURE__ */r.jsx(BannerCard,{tier:c,reason:d.reason,surface:t,petRef:petRef,renderVetAction:n,onFindVet:l,vet:i,styles:s,compact:o}):null}),
|
|
244
|
-
/* @__PURE__ */r.jsx(FadePresence,{visible:t.showCompactIcon,inMs:u.iconInMs,outMs:u.iconOutMs,style:s.indicatorRow,children:/* @__PURE__ */r.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:se.showLatestVetAlert,hitSlop:
|
|
244
|
+
/* @__PURE__ */r.jsx(FadePresence,{visible:t.showCompactIcon,inMs:u.iconInMs,outMs:u.iconOutMs,style:s.indicatorRow,children:/* @__PURE__ */r.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:se.showLatestVetAlert,hitSlop:Gh,onPress:t.expand,children:/* @__PURE__ */r.jsx(InfoGlyph,{size:qh,color:a.color.text.muted,strokeWidth:2})})})]})}function BannerCard({tier:e,reason:n,surface:l,petRef:petRef,renderVetAction:i,onFindVet:o,vet:a,styles:s,compact:u}){let c=useEverfurTheme(),d=nb(c,e),p=/* @__PURE__ */r.jsx(VetAction,{tier:e,paint:d,petRef:petRef,onFindVet:o,vet:a,styles:s}),f=l.showVetAction?i!==void 0?/* @__PURE__ */r.jsx(HostRender,{render:()=>i(e.level),fallback:p,resetKey:e.level}):p:null,h=d.action!==null?/* @__PURE__ */r.jsx(PoisonControl,{paint:d.action,styles:s}):null,b=e.level==="emergency"&&o===void 0,g=e.level==="emergency"||e.level==="schedule_soon";/* @__PURE__ */
|
|
245
245
|
return r.jsxs(t.View,{...g?{accessibilityRole:"alert"}:{accessibilityLiveRegion:"polite"},style:[s.card,d.card,u?s.cardCompact:null],testID:u?"chat-urgency-compact":void 0,children:[
|
|
246
|
-
/* @__PURE__ */r.jsx(Text,{tier:"control",style:[s.label,{color:d.label}],children:e.label}),n!==null?/* @__PURE__ */r.jsx(Text,{style:[s.reason,{color:d.reason}],numberOfLines:u?
|
|
247
|
-
return r.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:se.poisonControlNative,hitSlop:0,style:[n.action,{backgroundColor:e.fill,borderColor:e.edge}],onPress:l,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:[n.actionLabel,{color:e.ink}],children:se.poisonControlNative})})}function VetAction({tier:e,paint:t,petRef:petRef,onFindVet:n,vet:l,styles:i}){let o=useEverfurTheme(),a=useVetVisit(
|
|
246
|
+
/* @__PURE__ */r.jsx(Text,{tier:"control",style:[s.label,{color:d.label}],children:e.label}),n!==null?/* @__PURE__ */r.jsx(Text,{style:[s.reason,{color:d.reason}],numberOfLines:u?rb:void 0,accessibilityLabel:u?n:void 0,children:n}):null,b?/* @__PURE__ */r.jsx(Text,{style:[s.reason,s.erLine,{color:d.reason}],children:se.goToNearestEmergencyVet}):null,f!==null||h!==null?/* @__PURE__ */r.jsxs(t.View,{style:s.actions,children:[f,h]}):null,l.dismissLabel!==null?/* @__PURE__ */r.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:l.dismissLabel,hitSlop:$h,containerStyle:s.closeSlot,style:s.closeButton,onPress:l.dismiss,children:/* @__PURE__ */r.jsx(CloseGlyph,{size:Uh,color:d.close,strokeWidth:1.5})}):null]})}function PoisonControl({paint:e,styles:n}){let l=()=>{try{t.Linking.openURL(pe).catch(()=>{})}catch{}};/* @__PURE__ */
|
|
247
|
+
return r.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:se.poisonControlNative,hitSlop:0,style:[n.action,{backgroundColor:e.fill,borderColor:e.edge}],onPress:l,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:[n.actionLabel,{color:e.ink}],children:se.poisonControlNative})})}function VetAction({tier:e,paint:t,petRef:petRef,onFindVet:n,vet:l,styles:i}){let o=useEverfurTheme(),a=useVetVisit(Oh(petRef,l)),s=a.status==="opening",u=!a.available&&n!==void 0,c=a.available?()=>{a.open()}:n!==void 0?()=>{br(n,e.level)}:null;if(c===null)return null;let d=t.action;if(d!==null){let e=u?se.nearestEmergencyVet:se.findVet,t=vo(o.slots.vetVisitButton)?.textColor??d.ink;/* @__PURE__ */
|
|
248
248
|
return r.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:u?se.nearestEmergencyVet:se.findVetA11y,accessibilityState:{busy:s},hitSlop:0,style:[i.action,{backgroundColor:d.fill,borderColor:d.edge},i.findVetSlotBox,s?i.findVetBusy:null],onPress:c,children:[
|
|
249
|
-
/* @__PURE__ */r.jsx(MapPinGlyph,{size
|
|
250
|
-
/* @__PURE__ */r.jsx(Text,{tier:"control",style:[i.actionLabel,{color:t}],children:e})]})}let p=
|
|
249
|
+
/* @__PURE__ */r.jsx(MapPinGlyph,{size:Kh,color:t,strokeWidth:1.5}),
|
|
250
|
+
/* @__PURE__ */r.jsx(Text,{tier:"control",style:[i.actionLabel,{color:t}],children:e})]})}let p=vo(o.slots.vetVisitButton)?.textColor??e.textColor;/* @__PURE__ */
|
|
251
251
|
return r.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:se.findVetA11y,accessibilityState:{busy:s},style:[i.findVetButton,{borderColor:e.borderColor,backgroundColor:e.pillColor},i.findVetSlotBox,s?i.findVetBusy:null],onPress:c,children:[
|
|
252
|
-
/* @__PURE__ */r.jsx(MapPinGlyph,{size
|
|
253
|
-
/* @__PURE__ */r.jsx(Text,{tier:"control",style:[i.findVetLabel,{color:p}],children:se.findVet})]})}function
|
|
254
|
-
/* @__PURE__ */r.jsx(BrandImage,{uri:e,decorative:true,style:l.assistantAvatar,resizeMode:"cover",onError:i.onError,testID:"everfur-assistant-avatar"}),n?/* @__PURE__ */r.jsx(Text,{tier:"control",style:[l.assistantName,l.assistantNameInRow],children:se.assistantName}):null]}):n?/* @__PURE__ */r.jsx(Text,{tier:"control",style:l.assistantName,children:se.assistantName}):null}var
|
|
255
|
-
return Object.freeze({title:o,sourceName:r,section:n,authorityTier:l,tierLabel:i,meta:s.length===0?null:s,url:
|
|
252
|
+
/* @__PURE__ */r.jsx(MapPinGlyph,{size:Kh,color:p,strokeWidth:1.5}),
|
|
253
|
+
/* @__PURE__ */r.jsx(Text,{tier:"control",style:[i.findVetLabel,{color:p}],children:se.findVet})]})}function lb(e){let r=vo(e.slots.vetVisitButton),n=e.space,l=e.type;return t.StyleSheet.create({pinned:{marginTop:0,marginBottom:n.xs,paddingHorizontal:n.lg},card:{borderRadius:e.radius.lg,paddingHorizontal:n.lg+Hh,paddingVertical:n.lg,gap:n.sm},cardCompact:{paddingVertical:n.md,gap:n.xs},label:{...face(e,"bold"),fontSize:l.size.body,paddingRight:Nh},reason:{...face(e,"regular"),fontSize:l.size.bodyTight,lineHeight:Math.round(l.size.bodyTight*Wh),paddingRight:Nh},erLine:{...face(e,"bold")},actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:n.sm},action:{flexDirection:"row",alignItems:"center",gap:tb,minHeight:Zh,paddingHorizontal:Jh,borderRadius:e.radius.pill,borderWidth:Xh},actionLabel:{...face(e,"bold"),fontSize:eb},findVetButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:e.radius.pill,borderWidth:1},findVetSlotBox:{...yo(r,1)},findVetBusy:{opacity:.6},findVetLabel:{...face(e,"monoBold"),fontSize:Yh,lineHeight:Qh},closeSlot:{position:"absolute",top:n.md,right:n.md},closeButton:{width:Nh,height:Nh,borderRadius:Nh/2,alignItems:"center",justifyContent:"center"},indicatorRow:{alignItems:"flex-end",paddingHorizontal:n.lg,paddingTop:2,paddingBottom:n.xs}})}function ib(t,userRef,petRef,r){let[n,l]=e.useState({pet:petRef,user:userRef}),i=n.pet!==petRef||n.user===null&&userRef!==null;i&&l({pet:petRef,user:userRef});let o=i?{user:userRef}:n,a=petRef!==null&&o.user!==null&&o.user!==userRef;return e.useEffect(()=>{if(!a||userRef===null||petRef===null)return;let e=true,r=createPetsRepository(t.registry.services.authFor(userRef)),n=async()=>{let t=await r.list();e&&t.ok&&t.value.some(e=>e.petRef===petRef)&&l({pet:petRef,user:userRef})};n();let i=Cc(t,()=>{n()});return()=>{e=false,i()}},[a,t,userRef,petRef,r]),a}var ob=/* @__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(t){let{runtime:r,userRef:userRef,activePet:n,scopeEpoch:l}=me(),petRef=t?.petRef??n??null,conversationId=t?.conversationId??null,i=ib(r,userRef,petRef,l),o=e.useMemo(()=>({runtime:r,userRef:userRef,petRef:petRef,conversationId:conversationId,scopeEpoch:l,held:i}),[r,userRef,petRef,conversationId,l,i]),[a,s]=e.useState(null),u=i?null:a?.scope===o?a.controller:r.registry.peekChat({userRef:userRef,petRef:petRef,conversationId:conversationId}),c=e.useRef(null);e.useEffect(()=>{if(i)return;let e=r.registry.acquireChat({userRef:userRef,petRef:petRef,conversationId:conversationId});return c.current=e,s({scope:o,controller:e}),()=>{c.current=null,s(t=>t?.controller===e?null:t),r.registry.releaseChat(e)}},[r,userRef,petRef,conversationId,l,i,o]);let d=e.useCallback(e=>u?u.subscribe(e):NOOP_UNSUBSCRIBE,[u]),p=e.useCallback(()=>u?u.getSnapshot():ob,[u]),f=e.useSyncExternalStore(d,p,p),h=e.useCallback((e,t)=>u&&c.current===u&&!u.getSnapshot().isBootstrapping?sb(u,u.send(e,t?.imageS3Keys===void 0?{}:{imageS3Keys:t.imageS3Keys}),()=>c.current===u):Promise.resolve(cb()),[u]),b=e.useCallback(e=>u&&c.current===u&&!u.getSnapshot().isBootstrapping?sb(u,u.askEverfur(e),()=>c.current===u):Promise.resolve(cb()),[u]),g=e.useCallback(()=>u&&c.current===u?sb(u,u.retryLast(),()=>c.current===u):Promise.resolve(cb()),[u]),m=e.useCallback(()=>{u&&c.current===u&&u.stop()},[u]),y=e.useCallback(()=>{u&&c.current===u&&u.newConversation()},[u]),[v,x]=e.useState({controller:null,byMessage:{}}),w=v.controller===u?v.byMessage:ab,k=e.useCallback(async(e,t,r,n)=>{if(!u||c.current!==u)return err(makeEverfurError("accessDenied"));let l=String(e),i=v.controller===u?v.byMessage[l]:void 0;if(i===t&&r==null)return x(e=>{let t={...e.controller===u?e.byMessage:{}};return delete t[l],{controller:u,byMessage:t}}),ok(/* @__PURE__ */Object.freeze({feedbackId:""}));x(e=>({controller:u,byMessage:{...e.controller===u?e.byMessage:{},[l]:t}}));let o=await u.submitFeedback(e,up(t,r??null),n??null);return c.current!==u?err(makeEverfurError("accessDenied")):(o.ok||x(e=>{let t={...e.controller===u?e.byMessage:{}};return i===void 0?delete t[l]:t[l]=i,{controller:u,byMessage:t}}),o)},[u,v]),S=e.useMemo(()=>{let e=async e=>{if(!u||c.current!==u)return err(makeEverfurError("accessDenied"));let t=await e(u);return c.current===u?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))}},[u,petRef]);return e.useMemo(()=>({status:f.status,messages:f.messages,conversationId:f.conversationId,petRef:petRef,error:f.error,isStreaming:f.isStreaming,isBootstrapping:f.isBootstrapping,historyCursor:f.historyCursor??null,isLoadingHistory:f.isLoadingHistory??false,stopped:f.stopped??false,reconnecting:f.reconnecting??false,...S,suggestedPrompts:f.suggestedPrompts,unreadCount:f.unreadCount,hasUnreadThreads:f.hasUnreadThreads??false,pendingCheckin:f.pendingCheckin??null,newConversation:y,sentimentByMessage:w,feedback:k,send:h,askEverfur:b,retryLast:g,stop:m}),[f,petRef,h,b,g,m,S,y,w,k])}var NOOP_UNSUBSCRIBE=()=>{},ab=/* @__PURE__ */Object.freeze({});async function sb(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(ub(n.messages))}function ub(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 cb(){return gl()}function db(){let t=useEverfurPets(),{handle:r}=me(),n=e.useCallback(petRef=>r.setActivePet(petRef),[r]);return e.useMemo(()=>({...t,setActivePet:n}),[t,n])}function pb(){try{let e=t.AccessibilityInfo?.announceForAccessibility;typeof e=="function"&&e.call(t.AccessibilityInfo,se.answered)}catch{}}function fb(t){let r=e.useRef(false),n=e.useRef({send:t.send,id:t.conversationId});e.useEffect(()=>{let e=n.current;if((e.send!==t.send||e.id!==null&&e.id!==t.conversationId)&&(r.current=false),n.current={send:t.send,id:t.conversationId},r.current&&!t.isStreaming){let e=t.messages[t.messages.length-1];e!==void 0&&e.role==="assistant"&&pb()}r.current=t.isStreaming},[t.isStreaming,t.messages,t.send,t.conversationId])}var hb=/* @__PURE__ */Object.freeze({kind:"live"}),bb=/* @__PURE__ */Object.freeze({kind:"folded"});function gb(e){if(e.role!=="assistant"||e.checkin===void 0)return null;let t=e.checkin.caseId,r=Hl(e.proactiveOriginRef);return{caseId:t,dueDay:r!==null&&r.caseId===t?r.dueDay:""}}function mb(e){let t=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;for(let t of e){let e=gb(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=gb(l);if(e===null){n=null;continue}if(r.get(e.caseId)?.messageId===l.id){t.set(l.id,hb),n=null;continue}if(n!==null&&n.caseId===e.caseId){n.days.push(e.dueDay),t.set(l.id,bb);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 yb(e){let t=/* @__PURE__ */new Set;for(let[r,n]of e)n.kind==="live"&&t.add(r);return t}var vb=864e5,xb=365;function wb(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/vb)-Math.floor(r/vb);return l<1||l>xb?null:l}function kb(e){return gb(e)?.dueDay||null}function Sb(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:n,styles:l}){let i=cd(e);return i.shown?/* @__PURE__ */r.jsxs(t.View,{style:l.assistantSender,testID:"everfur-assistant-sender",children:[
|
|
254
|
+
/* @__PURE__ */r.jsx(BrandImage,{uri:e,decorative:true,style:l.assistantAvatar,resizeMode:"cover",onError:i.onError,testID:"everfur-assistant-avatar"}),n?/* @__PURE__ */r.jsx(Text,{tier:"control",style:[l.assistantName,l.assistantNameInRow],children:se.assistantName}):null]}):n?/* @__PURE__ */r.jsx(Text,{tier:"control",style:l.assistantName,children:se.assistantName}):null}var Cb=/* @__PURE__ */Object.freeze({TIER_1:"#07C168",TIER_2:"#27A9FF",TIER_3:"#FBC558"}),jb="#C8BEB4";function Rb(e){return e?Cb[e.toUpperCase()]??jb:jb}function Tb(e){if(!e)return null;let t=/^tier[_\s-]?(\d+)$/i.exec(e.trim());return t?`Tier ${t[1]}`:e}function _b(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}function zb(e){let t=_b(e);return t!==null&&/^https:\/\/\S+$/i.test(t)?t:null}function Ib(e,t){let r=_b(e.source_name)??_b(e.sourceName),n=_b(e.section),l=_b(e.authority_tier)??_b(e.authorityTier),i=Tb(l),o=r??_b(e.title)??`Source ${t+1}`,a=_b(e.monograph_chunk_id)??_b(e.chunkId),s=[n,i].filter(e=>e!==null).join(" · ");/* @__PURE__ */
|
|
255
|
+
return Object.freeze({title:o,sourceName:r,section:n,authorityTier:l,tierLabel:i,meta:s.length===0?null:s,url:zb(e.url),excerpt:_b(e.excerpt),tierColor:Rb(l),key:`${o}-${a??"none"}-${t}`})}function Pb(e){return e===void 0||e.length===0?Eb:/* @__PURE__ */Object.freeze(e.map((e,t)=>Ib(e,t)))}var Eb=/* @__PURE__ */Object.freeze([]);function Mb(e){return e===1?`1 ${se.sourceSingular}`:`${e} ${se.sourcePlural}`}function Fb(e,t){return`${t?se.hideSources:se.showSources} ${Mb(e)}`}function Ab(e){return[e.url!==null?`${se.openSource}: ${e.title}`:e.title,e.meta,e.excerpt].filter(e=>e!==null&&e.length>0).join(". ")}var Lb="https:\\/\\/sdk(?:-[a-z]+)?\\.everfur\\.com";function Ob(e){return e.replace(/[.*+?^${}()|[\]\\/]/g,"\\$&")}typeof __EVERFUR_BRAND_CDN_ORIGIN__=="string"&&__EVERFUR_BRAND_CDN_ORIGIN__.length>0?Ob(__EVERFUR_BRAND_CDN_ORIGIN__):Lb;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 Vb(e){let t=e.split(/\n\s*\n/).map(e=>e.trim()).filter(e=>e.length>0);return t.length>0?t:[e]}var Db=/^\s*[-*]\s+(\S.*)$/,Bb=/^\s*(\d{1,3})[.)]\s+(\S.*)$/;function Hb(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=Db.exec(t),o=e===null?Bb.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 Wb(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 Nb(e,t){if(e===void 0)return[];try{let r=e(t);return Array.isArray(r)?r:[]}catch{return[]}}function Ub(e){return hardenHttpsUrl(e.trim())}function $b(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?[]:Nb(t.followUpActions,{answer:r.text,question:Wb(e.messages,r.id),messageId:r.id})}var qb=/\*\*([^*]+?)\*\*|\*([^*]+?)\*|`([^`]+?)`/g,Gb=new RegExp(`\\[([^\\]\\n]{1,300})\\]\\((https:\\/\\/[^\\s()<>]{1,${ji}})\\)|(https:\\/\\/[^\\s<>"'\`*\\[\\]]{1,${ji}})`,"gi"),Kb=/https:\/\//i,Yb=`.,;:!?'"`;function Qb(e,t){return e.includes("*")||e.includes("`")||t!==void 0&&Kb.test(e)}function Zb(e,t){let r=[],n=e=>{t===void 0?r.push({kind:"text",text:e}):eg(r,e,t)},l=0;qb.lastIndex=0;for(let t=qb.exec(e);t!==null;t=qb.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 Jb(e){let t=e.length;for(;;){let r=e[t-1];if(r===void 0)break;if(Yb.includes(r))t-=1;else if(r===")"&&Xb(e,"(",t)<Xb(e,")",t))t-=1;else break}return e.slice(0,t)}function Xb(e,t,r){let n=0;for(let l=0;l<r;l+=1)e[l]===t&&(n+=1);return n}function eg(e,t,r){if(!Kb.test(t)){e.push({kind:"text",text:t});return}let n=0;Gb.lastIndex=0;for(let l=Gb.exec(t);l!==null;l=Gb.exec(t)){let i=l[1],o=l[2],a=l[3],s,u,c;if(i!==void 0&&o!==void 0)s=i.trim(),u=s.length>0?zi(o,r):null,c=l[0].length;else if(a!==void 0)s=Jb(a),u=zi(s,r),c=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+c,Gb.lastIndex=n)}n<t.length&&e.push({kind:"text",text:t.slice(n)})}var tg=/* @__PURE__ */Object.freeze({textDecorationLine:"underline"});function rg(e,t){return t===void 0||!Qb(e,t.hosts)?false:Zb(e,t.hosts).some(e=>e.kind==="link")}function ng(e,t,n){let l=n?.hosts;return Qb(e,l)?Zb(e,l).map((e,l)=>{switch(e.kind){case"bold":/* @__PURE__ */
|
|
256
256
|
return r.jsx(Text,{style:t.bold,children:e.text},l);case"italic":return t.italic?/* @__PURE__ */r.jsx(Text,{style:t.italic,children:e.text},l):e.text;case"code":return t.code?/* @__PURE__ */r.jsx(Text,{style:t.code,children:e.text},l):e.text;case"link":{if(n===void 0)return e.text;let{href:t}=e;/* @__PURE__ */
|
|
257
|
-
return r.jsx(Text,{style:
|
|
258
|
-
return r.jsx(t.View,{style:[i.card,e.variant!==void 0?n?.styles?.cardVariant?.[e.variant]:null],accessible:false,accessibilityLabel:e.title,testID:"everfur-answer-host-card",children:/* @__PURE__ */r.jsx(HostRender,{render:l,fallback:null})})}let o=e.value!==void 0,a=n?.styles,s=[i.card,o?a?.cardStat:null,e.variant!==void 0?a?.cardVariant?.[e.variant]:null],u=e.tile?.tone,c=e.pill?.tone,d=e.tile?.imageUrl!==void 0?
|
|
257
|
+
return r.jsx(Text,{style:tg,accessibilityRole:"link",accessibilityLabel:e.text,onPress:()=>n.open(t),children:e.text},l)}default:return e.text}}):e}var lg=10.5,ig=16,og=12,ag=38,sg=11,ug=15,cg=22,dg=32,pg=13.5,fg=14,hg=15,bg=16,gg=13,mg=13,yg=26,vg=21,xg=42,wg=1,kg=.06,Sg=.07,Cg=.12,jg="45%";function Rg(){let t=useEverfurTheme(),r=e.useMemo(()=>Tg(t),[t]);return{theme:t,styles:r}}function Chevron({options:e,color:t}){let n=/* @__PURE__ */r.jsx(ChevronGlyph,{size:bg,color:t,strokeWidth:2,direction:"right"}),l=e?.renderIcon;return l===void 0?n:/* @__PURE__ */r.jsx(HostRender,{render:()=>l("chevron"),fallback:n})}function AnswerCard({card:e,options:n}){let{theme:l,styles:i}=Rg();if(e.render!==void 0){let l=e.render;/* @__PURE__ */
|
|
258
|
+
return r.jsx(t.View,{style:[i.card,e.variant!==void 0?n?.styles?.cardVariant?.[e.variant]:null],accessible:false,accessibilityLabel:e.title,testID:"everfur-answer-host-card",children:/* @__PURE__ */r.jsx(HostRender,{render:l,fallback:null})})}let o=e.value!==void 0,a=n?.styles,s=[i.card,o?a?.cardStat:null,e.variant!==void 0?a?.cardVariant?.[e.variant]:null],u=e.tile?.tone,c=e.pill?.tone,d=e.tile?.imageUrl!==void 0?Ub(e.tile.imageUrl):null,p=/* @__PURE__ */r.jsxs(r.Fragment,{children:[o?null:/* @__PURE__ */r.jsx(t.View,{style:[i.tile,u!==void 0?a?.tileTone?.[u]:null],children:d!==null?/* @__PURE__ */r.jsx(t.Image,{source:{uri:d},style:i.tileImage,accessibilityIgnoresInvertColors:true}):e.tile?.icon??null}),
|
|
259
259
|
/* @__PURE__ */r.jsxs(t.View,{style:i.cardWords,children:[
|
|
260
260
|
/* @__PURE__ */r.jsx(Text,{tier:"control",style:i.cardTitle,children:e.title}),e.meta!==void 0?/* @__PURE__ */r.jsx(Text,{tier:"compact",style:i.cardMeta,children:e.meta}):null]}),o?/* @__PURE__ */r.jsxs(Text,{tier:"control",style:i.stat,children:[e.value?.amount,e.value?.unit!==void 0?/* @__PURE__ */r.jsx(Text,{style:i.statUnit,children:e.value.unit}):null]}):/* @__PURE__ */r.jsxs(r.Fragment,{children:[e.pill!==void 0?/* @__PURE__ */r.jsx(t.View,{style:[i.pill,c!==void 0?a?.pillTone?.[c]:null],children:/* @__PURE__ */r.jsx(Text,{tier:"badge",style:[i.pillText,c!==void 0?a?.pillToneText?.[c]:null],numberOfLines:1,ellipsizeMode:"tail",children:e.pill.label})}):null,e.onPress!==void 0?/* @__PURE__ */r.jsx(Chevron,{options:n,color:l.color.text.muted}):null]})]});if(e.onPress!==void 0){let n=e.onPress;/* @__PURE__ */
|
|
261
261
|
return r.jsx(t.Pressable,{onPress:()=>{br(n)},accessibilityRole:"button",accessibilityLabel:e.title,style:s,children:p})}/* @__PURE__ */
|
|
262
|
-
return r.jsx(t.View,{style:s,children:p})}function CardsAnswer({message:n,text:l,streaming:i,messages:o,options:a,sentiment:s,onSentiment:u,sender:c,footer:d,onOpenUrl:p}){let{styles:f}=
|
|
262
|
+
return r.jsx(t.View,{style:s,children:p})}function CardsAnswer({message:n,text:l,streaming:i,messages:o,options:a,sentiment:s,onSentiment:u,sender:c,footer:d,onOpenUrl:p}){let{styles:f}=Rg(),h=e.useMemo(()=>({answer:n.text,question:Wb(o,n.id),messageId:n.id}),[n.text,n.id,o]),b=!i&&n.pending!==true,g=b?Nb(a?.cards,h):[],m=e.useMemo(()=>b?Pb(n.citations):[],[b,n.citations]),y=a?.byline,v=a?.feedback!==void 0&&n.responseId!==void 0&&u!==void 0?a.feedback:null,x={bold:f.bold,italic:f.italic,code:f.code},w=Ei(),k=b?w:void 0;/* @__PURE__ */
|
|
263
263
|
return r.jsxs(t.View,{style:f.answer,testID:"everfur-answer-cards",children:[y!==void 0?/* @__PURE__ */r.jsxs(t.View,{style:f.byline,children:[y.icon??null,
|
|
264
264
|
/* @__PURE__ */r.jsx(Text,{tier:"compact",style:f.bylineText,children:y.label})]}):c,
|
|
265
|
-
/* @__PURE__ */r.jsx(t.View,{style:f.body,children:
|
|
265
|
+
/* @__PURE__ */r.jsx(t.View,{style:f.body,children:Vb(l).flatMap((e,n)=>Hb(e).map((e,l)=>{let i=`${n}-${l}`;return e.kind==="text"?/* @__PURE__ */r.jsx(Text,{style:f.paragraph,children:ng(e.text,x,k)},i):/* @__PURE__ */r.jsx(t.View,{style:f.list,children:e.items.map((n,l)=>/* @__PURE__ */r.jsxs(t.View,{style:f.listItem,children:[
|
|
266
266
|
/* @__PURE__ */r.jsx(Text,{style:f.paragraph,children:e.ordered?`${e.start+l}.`:"•"}),
|
|
267
|
-
/* @__PURE__ */r.jsx(Text,{style:[f.paragraph,f.listText],children:
|
|
267
|
+
/* @__PURE__ */r.jsx(Text,{style:[f.paragraph,f.listText],children:ng(n,x,k)})]},l))},i)}))}),g.length>0?/* @__PURE__ */r.jsx(t.View,{style:f.cards,children:g.map(e=>/* @__PURE__ */r.jsx(AnswerCard,{card:e,options:a},e.key))}):null,b?/* @__PURE__ */r.jsx(ServerCardsSlot,{message:n}):null,m.length>0?/* @__PURE__ */r.jsxs(t.View,{style:f.cards,accessibilityLabel:Mb(m.length),children:[
|
|
268
268
|
/* @__PURE__ */r.jsx(Text,{tier:"compact",style:f.label,children:se.sourcesHeading}),m.map(e=>{let t=e.url;/* @__PURE__ */
|
|
269
269
|
return r.jsx(AnswerCard,{card:{key:e.key,title:e.title,...e.meta!==null?{meta:e.meta}:{},tile:{icon:/* @__PURE__ */r.jsx(SourceTileGlyph,{})},...p!==void 0&&t!==null?{onPress:()=>p(t)}:{}},options:a},e.key)})]}):null,b&&v!==null&&u!==void 0?/* @__PURE__ */r.jsxs(t.View,{style:[f.feedback,a?.styles?.feedback],children:[
|
|
270
270
|
/* @__PURE__ */r.jsx(FeedbackChip,{label:v.helpful,on:s==="up",onPress:()=>u("up"),styles:f,host:a?.styles}),
|
|
271
271
|
/* @__PURE__ */r.jsx(FeedbackChip,{label:v.notHelpful,on:s==="down",onPress:()=>u("down"),styles:f,host:a?.styles})]}):null,b?d(v===null):null]})}function SourceTileGlyph(){let e=useEverfurTheme();/* @__PURE__ */
|
|
272
|
-
return r.jsx(BookGlyph,{size:
|
|
273
|
-
return r.jsx(t.Pressable,{onPress:l,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{selected:n},style:[i.chip,o?.feedbackChip,n?i.chipOn:null],hitSlop:(
|
|
272
|
+
return r.jsx(BookGlyph,{size:vg,color:e.color.linkInk,strokeWidth:1.5})}function FeedbackChip({label:e,on:n,onPress:l,styles:i,host:o}){/* @__PURE__ */
|
|
273
|
+
return r.jsx(t.Pressable,{onPress:l,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{selected:n},style:[i.chip,o?.feedbackChip,n?i.chipOn:null],hitSlop:(cs-dg)/2,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:[i.chipText,o?.feedbackChipText],children:e})})}function CardsFollowUps({prompts:e,onSelectPrompt:n,label:l,actions:i,options:o}){let{theme:a,styles:s}=Rg();if(e.length===0&&i.length===0)return null;let u=o?.styles,c=l??se.followUpsHeadingNative;/* @__PURE__ */
|
|
274
274
|
return r.jsxs(t.View,{style:[s.followUps,u?.followUps],accessibilityLabel:c,testID:"everfur-cards-follow-ups",children:[
|
|
275
|
-
/* @__PURE__ */r.jsx(Text,{tier:"compact",style:[s.label,u?.followUpsLabel],accessibilityRole:"header",children:c}),i.map(e=>/* @__PURE__ */r.jsxs(t.Pressable,{onPress:()=>{br(e.onPress)},accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:
|
|
275
|
+
/* @__PURE__ */r.jsx(Text,{tier:"compact",style:[s.label,u?.followUpsLabel],accessibilityRole:"header",children:c}),i.map(e=>/* @__PURE__ */r.jsxs(t.Pressable,{onPress:()=>{br(e.onPress)},accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:wg,style:[s.row,s.rowAction,u?.followUp,u?.followUpAction],children:[e.icon??null,
|
|
276
276
|
/* @__PURE__ */r.jsx(Text,{tier:"control",style:[s.rowText,s.rowTextAction,u?.followUpText,u?.followUpActionText],children:e.label}),
|
|
277
|
-
/* @__PURE__ */r.jsx(Chevron,{options:o,color:a.color.text.primary})]},`action:${e.key}`)),e.map(e=>/* @__PURE__ */r.jsxs(t.Pressable,{onPress:()=>n(e),accessibilityRole:"button",accessibilityLabel:e,hitSlop:
|
|
277
|
+
/* @__PURE__ */r.jsx(Chevron,{options:o,color:a.color.text.primary})]},`action:${e.key}`)),e.map(e=>/* @__PURE__ */r.jsxs(t.Pressable,{onPress:()=>n(e),accessibilityRole:"button",accessibilityLabel:e,hitSlop:wg,style:[s.row,u?.followUp],children:[
|
|
278
278
|
/* @__PURE__ */r.jsx(Text,{tier:"control",style:[s.rowText,u?.followUpText],children:e}),
|
|
279
|
-
/* @__PURE__ */r.jsx(Chevron,{options:o,color:a.color.linkInk})]},e))]})}function CardsByline({label:e}){let{styles:n}=
|
|
280
|
-
return r.jsx(t.View,{style:n.byline,children:/* @__PURE__ */r.jsx(Text,{tier:"compact",style:n.bylineText,children:e})})}function
|
|
281
|
-
return r.jsxs(t.View,{style:d.card,accessibilityLabel:
|
|
279
|
+
/* @__PURE__ */r.jsx(Chevron,{options:o,color:a.color.linkInk})]},e))]})}function CardsByline({label:e}){let{styles:n}=Rg();/* @__PURE__ */
|
|
280
|
+
return r.jsx(t.View,{style:n.byline,children:/* @__PURE__ */r.jsx(Text,{tier:"compact",style:n.bylineText,children:e})})}function Tg(e){let r=e.color,n=e.space,l={...face(e,"mono"),fontSize:lg,textTransform:"uppercase",color:r.text.muted},i={borderWidth:1,borderColor:r.borderRingCream},o={borderWidth:1,borderColor:Pa(r.text.primary,kg)??r.borderRingCream},a={shadowColor:r.text.primary,shadowOffset:{width:0,height:1},shadowOpacity:Sg,shadowRadius:2,elevation:1},s=textRole(e,"message"),chipInk=xo(e.slots.chip);return t.StyleSheet.create({answer:{gap:n.md,alignSelf:"stretch"},byline:{flexDirection:"row",alignItems:"center",gap:10,minHeight:14},bylineText:{...l,letterSpacing:lg*.06,flexShrink:1},body:{gap:10},paragraph:{...face(e,"regular"),fontSize:s.fontSize,lineHeight:Math.round(s.lineHeight),color:r.text.primary},list:{gap:4},listItem:{flexDirection:"row",gap:n.sm,paddingLeft:n.xs},listText:{flex:1},bold:face(e,"bold"),italic:{fontStyle:"italic"},code:face(e,"mono"),cards:{gap:n.sm},card:{flexDirection:"row",alignItems:"center",gap:n.md,padding:og,borderRadius:ig,backgroundColor:r.surface,...o,...a,minHeight:cs,...yo(e.slots.card)},tile:{width:ag,height:ag,borderRadius:sg,backgroundColor:Pa(r.linkInk,Cg)??r.surfaceSubtle,alignItems:"center",justifyContent:"center",overflow:"hidden"},tileImage:{width:ag,height:ag},cardWords:{flex:1,minWidth:0},cardTitle:{...face(e,"bold"),fontSize:ug,lineHeight:Math.round(ug*1.25),color:r.text.primary,...xo(e.slots.card)},cardMeta:{...l,letterSpacing:lg*.04,marginTop:3},stat:{...face(e,"mono"),fontSize:cg,color:r.text.primary},statUnit:{...face(e,"mono"),fontSize:lg+2,color:r.text.muted},pill:{minHeight:yg,paddingHorizontal:10,borderRadius:e.radius.pill,backgroundColor:r.surfaceSubtle,justifyContent:"center",flexShrink:1,maxWidth:jg},pillText:{...face(e,"bold"),fontSize:mg,color:r.text.primary},feedback:{flexDirection:"row",flexWrap:"wrap",gap:n.sm,alignItems:"center"},chip:{minHeight:dg,paddingHorizontal:12,borderRadius:e.radius.pill,...i,justifyContent:"center"},chipOn:{backgroundColor:r.surfaceSubtle},chipText:{...Cf(e),fontSize:pg,color:r.text.primary,...chipInk},followUps:{gap:n.sm,alignSelf:"stretch",marginTop:n.xs},label:{...face(e,"bold"),fontSize:gg,lineHeight:Math.round(gg*1.5),color:r.text.muted,marginTop:2},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:xg,paddingTop:11,paddingBottom:11,paddingRight:12,paddingLeft:14,borderRadius:fg,backgroundColor:r.surface,...o},rowAction:{},rowText:{...Cf(e),flex:1,fontSize:hg,lineHeight:Math.round(hg*1.3),color:r.linkInk},rowTextAction:{color:r.text.primary}})}var _g=/* @__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"})}),zg=/* @__PURE__ */Object.freeze(Ll.map(e=>/* @__PURE__ */Object.freeze({answer:e,label:_g.answers[e]})));function Ig(t,r){let[n,l]=e.useState(null),[i,o]=e.useState(null),[a,s]=e.useState(null),u=e.useCallback(e=>{r!==null&&(l(e),o(null),r(t.caseId,e).then(t=>{l(null),t.ok?s(e):o(t.error)}))},[r,t.caseId]),c=a??t.answer;return{answer:c,answerable:!isCheckinSettled(t),escalated:c==="worse",pending:n,error:i,choose:u}}var Pg=44,Eg=.6,Mg=/* @__PURE__ */Object.freeze({caseId:"",answer:null,resolutionText:null,status:null});function CheckinCard({message:n,checkin:l,onAnswer:i,petRef:petRef,onFindVet:o,vet:a,onLayout:s,onOpen:u}){let c=useEverfurTheme(),d=e.useMemo(()=>Fg(c),[c]),p=Ig(l??Mg,l===null?null:i),f=p.answer!==null||p.pending!==null,h=l!==null&&i!==null&&p.answerable,b=l===null?null:wb(l.openedAt,kb(n));/* @__PURE__ */
|
|
281
|
+
return r.jsxs(t.View,{style:d.card,accessibilityLabel:_g.eyebrow,onLayout:s,children:[
|
|
282
282
|
/* @__PURE__ */r.jsxs(t.View,{style:d.head,children:[
|
|
283
|
-
/* @__PURE__ */r.jsx(Text,{tier:"compact",style:d.eyebrow,children:
|
|
284
|
-
return r.jsx(t.Pressable,{onPress:()=>p.choose(e),disabled:f,accessibilityRole:"button",accessibilityLabel:n,accessibilityState:{selected:l,disabled:f,busy:p.pending===e},style:[d.pill,l?d.pillSelected:null],children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:[d.pillLabel,l?d.pillLabelSelected:null],children:n})},e)})}):null,p.answer!==null?/* @__PURE__ */r.jsx(Text,{style:d.logged,children:
|
|
283
|
+
/* @__PURE__ */r.jsx(Text,{tier:"compact",style:d.eyebrow,children:_g.eyebrow}),b!==null?/* @__PURE__ */r.jsx(Text,{tier:"compact",style:d.headDay,children:ue(_g.day,{day:b})}):null]}),u?/* @__PURE__ */r.jsx(t.Pressable,{onPress:u,accessibilityRole:"button",accessibilityLabel:n.text,style:d.open,children:/* @__PURE__ */r.jsx(Text,{style:[d.question,d.openText],children:n.text})}):/* @__PURE__ */r.jsx(Text,{style:d.question,accessibilityRole:"text",children:n.text}),h?/* @__PURE__ */r.jsx(t.View,{style:[d.row,p.pending?d.rowPending:null],children:zg.map(({answer:e,label:n})=>{let l=(p.pending??p.answer)===e;/* @__PURE__ */
|
|
284
|
+
return r.jsx(t.Pressable,{onPress:()=>p.choose(e),disabled:f,accessibilityRole:"button",accessibilityLabel:n,accessibilityState:{selected:l,disabled:f,busy:p.pending===e},style:[d.pill,l?d.pillSelected:null],children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:[d.pillLabel,l?d.pillLabelSelected:null],children:n})},e)})}):null,p.answer!==null?/* @__PURE__ */r.jsx(Text,{style:d.logged,children:_g.logged}):null,p.escalated?/* @__PURE__ */r.jsx(CheckinFindVet,{petRef:petRef??null,onFindVet:o,vet:a,styles:d}):null,l?.resolutionText?/* @__PURE__ */r.jsx(Text,{style:d.resolution,children:l.resolutionText}):null,p.error?/* @__PURE__ */r.jsx(Text,{style:d.error,accessibilityRole:"alert",children:p.error.displayMessage}):null]})}function CheckinFindVet({petRef:petRef,onFindVet:e,vet:n,styles:l}){return useVetVisit(Oh(petRef,n)).available&&petRef!==null?/* @__PURE__ */r.jsx(VetVisitButtonCore,{entry:"chat",petRef:petRef,label:_g.findVet,...n?.returnTo!==void 0?{returnTo:n.returnTo}:{},...n?.usState!==void 0?{usState:n.usState}:{},...n?.prefer!==void 0?{prefer:n.prefer}:{},style:l.findVet,labelStyle:l.findVetLabel}):e===void 0?null:/* @__PURE__ */r.jsx(t.Pressable,{onPress:e,accessibilityRole:"button",accessibilityLabel:_g.findVet,style:l.findVet,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:l.findVetLabel,children:_g.findVet})})}function Fg(e){let r=e.color,n=e.space,l=e.radius,i=e.type,o=vo(e.slots.card),a=xo(o);return t.StyleSheet.create({card:{maxWidth:"92%",padding:n.md,gap:n.sm,borderRadius:l.lg,backgroundColor:r.brandSoft,borderWidth:t.StyleSheet.hairlineWidth,borderColor:r.brandBorder,...yo(o,t.StyleSheet.hairlineWidth)},head:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:n.sm},eyebrow:{...face(e,"regular"),color:r.text.secondary,fontSize:i.size.caption,letterSpacing:i.letterSpacing.eyebrow,textTransform:"uppercase",...a},headDay:{...face(e,"bold"),color:r.text.primary,fontSize:i.size.caption,letterSpacing:i.letterSpacing.eyebrow,textTransform:"uppercase",...a},question:{...face(e,"regular"),color:r.text.primary,fontSize:i.size.body,lineHeight:i.size.body*i.lineHeight.normal,...a},open:{minHeight:Pg,justifyContent:"center"},openText:{textDecorationLine:"underline"},row:{flexDirection:"row",gap:n.sm,marginTop:n.xs},rowPending:{opacity:Eg},pill:{flex:1,minHeight:Pg,alignItems:"center",justifyContent:"center",paddingHorizontal:n.md,borderRadius:l.pill,borderWidth:1,borderColor:r.controlEdge,backgroundColor:r.surface},pillSelected:{backgroundColor:r.brand,borderColor:r.brandInk},pillLabel:{...face(e,"regular"),color:r.text.primary,fontSize:i.size.body},pillLabelSelected:{color:r.onPrimary},logged:{...face(e,"regular"),color:r.text.secondary,fontSize:i.size.caption,...a},resolution:{...face(e,"regular"),color:r.text.primary,fontSize:i.size.body,lineHeight:i.size.body*i.lineHeight.normal,...a},error:{...face(e,"regular"),color:r.danger,fontSize:i.size.caption},findVet:{alignSelf:"stretch",minHeight:Pg,alignItems:"center",justifyContent:"center",borderRadius:l.pill,borderWidth:1.5,borderColor:r.controlEdge,backgroundColor:r.surface},findVetLabel:{...face(e,"bold"),color:r.brandInk,fontSize:i.size.body}})}var Ag=244,Lg=8,Og=13,Vg=14,Dg=.3,Bg=-.24,Hg=22,Wg=10,Ng=15;function CitationCards({citations:n,onOpenUrl:l}){let i=useEverfurTheme(),o=e.useMemo(()=>Ug(i),[i]),a=e.useMemo(()=>Pb(n),[n]),[s,u]=e.useState(false);if(a.length===0)return null;let c=a.length;/* @__PURE__ */
|
|
285
285
|
return r.jsxs(t.View,{style:o.block,children:[
|
|
286
|
-
/* @__PURE__ */r.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:
|
|
287
|
-
/* @__PURE__ */r.jsx(BookGlyph,{size:
|
|
288
|
-
/* @__PURE__ */r.jsx(Text,{tier:"compact",style:o.toggleLabel,children:
|
|
289
|
-
/* @__PURE__ */r.jsx(ChevronGlyph,{size:
|
|
290
|
-
return r.jsx(t.Animated.View,{style:o,children:/* @__PURE__ */r.jsx(t.ScrollView,{horizontal:true,nestedScrollEnabled:true,showsHorizontalScrollIndicator:false,contentContainerStyle:n.row,children:e.map(e=>/* @__PURE__ */r.jsx(Card,{card:e,styles:n,open:l},e.key))})})}function Card({card:e,styles:n,open:l}){let i=useEverfurTheme(),o=e.url!==null&&l!==void 0,a=
|
|
286
|
+
/* @__PURE__ */r.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:Fb(c,s),accessibilityState:{expanded:s},containerStyle:o.toggleSlot,style:o.togglePill,onPress:()=>u(e=>!e),children:[
|
|
287
|
+
/* @__PURE__ */r.jsx(BookGlyph,{size:Og,color:i.color.brandInk,strokeWidth:1.5}),
|
|
288
|
+
/* @__PURE__ */r.jsx(Text,{tier:"compact",style:o.toggleLabel,children:Mb(c)}),
|
|
289
|
+
/* @__PURE__ */r.jsx(ChevronGlyph,{size:Og,color:i.color.brandInk,strokeWidth:1.5,direction:s?"up":"down"})]}),s?/* @__PURE__ */r.jsx(Deck,{cards:a,styles:o,open:l}):null]})}function Deck({cards:e,styles:n,open:l}){let i=Ni(),o=Ji(i.citationsInMs,{risePx:i.citationsRisePx});/* @__PURE__ */
|
|
290
|
+
return r.jsx(t.Animated.View,{style:o,children:/* @__PURE__ */r.jsx(t.ScrollView,{horizontal:true,nestedScrollEnabled:true,showsHorizontalScrollIndicator:false,contentContainerStyle:n.row,children:e.map(e=>/* @__PURE__ */r.jsx(Card,{card:e,styles:n,open:l},e.key))})})}function Card({card:e,styles:n,open:l}){let i=useEverfurTheme(),o=e.url!==null&&l!==void 0,a=Ab(o?e:{...e,url:null}),s=/* @__PURE__ */r.jsxs(r.Fragment,{children:[
|
|
291
291
|
/* @__PURE__ */r.jsxs(t.View,{style:n.cardHeader,children:[
|
|
292
292
|
/* @__PURE__ */r.jsx(t.View,{style:[n.tierDot,{backgroundColor:e.tierColor}]}),
|
|
293
|
-
/* @__PURE__ */r.jsx(Text,{style:[n.cardTitle,o?n.cardTitleLink:null],numberOfLines:2,children:e.title}),o?/* @__PURE__ */r.jsx(ArrowUpRightGlyph,{size:
|
|
293
|
+
/* @__PURE__ */r.jsx(Text,{style:[n.cardTitle,o?n.cardTitleLink:null],numberOfLines:2,children:e.title}),o?/* @__PURE__ */r.jsx(ArrowUpRightGlyph,{size:Vg,color:i.color.linkInk,strokeWidth:1.5}):null]}),e.meta!==null?/* @__PURE__ */r.jsx(Text,{tier:"compact",style:n.cardMeta,numberOfLines:1,children:e.meta}):null,e.excerpt!==null?/* @__PURE__ */r.jsx(Text,{style:n.cardExcerpt,numberOfLines:3,children:e.excerpt}):null]});if(e.url!==null&&l!==void 0){let t=e.url;/* @__PURE__ */
|
|
294
294
|
return r.jsx(PressScale,{accessibilityRole:"link",accessibilityLabel:a,style:n.card,onPress:()=>l(t),children:s})}/* @__PURE__ */
|
|
295
|
-
return r.jsx(t.View,{accessible:true,accessibilityRole:"text",accessibilityLabel:a,style:n.card,children:s})}function
|
|
296
|
-
/* @__PURE__ */r.jsxs(t.View,{style:[u.row,d?u.rowUser:u.rowAssistant],children:[p!==null?/* @__PURE__ */r.jsx(Text,{tier:"compact",style:u.timestamp,children:p}):null,f?/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:"button",accessibilityLabel:b?se.copied:d?se.copyUserMessage:se.copyAssistantMessage,onPress:y,style:u.iconHit,children:b?/* @__PURE__ */r.jsx(CheckGlyph,{size
|
|
295
|
+
return r.jsx(t.View,{accessible:true,accessibilityRole:"text",accessibilityLabel:a,style:n.card,children:s})}function Ug(e){let r=e.color,n=e.space,l=e.radius,i=e.type.size,o=xo(e.slots.card);return t.StyleSheet.create({block:{gap:n.sm},toggleSlot:{alignSelf:"flex-start",borderRadius:l.pill},togglePill:{flexDirection:"row",alignItems:"center",gap:n.xs+2,paddingHorizontal:n.md,paddingVertical:n.xs+2,borderRadius:l.pill,backgroundColor:r.brandSoft},toggleLabel:{...face(e,"monoBold"),fontSize:i.micro,lineHeight:i.micro,letterSpacing:Dg,color:r.brandInk,textTransform:"uppercase"},row:{gap:n.sm,paddingRight:n.xl,paddingTop:n.xs},card:{width:Ag,borderRadius:l.md,borderWidth:1,borderColor:r.brandBorder,backgroundColor:r.surface,padding:n.md,gap:n.xs+2,...yo(e.slots.card,1)},cardHeader:{flexDirection:"row",alignItems:"center",gap:n.sm},tierDot:{width:Lg,height:Lg,borderRadius:l.pill},cardTitle:{...headingFace(e,"bold"),flex:1,fontSize:i.bodyTight,lineHeight:Hg,color:r.text.primary,letterSpacing:Bg,...o},cardTitleLink:{color:r.linkInk},cardMeta:{...face(e,"monoMedium"),fontSize:i.nano,lineHeight:Wg,letterSpacing:e.type.letterSpacing.monoWide,color:r.text.metaCool,textTransform:"uppercase",...o},cardExcerpt:{...face(e,"regular"),fontSize:i.tiny,lineHeight:Ng,color:r.text.muted,...o}})}var $g=15,qg=44,Gg=16,Kg=/* @__PURE__ */Object.freeze({up:"0deg",neutral:"270deg",down:"180deg"});function MessageFooter({message:n,onCopy:l,sentiment:i=null,onSentiment:o,note:a=null}){let s=useEverfurTheme(),u=e.useMemo(()=>Yg(s),[s]),c=Ni(),d=n.role==="user",p=e.useMemo(()=>Sb(n.createdAt),[n.createdAt]),f=l!==void 0&&n.role!=="vet"&&n.text.length>0,h=n.role==="assistant"&&o!==void 0&&n.responseId!==void 0,[b,g]=e.useState(false),m=e.useRef(null);e.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);let y=()=>{l!==void 0&&(yr(l,n.text),g(true),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{g(false),m.current=null},c.copiedMs))};return p===null&&!f&&!h?null:/* @__PURE__ */r.jsxs(t.View,{style:u.wrap,children:[
|
|
296
|
+
/* @__PURE__ */r.jsxs(t.View,{style:[u.row,d?u.rowUser:u.rowAssistant],children:[p!==null?/* @__PURE__ */r.jsx(Text,{tier:"compact",style:u.timestamp,children:p}):null,f?/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:"button",accessibilityLabel:b?se.copied:d?se.copyUserMessage:se.copyAssistantMessage,onPress:y,style:u.iconHit,children:b?/* @__PURE__ */r.jsx(CheckGlyph,{size:$g,color:s.color.success,strokeWidth:2}):/* @__PURE__ */r.jsx(CopyGlyph,{size:$g,color:s.color.text.timestamp,strokeWidth:1.5})}):null,h?ap.map(({sentiment:e,label:n})=>/* @__PURE__ */r.jsx(t.Pressable,{accessibilityRole:"button",accessibilityLabel:n,accessibilityState:{selected:i===e},onPress:()=>o?.(e),style:u.iconHit,children:/* @__PURE__ */r.jsx(ThumbGlyph,{size:$g,color:i===e?s.color.sentiment[e]:s.color.text.timestamp,active:i===e,rotate:Kg[e],strokeWidth:1.5})},e)):null]}),a==="thanks"?/* @__PURE__ */r.jsx(Text,{style:u.thanks,accessibilityLiveRegion:"polite",children:se.feedbackThanks}):null,a==="failed"?/* @__PURE__ */r.jsxs(r.Fragment,{children:[
|
|
297
297
|
/* @__PURE__ */r.jsx(Text,{style:u.failed,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:se.feedbackFailed}),
|
|
298
|
-
/* @__PURE__ */r.jsx(AnnounceLine,{line:se.feedbackFailed})]}):null]})}function
|
|
298
|
+
/* @__PURE__ */r.jsx(AnnounceLine,{line:se.feedbackFailed})]}):null]})}function Yg(e){let r=e.type;return t.StyleSheet.create({wrap:{gap:4},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:Gg,paddingTop:6},rowAssistant:{alignSelf:"flex-start"},rowUser:{alignSelf:"flex-end"},timestamp:{...face(e,"monoMedium"),fontSize:r.size.nano,lineHeight:r.size.nano+2,color:e.color.text.timestamp,textAlign:"center"},iconHit:{width:qg,height:qg,marginVertical:-28/2,alignItems:"center",justifyContent:"center"},thanks:{...face(e,"regular"),fontSize:r.size.caption,lineHeight:r.size.caption*r.lineHeight.normal,color:e.color.text.secondary},failed:{...face(e,"regular"),fontSize:r.size.caption,lineHeight:r.size.caption*r.lineHeight.normal,color:e.color.danger}})}var Qg=16,Zg=10,Jg=12,Xg=10,em=2,tm=.06,rm=34,nm=9,lm=10.5,im=.06,om=15,am=19.5,sm=14,um=19.6;function OpeningCard({card:n,onLayout:l}){let i=useEverfurTheme(),o=e.useMemo(()=>cm(i),[i]),a=n.styles;/* @__PURE__ */
|
|
299
299
|
return r.jsxs(t.View,{testID:"everfur-opening-card",onLayout:l,accessible:true,accessibilityLabel:[n.kicker,n.title,n.body].filter(e=>e!==void 0).join(", "),style:[o.card,a?.card],children:[n.icon!==void 0?/* @__PURE__ */r.jsx(t.View,{style:[o.icon,a?.icon],children:n.icon}):null,
|
|
300
300
|
/* @__PURE__ */r.jsxs(t.View,{style:o.words,children:[
|
|
301
301
|
/* @__PURE__ */r.jsx(Text,{tier:"compact",style:[o.kicker,a?.kicker],children:n.kicker}),
|
|
302
|
-
/* @__PURE__ */r.jsx(Text,{tier:"control",style:[o.title,a?.title],children:n.title}),n.body!==void 0?/* @__PURE__ */r.jsx(Text,{style:[o.body,a?.body],children:n.body}):null]})]})}function
|
|
302
|
+
/* @__PURE__ */r.jsx(Text,{tier:"control",style:[o.title,a?.title],children:n.title}),n.body!==void 0?/* @__PURE__ */r.jsx(Text,{style:[o.body,a?.body],children:n.body}):null]})]})}function cm(e){let r=e.color;return t.StyleSheet.create({card:{flexDirection:"row",alignItems:"flex-start",gap:Xg,paddingVertical:Zg,paddingHorizontal:Jg,alignSelf:"stretch",borderRadius:Qg,backgroundColor:r.surface,borderWidth:1,borderColor:Pa(r.text.primary,tm)??r.borderRingCream},icon:{flexShrink:0,width:rm,height:rm,borderRadius:nm,backgroundColor:r.highlight,alignItems:"center",justifyContent:"center",overflow:"hidden"},words:{flex:1,minWidth:0,gap:em},kicker:{...face(e,"mono"),fontSize:lm,letterSpacing:lm*im,textTransform:"uppercase",color:r.text.muted},title:{...face(e,"bold"),fontSize:om,lineHeight:am,color:r.text.primary},body:{...face(e,"regular"),fontSize:sm,lineHeight:um,color:r.text.secondary}})}var dm="#10462E",pm="Book a video visit",fm="#000000",hm="#83E0B4",bm=/* @__PURE__ */Object.freeze([
|
|
303
303
|
/* @__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}),
|
|
304
|
-
/* @__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:
|
|
305
|
-
/* @__PURE__ */Object.freeze({id:"early-pain-signs",intent:"send",label:"What are early signs of pain?",background:"#FBC558",borderColor:
|
|
306
|
-
/* @__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
|
|
307
|
-
return Object.freeze(
|
|
304
|
+
/* @__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:hm,borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),
|
|
305
|
+
/* @__PURE__ */Object.freeze({id:"early-pain-signs",intent:"send",label:"What are early signs of pain?",background:"#FBC558",borderColor:dm,brandEdge:true,borderWidth:1}),
|
|
306
|
+
/* @__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 gm(e,t){return e?null:{fill:t.fill,ink:t.ink}}var mm=8;function ym(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0&&t.length<=64&&!/[;{}<>]/u.test(t)?t:null}function vm(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(t.length>=mm)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=ym(r.tint);t.push(/* @__PURE__ */Object.freeze({id:`starter-${t.length}`,label:e,prompt:n,tint:l,ink:l===null?null:ym(r.ink)}))}return t.length>0?/* @__PURE__ */Object.freeze(t):null}var xm=/\s*-\s*(?:small|medium|large|giant|toy)\s*$/i;function wm(e){return e==null?e:e.replace(xm,"").trim()}var km=/* @__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 Sm(e){let t=String(e??"").replace(/\s+/gu," ").trim().toLowerCase().replace(/\u2019/g,"'");return km.has(t)}function Cm(e){return e==="cat"?"Domestic Short Hair Mix":"Mixed Breed"}function jm(e,t){let r=e?.trim();if(r===void 0||r==="")return Rm(t);let n=t?.name?.trim()||se.emptyTitlePetFallback,l=n.charAt(0).toUpperCase()+n.slice(1);return r.replace(/\{(pet|petName)\}/g,(e,t,r)=>r===0?l:n)}function Rm(e){let t=e?.name?.trim()||se.emptyTitlePetFallback;return ue(se.emptyTitle,{petName:t})}function Tm(e){let t=e.toLowerCase();return t===Cm("dog").toLowerCase()||t===Cm("cat").toLowerCase()}function _m(e){let t=wm(e);if(Sm(t))return null;let r=String(t).replace(/\s+/gu," ").trim();return Tm(r)?null:r}function zm(e,t=dm,r){let n=canonicalPetSpecies(e?.species),l=e?.name?.trim()||null,i=_m(e?.breed),o=vd(e?.ageYears),a=o===null?null:String(o),s=r?.vetPrepLabel?.trim()||null;/* @__PURE__ */
|
|
307
|
+
return Object.freeze(bm.flatMap(e=>{let r=e.intent==="vet_report"&&s!==null?s:e.label,o=r.includes("{breed}"),u=r.includes("{ageYears}"),c=e.fallbackLabel!==void 0&&(o&&!i||u&&!a)&&e.fallbackLabel?e.fallbackLabel:r;if(c.includes("{breed}")&&i===null||c.includes("{ageYears}")&&a===null||n===null&&(c.includes("{species}")||c.includes("{petName}")&&l===null))return[];let d=ue(c,{petName:l??(n==="cat"?"my cat":"my dog"),breed:i??"",species:n??"",ageYears:a??""}),p=!l&&c.startsWith("{petName}")?d.charAt(0).toUpperCase()+d.slice(1):d;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 Im=44,Pm=0,Em={top:3,bottom:3},Mm=1,Fm=.28,Am=2,Lm=2,Om=1.3,Vm=-.015,Dm=/* @__PURE__ */Object.freeze([
|
|
308
308
|
/* @__PURE__ */Object.freeze({tint:"#FFE7A1",ink:"#262523"}),
|
|
309
309
|
/* @__PURE__ */Object.freeze({tint:"#C8F4F8",ink:"#262523"}),
|
|
310
310
|
/* @__PURE__ */Object.freeze({tint:"#DDEFC4",ink:"#262523"}),
|
|
311
|
-
/* @__PURE__ */Object.freeze({tint:"#FFD8D6",ink:"#262523"})]);function QuickPrompts({pet:n,petRef:petRef,onSend:l,onVetPrep:i,vet:o,starterPrompts:a,emptyState:s,centered:u=false}){let c=useEverfurTheme(),d=e.useMemo(()=>
|
|
311
|
+
/* @__PURE__ */Object.freeze({tint:"#FFD8D6",ink:"#262523"})]);function QuickPrompts({pet:n,petRef:petRef,onSend:l,onVetPrep:i,vet:o,starterPrompts:a,emptyState:s,centered:u=false}){let c=useEverfurTheme(),d=e.useMemo(()=>Bm(c),[c]),p=e.useMemo(()=>vm(a),[a]),f=e.useMemo(()=>p!==null?p.map(e=>({prompt:{id:e.id,intent:"send",label:e.label,background:e.tint??c.color.highlight,borderColor:"transparent",borderWidth:1},send:e.prompt,paint:e.tint===null?null:{fill:e.tint,ink:e.ink??c.color.text.primary}})):zm(n,c.color.brandInk,{vetPrepLabel:pm}).map(e=>({prompt:e,send:e.label,paint:null})),[p,n,c.color.brandInk,c.color.highlight,c.color.text.primary]),h=s?.chipTints!==void 0,b=e.useMemo(()=>(s?.chipTints??(c.brightness==="light"?Dm:[])).filter(e=>typeof e.tint=="string"&&e.tint.trim()!==""),[s?.chipTints,c.brightness]),g=e.useMemo(()=>b.length===0?f:f.map((e,t)=>{if(e.paint!==null)return e;let r=b[t%b.length];return{...e,paint:{fill:r.tint,ink:r.ink??c.color.text.primary},...h?{}:{cycleDefault:true}}}),[f,b,h,c.color.text.primary]),m=e.useMemo(()=>gm(gd(c),{fill:c.color.highlight,ink:c.color.onHighlight}),[c]),y=e.useMemo(()=>({fill:c.color.highlight,ink:c.color.onHighlight}),[c.color.highlight,c.color.onHighlight]),v=jm(s?.title,n),x=jp(),w=Rp(),k=x!==null&&w!==null?/* @__PURE__ */r.jsx(w.Title,{text:v,style:[d.title,x.text(".serif",".ask-empty h2"),d.centerText],measureCh:w.titleCh}):/* @__PURE__ */r.jsx(Text,{tier:"heading",style:u?[d.title,d.centerText]:d.title,accessibilityRole:"header",children:v});/* @__PURE__ */
|
|
312
312
|
return r.jsxs(t.View,{style:x!==null?d.homeBlock:d.block,children:[k,
|
|
313
|
-
/* @__PURE__ */r.jsx(t.View,{style:x!==null?[d.list,d.listCentered,x.view(".ask-chips",".ask-empty .ask-chips")]:u?[d.list,d.listCentered]:d.list,accessibilityLabel:se.suggestions,children:g.map(({prompt:e,send:t,paint:a,cycleDefault:s},c)=>/* @__PURE__ */r.jsx(Chip,{prompt:e,send:t,themed:a??(p!==null?y:m),index:c,petRef:petRef,onSend:l,onVetPrep:i,vet:o,pet:n,styles:d,tinted:a!==null&&s!==true,soft:a!==null,centered:u},e.id))})]})}function Chip({prompt:e,send:n,themed:l,index:i,pet:o,petRef:petRef,onSend:a,onVetPrep:s,vet:u,styles:c,tinted:d,soft:p,centered:f}){let h=
|
|
313
|
+
/* @__PURE__ */r.jsx(t.View,{style:x!==null?[d.list,d.listCentered,x.view(".ask-chips",".ask-empty .ask-chips")]:u?[d.list,d.listCentered]:d.list,accessibilityLabel:se.suggestions,children:g.map(({prompt:e,send:t,paint:a,cycleDefault:s},c)=>/* @__PURE__ */r.jsx(Chip,{prompt:e,send:t,themed:a??(p!==null?y:m),index:c,petRef:petRef,onSend:l,onVetPrep:i,vet:o,pet:n,styles:d,tinted:a!==null&&s!==true,soft:a!==null,centered:u},e.id))})]})}function Chip({prompt:e,send:n,themed:l,index:i,pet:o,petRef:petRef,onSend:a,onVetPrep:s,vet:u,styles:c,tinted:d,soft:p,centered:f}){let h=Ni(),b=Ji(h.followUpInMs,{delayMs:Hi(h,i),risePx:h.promptRisePx}),g=jp(),m=g!==null?[c.chipHome,g.view(".chip")]:f&&p?c.chipNoEdge:c.chipEdge,y={backgroundColor:l?.fill??e.background},v=c.chipSlot===null?y:d?{...c.chipSlot,...y}:{...y,...c.chipSlot},x=g!==null?[c.chipLabel,g.text(".chip")]:f?[c.chipLabel,c.centerText]:[c.chipLabel],w=g!==null?Em:Pm,k=l===null?c.chipSlotLabel===null?x:[...x,c.chipSlotLabel]:d?[...x,...c.chipSlotLabel===null?[]:[c.chipSlotLabel],{color:l.ink}]:[...x,{color:l.ink},...c.chipSlotLabel===null?[]:[c.chipSlotLabel]];return e.intent==="vet_report"?s!==void 0?/* @__PURE__ */r.jsx(t.Animated.View,{style:b,children:/* @__PURE__ */r.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:w,style:[c.chip,m,v],onPress:()=>{br(s,o)},children:/* @__PURE__ */r.jsx(Text,{tier:"compact",style:k,children:e.label})})}):petRef===null?null:/* @__PURE__ */r.jsx(t.Animated.View,{style:b,children:/* @__PURE__ */r.jsx(VetVisitButtonCore,{entry:"chat",petRef:petRef,label:e.label,...u?.returnTo!==void 0?{returnTo:u.returnTo}:{},...u?.usState!==void 0?{usState:u.usState}:{},...u?.prefer!==void 0?{prefer:u.prefer}:{},style:[c.chip,m,v],labelStyle:k})}):/* @__PURE__ */r.jsx(t.Animated.View,{style:b,children:/* @__PURE__ */r.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:w,style:[c.chip,m,v],onPress:()=>a(n),children:/* @__PURE__ */r.jsx(Text,{tier:"compact",style:k,children:e.label})})})}function Bm(e){let t=vo(e.slots.chip),r=xo(t);return{chipSlot:t===void 0?null:yo(t,Mm),chipSlotLabel:r.color===void 0?null:r,...Hm(e)}}function Hm(e){let r=e.color,n=e.space,l=e.type;return t.StyleSheet.create({block:{gap:n.lg,alignItems:"stretch",width:"100%"},homeBlock:{alignItems:"stretch",width:"100%"},chipHome:{borderWidth:0,minHeight:0},title:{...headingFace(e,"medium"),fontSize:l.size.heading,lineHeight:Math.round(l.size.heading*l.lineHeight.snug),color:r.brandInk,letterSpacing:l.size.heading*Vm,textAlign:"left"},list:{width:"100%",flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-start",gap:n.sm+Am},listCentered:{flexDirection:"column",flexWrap:"nowrap",alignItems:"stretch"},centerText:{textAlign:"center"},chipNoEdge:{borderWidth:Mm,borderColor:"transparent"},chip:{borderRadius:e.radius.pill,paddingHorizontal:n.lg+Lm,paddingVertical:n.sm,minHeight:Im,minWidth:0,alignItems:"center",justifyContent:"center",maxWidth:"100%"},chipEdge:{borderWidth:Mm,borderColor:Pa(r.brandInk,Fm)??r.borderRingCream},chipLabel:{...face(e,"bold"),fontSize:l.size.bodyTight,lineHeight:Math.round(l.size.bodyTight*Om),color:fm,textAlign:"left"}})}var Wm=1e3,Nm=150,Um=.25,$m=.5,qm=3;function TypingIndicator({petName:n=null,inline:l=false}){let{theme:i,styles:o}=tu(),a=i.motion.reducedMotion,s=de(se.reading,n),u=e.useRef(Array.from({length:qm},()=>new t.Animated.Value(0))).current;return e.useEffect(()=>{if(a)return;let e=u.map((e,r)=>t.Animated.loop(t.Animated.sequence([t.Animated.delay(r*Nm),t.Animated.timing(e,{toValue:1,duration:Wm*.4,useNativeDriver:true}),t.Animated.timing(e,{toValue:0,duration:Wm*.6,useNativeDriver:true}),t.Animated.delay((qm-r-1)*Nm)])));for(let t of e)t.start();return()=>{for(let t of e)t.stop()}},[a,u]),/* @__PURE__ */r.jsx(t.View,{style:l?o.readingInline:o.readingBox,accessible:true,accessibilityRole:"text",accessibilityLabel:s,accessibilityLiveRegion:"polite",accessibilityState:{busy:true},children:u.map((e,n)=>/* @__PURE__ */r.jsx(t.Animated.View,{accessibilityElementsHidden:true,importantForAccessibility:"no",style:[l?o.readingDotInline:o.readingDot,a?{opacity:$m}:{opacity:e.interpolate({inputRange:[0,1],outputRange:[Um,1]}),transform:[{translateY:e.interpolate({inputRange:[0,1],outputRange:[0,-3]})}]}]},n))})}function Gm(e,t,r){let n=e-r,l=t!=null?Math.min(n,t):n;return Math.max(0,l)}function Km(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 Ym(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 Qm=16;function Zm(t,r,n=null){let l=e.useRef(null),i=e.useRef(true),o=e.useRef(r),a=e.useRef(0),s=e.useRef(0),u=e.useRef(0),c=e.useRef(/* @__PURE__ */new Map),d=e.useRef(null),p=e.useRef(false),f=t[0]?.id??null,h=e.useRef(f),b=e.useRef(null);e.useEffect(()=>{let e=h.current;if(h.current=f,e===null||e===f||(b.current=null,i.current||!t.some(t=>t.id===e)))return;let r=c.current.get(e);r!==void 0&&(b.current={id:e,top:r,offset:a.current})},[f,t]);let g=Km(t),m=g===null?null:t[g.assistantIndex]?.id??null,y=g===null||g.userIndex===null?null:t[g.userIndex]?.id??null,v=e.useCallback(()=>{let e=l.current;if(e===null||!i.current||s.current===0)return;let t=null;if(m!==null){let e=c.current.get(m);if(e===void 0)return;let r=y===null?null:c.current.get(y)??null;t=Gm(e,r,96)}let r=Ym(t,a.current,u.current-s.current);if(r!==null&&(a.current=r,e.scrollTo({y:r,animated:false})),!p.current||d.current===null)return;let n=Ym(d.current+Qm-s.current,a.current,u.current-s.current);n!==null&&(a.current=n,e.scrollTo({y:n,animated:false}))},[m,y]);e.useEffect(()=>{p.current=n!==null,n===null&&(d.current=null),v()},[n,v]),e.useEffect(()=>{r&&!o.current&&(i.current=true,p.current=false),o.current=r,v()},[t,r,v]);let x=e.useCallback(e=>{s.current=e.nativeEvent.layout.height,v()},[v]),w=e.useCallback((e,t)=>{u.current=t,s.current>0&&(a.current=Math.min(a.current,Math.max(0,t-s.current))),v()},[v]),k=e.useCallback(e=>{a.current=e.nativeEvent.contentOffset.y},[]),S=e.useCallback(()=>{i.current=false,p.current=false},[]),C=e.useCallback(e=>{let{contentOffset:t,contentSize:r,layoutMeasurement:n}=e.nativeEvent;a.current=t.y,i.current=r.height-t.y-n.height<=24},[]),j=e.useCallback(e=>t=>{let r=t.nativeEvent.layout.y;c.current.set(e,r);let n=b.current;if(n!==null&&n.id===e&&r!==n.top){b.current=null;let e=Math.max(0,n.offset+r-n.top);a.current=e,l.current?.scrollTo({y:e,animated:false})}(e===m||e===y)&&v()},[m,y,v]),R=e.useCallback(e=>{let{y:t,height:r}=e.nativeEvent.layout;d.current=t+r,v()},[v]);return{ref:l,onLayout:x,onContentSizeChange:w,onScroll:k,onScrollBeginDrag:S,onScrollEnd:C,rowLayout:j,asideLayout:R}}function Jm(e,t,n){switch(e){case"loading":return n.renderPending?/* @__PURE__ */r.jsx(HostRender,{render:n.renderPending,fallback:/* @__PURE__ */r.jsx(LoadingState,{})}):/* @__PURE__ */r.jsx(LoadingState,{});case"empty":/* @__PURE__ */
|
|
314
314
|
return r.jsx(EmptyState,{pet:n.shownPet,petRef:t.petRef,onSelectPrompt:n.onSelectPrompt,onVetPrep:n.onVetPrep,vet:n.vet,top:n.threadTop,pendingCheckin:n.pendingCheckin??null,topCard:n.topCard,starterPrompts:n.starterPrompts,emptyState:n.emptyState,centered:n.emptyCentered===true,renderEmptyHeader:n.renderEmptyHeader});case"error":/* @__PURE__ */
|
|
315
315
|
return r.jsx(ErrorState,{error:t.error,onRetry:t.retryLast,onAddPet:n.onAddPet});case"populated":/* @__PURE__ */
|
|
316
|
-
return r.jsx(PopulatedState,{messages:t.messages,prompts:Kr(t,n.followUpPolicy),actions:n.answerCards
|
|
317
|
-
return r.jsxs(t.ScrollView,{contentContainerStyle:[p,f.homeEmpty],keyboardShouldPersistTaps:"handled",keyboardDismissMode:
|
|
316
|
+
return r.jsx(PopulatedState,{messages:t.messages,prompts:Kr(t,n.followUpPolicy),actions:n.answerCards?$b(t,n.answerCards):ey,answerCards:n.answerCards??null,threadTop:n.threadTop,pendingCheckin:n.pendingCheckin??null,threadAside:n.threadAside,threadAsideKey:n.threadAsideKey??null,onSelectPrompt:n.onSelectPrompt,isStreaming:t.isStreaming,onAnswerCheckin:t.petRef?t.answerCheckin:null,onCopy:n.onCopy,sentimentByMessage:t.sentimentByMessage,onSentiment:n.onSentiment,feedbackNote:n.feedbackNote,imagesByMessage:n.imagesByMessage,onPreview:n.onPreview,notice:n.notice,reconnecting:t.reconnecting===true,onRetry:t.retryLast,onStartNew:t.newConversation,petRef:t.petRef,onFindVet:n.onCheckinFindVet,vet:n.vet,onOpenUrl:n.onOpenUrl,petName:n.shownPet?.name??null,followUpLabel:n.followUpPolicy?.label,openingCard:n.openingCard,earlier:t.historyCursor?{loading:t.isLoadingHistory,load:t.loadOlderMessages}:null});default:return assertNever(e)}}function LoadingState(){let{theme:n,styles:l}=tu(),[i,o]=e.useState(false);return e.useEffect(()=>{let e=setTimeout(()=>o(true),as);return()=>clearTimeout(e)},[]),/* @__PURE__ */r.jsx(t.View,{style:l.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:se.loading,children:i?/* @__PURE__ */r.jsx(t.ActivityIndicator,{color:n.color.brandInk}):null})}function EmptyState({pet:e,petRef:petRef,onSelectPrompt:n,onVetPrep:l,vet:i,top:o,topCard:a,pendingCheckin:s,starterPrompts:u,emptyState:c,centered:d,renderEmptyHeader:p}){let{styles:f}=tu(),h=jp(),b=p===void 0?null:/* @__PURE__ */r.jsx(t.View,{testID:"everfur-empty-header",children:/* @__PURE__ */r.jsx(HostRender,{render:()=>p({ask:n}),fallback:null})});if(h!==null){let{minHeight:d,...p}=h.view(".ask-empty");/* @__PURE__ */
|
|
317
|
+
return r.jsxs(t.ScrollView,{contentContainerStyle:[p,f.homeEmpty],keyboardShouldPersistTaps:"handled",keyboardDismissMode:ry,nestedScrollEnabled:true,accessibilityLabel:se.empty,children:[o!=null?/* @__PURE__ */r.jsx(t.View,{style:h.view(".ask-top"),children:o}):null,s,a??null,b,
|
|
318
318
|
/* @__PURE__ */r.jsx(t.View,{style:h.view(".ask-start"),children:/* @__PURE__ */r.jsx(QuickPrompts,{pet:e,petRef:petRef,onSend:n,onVetPrep:l,vet:i,starterPrompts:u,emptyState:c,centered:true})})]})}
|
|
319
319
|
/* @__PURE__ */
|
|
320
|
-
return r.jsxs(t.ScrollView,{contentContainerStyle:f.emptyContent,keyboardShouldPersistTaps:"handled",keyboardDismissMode:
|
|
321
|
-
/* @__PURE__ */r.jsx(QuickPrompts,{pet:e,petRef:petRef,onSend:n,onVetPrep:l,vet:i,starterPrompts:u,emptyState:c,centered:d})]})}function FollowUps({prompts:e,onSelectPrompt:n,label:l}){let{styles:i}=
|
|
322
|
-
/* @__PURE__ */r.jsx(Text,{tier:"compact",style:i.followUpsHeading,accessibilityRole:"header",children:l??se.followUpsHeadingNative}),e.map((e,t)=>/* @__PURE__ */r.jsx(FollowUpRow,{prompt:e,index:t,onSelectPrompt:n},e))]})}function FollowUpRow({prompt:e,index:n,onSelectPrompt:l}){let{theme:i,styles:o}=
|
|
320
|
+
return r.jsxs(t.ScrollView,{contentContainerStyle:f.emptyContent,keyboardShouldPersistTaps:"handled",keyboardDismissMode:ry,nestedScrollEnabled:true,accessibilityLabel:se.empty,children:[o??null,s,a??null,b,
|
|
321
|
+
/* @__PURE__ */r.jsx(QuickPrompts,{pet:e,petRef:petRef,onSend:n,onVetPrep:l,vet:i,starterPrompts:u,emptyState:c,centered:d})]})}function FollowUps({prompts:e,onSelectPrompt:n,label:l}){let{styles:i}=tu();return e.length===0?null:/* @__PURE__ */r.jsxs(t.View,{style:i.followUps,children:[
|
|
322
|
+
/* @__PURE__ */r.jsx(Text,{tier:"compact",style:i.followUpsHeading,accessibilityRole:"header",children:l??se.followUpsHeadingNative}),e.map((e,t)=>/* @__PURE__ */r.jsx(FollowUpRow,{prompt:e,index:t,onSelectPrompt:n},e))]})}function FollowUpRow({prompt:e,index:n,onSelectPrompt:l}){let{theme:i,styles:o}=tu(),a=Ni(),s=Ji(a.followUpInMs,{delayMs:Hi(a,n)});/* @__PURE__ */
|
|
323
323
|
return r.jsx(t.Animated.View,{style:s,children:/* @__PURE__ */r.jsxs(PressScale,{onPress:()=>l(e),accessibilityRole:"button",accessibilityLabel:e,containerStyle:[o.followUpSlot,n>0?o.followUpSlotRuled:null],style:o.followUpRow,children:[
|
|
324
324
|
/* @__PURE__ */r.jsx(Text,{tier:"control",style:o.followUpText,children:e}),
|
|
325
|
-
/* @__PURE__ */r.jsx(PlusGlyph,{size:
|
|
325
|
+
/* @__PURE__ */r.jsx(PlusGlyph,{size:ny,color:i.slots.chip?.textColor??i.color.text.muted,strokeWidth:1.75})]})})}function ErrorState({error:e,onRetry:n,onAddPet:l}){let{styles:i}=tu(),o=cl(e)?mr(l):void 0,a=Dr(e);/* @__PURE__ */
|
|
326
326
|
return r.jsxs(t.View,{style:i.centered,accessible:true,accessibilityRole:"alert",children:[a!==null?/* @__PURE__ */r.jsx(Text,{style:i.errorText,testID:"everfur-chat-cap-reached",children:a.reached}):null,
|
|
327
|
-
/* @__PURE__ */r.jsx(Text,{style:i.errorText,children:e.displayMessage}),a!==null&&a.guidance!==null?/* @__PURE__ */r.jsx(Text,{style:i.errorText,testID:"everfur-chat-cap-guidance",children:a.guidance}):null,o!==void 0?/* @__PURE__ */r.jsx(t.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:se.addPet,style:i.retryButton,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:i.retryLabel,children:se.addPet})}):null,e.retryable?/* @__PURE__ */r.jsx(t.Pressable,{onPress:n,accessibilityRole:"button",accessibilityLabel:se.retry,style:i.retryButton,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:i.retryLabel,children:se.retry})}):null]})}function PopulatedState({messages:n,prompts:l,onSelectPrompt:i,isStreaming:o,onAnswerCheckin:a,onCopy:s,sentimentByMessage:u,onSentiment:c,feedbackNote:d,imagesByMessage:p,onPreview:f,notice:h,reconnecting:b,onRetry:g,onStartNew:m,petRef:petRef,onFindVet:y,vet:v,onOpenUrl:x,petName:w,actions:k,answerCards:S,threadTop:C,pendingCheckin:j,threadAside:R,threadAsideKey:T,followUpLabel:_,openingCard:z,earlier:I}){let{styles:P}=
|
|
328
|
-
return r.jsxs(t.ScrollView,{ref:O.ref,style:P.list,contentContainerStyle:S!==null?P.listContentCards:P.listContent,accessibilityLabel:se.transcript,keyboardShouldPersistTaps:"handled",keyboardDismissMode:
|
|
327
|
+
/* @__PURE__ */r.jsx(Text,{style:i.errorText,children:e.displayMessage}),a!==null&&a.guidance!==null?/* @__PURE__ */r.jsx(Text,{style:i.errorText,testID:"everfur-chat-cap-guidance",children:a.guidance}):null,o!==void 0?/* @__PURE__ */r.jsx(t.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:se.addPet,style:i.retryButton,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:i.retryLabel,children:se.addPet})}):null,e.retryable?/* @__PURE__ */r.jsx(t.Pressable,{onPress:n,accessibilityRole:"button",accessibilityLabel:se.retry,style:i.retryButton,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:i.retryLabel,children:se.retry})}):null]})}function PopulatedState({messages:n,prompts:l,onSelectPrompt:i,isStreaming:o,onAnswerCheckin:a,onCopy:s,sentimentByMessage:u,onSentiment:c,feedbackNote:d,imagesByMessage:p,onPreview:f,notice:h,reconnecting:b,onRetry:g,onStartNew:m,petRef:petRef,onFindVet:y,vet:v,onOpenUrl:x,petName:w,actions:k,answerCards:S,threadTop:C,pendingCheckin:j,threadAside:R,threadAsideKey:T,followUpLabel:_,openingCard:z,earlier:I}){let{styles:P}=tu(),E=Ni();oo(n.length,E);let M=e.useMemo(()=>yb(mb(n)),[n]),F=Wr(n,o),A=n[n.length-1],L=R??null,O=Zm(n,o,L===null?null:T??"shown"),V=to(n),D=n[0],B=z!==void 0&&D!==void 0&&D.role==="user"&&D.text.trim()===z.prompt?D.id:null;/* @__PURE__ */
|
|
328
|
+
return r.jsxs(t.ScrollView,{ref:O.ref,style:P.list,contentContainerStyle:S!==null?P.listContentCards:P.listContent,accessibilityLabel:se.transcript,keyboardShouldPersistTaps:"handled",keyboardDismissMode:ry,nestedScrollEnabled:true,onLayout:O.onLayout,onContentSizeChange:O.onContentSizeChange,onScroll:O.onScroll,scrollEventThrottle:ty,onScrollBeginDrag:O.onScrollBeginDrag,onScrollEndDrag:O.onScrollEnd,onMomentumScrollEnd:O.onScrollEnd,children:[C??null,j,I!==null?/* @__PURE__ */r.jsx(t.Pressable,{onPress:()=>{I.load()},disabled:I.loading,accessibilityRole:"button",accessibilityLabel:I.loading?Xl.loadingEarlier:Xl.earlier,accessibilityState:{disabled:I.loading,busy:I.loading},hitSlop:Ts,style:P.earlierButton,children:/* @__PURE__ */r.jsx(Text,{tier:"compact",style:P.earlierLabel,children:I.loading?Xl.loadingEarlier:Xl.earlier})}):null,n.map(e=>e.id===B&&z!==void 0?/* @__PURE__ */r.jsx(OpeningCard,{card:z.card,onLayout:O.rowLayout(e.id)},e.id):e.checkin&&M.has(e.id)?/* @__PURE__ */r.jsx(CheckinCard,{message:e,checkin:e.checkin,onAnswer:a,petRef:petRef,onFindVet:y,vet:v,onLayout:O.rowLayout(e.id)},e.id):/* @__PURE__ */r.jsx(MessageRow,{onLayout:O.rowLayout(e.id),message:e,revealing:o&&e===A&&e.role==="assistant",onCopy:s,sentiment:e.responseId===void 0?null:u[String(e.responseId)]??null,onSentiment:c,note:e.responseId!==void 0&&d?.responseId===String(e.responseId)?d.kind:null,images:p[e.id]??Xm,onPreview:f,onOpenUrl:x,entering:V(e.id),answerCards:S,messages:n},e.id)),b?/* @__PURE__ */r.jsx(Text,{tier:"compact",style:P.reconnectingCaption,accessibilityRole:"text",children:se.reconnecting}):null,F?/* @__PURE__ */r.jsx(TypingIndicator,{petName:w,inline:S!==null}):null,h!==null?/* @__PURE__ */r.jsx(TurnNoticeCard,{notice:h,onRetry:g,onStartNew:m}):null,S!==null?/* @__PURE__ */r.jsx(CardsFollowUps,{prompts:l,onSelectPrompt:i,label:_,actions:k,options:S}):/* @__PURE__ */r.jsx(FollowUps,{prompts:l,onSelectPrompt:i,label:_}),L!==null?/* @__PURE__ */r.jsx(t.View,{onLayout:O.asideLayout,children:L}):null]})}function TurnNoticeCard({notice:e,onRetry:n,onStartNew:l}){let{styles:i}=tu(),o=e.tone==="error";/* @__PURE__ */
|
|
329
329
|
return r.jsxs(t.View,{style:[i.turnNotice,o?i.turnNoticeError:null],accessible:true,accessibilityRole:"alert",children:[
|
|
330
330
|
/* @__PURE__ */r.jsx(Text,{tier:"control",style:[i.turnNoticeTitle,o?i.turnNoticeTitleError:null],children:e.title}),
|
|
331
331
|
/* @__PURE__ */r.jsx(Text,{tier:"compact",style:i.turnNoticeBody,children:e.body}),e.guidance!==void 0?/* @__PURE__ */r.jsx(Text,{tier:"compact",style:i.turnNoticeBody,testID:"everfur-chat-cap-guidance",children:e.guidance}):null,
|
|
332
|
-
/* @__PURE__ */r.jsx(t.Pressable,{onPress:e.action==="startNew"?l:n,accessibilityRole:"button",accessibilityLabel:e.actionLabel,hitSlop:
|
|
332
|
+
/* @__PURE__ */r.jsx(t.Pressable,{onPress:e.action==="startNew"?l:n,accessibilityRole:"button",accessibilityLabel:e.actionLabel,hitSlop:Ts,style:i.turnNoticeAction,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:i.turnNoticeActionLabel,children:e.actionLabel})})]})}var Xm=/* @__PURE__ */Object.freeze([]),ey=/* @__PURE__ */Object.freeze([]),ty=16,ry=t.Platform.OS==="ios"?"interactive":"on-drag",ny=18;function MessageRow({message:n,revealing:l,onCopy:i,sentiment:o,onSentiment:a,note:s,images:u,onPreview:c,onOpenUrl:d,onLayout:p,entering:f,answerCards:h,messages:b}){let{theme:g,styles:m}=tu(),y=Ni(),v=eo(f,y),x=no(n.text,l,y),w=n.role==="user",k=n.role==="vet",S=n.role==="assistant",C=Ei(),j=S&&!l?C:void 0,R=j!==void 0&&rg(n.text,j),T=S&&!g.meta.hidePoweredBy,_=w?se.senderUser:k?Yr(n):T?se.assistantName:se.senderAssistant,z=k?Sb(n.createdAt):null,I=e.useCallback(e=>a(n,e),[a,n]),P=n.pending!==true,E=S&&g.meta.assistantAvatarUrl!==null?/* @__PURE__ */r.jsx(AssistantSender,{avatarUrl:g.meta.assistantAvatarUrl,named:T,styles:m}):T?h!==null?/* @__PURE__ */r.jsx(CardsByline,{label:se.assistantName}):/* @__PURE__ */r.jsx(Text,{tier:"control",style:m.assistantName,children:se.assistantName}):null,M=h!==null;return S&&h!==null?/* @__PURE__ */r.jsx(t.Animated.View,{style:[m.rowBlock,v],onLayout:p,accessibilityLabel:`${_}: ${n.text}`,children:/* @__PURE__ */r.jsx(CardsAnswer,{message:n,text:x,streaming:l,messages:b,options:h,sentiment:o,onSentiment:n.responseId===void 0?void 0:I,sender:E,onOpenUrl:d,footer:e=>/* @__PURE__ */r.jsx(MessageFooter,{message:n,onCopy:i,sentiment:o,onSentiment:e&&n.responseId!==void 0?I:void 0,note:s})})}):/* @__PURE__ */r.jsxs(t.View,{style:[m.rowBlock,w?m.rowBlockUser:m.rowBlockAssistant],onLayout:p,children:[
|
|
333
333
|
/* @__PURE__ */r.jsx(t.View,{style:[m.row,w?m.rowUser:m.rowAssistant],accessible:!R,accessibilityRole:R?void 0:"text",accessibilityLabel:R?void 0:`${_}: ${n.text}`,accessibilityState:n.pending===true?{busy:true}:void 0,children:/* @__PURE__ */r.jsxs(t.Animated.View,{style:[m.bubble,M?m.bubbleCards:null,w?m.bubbleSideUser:null,v],children:[E,k?/* @__PURE__ */r.jsxs(t.View,{style:m.vetHeader,children:[
|
|
334
334
|
/* @__PURE__ */r.jsx(Text,{tier:"control",style:m.vetSender,children:_}),z!==null?/* @__PURE__ */r.jsx(Text,{tier:"compact",style:m.vetTime,children:z}):null]}):null,
|
|
335
335
|
/* @__PURE__ */r.jsxs(t.View,{style:[w?m.bubbleUser:k?m.bubbleVet:m.bubbleAssistant,w&&M?m.bubbleUserCards:null,n.pending?m.bubblePending:null],children:[w&&u.length>0?/* @__PURE__ */r.jsx(SentImages,{images:u,onPreview:e=>c({uri:e.uri,label:e.filename})}):null,
|
|
336
|
-
/* @__PURE__ */r.jsx(Text,{style:w?M?[m.bubbleTextUser,m.bubbleTextUserCards]:m.bubbleTextUser:k?m.bubbleTextVet:m.bubbleTextAssistant,children:S?
|
|
336
|
+
/* @__PURE__ */r.jsx(Text,{style:w?M?[m.bubbleTextUser,m.bubbleTextUserCards]:m.bubbleTextUser:k?m.bubbleTextVet:m.bubbleTextAssistant,children:S?ng(x,{bold:m.bubbleBold,italic:m.bubbleItalic,code:m.bubbleCode},j):n.text})]})]})}),S&&!l?/* @__PURE__ */r.jsx(ServerCardsSlot,{message:n}):null,S&&!l?/* @__PURE__ */r.jsx(CitationCards,{citations:n.citations,onOpenUrl:d}):null,P&&!(w&&h!==null)?/* @__PURE__ */r.jsx(MessageFooter,{message:n,onCopy:i,sentiment:o,onSentiment:n.responseId===void 0?void 0:I,note:s}):null]})}var ly=/* @__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"&&ly.has(t.urgencyLevel))}var NO_SNAPSHOT2=()=>null;function iy(){let{runtime:t}=me(),r=t.entitlements??null,n=e.useCallback(e=>r===null?()=>{}:r.subscribe(e),[r]),l=r===null?NO_SNAPSHOT2:r.getSnapshot,i=e.useSyncExternalStore(n,l,l);return e.useMemo(()=>i!==null&&decideCapability("texting",i.decisions,{isPending:i.isPending}).enabled,[i])}var oy=/* @__PURE__ */Object.freeze({runner:null,line:null,entry:null,stage:null,headerEntry:null});function ay(t,n,l=false){let[i,o]=e.useState(null);if(!t)return oy;let s=/* @__PURE__ */r.jsx(AskRunner,{ready:textingAskThreadReady(n),onAsk:o,entry:l}),u=l&&i!==null&&i.canOpen?{label:a.textingAskLines(i).accept,onOpen:i.open}:null;if(i===null||i.stage==="hidden"||i.stage==="dismissed")return{runner:s,line:null,entry:null,stage:null,headerEntry:u};let c=a.textingAskLines(i),d=/* @__PURE__ */r.jsx(AskLine,{stage:i.stage,text:i.stage==="verified"?c.verified:c.line,accept:c.accept,dismiss:c.dismiss,onAccept:i.accept,onDismiss:i.dismiss}),p=i.stage==="enrolling"?/* @__PURE__ */r.jsx(a.ChatTextingAskComposer,{ask:i}):null;return{runner:s,line:d,entry:p,stage:i.stage,headerEntry:u}}function AskRunner({ready:t,onAsk:n,entry:l}){let{userRef:userRef}=me(),i=iy(),o=userRef!==null&&i;return e.useEffect(()=>{o||n(null)},[o,n]),o?/* @__PURE__ */r.jsx(a.ChatTextingAskController,{enabled:true,ready:t,onAsk:n,entry:l}):null}function AskLine({stage:e,text:n,accept:l,dismiss:i,onAccept:o,onDismiss:a}){let{theme:s,styles:u}=tu(),c=!s.meta.hidePoweredBy,d=c?se.assistantName:se.senderAssistant,p=s.meta.assistantAvatarUrl!==null?/* @__PURE__ */r.jsx(AssistantSender,{avatarUrl:s.meta.assistantAvatarUrl,named:c,styles:u}):c?/* @__PURE__ */r.jsx(Text,{tier:"control",style:u.assistantName,children:se.assistantName}):null;/* @__PURE__ */
|
|
337
337
|
return r.jsxs(t.View,{style:[u.rowBlock,u.rowBlockAssistant],testID:`everfur-texting-ask-${e}`,children:[
|
|
338
338
|
/* @__PURE__ */r.jsx(t.View,{style:[u.row,u.rowAssistant],accessible:true,accessibilityRole:"text",accessibilityLabel:`${d}: ${n}`,children:/* @__PURE__ */r.jsxs(t.View,{style:u.bubble,children:[p,
|
|
339
|
-
/* @__PURE__ */r.jsx(t.View,{style:u.bubbleAssistant,children:/* @__PURE__ */r.jsx(Text,{style:u.bubbleTextAssistant,children:n})})]})}),e==="offered"?/* @__PURE__ */r.jsx(t.View,{style:u.askChips,children:[{label:l,onPress:o,testID:"everfur-texting-ask-accept"},{label:i,onPress:a,testID:"everfur-texting-ask-dismiss"}].map(e=>/* @__PURE__ */r.jsx(PressScale,{onPress:e.onPress,accessibilityRole:"button",accessibilityLabel:e.label,style:u.askChip,testID:e.testID,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:u.askChipText,children:e.label})},e.testID))}):null]})}function
|
|
340
|
-
return r.jsx(CapabilityGate,{capability:"chat",style:t,...n?{renderPending:n}:{},children:/* @__PURE__ */r.jsx(MessageLinksScope,{linkHosts:e.linkHosts,onOpenUrl:e.onOpenUrl,children:/* @__PURE__ */r.jsx(ChatBody,{...e})})})}function
|
|
341
|
-
return r.jsx(ChatSurface,{...t,settings:o})}function ChatBodyInProvider({activePet:t,telemetry:n,...l}){let{presentation:i,isLocked:isLocked}=Lr(
|
|
342
|
-
return r.jsx(ChatSurface,{...l,settings:d})}function ChatSurface({settings:l,petRef:petRef,conversationId:conversationId,style:i,renderPending:o,onCopy:a,onPetChange:s,onVetPrep:u,onFindVet:c,renderVetAction:d,attachments:p,pet:f,onAddPet:h,checkinTarget:b,handoffToken:g,initialAsk:m,initialAskKey:y,composerSeed:v,lifecycle:x,refreshIntervalMs:w,refreshesBlankThread:k,openUnreadOnRefresh:S,draftStore:C,vetReturnTo:j,vetUsState:R,vetPrefer:T,onOpenUrl:_,keyboardVerticalOffset:z,topCard:I,onOpenHealthPlan:P,answerCards:E,historySheet:M,historyBar:F,starterPrompts:A,emptyState:L,header:O=true,textingEntry:V=true,renderEmptyHeader:D,followUpPolicy:B,initialAskCard:H}){let{presentation:W,isLocked:isLocked,planPage:N,planPetRef:U}=l,{theme:$,styles:q}=
|
|
343
|
-
/* @__PURE__ */r.jsx(TopCard,{card
|
|
339
|
+
/* @__PURE__ */r.jsx(t.View,{style:u.bubbleAssistant,children:/* @__PURE__ */r.jsx(Text,{style:u.bubbleTextAssistant,children:n})})]})}),e==="offered"?/* @__PURE__ */r.jsx(t.View,{style:u.askChips,children:[{label:l,onPress:o,testID:"everfur-texting-ask-accept"},{label:i,onPress:a,testID:"everfur-texting-ask-dismiss"}].map(e=>/* @__PURE__ */r.jsx(PressScale,{onPress:e.onPress,accessibilityRole:"button",accessibilityLabel:e.label,style:u.askChip,testID:e.testID,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:u.askChipText,children:e.label})},e.testID))}):null]})}function sy(){let t=/* @__PURE__ */Symbol.for("@everfur/sdk#SdkSurfaceHooks@v1"),r=globalThis;return r[t]??(r[t]=e.createContext(null))}var uy=/* @__PURE__ */sy();function cy(e){return typeof e=="object"&&e!==null&&e.ok===true}function dy(e){if(typeof e!="object"||e===null)return null;let t=e;return t.ok!==false||typeof t.error!="object"||t.error===null?null:Ye(t.error)}function py(t){let r=e.useContext(uy),n=r?.onMessageSent,l=r?.onFreeCapReached,i=e.useCallback((...e)=>{let r=t(...e);return Promise.resolve(r).then(e=>{try{if(cy(e)){n?.();return}let t=l===void 0?null:dy(e);t!==null&&l?.(t)}catch{}},()=>{}),r},[t,n,l]);return n===void 0&&l===void 0?t:i}function EverfurChatCore(e){let{style:t,renderPending:n}=e;/* @__PURE__ */
|
|
340
|
+
return r.jsx(CapabilityGate,{capability:"chat",style:t,...n?{renderPending:n}:{},children:/* @__PURE__ */r.jsx(MessageLinksScope,{linkHosts:e.linkHosts,onOpenUrl:e.onOpenUrl,children:/* @__PURE__ */r.jsx(ChatBody,{...e})})})}function fy(){try{return me()}catch{return null}}function hy(e){return Or({...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=fy();return t===null?/* @__PURE__ */r.jsx(ChatBodyAlone,{...e}):/* @__PURE__ */r.jsx(ChatBodyInProvider,{...e,activePet:t.activePet,telemetry:t.runtime.registry?.services?.telemetry??null})}function ChatBodyAlone(t){let n=hy(t),l=JSON.stringify(n),i=t.petRef??null,o=e.useMemo(()=>({presentation:resolvePresentation({server:null,locked:null,client:n}),isLocked:()=>false,planPage:null,planPetRef:i,inProvider:false,telemetry:null}),[l,i]);/* @__PURE__ */
|
|
341
|
+
return r.jsx(ChatSurface,{...t,settings:o})}function ChatBodyInProvider({activePet:t,telemetry:n,...l}){let{presentation:i,isLocked:isLocked}=Lr(hy(l)),o=zr("healthPlan"),a=i.chatTopCard==="focus"&&l.topCard===void 0&&o,s=l.petRef??t??null,u=useHealthPlanPage({petRef:s,enabled:a}),c=a&&u.phase==="ready"?u.page:null,d=e.useMemo(()=>({presentation:i,isLocked:isLocked,planPage:c,planPetRef:s,inProvider:true,telemetry:n}),[i,isLocked,c,s,n]);/* @__PURE__ */
|
|
342
|
+
return r.jsx(ChatSurface,{...l,settings:d})}function ChatSurface({settings:l,petRef:petRef,conversationId:conversationId,style:i,renderPending:o,onCopy:a,onPetChange:s,onVetPrep:u,onFindVet:c,renderVetAction:d,attachments:p,pet:f,onAddPet:h,checkinTarget:b,handoffToken:g,initialAsk:m,initialAskKey:y,composerSeed:v,lifecycle:x,refreshIntervalMs:w,refreshesBlankThread:k,openUnreadOnRefresh:S,draftStore:C,vetReturnTo:j,vetUsState:R,vetPrefer:T,onOpenUrl:_,keyboardVerticalOffset:z,topCard:I,onOpenHealthPlan:P,answerCards:E,historySheet:M,historyBar:F,starterPrompts:A,emptyState:L,header:O=true,textingEntry:V=true,renderEmptyHeader:D,followUpPolicy:B,initialAskCard:H}){let{presentation:W,isLocked:isLocked,planPage:N,planPetRef:U}=l,{theme:$,styles:q}=tu(),G=Cp()??(W.chatAnswerStyle==="cards"?vh:null),K=e.useMemo(()=>G===null?null:G($),[G,$]),Y=useHostPoweredBy(),Q=Ni(),Z=e.useMemo(()=>Qr(petRef,conversationId),[petRef,conversationId]),J=useEverfurChat(Z),X=py(J.send),ee=e.useMemo(()=>X===J.send?J:{...J,send:X},[J,X]),te=Vr(ee),re=db(),ne=si(ee),le=n.useSafeAreaInsets(),ie=Hr(ee,"web"),oe=e.useMemo(()=>c===void 0?void 0:()=>{br(c,"emergency")},[c]),ae=e.useMemo(()=>j===void 0&&R===void 0&&T===void 0?void 0:{returnTo:j,usState:R,prefer:T},[j,R,T]),ue=lp(re.pets,ee.petRef),[ce,de]=e.useState(null),pe=e.useMemo(()=>{let e=hi(ee.messages,ue?.name??null);return e?.level==="schedule_soon"&&e.messageId===ce?null:e},[ee.messages,ue?.name,ce]),fe=gi(pe);fb(ee),oo(fe.showBanner,Q);let he=fy(),be=Ql(g,he);Jl(ee.openCheckin,b??be,{petRef:ee.petRef,pinned:petRef!==void 0,ready:!ee.isBootstrapping,selectPet:e=>{re.setActivePet(e),br(s,e)}}),xl(ee.askEverfur,ee.isBootstrapping,m,y);let ge=e.useMemo(()=>vl(v),[v]),me=e.useMemo(()=>vl(m),[m]),ye=e.useMemo(()=>H!==void 0&&me!==null?{card:H,prompt:me}:void 0,[H,me]),ve=e.useMemo(()=>x===void 0?createAppStateLifecycle():x??void 0,[x]);El(ve,{conversationId:ee.conversationId===null?null:String(ee.conversationId),isTurnInFlight:ee.isStreaming,refreshesBlankThread:k===true||S===true,refresh:ee.refreshActiveThread===void 0?void 0:()=>ee.refreshActiveThread?.(jl(S===true,Rl(ve,mo)))??Promise.resolve()},{intervalMs:w===void 0?3e4:w,isVisibleFallback:mo}),Tl({isStreaming:ee.isStreaming,status:ee.status,conversationId:ee.conversationId===null?null:String(ee.conversationId),unreadCount:ee.unreadCount,markRead:ee.markRead},()=>Rl(ve,mo));let xe=ee.pendingCheckin??null,we=xe===null?null:/* @__PURE__ */r.jsx(t.View,{testID:"everfur-pending-checkin",accessibilityLiveRegion:"polite",children:/* @__PURE__ */r.jsx(CheckinCard,{message:xe.message,checkin:xe.checkin,onAnswer:ee.petRef?ee.answerCheckin:null,petRef:ee.petRef,onFindVet:oe,vet:ae,onOpen:()=>{ee.resumeConversation(xe.conversationId)}})}),ke=(ee.hasUnreadThreads??false)||ne.rows.some(e=>e.unreadCount!==null&&e.unreadCount>0)||(ee.unreadCount??0)>0,Se=hl(ee.messages),[Ce,je]=e.useState(null),Re=e.useCallback(()=>je(null),[]),[Te,_e]=e.useState(null),[ze,Ie]=e.useState(null),Pe=e.useRef(null);e.useEffect(()=>()=>{Pe.current&&clearTimeout(Pe.current)},[]);let Ee=e.useCallback((e,t)=>{Ie({responseId:String(e),kind:t}),Pe.current&&clearTimeout(Pe.current),Pe.current=t==="thanks"?setTimeout(()=>{Ie(null),Pe.current=null},ss):null},[]),Me=e.useCallback((e,t)=>{let r=e.responseId;if(r===void 0)return;let n=ee.sentimentByMessage[String(r)];Ie(e=>e?.responseId===String(r)?null:e),ee.feedback(r,t).then(e=>{e.ok||Ee(r,"failed")}),t==="down"&&n!=="down"&&_e(r)},[ee,Ee]),Fe=e.useCallback(async(e,t)=>Te===null||!(e==null&&t===null?{ok:true}:await ee.feedback(Te,"down",e??"other",t)).ok?false:(_e(null),Ee(Te,"thanks"),true),[ee,Te,Ee]),Ae=e.useCallback(()=>_e(null),[]),Le=e.useCallback(e=>{ee.send(e)},[ee.send]),Oe=e.useMemo(()=>_===void 0?void 0:e=>{br(_,e,"citation")},[_]),Ve=t.Platform.OS==="ios"?"padding":void 0,De=_h(z,Ve!==void 0),Be=De.topInWindow===null?le.top:Math.max(0,le.top-De.topInWindow),He=Ih(),We=e.useMemo(()=>P===void 0?void 0:()=>{br(P,U)},[P,U]),Ne=e.useMemo(()=>({petRef:ee.petRef,vet:ae,cover:de}),[ee.petRef,ae]),Ue=e.useMemo(()=>I===void 0?healthPlanTopCard(N,{onOpenPlan:We}):void 0,[I,N,We]),$e=W.chatTopCard==="focus"?I??Ue:void 0,[qe,Ge]=e.useState(true),Ke=e.useCallback(e=>{ee.send(e)},[ee.send]),Ye=e.useMemo(()=>Xr(B,W,isLocked("chatFollowUpCount")),[B,W,isLocked]),Qe=W.chatAnswerStyle==="cards",Ze=e.useMemo(()=>Qe&&ee.messages.length===0?my(ee.suggestedPrompts):void 0,[Qe,ee.messages.length,ee.suggestedPrompts]),Je=W.chatHistoryStyle==="sheet",Xe=ee.messages.length===0,et=$e!==void 0?/* @__PURE__ */r.jsx(TopCardPill,{card:$e,open:qe,onOpenChange:Ge}):null,tt=F??(O?void 0:yy),rt=tt!==void 0?/* @__PURE__ */r.jsx(HistoryBar,{bar:tt,history:ne,empty:Xe,unread:ke,extra:et}):null,nt=W.chatHistoryBar==="scroll"&&(te==="empty"||te==="populated"),lt=$e===void 0?null:/* @__PURE__ */r.jsxs(r.Fragment,{children:[
|
|
343
|
+
/* @__PURE__ */r.jsx(TopCard,{card:$e,open:qe,onOpenChange:Ge,ask:Ke}),tt===void 0?et:null]}),it=tt!==void 0,ot=ne.load,at=ne.open;e.useEffect(()=>{it&&!at&&ot()},[it,at,ee.conversationId,ot]);let st={send:ee.send,stop:ee.stop,isStreaming:ee.isStreaming,conversationId:ee.conversationId,seed:ge,draftStore:C,onStage:Se.stage,onPreview:je,petName:ue?.name??null,petBreed:ue?.breed??null,compact:W.chatComposerStyle==="compact",petPlaceholder:W.chatComposerPlaceholder==="pet_name",dimEmptySend:W.chatSendButton==="dim_when_empty",mood:vy(te,fe.source?.level??null),dictation:W.chatComposerMic,telemetry:l.telemetry},ut=ay(W.chatTextingAsk&&l.inProvider,ee,V),ct=p!==void 0&&W.chatComposerUpload,dt=!W.chatGeneralBanner&&fe.source?.level==="general";
|
|
344
344
|
/* @__PURE__ */
|
|
345
|
-
return r.jsx(
|
|
346
|
-
/* @__PURE__ */r.jsx(KeyboardOffsetProbe,{probeRef:
|
|
347
|
-
/* @__PURE__ */r.jsxs(SdkTabletColumn,{children:[O?/* @__PURE__ */r.jsx(ChatHeader,{pets:re,petRef:ee.petRef,historyUnread:
|
|
348
|
-
/* @__PURE__ */r.jsx(t.View,{style:q.body,children:
|
|
349
|
-
/* @__PURE__ */r.jsx(FeedbackReasons,{visible:
|
|
350
|
-
/* @__PURE__ */r.jsx(AttachmentImageLightbox,{uri:
|
|
351
|
-
/* @__PURE__ */r.jsx(TelevetHostOutlet,{})]})})}function PetSetupNotice({petRef:petRef,pet:e,onRegistered:n}){let{styles:l}=
|
|
345
|
+
return r.jsx(Sp.Provider,{value:K,children:/* @__PURE__ */r.jsxs(t.KeyboardAvoidingView,{style:[q.container,{paddingTop:Be},i],behavior:Ve,...De.avoidingProps,children:[
|
|
346
|
+
/* @__PURE__ */r.jsx(KeyboardOffsetProbe,{probeRef:De.probeRef}),
|
|
347
|
+
/* @__PURE__ */r.jsxs(SdkTabletColumn,{children:[O?/* @__PURE__ */r.jsx(ChatHeader,{pets:re,petRef:ee.petRef,historyUnread:ke,onOpenHistory:ne.show,onNewChat:ne.newConversation,onPetChange:s,onAddPet:h,vet:ae,textingEntry:ut.headerEntry}):null,f!==void 0?/* @__PURE__ */r.jsx(PetSetupNotice,{petRef:petRef??null,pet:f,onRegistered:re.refresh}):null,!O&&ut.headerEntry!==null?/* @__PURE__ */r.jsx(TextingEntryRow,{entry:ut.headerEntry,place:"thread"}):null,nt?null:rt,dt?null:/* @__PURE__ */r.jsx(UrgencyBanner,{surface:fe,petRef:ee.petRef,renderVetAction:d,onFindVet:c,vet:ae,compact:He}),
|
|
348
|
+
/* @__PURE__ */r.jsx(t.View,{style:q.body,children:/* @__PURE__ */r.jsx(vi.Provider,{value:Ne,children:Jm(te,ee,{notice:ie,vet:ae,onCheckinFindVet:oe,onSelectPrompt:Le,renderPending:o,shownPet:ue,onVetPrep:u,onCopy:a,onSentiment:Me,feedbackNote:ze,imagesByMessage:Se.byMessage,onPreview:je,onAddPet:h,onOpenUrl:Oe,threadTop:nt?rt:null,pendingCheckin:we,topCard:lt,starterPrompts:A??Ze,emptyState:L,emptyCentered:W.chatAnswerStyle==="cards",followUpPolicy:Ye,answerCards:W.chatAnswerStyle==="cards"?E??by:null,threadAside:ut.line,threadAsideKey:ut.stage,renderEmptyHeader:D,openingCard:ye})})}),ut.runner,ut.entry!==null?/* @__PURE__ */r.jsx(t.View,{style:q.composerOuter,children:/* @__PURE__ */r.jsx(t.View,{style:q.askEntry,children:ut.entry})}):ct&&p!==void 0?/* @__PURE__ */r.jsx(ComposerWithAttachments,{...st,attachments:p}):/* @__PURE__ */r.jsx(Composer,{...st,attachments:null}),$.meta.hidePoweredBy||Y?null:/* @__PURE__ */r.jsx(Text,{tier:"compact",style:q.poweredBy,accessibilityRole:"text",accessibilityLabel:se.poweredBy,children:se.poweredBy})]}),Je?/* @__PURE__ */r.jsx(HistorySheet,{chat:ee,history:ne,sheet:M}):/* @__PURE__ */r.jsx(HistoryDrawer,{chat:ee,history:ne}),
|
|
349
|
+
/* @__PURE__ */r.jsx(FeedbackReasons,{visible:Te!==null,onSubmit:Fe,onSkip:Ae}),
|
|
350
|
+
/* @__PURE__ */r.jsx(AttachmentImageLightbox,{uri:Ce?.uri??null,label:Ce?.label??"",onClose:Re}),
|
|
351
|
+
/* @__PURE__ */r.jsx(TelevetHostOutlet,{})]})})}function PetSetupNotice({petRef:petRef,pet:e,onRegistered:n}){let{styles:l}=tu(),i=pl(petRef,e,n);return i.status!=="failed"||i.error===null?null:/* @__PURE__ */r.jsxs(t.View,{style:l.setupNotice,accessible:true,accessibilityRole:"alert",children:[
|
|
352
352
|
/* @__PURE__ */r.jsx(Text,{tier:"compact",style:l.setupNoticeText,children:i.error.displayMessage}),
|
|
353
|
-
/* @__PURE__ */r.jsx(t.Pressable,{onPress:i.retry,accessibilityRole:"button",accessibilityLabel:se.retry,hitSlop:
|
|
354
|
-
return r.jsx(EverfurChatCore,{...e})}var
|
|
353
|
+
/* @__PURE__ */r.jsx(t.Pressable,{onPress:i.retry,accessibilityRole:"button",accessibilityLabel:se.retry,hitSlop:Ts,children:/* @__PURE__ */r.jsx(Text,{tier:"control",style:l.setupNoticeAction,children:se.retry})})]})}var by=/* @__PURE__ */Object.freeze({}),gy=3;function my(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===gy)break}return t.length>0?/* @__PURE__ */Object.freeze(t):void 0}var yy=/* @__PURE__ */Object.freeze({chats:Xl.heading,newChat:Xl.newChat});function vy(e,t){return t==="emergency"?"urgent":e==="populated"?"followUp":"ask"}function EverfurChat(e){/* @__PURE__ */
|
|
354
|
+
return r.jsx(EverfurChatCore,{...e})}var xy=/* @__PURE__ */Object.freeze({hasUnread:null,unreadCount:null,conversationId:null,petRef:null}),NO_SUBSCRIPTION=()=>()=>{};function wy(t,r){let{runtime:n,userRef:userRef,activePet:l,scopeEpoch:i}=me(),o=n.unread??null,petRef=t===void 0?l:t,a=e.useCallback(e=>o===null?NO_SUBSCRIPTION():o.subscribe(e),[o]),s=e.useCallback(()=>o===null||userRef===null?xy:o.get(petRef),[o,userRef,petRef]),u=e.useSyncExternalStore(a,s,s),c=e.useCallback(()=>o===null||userRef===null?Promise.resolve():o.refresh(petRef),[o,userRef,petRef]);return e.useEffect(()=>{c()},[c,i]),El(r,{conversationId:null,isTurnInFlight:false,refreshesBlankThread:true,refresh:c}),e.useMemo(()=>({...u,refresh:c}),[u,c])}function useEverfurUnread(t={}){let{lifecycle:r}=t,n=e.useMemo(()=>r===void 0?createAppStateLifecycle():r??void 0,[r]);return wy(t.petRef,n)}exports.EverfurChat=EverfurChat;exports.EverfurPoweredBy=EverfurPoweredBy;exports.chatHandoffTokenFromUrl=chatHandoffTokenFromUrl;exports.createAppStateLifecycle=createAppStateLifecycle;exports.createRnChatAttachmentTransport=createRnChatAttachmentTransport;exports.registerEverfurChatCards=registerEverfurChatCards;exports.registerEverfurDictation=registerEverfurDictation;exports.useChatAttachments=useChatAttachments;exports.useEverfurChat=useEverfurChat;exports.useEverfurPets=useEverfurPets;exports.useEverfurUnread=useEverfurUnread;exports.useHostPoweredBy=useHostPoweredBy;
|