@everfur/sdk 0.15.1 → 0.16.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/CHANGELOG.md +138 -0
- package/README.md +3 -1
- package/chat/lite/package.json +8 -0
- package/dist/Chat.d-CzI2228d.d.ts +11 -0
- package/dist/Chat.d-D3ScVQ22.d.cts +11 -0
- package/dist/{DepthViews.d-PuBGdAYk.d.cts → DepthViews.d-6U4QqaW3.d.cts} +1 -1
- package/dist/{DepthViews.d--1daZblh.d.cts → DepthViews.d-BLx_ZTwa.d.cts} +1 -1
- package/dist/{DepthViews.d-CKTnEeUo.d.ts → DepthViews.d-Cwbel5o4.d.ts} +1 -1
- package/dist/{DepthViews.d-BuEWI6Ln.d.ts → DepthViews.d-DVIydPLt.d.ts} +1 -1
- package/dist/{RecordsPage.d-CBB8sfoY.d.ts → RecordsPage.d-Bwalb0wU.d.ts} +1 -1
- package/dist/{RecordsPage.d-Dq5gpQG0.d.cts → RecordsPage.d-Do7T8Fns.d.cts} +1 -1
- package/dist/animations/index.d.cts +5 -5
- package/dist/animations/index.d.ts +5 -5
- package/dist/{Chat.d-BlsnQwCQ.d.ts → appStateLifecycle.d-Bd-rNy6K.d.ts} +62 -144
- package/dist/{Chat.d-BO5iJsR2.d.cts → appStateLifecycle.d-_mh4CEAq.d.cts} +62 -144
- package/dist/attachmentTransport.d-Syrvv5zH.d.ts +41 -0
- package/dist/attachmentTransport.d-r1XCCdUB.d.cts +41 -0
- package/dist/{attachments.d-DFP9yvz9.d.ts → attachments.d-BiBGBE4o.d.ts} +24 -6
- package/dist/{attachments.d-C2nkIyDB.d.ts → attachments.d-CyB8hzDo.d.ts} +2 -2
- package/dist/{attachments.d-DRHsJkni.d.cts → attachments.d-GlO5UP7H.d.cts} +24 -6
- package/dist/{attachments.d-DRUC35Ti.d.cts → attachments.d-Y-qvSHVU.d.cts} +2 -2
- package/dist/{bookingCopy.d-bF_QknDC.d.cts → bookingCopy.d-BIaCiRuW.d.cts} +2 -2
- package/dist/{bookingCopy.d-CFL-1Be2.d.ts → bookingCopy.d-DgWvNKD5.d.ts} +2 -2
- package/dist/{casesRepository.d-C__BnffJ.d.ts → casesRepository.d-BW8DTYeN.d.ts} +1 -1
- package/dist/{casesRepository.d-BMOnT1fg.d.cts → casesRepository.d-_0AO2YrL.d.cts} +1 -1
- package/dist/chat/index.cjs +246 -231
- package/dist/chat/index.d.cts +16 -49
- package/dist/chat/index.d.ts +16 -49
- package/dist/chat/index.js +246 -231
- package/dist/chat/lite/index.cjs +430 -0
- package/dist/chat/lite/index.d.cts +35 -0
- package/dist/chat/lite/index.d.ts +35 -0
- package/dist/chat/lite/index.js +430 -0
- package/dist/client/index.cjs +4 -4
- package/dist/client/index.d.cts +6 -6
- package/dist/client/index.d.ts +6 -6
- package/dist/client/index.js +4 -4
- package/dist/{clinicBatch.d-D68RYvc3.d.ts → clinicBatch.d-BXwATY3-.d.ts} +2 -2
- package/dist/{clinicBatch.d-C5deJ4xY.d.cts → clinicBatch.d-BcuSaOkv.d.cts} +2 -2
- package/dist/{config.d-BQgrIDdu.d.cts → config.d-D1xcxALX.d.cts} +1 -1
- package/dist/{config.d-XSMThgVj.d.ts → config.d-jTVsAeky.d.ts} +1 -1
- package/dist/consent/index.d.cts +5 -5
- package/dist/consent/index.d.ts +5 -5
- package/dist/{context.d-Ba8YyJpk.d.cts → context.d-C3x-z665.d.cts} +5 -5
- package/dist/{context.d-xoh5vmxS.d.ts → context.d-goZeZO2I.d.ts} +5 -5
- package/dist/{copy.d-Cq-s-UUv.d.cts → copy.d-DPwFY4r5.d.cts} +2 -2
- package/dist/{copy.d-HV9fU5kh.d.ts → copy.d-yfJv7fl6.d.ts} +2 -2
- package/dist/core/index.cjs +10 -10
- package/dist/core/index.d.cts +13 -13
- package/dist/core/index.d.ts +13 -13
- package/dist/core/index.js +10 -10
- package/dist/{depth.d-D7kKiYl7.d.ts → depth.d-SJzknw_P.d.ts} +2 -2
- package/dist/{depth.d-DYnkz8Re.d.cts → depth.d-e_8_icip.d.cts} +2 -2
- package/dist/{entitlementRepository.d-DmnUZLl_.d.ts → entitlementRepository.d-BNgZhwoE.d.ts} +2 -2
- package/dist/{entitlementRepository.d-B_kEPLhz.d.cts → entitlementRepository.d-C_LdzINM.d.cts} +2 -2
- package/dist/{focus.d-BHm_QtQ9.d.cts → focus.d-CXpIkIuU.d.cts} +3 -3
- package/dist/{focus.d-CjL6Cj0m.d.ts → focus.d-DzIgOqNB.d.ts} +3 -3
- package/dist/health-plan/index.cjs +136 -133
- package/dist/health-plan/index.d.cts +77 -24
- package/dist/health-plan/index.d.ts +77 -24
- package/dist/health-plan/index.js +136 -133
- package/dist/{idempotency.d-BSRK8od4.d.cts → idempotency.d-0biUa_Vw.d.cts} +1 -1
- package/dist/{idempotency.d-CFc4CCc9.d.ts → idempotency.d-DcqIqmf9.d.ts} +1 -1
- package/dist/{identity.d-Be2Es9Td.d.ts → identity.d-BEJcHY-5.d.ts} +1 -1
- package/dist/{identity.d-HbwYQ4-z.d.cts → identity.d-COcNGuCJ.d.cts} +1 -1
- package/dist/index.cjs +245 -230
- package/dist/index.d.cts +15 -12
- package/dist/index.d.ts +15 -12
- package/dist/index.js +246 -231
- package/dist/{introEvents.d-Dr34KIaD.d.cts → introEvents.d-D8N9bbGO.d.cts} +1 -1
- package/dist/{introEvents.d-DflJ6J9H.d.ts → introEvents.d-GCdyQyUG.d.ts} +1 -1
- package/dist/notifications/index.d.cts +4 -4
- package/dist/notifications/index.d.ts +4 -4
- package/dist/{optInView.d-3mbj1mR6.d.ts → optInView.d-CY2IueSZ.d.ts} +2 -2
- package/dist/{optInView.d-D23o1gtT.d.cts → optInView.d-DVuuWDRw.d.cts} +2 -2
- package/dist/{parse.d-BERabxHw.d.ts → parse.d--ztmWIIP.d.ts} +1 -1
- package/dist/{parse.d-4lUXdmvY.d.cts → parse.d-B-WrkW2C.d.cts} +1 -1
- package/dist/{pets.d-CHU0UbXt.d.cts → pets.d-BSW0oEYx.d.cts} +1 -1
- package/dist/{pets.d-D_ayuqjp.d.ts → pets.d-DwsImaHU.d.ts} +1 -1
- package/dist/{petsRepository.d-Bwfe8yuR.d.cts → petsRepository.d-BQfWC3d4.d.cts} +1 -1
- package/dist/{petsRepository.d-DUaAWoTv.d.ts → petsRepository.d-BudLFHVe.d.ts} +1 -1
- package/dist/photo/index.cjs +2 -2
- package/dist/photo/index.js +2 -2
- package/dist/{ports.d-DzEJMVRs.d.ts → ports.d-B6kDPKF7.d.ts} +4 -4
- package/dist/{ports.d-ClbPRUtx.d.cts → ports.d-DzPbmiDT.d.cts} +4 -4
- package/dist/records/depth/index.cjs +10 -10
- package/dist/records/depth/index.d.cts +9 -9
- package/dist/records/depth/index.d.ts +9 -9
- package/dist/records/depth/index.js +10 -10
- package/dist/records/index.cjs +253 -211
- package/dist/records/index.d.cts +169 -73
- package/dist/records/index.d.ts +169 -73
- package/dist/records/index.js +254 -212
- package/dist/{requestFunnel.d-YabU6G-Z.d.ts → requestFunnel.d-BPsCHJWf.d.ts} +2 -2
- package/dist/{requestFunnel.d-JoqddYSx.d.cts → requestFunnel.d-BdpL7gwg.d.cts} +2 -2
- package/dist/{runtimeTypes.d-DQTBJAbk.d.ts → runtimeTypes.d-C_Pcxn-n.d.ts} +4 -4
- package/dist/{runtimeTypes.d-Cv38YuzP.d.cts → runtimeTypes.d-Cfq3IrZG.d.cts} +4 -4
- package/dist/{screenProps.d-C-AuHoyF.d.cts → screenProps.d-BJMn1kTR.d.cts} +2 -2
- package/dist/{screenProps.d-BuJLzFkN.d.ts → screenProps.d-DGrfO17l.d.ts} +2 -2
- package/dist/server/events/index.cjs +3 -3
- package/dist/server/events/index.d.cts +48 -6
- package/dist/server/events/index.d.ts +48 -6
- package/dist/server/events/index.js +3 -3
- package/dist/server/index.cjs +2 -2
- package/dist/server/index.d.cts +3 -3
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +2 -2
- package/dist/shop/index.cjs +16 -16
- package/dist/shop/index.d.cts +12 -3
- package/dist/shop/index.d.ts +12 -3
- package/dist/shop/index.js +16 -16
- package/dist/tabs/index.cjs +4 -4
- package/dist/tabs/index.d.cts +34 -15
- package/dist/tabs/index.d.ts +34 -15
- package/dist/tabs/index.js +5 -5
- package/dist/{tabsModel.d-BfIQg6yS.d.ts → tabsModel.d-B7QMug1u.d.cts} +1 -17
- package/dist/{tabsModel.d-BfIQg6yS.d.cts → tabsModel.d-B7QMug1u.d.ts} +1 -17
- package/dist/televet/booking/index.cjs +2 -2
- package/dist/televet/booking/index.d.cts +6 -6
- package/dist/televet/booking/index.d.ts +6 -6
- package/dist/televet/booking/index.js +2 -2
- package/dist/televet/call/index.cjs +1 -1
- package/dist/televet/call/index.js +1 -1
- package/dist/televet/index.cjs +4 -3
- package/dist/televet/index.d.cts +1 -0
- package/dist/televet/index.d.ts +1 -0
- package/dist/televet/index.js +5 -4
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/rn/index.cjs +1 -1
- package/dist/testing/rn/index.d.cts +7 -7
- package/dist/testing/rn/index.d.ts +7 -7
- package/dist/testing/rn/index.js +1 -1
- package/dist/testing/web/index.d.cts +7 -7
- package/dist/testing/web/index.d.ts +7 -7
- package/dist/texting/index.cjs +21 -16
- package/dist/texting/index.d.cts +5 -5
- package/dist/texting/index.d.ts +5 -5
- package/dist/texting/index.js +22 -17
- package/dist/threadOptions.d-B0folrKm.d.cts +147 -0
- package/dist/{threadOptions.d-DBrmOwmb.d.cts → threadOptions.d-B8HTJa9A.d.cts} +6 -40
- package/dist/{threadOptions.d-8x_1evAr.d.ts → threadOptions.d-BnhE7T8Y.d.ts} +6 -40
- package/dist/threadOptions.d-DTsJFkL-.d.ts +147 -0
- package/dist/threadOptions.d-GPJPprkn.d.cts +55 -0
- package/dist/threadOptions.d-GPJPprkn.d.ts +55 -0
- package/dist/{timelineRows.d-B6lLC8Ud.d.cts → timelineRows.d-BTcUdNeI.d.cts} +1 -1
- package/dist/{timelineRows.d-Brlkti-G.d.ts → timelineRows.d-kmBms1W5.d.ts} +1 -1
- package/dist/{planSignals.d-Dha2CMDF.d.cts → useHealthPlanSubscription.d-B_cth_iF.d.cts} +81 -3
- package/dist/{planSignals.d-CON9gTvJ.d.ts → useHealthPlanSubscription.d-BzNaVl89.d.ts} +81 -3
- package/dist/{usePresentation.d-Bne14SlX.d.ts → usePresentation.d-B7Uf44Ax.d.ts} +40 -40
- package/dist/{usePresentation.d-BcdCIuEU.d.cts → usePresentation.d-BkAMOfb5.d.cts} +40 -40
- package/dist/{useRecordsDepth.d-Cd6J03o5.d.ts → useRecordsDepth.d-BHkZi0tM.d.ts} +1 -1
- package/dist/{useRecordsDepth.d-DAa169VY.d.cts → useRecordsDepth.d-BxHpKipf.d.cts} +1 -1
- package/dist/video/index.cjs +2 -2
- package/dist/video/index.js +2 -2
- package/dist/{view.d-DkGM8GNA.d.ts → view.d-2BYMRnWj.d.ts} +3 -3
- package/dist/{view.d-3d5_O7Xk.d.cts → view.d-CoDbnv0f.d.cts} +3 -3
- package/dist/web/consent/index.d.cts +5 -5
- package/dist/web/consent/index.d.ts +5 -5
- package/dist/web/health-plan/index.cjs +5 -5
- package/dist/web/health-plan/index.d.cts +15 -69
- package/dist/web/health-plan/index.d.ts +15 -69
- package/dist/web/health-plan/index.js +5 -5
- package/dist/web/index.cjs +8 -8
- package/dist/web/index.d.cts +26 -43
- package/dist/web/index.d.ts +26 -43
- package/dist/web/index.js +8 -8
- package/dist/web/intro/index.d.cts +6 -6
- package/dist/web/intro/index.d.ts +6 -6
- package/dist/web/notifications/index.d.cts +3 -3
- package/dist/web/notifications/index.d.ts +3 -3
- package/dist/web/records/depth/index.cjs +9 -9
- package/dist/web/records/depth/index.d.cts +9 -9
- package/dist/web/records/depth/index.d.ts +9 -9
- package/dist/web/records/depth/index.js +9 -9
- package/dist/web/records/index.cjs +12 -12
- package/dist/web/records/index.d.cts +11 -11
- package/dist/web/records/index.d.ts +11 -11
- package/dist/web/records/index.js +12 -12
- package/dist/web/records-sheet/index.cjs +17 -17
- package/dist/web/records-sheet/index.js +17 -17
- package/dist/web/shop/index.cjs +12 -12
- package/dist/web/shop/index.d.cts +3 -3
- package/dist/web/shop/index.d.ts +3 -3
- package/dist/web/shop/index.js +12 -12
- package/dist/web/televet/booking/index.cjs +2 -2
- package/dist/web/televet/booking/index.d.cts +6 -6
- package/dist/web/televet/booking/index.d.ts +6 -6
- package/dist/web/televet/booking/index.js +2 -2
- package/dist/web/televet/call/index.cjs +1 -1
- package/dist/web/televet/call/index.js +1 -1
- package/dist/web/texting/index.d.cts +5 -5
- package/dist/web/texting/index.d.ts +5 -5
- package/package.json +22 -27
package/dist/texting/index.cjs
CHANGED
|
@@ -107,12 +107,14 @@ return Object.freeze({challengeId:challengeId,expiresAt:str3(o.expires_at),attem
|
|
|
107
107
|
return Object.freeze({reason:explicit.reason,level:explicit.level,recoverable:explicit.recoverable})}/* @__PURE__ */
|
|
108
108
|
return Object.freeze({reason:userFacingError("accessDenied"),level:"user_entitlement",recoverable:false})}function freezeDecision(d){let base={name:d.name,enabled:d.enabled,isPending:d.isPending,limits:/* @__PURE__ */Object.freeze({...d.limits})};return d.disabled!==void 0&&(base.disabled=d.disabled),/* @__PURE__ */Object.freeze(base)}function useCapability(name){let{runtime:runtime}=useEverfurContext(),store=runtime.entitlements,snapshot=react.useSyncExternalStore(store.subscribe,store.getSnapshot,store.getSnapshot);return react.useMemo(()=>decideCapability(name,snapshot.decisions,{isPending:snapshot.isPending}),[name,snapshot])}var MIN_OFFSTATE_HEIGHT=48;function selectView(decision){return decision.isPending?"pending":decision.enabled?"enabled":"disabled"}function CapabilityGate(props){let{capability:capability,children:children,renderDisabled:renderDisabled,renderPending:renderPending,style:style}=props,decision=useCapability(capability),view=react.useMemo(()=>selectView(decision),[decision]);switch(view){case"enabled":return children;case"pending":return renderPending?/* @__PURE__ */jsxRuntime.jsx(HostRender,{render:renderPending,fallback:/* @__PURE__ */jsxRuntime.jsx(PendingSkeleton,{capability:capability,style:style})}):/* @__PURE__ */jsxRuntime.jsx(PendingSkeleton,{capability:capability,style:style});case"disabled":return renderDisabled?/* @__PURE__ */jsxRuntime.jsx(HostRender,{render:()=>renderDisabled(decision),fallback:/* @__PURE__ */jsxRuntime.jsx(OffState,{decision:decision,style:style}),resetKey:decision}):/* @__PURE__ */jsxRuntime.jsx(OffState,{decision:decision,style:style});default:return assertNever(view)}}function PendingSkeleton({capability:capability,style:style}){let theme=useEverfurTheme(),styles=react.useMemo(()=>makeStyles(theme),[theme]);/* @__PURE__ */
|
|
109
109
|
return jsxRuntime.jsx(reactNative.View,{style:[styles.offstate,style],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${capability}`,children:/* @__PURE__ */jsxRuntime.jsx(reactNative.View,{style:styles.skeletonBar})})}function OffState({decision:decision,style:style}){let theme=useEverfurTheme(),styles=react.useMemo(()=>makeStyles(theme),[theme]),message=decision.disabled?.reason??"";/* @__PURE__ */
|
|
110
|
-
return jsxRuntime.jsx(reactNative.View,{style:[styles.offstate,style],accessible:true,accessibilityRole:"text",accessibilityLabel:message,children:message.length>0?/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.offstateText,children:message}):null})}function makeStyles(theme){let{color:color,space:space,radius:radius,type:type}=theme;return reactNative.StyleSheet.create({offstate:{minHeight:MIN_OFFSTATE_HEIGHT,justifyContent:"center",paddingHorizontal:space.lg,paddingVertical:space.md,backgroundColor:color.surfaceCream,borderRadius:radius.md,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:color.brandBorder},offstateText:{...face(theme,"regular"),fontSize:type.size.body,lineHeight:Math.round(type.size.body*type.lineHeight.normal),color:color.text.muted},skeletonBar:{height:space.md,borderRadius:radius.xs,backgroundColor:color.brandSofter}})}function EverfurTextingOptIn(props){let guarded=guardHostProps(props,["onStatusChange"]),resolved=react.useMemo(()=>({copy:resolveTextingCopy(props.copy),brandCopy:resolveTextingBrandCopy(props.brandCopy)}),[props.copy,props.brandCopy]),{copy:copy,brandCopy:brandCopy}=resolved,theme=useEverfurTheme(),styles=react.useMemo(()=>makeStyles2(theme),[theme]),texting=useEverfurTexting();return texting.status==="signedOut"?/* @__PURE__ */jsxRuntime.jsxs(reactNative.View,{style:[styles.card,guarded.style],children:[
|
|
110
|
+
return jsxRuntime.jsx(reactNative.View,{style:[styles.offstate,style],accessible:true,accessibilityRole:"text",accessibilityLabel:message,children:message.length>0?/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.offstateText,children:message}):null})}function makeStyles(theme){let{color:color,space:space,radius:radius,type:type}=theme;return reactNative.StyleSheet.create({offstate:{minHeight:MIN_OFFSTATE_HEIGHT,justifyContent:"center",paddingHorizontal:space.lg,paddingVertical:space.md,backgroundColor:color.surfaceCream,borderRadius:radius.md,borderWidth:reactNative.StyleSheet.hairlineWidth,borderColor:color.brandBorder},offstateText:{...face(theme,"regular"),fontSize:type.size.body,lineHeight:Math.round(type.size.body*type.lineHeight.normal),color:color.text.muted},skeletonBar:{height:space.md,borderRadius:radius.xs,backgroundColor:color.brandSofter}})}function announceLine(line){if(!(reactNative.Platform.OS!=="ios"||line===""))try{let announce=reactNative.AccessibilityInfo?.announceForAccessibility;typeof announce=="function"&&announce.call(reactNative.AccessibilityInfo,line)}catch{}}function AnnounceLine({line:line}){return react.useEffect(()=>{announceLine(line)},[line]),null}function EverfurTextingOptIn(props){let guarded=guardHostProps(props,["onStatusChange"]),resolved=react.useMemo(()=>({copy:resolveTextingCopy(props.copy),brandCopy:resolveTextingBrandCopy(props.brandCopy)}),[props.copy,props.brandCopy]),{copy:copy,brandCopy:brandCopy}=resolved,theme=useEverfurTheme(),styles=react.useMemo(()=>makeStyles2(theme),[theme]),texting=useEverfurTexting();return texting.status==="signedOut"?/* @__PURE__ */jsxRuntime.jsxs(reactNative.View,{style:[styles.card,guarded.style],children:[
|
|
111
111
|
/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.title,accessibilityRole:"header",children:brandCopy.introTitle(theme.meta.displayName)}),
|
|
112
112
|
/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.body,children:copy.signedOut})]}):/* @__PURE__ */jsxRuntime.jsx(CapabilityGate,{capability:"texting",...guarded.renderDisabled?{renderDisabled:guarded.renderDisabled}:{},style:guarded.style,children:/* @__PURE__ */jsxRuntime.jsx(TextingCopyContext.Provider,{value:resolved,children:/* @__PURE__ */jsxRuntime.jsx(OptInBody,{...guarded,texting:texting,styles:styles})})})}function Button({label:label,onPress:onPress,disabled:disabled=false,busy:busy=false,styles:styles,kind:kind="primary",testID:testID}){let box=kind==="primary"?styles.primary:kind==="secondary"?styles.secondary:styles.link,ink=kind==="primary"?styles.primaryLabel:kind==="secondary"?styles.secondaryLabel:styles.linkLabel;/* @__PURE__ */
|
|
113
|
-
return jsxRuntime.jsx(reactNative.Pressable,{onPress:onPress,disabled:disabled||busy,accessibilityRole:"button",accessibilityLabel:label,accessibilityState:{disabled:disabled||busy,busy:busy},style:[box,disabled||busy?styles.dimmed:null],...testID===void 0?{}:{testID:testID},children:/* @__PURE__ */jsxRuntime.jsx(Text,{tier:"control",style:ink,children:label})})}function OptInBody({texting:texting,styles:styles,onStatusChange:onStatusChange,renderNotice:renderNotice,style:style}){let{copy:copy,brandCopy:brandCopy}=useTextingCopy(),theme=useEverfurTheme(),{status:status,profile:profile,snapshot:snapshot}=texting,brand=profile?.brandName??theme.meta.displayName,[phone,setPhone]=react.useState(""),[consented,setConsented]=react.useState(false),[code,setCode]=react.useState(""),[problem,setProblem]=react.useState(null),[confirmingOff,setConfirmingOff]=react.useState(false),[petChoice,setPetChoice]=react.useState(null),[petSaved,setPetSaved]=react.useState(false);react.useEffect(()=>{onStatusChange?.(status)},[onStatusChange,status]),react.useEffect(()=>{setProblem(null),setConfirmingOff(false)},[status]);let frame=children=>/* @__PURE__ */jsxRuntime.jsx(reactNative.View,{style:[styles.card,style],children:children}),notice=(error,onRetry)=>{let line=textingErrorText(error,snapshot.failedAction,snapshot.codeRefusal,copy),support=textingSupportText(error,copy);/* @__PURE__ */
|
|
113
|
+
return jsxRuntime.jsx(reactNative.Pressable,{onPress:onPress,disabled:disabled||busy,accessibilityRole:"button",accessibilityLabel:label,accessibilityState:{disabled:disabled||busy,busy:busy},style:[box,disabled||busy?styles.dimmed:null],...testID===void 0?{}:{testID:testID},children:/* @__PURE__ */jsxRuntime.jsx(Text,{tier:"control",style:ink,children:label})})}function OptInBody({texting:texting,styles:styles,onStatusChange:onStatusChange,renderNotice:renderNotice,style:style}){let{copy:copy,brandCopy:brandCopy}=useTextingCopy(),theme=useEverfurTheme(),{status:status,profile:profile,snapshot:snapshot}=texting,brand=profile?.brandName??theme.meta.displayName,[phone,setPhone]=react.useState(""),[consented,setConsented]=react.useState(false),[code,setCode]=react.useState(""),[problem,setProblem]=react.useState(null),[confirmingOff,setConfirmingOff]=react.useState(false),[petChoice,setPetChoice]=react.useState(null),[petSaved,setPetSaved]=react.useState(false);react.useEffect(()=>{onStatusChange?.(status)},[onStatusChange,status]),react.useEffect(()=>{setProblem(null),setConfirmingOff(false)},[status]);let frame=(children,busy2=false)=>/* @__PURE__ */jsxRuntime.jsx(reactNative.View,{style:[styles.card,style],accessibilityState:{busy:busy2},children:children}),notice=(error,onRetry)=>{let line=textingErrorText(error,snapshot.failedAction,snapshot.codeRefusal,copy),support=textingSupportText(error,copy);/* @__PURE__ */
|
|
114
114
|
return jsxRuntime.jsxs(reactNative.View,{style:styles.notice,accessibilityLiveRegion:"polite",children:[
|
|
115
|
-
/* @__PURE__ */jsxRuntime.jsx(HostRender,{resetKey:error,render:()=>renderNotice?renderNotice(error):/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.noticeText,children:line}),fallback:/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.noticeText,children:line})}),support===null?null:/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.footnote,children:support}),onRetry===void 0?null:/* @__PURE__ */jsxRuntime.jsx(Button,{label:copy.retry,onPress:onRetry,styles:styles,kind:"link"})]})},problemLine=problem===null?null:/* @__PURE__ */jsxRuntime.
|
|
115
|
+
/* @__PURE__ */jsxRuntime.jsx(HostRender,{resetKey:error,render:()=>renderNotice?renderNotice(error):/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.noticeText,children:line}),fallback:/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.noticeText,children:line})}),support===null?null:/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.footnote,children:support}),onRetry===void 0?null:/* @__PURE__ */jsxRuntime.jsx(Button,{label:copy.retry,onPress:onRetry,styles:styles,kind:"link"}),renderNotice?null:/* @__PURE__ */jsxRuntime.jsx(AnnounceLine,{line:support===null?line:`${line} ${support}`})]})},problemLine=problem===null?null:/* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[
|
|
116
|
+
/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.noticeText,accessibilityLiveRegion:"polite",children:textingInputProblemText(problem,copy)}),
|
|
117
|
+
/* @__PURE__ */jsxRuntime.jsx(AnnounceLine,{line:textingInputProblemText(problem,copy)})]});if(status==="unavailable")return frame(
|
|
116
118
|
/* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[
|
|
117
119
|
/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.title,accessibilityRole:"header",children:copy.unavailableTitle}),
|
|
118
120
|
/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.body,children:copy.unavailableBody})]}));if(profile===null)return null;if(status==="loading")/* @__PURE__ */
|
|
@@ -128,7 +130,7 @@ return jsxRuntime.jsx(reactNative.View,{style:[styles.card,style],accessible:tru
|
|
|
128
130
|
/* @__PURE__ */jsxRuntime.jsxs(reactNative.Pressable,{onPress:()=>setConsented(!consented),disabled:busy2,accessibilityRole:"checkbox",accessibilityState:{checked:consented,disabled:busy2},accessibilityLabel:profile.consentText,style:styles.consentRow,testID:"texting-consent",children:[
|
|
129
131
|
/* @__PURE__ */jsxRuntime.jsx(reactNative.View,{style:[styles.box,consented?styles.boxChecked:null],accessibilityElementsHidden:true,importantForAccessibility:"no",children:consented?/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.tick,children:"✓"}):null}),
|
|
130
132
|
/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.consentText,children:profile.consentText})]}),help,problemLine,snapshot.error===null?null:notice(snapshot.error),
|
|
131
|
-
/* @__PURE__ */jsxRuntime.jsx(Button,{label:busy2?copy.sendingCode:copy.sendCode,busy:busy2,styles:styles,testID:"texting-send",onPress:()=>{let found=validateTextingEnroll(phone,consented);setProblem(found),found===null&&texting.start(phone)}})]}))}if(status==="code"||status==="confirming"||status==="requesting"){let confirming=status==="confirming",resending=status==="requesting",busy2=confirming||resending;return frame(
|
|
133
|
+
/* @__PURE__ */jsxRuntime.jsx(Button,{label:busy2?copy.sendingCode:copy.sendCode,busy:busy2,styles:styles,testID:"texting-send",onPress:()=>{let found=validateTextingEnroll(phone,consented);setProblem(found),found===null&&texting.start(phone)}})]}),busy2)}if(status==="code"||status==="confirming"||status==="requesting"){let confirming=status==="confirming",resending=status==="requesting",busy2=confirming||resending;return frame(
|
|
132
134
|
/* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[
|
|
133
135
|
/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.title,accessibilityRole:"header",children:copy.codeTitle}),
|
|
134
136
|
/* @__PURE__ */jsxRuntime.jsxs(Text,{style:styles.body,children:[copy.codeSentTo," ",formatTextingPhone(snapshot.phoneE164)]}),
|
|
@@ -137,7 +139,7 @@ return jsxRuntime.jsx(reactNative.View,{style:[styles.card,style],accessible:tru
|
|
|
137
139
|
/* @__PURE__ */jsxRuntime.jsx(Button,{label:confirming?copy.confirmingCode:copy.confirmCode,busy:confirming,disabled:resending,styles:styles,testID:"texting-confirm",onPress:()=>{let found=validateTextingCode(code);setProblem(found),found===null&&texting.confirm(code)}}),
|
|
138
140
|
/* @__PURE__ */jsxRuntime.jsxs(reactNative.View,{style:styles.links,children:[
|
|
139
141
|
/* @__PURE__ */jsxRuntime.jsx(Button,{label:copy.requestNewCode,kind:"link",disabled:confirming,busy:resending,styles:styles,onPress:()=>{setCode(""),texting.resend()}}),
|
|
140
|
-
/* @__PURE__ */jsxRuntime.jsx(Button,{label:copy.changeNumber,kind:"link",styles:styles,onPress:()=>{setCode(""),texting.changeNumber()}})]})]}))}if(status==="optedOut")return frame(
|
|
142
|
+
/* @__PURE__ */jsxRuntime.jsx(Button,{label:copy.changeNumber,kind:"link",styles:styles,onPress:()=>{setCode(""),texting.changeNumber()}})]})]}),busy2)}if(status==="optedOut")return frame(
|
|
141
143
|
/* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[
|
|
142
144
|
/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.title,accessibilityRole:"header",children:copy.optedOutTitle}),
|
|
143
145
|
/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.body,children:textingOptedOutBody(snapshot.identity,brand,copy,brandCopy)}),help,
|
|
@@ -157,10 +159,13 @@ return jsxRuntime.jsxs(reactNative.View,{style:styles.petRow,children:[
|
|
|
157
159
|
return jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>onChoose(pet.petRef),disabled:saving,accessibilityRole:"radio",accessibilityState:{checked:picked,disabled:saving},accessibilityLabel:pet.name??pet.petRef,style:[styles.chip,picked?styles.chipPicked:null],children:/* @__PURE__ */jsxRuntime.jsx(Text,{tier:"compact",style:[styles.chipLabel,picked?styles.chipLabelPicked:null],children:pet.name??pet.petRef})},pet.petRef)})}),
|
|
158
160
|
/* @__PURE__ */jsxRuntime.jsxs(reactNative.View,{style:styles.links,children:[
|
|
159
161
|
/* @__PURE__ */jsxRuntime.jsx(Button,{label:saving?copy.savingPet:copy.savePet,kind:"secondary",busy:saving,disabled:!changed,styles:styles,onPress:()=>{value!==null&&onSave(value)},testID:"texting-pet-save"}),saved&&!changed?/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.footnote,children:copy.petSaved}):null]})]})}function makeStyles2(theme){let{color:color,radius:radius,space:space,type:type,slots:slots}=theme,text3=(size,ink,weight)=>({...face(theme,weight),fontSize:size,lineHeight:Math.round(size*type.lineHeight.snug),color:ink}),cardInk=slots.card?.textColor;return reactNative.StyleSheet.create({card:{gap:space.md,padding:space.lg,borderRadius:radius.lg,borderWidth:1,borderColor:color.brandBorder,backgroundColor:color.surface,...slotBox(slots.card,1)},title:text3(type.size.subtitle,cardInk??color.text.primary,"bold"),subtitle:text3(type.size.body,cardInk??color.text.primary,"bold"),body:text3(type.size.body,cardInk??color.text.secondary,"regular"),footnote:text3(type.size.caption,color.text.muted,"regular"),phone:text3(type.size.body,cardInk??color.text.primary,"bold"),label:text3(type.size.caption,cardInk??color.text.primary,"bold"),input:{minHeight:44,paddingHorizontal:space.md,borderRadius:radius.md,borderWidth:1,borderColor:color.controlEdge,backgroundColor:color.surface,...text3(type.size.body,color.text.primary,"regular"),...slotBox(slots.input,1),...slotText(slots.input)},consentRow:{flexDirection:"row",alignItems:"flex-start",gap:space.sm,minHeight:44},box:{width:24,height:24,borderRadius:radius.xs,borderWidth:2,borderColor:color.controlEdge,alignItems:"center",justifyContent:"center",backgroundColor:color.surface},boxChecked:{backgroundColor:color.brand,borderColor:color.brandInk},tick:{...text3(type.size.caption,color.text.onBrand,"bold")},consentText:{flex:1,...text3(type.size.caption,cardInk??color.text.secondary,"regular")},primary:{minHeight:44,paddingHorizontal:space.lg,borderRadius:radius.pill,alignItems:"center",justifyContent:"center",backgroundColor:color.brand,...slotBox(slots.primaryButton)},primaryLabel:{...text3(type.size.body,color.text.onBrand,"bold"),...slotText(slots.primaryButton)},secondary:{minHeight:44,paddingHorizontal:space.lg,borderRadius:radius.pill,borderWidth:1,borderColor:color.brandBorder,alignItems:"center",justifyContent:"center",backgroundColor:color.surface},secondaryLabel:text3(type.size.caption,color.brandInk,"bold"),link:{minHeight:44,justifyContent:"center",alignSelf:"flex-start"},linkLabel:{...text3(type.size.caption,color.linkInk,"bold"),...slotText(slots.link)},dimmed:{opacity:.5},links:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:space.md},notice:{gap:space.xs},noticeText:text3(type.size.caption,color.errorRed,"regular"),confirm:{gap:space.sm,padding:space.md,borderRadius:radius.md,backgroundColor:color.surfaceSubtle},petRow:{gap:space.xs},chips:{flexDirection:"row",flexWrap:"wrap",gap:space.sm},chip:{minHeight:44,paddingHorizontal:space.md,borderRadius:radius.pill,borderWidth:1,borderColor:color.brandBorder,backgroundColor:color.surface,justifyContent:"center",...slotBox(slots.chip,1)},chipPicked:{backgroundColor:color.brandSoft,borderColor:color.brandInk},chipLabel:{...text3(type.size.caption,color.text.primary,"regular"),...slotText(slots.chip)},chipLabelPicked:{...face(theme,"bold"),color:color.brandInk}})}var INTRO_OPEN_SYMBOL=/* @__PURE__ */Symbol.for("@everfur/sdk#IntroOpen@v1"),host=globalThis;function isIntroOpenState(value){if(typeof value!="object"||value===null)return false;let v=value;return v.holds instanceof Set&&v.listeners instanceof Set}var stored=host[INTRO_OPEN_SYMBOL],fresh=()=>({holds:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set}),state=isIntroOpenState(stored)?stored:host[INTRO_OPEN_SYMBOL]=fresh();function isIntroOpen(){return state.holds.size>0}function subscribe(listener){return state.listeners.add(listener),()=>{state.listeners.delete(listener)}}function useIntroOpen(){return react.useSyncExternalStore(subscribe,isIntroOpen,isIntroOpen)}function resolveTextingAskDue(input){let readEnabled=input.enabled&&input.capabilityGranted&&input.hasProfile&&input.signedIn&&input.scheduleEligible&&!input.offeredThisSession,due=readEnabled&&input.identity==="none"&&input.surfaceReady;return{readEnabled:readEnabled,due:due}}var URGENT_LEVELS=/* @__PURE__ */new Set(["emergency","schedule_soon"]);function textingAskThreadReady(chat){if(chat.isBootstrapping===true||chat.isLoadingHistory===true||chat.isStreaming===true||chat.status==="error"||chat.stopped===true)return false;let last=chat.messages[chat.messages.length-1];return last===void 0||last.role!=="assistant"||last.pending===true||last.checkin!==void 0||last.text.trim().length===0?false:!(typeof last.urgencyLevel=="string"&&URGENT_LEVELS.has(last.urgencyLevel))}var IN_MEMORY_KVS=/* @__PURE__ */new WeakSet;function isInMemoryKv(kv){return IN_MEMORY_KVS.has(kv)}var TEXTING_ASK_SCHEDULE_KEY="everfur.texting.askSchedule.v1",TEXTING_ASK_SNOOZE_MS=2880*60*1e3,TEXTING_ASK_MAX_ASKS=3,EMPTY_TEXTING_ASK_ENTRY=/* @__PURE__ */Object.freeze({askCount:0,nextAskAt:null,completed:false});function isTextingAskEligible(read,now){if(read.status!=="ok")return false;let{entry:entry}=read;return entry.completed||entry.askCount>=TEXTING_ASK_MAX_ASKS?false:entry.nextAskAt===null||now>=entry.nextAskAt}function applyTextingAsk(entry,now){return{askCount:Math.min(entry.askCount+1,TEXTING_ASK_MAX_ASKS),nextAskAt:now+TEXTING_ASK_SNOOZE_MS,completed:entry.completed}}function applyTextingAskSnooze(entry,now){return{...entry,nextAskAt:now+TEXTING_ASK_SNOOZE_MS}}function applyTextingAskCompleted(entry){return{...entry,completed:true}}function nextTextingAskNumber(entry){return entry.askCount<=0?1:entry.askCount===1?2:3}function entryOf(raw){if(raw===null||typeof raw!="object"||Array.isArray(raw))return null;let o=raw,{askCount:askCount,nextAskAt:nextAskAt,completed:completed}=o;return typeof askCount!="number"||!Number.isInteger(askCount)||askCount<0||nextAskAt!==null&&(typeof nextAskAt!="number"||!Number.isFinite(nextAskAt))||typeof completed!="boolean"?null:{askCount:Math.min(askCount,TEXTING_ASK_MAX_ASKS),nextAskAt:nextAskAt,completed:completed}}function parseTextingAskMap(raw){let value;try{value=JSON.parse(raw)}catch{return null}if(value===null||typeof value!="object"||Array.isArray(value))return null;let out={};for(let[key,item]of Object.entries(value)){let entry=entryOf(item);if(entry===null)return null;out[key]=entry}return out}var SLOT=/* @__PURE__ */Symbol.for("@everfur/sdk/texting/ask-schedule@v1");function shared(){let host2=globalThis,state2=host2[SLOT];return state2===void 0&&(state2={sessions:/* @__PURE__ */new Map,sessionListeners:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set,writeChain:Promise.resolve()},host2[SLOT]=state2),state2.sessionListeners===void 0&&(state2.sessionListeners=/* @__PURE__ */new Set),state2}async function load(kv){if(isInMemoryKv(kv))return{status:"unreadable"};let raw;try{raw=await kv.getItem(TEXTING_ASK_SCHEDULE_KEY)}catch{return{status:"unreadable"}}if(raw===null)try{return await kv.setItem(TEXTING_ASK_SCHEDULE_KEY,"{}"),await kv.getItem(TEXTING_ASK_SCHEDULE_KEY)===null?{status:"unreadable"}:{status:"ok",map:{}}}catch{return{status:"unreadable"}}let map=parseTextingAskMap(raw);if(map!==null)return{status:"ok",map:map};try{await kv.removeItem(TEXTING_ASK_SCHEDULE_KEY)}catch{}return{status:"unreadable"}}function subscribeTextingAskSchedule(listener){let{listeners:listeners2}=shared();return listeners2.add(listener),()=>{listeners2.delete(listener)}}function update(kv,userRef,change){let state2=shared(),run=async()=>{let loaded=await load(kv);if(loaded.status!=="ok")return;let current=loaded.map[userRef]??EMPTY_TEXTING_ASK_ENTRY;try{await kv.setItem(TEXTING_ASK_SCHEDULE_KEY,JSON.stringify({...loaded.map,[userRef]:change(current)}))}catch{return}for(let listener of[...state2.listeners])listener()},next=state2.writeChain.then(run,run);return state2.writeChain=next.catch(()=>{}),next}async function readTextingAskSchedule(kv,userRef){let loaded=await load(kv);return loaded.status!=="ok"?{status:"unreadable"}:{status:"ok",entry:loaded.map[userRef]??EMPTY_TEXTING_ASK_ENTRY}}function recordTextingAsk(kv,userRef,now=Date.now()){return update(kv,userRef,entry=>applyTextingAsk(entry,now))}function snoozeTextingAsk(kv,userRef,now=Date.now()){return update(kv,userRef,entry=>applyTextingAskSnooze(entry,now))}function markTextingAskCompleted(kv,userRef){return update(kv,userRef,applyTextingAskCompleted)}function textingAskSession(userRef){return shared().sessions.get(userRef)??null}function setTextingAskSession(userRef,entry){let state2=shared();state2.sessions.set(userRef,entry);for(let listener of[...state2.sessionListeners])listener()}function subscribeTextingAskSessions(listener){let{sessionListeners:sessionListeners}=shared();return sessionListeners.add(listener),()=>{sessionListeners.delete(listener)}}var NO_SNAPSHOT=()=>null;function useTextingGranted(){let{runtime:runtime}=useEverfurContext(),source=runtime.entitlements??null,subscribe2=react.useCallback(listener=>source===null?()=>{}:source.subscribe(listener),[source]),read=source===null?NO_SNAPSHOT:source.getSnapshot,snapshot=react.useSyncExternalStore(subscribe2,read,read);return react.useMemo(()=>snapshot!==null&&decideCapability("texting",snapshot.decisions,{isPending:snapshot.isPending}).enabled,[snapshot])}var IDLE=/* @__PURE__ */Object.freeze({status:"idle"});function useAskSchedule(userRef){let{runtime:runtime}=useEverfurContext(),kv=runtime.registry.services.kv,[state2,setState]=react.useState({user:null,value:IDLE});return react.useEffect(()=>{if(userRef===null)return;let live=true,read=()=>{readTextingAskSchedule(kv,userRef).then(value=>{live&&setState({user:userRef,value:{status:"ready",read:value}})})};read();let unsubscribe=subscribeTextingAskSchedule(read);return()=>{live=false,unsubscribe()}},[kv,userRef]),state2.user===userRef?state2.value:IDLE}function identityOf(texting){switch(texting.status){case"enroll":case"requesting":case"code":case"confirming":return"none";case"verified":case"optingOut":case"optedOut":return"exists";default:return"unknown"}}function useTextingAsk(options={}){let enabled=options.enabled!==false,ready=options.ready!==false,surface=options.surface??"prompt",entryWanted=options.entry===true,{runtime:runtime,userRef:userRef}=useEverfurContext(),kv=runtime.registry.services.kv,granted=useTextingGranted(),schedule=useAskSchedule(enabled&&userRef!==null?userRef:null),readSession=react.useCallback(()=>userRef===null?null:textingAskSession(userRef),[userRef]),current=react.useSyncExternalStore(subscribeTextingAskSessions,readSession,readSession),update2=react.useCallback(entry=>{userRef!==null&&setTextingAskSession(userRef,entry)},[userRef]),mine=current!==null&¤t.surface===surface,handedOff=current!==null&¤t.fromPrompt===true,stage=mine?current.stage==="handoff"?"hidden":current.stage:surface==="prompt"&&handedOff?"dismissed":"hidden",now=Date.now(),scheduleEligible=schedule.status==="ready"&&isTextingAskEligible(schedule.read,now),[readFor,setReadFor]=react.useState(null),entryRead=entryWanted&&userRef!==null&&granted,texting=useTextingState(userRef!==null&&readFor===userRef||stage!=="hidden"||mine||entryRead),identity=identityOf(texting),{readEnabled:readEnabled,due:due}=resolveTextingAskDue({enabled:enabled,capabilityGranted:granted,hasProfile:texting.profile!==null,signedIn:userRef!==null,scheduleEligible:scheduleEligible,offeredThisSession:current!==null,identity:identity,surfaceReady:ready});react.useEffect(()=>{readEnabled&&userRef!==null&&setReadFor(userRef)},[readEnabled,userRef]);let askNumber=current?.askNumber??(schedule.status==="ready"&&schedule.read.status==="ok"?nextTextingAskNumber(schedule.read.entry):1);react.useEffect(()=>{!due||userRef===null||textingAskSession(userRef)!==null||update2({surface:surface,stage:"offered",answered:false,askNumber:askNumber})},[due,userRef,update2,askNumber,surface]),react.useEffect(()=>{!mine||current.stage!=="handoff"||enabled&&ready&&granted&&texting.profile!==null&&identity==="none"&&update2({...current,stage:"offered"})},[mine,current,enabled,ready,granted,texting.profile,identity,update2]);let completed=schedule.status==="ready"&&schedule.read.status==="ok"&&schedule.read.entry.completed;react.useEffect(()=>{userRef===null||identity!=="exists"||completed||schedule.status!=="ready"||markTextingAskCompleted(kv,userRef)},[identity,completed,schedule.status,kv,userRef]),react.useEffect(()=>{mine&¤t.stage==="enrolling"&&texting.status==="verified"&&update2({...current,stage:"verified"})},[mine,current,texting.status,update2]);let answer=react.useCallback(entry=>userRef===null||entry.answered?entry:(recordTextingAsk(kv,userRef),{...entry,answered:true}),[kv,userRef]),accept=react.useCallback(()=>{mine&¤t.stage==="offered"&&update2({...current,stage:"enrolling"})},[mine,current,update2]),close=react.useCallback(()=>{if(!mine||current.stage!=="enrolling")return;let{back:back,...rest}=current;update2({...rest,stage:back??"offered"})},[mine,current,update2]),dismiss=react.useCallback(()=>{if(!(!mine||current.stage!=="offered"&¤t.stage!=="enrolling")){if(surface==="prompt"){update2({...answer(current),surface:"chat",stage:"handoff",fromPrompt:true});return}current.fromPrompt===true&¤t.answered&&userRef!==null&&snoozeTextingAsk(kv,userRef),update2({...answer(current),stage:"dismissed"})}},[mine,current,surface,update2,answer,kv,userRef]),{start:startCode}=texting,start=react.useCallback(async phone=>!mine||current.stage!=="enrolling"?false:(current.answered||update2(answer(current)),startCode(phone)),[mine,current,update2,answer,startCode]),canOpen=entryRead&&texting.profile!==null&&identity==="none"&&stage!=="enrolling"&&stage!=="verified",open=react.useCallback(()=>{if(!canOpen||userRef===null)return;let was=mine?current:null;update2({surface:surface,stage:"enrolling",answered:was?.answered??false,askNumber:current?.askNumber??askNumber,...was?.fromPrompt===true?{fromPrompt:true}:{},back:was?.stage==="offered"?"offered":"dismissed"})},[canOpen,userRef,mine,current,update2,surface,askNumber]),brand=texting.profile?.brandName??"";return react.useMemo(()=>({stage:userRef===null?"hidden":stage,brand:brand,askNumber:askNumber,texting:texting,accept:accept,dismiss:dismiss,close:close,start:start,canOpen:canOpen,open:open}),[userRef,stage,brand,askNumber,texting,accept,dismiss,close,start,canOpen,open])}var ABSOLUTE_FILL=/* @__PURE__ */Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});function ChatTextingAskController({enabled:enabled,ready:ready,onAsk:onAsk,entry:entry=false}){let ask=useTextingAsk({enabled:enabled,ready:ready,surface:"chat",entry:entry});return react.useEffect(()=>{callHost(onAsk,ask)},[ask,onAsk]),null}function textingAskLines(ask){return{line:TEXTING_BRAND_COPY.chatAskLine(ask.brand),accept:TEXTING_COPY.promptAccept,dismiss:TEXTING_COPY.promptDismiss,verified:TEXTING_BRAND_COPY.chatAskVerified(ask.brand)}}function ChatTextingAskComposer({ask:ask}){let theme=useEverfurTheme(),styles=react.useMemo(()=>makeAskStyles(theme),[theme]);/* @__PURE__ */
|
|
160
|
-
return jsxRuntime.jsx(AskEntry,{ask:ask,styles:styles})}function AskEntry({ask:ask,styles:styles}){let{texting:texting}=ask,{status:status,profile:profile,snapshot:snapshot}=texting,[phone,setPhone]=react.useState(""),[consented,setConsented]=react.useState(false),[code,setCode]=react.useState(""),[problem,setProblem]=react.useState(null),onNumber=status==="enroll"||status==="requesting"&&!snapshot.resending,onCode=status==="code"||status==="confirming"||status==="requesting";react.useEffect(()=>{setProblem(null)},[status]);let close=/* @__PURE__ */jsxRuntime.jsxs(reactNative.Pressable,{onPress:ask.close,accessibilityRole:"button",accessibilityLabel:TEXTING_COPY.close,hitSlop:8,style:styles.close,testID:"texting-ask-close",children:[
|
|
162
|
+
return jsxRuntime.jsx(AskEntry,{ask:ask,styles:styles})}function AskEntry({ask:ask,styles:styles}){let{texting:texting}=ask,{status:status,profile:profile,snapshot:snapshot}=texting,[phone,setPhone]=react.useState(""),[consented,setConsented]=react.useState(false),[code,setCode]=react.useState(""),[problem,setProblem]=react.useState(null),[fieldFocused,setFieldFocused]=react.useState(false),fieldFocus={onFocus:()=>setFieldFocused(true),onBlur:()=>setFieldFocused(false)},pill=fieldFocused?[styles.pill,styles.pillFocused]:styles.pill,onNumber=status==="enroll"||status==="requesting"&&!snapshot.resending,onCode=status==="code"||status==="confirming"||status==="requesting",phoneRef=react.useRef(null),codeRef=react.useRef(null),numberReady=status==="enroll",codeReady=status==="code";react.useEffect(()=>{setProblem(null)},[status]),react.useEffect(()=>{numberReady?phoneRef.current?.focus():codeReady&&codeRef.current?.focus()},[numberReady,codeReady]);let close=/* @__PURE__ */jsxRuntime.jsxs(reactNative.Pressable,{onPress:ask.close,accessibilityRole:"button",accessibilityLabel:TEXTING_COPY.close,hitSlop:8,style:styles.close,testID:"texting-ask-close",children:[
|
|
161
163
|
/* @__PURE__ */jsxRuntime.jsx(reactNative.View,{style:[styles.closeBar,styles.closeBarA]}),
|
|
162
|
-
/* @__PURE__ */jsxRuntime.jsx(reactNative.View,{style:[styles.closeBar,styles.closeBarB]})]}),
|
|
163
|
-
/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.noticeText,children:
|
|
164
|
+
/* @__PURE__ */jsxRuntime.jsx(reactNative.View,{style:[styles.closeBar,styles.closeBarB]})]}),refusalLine=snapshot.error===null?null:textingErrorText(snapshot.error,snapshot.failedAction,snapshot.codeRefusal),supportLine=snapshot.error===null?null:textingSupportText(snapshot.error),refusal=refusalLine===null?null:/* @__PURE__ */jsxRuntime.jsxs(reactNative.View,{style:styles.notice,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:[
|
|
165
|
+
/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.noticeText,children:refusalLine}),supportLine===null?null:/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.footnote,children:supportLine}),
|
|
166
|
+
/* @__PURE__ */jsxRuntime.jsx(AnnounceLine,{line:supportLine===null?refusalLine:`${refusalLine} ${supportLine}`})]}),inputProblem=problem===null?null:/* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[
|
|
167
|
+
/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.noticeText,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:textingInputProblemText(problem)}),
|
|
168
|
+
/* @__PURE__ */jsxRuntime.jsx(AnnounceLine,{line:textingInputProblemText(problem)})]});if(profile===null)return null;if(status==="loading"||status==="failed"||status==="signedOut"||status==="unavailable")/* @__PURE__ */
|
|
164
169
|
return jsxRuntime.jsx(reactNative.View,{style:styles.root,testID:"texting-ask-entry",accessibilityState:{busy:status==="loading"},children:/* @__PURE__ */jsxRuntime.jsxs(reactNative.View,{style:styles.head,children:[
|
|
165
170
|
/* @__PURE__ */jsxRuntime.jsx(reactNative.View,{style:styles.headBody,children:status==="failed"?refusal:null}),close]})});if(onNumber){let busy=status==="requesting",submit=()=>{let found=validateTextingEnroll(phone,consented);setProblem(found),found===null&&ask.start(phone)};/* @__PURE__ */
|
|
166
171
|
return jsxRuntime.jsxs(reactNative.View,{style:styles.root,testID:"texting-ask-phone",children:[
|
|
@@ -169,8 +174,8 @@ return jsxRuntime.jsxs(reactNative.View,{style:styles.root,testID:"texting-ask-p
|
|
|
169
174
|
/* @__PURE__ */jsxRuntime.jsxs(reactNative.Pressable,{onPress:()=>setConsented(!consented),disabled:busy,accessibilityRole:"checkbox",accessibilityState:{checked:consented,disabled:busy},accessibilityLabel:profile.consentText,style:styles.consentRow,testID:"texting-ask-consent",children:[
|
|
170
175
|
/* @__PURE__ */jsxRuntime.jsx(reactNative.View,{style:[styles.box,consented?styles.boxChecked:null],accessibilityElementsHidden:true,importantForAccessibility:"no",children:consented?/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.tick,children:"✓"}):null}),
|
|
171
176
|
/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.consentText,children:profile.consentText})]}),profile.helpContact===null?null:/* @__PURE__ */jsxRuntime.jsxs(Text,{style:styles.footnote,children:[TEXTING_COPY.helpContactLabel," ",profile.helpContact]})]}),close]}),inputProblem,refusal,
|
|
172
|
-
/* @__PURE__ */jsxRuntime.jsxs(reactNative.View,{style:
|
|
173
|
-
/* @__PURE__ */jsxRuntime.jsx(TextInput,{value:phone,onChangeText:setPhone,editable:!busy,
|
|
177
|
+
/* @__PURE__ */jsxRuntime.jsxs(reactNative.View,{style:pill,children:[
|
|
178
|
+
/* @__PURE__ */jsxRuntime.jsx(TextInput,{value:phone,onChangeText:setPhone,editable:!busy,keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",accessibilityLabel:TEXTING_COPY.phoneLabel,placeholder:TEXTING_COPY.phoneLabel,placeholderTextColor:styles.placeholder.color,ref:phoneRef,onSubmitEditing:submit,...fieldFocus,style:styles.field,testID:"texting-ask-phone-input"},"phone"),
|
|
174
179
|
/* @__PURE__ */jsxRuntime.jsx(reactNative.Pressable,{onPress:submit,disabled:busy,accessibilityRole:"button",accessibilityLabel:busy?TEXTING_COPY.sendingCode:TEXTING_COPY.sendCode,accessibilityState:{disabled:busy,busy:busy},style:[styles.primary,busy?styles.dimmed:null],testID:"texting-ask-send",children:/* @__PURE__ */jsxRuntime.jsx(Text,{tier:"control",style:styles.primaryLabel,children:busy?TEXTING_COPY.sendingCode:TEXTING_COPY.sendCode})})]})]})}if(onCode){let confirming=status==="confirming",resending=status==="requesting",busy=confirming||resending,submit=()=>{let found=validateTextingCode(code);setProblem(found),found===null&&texting.confirm(code)};/* @__PURE__ */
|
|
175
180
|
return jsxRuntime.jsxs(reactNative.View,{style:styles.root,testID:"texting-ask-code",children:[
|
|
176
181
|
/* @__PURE__ */jsxRuntime.jsxs(reactNative.View,{style:styles.head,children:[
|
|
@@ -179,16 +184,16 @@ return jsxRuntime.jsxs(reactNative.View,{style:styles.root,testID:"texting-ask-c
|
|
|
179
184
|
/* @__PURE__ */jsxRuntime.jsxs(reactNative.View,{style:styles.links,children:[
|
|
180
185
|
/* @__PURE__ */jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>{setCode(""),texting.resend()},disabled:busy,accessibilityRole:"button",accessibilityState:{disabled:busy,busy:resending},style:[styles.link,busy?styles.dimmed:null],children:/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.linkLabel,children:TEXTING_COPY.requestNewCode})}),
|
|
181
186
|
/* @__PURE__ */jsxRuntime.jsx(reactNative.Pressable,{onPress:()=>{setCode(""),texting.changeNumber()},disabled:busy,accessibilityRole:"button",accessibilityState:{disabled:busy},style:[styles.link,busy?styles.dimmed:null],children:/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.linkLabel,children:TEXTING_COPY.changeNumber})})]})]}),close]}),inputProblem,refusal,
|
|
182
|
-
/* @__PURE__ */jsxRuntime.jsxs(reactNative.View,{style:
|
|
183
|
-
/* @__PURE__ */jsxRuntime.jsx(TextInput,{value:code,onChangeText:value=>setCode(value.replace(/\D/g,"")),editable:!busy,
|
|
184
|
-
/* @__PURE__ */jsxRuntime.jsx(reactNative.Pressable,{onPress:submit,disabled:busy,accessibilityRole:"button",accessibilityLabel:confirming?TEXTING_COPY.confirmingCode:TEXTING_COPY.confirmCode,accessibilityState:{disabled:busy,busy:confirming},style:[styles.primary,busy?styles.dimmed:null],testID:"texting-ask-confirm",children:/* @__PURE__ */jsxRuntime.jsx(Text,{tier:"control",style:styles.primaryLabel,children:confirming?TEXTING_COPY.confirmingCode:TEXTING_COPY.confirmCode})})]})]})}return null}function makeAskStyles(theme){let{color:color,radius:radius,space:space,type:type,slots:slots}=theme,text3=(size,ink,weight)=>({...face(theme,weight),fontSize:size,lineHeight:Math.round(size*type.lineHeight.snug),color:ink});return reactNative.StyleSheet.create({root:{gap:space.sm,width:"100%"},head:{flexDirection:"row",alignItems:"flex-start",gap:space.sm},headBody:{flex:1,minWidth:0,gap:space.xs},consentRow:{flexDirection:"row",alignItems:"flex-start",gap:space.sm,minHeight:44},box:{width:24,height:24,borderRadius:radius.xs,borderWidth:2,borderColor:color.controlEdge,alignItems:"center",justifyContent:"center",backgroundColor:color.surface},boxChecked:{backgroundColor:color.brand,borderColor:color.brandInk},tick:text3(type.size.caption,color.text.onBrand,"bold"),consentText:{flex:1,...text3(type.size.caption,color.text.secondary,"regular")},body:text3(type.size.body,color.text.primary,"regular"),footnote:text3(type.size.caption,color.text.muted,"regular"),pill:{flexDirection:"row",alignItems:"center",gap:space.xs,minHeight:50,paddingVertical:space.xs,paddingLeft:space.md,paddingRight:space.xs,borderRadius:radius.pill,borderWidth:1.5,borderColor:color.controlEdge,backgroundColor:color.surface,...slotBox(slots.input,1)},field:{flex:1,minWidth:0,minHeight:44,padding:0,...text3(type.size.body,color.text.primary,"regular"),...slotText(slots.input)},digits:{fontVariant:["tabular-nums"]},primary:{minHeight:
|
|
185
|
-
return jsxRuntime.jsx(reactNative.Modal,{transparent:true,visible:true,animationType:theme.motion.reducedMotion?"none":"fade",onRequestClose:finish,children:/* @__PURE__ */jsxRuntime.jsxs(reactNative.
|
|
187
|
+
/* @__PURE__ */jsxRuntime.jsxs(reactNative.View,{style:pill,children:[
|
|
188
|
+
/* @__PURE__ */jsxRuntime.jsx(TextInput,{value:code,onChangeText:value=>setCode(value.replace(/\D/g,"")),editable:!busy,keyboardType:"number-pad",textContentType:"oneTimeCode",autoComplete:"sms-otp",maxLength:6,accessibilityLabel:TEXTING_COPY.codeLabel,placeholder:TEXTING_COPY.codeLabel,placeholderTextColor:styles.placeholder.color,ref:codeRef,onSubmitEditing:submit,...fieldFocus,style:[styles.field,styles.digits],testID:"texting-ask-code-input"},"code"),
|
|
189
|
+
/* @__PURE__ */jsxRuntime.jsx(reactNative.Pressable,{onPress:submit,disabled:busy,accessibilityRole:"button",accessibilityLabel:confirming?TEXTING_COPY.confirmingCode:TEXTING_COPY.confirmCode,accessibilityState:{disabled:busy,busy:confirming},style:[styles.primary,busy?styles.dimmed:null],testID:"texting-ask-confirm",children:/* @__PURE__ */jsxRuntime.jsx(Text,{tier:"control",style:styles.primaryLabel,children:confirming?TEXTING_COPY.confirmingCode:TEXTING_COPY.confirmCode})})]})]})}return null}function makeAskStyles(theme,align="auto"){let{color:color,radius:radius,space:space,type:type,slots:slots}=theme,text3=(size,ink,weight)=>({...face(theme,weight),fontSize:size,lineHeight:Math.round(size*type.lineHeight.snug),color:ink}),words={textAlign:align};return reactNative.StyleSheet.create({root:{gap:space.sm,width:"100%"},head:{flexDirection:"row",alignItems:"flex-start",gap:space.sm},headBody:{flex:1,minWidth:0,gap:space.xs},consentRow:{flexDirection:"row",alignItems:"flex-start",gap:space.sm,minHeight:44},box:{width:24,height:24,borderRadius:radius.xs,borderWidth:2,borderColor:color.controlEdge,alignItems:"center",justifyContent:"center",backgroundColor:color.surface},boxChecked:{backgroundColor:color.brand,borderColor:color.brandInk},tick:text3(type.size.caption,color.text.onBrand,"bold"),consentText:{...align==="center"?{flexShrink:1}:{flex:1},...text3(type.size.caption,color.text.secondary,"regular"),...words},body:{...text3(type.size.body,color.text.primary,"regular"),...words},footnote:{...text3(type.size.caption,color.text.muted,"regular"),...words},placeholder:{color:color.text.placeholder},pill:{flexDirection:"row",alignItems:"center",gap:space.xs,minHeight:50,paddingVertical:space.xs,paddingLeft:space.md,paddingRight:space.xs,borderRadius:radius.pill,borderWidth:1.5,borderColor:color.controlEdge,backgroundColor:color.surface,...slotBox(slots.input,1)},pillFocused:{borderWidth:1.5,borderColor:slots.input?.borderColor??color.brandInk},field:{flex:1,minWidth:0,minHeight:44,padding:0,...text3(type.size.body,color.text.primary,"regular"),...slotText(slots.input)},digits:{fontVariant:["tabular-nums"]},primary:{minHeight:44,paddingHorizontal:space.lg,borderRadius:radius.pill,alignItems:"center",justifyContent:"center",backgroundColor:color.brand,...slotBox(slots.primaryButton)},primaryLabel:{...text3(type.size.caption,color.text.onBrand,"bold"),...slotText(slots.primaryButton)},dimmed:{opacity:.5},close:{width:44,height:44,alignItems:"center",justifyContent:"center"},closeBar:{position:"absolute",width:18,height:2,borderRadius:1,backgroundColor:color.text.muted},closeBarA:{transform:[{rotate:"45deg"}]},closeBarB:{transform:[{rotate:"-45deg"}]},links:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:space.md},link:{minHeight:44,justifyContent:"center"},linkLabel:{...text3(type.size.caption,color.linkInk,"bold"),...slotText(slots.link)},notice:{gap:space.xs},noticeText:{...text3(type.size.caption,color.errorRed,"regular"),...words}})}var ORIENTATIONS=["portrait","landscape"],OPEN=/* @__PURE__ */new Set(["offered","enrolling"]);function EverfurTextingPrompt({onResolved:onResolved}){let introOpen=useIntroOpen(),ask=useTextingAsk({surface:"prompt",ready:!introOpen}),theme=useEverfurTheme(),styles=react.useMemo(()=>makePromptStyles(theme),[theme]),entryStyles=react.useMemo(()=>makeAskStyles(theme,"center"),[theme]),shown=react.useRef(false),[resolved,setResolved]=react.useState(false);OPEN.has(ask.stage)&&(shown.current=true);let open=shown.current&&(OPEN.has(ask.stage)||ask.stage==="verified")&&!resolved&&!introOpen,finish=()=>{resolved||(ask.stage==="verified"?(setResolved(true),callHost(onResolved,"verified")):ask.dismiss())};if(react.useEffect(()=>{shown.current&&ask.stage==="dismissed"&&!resolved&&(setResolved(true),callHost(onResolved,"dismissed"))},[ask.stage,onResolved,resolved]),!open)return null;let title=ask.stage==="verified"?TEXTING_COPY.verifiedTitle:TEXTING_BRAND_COPY.promptTitle(ask.brand);/* @__PURE__ */
|
|
190
|
+
return jsxRuntime.jsx(reactNative.Modal,{transparent:true,visible:true,animationType:theme.motion.reducedMotion?"none":"fade",statusBarTranslucent:true,supportedOrientations:ORIENTATIONS,onRequestClose:finish,children:/* @__PURE__ */jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{behavior:reactNative.Platform.OS==="ios"?"padding":"height",style:styles.backdrop,children:[
|
|
186
191
|
/* @__PURE__ */jsxRuntime.jsx(reactNative.Pressable,{style:ABSOLUTE_FILL,accessibilityRole:"button",accessibilityLabel:TEXTING_COPY.close,onPress:finish}),
|
|
187
|
-
/* @__PURE__ */jsxRuntime.
|
|
192
|
+
/* @__PURE__ */jsxRuntime.jsx(reactNative.View,{style:styles.sheet,accessibilityViewIsModal:true,testID:"everfur-texting-prompt",children:/* @__PURE__ */jsxRuntime.jsxs(reactNative.ScrollView,{style:styles.scroller,contentContainerStyle:styles.sheetBody,keyboardShouldPersistTaps:"handled",bounces:false,testID:"everfur-texting-prompt-scroll",children:[
|
|
188
193
|
/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.title,accessibilityRole:"header",children:title}),ask.stage==="offered"?/* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[
|
|
189
194
|
/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.body,children:TEXTING_COPY.promptBody}),
|
|
190
195
|
/* @__PURE__ */jsxRuntime.jsxs(reactNative.View,{style:styles.actions,children:[
|
|
191
196
|
/* @__PURE__ */jsxRuntime.jsx(reactNative.Pressable,{onPress:ask.accept,accessibilityRole:"button",accessibilityLabel:TEXTING_COPY.promptAccept,style:styles.primary,testID:"texting-prompt-accept",children:/* @__PURE__ */jsxRuntime.jsx(Text,{tier:"control",style:styles.primaryLabel,children:TEXTING_COPY.promptAccept})}),
|
|
192
197
|
/* @__PURE__ */jsxRuntime.jsx(reactNative.Pressable,{onPress:ask.dismiss,accessibilityRole:"button",accessibilityLabel:TEXTING_COPY.promptDismiss,style:styles.secondary,testID:"texting-prompt-dismiss",children:/* @__PURE__ */jsxRuntime.jsx(Text,{tier:"control",style:styles.secondaryLabel,children:TEXTING_COPY.promptDismiss})})]})]}):null,ask.stage==="enrolling"?/* @__PURE__ */jsxRuntime.jsx(AskEntry,{ask:ask,styles:entryStyles}):null,ask.stage==="verified"?/* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[
|
|
193
198
|
/* @__PURE__ */jsxRuntime.jsx(Text,{style:styles.body,children:TEXTING_BRAND_COPY.chatAskVerified(ask.brand)}),
|
|
194
|
-
/* @__PURE__ */jsxRuntime.jsx(reactNative.View,{style:styles.actions,children:/* @__PURE__ */jsxRuntime.jsx(reactNative.Pressable,{onPress:finish,accessibilityRole:"button",accessibilityLabel:TEXTING_COPY.close,style:styles.secondary,testID:"texting-prompt-close",children:/* @__PURE__ */jsxRuntime.jsx(Text,{tier:"control",style:styles.secondaryLabel,children:TEXTING_COPY.close})})})]}):null]})]})})}function makePromptStyles(theme){let{color:color,radius:radius,space:space,type:type,slots:slots}=theme,dialogText=slotText(slots.dialog),text3=(size,ink,weight)=>({...face(theme,weight),fontSize:size,lineHeight:Math.round(size*type.lineHeight.normal),color:ink}),button={minHeight:48,paddingHorizontal:space.lg,borderRadius:radius.pill,alignItems:"center",justifyContent:"center"};return reactNative.StyleSheet.create({backdrop:{flex:1,justifyContent:"center",paddingHorizontal:space.lg,backgroundColor:"rgba(0,0,0,0.4)"},sheet:{width:"100%",maxWidth:480,alignSelf:"center",backgroundColor:color.surface,borderRadius:radius.xl,paddingHorizontal:space.lg,paddingTop:space.xl,paddingBottom:space.lg,
|
|
199
|
+
/* @__PURE__ */jsxRuntime.jsx(reactNative.View,{style:styles.actions,children:/* @__PURE__ */jsxRuntime.jsx(reactNative.Pressable,{onPress:finish,accessibilityRole:"button",accessibilityLabel:TEXTING_COPY.close,style:styles.secondary,testID:"texting-prompt-close",children:/* @__PURE__ */jsxRuntime.jsx(Text,{tier:"control",style:styles.secondaryLabel,children:TEXTING_COPY.close})})})]}):null]})})]})})}function makePromptStyles(theme){let{color:color,radius:radius,space:space,type:type,slots:slots}=theme,dialogText=slotText(slots.dialog),text3=(size,ink,weight)=>({...face(theme,weight),fontSize:size,lineHeight:Math.round(size*type.lineHeight.normal),color:ink}),button={minHeight:48,paddingHorizontal:space.lg,borderRadius:radius.pill,alignItems:"center",justifyContent:"center"};return reactNative.StyleSheet.create({backdrop:{flex:1,justifyContent:"center",paddingHorizontal:space.lg,backgroundColor:"rgba(0,0,0,0.4)"},sheet:{width:"100%",maxWidth:480,alignSelf:"center",backgroundColor:color.surface,borderRadius:radius.xl,maxHeight:"88%",overflow:"hidden",...slotBox(slots.dialog)},scroller:{flexGrow:0,flexShrink:1},sheetBody:{paddingHorizontal:space.lg,paddingTop:space.xl,paddingBottom:space.lg,gap:space.md},title:{...text3(type.size.heading,color.text.primary,"bold"),...headingFace(theme,"bold"),textAlign:"center",...dialogText},body:{...text3(type.size.body,color.text.secondary,"regular"),textAlign:"center",...dialogText},actions:{gap:space.xs},primary:{...button,backgroundColor:color.brand,...slotBox(slots.primaryButton)},primaryLabel:{...text3(type.size.body,color.text.onBrand,"bold"),...slotText(slots.primaryButton)},secondary:button,secondaryLabel:text3(type.size.body,color.text.muted,"bold")})}exports.COPY_PLACEHOLDER_PREFIX=COPY_PLACEHOLDER_PREFIX;exports.ChatTextingAskComposer=ChatTextingAskComposer;exports.ChatTextingAskController=ChatTextingAskController;exports.EVERFUR_TEXTING_STATUSES=EVERFUR_TEXTING_STATUSES;exports.EverfurTextingOptIn=EverfurTextingOptIn;exports.EverfurTextingPrompt=EverfurTextingPrompt;exports.TEXTING_ASK_MAX_ASKS=TEXTING_ASK_MAX_ASKS;exports.TEXTING_ASK_SCHEDULE_KEY=TEXTING_ASK_SCHEDULE_KEY;exports.TEXTING_ASK_SNOOZE_MS=TEXTING_ASK_SNOOZE_MS;exports.TEXTING_BRAND_COPY=TEXTING_BRAND_COPY;exports.TEXTING_CODE_PATTERN=TEXTING_CODE_PATTERN;exports.TEXTING_COPY=TEXTING_COPY;exports.TEXTING_COPY_PLACEHOLDERS=TEXTING_COPY_PLACEHOLDERS;exports.TEXTING_UI_CODE_LENGTH=TEXTING_UI_CODE_LENGTH;exports.TextingController=TextingController;exports.createTextingRepository=createTextingRepository;exports.createTextingRepositoryOver=createTextingRepositoryOver;exports.formatTextingPhone=formatTextingPhone;exports.isE164=isE164;exports.isTextingAskEligible=isTextingAskEligible;exports.parseTextingProfile=parseTextingProfile;exports.resolveTextingAskDue=resolveTextingAskDue;exports.textingAskLines=textingAskLines;exports.textingAskThreadReady=textingAskThreadReady;exports.textingErrorText=textingErrorText;exports.textingIdentityFromWire=textingIdentityFromWire;exports.textingInputProblemText=textingInputProblemText;exports.textingOptedOutBody=textingOptedOutBody;exports.textingReasonOf=textingReasonOf;exports.textingSupportText=textingSupportText;exports.toTextingE164=toTextingE164;exports.useEverfurTexting=useEverfurTexting;exports.useEverfurTextingProfile=useEverfurTextingProfile;exports.useEverfurTextingRepository=useEverfurTextingRepository;exports.useTextingAsk=useTextingAsk;exports.validateTextingCode=validateTextingCode;exports.validateTextingEnroll=validateTextingEnroll;
|
package/dist/texting/index.d.cts
CHANGED
|
@@ -4,14 +4,14 @@ import { StyleProp, ViewStyle } from 'react-native';
|
|
|
4
4
|
import { a as CapabilityDecision } from '../resolve.d-CoQWUy1Y.cjs';
|
|
5
5
|
import { E as EverfurError } from '../EverfurError.d-8NHtlgzA.cjs';
|
|
6
6
|
export { a as EverfurErrorCategory, b as EverfurErrorCode } from '../EverfurError.d-8NHtlgzA.cjs';
|
|
7
|
-
import { E as EverfurTextingViewStatus, T as TextingCopy, a as TextingBrandCopy, b as TextingAsk } from '../optInView.d-
|
|
8
|
-
export { C as COPY_PLACEHOLDER_PREFIX, c as EVERFUR_TEXTING_STATUSES, d as EverfurTextingChallenge, e as EverfurTextingIdentity, f as EverfurTextingInputProblem, g as EverfurTextingProfile, h as EverfurTextingReason, i as EverfurTextingState, j as EverfurTextingStatus, k as EverfurTextingVerificationInput, l as TEXTING_ASK_MAX_ASKS, m as TEXTING_ASK_SCHEDULE_KEY, n as TEXTING_ASK_SNOOZE_MS, o as TEXTING_BRAND_COPY, p as TEXTING_CODE_PATTERN, q as TEXTING_COPY, r as TEXTING_COPY_PLACEHOLDERS, s as TEXTING_UI_CODE_LENGTH, t as TextingAction, u as TextingAskDue, v as TextingAskDueInput, w as TextingAskEntry, x as TextingAskIdentity, y as TextingAskOptions, z as TextingAskScheduleRead, A as TextingAskStage, B as TextingAskThreadMessage, D as TextingAskThreadState, F as TextingCodeRefusal, G as TextingController, H as TextingPhase, I as TextingRepository, J as TextingRepositoryDeps, K as TextingRuntime, L as TextingSnapshot, M as createTextingRepository, N as createTextingRepositoryOver, O as formatTextingPhone, P as isE164, Q as isTextingAskEligible, R as parseTextingProfile, S as resolveTextingAskDue, U as textingAskThreadReady, V as textingErrorText, W as textingIdentityFromWire, X as textingInputProblemText, Y as textingOptedOutBody, Z as textingReasonOf, _ as textingSupportText, $ as toTextingE164, a0 as useEverfurTexting, a1 as useEverfurTextingProfile, a2 as useEverfurTextingRepository, a3 as useTextingAsk, a4 as validateTextingCode, a5 as validateTextingEnroll } from '../optInView.d-
|
|
9
|
-
export { A as AuthContext, I as IdentityProvider, M as MintedToken, T as TokenProvider } from '../identity.d-
|
|
10
|
-
export { A as AcceptedFrame, a as AnalysisCompleteFrame, b as AnalysisStartedFrame, D as DeltaFrame, c as DoneFrame, E as ErrorFrame, d as EverfurRequest, e as EverfurRequestBase, F as Frame, f as FrameBase, g as FrameKind, H as HeartbeatFrame, h as HttpMethod, M as MultipartBody, T as TransportPort, U as UnknownFrame, i as UrgencyLevel } from '../config.d-
|
|
7
|
+
import { E as EverfurTextingViewStatus, T as TextingCopy, a as TextingBrandCopy, b as TextingAsk } from '../optInView.d-DVuuWDRw.cjs';
|
|
8
|
+
export { C as COPY_PLACEHOLDER_PREFIX, c as EVERFUR_TEXTING_STATUSES, d as EverfurTextingChallenge, e as EverfurTextingIdentity, f as EverfurTextingInputProblem, g as EverfurTextingProfile, h as EverfurTextingReason, i as EverfurTextingState, j as EverfurTextingStatus, k as EverfurTextingVerificationInput, l as TEXTING_ASK_MAX_ASKS, m as TEXTING_ASK_SCHEDULE_KEY, n as TEXTING_ASK_SNOOZE_MS, o as TEXTING_BRAND_COPY, p as TEXTING_CODE_PATTERN, q as TEXTING_COPY, r as TEXTING_COPY_PLACEHOLDERS, s as TEXTING_UI_CODE_LENGTH, t as TextingAction, u as TextingAskDue, v as TextingAskDueInput, w as TextingAskEntry, x as TextingAskIdentity, y as TextingAskOptions, z as TextingAskScheduleRead, A as TextingAskStage, B as TextingAskThreadMessage, D as TextingAskThreadState, F as TextingCodeRefusal, G as TextingController, H as TextingPhase, I as TextingRepository, J as TextingRepositoryDeps, K as TextingRuntime, L as TextingSnapshot, M as createTextingRepository, N as createTextingRepositoryOver, O as formatTextingPhone, P as isE164, Q as isTextingAskEligible, R as parseTextingProfile, S as resolveTextingAskDue, U as textingAskThreadReady, V as textingErrorText, W as textingIdentityFromWire, X as textingInputProblemText, Y as textingOptedOutBody, Z as textingReasonOf, _ as textingSupportText, $ as toTextingE164, a0 as useEverfurTexting, a1 as useEverfurTextingProfile, a2 as useEverfurTextingRepository, a3 as useTextingAsk, a4 as validateTextingCode, a5 as validateTextingEnroll } from '../optInView.d-DVuuWDRw.cjs';
|
|
9
|
+
export { A as AuthContext, I as IdentityProvider, M as MintedToken, T as TokenProvider } from '../identity.d-COcNGuCJ.cjs';
|
|
10
|
+
export { A as AcceptedFrame, a as AnalysisCompleteFrame, b as AnalysisStartedFrame, D as DeltaFrame, c as DoneFrame, E as ErrorFrame, d as EverfurRequest, e as EverfurRequestBase, F as Frame, f as FrameBase, g as FrameKind, H as HeartbeatFrame, h as HttpMethod, M as MultipartBody, T as TransportPort, U as UnknownFrame, i as UrgencyLevel } from '../config.d-D1xcxALX.cjs';
|
|
11
11
|
export { B as Brand, C as ConversationId, P as PetRef, R as RecordsRequestId, U as UserRef, _ as __brand } from '../ids.d-B2GAAifq.cjs';
|
|
12
12
|
export { E as EverfurResult } from '../EverfurResult.d-BFH-3s6E.cjs';
|
|
13
13
|
export { E as ErrorPolicyPort } from '../ErrorPolicyPort.d-DirW9hgO.cjs';
|
|
14
|
-
import '../requestFunnel.d-
|
|
14
|
+
import '../requestFunnel.d-BdpL7gwg.cjs';
|
|
15
15
|
|
|
16
16
|
interface EverfurTextingOptInProps {
|
|
17
17
|
/** Called when the member's step changes (for example to `verified` or `optedOut`). A throw is swallowed. */
|
package/dist/texting/index.d.ts
CHANGED
|
@@ -4,14 +4,14 @@ import { StyleProp, ViewStyle } from 'react-native';
|
|
|
4
4
|
import { a as CapabilityDecision } from '../resolve.d-CoQWUy1Y.js';
|
|
5
5
|
import { E as EverfurError } from '../EverfurError.d-8NHtlgzA.js';
|
|
6
6
|
export { a as EverfurErrorCategory, b as EverfurErrorCode } from '../EverfurError.d-8NHtlgzA.js';
|
|
7
|
-
import { E as EverfurTextingViewStatus, T as TextingCopy, a as TextingBrandCopy, b as TextingAsk } from '../optInView.d-
|
|
8
|
-
export { C as COPY_PLACEHOLDER_PREFIX, c as EVERFUR_TEXTING_STATUSES, d as EverfurTextingChallenge, e as EverfurTextingIdentity, f as EverfurTextingInputProblem, g as EverfurTextingProfile, h as EverfurTextingReason, i as EverfurTextingState, j as EverfurTextingStatus, k as EverfurTextingVerificationInput, l as TEXTING_ASK_MAX_ASKS, m as TEXTING_ASK_SCHEDULE_KEY, n as TEXTING_ASK_SNOOZE_MS, o as TEXTING_BRAND_COPY, p as TEXTING_CODE_PATTERN, q as TEXTING_COPY, r as TEXTING_COPY_PLACEHOLDERS, s as TEXTING_UI_CODE_LENGTH, t as TextingAction, u as TextingAskDue, v as TextingAskDueInput, w as TextingAskEntry, x as TextingAskIdentity, y as TextingAskOptions, z as TextingAskScheduleRead, A as TextingAskStage, B as TextingAskThreadMessage, D as TextingAskThreadState, F as TextingCodeRefusal, G as TextingController, H as TextingPhase, I as TextingRepository, J as TextingRepositoryDeps, K as TextingRuntime, L as TextingSnapshot, M as createTextingRepository, N as createTextingRepositoryOver, O as formatTextingPhone, P as isE164, Q as isTextingAskEligible, R as parseTextingProfile, S as resolveTextingAskDue, U as textingAskThreadReady, V as textingErrorText, W as textingIdentityFromWire, X as textingInputProblemText, Y as textingOptedOutBody, Z as textingReasonOf, _ as textingSupportText, $ as toTextingE164, a0 as useEverfurTexting, a1 as useEverfurTextingProfile, a2 as useEverfurTextingRepository, a3 as useTextingAsk, a4 as validateTextingCode, a5 as validateTextingEnroll } from '../optInView.d-
|
|
9
|
-
export { A as AuthContext, I as IdentityProvider, M as MintedToken, T as TokenProvider } from '../identity.d-
|
|
10
|
-
export { A as AcceptedFrame, a as AnalysisCompleteFrame, b as AnalysisStartedFrame, D as DeltaFrame, c as DoneFrame, E as ErrorFrame, d as EverfurRequest, e as EverfurRequestBase, F as Frame, f as FrameBase, g as FrameKind, H as HeartbeatFrame, h as HttpMethod, M as MultipartBody, T as TransportPort, U as UnknownFrame, i as UrgencyLevel } from '../config.d-
|
|
7
|
+
import { E as EverfurTextingViewStatus, T as TextingCopy, a as TextingBrandCopy, b as TextingAsk } from '../optInView.d-CY2IueSZ.js';
|
|
8
|
+
export { C as COPY_PLACEHOLDER_PREFIX, c as EVERFUR_TEXTING_STATUSES, d as EverfurTextingChallenge, e as EverfurTextingIdentity, f as EverfurTextingInputProblem, g as EverfurTextingProfile, h as EverfurTextingReason, i as EverfurTextingState, j as EverfurTextingStatus, k as EverfurTextingVerificationInput, l as TEXTING_ASK_MAX_ASKS, m as TEXTING_ASK_SCHEDULE_KEY, n as TEXTING_ASK_SNOOZE_MS, o as TEXTING_BRAND_COPY, p as TEXTING_CODE_PATTERN, q as TEXTING_COPY, r as TEXTING_COPY_PLACEHOLDERS, s as TEXTING_UI_CODE_LENGTH, t as TextingAction, u as TextingAskDue, v as TextingAskDueInput, w as TextingAskEntry, x as TextingAskIdentity, y as TextingAskOptions, z as TextingAskScheduleRead, A as TextingAskStage, B as TextingAskThreadMessage, D as TextingAskThreadState, F as TextingCodeRefusal, G as TextingController, H as TextingPhase, I as TextingRepository, J as TextingRepositoryDeps, K as TextingRuntime, L as TextingSnapshot, M as createTextingRepository, N as createTextingRepositoryOver, O as formatTextingPhone, P as isE164, Q as isTextingAskEligible, R as parseTextingProfile, S as resolveTextingAskDue, U as textingAskThreadReady, V as textingErrorText, W as textingIdentityFromWire, X as textingInputProblemText, Y as textingOptedOutBody, Z as textingReasonOf, _ as textingSupportText, $ as toTextingE164, a0 as useEverfurTexting, a1 as useEverfurTextingProfile, a2 as useEverfurTextingRepository, a3 as useTextingAsk, a4 as validateTextingCode, a5 as validateTextingEnroll } from '../optInView.d-CY2IueSZ.js';
|
|
9
|
+
export { A as AuthContext, I as IdentityProvider, M as MintedToken, T as TokenProvider } from '../identity.d-BEJcHY-5.js';
|
|
10
|
+
export { A as AcceptedFrame, a as AnalysisCompleteFrame, b as AnalysisStartedFrame, D as DeltaFrame, c as DoneFrame, E as ErrorFrame, d as EverfurRequest, e as EverfurRequestBase, F as Frame, f as FrameBase, g as FrameKind, H as HeartbeatFrame, h as HttpMethod, M as MultipartBody, T as TransportPort, U as UnknownFrame, i as UrgencyLevel } from '../config.d-jTVsAeky.js';
|
|
11
11
|
export { B as Brand, C as ConversationId, P as PetRef, R as RecordsRequestId, U as UserRef, _ as __brand } from '../ids.d-B2GAAifq.js';
|
|
12
12
|
export { E as EverfurResult } from '../EverfurResult.d-D_-254ZY.js';
|
|
13
13
|
export { E as ErrorPolicyPort } from '../ErrorPolicyPort.d-68yrE3BE.js';
|
|
14
|
-
import '../requestFunnel.d-
|
|
14
|
+
import '../requestFunnel.d-BPsCHJWf.js';
|
|
15
15
|
|
|
16
16
|
interface EverfurTextingOptInProps {
|
|
17
17
|
/** Called when the member's step changes (for example to `verified` or `optedOut`). A throw is swallowed. */
|
package/dist/texting/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! @everfur/sdk. Copyright (c) 2026 Strand Health Inc. dba Everfur. All rights reserved. Use is subject to the Everfur SDK License: https://docs.everfur.com/license */
|
|
2
|
-
import{createContext,forwardRef,createElement,useMemo,useRef,useEffect,useSyncExternalStore,useCallback,useState,useContext,Component}from"react";import{TextInput as TextInput$1,View,ActivityIndicator,Pressable,StyleSheet,Modal,Text as Text$1}from"react-native";import{jsxs,jsx,Fragment}from"react/jsx-runtime";function slotBox(slot,borderWidth){if(slot===void 0)return{};let out={};return slot.backgroundColor!==void 0&&(out.backgroundColor=slot.backgroundColor),slot.borderColor!==void 0&&(out.borderColor=slot.borderColor,out.borderWidth=borderWidth??1),slot.borderRadius!==void 0&&(out.borderRadius=slot.borderRadius),out}function slotText(slot){return slot?.textColor===void 0?{}:{color:slot.textColor}}var FACE_WEIGHT=/* @__PURE__ */Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function face(theme,weight){let type=theme.type,fontFamily=type.families[weight];return weight==="mono"||type.namedFaces[weight]?{fontFamily:fontFamily}:{fontFamily:fontFamily,fontWeight:type.weight[FACE_WEIGHT[weight]]}}function headingFace(theme,fallback="bold"){let{headingFamily:headingFamily,headingWeight:headingWeight}=theme.type;if(headingFamily===null&&headingWeight===null)return face(theme,fallback);if(headingFamily!==null)return{fontFamily:headingFamily,fontWeight:headingWeight??theme.type.weight[FACE_WEIGHT[fallback]]};let base=face(theme,fallback);return base.fontWeight===void 0||headingWeight===null?base:{fontFamily:base.fontFamily,fontWeight:headingWeight}}function reportHostFailure(error){let globalConsole=globalThis.console;try{globalConsole?.error?.("[everfur] A host callback threw; the SDK ignored it.",error)}catch{}}function isThenable(value){return(typeof value=="object"||typeof value=="function")&&value!==null&&typeof value.then=="function"}function callHost(fn,...args){if(typeof fn=="function")try{let result=fn(...args);return isThenable(result)&&Promise.resolve(result).then(void 0,reportHostFailure),result}catch(error){reportHostFailure(error);return}}var GUARDED=/* @__PURE__ */new WeakMap;function guardHost(fn){if(typeof fn!="function")return;let cached=GUARDED.get(fn);if(cached!==void 0)return cached;let guarded=(...args)=>{callHost(fn,...args)};return GUARDED.set(fn,guarded),guarded}function guardHostProps(props,names){let guarded=null;for(let name of names){let fn=props[name];typeof fn=="function"&&(guarded??={...props},guarded[name]=guardHost(fn))}return guarded??props}var HostRenderBoundary=class extends Component{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey}}static getDerivedStateFromError(){return{failed:true}}static getDerivedStateFromProps(props,state2){return Object.is(props.resetKey,state2.key)?null:{failed:false,key:props.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};function RenderHost({render:render}){return render()}function HostRender({render:render,fallback:fallback,resetKey:resetKey}){return createElement(HostRenderBoundary,{fallback:fallback,resetKey:resetKey,children:createElement(RenderHost,{render:render})})}var CONTRACT_RETRYABILITY=/* @__PURE__ */Object.freeze([
|
|
2
|
+
import{createContext,forwardRef,createElement,useMemo,useRef,useEffect,useSyncExternalStore,useCallback,useState,useContext,Component}from"react";import{TextInput as TextInput$1,View,ActivityIndicator,Pressable,StyleSheet,Modal,KeyboardAvoidingView,ScrollView,Platform,Text as Text$1,AccessibilityInfo}from"react-native";import{jsxs,jsx,Fragment}from"react/jsx-runtime";function slotBox(slot,borderWidth){if(slot===void 0)return{};let out={};return slot.backgroundColor!==void 0&&(out.backgroundColor=slot.backgroundColor),slot.borderColor!==void 0&&(out.borderColor=slot.borderColor,out.borderWidth=borderWidth??1),slot.borderRadius!==void 0&&(out.borderRadius=slot.borderRadius),out}function slotText(slot){return slot?.textColor===void 0?{}:{color:slot.textColor}}var FACE_WEIGHT=/* @__PURE__ */Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function face(theme,weight){let type=theme.type,fontFamily=type.families[weight];return weight==="mono"||type.namedFaces[weight]?{fontFamily:fontFamily}:{fontFamily:fontFamily,fontWeight:type.weight[FACE_WEIGHT[weight]]}}function headingFace(theme,fallback="bold"){let{headingFamily:headingFamily,headingWeight:headingWeight}=theme.type;if(headingFamily===null&&headingWeight===null)return face(theme,fallback);if(headingFamily!==null)return{fontFamily:headingFamily,fontWeight:headingWeight??theme.type.weight[FACE_WEIGHT[fallback]]};let base=face(theme,fallback);return base.fontWeight===void 0||headingWeight===null?base:{fontFamily:base.fontFamily,fontWeight:headingWeight}}function reportHostFailure(error){let globalConsole=globalThis.console;try{globalConsole?.error?.("[everfur] A host callback threw; the SDK ignored it.",error)}catch{}}function isThenable(value){return(typeof value=="object"||typeof value=="function")&&value!==null&&typeof value.then=="function"}function callHost(fn,...args){if(typeof fn=="function")try{let result=fn(...args);return isThenable(result)&&Promise.resolve(result).then(void 0,reportHostFailure),result}catch(error){reportHostFailure(error);return}}var GUARDED=/* @__PURE__ */new WeakMap;function guardHost(fn){if(typeof fn!="function")return;let cached=GUARDED.get(fn);if(cached!==void 0)return cached;let guarded=(...args)=>{callHost(fn,...args)};return GUARDED.set(fn,guarded),guarded}function guardHostProps(props,names){let guarded=null;for(let name of names){let fn=props[name];typeof fn=="function"&&(guarded??={...props},guarded[name]=guardHost(fn))}return guarded??props}var HostRenderBoundary=class extends Component{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey}}static getDerivedStateFromError(){return{failed:true}}static getDerivedStateFromProps(props,state2){return Object.is(props.resetKey,state2.key)?null:{failed:false,key:props.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};function RenderHost({render:render}){return render()}function HostRender({render:render,fallback:fallback,resetKey:resetKey}){return createElement(HostRenderBoundary,{fallback:fallback,resetKey:resetKey,children:createElement(RenderHost,{render:render})})}var CONTRACT_RETRYABILITY=/* @__PURE__ */Object.freeze([
|
|
3
3
|
/* @__PURE__ */Object.freeze({wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false}),
|
|
4
4
|
/* @__PURE__ */Object.freeze({wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false}),
|
|
5
5
|
/* @__PURE__ */Object.freeze({wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true}),
|
|
@@ -107,12 +107,14 @@ return Object.freeze({challengeId:challengeId,expiresAt:str3(o.expires_at),attem
|
|
|
107
107
|
return Object.freeze({reason:explicit.reason,level:explicit.level,recoverable:explicit.recoverable})}/* @__PURE__ */
|
|
108
108
|
return Object.freeze({reason:userFacingError("accessDenied"),level:"user_entitlement",recoverable:false})}function freezeDecision(d){let base={name:d.name,enabled:d.enabled,isPending:d.isPending,limits:/* @__PURE__ */Object.freeze({...d.limits})};return d.disabled!==void 0&&(base.disabled=d.disabled),/* @__PURE__ */Object.freeze(base)}function useCapability(name){let{runtime:runtime}=useEverfurContext(),store=runtime.entitlements,snapshot=useSyncExternalStore(store.subscribe,store.getSnapshot,store.getSnapshot);return useMemo(()=>decideCapability(name,snapshot.decisions,{isPending:snapshot.isPending}),[name,snapshot])}var MIN_OFFSTATE_HEIGHT=48;function selectView(decision){return decision.isPending?"pending":decision.enabled?"enabled":"disabled"}function CapabilityGate(props){let{capability:capability,children:children,renderDisabled:renderDisabled,renderPending:renderPending,style:style}=props,decision=useCapability(capability),view=useMemo(()=>selectView(decision),[decision]);switch(view){case"enabled":return children;case"pending":return renderPending?/* @__PURE__ */jsx(HostRender,{render:renderPending,fallback:/* @__PURE__ */jsx(PendingSkeleton,{capability:capability,style:style})}):/* @__PURE__ */jsx(PendingSkeleton,{capability:capability,style:style});case"disabled":return renderDisabled?/* @__PURE__ */jsx(HostRender,{render:()=>renderDisabled(decision),fallback:/* @__PURE__ */jsx(OffState,{decision:decision,style:style}),resetKey:decision}):/* @__PURE__ */jsx(OffState,{decision:decision,style:style});default:return assertNever(view)}}function PendingSkeleton({capability:capability,style:style}){let theme=useEverfurTheme(),styles=useMemo(()=>makeStyles(theme),[theme]);/* @__PURE__ */
|
|
109
109
|
return jsx(View,{style:[styles.offstate,style],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${capability}`,children:/* @__PURE__ */jsx(View,{style:styles.skeletonBar})})}function OffState({decision:decision,style:style}){let theme=useEverfurTheme(),styles=useMemo(()=>makeStyles(theme),[theme]),message=decision.disabled?.reason??"";/* @__PURE__ */
|
|
110
|
-
return jsx(View,{style:[styles.offstate,style],accessible:true,accessibilityRole:"text",accessibilityLabel:message,children:message.length>0?/* @__PURE__ */jsx(Text,{style:styles.offstateText,children:message}):null})}function makeStyles(theme){let{color:color,space:space,radius:radius,type:type}=theme;return StyleSheet.create({offstate:{minHeight:MIN_OFFSTATE_HEIGHT,justifyContent:"center",paddingHorizontal:space.lg,paddingVertical:space.md,backgroundColor:color.surfaceCream,borderRadius:radius.md,borderWidth:StyleSheet.hairlineWidth,borderColor:color.brandBorder},offstateText:{...face(theme,"regular"),fontSize:type.size.body,lineHeight:Math.round(type.size.body*type.lineHeight.normal),color:color.text.muted},skeletonBar:{height:space.md,borderRadius:radius.xs,backgroundColor:color.brandSofter}})}function EverfurTextingOptIn(props){let guarded=guardHostProps(props,["onStatusChange"]),resolved=useMemo(()=>({copy:resolveTextingCopy(props.copy),brandCopy:resolveTextingBrandCopy(props.brandCopy)}),[props.copy,props.brandCopy]),{copy:copy,brandCopy:brandCopy}=resolved,theme=useEverfurTheme(),styles=useMemo(()=>makeStyles2(theme),[theme]),texting=useEverfurTexting();return texting.status==="signedOut"?/* @__PURE__ */jsxs(View,{style:[styles.card,guarded.style],children:[
|
|
110
|
+
return jsx(View,{style:[styles.offstate,style],accessible:true,accessibilityRole:"text",accessibilityLabel:message,children:message.length>0?/* @__PURE__ */jsx(Text,{style:styles.offstateText,children:message}):null})}function makeStyles(theme){let{color:color,space:space,radius:radius,type:type}=theme;return StyleSheet.create({offstate:{minHeight:MIN_OFFSTATE_HEIGHT,justifyContent:"center",paddingHorizontal:space.lg,paddingVertical:space.md,backgroundColor:color.surfaceCream,borderRadius:radius.md,borderWidth:StyleSheet.hairlineWidth,borderColor:color.brandBorder},offstateText:{...face(theme,"regular"),fontSize:type.size.body,lineHeight:Math.round(type.size.body*type.lineHeight.normal),color:color.text.muted},skeletonBar:{height:space.md,borderRadius:radius.xs,backgroundColor:color.brandSofter}})}function announceLine(line){if(!(Platform.OS!=="ios"||line===""))try{let announce=AccessibilityInfo?.announceForAccessibility;typeof announce=="function"&&announce.call(AccessibilityInfo,line)}catch{}}function AnnounceLine({line:line}){return useEffect(()=>{announceLine(line)},[line]),null}function EverfurTextingOptIn(props){let guarded=guardHostProps(props,["onStatusChange"]),resolved=useMemo(()=>({copy:resolveTextingCopy(props.copy),brandCopy:resolveTextingBrandCopy(props.brandCopy)}),[props.copy,props.brandCopy]),{copy:copy,brandCopy:brandCopy}=resolved,theme=useEverfurTheme(),styles=useMemo(()=>makeStyles2(theme),[theme]),texting=useEverfurTexting();return texting.status==="signedOut"?/* @__PURE__ */jsxs(View,{style:[styles.card,guarded.style],children:[
|
|
111
111
|
/* @__PURE__ */jsx(Text,{style:styles.title,accessibilityRole:"header",children:brandCopy.introTitle(theme.meta.displayName)}),
|
|
112
112
|
/* @__PURE__ */jsx(Text,{style:styles.body,children:copy.signedOut})]}):/* @__PURE__ */jsx(CapabilityGate,{capability:"texting",...guarded.renderDisabled?{renderDisabled:guarded.renderDisabled}:{},style:guarded.style,children:/* @__PURE__ */jsx(TextingCopyContext.Provider,{value:resolved,children:/* @__PURE__ */jsx(OptInBody,{...guarded,texting:texting,styles:styles})})})}function Button({label:label,onPress:onPress,disabled:disabled=false,busy:busy=false,styles:styles,kind:kind="primary",testID:testID}){let box=kind==="primary"?styles.primary:kind==="secondary"?styles.secondary:styles.link,ink=kind==="primary"?styles.primaryLabel:kind==="secondary"?styles.secondaryLabel:styles.linkLabel;/* @__PURE__ */
|
|
113
|
-
return jsx(Pressable,{onPress:onPress,disabled:disabled||busy,accessibilityRole:"button",accessibilityLabel:label,accessibilityState:{disabled:disabled||busy,busy:busy},style:[box,disabled||busy?styles.dimmed:null],...testID===void 0?{}:{testID:testID},children:/* @__PURE__ */jsx(Text,{tier:"control",style:ink,children:label})})}function OptInBody({texting:texting,styles:styles,onStatusChange:onStatusChange,renderNotice:renderNotice,style:style}){let{copy:copy,brandCopy:brandCopy}=useTextingCopy(),theme=useEverfurTheme(),{status:status,profile:profile,snapshot:snapshot}=texting,brand=profile?.brandName??theme.meta.displayName,[phone,setPhone]=useState(""),[consented,setConsented]=useState(false),[code,setCode]=useState(""),[problem,setProblem]=useState(null),[confirmingOff,setConfirmingOff]=useState(false),[petChoice,setPetChoice]=useState(null),[petSaved,setPetSaved]=useState(false);useEffect(()=>{onStatusChange?.(status)},[onStatusChange,status]),useEffect(()=>{setProblem(null),setConfirmingOff(false)},[status]);let frame=children=>/* @__PURE__ */jsx(View,{style:[styles.card,style],children:children}),notice=(error,onRetry)=>{let line=textingErrorText(error,snapshot.failedAction,snapshot.codeRefusal,copy),support=textingSupportText(error,copy);/* @__PURE__ */
|
|
113
|
+
return jsx(Pressable,{onPress:onPress,disabled:disabled||busy,accessibilityRole:"button",accessibilityLabel:label,accessibilityState:{disabled:disabled||busy,busy:busy},style:[box,disabled||busy?styles.dimmed:null],...testID===void 0?{}:{testID:testID},children:/* @__PURE__ */jsx(Text,{tier:"control",style:ink,children:label})})}function OptInBody({texting:texting,styles:styles,onStatusChange:onStatusChange,renderNotice:renderNotice,style:style}){let{copy:copy,brandCopy:brandCopy}=useTextingCopy(),theme=useEverfurTheme(),{status:status,profile:profile,snapshot:snapshot}=texting,brand=profile?.brandName??theme.meta.displayName,[phone,setPhone]=useState(""),[consented,setConsented]=useState(false),[code,setCode]=useState(""),[problem,setProblem]=useState(null),[confirmingOff,setConfirmingOff]=useState(false),[petChoice,setPetChoice]=useState(null),[petSaved,setPetSaved]=useState(false);useEffect(()=>{onStatusChange?.(status)},[onStatusChange,status]),useEffect(()=>{setProblem(null),setConfirmingOff(false)},[status]);let frame=(children,busy2=false)=>/* @__PURE__ */jsx(View,{style:[styles.card,style],accessibilityState:{busy:busy2},children:children}),notice=(error,onRetry)=>{let line=textingErrorText(error,snapshot.failedAction,snapshot.codeRefusal,copy),support=textingSupportText(error,copy);/* @__PURE__ */
|
|
114
114
|
return jsxs(View,{style:styles.notice,accessibilityLiveRegion:"polite",children:[
|
|
115
|
-
/* @__PURE__ */jsx(HostRender,{resetKey:error,render:()=>renderNotice?renderNotice(error):/* @__PURE__ */jsx(Text,{style:styles.noticeText,children:line}),fallback:/* @__PURE__ */jsx(Text,{style:styles.noticeText,children:line})}),support===null?null:/* @__PURE__ */jsx(Text,{style:styles.footnote,children:support}),onRetry===void 0?null:/* @__PURE__ */jsx(Button,{label:copy.retry,onPress:onRetry,styles:styles,kind:"link"})]})},problemLine=problem===null?null:/* @__PURE__ */
|
|
115
|
+
/* @__PURE__ */jsx(HostRender,{resetKey:error,render:()=>renderNotice?renderNotice(error):/* @__PURE__ */jsx(Text,{style:styles.noticeText,children:line}),fallback:/* @__PURE__ */jsx(Text,{style:styles.noticeText,children:line})}),support===null?null:/* @__PURE__ */jsx(Text,{style:styles.footnote,children:support}),onRetry===void 0?null:/* @__PURE__ */jsx(Button,{label:copy.retry,onPress:onRetry,styles:styles,kind:"link"}),renderNotice?null:/* @__PURE__ */jsx(AnnounceLine,{line:support===null?line:`${line} ${support}`})]})},problemLine=problem===null?null:/* @__PURE__ */jsxs(Fragment,{children:[
|
|
116
|
+
/* @__PURE__ */jsx(Text,{style:styles.noticeText,accessibilityLiveRegion:"polite",children:textingInputProblemText(problem,copy)}),
|
|
117
|
+
/* @__PURE__ */jsx(AnnounceLine,{line:textingInputProblemText(problem,copy)})]});if(status==="unavailable")return frame(
|
|
116
118
|
/* @__PURE__ */jsxs(Fragment,{children:[
|
|
117
119
|
/* @__PURE__ */jsx(Text,{style:styles.title,accessibilityRole:"header",children:copy.unavailableTitle}),
|
|
118
120
|
/* @__PURE__ */jsx(Text,{style:styles.body,children:copy.unavailableBody})]}));if(profile===null)return null;if(status==="loading")/* @__PURE__ */
|
|
@@ -128,7 +130,7 @@ return jsx(View,{style:[styles.card,style],accessible:true,accessibilityRole:"pr
|
|
|
128
130
|
/* @__PURE__ */jsxs(Pressable,{onPress:()=>setConsented(!consented),disabled:busy2,accessibilityRole:"checkbox",accessibilityState:{checked:consented,disabled:busy2},accessibilityLabel:profile.consentText,style:styles.consentRow,testID:"texting-consent",children:[
|
|
129
131
|
/* @__PURE__ */jsx(View,{style:[styles.box,consented?styles.boxChecked:null],accessibilityElementsHidden:true,importantForAccessibility:"no",children:consented?/* @__PURE__ */jsx(Text,{style:styles.tick,children:"✓"}):null}),
|
|
130
132
|
/* @__PURE__ */jsx(Text,{style:styles.consentText,children:profile.consentText})]}),help,problemLine,snapshot.error===null?null:notice(snapshot.error),
|
|
131
|
-
/* @__PURE__ */jsx(Button,{label:busy2?copy.sendingCode:copy.sendCode,busy:busy2,styles:styles,testID:"texting-send",onPress:()=>{let found=validateTextingEnroll(phone,consented);setProblem(found),found===null&&texting.start(phone)}})]}))}if(status==="code"||status==="confirming"||status==="requesting"){let confirming=status==="confirming",resending=status==="requesting",busy2=confirming||resending;return frame(
|
|
133
|
+
/* @__PURE__ */jsx(Button,{label:busy2?copy.sendingCode:copy.sendCode,busy:busy2,styles:styles,testID:"texting-send",onPress:()=>{let found=validateTextingEnroll(phone,consented);setProblem(found),found===null&&texting.start(phone)}})]}),busy2)}if(status==="code"||status==="confirming"||status==="requesting"){let confirming=status==="confirming",resending=status==="requesting",busy2=confirming||resending;return frame(
|
|
132
134
|
/* @__PURE__ */jsxs(Fragment,{children:[
|
|
133
135
|
/* @__PURE__ */jsx(Text,{style:styles.title,accessibilityRole:"header",children:copy.codeTitle}),
|
|
134
136
|
/* @__PURE__ */jsxs(Text,{style:styles.body,children:[copy.codeSentTo," ",formatTextingPhone(snapshot.phoneE164)]}),
|
|
@@ -137,7 +139,7 @@ return jsx(View,{style:[styles.card,style],accessible:true,accessibilityRole:"pr
|
|
|
137
139
|
/* @__PURE__ */jsx(Button,{label:confirming?copy.confirmingCode:copy.confirmCode,busy:confirming,disabled:resending,styles:styles,testID:"texting-confirm",onPress:()=>{let found=validateTextingCode(code);setProblem(found),found===null&&texting.confirm(code)}}),
|
|
138
140
|
/* @__PURE__ */jsxs(View,{style:styles.links,children:[
|
|
139
141
|
/* @__PURE__ */jsx(Button,{label:copy.requestNewCode,kind:"link",disabled:confirming,busy:resending,styles:styles,onPress:()=>{setCode(""),texting.resend()}}),
|
|
140
|
-
/* @__PURE__ */jsx(Button,{label:copy.changeNumber,kind:"link",styles:styles,onPress:()=>{setCode(""),texting.changeNumber()}})]})]}))}if(status==="optedOut")return frame(
|
|
142
|
+
/* @__PURE__ */jsx(Button,{label:copy.changeNumber,kind:"link",styles:styles,onPress:()=>{setCode(""),texting.changeNumber()}})]})]}),busy2)}if(status==="optedOut")return frame(
|
|
141
143
|
/* @__PURE__ */jsxs(Fragment,{children:[
|
|
142
144
|
/* @__PURE__ */jsx(Text,{style:styles.title,accessibilityRole:"header",children:copy.optedOutTitle}),
|
|
143
145
|
/* @__PURE__ */jsx(Text,{style:styles.body,children:textingOptedOutBody(snapshot.identity,brand,copy,brandCopy)}),help,
|
|
@@ -157,10 +159,13 @@ return jsxs(View,{style:styles.petRow,children:[
|
|
|
157
159
|
return jsx(Pressable,{onPress:()=>onChoose(pet.petRef),disabled:saving,accessibilityRole:"radio",accessibilityState:{checked:picked,disabled:saving},accessibilityLabel:pet.name??pet.petRef,style:[styles.chip,picked?styles.chipPicked:null],children:/* @__PURE__ */jsx(Text,{tier:"compact",style:[styles.chipLabel,picked?styles.chipLabelPicked:null],children:pet.name??pet.petRef})},pet.petRef)})}),
|
|
158
160
|
/* @__PURE__ */jsxs(View,{style:styles.links,children:[
|
|
159
161
|
/* @__PURE__ */jsx(Button,{label:saving?copy.savingPet:copy.savePet,kind:"secondary",busy:saving,disabled:!changed,styles:styles,onPress:()=>{value!==null&&onSave(value)},testID:"texting-pet-save"}),saved&&!changed?/* @__PURE__ */jsx(Text,{style:styles.footnote,children:copy.petSaved}):null]})]})}function makeStyles2(theme){let{color:color,radius:radius,space:space,type:type,slots:slots}=theme,text3=(size,ink,weight)=>({...face(theme,weight),fontSize:size,lineHeight:Math.round(size*type.lineHeight.snug),color:ink}),cardInk=slots.card?.textColor;return StyleSheet.create({card:{gap:space.md,padding:space.lg,borderRadius:radius.lg,borderWidth:1,borderColor:color.brandBorder,backgroundColor:color.surface,...slotBox(slots.card,1)},title:text3(type.size.subtitle,cardInk??color.text.primary,"bold"),subtitle:text3(type.size.body,cardInk??color.text.primary,"bold"),body:text3(type.size.body,cardInk??color.text.secondary,"regular"),footnote:text3(type.size.caption,color.text.muted,"regular"),phone:text3(type.size.body,cardInk??color.text.primary,"bold"),label:text3(type.size.caption,cardInk??color.text.primary,"bold"),input:{minHeight:44,paddingHorizontal:space.md,borderRadius:radius.md,borderWidth:1,borderColor:color.controlEdge,backgroundColor:color.surface,...text3(type.size.body,color.text.primary,"regular"),...slotBox(slots.input,1),...slotText(slots.input)},consentRow:{flexDirection:"row",alignItems:"flex-start",gap:space.sm,minHeight:44},box:{width:24,height:24,borderRadius:radius.xs,borderWidth:2,borderColor:color.controlEdge,alignItems:"center",justifyContent:"center",backgroundColor:color.surface},boxChecked:{backgroundColor:color.brand,borderColor:color.brandInk},tick:{...text3(type.size.caption,color.text.onBrand,"bold")},consentText:{flex:1,...text3(type.size.caption,cardInk??color.text.secondary,"regular")},primary:{minHeight:44,paddingHorizontal:space.lg,borderRadius:radius.pill,alignItems:"center",justifyContent:"center",backgroundColor:color.brand,...slotBox(slots.primaryButton)},primaryLabel:{...text3(type.size.body,color.text.onBrand,"bold"),...slotText(slots.primaryButton)},secondary:{minHeight:44,paddingHorizontal:space.lg,borderRadius:radius.pill,borderWidth:1,borderColor:color.brandBorder,alignItems:"center",justifyContent:"center",backgroundColor:color.surface},secondaryLabel:text3(type.size.caption,color.brandInk,"bold"),link:{minHeight:44,justifyContent:"center",alignSelf:"flex-start"},linkLabel:{...text3(type.size.caption,color.linkInk,"bold"),...slotText(slots.link)},dimmed:{opacity:.5},links:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:space.md},notice:{gap:space.xs},noticeText:text3(type.size.caption,color.errorRed,"regular"),confirm:{gap:space.sm,padding:space.md,borderRadius:radius.md,backgroundColor:color.surfaceSubtle},petRow:{gap:space.xs},chips:{flexDirection:"row",flexWrap:"wrap",gap:space.sm},chip:{minHeight:44,paddingHorizontal:space.md,borderRadius:radius.pill,borderWidth:1,borderColor:color.brandBorder,backgroundColor:color.surface,justifyContent:"center",...slotBox(slots.chip,1)},chipPicked:{backgroundColor:color.brandSoft,borderColor:color.brandInk},chipLabel:{...text3(type.size.caption,color.text.primary,"regular"),...slotText(slots.chip)},chipLabelPicked:{...face(theme,"bold"),color:color.brandInk}})}var INTRO_OPEN_SYMBOL=/* @__PURE__ */Symbol.for("@everfur/sdk#IntroOpen@v1"),host=globalThis;function isIntroOpenState(value){if(typeof value!="object"||value===null)return false;let v=value;return v.holds instanceof Set&&v.listeners instanceof Set}var stored=host[INTRO_OPEN_SYMBOL],fresh=()=>({holds:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set}),state=isIntroOpenState(stored)?stored:host[INTRO_OPEN_SYMBOL]=fresh();function isIntroOpen(){return state.holds.size>0}function subscribe(listener){return state.listeners.add(listener),()=>{state.listeners.delete(listener)}}function useIntroOpen(){return useSyncExternalStore(subscribe,isIntroOpen,isIntroOpen)}function resolveTextingAskDue(input){let readEnabled=input.enabled&&input.capabilityGranted&&input.hasProfile&&input.signedIn&&input.scheduleEligible&&!input.offeredThisSession,due=readEnabled&&input.identity==="none"&&input.surfaceReady;return{readEnabled:readEnabled,due:due}}var URGENT_LEVELS=/* @__PURE__ */new Set(["emergency","schedule_soon"]);function textingAskThreadReady(chat){if(chat.isBootstrapping===true||chat.isLoadingHistory===true||chat.isStreaming===true||chat.status==="error"||chat.stopped===true)return false;let last=chat.messages[chat.messages.length-1];return last===void 0||last.role!=="assistant"||last.pending===true||last.checkin!==void 0||last.text.trim().length===0?false:!(typeof last.urgencyLevel=="string"&&URGENT_LEVELS.has(last.urgencyLevel))}var IN_MEMORY_KVS=/* @__PURE__ */new WeakSet;function isInMemoryKv(kv){return IN_MEMORY_KVS.has(kv)}var TEXTING_ASK_SCHEDULE_KEY="everfur.texting.askSchedule.v1",TEXTING_ASK_SNOOZE_MS=2880*60*1e3,TEXTING_ASK_MAX_ASKS=3,EMPTY_TEXTING_ASK_ENTRY=/* @__PURE__ */Object.freeze({askCount:0,nextAskAt:null,completed:false});function isTextingAskEligible(read,now){if(read.status!=="ok")return false;let{entry:entry}=read;return entry.completed||entry.askCount>=TEXTING_ASK_MAX_ASKS?false:entry.nextAskAt===null||now>=entry.nextAskAt}function applyTextingAsk(entry,now){return{askCount:Math.min(entry.askCount+1,TEXTING_ASK_MAX_ASKS),nextAskAt:now+TEXTING_ASK_SNOOZE_MS,completed:entry.completed}}function applyTextingAskSnooze(entry,now){return{...entry,nextAskAt:now+TEXTING_ASK_SNOOZE_MS}}function applyTextingAskCompleted(entry){return{...entry,completed:true}}function nextTextingAskNumber(entry){return entry.askCount<=0?1:entry.askCount===1?2:3}function entryOf(raw){if(raw===null||typeof raw!="object"||Array.isArray(raw))return null;let o=raw,{askCount:askCount,nextAskAt:nextAskAt,completed:completed}=o;return typeof askCount!="number"||!Number.isInteger(askCount)||askCount<0||nextAskAt!==null&&(typeof nextAskAt!="number"||!Number.isFinite(nextAskAt))||typeof completed!="boolean"?null:{askCount:Math.min(askCount,TEXTING_ASK_MAX_ASKS),nextAskAt:nextAskAt,completed:completed}}function parseTextingAskMap(raw){let value;try{value=JSON.parse(raw)}catch{return null}if(value===null||typeof value!="object"||Array.isArray(value))return null;let out={};for(let[key,item]of Object.entries(value)){let entry=entryOf(item);if(entry===null)return null;out[key]=entry}return out}var SLOT=/* @__PURE__ */Symbol.for("@everfur/sdk/texting/ask-schedule@v1");function shared(){let host2=globalThis,state2=host2[SLOT];return state2===void 0&&(state2={sessions:/* @__PURE__ */new Map,sessionListeners:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set,writeChain:Promise.resolve()},host2[SLOT]=state2),state2.sessionListeners===void 0&&(state2.sessionListeners=/* @__PURE__ */new Set),state2}async function load(kv){if(isInMemoryKv(kv))return{status:"unreadable"};let raw;try{raw=await kv.getItem(TEXTING_ASK_SCHEDULE_KEY)}catch{return{status:"unreadable"}}if(raw===null)try{return await kv.setItem(TEXTING_ASK_SCHEDULE_KEY,"{}"),await kv.getItem(TEXTING_ASK_SCHEDULE_KEY)===null?{status:"unreadable"}:{status:"ok",map:{}}}catch{return{status:"unreadable"}}let map=parseTextingAskMap(raw);if(map!==null)return{status:"ok",map:map};try{await kv.removeItem(TEXTING_ASK_SCHEDULE_KEY)}catch{}return{status:"unreadable"}}function subscribeTextingAskSchedule(listener){let{listeners:listeners2}=shared();return listeners2.add(listener),()=>{listeners2.delete(listener)}}function update(kv,userRef,change){let state2=shared(),run=async()=>{let loaded=await load(kv);if(loaded.status!=="ok")return;let current=loaded.map[userRef]??EMPTY_TEXTING_ASK_ENTRY;try{await kv.setItem(TEXTING_ASK_SCHEDULE_KEY,JSON.stringify({...loaded.map,[userRef]:change(current)}))}catch{return}for(let listener of[...state2.listeners])listener()},next=state2.writeChain.then(run,run);return state2.writeChain=next.catch(()=>{}),next}async function readTextingAskSchedule(kv,userRef){let loaded=await load(kv);return loaded.status!=="ok"?{status:"unreadable"}:{status:"ok",entry:loaded.map[userRef]??EMPTY_TEXTING_ASK_ENTRY}}function recordTextingAsk(kv,userRef,now=Date.now()){return update(kv,userRef,entry=>applyTextingAsk(entry,now))}function snoozeTextingAsk(kv,userRef,now=Date.now()){return update(kv,userRef,entry=>applyTextingAskSnooze(entry,now))}function markTextingAskCompleted(kv,userRef){return update(kv,userRef,applyTextingAskCompleted)}function textingAskSession(userRef){return shared().sessions.get(userRef)??null}function setTextingAskSession(userRef,entry){let state2=shared();state2.sessions.set(userRef,entry);for(let listener of[...state2.sessionListeners])listener()}function subscribeTextingAskSessions(listener){let{sessionListeners:sessionListeners}=shared();return sessionListeners.add(listener),()=>{sessionListeners.delete(listener)}}var NO_SNAPSHOT=()=>null;function useTextingGranted(){let{runtime:runtime}=useEverfurContext(),source=runtime.entitlements??null,subscribe2=useCallback(listener=>source===null?()=>{}:source.subscribe(listener),[source]),read=source===null?NO_SNAPSHOT:source.getSnapshot,snapshot=useSyncExternalStore(subscribe2,read,read);return useMemo(()=>snapshot!==null&&decideCapability("texting",snapshot.decisions,{isPending:snapshot.isPending}).enabled,[snapshot])}var IDLE=/* @__PURE__ */Object.freeze({status:"idle"});function useAskSchedule(userRef){let{runtime:runtime}=useEverfurContext(),kv=runtime.registry.services.kv,[state2,setState]=useState({user:null,value:IDLE});return useEffect(()=>{if(userRef===null)return;let live=true,read=()=>{readTextingAskSchedule(kv,userRef).then(value=>{live&&setState({user:userRef,value:{status:"ready",read:value}})})};read();let unsubscribe=subscribeTextingAskSchedule(read);return()=>{live=false,unsubscribe()}},[kv,userRef]),state2.user===userRef?state2.value:IDLE}function identityOf(texting){switch(texting.status){case"enroll":case"requesting":case"code":case"confirming":return"none";case"verified":case"optingOut":case"optedOut":return"exists";default:return"unknown"}}function useTextingAsk(options={}){let enabled=options.enabled!==false,ready=options.ready!==false,surface=options.surface??"prompt",entryWanted=options.entry===true,{runtime:runtime,userRef:userRef}=useEverfurContext(),kv=runtime.registry.services.kv,granted=useTextingGranted(),schedule=useAskSchedule(enabled&&userRef!==null?userRef:null),readSession=useCallback(()=>userRef===null?null:textingAskSession(userRef),[userRef]),current=useSyncExternalStore(subscribeTextingAskSessions,readSession,readSession),update2=useCallback(entry=>{userRef!==null&&setTextingAskSession(userRef,entry)},[userRef]),mine=current!==null&¤t.surface===surface,handedOff=current!==null&¤t.fromPrompt===true,stage=mine?current.stage==="handoff"?"hidden":current.stage:surface==="prompt"&&handedOff?"dismissed":"hidden",now=Date.now(),scheduleEligible=schedule.status==="ready"&&isTextingAskEligible(schedule.read,now),[readFor,setReadFor]=useState(null),entryRead=entryWanted&&userRef!==null&&granted,texting=useTextingState(userRef!==null&&readFor===userRef||stage!=="hidden"||mine||entryRead),identity=identityOf(texting),{readEnabled:readEnabled,due:due}=resolveTextingAskDue({enabled:enabled,capabilityGranted:granted,hasProfile:texting.profile!==null,signedIn:userRef!==null,scheduleEligible:scheduleEligible,offeredThisSession:current!==null,identity:identity,surfaceReady:ready});useEffect(()=>{readEnabled&&userRef!==null&&setReadFor(userRef)},[readEnabled,userRef]);let askNumber=current?.askNumber??(schedule.status==="ready"&&schedule.read.status==="ok"?nextTextingAskNumber(schedule.read.entry):1);useEffect(()=>{!due||userRef===null||textingAskSession(userRef)!==null||update2({surface:surface,stage:"offered",answered:false,askNumber:askNumber})},[due,userRef,update2,askNumber,surface]),useEffect(()=>{!mine||current.stage!=="handoff"||enabled&&ready&&granted&&texting.profile!==null&&identity==="none"&&update2({...current,stage:"offered"})},[mine,current,enabled,ready,granted,texting.profile,identity,update2]);let completed=schedule.status==="ready"&&schedule.read.status==="ok"&&schedule.read.entry.completed;useEffect(()=>{userRef===null||identity!=="exists"||completed||schedule.status!=="ready"||markTextingAskCompleted(kv,userRef)},[identity,completed,schedule.status,kv,userRef]),useEffect(()=>{mine&¤t.stage==="enrolling"&&texting.status==="verified"&&update2({...current,stage:"verified"})},[mine,current,texting.status,update2]);let answer=useCallback(entry=>userRef===null||entry.answered?entry:(recordTextingAsk(kv,userRef),{...entry,answered:true}),[kv,userRef]),accept=useCallback(()=>{mine&¤t.stage==="offered"&&update2({...current,stage:"enrolling"})},[mine,current,update2]),close=useCallback(()=>{if(!mine||current.stage!=="enrolling")return;let{back:back,...rest}=current;update2({...rest,stage:back??"offered"})},[mine,current,update2]),dismiss=useCallback(()=>{if(!(!mine||current.stage!=="offered"&¤t.stage!=="enrolling")){if(surface==="prompt"){update2({...answer(current),surface:"chat",stage:"handoff",fromPrompt:true});return}current.fromPrompt===true&¤t.answered&&userRef!==null&&snoozeTextingAsk(kv,userRef),update2({...answer(current),stage:"dismissed"})}},[mine,current,surface,update2,answer,kv,userRef]),{start:startCode}=texting,start=useCallback(async phone=>!mine||current.stage!=="enrolling"?false:(current.answered||update2(answer(current)),startCode(phone)),[mine,current,update2,answer,startCode]),canOpen=entryRead&&texting.profile!==null&&identity==="none"&&stage!=="enrolling"&&stage!=="verified",open=useCallback(()=>{if(!canOpen||userRef===null)return;let was=mine?current:null;update2({surface:surface,stage:"enrolling",answered:was?.answered??false,askNumber:current?.askNumber??askNumber,...was?.fromPrompt===true?{fromPrompt:true}:{},back:was?.stage==="offered"?"offered":"dismissed"})},[canOpen,userRef,mine,current,update2,surface,askNumber]),brand=texting.profile?.brandName??"";return useMemo(()=>({stage:userRef===null?"hidden":stage,brand:brand,askNumber:askNumber,texting:texting,accept:accept,dismiss:dismiss,close:close,start:start,canOpen:canOpen,open:open}),[userRef,stage,brand,askNumber,texting,accept,dismiss,close,start,canOpen,open])}var ABSOLUTE_FILL=/* @__PURE__ */Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});function ChatTextingAskController({enabled:enabled,ready:ready,onAsk:onAsk,entry:entry=false}){let ask=useTextingAsk({enabled:enabled,ready:ready,surface:"chat",entry:entry});return useEffect(()=>{callHost(onAsk,ask)},[ask,onAsk]),null}function textingAskLines(ask){return{line:TEXTING_BRAND_COPY.chatAskLine(ask.brand),accept:TEXTING_COPY.promptAccept,dismiss:TEXTING_COPY.promptDismiss,verified:TEXTING_BRAND_COPY.chatAskVerified(ask.brand)}}function ChatTextingAskComposer({ask:ask}){let theme=useEverfurTheme(),styles=useMemo(()=>makeAskStyles(theme),[theme]);/* @__PURE__ */
|
|
160
|
-
return jsx(AskEntry,{ask:ask,styles:styles})}function AskEntry({ask:ask,styles:styles}){let{texting:texting}=ask,{status:status,profile:profile,snapshot:snapshot}=texting,[phone,setPhone]=useState(""),[consented,setConsented]=useState(false),[code,setCode]=useState(""),[problem,setProblem]=useState(null),onNumber=status==="enroll"||status==="requesting"&&!snapshot.resending,onCode=status==="code"||status==="confirming"||status==="requesting";useEffect(()=>{setProblem(null)},[status]);let close=/* @__PURE__ */jsxs(Pressable,{onPress:ask.close,accessibilityRole:"button",accessibilityLabel:TEXTING_COPY.close,hitSlop:8,style:styles.close,testID:"texting-ask-close",children:[
|
|
162
|
+
return jsx(AskEntry,{ask:ask,styles:styles})}function AskEntry({ask:ask,styles:styles}){let{texting:texting}=ask,{status:status,profile:profile,snapshot:snapshot}=texting,[phone,setPhone]=useState(""),[consented,setConsented]=useState(false),[code,setCode]=useState(""),[problem,setProblem]=useState(null),[fieldFocused,setFieldFocused]=useState(false),fieldFocus={onFocus:()=>setFieldFocused(true),onBlur:()=>setFieldFocused(false)},pill=fieldFocused?[styles.pill,styles.pillFocused]:styles.pill,onNumber=status==="enroll"||status==="requesting"&&!snapshot.resending,onCode=status==="code"||status==="confirming"||status==="requesting",phoneRef=useRef(null),codeRef=useRef(null),numberReady=status==="enroll",codeReady=status==="code";useEffect(()=>{setProblem(null)},[status]),useEffect(()=>{numberReady?phoneRef.current?.focus():codeReady&&codeRef.current?.focus()},[numberReady,codeReady]);let close=/* @__PURE__ */jsxs(Pressable,{onPress:ask.close,accessibilityRole:"button",accessibilityLabel:TEXTING_COPY.close,hitSlop:8,style:styles.close,testID:"texting-ask-close",children:[
|
|
161
163
|
/* @__PURE__ */jsx(View,{style:[styles.closeBar,styles.closeBarA]}),
|
|
162
|
-
/* @__PURE__ */jsx(View,{style:[styles.closeBar,styles.closeBarB]})]}),
|
|
163
|
-
/* @__PURE__ */jsx(Text,{style:styles.noticeText,children:
|
|
164
|
+
/* @__PURE__ */jsx(View,{style:[styles.closeBar,styles.closeBarB]})]}),refusalLine=snapshot.error===null?null:textingErrorText(snapshot.error,snapshot.failedAction,snapshot.codeRefusal),supportLine=snapshot.error===null?null:textingSupportText(snapshot.error),refusal=refusalLine===null?null:/* @__PURE__ */jsxs(View,{style:styles.notice,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:[
|
|
165
|
+
/* @__PURE__ */jsx(Text,{style:styles.noticeText,children:refusalLine}),supportLine===null?null:/* @__PURE__ */jsx(Text,{style:styles.footnote,children:supportLine}),
|
|
166
|
+
/* @__PURE__ */jsx(AnnounceLine,{line:supportLine===null?refusalLine:`${refusalLine} ${supportLine}`})]}),inputProblem=problem===null?null:/* @__PURE__ */jsxs(Fragment,{children:[
|
|
167
|
+
/* @__PURE__ */jsx(Text,{style:styles.noticeText,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:textingInputProblemText(problem)}),
|
|
168
|
+
/* @__PURE__ */jsx(AnnounceLine,{line:textingInputProblemText(problem)})]});if(profile===null)return null;if(status==="loading"||status==="failed"||status==="signedOut"||status==="unavailable")/* @__PURE__ */
|
|
164
169
|
return jsx(View,{style:styles.root,testID:"texting-ask-entry",accessibilityState:{busy:status==="loading"},children:/* @__PURE__ */jsxs(View,{style:styles.head,children:[
|
|
165
170
|
/* @__PURE__ */jsx(View,{style:styles.headBody,children:status==="failed"?refusal:null}),close]})});if(onNumber){let busy=status==="requesting",submit=()=>{let found=validateTextingEnroll(phone,consented);setProblem(found),found===null&&ask.start(phone)};/* @__PURE__ */
|
|
166
171
|
return jsxs(View,{style:styles.root,testID:"texting-ask-phone",children:[
|
|
@@ -169,8 +174,8 @@ return jsxs(View,{style:styles.root,testID:"texting-ask-phone",children:[
|
|
|
169
174
|
/* @__PURE__ */jsxs(Pressable,{onPress:()=>setConsented(!consented),disabled:busy,accessibilityRole:"checkbox",accessibilityState:{checked:consented,disabled:busy},accessibilityLabel:profile.consentText,style:styles.consentRow,testID:"texting-ask-consent",children:[
|
|
170
175
|
/* @__PURE__ */jsx(View,{style:[styles.box,consented?styles.boxChecked:null],accessibilityElementsHidden:true,importantForAccessibility:"no",children:consented?/* @__PURE__ */jsx(Text,{style:styles.tick,children:"✓"}):null}),
|
|
171
176
|
/* @__PURE__ */jsx(Text,{style:styles.consentText,children:profile.consentText})]}),profile.helpContact===null?null:/* @__PURE__ */jsxs(Text,{style:styles.footnote,children:[TEXTING_COPY.helpContactLabel," ",profile.helpContact]})]}),close]}),inputProblem,refusal,
|
|
172
|
-
/* @__PURE__ */jsxs(View,{style:
|
|
173
|
-
/* @__PURE__ */jsx(TextInput,{value:phone,onChangeText:setPhone,editable:!busy,
|
|
177
|
+
/* @__PURE__ */jsxs(View,{style:pill,children:[
|
|
178
|
+
/* @__PURE__ */jsx(TextInput,{value:phone,onChangeText:setPhone,editable:!busy,keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",accessibilityLabel:TEXTING_COPY.phoneLabel,placeholder:TEXTING_COPY.phoneLabel,placeholderTextColor:styles.placeholder.color,ref:phoneRef,onSubmitEditing:submit,...fieldFocus,style:styles.field,testID:"texting-ask-phone-input"},"phone"),
|
|
174
179
|
/* @__PURE__ */jsx(Pressable,{onPress:submit,disabled:busy,accessibilityRole:"button",accessibilityLabel:busy?TEXTING_COPY.sendingCode:TEXTING_COPY.sendCode,accessibilityState:{disabled:busy,busy:busy},style:[styles.primary,busy?styles.dimmed:null],testID:"texting-ask-send",children:/* @__PURE__ */jsx(Text,{tier:"control",style:styles.primaryLabel,children:busy?TEXTING_COPY.sendingCode:TEXTING_COPY.sendCode})})]})]})}if(onCode){let confirming=status==="confirming",resending=status==="requesting",busy=confirming||resending,submit=()=>{let found=validateTextingCode(code);setProblem(found),found===null&&texting.confirm(code)};/* @__PURE__ */
|
|
175
180
|
return jsxs(View,{style:styles.root,testID:"texting-ask-code",children:[
|
|
176
181
|
/* @__PURE__ */jsxs(View,{style:styles.head,children:[
|
|
@@ -179,16 +184,16 @@ return jsxs(View,{style:styles.root,testID:"texting-ask-code",children:[
|
|
|
179
184
|
/* @__PURE__ */jsxs(View,{style:styles.links,children:[
|
|
180
185
|
/* @__PURE__ */jsx(Pressable,{onPress:()=>{setCode(""),texting.resend()},disabled:busy,accessibilityRole:"button",accessibilityState:{disabled:busy,busy:resending},style:[styles.link,busy?styles.dimmed:null],children:/* @__PURE__ */jsx(Text,{style:styles.linkLabel,children:TEXTING_COPY.requestNewCode})}),
|
|
181
186
|
/* @__PURE__ */jsx(Pressable,{onPress:()=>{setCode(""),texting.changeNumber()},disabled:busy,accessibilityRole:"button",accessibilityState:{disabled:busy},style:[styles.link,busy?styles.dimmed:null],children:/* @__PURE__ */jsx(Text,{style:styles.linkLabel,children:TEXTING_COPY.changeNumber})})]})]}),close]}),inputProblem,refusal,
|
|
182
|
-
/* @__PURE__ */jsxs(View,{style:
|
|
183
|
-
/* @__PURE__ */jsx(TextInput,{value:code,onChangeText:value=>setCode(value.replace(/\D/g,"")),editable:!busy,
|
|
184
|
-
/* @__PURE__ */jsx(Pressable,{onPress:submit,disabled:busy,accessibilityRole:"button",accessibilityLabel:confirming?TEXTING_COPY.confirmingCode:TEXTING_COPY.confirmCode,accessibilityState:{disabled:busy,busy:confirming},style:[styles.primary,busy?styles.dimmed:null],testID:"texting-ask-confirm",children:/* @__PURE__ */jsx(Text,{tier:"control",style:styles.primaryLabel,children:confirming?TEXTING_COPY.confirmingCode:TEXTING_COPY.confirmCode})})]})]})}return null}function makeAskStyles(theme){let{color:color,radius:radius,space:space,type:type,slots:slots}=theme,text3=(size,ink,weight)=>({...face(theme,weight),fontSize:size,lineHeight:Math.round(size*type.lineHeight.snug),color:ink});return StyleSheet.create({root:{gap:space.sm,width:"100%"},head:{flexDirection:"row",alignItems:"flex-start",gap:space.sm},headBody:{flex:1,minWidth:0,gap:space.xs},consentRow:{flexDirection:"row",alignItems:"flex-start",gap:space.sm,minHeight:44},box:{width:24,height:24,borderRadius:radius.xs,borderWidth:2,borderColor:color.controlEdge,alignItems:"center",justifyContent:"center",backgroundColor:color.surface},boxChecked:{backgroundColor:color.brand,borderColor:color.brandInk},tick:text3(type.size.caption,color.text.onBrand,"bold"),consentText:{flex:1,...text3(type.size.caption,color.text.secondary,"regular")},body:text3(type.size.body,color.text.primary,"regular"),footnote:text3(type.size.caption,color.text.muted,"regular"),pill:{flexDirection:"row",alignItems:"center",gap:space.xs,minHeight:50,paddingVertical:space.xs,paddingLeft:space.md,paddingRight:space.xs,borderRadius:radius.pill,borderWidth:1.5,borderColor:color.controlEdge,backgroundColor:color.surface,...slotBox(slots.input,1)},field:{flex:1,minWidth:0,minHeight:44,padding:0,...text3(type.size.body,color.text.primary,"regular"),...slotText(slots.input)},digits:{fontVariant:["tabular-nums"]},primary:{minHeight:
|
|
185
|
-
return jsx(Modal,{transparent:true,visible:true,animationType:theme.motion.reducedMotion?"none":"fade",onRequestClose:finish,children:/* @__PURE__ */jsxs(
|
|
187
|
+
/* @__PURE__ */jsxs(View,{style:pill,children:[
|
|
188
|
+
/* @__PURE__ */jsx(TextInput,{value:code,onChangeText:value=>setCode(value.replace(/\D/g,"")),editable:!busy,keyboardType:"number-pad",textContentType:"oneTimeCode",autoComplete:"sms-otp",maxLength:6,accessibilityLabel:TEXTING_COPY.codeLabel,placeholder:TEXTING_COPY.codeLabel,placeholderTextColor:styles.placeholder.color,ref:codeRef,onSubmitEditing:submit,...fieldFocus,style:[styles.field,styles.digits],testID:"texting-ask-code-input"},"code"),
|
|
189
|
+
/* @__PURE__ */jsx(Pressable,{onPress:submit,disabled:busy,accessibilityRole:"button",accessibilityLabel:confirming?TEXTING_COPY.confirmingCode:TEXTING_COPY.confirmCode,accessibilityState:{disabled:busy,busy:confirming},style:[styles.primary,busy?styles.dimmed:null],testID:"texting-ask-confirm",children:/* @__PURE__ */jsx(Text,{tier:"control",style:styles.primaryLabel,children:confirming?TEXTING_COPY.confirmingCode:TEXTING_COPY.confirmCode})})]})]})}return null}function makeAskStyles(theme,align="auto"){let{color:color,radius:radius,space:space,type:type,slots:slots}=theme,text3=(size,ink,weight)=>({...face(theme,weight),fontSize:size,lineHeight:Math.round(size*type.lineHeight.snug),color:ink}),words={textAlign:align};return StyleSheet.create({root:{gap:space.sm,width:"100%"},head:{flexDirection:"row",alignItems:"flex-start",gap:space.sm},headBody:{flex:1,minWidth:0,gap:space.xs},consentRow:{flexDirection:"row",alignItems:"flex-start",gap:space.sm,minHeight:44},box:{width:24,height:24,borderRadius:radius.xs,borderWidth:2,borderColor:color.controlEdge,alignItems:"center",justifyContent:"center",backgroundColor:color.surface},boxChecked:{backgroundColor:color.brand,borderColor:color.brandInk},tick:text3(type.size.caption,color.text.onBrand,"bold"),consentText:{...align==="center"?{flexShrink:1}:{flex:1},...text3(type.size.caption,color.text.secondary,"regular"),...words},body:{...text3(type.size.body,color.text.primary,"regular"),...words},footnote:{...text3(type.size.caption,color.text.muted,"regular"),...words},placeholder:{color:color.text.placeholder},pill:{flexDirection:"row",alignItems:"center",gap:space.xs,minHeight:50,paddingVertical:space.xs,paddingLeft:space.md,paddingRight:space.xs,borderRadius:radius.pill,borderWidth:1.5,borderColor:color.controlEdge,backgroundColor:color.surface,...slotBox(slots.input,1)},pillFocused:{borderWidth:1.5,borderColor:slots.input?.borderColor??color.brandInk},field:{flex:1,minWidth:0,minHeight:44,padding:0,...text3(type.size.body,color.text.primary,"regular"),...slotText(slots.input)},digits:{fontVariant:["tabular-nums"]},primary:{minHeight:44,paddingHorizontal:space.lg,borderRadius:radius.pill,alignItems:"center",justifyContent:"center",backgroundColor:color.brand,...slotBox(slots.primaryButton)},primaryLabel:{...text3(type.size.caption,color.text.onBrand,"bold"),...slotText(slots.primaryButton)},dimmed:{opacity:.5},close:{width:44,height:44,alignItems:"center",justifyContent:"center"},closeBar:{position:"absolute",width:18,height:2,borderRadius:1,backgroundColor:color.text.muted},closeBarA:{transform:[{rotate:"45deg"}]},closeBarB:{transform:[{rotate:"-45deg"}]},links:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:space.md},link:{minHeight:44,justifyContent:"center"},linkLabel:{...text3(type.size.caption,color.linkInk,"bold"),...slotText(slots.link)},notice:{gap:space.xs},noticeText:{...text3(type.size.caption,color.errorRed,"regular"),...words}})}var ORIENTATIONS=["portrait","landscape"],OPEN=/* @__PURE__ */new Set(["offered","enrolling"]);function EverfurTextingPrompt({onResolved:onResolved}){let introOpen=useIntroOpen(),ask=useTextingAsk({surface:"prompt",ready:!introOpen}),theme=useEverfurTheme(),styles=useMemo(()=>makePromptStyles(theme),[theme]),entryStyles=useMemo(()=>makeAskStyles(theme,"center"),[theme]),shown=useRef(false),[resolved,setResolved]=useState(false);OPEN.has(ask.stage)&&(shown.current=true);let open=shown.current&&(OPEN.has(ask.stage)||ask.stage==="verified")&&!resolved&&!introOpen,finish=()=>{resolved||(ask.stage==="verified"?(setResolved(true),callHost(onResolved,"verified")):ask.dismiss())};if(useEffect(()=>{shown.current&&ask.stage==="dismissed"&&!resolved&&(setResolved(true),callHost(onResolved,"dismissed"))},[ask.stage,onResolved,resolved]),!open)return null;let title=ask.stage==="verified"?TEXTING_COPY.verifiedTitle:TEXTING_BRAND_COPY.promptTitle(ask.brand);/* @__PURE__ */
|
|
190
|
+
return jsx(Modal,{transparent:true,visible:true,animationType:theme.motion.reducedMotion?"none":"fade",statusBarTranslucent:true,supportedOrientations:ORIENTATIONS,onRequestClose:finish,children:/* @__PURE__ */jsxs(KeyboardAvoidingView,{behavior:Platform.OS==="ios"?"padding":"height",style:styles.backdrop,children:[
|
|
186
191
|
/* @__PURE__ */jsx(Pressable,{style:ABSOLUTE_FILL,accessibilityRole:"button",accessibilityLabel:TEXTING_COPY.close,onPress:finish}),
|
|
187
|
-
/* @__PURE__ */
|
|
192
|
+
/* @__PURE__ */jsx(View,{style:styles.sheet,accessibilityViewIsModal:true,testID:"everfur-texting-prompt",children:/* @__PURE__ */jsxs(ScrollView,{style:styles.scroller,contentContainerStyle:styles.sheetBody,keyboardShouldPersistTaps:"handled",bounces:false,testID:"everfur-texting-prompt-scroll",children:[
|
|
188
193
|
/* @__PURE__ */jsx(Text,{style:styles.title,accessibilityRole:"header",children:title}),ask.stage==="offered"?/* @__PURE__ */jsxs(Fragment,{children:[
|
|
189
194
|
/* @__PURE__ */jsx(Text,{style:styles.body,children:TEXTING_COPY.promptBody}),
|
|
190
195
|
/* @__PURE__ */jsxs(View,{style:styles.actions,children:[
|
|
191
196
|
/* @__PURE__ */jsx(Pressable,{onPress:ask.accept,accessibilityRole:"button",accessibilityLabel:TEXTING_COPY.promptAccept,style:styles.primary,testID:"texting-prompt-accept",children:/* @__PURE__ */jsx(Text,{tier:"control",style:styles.primaryLabel,children:TEXTING_COPY.promptAccept})}),
|
|
192
197
|
/* @__PURE__ */jsx(Pressable,{onPress:ask.dismiss,accessibilityRole:"button",accessibilityLabel:TEXTING_COPY.promptDismiss,style:styles.secondary,testID:"texting-prompt-dismiss",children:/* @__PURE__ */jsx(Text,{tier:"control",style:styles.secondaryLabel,children:TEXTING_COPY.promptDismiss})})]})]}):null,ask.stage==="enrolling"?/* @__PURE__ */jsx(AskEntry,{ask:ask,styles:entryStyles}):null,ask.stage==="verified"?/* @__PURE__ */jsxs(Fragment,{children:[
|
|
193
198
|
/* @__PURE__ */jsx(Text,{style:styles.body,children:TEXTING_BRAND_COPY.chatAskVerified(ask.brand)}),
|
|
194
|
-
/* @__PURE__ */jsx(View,{style:styles.actions,children:/* @__PURE__ */jsx(Pressable,{onPress:finish,accessibilityRole:"button",accessibilityLabel:TEXTING_COPY.close,style:styles.secondary,testID:"texting-prompt-close",children:/* @__PURE__ */jsx(Text,{tier:"control",style:styles.secondaryLabel,children:TEXTING_COPY.close})})})]}):null]})]})})}function makePromptStyles(theme){let{color:color,radius:radius,space:space,type:type,slots:slots}=theme,dialogText=slotText(slots.dialog),text3=(size,ink,weight)=>({...face(theme,weight),fontSize:size,lineHeight:Math.round(size*type.lineHeight.normal),color:ink}),button={minHeight:48,paddingHorizontal:space.lg,borderRadius:radius.pill,alignItems:"center",justifyContent:"center"};return StyleSheet.create({backdrop:{flex:1,justifyContent:"center",paddingHorizontal:space.lg,backgroundColor:"rgba(0,0,0,0.4)"},sheet:{width:"100%",maxWidth:480,alignSelf:"center",backgroundColor:color.surface,borderRadius:radius.xl,paddingHorizontal:space.lg,paddingTop:space.xl,paddingBottom:space.lg,
|
|
199
|
+
/* @__PURE__ */jsx(View,{style:styles.actions,children:/* @__PURE__ */jsx(Pressable,{onPress:finish,accessibilityRole:"button",accessibilityLabel:TEXTING_COPY.close,style:styles.secondary,testID:"texting-prompt-close",children:/* @__PURE__ */jsx(Text,{tier:"control",style:styles.secondaryLabel,children:TEXTING_COPY.close})})})]}):null]})})]})})}function makePromptStyles(theme){let{color:color,radius:radius,space:space,type:type,slots:slots}=theme,dialogText=slotText(slots.dialog),text3=(size,ink,weight)=>({...face(theme,weight),fontSize:size,lineHeight:Math.round(size*type.lineHeight.normal),color:ink}),button={minHeight:48,paddingHorizontal:space.lg,borderRadius:radius.pill,alignItems:"center",justifyContent:"center"};return StyleSheet.create({backdrop:{flex:1,justifyContent:"center",paddingHorizontal:space.lg,backgroundColor:"rgba(0,0,0,0.4)"},sheet:{width:"100%",maxWidth:480,alignSelf:"center",backgroundColor:color.surface,borderRadius:radius.xl,maxHeight:"88%",overflow:"hidden",...slotBox(slots.dialog)},scroller:{flexGrow:0,flexShrink:1},sheetBody:{paddingHorizontal:space.lg,paddingTop:space.xl,paddingBottom:space.lg,gap:space.md},title:{...text3(type.size.heading,color.text.primary,"bold"),...headingFace(theme,"bold"),textAlign:"center",...dialogText},body:{...text3(type.size.body,color.text.secondary,"regular"),textAlign:"center",...dialogText},actions:{gap:space.xs},primary:{...button,backgroundColor:color.brand,...slotBox(slots.primaryButton)},primaryLabel:{...text3(type.size.body,color.text.onBrand,"bold"),...slotText(slots.primaryButton)},secondary:button,secondaryLabel:text3(type.size.body,color.text.muted,"bold")})}export{COPY_PLACEHOLDER_PREFIX,ChatTextingAskComposer,ChatTextingAskController,EVERFUR_TEXTING_STATUSES,EverfurTextingOptIn,EverfurTextingPrompt,TEXTING_ASK_MAX_ASKS,TEXTING_ASK_SCHEDULE_KEY,TEXTING_ASK_SNOOZE_MS,TEXTING_BRAND_COPY,TEXTING_CODE_PATTERN,TEXTING_COPY,TEXTING_COPY_PLACEHOLDERS,TEXTING_UI_CODE_LENGTH,TextingController,createTextingRepository,createTextingRepositoryOver,formatTextingPhone,isE164,isTextingAskEligible,parseTextingProfile,resolveTextingAskDue,textingAskLines,textingAskThreadReady,textingErrorText,textingIdentityFromWire,textingInputProblemText,textingOptedOutBody,textingReasonOf,textingSupportText,toTextingE164,useEverfurTexting,useEverfurTextingProfile,useEverfurTextingRepository,useTextingAsk,validateTextingCode,validateTextingEnroll};
|