@buoy-gg/ask-buoy 7.0.65 → 7.0.67
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/lib/commonjs/components/AskBuoyModal.js +2 -2
- package/lib/commonjs/components/AskBuoySettings.js +1 -1
- package/lib/commonjs/hosted.js +1 -1
- package/lib/commonjs/hostedModel.js +1 -0
- package/lib/commonjs/hostedModel.test.js +1 -0
- package/lib/commonjs/store/askBuoySettings.js +1 -1
- package/lib/commonjs/store/askBuoyStore.js +2 -2
- package/lib/commonjs/store/hostedModelSetting.js +1 -0
- package/lib/commonjs/store/useAskBuoy.js +1 -1
- package/lib/module/components/AskBuoyModal.js +2 -2
- package/lib/module/components/AskBuoySettings.js +1 -1
- package/lib/module/hosted.js +1 -1
- package/lib/module/hostedModel.js +1 -0
- package/lib/module/hostedModel.test.js +1 -0
- package/lib/module/store/askBuoySettings.js +1 -1
- package/lib/module/store/askBuoyStore.js +2 -2
- package/lib/module/store/hostedModelSetting.js +1 -0
- package/lib/module/store/useAskBuoy.js +1 -1
- package/lib/typescript/hosted.d.ts +2 -1
- package/lib/typescript/hostedModel.d.ts +10 -0
- package/lib/typescript/hostedModel.test.d.ts +2 -0
- package/lib/typescript/store/askBuoySettings.d.ts +6 -0
- package/lib/typescript/store/askBuoyStore.d.ts +12 -0
- package/lib/typescript/store/hostedModelSetting.d.ts +9 -0
- package/lib/typescript/store/useAskBuoy.d.ts +1 -1
- package/lib/typescript/types.d.ts +14 -0
- package/lib/web/index.mjs +11 -11
- package/package.json +7 -7
package/lib/web/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use client";var er=Object.defineProperty;var ri=Object.getOwnPropertyDescriptor;var ni=Object.getOwnPropertyNames;var ii=Object.prototype.hasOwnProperty;var li=(e,t)=>{for(var o in t)er(e,o,{get:t[o],enumerable:true})},tr=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ni(t))!ii.call(e,n)&&n!==o&&er(e,n,{get:()=>t[n],enumerable:!(r=ri(t,n))||r.enumerable});return e},ai=(e,t,o)=>(tr(e,t,"default"),o&&tr(o,t,"default"));var Zt=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{useCallback as Fe,useEffect as Pt,useMemo as eo,useRef as Wt,useState as go}from"react";var or={};li(or,{AccessibilityInfo:()=>ui,ActivityIndicator:()=>Nt,Alert:()=>yo,Animated:()=>ce,AppRegistry:()=>hi,AppState:()=>gi,Appearance:()=>pi,BackHandler:()=>fi,Button:()=>tl,CheckBox:()=>zi,Clipboard:()=>bi,DeviceEventEmitter:()=>ji,Dimensions:()=>yi,Easing:()=>$t,FlatList:()=>nr,I18nManager:()=>mi,Image:()=>xt,ImageBackground:()=>Di,InteractionManager:()=>xi,Keyboard:()=>fo,KeyboardAvoidingView:()=>Ri,LayoutAnimation:()=>ki,Linking:()=>wi,LogBox:()=>Ni,Modal:()=>el,NativeEventEmitter:()=>vi,NativeModules:()=>di,PanResponder:()=>Si,Picker:()=>$i,PixelRatio:()=>Ti,Platform:()=>we,Pressable:()=>m,ProgressBar:()=>Ai,RefreshControl:()=>Bi,SafeAreaView:()=>Hi,ScrollView:()=>_e,SectionList:()=>Li,Share:()=>rr,StatusBar:()=>Oi,StyleSheet:()=>w,Switch:()=>dr,Text:()=>l,TextInput:()=>et,Touchable:()=>Pi,TouchableHighlight:()=>Xi,TouchableNativeFeedback:()=>Wi,TouchableOpacity:()=>Vt,TouchableWithoutFeedback:()=>Zi,UIManager:()=>Ci,Vibration:()=>Ii,View:()=>s,VirtualizedList:()=>Ei,YellowBox:()=>Vi,findNodeHandle:()=>ol,unstable_createElement:()=>ci,useColorScheme:()=>Mi,useLocaleContext:()=>qi,useWindowDimensions:()=>ir});ai(or,si);import*as si from"react-native-web";import{unstable_createElement as ci,NativeModules as di,AccessibilityInfo as ui,Animated as ce,Appearance as pi,AppRegistry as hi,AppState as gi,BackHandler as fi,Clipboard as bi,Dimensions as yi,Easing as $t,I18nManager as mi,Keyboard as fo,InteractionManager as xi,LayoutAnimation as ki,Linking as wi,NativeEventEmitter as vi,PanResponder as Si,PixelRatio as Ti,Platform as we,Share as rr,StyleSheet as w,UIManager as Ci,Vibration as Ii,CheckBox as zi,FlatList as nr,Image as xt,ImageBackground as Di,KeyboardAvoidingView as Ri,Picker as $i,ProgressBar as Ai,RefreshControl as Bi,SafeAreaView as Hi,SectionList as Li,StatusBar as Oi,Touchable as Pi,TouchableNativeFeedback as Wi,VirtualizedList as Ei,YellowBox as Vi,LogBox as Ni,DeviceEventEmitter as ji,useColorScheme as Mi,useLocaleContext as qi,useWindowDimensions as ir}from"react-native-web";import*as Ae from"react-native-web";import{createElement as bo,forwardRef as lr,useCallback as Fi,useRef as _i}from"react";import{useEffect as Ui,useState as Ki}from"react";import{createPortal as Gi}from"react-dom";var Ji='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as Qi}from"react/jsx-runtime";var Et=Symbol.for("@buoy-gg/portal-host"),ar=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function sr(){let e=document;if(e[Et])return e[Et].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:Ji});let o=()=>{let f=document.fullscreenElement,S=f&&f.tagName!=="CANVAS"?f:document.body;t.parentElement!==S&&S.appendChild(t)},r=new Map,n=f=>{(!t.contains(f.target)||!ar(f.target))&&r.set(f.code||f.key,{key:f.key,code:f.code,location:f.location,keyCode:f.keyCode,which:f.which,altKey:f.altKey,ctrlKey:f.ctrlKey,metaKey:f.metaKey,shiftKey:f.shiftKey})},i=f=>{r.delete(f.code||f.key)},a=()=>r.clear(),h=()=>{let f=[...r.values()];r.clear();for(let S of f)document.dispatchEvent(new KeyboardEvent("keyup",{...S,bubbles:true}))},u=f=>{ar(f.target)&&f.stopPropagation()},g=f=>f.stopPropagation();return o(),document.addEventListener("fullscreenchange",o),document.addEventListener("keydown",n,true),document.addEventListener("keyup",i,true),window.addEventListener("blur",a),t.addEventListener("focusin",h),t.addEventListener("keydown",u),t.addEventListener("keyup",u),t.addEventListener("keypress",u),t.addEventListener("wheel",g,{passive:true}),e[Et]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",o),document.removeEventListener("keydown",n,true),document.removeEventListener("keyup",i,true),window.removeEventListener("blur",a),t.remove(),delete e[Et]}},t}function Yi({children:e}){let[t,o]=Ki(null);return Ui(()=>{let r=sr(),n=document[Et];return n.users++,o(r),()=>{--n.users===0&&n.dispose()}},[]),t?Gi(Qi("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}function We(e){let t=lr((r,n)=>{let{accessibilityState:i,accessibilityValue:a,...h}=r;for(let u of["busy","checked","disabled","expanded","selected"])i?.[u]!==void 0&&h[`aria-${u}`]===void 0&&(h[`aria-${u}`]=i[u]);for(let[u,g]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))a?.[u]!==void 0&&h[`aria-${g}`]===void 0&&(h[`aria-${g}`]=a[u]);return bo(e,{...h,ref:n})}),o=e.State;return o&&Object.assign(t,{State:o}),t.displayName=e.displayName??e.name??"NativeWebView",t}var s=We(Ae.View),l=We(Ae.Text),et=We(Ae.TextInput),Vt=We(Ae.TouchableOpacity),Xi=We(Ae.TouchableHighlight),Zi=We(Ae.TouchableWithoutFeedback),m=We(Ae.Pressable),_e=We(Ae.ScrollView),cr=lr((e,t)=>{let o=_i(null),r=Fi(n=>{if(n){let i=n;for(;i.parentElement&&i.parentElement!==document.body;)i=i.parentElement;i.parentElement===document.body&&(o.current=i,Object.assign(i.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),sr().appendChild(i))}else o.current&&(document.body.appendChild(o.current),o.current=null);typeof t=="function"?t(n):t&&(t.current=n)},[t]);return bo(Yi,null,bo(Ae.Modal,{...e,ref:r}))});cr.displayName="Modal";var el=We(cr),dr=We(Ae.Switch),Nt=We(Ae.ActivityIndicator),tl=We(Ae.Button),ol=Ae.findNodeHandle,yo={alert(e,t,o,r){if(typeof document>"u")return;let n=document.createElement("dialog");n.dataset.buoyRoot="",n.setAttribute("aria-label",e),n.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let i=document.createElement("h2");if(i.textContent=e,i.style.cssText="font-size:18px;margin:0 0 12px",n.appendChild(i),t){let g=document.createElement("p");g.textContent=t,g.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",n.appendChild(g)}let a=document.createElement("div");a.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let h=o?.length?o:[{text:"OK"}],u=()=>{n.close?.(),n.remove()};for(let g of h){let f=document.createElement("button");f.type="button",f.textContent=g.text??"OK",f.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${g.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,f.onclick=()=>{u(),g.onPress?.()},a.appendChild(f)}n.addEventListener("cancel",g=>{g.preventDefault(),r?.cancelable!==false&&(u(),r?.onDismiss?.())}),n.appendChild(a),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}};import{isReversible as rl}from"@buoy-gg/agent-core/web";import{dispatchToolAction as nl,FeatureGate as il,Info as ur,JsModal as ll,ModalHeader as mo,night as Ue,setToolAttention as At,useSafeAreaInsets as al}from"@buoy-gg/shared-ui/web";import{Component as sl}from"react";import{night as pr}from"@buoy-gg/shared-ui/web";import{useState as cl}from"react";import{Check as dl,ChevronRight as ul,night as N}from"@buoy-gg/shared-ui/web";import{createContext as pl,useContext as hl}from"react";import{jsx as gl}from"react/jsx-runtime";var fl={answer:()=>{},runAction:()=>{},answered:{},supports:{}},hr=pl(fl);function gr({value:e,children:t}){return gl(hr.Provider,{value:e,children:t})}function Z(){return hl(hr)}function bl(e,t){return`${e}:${t.label}`}import{AlertTriangle as yl,Check as ml,Clock as xl,Database as kl,Eye as wl,Globe as vl,Image as Sl,Info as Tl,Layers as fr,Navigation as Cl,night as jt,User as Il}from"@buoy-gg/shared-ui/web";import{jsx as Be}from"react/jsx-runtime";function br({name:e,size:t=14}){let o=jt.color.textSecondary,r=(()=>{switch(e){case"network":return Be(vl,{size:t,color:o});case"storage":return Be(kl,{size:t,color:o});case"route":return Be(Cl,{size:t,color:o});case"screen":return Be(wl,{size:t,color:o});case"user":return Be(Il,{size:t,color:o});case"image":return Be(Sl,{size:t,color:o});case"check":return Be(ml,{size:t,color:jt.color.accent});case"warn":return Be(yl,{size:t,color:jt.color.warning});case"info":return Be(Tl,{size:t,color:jt.color.info});case"store":return Be(fr,{size:t,color:o});case"query":return Be(fr,{size:t,color:o});case"clock":return Be(xl,{size:t,color:o})}})();return Be(s,{style:zl.wrap,children:r})}var zl=w.create({wrap:{width:24,height:24,borderRadius:6,backgroundColor:jt.color.fill,alignItems:"center",justifyContent:"center"}});import{monoFont as Dl}from"@buoy-gg/shared-ui/web";import{useState as yr}from"react";import{Check as Rl,ChevronDown as mr,ChevronUp as xr,night as I,X as $l}from"@buoy-gg/shared-ui/web";function Al(e,t,o,r){let n=Math.min(o,e),i=Math.max(0,e-n),a=o>t&&e>t;return{hidden:i,next:Math.min(i,r),expanded:a,canExpand:i>0,canCollapse:a}}import{jsx as ve,jsxs as tt}from"react/jsx-runtime";function kt(e){switch(e){case"accent":return I.color.accent;case"warning":return I.color.warning;case"danger":return I.color.danger;case"info":return I.color.info;case"muted":return I.color.textTertiary;default:return I.color.text}}function kr({source:e}){if(!e||e==="live")return null;let t=e==="changed"?"CHANGED BY ASK BUOY":e==="mocked"?"MOCKED":"FROM THE MODEL",o=e==="changed"?I.color.warning:e==="mocked"?I.color.danger:I.color.textTertiary;return ve(s,{style:[F.badge,{borderColor:o}],children:ve(l,{style:[F.badgeText,{color:o}],children:t})})}function P({title:e,source:t,children:o,testID:r,tone:n,collapsible:i,summary:a}){let[h,u]=yr(false),g=!!i&&!h;return tt(s,{style:[F.card,n==="warning"&&F.cardWarning,n==="danger"&&F.cardDanger,n==="info"&&F.cardInfo],testID:r,children:[(e||t&&t!=="live")&&tt(s,{style:F.titleRow,children:[e?ve(l,{style:F.title,numberOfLines:2,children:e}):ve(s,{style:F.flex}),ve(kr,{source:t})]}),i?tt(m,{testID:r?`${r}-toggle`:void 0,onPress:()=>u(f=>!f),accessibilityRole:"button",accessibilityState:{expanded:h},accessibilityLabel:`${a??"Details"}, ${h?"hide":"show"}`,style:({pressed:f})=>[F.disclosure,!g&&F.disclosureOpen,f&&F.pressed],children:[ve(l,{style:F.disclosureText,numberOfLines:1,children:a??"Details"}),g?ve(mr,{size:12,color:I.color.textTertiary}):ve(xr,{size:12,color:I.color.textTertiary})]}):null,g?null:o]})}var Bl=5;function ot(e,t,o=Bl){let[r,n]=yr(t),{hidden:i,next:a,expanded:h,canExpand:u,canCollapse:g}=Al(e.length,t,r,o);return{visible:e.slice(0,r),hidden:i,next:a,expanded:h,showMore:u?()=>n(f=>f+o):void 0,showLess:g?()=>n(t):void 0}}function rt({paged:e}){let{next:t,showMore:o,showLess:r}=e;return!o&&!r?null:tt(s,{style:F.moreRow,children:[o?tt(m,{testID:"buoy-block-show-more",onPress:o,style:[F.more,F.moreCell],accessibilityRole:"button",children:[tt(l,{style:F.moreText,children:["Show ",t," more"]}),ve(mr,{size:12,color:I.color.textTertiary})]}):null,r?tt(m,{testID:"buoy-block-show-fewer",onPress:r,style:[F.more,F.moreCell],accessibilityRole:"button",children:[ve(l,{style:F.moreText,children:"Show fewer"}),ve(xr,{size:12,color:I.color.textTertiary})]}):null]})}function Hl({shown:e,total:t}){return!t||t<=e?null:ve(s,{style:F.more,children:tt(l,{style:F.moreNote,children:[e," of ",t," shown"]})})}function Ee({actions:e,blockId:t,align:o="left"}){let r=Z();if(!e?.length)return null;let n=e.filter(i=>i.openTool?r.supports?.openTool!==false:i.minimize?r.supports?.minimize!==false:i.dispatch?r.supports?.dispatch!==false:true);return n.length===0?null:ve(s,{style:[F.actions,o==="right"&&F.actionsRight],children:n.slice(0,2).map(i=>{let a=r.actionState?.[bl(t,i)],h=!!r.busy||a==="running"||a==="done";return tt(m,{accessibilityRole:"button",accessibilityLabel:i.label,testID:`buoy-block-action-${i.label.toLowerCase().replace(/\s+/g,"-")}`,disabled:h,onPress:()=>void r.runAction(i,t),style:({pressed:u})=>[F.button,i.primary?F.buttonPrimary:F.buttonPlate,h&&F.buttonDisabled,u&&!h&&F.pressed],children:[a==="running"?ve(Nt,{size:"small",color:i.primary?I.color.onAccent:I.color.text}):a==="done"?ve(Rl,{size:12,color:i.primary?I.color.onAccent:I.color.accent}):a==="failed"?ve($l,{size:12,color:I.color.danger}):null,ve(l,{style:[F.buttonText,i.primary?F.buttonTextPrimary:F.buttonTextPlate],children:i.label})]},i.label)})})}var D=w.create({row:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},rowDivider:{borderTopWidth:w.hairlineWidth,borderTopColor:I.color.separator},rowTitle:{flex:1,color:I.color.text,fontSize:I.font.body,lineHeight:19},rowSub:{color:I.color.textSecondary,fontSize:I.font.caption,lineHeight:17},rowTrailing:{color:I.color.textTertiary,fontSize:I.font.caption,maxWidth:120,textAlign:"right"},mono:{fontFamily:we.OS==="web"?Dl:"Menlo",fontSize:12,color:I.color.text},pill:{paddingHorizontal:7,paddingVertical:2,borderRadius:I.radius.badge,backgroundColor:I.color.fill},pillText:{fontSize:I.font.micro,fontWeight:"700",letterSpacing:.4,color:I.color.textSecondary}}),F=w.create({card:{borderRadius:I.radius.card,borderWidth:w.hairlineWidth,borderColor:I.color.border,backgroundColor:I.color.surface,overflow:"hidden"},cardWarning:{borderColor:I.color.warning,backgroundColor:I.color.warningSoft},cardDanger:{borderColor:I.color.danger,backgroundColor:I.color.dangerSoft},cardInfo:{borderColor:I.color.accentBorderStrong,backgroundColor:I.color.accentSoft},titleRow:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingTop:10,paddingBottom:6},flex:{flex:1},title:{flex:1,color:I.color.text,fontSize:I.font.caption,fontWeight:"600"},disclosure:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:9},disclosureOpen:{borderBottomWidth:w.hairlineWidth,borderBottomColor:I.color.separator},disclosureText:{flex:1,color:I.color.textSecondary,fontSize:I.font.caption},badge:{borderWidth:w.hairlineWidth,borderRadius:I.radius.badge,paddingHorizontal:6,paddingVertical:2},badgeText:{fontSize:9,fontWeight:"700",letterSpacing:.6},moreRow:{flexDirection:"row"},more:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:4,paddingVertical:9,paddingHorizontal:8,borderTopWidth:w.hairlineWidth,borderTopColor:I.color.separator},moreCell:{flex:1},moreText:{color:I.color.textSecondary,fontSize:I.font.caption,fontWeight:"600"},moreNote:{color:I.color.textTertiary,fontSize:I.font.caption},actions:{flexDirection:"row",gap:8,paddingHorizontal:12,paddingVertical:10,flexWrap:"wrap"},actionsRight:{justifyContent:"flex-end"},button:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:14,paddingVertical:9,borderRadius:I.radius.row},buttonPrimary:{backgroundColor:I.color.accent},buttonPlate:{backgroundColor:I.color.button},buttonDisabled:{opacity:.55},buttonText:{fontSize:I.font.caption,fontWeight:"600"},buttonTextPrimary:{color:I.color.onAccent},buttonTextPlate:{color:I.color.text},pressed:{opacity:.7}});import{Fragment as Ll,jsx as le,jsxs as wt}from"react/jsx-runtime";function Ol({block:e}){let t=Z(),o=t.answered[e.id],r=o?.kind==="choice"?o.optionId:null,n=!!o;return wt(P,{testID:`buoy-block-choice-${e.id}`,tone:n?void 0:"info",children:[le(l,{style:M.question,children:e.question}),le(s,{style:M.options,children:e.options.slice(0,5).map((i,a)=>{let h=r===i.id;return wt(m,{testID:`buoy-block-option-${i.id}`,accessibilityRole:"button",accessibilityState:{selected:h,disabled:n},disabled:n,onPress:()=>t.answer({blockId:e.id,kind:"choice",optionId:i.id,label:i.label}),style:({pressed:u})=>[M.option,a>0&&M.optionDivider,h&&M.optionChosen,n&&!h&&M.optionDimmed,u&&!n&&M.pressed],children:[i.icon?le(br,{name:i.icon}):null,wt(s,{style:M.optionText,children:[le(l,{style:[M.optionLabel,h&&M.optionLabelChosen],children:i.label}),i.detail?le(l,{style:M.optionDetail,children:i.detail}):null]}),h?le(dl,{size:14,color:N.color.accent}):n?null:le(ul,{size:14,color:N.color.textTertiary})]},i.id)})}),!n&&e.allowFreeText!==false?le(l,{style:M.hint,children:"Or just type your answer below."}):null]})}function Pl({block:e}){let t=Z(),o=t.answered[e.id],r=!!o,n=o?.kind==="confirm"?o.approved:null;return wt(P,{testID:`buoy-block-confirm-${e.id}`,tone:r?void 0:"warning",children:[le(l,{style:M.confirmTitle,children:e.title}),le(l,{style:M.confirmChange,children:e.change}),e.consequence?le(l,{style:M.confirmConsequence,children:e.consequence}):null,le(s,{style:M.confirmActions,children:r?le(l,{style:M.decided,children:n?`\u2713 ${e.approveLabel??"Done"}`:`\u2715 ${e.declineLabel??"Not now"}`}):wt(Ll,{children:[le(m,{testID:"buoy-block-approve",accessibilityRole:"button",onPress:()=>t.answer({blockId:e.id,kind:"confirm",approved:true}),style:({pressed:i})=>[M.button,M.buttonPrimary,i&&M.pressed],children:le(l,{style:M.buttonTextPrimary,children:e.approveLabel??"Do it"})}),le(m,{testID:"buoy-block-decline",accessibilityRole:"button",onPress:()=>t.answer({blockId:e.id,kind:"confirm",approved:false}),style:({pressed:i})=>[M.button,M.buttonPlate,i&&M.pressed],children:le(l,{style:M.buttonTextPlate,children:e.declineLabel??"Not now"})})]})})]})}function Wl({block:e}){let t=Z(),o=t.answered[e.id],r=!!o,[n,i]=cl(""),a=e.type==="secret",h=()=>{let u=n.trim();u&&t.answer({blockId:e.id,kind:"input",value:u})};return wt(P,{testID:`buoy-block-input-${e.id}`,tone:r?void 0:"info",children:[le(l,{style:M.question,children:e.label}),r?le(l,{style:M.decided,children:o.kind==="input"?a?"\u2022\u2022\u2022\u2022\u2022\u2022":o.value:"(skipped)"}):wt(s,{style:M.inputRow,children:[le(et,{testID:"buoy-block-input-field",style:M.input,value:n,onChangeText:i,placeholder:e.placeholder??"",placeholderTextColor:N.color.placeholder,keyboardType:e.type==="number"?"numeric":"ascii-capable",secureTextEntry:a,autoCapitalize:"none",autoCorrect:false,returnKeyType:"send",onSubmitEditing:h}),le(m,{testID:"buoy-block-input-submit",accessibilityRole:"button",disabled:!n.trim(),onPress:h,style:({pressed:u})=>[M.button,M.buttonPrimary,!n.trim()&&M.buttonDisabled,u&&M.pressed],children:le(l,{style:M.buttonTextPrimary,children:e.submitLabel??"Send"})})]})]})}var M=w.create({question:{color:N.color.text,fontSize:N.font.row,fontWeight:"600",lineHeight:20,paddingHorizontal:12,paddingTop:12,paddingBottom:8},options:{marginHorizontal:8,marginBottom:8,borderRadius:N.radius.row,backgroundColor:N.color.surfaceElevated,overflow:"hidden"},option:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:11},optionDivider:{borderTopWidth:w.hairlineWidth,borderTopColor:N.color.separator},optionChosen:{backgroundColor:N.color.accentSoft},optionDimmed:{opacity:.45},optionText:{flex:1,gap:2},optionLabel:{color:N.color.text,fontSize:N.font.body,fontWeight:"500"},optionLabelChosen:{color:N.color.accent},optionDetail:{color:N.color.textSecondary,fontSize:N.font.caption,lineHeight:17},hint:{color:N.color.textTertiary,fontSize:N.font.micro,paddingHorizontal:12,paddingBottom:10},confirmTitle:{color:N.color.text,fontSize:N.font.row,fontWeight:"600",paddingHorizontal:12,paddingTop:12},confirmChange:{color:N.color.text,fontSize:N.font.body,lineHeight:19,paddingHorizontal:12,paddingTop:6},confirmConsequence:{color:N.color.warning,fontSize:N.font.caption,lineHeight:17,paddingHorizontal:12,paddingTop:6},confirmActions:{flexDirection:"row",gap:8,paddingHorizontal:12,paddingVertical:12,alignItems:"center"},decided:{color:N.color.textSecondary,fontSize:N.font.caption,fontWeight:"600",paddingHorizontal:12,paddingVertical:10},inputRow:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingBottom:12},input:{flex:1,height:38,paddingHorizontal:12,borderRadius:N.radius.row,backgroundColor:N.color.surfaceElevated,color:N.color.text,fontSize:N.font.body},button:{paddingHorizontal:14,paddingVertical:9,borderRadius:N.radius.row},buttonPrimary:{backgroundColor:N.color.accent},buttonPlate:{backgroundColor:N.color.button},buttonDisabled:{opacity:.5},buttonTextPrimary:{color:N.color.onAccent,fontSize:N.font.caption,fontWeight:"600"},buttonTextPlate:{color:N.color.text,fontSize:N.font.caption,fontWeight:"600"},pressed:{opacity:.7}});import{monoFont as wr}from"@buoy-gg/shared-ui/web";import{useState as vr}from"react";import{AlertTriangle as El,Check as Vl,Info as Nl,night as B,X as jl}from"@buoy-gg/shared-ui/web";import{DataViewer as Ml,TreeDiffViewer as ql}from"@buoy-gg/shared-ui/web/dataViewer";import{CAPS as Mt}from"@buoy-gg/agent-core/web";import{monoFont as Sr}from"@buoy-gg/shared-ui/web";import{useState as Fl}from"react";import{night as ae}from"@buoy-gg/shared-ui/web";var Tr=e=>/^\s*\|.*\|\s*$/.test(e),_l=e=>/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(e),Cr=e=>e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>t.trim()),Ul=/^\s*```\s*([\w+-]*)\s*$/;function Kl(e){let t=[],o=[],r=()=>{o.length&&t.push({kind:"p",text:o.join(" ")}),o=[]},n=e.split(`
|
|
2
|
-
`);for(let i=0;i<n.length;i++){let a=n[i].replace(/\s+$/,""),
|
|
3
|
-
`),closed:
|
|
1
|
+
"use client";var pr=Object.defineProperty;var fi=Object.getOwnPropertyDescriptor;var bi=Object.getOwnPropertyNames;var yi=Object.prototype.hasOwnProperty;var mi=(e,t)=>{for(var o in t)pr(e,o,{get:t[o],enumerable:true})},hr=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of bi(t))!yi.call(e,n)&&n!==o&&pr(e,n,{get:()=>t[n],enumerable:!(r=fi(t,n))||r.enumerable});return e},ki=(e,t,o)=>(hr(e,t,"default"),o&&hr(o,t,"default"));var ao=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{useCallback as Ke,useEffect as Ft,useMemo as so,useRef as _t,useState as Co}from"react";var gr={};mi(gr,{AccessibilityInfo:()=>Si,ActivityIndicator:()=>Jt,Alert:()=>Do,Animated:()=>ue,AppRegistry:()=>Ci,AppState:()=>Ii,Appearance:()=>Ti,BackHandler:()=>zi,Button:()=>hl,CheckBox:()=>Ni,Clipboard:()=>Di,DeviceEventEmitter:()=>Zi,Dimensions:()=>Ri,Easing:()=>At,FlatList:()=>br,I18nManager:()=>$i,Image:()=>wt,ImageBackground:()=>Vi,InteractionManager:()=>Ai,Keyboard:()=>Io,KeyboardAvoidingView:()=>Mi,LayoutAnimation:()=>Bi,Linking:()=>Li,LogBox:()=>Xi,Modal:()=>pl,NativeEventEmitter:()=>Oi,NativeModules:()=>vi,PanResponder:()=>Hi,Picker:()=>ji,PixelRatio:()=>Pi,Platform:()=>we,Pressable:()=>m,ProgressBar:()=>qi,RefreshControl:()=>Fi,SafeAreaView:()=>_i,ScrollView:()=>Je,SectionList:()=>Ui,Share:()=>fr,StatusBar:()=>Ki,StyleSheet:()=>w,Switch:()=>vr,Text:()=>l,TextInput:()=>rt,Touchable:()=>Ji,TouchableHighlight:()=>dl,TouchableNativeFeedback:()=>Gi,TouchableOpacity:()=>Kt,TouchableWithoutFeedback:()=>ul,UIManager:()=>Wi,Vibration:()=>Ei,View:()=>s,VirtualizedList:()=>Yi,YellowBox:()=>Qi,findNodeHandle:()=>gl,unstable_createElement:()=>wi,useColorScheme:()=>el,useLocaleContext:()=>tl,useWindowDimensions:()=>yr});ki(gr,xi);import*as xi from"react-native-web";import{unstable_createElement as wi,NativeModules as vi,AccessibilityInfo as Si,Animated as ue,Appearance as Ti,AppRegistry as Ci,AppState as Ii,BackHandler as zi,Clipboard as Di,Dimensions as Ri,Easing as At,I18nManager as $i,Keyboard as Io,InteractionManager as Ai,LayoutAnimation as Bi,Linking as Li,NativeEventEmitter as Oi,PanResponder as Hi,PixelRatio as Pi,Platform as we,Share as fr,StyleSheet as w,UIManager as Wi,Vibration as Ei,CheckBox as Ni,FlatList as br,Image as wt,ImageBackground as Vi,KeyboardAvoidingView as Mi,Picker as ji,ProgressBar as qi,RefreshControl as Fi,SafeAreaView as _i,SectionList as Ui,StatusBar as Ki,Touchable as Ji,TouchableNativeFeedback as Gi,VirtualizedList as Yi,YellowBox as Qi,LogBox as Xi,DeviceEventEmitter as Zi,useColorScheme as el,useLocaleContext as tl,useWindowDimensions as yr}from"react-native-web";import*as $e from"react-native-web";import{createElement as zo,forwardRef as mr,useCallback as ol,useRef as rl}from"react";import{useEffect as nl,useState as il}from"react";import{createPortal as ll}from"react-dom";var al='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as sl}from"react/jsx-runtime";var Ut=Symbol.for("@buoy-gg/portal-host"),kr=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function xr(){let e=document;if(e[Ut])return e[Ut].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:al});let o=()=>{let f=document.fullscreenElement,T=f&&f.tagName!=="CANVAS"?f:document.body;t.parentElement!==T&&T.appendChild(t)},r=new Map,n=f=>{(!t.contains(f.target)||!kr(f.target))&&r.set(f.code||f.key,{key:f.key,code:f.code,location:f.location,keyCode:f.keyCode,which:f.which,altKey:f.altKey,ctrlKey:f.ctrlKey,metaKey:f.metaKey,shiftKey:f.shiftKey})},i=f=>{r.delete(f.code||f.key)},a=()=>r.clear(),g=()=>{let f=[...r.values()];r.clear();for(let T of f)document.dispatchEvent(new KeyboardEvent("keyup",{...T,bubbles:true}))},u=f=>{kr(f.target)&&f.stopPropagation()},h=f=>f.stopPropagation();return o(),document.addEventListener("fullscreenchange",o),document.addEventListener("keydown",n,true),document.addEventListener("keyup",i,true),window.addEventListener("blur",a),t.addEventListener("focusin",g),t.addEventListener("keydown",u),t.addEventListener("keyup",u),t.addEventListener("keypress",u),t.addEventListener("wheel",h,{passive:true}),e[Ut]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",o),document.removeEventListener("keydown",n,true),document.removeEventListener("keyup",i,true),window.removeEventListener("blur",a),t.remove(),delete e[Ut]}},t}function cl({children:e}){let[t,o]=il(null);return nl(()=>{let r=xr(),n=document[Ut];return n.users++,o(r),()=>{--n.users===0&&n.dispose()}},[]),t?ll(sl("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}function Ne(e){let t=mr((r,n)=>{let{accessibilityState:i,accessibilityValue:a,...g}=r;for(let u of["busy","checked","disabled","expanded","selected"])i?.[u]!==void 0&&g[`aria-${u}`]===void 0&&(g[`aria-${u}`]=i[u]);for(let[u,h]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))a?.[u]!==void 0&&g[`aria-${h}`]===void 0&&(g[`aria-${h}`]=a[u]);return zo(e,{...g,ref:n})}),o=e.State;return o&&Object.assign(t,{State:o}),t.displayName=e.displayName??e.name??"NativeWebView",t}var s=Ne($e.View),l=Ne($e.Text),rt=Ne($e.TextInput),Kt=Ne($e.TouchableOpacity),dl=Ne($e.TouchableHighlight),ul=Ne($e.TouchableWithoutFeedback),m=Ne($e.Pressable),Je=Ne($e.ScrollView),wr=mr((e,t)=>{let o=rl(null),r=ol(n=>{if(n){let i=n;for(;i.parentElement&&i.parentElement!==document.body;)i=i.parentElement;i.parentElement===document.body&&(o.current=i,Object.assign(i.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),xr().appendChild(i))}else o.current&&(document.body.appendChild(o.current),o.current=null);typeof t=="function"?t(n):t&&(t.current=n)},[t]);return zo(cl,null,zo($e.Modal,{...e,ref:r}))});wr.displayName="Modal";var pl=Ne(wr),vr=Ne($e.Switch),Jt=Ne($e.ActivityIndicator),hl=Ne($e.Button),gl=$e.findNodeHandle,Do={alert(e,t,o,r){if(typeof document>"u")return;let n=document.createElement("dialog");n.dataset.buoyRoot="",n.setAttribute("aria-label",e),n.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let i=document.createElement("h2");if(i.textContent=e,i.style.cssText="font-size:18px;margin:0 0 12px",n.appendChild(i),t){let h=document.createElement("p");h.textContent=t,h.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",n.appendChild(h)}let a=document.createElement("div");a.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let g=o?.length?o:[{text:"OK"}],u=()=>{n.close?.(),n.remove()};for(let h of g){let f=document.createElement("button");f.type="button",f.textContent=h.text??"OK",f.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${h.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,f.onclick=()=>{u(),h.onPress?.()},a.appendChild(f)}n.addEventListener("cancel",h=>{h.preventDefault(),r?.cancelable!==false&&(u(),r?.onDismiss?.())}),n.appendChild(a),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}};import{isReversible as fl}from"@buoy-gg/agent-core/web";import{dispatchToolAction as bl,FeatureGate as yl,Info as Sr,JsModal as ml,ModalHeader as Ro,night as Ge,setToolAttention as Bt,useSafeAreaInsets as kl}from"@buoy-gg/shared-ui/web";import{Component as xl}from"react";import{night as Tr}from"@buoy-gg/shared-ui/web";import{useState as wl}from"react";import{Check as vl,ChevronRight as Sl,night as M}from"@buoy-gg/shared-ui/web";import{createContext as Tl,useContext as Cl}from"react";import{jsx as Il}from"react/jsx-runtime";var zl={answer:()=>{},runAction:()=>{},answered:{},supports:{}},Cr=Tl(zl);function Ir({value:e,children:t}){return Il(Cr.Provider,{value:e,children:t})}function oe(){return Cl(Cr)}function Dl(e,t){return`${e}:${t.label}`}import{AlertTriangle as Rl,Check as $l,Clock as Al,Database as Bl,Eye as Ll,Globe as Ol,Image as Hl,Info as Pl,Layers as zr,Navigation as Wl,night as Gt,User as El}from"@buoy-gg/shared-ui/web";import{jsx as Ae}from"react/jsx-runtime";function Dr({name:e,size:t=14}){let o=Gt.color.textSecondary,r=(()=>{switch(e){case"network":return Ae(Ol,{size:t,color:o});case"storage":return Ae(Bl,{size:t,color:o});case"route":return Ae(Wl,{size:t,color:o});case"screen":return Ae(Ll,{size:t,color:o});case"user":return Ae(El,{size:t,color:o});case"image":return Ae(Hl,{size:t,color:o});case"check":return Ae($l,{size:t,color:Gt.color.accent});case"warn":return Ae(Rl,{size:t,color:Gt.color.warning});case"info":return Ae(Pl,{size:t,color:Gt.color.info});case"store":return Ae(zr,{size:t,color:o});case"query":return Ae(zr,{size:t,color:o});case"clock":return Ae(Al,{size:t,color:o})}})();return Ae(s,{style:Nl.wrap,children:r})}var Nl=w.create({wrap:{width:24,height:24,borderRadius:6,backgroundColor:Gt.color.fill,alignItems:"center",justifyContent:"center"}});import{monoFont as Vl}from"@buoy-gg/shared-ui/web";import{useState as Rr}from"react";import{Check as Ml,ChevronDown as $r,ChevronUp as Ar,night as I,X as jl}from"@buoy-gg/shared-ui/web";function ql(e,t,o,r){let n=Math.min(o,e),i=Math.max(0,e-n),a=o>t&&e>t;return{hidden:i,next:Math.min(i,r),expanded:a,canExpand:i>0,canCollapse:a}}import{jsx as ve,jsxs as nt}from"react/jsx-runtime";function vt(e){switch(e){case"accent":return I.color.accent;case"warning":return I.color.warning;case"danger":return I.color.danger;case"info":return I.color.info;case"muted":return I.color.textTertiary;default:return I.color.text}}function Br({source:e}){if(!e||e==="live")return null;let t=e==="changed"?"CHANGED BY ASK BUOY":e==="mocked"?"MOCKED":"FROM THE MODEL",o=e==="changed"?I.color.warning:e==="mocked"?I.color.danger:I.color.textTertiary;return ve(s,{style:[F.badge,{borderColor:o}],children:ve(l,{style:[F.badgeText,{color:o}],children:t})})}function W({title:e,source:t,children:o,testID:r,tone:n,collapsible:i,summary:a}){let[g,u]=Rr(false),h=!!i&&!g;return nt(s,{style:[F.card,n==="warning"&&F.cardWarning,n==="danger"&&F.cardDanger,n==="info"&&F.cardInfo],testID:r,children:[(e||t&&t!=="live")&&nt(s,{style:F.titleRow,children:[e?ve(l,{style:F.title,numberOfLines:2,children:e}):ve(s,{style:F.flex}),ve(Br,{source:t})]}),i?nt(m,{testID:r?`${r}-toggle`:void 0,onPress:()=>u(f=>!f),accessibilityRole:"button",accessibilityState:{expanded:g},accessibilityLabel:`${a??"Details"}, ${g?"hide":"show"}`,style:({pressed:f})=>[F.disclosure,!h&&F.disclosureOpen,f&&F.pressed],children:[ve(l,{style:F.disclosureText,numberOfLines:1,children:a??"Details"}),h?ve($r,{size:12,color:I.color.textTertiary}):ve(Ar,{size:12,color:I.color.textTertiary})]}):null,h?null:o]})}var Fl=5;function it(e,t,o=Fl){let[r,n]=Rr(t),{hidden:i,next:a,expanded:g,canExpand:u,canCollapse:h}=ql(e.length,t,r,o);return{visible:e.slice(0,r),hidden:i,next:a,expanded:g,showMore:u?()=>n(f=>f+o):void 0,showLess:h?()=>n(t):void 0}}function lt({paged:e}){let{next:t,showMore:o,showLess:r}=e;return!o&&!r?null:nt(s,{style:F.moreRow,children:[o?nt(m,{testID:"buoy-block-show-more",onPress:o,style:[F.more,F.moreCell],accessibilityRole:"button",children:[nt(l,{style:F.moreText,children:["Show ",t," more"]}),ve($r,{size:12,color:I.color.textTertiary})]}):null,r?nt(m,{testID:"buoy-block-show-fewer",onPress:r,style:[F.more,F.moreCell],accessibilityRole:"button",children:[ve(l,{style:F.moreText,children:"Show fewer"}),ve(Ar,{size:12,color:I.color.textTertiary})]}):null]})}function _l({shown:e,total:t}){return!t||t<=e?null:ve(s,{style:F.more,children:nt(l,{style:F.moreNote,children:[e," of ",t," shown"]})})}function Ve({actions:e,blockId:t,align:o="left"}){let r=oe();if(!e?.length)return null;let n=e.filter(i=>i.openTool?r.supports?.openTool!==false:i.minimize?r.supports?.minimize!==false:i.dispatch?r.supports?.dispatch!==false:true);return n.length===0?null:ve(s,{style:[F.actions,o==="right"&&F.actionsRight],children:n.slice(0,2).map(i=>{let a=r.actionState?.[Dl(t,i)],g=!!r.busy||a==="running"||a==="done";return nt(m,{accessibilityRole:"button",accessibilityLabel:i.label,testID:`buoy-block-action-${i.label.toLowerCase().replace(/\s+/g,"-")}`,disabled:g,onPress:()=>void r.runAction(i,t),style:({pressed:u})=>[F.button,i.primary?F.buttonPrimary:F.buttonPlate,g&&F.buttonDisabled,u&&!g&&F.pressed],children:[a==="running"?ve(Jt,{size:"small",color:i.primary?I.color.onAccent:I.color.text}):a==="done"?ve(Ml,{size:12,color:i.primary?I.color.onAccent:I.color.accent}):a==="failed"?ve(jl,{size:12,color:I.color.danger}):null,ve(l,{style:[F.buttonText,i.primary?F.buttonTextPrimary:F.buttonTextPlate],children:i.label})]},i.label)})})}var D=w.create({row:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},rowDivider:{borderTopWidth:w.hairlineWidth,borderTopColor:I.color.separator},rowTitle:{flex:1,color:I.color.text,fontSize:I.font.body,lineHeight:19},rowSub:{color:I.color.textSecondary,fontSize:I.font.caption,lineHeight:17},rowTrailing:{color:I.color.textTertiary,fontSize:I.font.caption,maxWidth:120,textAlign:"right"},mono:{fontFamily:we.OS==="web"?Vl:"Menlo",fontSize:12,color:I.color.text},pill:{paddingHorizontal:7,paddingVertical:2,borderRadius:I.radius.badge,backgroundColor:I.color.fill},pillText:{fontSize:I.font.micro,fontWeight:"700",letterSpacing:.4,color:I.color.textSecondary}}),F=w.create({card:{borderRadius:I.radius.card,borderWidth:w.hairlineWidth,borderColor:I.color.border,backgroundColor:I.color.surface,overflow:"hidden"},cardWarning:{borderColor:I.color.warning,backgroundColor:I.color.warningSoft},cardDanger:{borderColor:I.color.danger,backgroundColor:I.color.dangerSoft},cardInfo:{borderColor:I.color.accentBorderStrong,backgroundColor:I.color.accentSoft},titleRow:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingTop:10,paddingBottom:6},flex:{flex:1},title:{flex:1,color:I.color.text,fontSize:I.font.caption,fontWeight:"600"},disclosure:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:9},disclosureOpen:{borderBottomWidth:w.hairlineWidth,borderBottomColor:I.color.separator},disclosureText:{flex:1,color:I.color.textSecondary,fontSize:I.font.caption},badge:{borderWidth:w.hairlineWidth,borderRadius:I.radius.badge,paddingHorizontal:6,paddingVertical:2},badgeText:{fontSize:9,fontWeight:"700",letterSpacing:.6},moreRow:{flexDirection:"row"},more:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:4,paddingVertical:9,paddingHorizontal:8,borderTopWidth:w.hairlineWidth,borderTopColor:I.color.separator},moreCell:{flex:1},moreText:{color:I.color.textSecondary,fontSize:I.font.caption,fontWeight:"600"},moreNote:{color:I.color.textTertiary,fontSize:I.font.caption},actions:{flexDirection:"row",gap:8,paddingHorizontal:12,paddingVertical:10,flexWrap:"wrap"},actionsRight:{justifyContent:"flex-end"},button:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:14,paddingVertical:9,borderRadius:I.radius.row},buttonPrimary:{backgroundColor:I.color.accent},buttonPlate:{backgroundColor:I.color.button},buttonDisabled:{opacity:.55},buttonText:{fontSize:I.font.caption,fontWeight:"600"},buttonTextPrimary:{color:I.color.onAccent},buttonTextPlate:{color:I.color.text},pressed:{opacity:.7}});import{Fragment as Ul,jsx as ie,jsxs as St}from"react/jsx-runtime";function Kl({block:e}){let t=oe(),o=t.answered[e.id],r=o?.kind==="choice"?o.optionId:null,n=!!o;return St(W,{testID:`buoy-block-choice-${e.id}`,tone:n?void 0:"info",children:[ie(l,{style:j.question,children:e.question}),ie(s,{style:j.options,children:e.options.slice(0,5).map((i,a)=>{let g=r===i.id;return St(m,{testID:`buoy-block-option-${i.id}`,accessibilityRole:"button",accessibilityState:{selected:g,disabled:n},disabled:n,onPress:()=>t.answer({blockId:e.id,kind:"choice",optionId:i.id,label:i.label}),style:({pressed:u})=>[j.option,a>0&&j.optionDivider,g&&j.optionChosen,n&&!g&&j.optionDimmed,u&&!n&&j.pressed],children:[i.icon?ie(Dr,{name:i.icon}):null,St(s,{style:j.optionText,children:[ie(l,{style:[j.optionLabel,g&&j.optionLabelChosen],children:i.label}),i.detail?ie(l,{style:j.optionDetail,children:i.detail}):null]}),g?ie(vl,{size:14,color:M.color.accent}):n?null:ie(Sl,{size:14,color:M.color.textTertiary})]},i.id)})}),!n&&e.allowFreeText!==false?ie(l,{style:j.hint,children:"Or just type your answer below."}):null]})}function Jl({block:e}){let t=oe(),o=t.answered[e.id],r=!!o,n=o?.kind==="confirm"?o.approved:null;return St(W,{testID:`buoy-block-confirm-${e.id}`,tone:r?void 0:"warning",children:[ie(l,{style:j.confirmTitle,children:e.title}),ie(l,{style:j.confirmChange,children:e.change}),e.consequence?ie(l,{style:j.confirmConsequence,children:e.consequence}):null,ie(s,{style:j.confirmActions,children:r?ie(l,{style:j.decided,children:n?`\u2713 ${e.approveLabel??"Done"}`:`\u2715 ${e.declineLabel??"Not now"}`}):St(Ul,{children:[ie(m,{testID:"buoy-block-approve",accessibilityRole:"button",onPress:()=>t.answer({blockId:e.id,kind:"confirm",approved:true}),style:({pressed:i})=>[j.button,j.buttonPrimary,i&&j.pressed],children:ie(l,{style:j.buttonTextPrimary,children:e.approveLabel??"Do it"})}),ie(m,{testID:"buoy-block-decline",accessibilityRole:"button",onPress:()=>t.answer({blockId:e.id,kind:"confirm",approved:false}),style:({pressed:i})=>[j.button,j.buttonPlate,i&&j.pressed],children:ie(l,{style:j.buttonTextPlate,children:e.declineLabel??"Not now"})})]})})]})}function Gl({block:e}){let t=oe(),o=t.answered[e.id],r=!!o,[n,i]=wl(""),a=e.type==="secret",g=()=>{let u=n.trim();u&&t.answer({blockId:e.id,kind:"input",value:u})};return St(W,{testID:`buoy-block-input-${e.id}`,tone:r?void 0:"info",children:[ie(l,{style:j.question,children:e.label}),r?ie(l,{style:j.decided,children:o.kind==="input"?a?"\u2022\u2022\u2022\u2022\u2022\u2022":o.value:"(skipped)"}):St(s,{style:j.inputRow,children:[ie(rt,{testID:"buoy-block-input-field",style:j.input,value:n,onChangeText:i,placeholder:e.placeholder??"",placeholderTextColor:M.color.placeholder,keyboardType:e.type==="number"?"numeric":"ascii-capable",secureTextEntry:a,autoCapitalize:"none",autoCorrect:false,returnKeyType:"send",onSubmitEditing:g}),ie(m,{testID:"buoy-block-input-submit",accessibilityRole:"button",disabled:!n.trim(),onPress:g,style:({pressed:u})=>[j.button,j.buttonPrimary,!n.trim()&&j.buttonDisabled,u&&j.pressed],children:ie(l,{style:j.buttonTextPrimary,children:e.submitLabel??"Send"})})]})]})}var j=w.create({question:{color:M.color.text,fontSize:M.font.row,fontWeight:"600",lineHeight:20,paddingHorizontal:12,paddingTop:12,paddingBottom:8},options:{marginHorizontal:8,marginBottom:8,borderRadius:M.radius.row,backgroundColor:M.color.surfaceElevated,overflow:"hidden"},option:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:11},optionDivider:{borderTopWidth:w.hairlineWidth,borderTopColor:M.color.separator},optionChosen:{backgroundColor:M.color.accentSoft},optionDimmed:{opacity:.45},optionText:{flex:1,gap:2},optionLabel:{color:M.color.text,fontSize:M.font.body,fontWeight:"500"},optionLabelChosen:{color:M.color.accent},optionDetail:{color:M.color.textSecondary,fontSize:M.font.caption,lineHeight:17},hint:{color:M.color.textTertiary,fontSize:M.font.micro,paddingHorizontal:12,paddingBottom:10},confirmTitle:{color:M.color.text,fontSize:M.font.row,fontWeight:"600",paddingHorizontal:12,paddingTop:12},confirmChange:{color:M.color.text,fontSize:M.font.body,lineHeight:19,paddingHorizontal:12,paddingTop:6},confirmConsequence:{color:M.color.warning,fontSize:M.font.caption,lineHeight:17,paddingHorizontal:12,paddingTop:6},confirmActions:{flexDirection:"row",gap:8,paddingHorizontal:12,paddingVertical:12,alignItems:"center"},decided:{color:M.color.textSecondary,fontSize:M.font.caption,fontWeight:"600",paddingHorizontal:12,paddingVertical:10},inputRow:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingBottom:12},input:{flex:1,height:38,paddingHorizontal:12,borderRadius:M.radius.row,backgroundColor:M.color.surfaceElevated,color:M.color.text,fontSize:M.font.body},button:{paddingHorizontal:14,paddingVertical:9,borderRadius:M.radius.row},buttonPrimary:{backgroundColor:M.color.accent},buttonPlate:{backgroundColor:M.color.button},buttonDisabled:{opacity:.5},buttonTextPrimary:{color:M.color.onAccent,fontSize:M.font.caption,fontWeight:"600"},buttonTextPlate:{color:M.color.text,fontSize:M.font.caption,fontWeight:"600"},pressed:{opacity:.7}});import{monoFont as Lr}from"@buoy-gg/shared-ui/web";import{useState as Or}from"react";import{AlertTriangle as Yl,Check as Ql,Info as Xl,night as B,X as Zl}from"@buoy-gg/shared-ui/web";import{DataViewer as ea,TreeDiffViewer as ta}from"@buoy-gg/shared-ui/web/dataViewer";import{CAPS as Yt}from"@buoy-gg/agent-core/web";import{monoFont as Hr}from"@buoy-gg/shared-ui/web";import{useState as oa}from"react";import{night as le}from"@buoy-gg/shared-ui/web";var Pr=e=>/^\s*\|.*\|\s*$/.test(e),ra=e=>/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(e),Wr=e=>e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>t.trim()),na=/^\s*```\s*([\w+-]*)\s*$/;function ia(e){let t=[],o=[],r=()=>{o.length&&t.push({kind:"p",text:o.join(" ")}),o=[]},n=e.split(`
|
|
2
|
+
`);for(let i=0;i<n.length;i++){let a=n[i].replace(/\s+$/,""),g=na.exec(a);if(g){r();let f=[],T=i+1,O=false;for(;T<n.length;){if(/^\s*```\s*$/.test(n[T])){O=true;break}f.push(n[T]),T++}t.push({kind:"code",lang:g[1]??"",text:f.join(`
|
|
3
|
+
`),closed:O}),i=O?T:n.length;continue}if(!a.trim()){r();continue}if(Pr(a)&&n[i+1]&&ra(n[i+1])){r();let f=Wr(a),T=[],O=i+2;for(;O<n.length&&Pr(n[O]);)T.push(Wr(n[O])),O++;t.push({kind:"table",header:f,rows:T}),i=O-1;continue}let u=/^#{1,6}\s+(.*)$/.exec(a);if(u){r(),t.push({kind:"h",text:u[1]});continue}let h=/^(\s*)([-*•]|\d+[.)])\s+(.*)$/.exec(a);if(h){r();let f=Math.min(2,Math.floor(h[1].length/2)),T=/^\d/.test(h[2])?h[2].replace(")","."):"\u2022";t.push({kind:"li",text:h[3],marker:T,depth:f});continue}o.push(a.trim())}return r(),t}var $o=12,Ao=4;function la(e,t){let o=[];return t.length>$o&&o.push(`${$o} of ${t.length} rows`),e.length>Ao&&o.push(`${Ao} of ${e.length} columns`),o.length?`Showing ${o.join(" \xB7 ")}`:null}import{jsx as me,jsxs as co}from"react/jsx-runtime";function Lt(e,t){let o=e.replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1"),r=[],n=/(\*\*[^*]+\*\*|`[^`]+`|\*[^*\s][^*]*\*|_[^_\s][^_]*_)/g,i=0,a,g=0;for(;a=n.exec(o);){a.index>i&&r.push(o.slice(i,a.index));let u=a[0];u.startsWith("**")?r.push(me(l,{style:[t,K.bold],children:u.slice(2,-2)},g++)):u.startsWith("`")?r.push(me(l,{style:[t,K.code],children:u.slice(1,-1)},g++)):r.push(me(l,{style:[t,K.italic],children:u.slice(1,-1)},g++)),i=a.index+u.length}return i<o.length&&r.push(o.slice(i)),r}var aa=e=>e.replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1");function sa({header:e,rows:t}){let[o,r]=oa(false),n=la(e,t),i=o?e:e.slice(0,Ao),a=o?t:t.slice(0,$o),g=co(s,{style:o&&K.tableWide,children:[me(s,{style:K.tableHead,children:i.map((u,h)=>me(l,{style:[K.th,h===0&&K.firstCol,o&&K.colFixed],numberOfLines:1,children:u.replace(/\*\*/g,"")},h))}),a.map((u,h)=>me(s,{style:[K.tr,h>0&&K.trDivider],children:i.map((f,T)=>me(l,{style:[K.td,T===0&&K.firstCol,T===0&&K.tdFirst,o&&K.colFixed],numberOfLines:o?3:2,children:Lt(aa(u[T]??""),K.td)},T))},h))]});return co(s,{style:K.table,testID:"buoy-ask-buoy-md-table",children:[o?me(Je,{style:K.tableScrollV,nestedScrollEnabled:true,children:me(Je,{horizontal:true,showsHorizontalScrollIndicator:true,children:g})}):g,n?co(m,{testID:"buoy-ask-buoy-md-table-toggle",accessibilityRole:"button",accessibilityLabel:o?"Show fewer rows":"Show all rows and columns",onPress:()=>r(u=>!u),style:({pressed:u})=>[K.tfoot,u&&K.pressed],children:[me(l,{style:K.tfootText,children:o?`All ${t.length} rows \xB7 ${e.length} columns`:n}),me(l,{style:K.tfootAction,children:o?"Show fewer":"Show all"})]}):null]})}function Er({text:e,style:t}){let o=ia(e);return me(s,{style:K.wrap,children:o.map((r,n)=>r.kind==="table"?me(sa,{header:r.header,rows:r.rows},n):r.kind==="code"?me(Je,{horizontal:true,style:K.codeBlock,contentContainerStyle:K.codeBlockContent,testID:"buoy-ask-buoy-md-code",children:me(l,{style:K.codeText,selectable:true,children:r.text})},n):r.kind==="li"?co(s,{style:[K.li,{paddingLeft:4+r.depth*14}],children:[me(l,{style:[t,K.marker],children:r.marker}),me(l,{style:[t,K.liText],selectable:true,children:Lt(r.text,t)})]},n):me(l,{style:[t,r.kind==="h"&&K.bold],selectable:true,children:Lt(r.text,t)},n))})}var K=w.create({wrap:{gap:8},bold:{fontWeight:"600"},italic:{fontStyle:"italic"},code:{fontFamily:we.OS==="web"?Hr:"Menlo",fontSize:13,color:le.color.accent,backgroundColor:le.color.fill},codeBlock:{borderRadius:le.radius.row,borderWidth:w.hairlineWidth,borderColor:le.color.border,backgroundColor:le.color.surface},codeBlockContent:{paddingHorizontal:12,paddingVertical:10},codeText:{fontFamily:we.OS==="web"?Hr:"Menlo",fontSize:12,lineHeight:18,color:le.color.text},li:{flexDirection:"row",gap:8},table:{borderRadius:le.radius.row,borderWidth:w.hairlineWidth,borderColor:le.color.border,backgroundColor:le.color.surface,overflow:"hidden"},tableWide:{minWidth:"100%"},tableScrollV:{maxHeight:320},tableHead:{flexDirection:"row",paddingHorizontal:10,paddingVertical:6,gap:8,backgroundColor:le.color.fill},th:{flex:1,color:le.color.textTertiary,fontSize:le.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},tr:{flexDirection:"row",paddingHorizontal:10,paddingVertical:7,gap:8},trDivider:{borderTopWidth:w.hairlineWidth,borderTopColor:le.color.separator},td:{flex:1,color:le.color.textSecondary,fontSize:le.font.caption,lineHeight:17},tdFirst:{color:le.color.text,fontWeight:"500"},firstCol:{flex:1.3},colFixed:{flex:0,width:110},tfoot:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingHorizontal:10,paddingVertical:8,borderTopWidth:w.hairlineWidth,borderTopColor:le.color.border},tfootText:{color:le.color.textSecondary,fontSize:le.font.micro},tfootAction:{color:le.color.accent,fontSize:le.font.micro,fontWeight:"600"},pressed:{opacity:.7},marker:{color:le.color.textSecondary,minWidth:14,textAlign:"right"},liText:{flex:1}});import{useCallback as ca,useEffect as da,useRef as ua,useState as pa}from"react";import{copyToClipboard as ha}from"@buoy-gg/shared-ui/web";var ga=1500;function uo(e){let[t,o]=pa(false),r=ua(null);da(()=>()=>{r.current&&clearTimeout(r.current)},[]);let n=ca(()=>{let i=e();ha(i).then(a=>{if(!a){fr.share({message:i}).catch(()=>{});return}o(true),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>o(false),ga)}).catch(()=>{})},[e]);return{copied:t,copy:n}}var fa=e=>typeof e=="string"?e:e.text;function Nr(e){switch(e.kind){case"finding":return[e.title,...e.evidence.map(t=>`${t.label}: ${t.value}`)].join(`
|
|
4
4
|
`);case"keyValue":return[e.title,...e.pairs.map(t=>`${t.key}: ${typeof t.value=="string"?t.value:JSON.stringify(t.value)}`)].filter(Boolean).join(`
|
|
5
|
-
`);case"table":{let t=e.columns.join(" | "),o=e.rows.map(n=>n.map(
|
|
5
|
+
`);case"table":{let t=e.columns.join(" | "),o=e.rows.map(n=>n.map(fa).join(" | ")),r=e.total&&e.total>e.rows.length?`\u2026 ${e.total-e.rows.length} more rows`:null;return[e.title,t,...o,r].filter(Boolean).join(`
|
|
6
6
|
`)}case"list":{let t=e.items.map(r=>`- ${r.title}${r.subtitle?` \u2014 ${r.subtitle}`:""}${r.trailing?` (${r.trailing})`:""}`),o=e.total&&e.total>e.items.length?`\u2026 ${e.total-e.items.length} more`:null;return[e.title,...t,o].filter(Boolean).join(`
|
|
7
|
-
`)}case"notice":return e.text;case"claim":return e.text;case"diff":case"chart":case"imageGrid":case"requestList":case"requestCard":case"logList":case"crash":case"screenElements":return`[${e.kind} card${"title"in e&&typeof e.title=="string"?`: ${e.title}`:""}]`;default:return null}}function na(e){return e.map(zr).filter(t=>!!t)}import{Fragment as ia,jsx as z,jsxs as he}from"react/jsx-runtime";function wo(e){if(e===void 0)return"\u2014";if(e===null)return"null";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{let t=JSON.stringify(e);return t.length>120?`${t.slice(0,117)}\u2026`:t}catch{return String(e)}}function la({block:e}){let t=ot(e.rows,Mt.tableRows),{visible:o}=t,r=e.columns.slice(0,4);return he(P,{title:e.title,source:e.source,testID:`buoy-block-table-${e.id}`,children:[z(s,{style:$.tableHead,children:r.map((n,i)=>z(l,{style:[$.th,i===0&&$.firstCol],numberOfLines:1,children:n},n))}),o.map((n,i)=>z(s,{style:[$.tr,i>0&&D.rowDivider],children:r.map((a,h)=>{let u=n[h],g=typeof u=="string"?u:u?.text??"",f=typeof u=="string"?void 0:u?.tone;return z(l,{style:[$.td,h===0&&$.firstCol,h===0&&$.tdFirst,f&&{color:kt(f)}],numberOfLines:2,children:Bt(g,$.td)},h)})},i)),z(rt,{paged:t})]})}function aa({block:e}){let t=ot(e.pairs,Mt.keyValuePairs),{visible:o}=t,[r,n]=vr(null);return he(P,{title:e.title,source:e.source,testID:`buoy-block-keyvalue-${e.id}`,children:[o.map((i,a)=>{let h=typeof i.value=="object"&&i.value!==null,u=r===i.key;return he(m,{onPress:h?()=>n(u?null:i.key):void 0,style:[$.kvRow,a>0&&D.rowDivider],children:[z(l,{style:$.kvKey,numberOfLines:1,children:i.key}),z(l,{style:[$.kvValue,u&&D.mono],numberOfLines:u?void 0:2,selectable:true,children:u?JSON.stringify(i.value,null,2):wo(i.value)})]},i.key)}),z(rt,{paged:t})]})}function sa(e){let t=!!e.image;return{canExpand:t,rowRunsAction:!!e.action&&!t,actionIsOwnControl:!!e.action&&t}}function ca({block:e}){let t=Z(),o=ot(e.items,Mt.listItems),{visible:r}=o,[n,i]=vr(null);return he(P,{title:e.title,source:e.source,testID:`buoy-block-list-${e.id}`,children:[r.map((a,h)=>{let u=`${a.id??a.title}-${h}`,g=n===u,{canExpand:f,rowRunsAction:S,actionIsOwnControl:j}=sa(a),q=f||S?m:s,X=f?{onPress:()=>i(g?null:u),accessibilityRole:"button",accessibilityState:{expanded:g},accessibilityLabel:`${a.title}, ${g?"hide":"show"} picture`,testID:`buoy-block-list-row-${u}`}:S?{onPress:()=>void t.runAction(a.action,e.id),accessibilityRole:"button"}:{};return he(s,{style:h>0?D.rowDivider:void 0,children:[g&&a.image?z(m,{onPress:()=>i(null),accessibilityRole:"button",accessibilityLabel:`Hide ${a.title}`,testID:`buoy-block-list-hero-${u}`,style:$.listHero,children:z(xt,{testID:"buoy-internal-chat-image",source:{uri:a.image},style:$.listHeroImage,resizeMode:"contain",accessibilityLabel:a.title})}):null,he(q,{...X,style:D.row,children:[a.image&&!g?z(xt,{testID:"buoy-internal-chat-image",source:{uri:a.image},style:$.thumb,resizeMode:"contain",accessibilityLabel:a.title}):a.icon?z(br,{name:a.icon}):null,he(s,{style:$.flex,children:[z(l,{style:[D.rowTitle,a.tone&&{color:kt(a.tone)}],numberOfLines:g?void 0:2,children:Bt(a.title,D.rowTitle)}),a.subtitle?z(l,{style:D.rowSub,numberOfLines:g?void 0:2,children:Bt(a.subtitle,D.rowSub)}):null]}),a.trailing?z(l,{style:[D.rowTrailing,a.tone&&{color:kt(a.tone)}],numberOfLines:1,children:a.trailing}):null,a.action?j?z(m,{onPress:()=>void t.runAction(a.action,e.id),accessibilityRole:"button",accessibilityLabel:a.action.label,hitSlop:8,children:z(l,{style:$.rowAction,children:a.action.label})}):z(l,{style:$.rowAction,children:a.action.label}):null]})]},u)}),z(rt,{paged:o})]})}function Dr(e){return e!==null&&typeof e=="object"}function da(e){let t=e.map(n=>n.path),o=t.slice(0,3).join(", "),r=t.length-3;return`${t.length===1?"1 field":`${t.length} fields`} \xB7 ${o}${r>0?`, +${r}`:""}`}function ua({block:e}){let t=ot(e.changes,Mt.keyValuePairs);return he(P,{title:e.title??"What changed",source:e.source,testID:`buoy-block-diff-${e.id}`,collapsible:true,summary:da(e.changes),children:[t.visible.map((o,r)=>{let n=o.before===void 0&&o.after!==void 0,i=o.after===void 0&&o.before!==void 0;return he(s,{style:[$.diffRow,r>0&&D.rowDivider],children:[z(l,{style:$.diffPath,numberOfLines:1,children:o.path}),Dr(o.before)||Dr(o.after)?z(s,{style:$.diffTree,children:z(ql,{oldValue:o.before,newValue:o.after,showUnchanged:false,scrollEnabled:false})}):he(ia,{children:[n?null:he(s,{style:$.diffLine,children:[z(l,{style:[$.diffMark,{color:B.color.danger}],children:"\u2212"}),z(l,{style:[$.diffValue,{color:B.color.danger}],numberOfLines:3,selectable:true,children:wo(o.before)})]}),i?null:he(s,{style:$.diffLine,children:[z(l,{style:[$.diffMark,{color:B.color.accent}],children:"+"}),z(l,{style:[$.diffValue,{color:B.color.accent}],numberOfLines:3,selectable:true,children:wo(o.after)})]})]})]},`${o.path}-${r}`)}),z(rt,{paged:t})]})}function pa({block:e}){let t=e.bars.slice(0,Mt.chartBars),o=e.max??Math.max(1,...t.map(r=>r.value));return z(P,{title:e.title,source:e.source,testID:`buoy-block-chart-${e.id}`,children:z(s,{style:$.chart,children:t.map((r,n)=>he(s,{style:$.barRow,children:[z(l,{style:$.barLabel,numberOfLines:1,children:r.label}),z(s,{style:$.barTrack,children:z(s,{style:[$.bar,{width:`${Math.max(2,Math.round(r.value/o*100))}%`,backgroundColor:kt(r.tone??"accent")}]})}),he(l,{style:$.barValue,numberOfLines:1,children:[r.value,r.unit?` ${r.unit}`:""]})]},`${r.label}-${n}`))})})}function ha({block:e}){return z(P,{title:e.title,testID:`buoy-block-steps-${e.id}`,children:e.steps.map((t,o)=>he(s,{style:[$.step,o>0&&D.rowDivider],children:[z(s,{style:[$.stepMark,t.state==="done"&&$.stepDone,t.state==="failed"&&$.stepFailed],children:t.state==="done"?z(Vl,{size:10,color:B.color.onAccent}):t.state==="failed"?z(jl,{size:10,color:B.color.text}):z(l,{style:$.stepNum,children:o+1})}),z(l,{style:[D.rowTitle,t.state==="done"&&$.stepTextDone],children:t.text})]},o))})}function ga(e){try{let t=JSON.parse(e);return t!==null&&typeof t=="object"?t:void 0}catch{return}}function fa({block:e,value:t}){return z(P,{title:e.title,testID:`buoy-block-code-${e.id}`,children:z(s,{style:$.viewer,children:z(Ml,{title:e.title??"Payload",data:t,initialExpanded:true,showTypeFilter:false,testIDPrefix:`buoy-block-code-${e.id}`})})})}function ba({block:e}){return z(P,{title:e.title,testID:`buoy-block-code-${e.id}`,children:z(l,{style:[D.mono,$.code],selectable:true,children:e.text})})}function ya({block:e}){let t=ga(e.text);return t===void 0?z(ba,{block:e}):z(fa,{block:e,value:t})}function ma({block:e}){let t=e.tone==="danger"?B.color.danger:e.tone==="warning"?B.color.warning:B.color.info,o=e.tone==="info"?Nl:El;return he(P,{tone:e.tone,testID:`buoy-block-notice-${e.id}`,children:[he(s,{style:$.noticeRow,children:[z(o,{size:14,color:t}),z(l,{style:$.noticeText,children:e.text})]}),z(Ee,{actions:e.actions,blockId:e.id})]})}function xa({block:e}){let{copied:t,copy:o}=oo(()=>zr(e)??e.title);return he(P,{title:e.title,source:e.source,testID:`buoy-block-finding-${e.id}`,tone:"warning",children:[e.evidence.map((r,n)=>he(s,{style:[$.kvRow,n>0&&D.rowDivider],children:[z(l,{style:$.kvKey,numberOfLines:1,children:r.label}),z(l,{style:[$.kvValue,r.tone&&{color:kt(r.tone)}],selectable:true,children:r.value})]},`${r.label}-${n}`)),z(s,{style:$.findingFoot,children:z(m,{testID:`buoy-block-finding-copy-${e.id}`,accessibilityRole:"button",accessibilityLabel:t?"Copied":"Copy this finding",onPress:o,style:({pressed:r})=>[$.findingCopy,r&&{opacity:.7}],children:z(l,{style:[$.findingCopyText,t&&{color:B.color.accent}],children:t?"Copied":"Copy finding"})})}),z(Ee,{actions:e.actions,blockId:e.id})]})}var $=w.create({flex:{flex:1},tableHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,gap:8,backgroundColor:B.color.fill},th:{flex:1,color:B.color.textTertiary,fontSize:B.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},tr:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"center"},td:{flex:1,color:B.color.textSecondary,fontSize:B.font.caption,lineHeight:17},tdFirst:{color:B.color.text,fontWeight:"500"},firstCol:{flex:1.4},kvRow:{flexDirection:"row",gap:12,paddingHorizontal:12,paddingVertical:8,alignItems:"flex-start"},kvKey:{width:110,color:B.color.textSecondary,fontSize:B.font.caption,paddingTop:1},kvValue:{flex:1,color:B.color.text,fontSize:B.font.caption,lineHeight:17},findingFoot:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,borderTopWidth:w.hairlineWidth,borderTopColor:B.color.separator},findingCopy:{paddingHorizontal:10,paddingVertical:5,borderRadius:B.radius.badge,backgroundColor:B.color.fill},findingCopyText:{color:B.color.textSecondary,fontSize:B.font.micro,fontWeight:"600"},thumb:{width:40,height:40,borderRadius:8,backgroundColor:B.color.fill},listHero:{paddingHorizontal:12,paddingTop:12},listHeroImage:{width:"100%",height:240,borderRadius:B.radius.row,backgroundColor:B.color.fill},rowAction:{color:B.color.accent,fontSize:B.font.caption,fontWeight:"600"},diffRow:{paddingHorizontal:12,paddingVertical:8,gap:3},diffPath:{color:B.color.textSecondary,fontSize:B.font.micro,fontWeight:"600",letterSpacing:.3},diffLine:{flexDirection:"row",gap:8,alignItems:"flex-start"},diffMark:{fontFamily:we.OS==="web"?wr:"Menlo",fontSize:12,width:10},diffValue:{flex:1,fontFamily:we.OS==="web"?wr:"Menlo",fontSize:12,lineHeight:16},diffTree:{borderRadius:B.radius.row,overflow:"hidden"},chart:{paddingHorizontal:12,paddingVertical:10,gap:8},barRow:{flexDirection:"row",alignItems:"center",gap:8},barLabel:{width:96,color:B.color.textSecondary,fontSize:B.font.caption},barTrack:{flex:1,height:10,borderRadius:5,backgroundColor:B.color.fill,overflow:"hidden"},bar:{height:10,borderRadius:5},barValue:{width:72,textAlign:"right",color:B.color.text,fontSize:B.font.caption,fontWeight:"600"},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:B.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:B.color.accent},stepFailed:{backgroundColor:B.color.danger},stepNum:{color:B.color.text,fontSize:B.font.micro,fontWeight:"700"},stepTextDone:{color:B.color.textSecondary},viewer:{paddingHorizontal:4,paddingBottom:8},code:{paddingHorizontal:12,paddingVertical:10,lineHeight:17},noticeRow:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingTop:10,paddingBottom:4},noticeText:{flex:1,color:B.color.text,fontSize:B.font.caption,lineHeight:18}});import{useState as ka}from"react";import{night as Ve}from"@buoy-gg/shared-ui/web";import{CAPS as Rr}from"@buoy-gg/agent-core/web";import{jsx as je,jsxs as vo}from"react/jsx-runtime";function wa({block:e}){let[t,o]=ka(null),{width:r}=ir(),n=e.images.slice(0,Rr.gridMax),i=n.length>Rr.gridImages,a=Math.min(150,Math.floor((r-2*Ve.gutter-24-8)/2)),h=({img:u,i:g})=>vo(m,{testID:`buoy-block-image-${g}`,accessibilityRole:"imagebutton",accessibilityLabel:u.alt,onPress:()=>o(t===g?null:g),style:[Me.tile,{width:a},i&&Me.tileCarousel],children:[je(xt,{testID:"buoy-internal-chat-image",source:{uri:u.url},style:[Me.image,{width:a,height:a}],resizeMode:"contain",accessibilityLabel:u.alt}),je(l,{style:Me.name,numberOfLines:1,children:u.alt}),u.caption?je(l,{style:Me.caption,numberOfLines:1,children:u.caption}):null]},`${u.url}-${g}`);return vo(P,{title:e.title,source:e.source,testID:`buoy-block-imagegrid-${e.id}`,children:[t!==null&&n[t]?vo(m,{onPress:()=>o(null),style:Me.hero,accessibilityRole:"button",accessibilityLabel:`Close ${n[t].alt}`,children:[je(xt,{testID:"buoy-internal-chat-image",source:{uri:n[t].url},style:Me.heroImage,resizeMode:"contain",accessibilityLabel:n[t].alt}),je(l,{style:Me.heroCaption,children:n[t].alt}),n[t].caption?je(l,{style:Me.caption,children:n[t].caption}):null]}):null,i?je(_e,{horizontal:true,showsHorizontalScrollIndicator:false,snapToInterval:a+8,decelerationRate:"fast",contentContainerStyle:Me.carousel,children:n.map((u,g)=>je(h,{img:u,i:g},g))}):je(s,{style:Me.grid,children:n.map((u,g)=>je(h,{img:u,i:g},g))}),je(Hl,{shown:n.length,total:e.total})]})}var Me=w.create({grid:{flexDirection:"row",flexWrap:"wrap",gap:8,padding:12},carousel:{gap:8,paddingHorizontal:12,paddingVertical:12},tile:{gap:4},tileCarousel:{},image:{borderRadius:Ve.radius.row,backgroundColor:Ve.color.fill},name:{color:Ve.color.text,fontSize:Ve.font.micro,fontWeight:"600"},caption:{color:Ve.color.textSecondary,fontSize:Ve.font.micro},hero:{alignItems:"center",padding:12,gap:6,borderBottomWidth:w.hairlineWidth,borderBottomColor:Ve.color.separator},heroImage:{width:"100%",height:240,borderRadius:Ve.radius.row,backgroundColor:Ve.color.fill},heroCaption:{color:Ve.color.text,fontSize:Ve.font.caption}});import{monoFont as va}from"@buoy-gg/shared-ui/web";import{useState as Sa}from"react";import{AlertTriangle as Ta,ChevronRight as Ca,Eye as $r,night as R,NightSegmented as Ia}from"@buoy-gg/shared-ui/web";import{CAPS as ro}from"@buoy-gg/agent-core/web";import{jsx as O,jsxs as se}from"react/jsx-runtime";function Ar(e){return e===void 0?R.color.textTertiary:e>=500?R.color.danger:e>=400?R.color.warning:e>=300?R.color.info:R.color.accent}function Br(e){try{let t=new URL(e);return t.pathname+(t.search?"?\u2026":"")}catch{return e}}function Hr({status:e}){return O(s,{style:[D.pill,{backgroundColor:`${Ar(e)}22`}],children:O(l,{style:[D.pillText,{color:Ar(e)}],children:e??"\u2026"})})}function za({block:e}){let t=Z(),o=t.supports?.openTool!==false,r=ot(e.requests,ro.listItems),{visible:n}=r;return se(P,{title:e.title??"Network requests",source:e.source,testID:`buoy-block-requests-${e.id}`,children:[n.map((i,a)=>se(m,{disabled:!o,onPress:()=>void t.runAction({label:"Open in Network",openTool:{toolId:"network",select:i.id}},e.id),style:[D.row,a>0&&D.rowDivider],accessibilityRole:o?"button":void 0,children:[O(l,{style:G.method,children:i.method}),O(l,{style:D.rowTitle,numberOfLines:1,children:Br(i.url)}),i.mocked?O(l,{style:G.mockedChip,children:"MOCKED"}):null,i.durationMs!==void 0?se(l,{style:D.rowTrailing,children:[i.durationMs," ms"]}):null,O(Hr,{status:i.status}),o?O(Ca,{size:12,color:R.color.textTertiary}):null]},`${i.id}-${a}`)),O(rt,{paged:r})]})}var Da=[{key:"response",label:"Response"},{key:"request",label:"Request"}];function Ra({block:e}){let[t,o]=Sa("response"),r=t==="response"?e.responseBody:e.requestBody,n=r===void 0?"(none)":typeof r=="string"?r:JSON.stringify(r,null,2),i=Z();return se(P,{source:e.source,testID:`buoy-block-request-${e.id}`,children:[se(s,{style:[D.row,G.reqHead],children:[O(l,{style:G.method,children:e.request.method}),O(l,{style:D.rowTitle,numberOfLines:2,children:Br(e.request.url)}),e.request.mocked?O(l,{style:G.mockedChip,children:"MOCKED"}):null,O(Hr,{status:e.request.status})]}),O(s,{style:G.tabs,children:O(Ia,{tabs:Da,activeKey:t,onChange:a=>o(a),size:"sm"})}),O(l,{style:[D.mono,G.body],numberOfLines:14,selectable:true,children:n.length>1600?`${n.slice(0,1600)}
|
|
8
|
-
\u2026`:n}),O(Ee,{blockId:e.id,actions:[{label:"Open in Network",openTool:{toolId:"network",select:e.request.id}}]}),(i.supports?.openTool===false,null)]})}function $a({block:e}){let t=Z().rules?.[e.rule.id],o=t?.deleted===true,r={...e.rule,enabled:o?false:t?.enabled??e.rule.enabled},n=r.kind==="fail"?"fails (no network)":r.kind==="delay"?`delayed ${r.delayMs??0} ms`:`returns ${r.status??200}`;return se(P,{title:r.name??"Network override",source:e.source,testID:`buoy-block-rule-${e.id}`,tone:r.enabled?"warning":void 0,children:[se(s,{style:G.ruleBody,children:[se(l,{style:G.ruleLine,children:[se(l,{style:G.ruleKey,children:[r.methods?.length?r.methods.join("/"):"ANY"," "]}),O(l,{style:D.mono,children:r.urlPattern})]}),se(l,{style:G.ruleLine,children:[O(l,{style:G.ruleKey,children:"\u2192 "}),n,r.times?` \xB7 ${r.times===1?"once":`${r.times} times`}`:" \xB7 every time",r.hits!==void 0?` \xB7 ${r.hits} hit${r.hits===1?"":"s"}`:""]}),O(s,{style:[D.pill,r.enabled?G.on:G.off],children:O(l,{style:[D.pillText,{color:r.enabled?R.color.onAccent:R.color.textSecondary}],children:o?"DELETED":r.enabled?"ON":"OFF"})})]}),o?null:O(Ee,{blockId:e.id,actions:[r.enabled?{label:"Turn off",dispatch:{toolId:"network",action:"setOverrideRuleEnabled",params:{id:r.id,enabled:false}}}:{label:"Turn on",primary:true,dispatch:{toolId:"network",action:"setOverrideRuleEnabled",params:{id:r.id,enabled:true}}},{label:"Delete",dispatch:{toolId:"network",action:"deleteOverrideRule",params:{id:r.id}}}]})]})}function Aa({block:e}){let t=Z(),o=ot(e.elements,ro.chips),{visible:r}=o;return se(P,{title:e.title??"On screen right now",source:e.source,testID:`buoy-block-screen-${e.id}`,children:[r.map((n,i)=>se(m,{onPress:()=>void t.runAction({label:"Highlight",dispatch:{toolId:"highlight-updates",action:"setSpotlight",params:{nativeTag:n.nativeTag}}},e.id),disabled:t.supports?.dispatch===false,style:[D.row,i>0&&D.rowDivider],accessibilityRole:"button",children:[O($r,{size:12,color:R.color.textTertiary}),O(l,{style:D.rowTitle,numberOfLines:1,children:n.label??n.testID??n.name}),O(l,{style:D.rowTrailing,numberOfLines:1,children:n.name})]},`${n.nativeTag}-${i}`)),O(rt,{paged:o})]})}function Ba({block:e}){let t=Z(),o=ot(e.routes,ro.chips),r=o.visible;return se(P,{title:e.current?`Routes \xB7 you're on ${e.current}`:"Routes",source:e.source,testID:`buoy-block-routes-${e.id}`,children:[O(s,{style:G.chips,children:r.map((n,i)=>O(m,{disabled:t.supports?.dispatch===false,onPress:()=>n.dynamic?t.answer({blockId:e.id,kind:"input",value:`Open ${n.path} \u2014 which id?`}):void t.runAction({label:`Open ${n.path}`,dispatch:{toolId:"route-events",action:"navigate",params:{path:n.path}}},e.id),style:[G.chip,n.path===e.current&&G.chipCurrent],accessibilityRole:"button",children:O(l,{style:[G.chipText,n.dynamic&&G.chipDynamic],children:n.path})},`${n.path}-${i}`))}),O(rt,{paged:o})]})}var Lr={error:R.color.danger,warn:R.color.warning,warning:R.color.warning,info:R.color.info};function Ha({block:e}){let t=ot(e.entries,ro.listItems),{visible:o}=t;return se(P,{title:"Console",source:e.source,testID:`buoy-block-logs-${e.id}`,children:[o.map((r,n)=>se(s,{style:[D.row,n>0&&D.rowDivider,G.logRow],children:[O(s,{style:[D.pill,{backgroundColor:`${Lr[r.level]??R.color.textTertiary}22`}],children:O(l,{style:[D.pillText,{color:Lr[r.level]??R.color.textSecondary}],children:r.level.toUpperCase()})}),O(l,{style:[D.rowTitle,D.mono],numberOfLines:3,children:r.message}),r.count>1?se(l,{style:D.rowTrailing,children:["\xD7",r.count]}):null]},`${r.level}-${r.message}-${n}`)),O(rt,{paged:t})]})}function La({block:e}){return se(P,{tone:"danger",testID:`buoy-block-crash-${e.id}`,children:[se(s,{style:G.crashHead,children:[O(Ta,{size:14,color:R.color.danger}),se(l,{style:G.crashTitle,children:["The app crashed",e.route?` on ${e.route}`:""]})]}),O(l,{style:[D.mono,G.crashMsg],numberOfLines:4,selectable:true,children:e.message}),e.suspect?se(l,{style:G.suspect,children:["Most likely cause: ",e.suspect.label]}):null,O(Ee,{blockId:e.id,actions:[...e.suspect?.action?[{...e.suspect.action,primary:true}]:[],...e.actions??[]].slice(0,2)})]})}function Oa({block:e}){let t=Z(),o=t.supports?.minimize!==false;return se(m,{testID:`buoy-block-peek-${e.id}`,disabled:!o,onPress:()=>void t.runAction({label:"Look",minimize:true},e.id),style:({pressed:r})=>[G.peek,r&&{opacity:.7}],accessibilityRole:"button",accessibilityLabel:`${e.label}. Look at the app`,children:[O(l,{style:G.peekText,children:e.label}),o?se(s,{style:G.peekLook,children:[O($r,{size:12,color:R.color.accent}),O(l,{style:G.peekLookText,children:"Look"})]}):null]})}var G=w.create({method:{color:R.color.textSecondary,fontSize:R.font.micro,fontWeight:"700",letterSpacing:.4,width:44},mockedChip:{color:R.color.warning,backgroundColor:R.color.warningSoft,fontSize:9,fontWeight:"700",letterSpacing:.6,paddingHorizontal:5,paddingVertical:1,borderRadius:R.radius.badge,overflow:"hidden"},reqHead:{paddingTop:12},tabs:{paddingHorizontal:12,paddingTop:4,paddingBottom:8},tab:{paddingHorizontal:10,paddingVertical:5,borderRadius:R.radius.badge,backgroundColor:R.color.fill},tabOn:{backgroundColor:R.color.accentSoft},tabText:{color:R.color.textSecondary,fontSize:R.font.micro,fontWeight:"600"},tabTextOn:{color:R.color.accent},body:{paddingHorizontal:12,paddingBottom:4,lineHeight:16,color:R.color.textSecondary},ruleBody:{paddingHorizontal:12,paddingTop:4,paddingBottom:4,gap:4},ruleLine:{color:R.color.text,fontSize:R.font.caption,lineHeight:18},ruleKey:{color:R.color.textSecondary,fontWeight:"700"},on:{alignSelf:"flex-start",backgroundColor:R.color.accent,marginTop:4},off:{alignSelf:"flex-start",backgroundColor:R.color.fillTertiary,marginTop:4},chips:{flexDirection:"row",flexWrap:"wrap",gap:6,padding:12},chip:{paddingHorizontal:10,paddingVertical:6,borderRadius:R.radius.chip,backgroundColor:R.color.fill,borderWidth:w.hairlineWidth,borderColor:R.color.border},chipCurrent:{backgroundColor:R.color.accentSoft,borderColor:R.color.accentBorderStrong},chipText:{color:R.color.text,fontSize:R.font.caption,fontFamily:we.OS==="web"?va:"Menlo"},chipDynamic:{color:R.color.textSecondary},logRow:{alignItems:"flex-start"},crashHead:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingTop:12},crashTitle:{color:R.color.danger,fontSize:R.font.row,fontWeight:"600"},crashMsg:{paddingHorizontal:12,paddingTop:6,color:R.color.text},suspect:{color:R.color.textSecondary,fontSize:R.font.caption,paddingHorizontal:12,paddingTop:6},peek:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:10,paddingLeft:12,paddingRight:10,paddingVertical:7,borderRadius:R.radius.chip,backgroundColor:R.color.fill},peekText:{color:R.color.textSecondary,fontSize:R.font.caption},peekLook:{flexDirection:"row",alignItems:"center",gap:4},peekLookText:{color:R.color.accent,fontSize:R.font.caption,fontWeight:"600"}});import{monoFont as So}from"@buoy-gg/shared-ui/web";import{useEffect as Pa,useRef as Or,useState as Ke}from"react";import{AlertTriangle as Wa,Check as Pr,ChevronDown as Wr,ChevronRight as Er,night as d,NightSegmented as Ea,RefreshCw as Va,Search as Na,X as ja}from"@buoy-gg/shared-ui/web";import{Fragment as no,jsx as p,jsxs as v}from"react/jsx-runtime";var Vr=e=>typeof e=="string"?e:e===void 0?"\u2014":JSON.stringify(e);function Ma({block:e}){let t=Z();return p(s,{style:c.chips,testID:`buoy-block-suggestions-${e.id}`,children:e.chips.slice(0,4).map(o=>p(m,{disabled:!!t.busy,onPress:()=>void t.runAction({label:o.label,send:o.send??o.label},e.id),style:({pressed:r})=>[c.chip,r&&c.pressed],accessibilityRole:"button",children:p(l,{style:c.chipText,children:o.label})},o.label))})}function qa({block:e}){let t=Z(),o=t.answered[e.id],r=!!o,[n,i]=Ke([]),a=o?.kind==="multi"?o.optionIds:n,h=g=>i(f=>f.includes(g)?f.filter(S=>S!==g):[...f,g]),u=n.length>=(e.min??1)&&(!e.max||n.length<=e.max);return v(P,{testID:`buoy-block-multi-${e.id}`,tone:r?void 0:"info",children:[p(l,{style:c.question,children:e.question}),p(s,{style:c.optionsBox,children:e.options.map((g,f)=>{let S=a.includes(g.id);return v(m,{disabled:r,onPress:()=>h(g.id),style:[c.option,f>0&&D.rowDivider,r&&!S&&c.dim],accessibilityRole:"checkbox",accessibilityState:{checked:S},children:[p(s,{style:[c.checkbox,S&&c.checkboxOn],children:S?p(Pr,{size:11,color:d.color.onAccent}):null}),v(s,{style:c.flex,children:[p(l,{style:c.optionLabel,children:g.label}),g.detail?p(l,{style:c.optionDetail,children:g.detail}):null]})]},g.id)})}),r?null:p(s,{style:c.rowEnd,children:p(m,{testID:"buoy-block-multi-submit",disabled:!u,onPress:()=>t.answer({blockId:e.id,kind:"multi",optionIds:n,labels:e.options.filter(g=>n.includes(g.id)).map(g=>g.label)}),style:[c.button,c.buttonPrimary,!u&&c.disabled],children:p(l,{style:c.buttonTextPrimary,children:e.submitLabel??`Use ${n.length||""}`.trim()})})})]})}var Fa=8;function _a({block:e}){let t=Z(),o=t.answered[e.id],[r,n]=Ke(""),[i,a]=Ke(false),h=o?.kind==="select"?o.label:null,u=e.options.filter(f=>!r||f.label.toLowerCase().includes(r.toLowerCase())).slice(0,8),g=e.searchable!==false&&e.options.length>=Fa;return v(P,{testID:`buoy-block-select-${e.id}`,tone:o?void 0:"info",children:[p(l,{style:c.question,children:e.label}),h?p(l,{style:c.decided,children:h}):v(s,{style:c.selectBox,children:[v(m,{onPress:()=>a(f=>!f),style:c.selectField,accessibilityRole:"button",children:[p(l,{style:c.selectPlaceholder,children:i?"Choose\u2026":`${e.options.length} options`}),p(Wr,{size:14,color:d.color.textSecondary})]}),i&&v(no,{children:[g&&v(s,{style:c.search,children:[p(Na,{size:12,color:d.color.textSecondary}),p(et,{style:c.searchInput,value:r,onChangeText:n,placeholder:"Search",placeholderTextColor:d.color.placeholder,autoCapitalize:"none",autoCorrect:false})]}),u.map((f,S)=>v(m,{onPress:()=>t.answer({blockId:e.id,kind:"select",optionId:f.id,label:f.label}),style:[c.option,S>0&&D.rowDivider],accessibilityRole:"button",children:[v(s,{style:c.flex,children:[p(l,{style:c.optionLabel,children:f.label}),f.detail?p(l,{style:c.optionDetail,children:f.detail}):null]}),p(Er,{size:12,color:d.color.textTertiary})]},f.id)),e.options.length>u.length?v(l,{style:c.hint,children:[e.options.length-u.length," more \u2014 keep typing"]}):null]})]})]})}function Nr({min:e,max:t,step:o=1,value:r,unit:n,onChange:i,disabled:a}){let h=Or(0),u=t>e?(r-e)/(t-e)*100:0,g=q=>Math.min(t,Math.max(e,+(Math.round((q-e)/o)*o+e).toFixed(6))),f=q=>!a&&i(g(r+q*o)),S=q=>{if(a||h.current<=0)return;let X=Math.min(1,Math.max(0,q.nativeEvent.locationX/h.current));i(g(e+X*(t-e)))},j=q=>{h.current=q.nativeEvent.layout.width};return v(s,{style:c.sliderRow,children:[p(m,{disabled:a,onPress:()=>f(-1),style:c.stepBtn,accessibilityRole:"button",accessibilityLabel:"Decrease",children:p(l,{style:c.stepText,children:"\u2212"})}),p(m,{style:c.trackHit,onLayout:j,onPress:S,disabled:a,accessibilityRole:"adjustable",accessibilityValue:{min:e,max:t,now:r},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:q=>f(q.nativeEvent.actionName==="increment"?1:-1),children:v(s,{style:c.track,pointerEvents:"none",children:[p(s,{style:[c.fill,{width:`${u}%`}]}),p(s,{style:[c.thumb,{left:`${u}%`}]})]})}),p(m,{disabled:a,onPress:()=>f(1),style:c.stepBtn,accessibilityRole:"button",accessibilityLabel:"Increase",children:p(l,{style:c.stepText,children:"+"})}),v(l,{style:c.sliderValue,children:[r,n?` ${n}`:""]})]})}function Ua({block:e}){let t=Z(),o=t.answered[e.id],[r,n]=Ke(e.value??e.min);return v(P,{testID:`buoy-block-slider-${e.id}`,tone:o?void 0:"info",children:[p(l,{style:c.question,children:e.label}),p(s,{style:c.pad,children:p(Nr,{min:e.min,max:e.max,step:e.step,value:o?.kind==="slider"?o.value:r,unit:e.unit,onChange:n,disabled:!!o})}),o?null:p(s,{style:c.rowEnd,children:p(m,{onPress:()=>t.answer({blockId:e.id,kind:"slider",value:r,unit:e.unit}),style:[c.button,c.buttonPrimary],children:v(l,{style:c.buttonTextPrimary,children:["Use ",r,e.unit?` ${e.unit}`:""]})})})]})}function Ka({block:e}){let t=Z(),o=t.answered[e.id],[r,n]=Ke(""),i=e.presets??[{label:"Now",value:new Date().toISOString()},{label:"Tomorrow",value:new Date(Date.now()+864e5).toISOString()},{label:"+7 days",value:new Date(Date.now()+7*864e5).toISOString()},{label:"+30 days",value:new Date(Date.now()+30*864e5).toISOString()}];return v(P,{testID:`buoy-block-datetime-${e.id}`,tone:o?void 0:"info",children:[p(l,{style:c.question,children:e.label}),o?p(l,{style:c.decided,children:o.kind==="dateTime"?o.label??o.value:"(skipped)"}):v(no,{children:[p(s,{style:[c.chips,c.pad],children:i.map(a=>p(m,{onPress:()=>t.answer({blockId:e.id,kind:"dateTime",value:a.value,label:a.label}),style:c.chip,children:p(l,{style:c.chipText,children:a.label})},a.label))}),v(s,{style:[c.inputRow,c.pad],children:[p(et,{style:c.input,value:r,onChangeText:n,placeholder:e.mode==="time"?"14:30":"2026-09-15",placeholderTextColor:d.color.placeholder,keyboardType:"numbers-and-punctuation"}),p(m,{disabled:!r.trim(),onPress:()=>t.answer({blockId:e.id,kind:"dateTime",value:r.trim()}),style:[c.button,c.buttonPrimary,!r.trim()&&c.disabled],children:p(l,{style:c.buttonTextPrimary,children:"Use"})})]})]})]})}function jr({f:e,value:t,onChange:o,disabled:r}){return e.type==="toggle"?v(s,{style:c.fieldRow,children:[p(l,{style:c.fieldLabel,children:e.label}),p(dr,{value:!!t,onValueChange:o,disabled:r,trackColor:{true:d.color.accent,false:d.color.fillTertiary},thumbColor:d.color.knob})]}):e.type==="select"?v(s,{style:c.fieldCol,children:[p(l,{style:c.fieldLabel,children:e.label}),p(s,{style:c.chips,children:e.options.map(n=>p(m,{disabled:r,onPress:()=>o(n.id),style:[c.chip,t===n.id&&c.chipOn],children:p(l,{style:[c.chipText,t===n.id&&c.chipTextOn],children:n.label})},n.id))})]}):e.type==="slider"?v(s,{style:c.fieldCol,children:[p(l,{style:c.fieldLabel,children:e.label}),p(Nr,{min:e.min,max:e.max,step:e.step,unit:e.unit,value:typeof t=="number"?t:e.min,onChange:o,disabled:r})]}):v(s,{style:c.fieldRow,children:[p(l,{style:c.fieldLabel,children:e.label}),p(et,{style:c.fieldInput,value:t==null?"":String(t),onChangeText:o,editable:!r,placeholder:e.placeholder??"",placeholderTextColor:d.color.placeholder,keyboardType:e.type==="number"?"numeric":"ascii-capable",secureTextEntry:e.type==="secret",autoCapitalize:"none",autoCorrect:false})]})}function Mr(e){let[t,o]=Ke(()=>Object.fromEntries(e.map(r=>[r.key,r.value])));return{values:t,set:(r,n)=>o(i=>({...i,[r]:n}))}}function Ga({block:e}){let t=Z(),o=t.answered[e.id],{values:r,set:n}=Mr(e.fields);return v(P,{title:e.title,testID:`buoy-block-form-${e.id}`,tone:o?void 0:"info",children:[p(s,{style:c.pad,children:e.fields.map(i=>p(jr,{f:i,value:r[i.key],onChange:a=>n(i.key,a),disabled:!!o},i.key))}),o?p(l,{style:c.decided,children:"Sent"}):p(s,{style:c.rowEnd,children:p(m,{onPress:()=>t.answer({blockId:e.id,kind:"form",values:r}),style:[c.button,c.buttonPrimary],children:p(l,{style:c.buttonTextPrimary,children:e.submitLabel??"Send"})})})]})}function Ja({block:e}){let t=Z(),o=t.answered[e.id],{values:r,set:n}=Mr(e.fields),i=o?.kind==="proposal"?o.approved:null;return v(P,{testID:`buoy-block-proposal-${e.id}`,tone:o?void 0:"warning",children:[p(l,{style:c.confirmTitle,children:e.title}),p(l,{style:c.confirmChange,children:e.change}),p(s,{style:c.pad,children:e.fields.map(a=>p(jr,{f:a,value:r[a.key],onChange:h=>n(a.key,h),disabled:!!o},a.key))}),e.consequence?p(l,{style:c.consequence,children:e.consequence}):null,p(s,{style:c.actionsRow,children:o?p(l,{style:c.decided,children:i?"\u2713 Applied with these values":"\u2715 Not applied"}):v(no,{children:[p(m,{onPress:()=>t.answer({blockId:e.id,kind:"proposal",approved:true,values:r}),style:[c.button,c.buttonPrimary],children:p(l,{style:c.buttonTextPrimary,children:e.approveLabel??"Apply"})}),p(m,{onPress:()=>t.answer({blockId:e.id,kind:"proposal",approved:false}),style:[c.button,c.buttonPlate],children:p(l,{style:c.buttonTextPlate,children:"Not now"})})]})})]})}function Qa({block:e}){let t=Z(),[o,r]=Ke(null),n=t.actionState?.[`${e.id}:${e.verify?.label??"Verify"}`],i=e.verified||n==="done";return v(s,{style:c.claim,testID:`buoy-block-claim-${e.id}`,children:[v(l,{style:c.claimText,children:[e.text,e.sources.map((a,h)=>v(l,{onPress:()=>r(o===h?null:h),style:c.cite,children:[" [",h+1,"]"]},h)),i?p(l,{style:c.verified,children:" \u2713 verified"}):null]}),o!==null&&e.sources[o]?v(s,{style:c.citeBox,children:[v(l,{style:c.citeLabel,children:["[",o+1,"] ",e.sources[o].label]}),e.sources[o].detail?p(l,{style:c.citeDetail,children:e.sources[o].detail}):null]}):null,e.verify&&!i?v(m,{onPress:()=>void t.runAction(e.verify,e.id),style:c.verifyBtn,accessibilityRole:"button",children:[p(Va,{size:11,color:d.color.accent}),p(l,{style:c.verifyText,children:n==="running"?"Checking\u2026":e.verify.label})]}):null]})}function Ya({block:e}){let[t,o]=Ke(!!e.open);return v(P,{testID:`buoy-block-details-${e.id}`,children:[v(m,{onPress:()=>o(r=>!r),style:D.row,accessibilityRole:"button",accessibilityState:{expanded:t},children:[p(l,{style:D.rowTitle,children:e.summary}),t?p(Wr,{size:12,color:d.color.textTertiary}):p(Er,{size:12,color:d.color.textTertiary})]}),t?p(l,{style:c.detailsBody,selectable:true,children:e.body}):null]})}function Xa({block:e,renderNested:t}){let[o,r]=Ke(0),n=e.tabs.map((a,h)=>({key:String(h),label:a.label})),i=e.tabs[o];return v(s,{style:c.tabsWrap,testID:`buoy-block-tabs-${e.id}`,children:[p(Ea,{tabs:n,activeKey:String(o),onChange:a=>r(Number(a)),size:"sm"}),i&&t?t(i.block):null]})}var Za=10;function es({block:e}){let t=ot(e.events,Za);return v(P,{title:e.title??"What happened",source:e.source,testID:`buoy-block-timeline-${e.id}`,children:[t.visible.map((o,r)=>v(s,{style:c.tlRow,children:[p(l,{style:c.tlAt,children:o.at}),v(s,{style:c.tlLine,children:[p(s,{style:[c.tlDot,{backgroundColor:kt(o.tone??"muted")}]}),r<t.visible.length-1?p(s,{style:c.tlStem}):null]}),v(s,{style:c.flex,children:[p(l,{style:c.tlSource,children:o.source.toUpperCase()}),p(l,{style:D.rowTitle,numberOfLines:2,children:o.label})]})]},r)),p(rt,{paged:t})]})}function ts({block:e}){let t=e.series.slice(-60),o=Math.max(1,...t),r=Math.min(...t,0),n=44;return v(P,{title:e.title,source:e.source,testID:`buoy-block-sparkline-${e.id}`,children:[v(s,{style:c.sparkHead,children:[v(l,{style:c.sparkCurrent,children:[e.current??t[t.length-1],e.unit?v(l,{style:c.sparkUnit,children:[" ",e.unit]}):null]}),e.live?p(qr,{}):null]}),p(s,{style:[c.spark,{height:n}],children:t.map((i,a)=>p(s,{style:[c.sparkBar,{height:Math.max(2,(i-r)/(o-r||1)*n),backgroundColor:a===t.length-1?d.color.accent:d.color.accentBorderStrong}]},a))}),e.label?p(l,{style:c.hint,children:e.label}):null]})}function qr(){let e=Or(new ce.Value(1)).current;return Pa(()=>{let t=ce.loop(ce.sequence([ce.timing(e,{toValue:.3,duration:700,useNativeDriver:true}),ce.timing(e,{toValue:1,duration:700,useNativeDriver:true})]));return t.start(),()=>t.stop()},[e]),v(s,{style:c.live,children:[p(ce.View,{style:[c.liveDot,{opacity:e}]}),p(l,{style:c.liveText,children:"LIVE"})]})}function os({block:e}){let t=[...new Set([...e.left.pairs.map(n=>n.key),...e.right.pairs.map(n=>n.key)])],o=Object.fromEntries(e.left.pairs.map(n=>[n.key,n.value])),r=Object.fromEntries(e.right.pairs.map(n=>[n.key,n.value]));return v(P,{title:e.title,source:e.source,testID:`buoy-block-compare-${e.id}`,children:[v(s,{style:c.cmpHead,children:[p(l,{style:c.cmpKey}),p(l,{style:c.cmpCol,children:e.left.title}),p(l,{style:c.cmpCol,children:e.right.title})]}),t.map((n,i)=>{let a=JSON.stringify(o[n])!==JSON.stringify(r[n]);return v(s,{style:[c.cmpRow,i>0&&D.rowDivider,a&&c.cmpDiff],children:[p(l,{style:c.cmpKey,numberOfLines:1,children:n}),p(l,{style:[c.cmpVal,a&&{color:d.color.danger}],numberOfLines:2,children:Vr(o[n])}),p(l,{style:[c.cmpVal,a&&{color:d.color.accent}],numberOfLines:2,children:Vr(r[n])})]},n)})]})}function Fr({c:e,id:t}){return v(no,{children:[e.image?p(xt,{testID:"buoy-internal-chat-image",source:{uri:e.image},style:c.cardImage,resizeMode:"contain",accessibilityLabel:e.title}):null,v(s,{style:c.cardText,children:[p(l,{style:c.cardTitle,numberOfLines:2,children:e.title}),e.subtitle?p(l,{style:D.rowSub,numberOfLines:2,children:e.subtitle}):null,e.facts?.slice(0,4).map(o=>v(s,{style:c.fact,children:[p(l,{style:c.factLabel,children:o.label}),p(l,{style:[c.factValue,o.tone&&{color:kt(o.tone)}],children:o.value})]},o.label))]}),p(Ee,{actions:e.actions,blockId:t})]})}function rs({block:e}){return p(P,{source:e.source,testID:`buoy-block-card-${e.id}`,children:p(Fr,{c:e,id:e.id})})}function ns({block:e}){return v(s,{testID:`buoy-block-cardcarousel-${e.id}`,children:[e.title?p(l,{style:c.carouselTitle,children:e.title}):null,p(_e,{horizontal:true,showsHorizontalScrollIndicator:false,snapToInterval:232,decelerationRate:"fast",contentContainerStyle:c.carousel,children:e.cards.slice(0,8).map((t,o)=>p(s,{style:c.carouselCard,children:p(Fr,{c:t,id:`${e.id}-${o}`})},`${t.title}-${o}`))})]})}function is({block:e}){let[t,o]=Ke(false);return v(P,{title:e.route?`Screen \xB7 ${e.route}`:"Screen",source:e.source,testID:`buoy-block-screenshot-${e.id}`,children:[p(m,{onPress:()=>o(r=>!r),accessibilityRole:"imagebutton",accessibilityLabel:e.caption??"Screenshot",children:p(xt,{testID:"buoy-internal-chat-image",source:{uri:e.url},style:[c.shot,t&&c.shotBig],resizeMode:"contain"})}),e.caption?p(l,{style:c.hint,children:e.caption}):null]})}function ls({block:e}){let t=e.steps.filter(o=>o.state==="done").length;return v(P,{title:e.title,testID:`buoy-block-plan-${e.id}`,tone:e.pending?"info":void 0,children:[p(s,{style:c.progress,children:p(s,{style:[c.progressFill,{width:`${t/Math.max(1,e.steps.length)*100}%`}]})}),e.steps.map((o,r)=>v(s,{style:[c.step,r>0&&D.rowDivider],children:[p(s,{style:[c.stepMark,o.state==="done"&&c.stepDone,o.state==="failed"&&c.stepFailed,o.state==="running"&&c.stepRunning],children:o.state==="done"?p(Pr,{size:10,color:d.color.onAccent}):o.state==="failed"?p(ja,{size:10,color:d.color.text}):p(l,{style:c.stepNum,children:r+1})}),v(l,{style:[D.rowTitle,o.state==="done"&&c.muted],children:[o.text,o.state==="running"?"\u2026":""]})]},r)),p(Ee,{actions:e.actions??(e.pending?[{label:"Go",primary:true,send:"Go ahead with the plan."},{label:"Change it",send:"Let me change the plan first."}]:void 0),blockId:e.id})]})}function as({block:e}){let t=Z();return v(m,{testID:`buoy-block-checkpoint-${e.id}`,disabled:!e.restore,onPress:()=>e.restore&&void t.runAction(e.restore,e.id),style:c.checkpoint,accessibilityRole:"button",children:[p(s,{style:c.cpFlag}),v(l,{style:c.cpText,children:[e.label,e.at?` \xB7 ${e.at}`:""]}),e.restore?p(l,{style:c.cpRestore,children:e.restore.label}):null]})}function ss({block:e}){let t=e.status==="failed"?d.color.danger:e.status==="done"?d.color.accent:d.color.info;return v(P,{testID:`buoy-block-task-${e.id}`,children:[v(s,{style:c.taskHead,children:[p(l,{style:c.cardTitle,children:e.title}),p(s,{style:[D.pill,{backgroundColor:`${t}22`}],children:p(l,{style:[D.pillText,{color:t}],children:e.status.toUpperCase()})})]}),e.progress!==void 0?p(s,{style:[c.progress,c.pad],children:p(s,{style:[c.progressFill,{width:`${Math.round(e.progress*100)}%`,backgroundColor:t}]})}):null,e.detail?p(l,{style:c.hint,children:e.detail}):null,p(Ee,{actions:e.actions,blockId:e.id})]})}function cs({block:e}){let t=e.tone==="danger"?d.color.danger:e.tone==="warning"?d.color.warning:d.color.info;return v(s,{style:[c.banner,{borderColor:t,backgroundColor:`${t}1A`}],testID:`buoy-block-banner-${e.id}`,children:[p(Wa,{size:13,color:t}),p(l,{style:[c.bannerText,{color:t}],numberOfLines:2,children:e.text}),e.actions?.[0]?p(Ee,{actions:e.actions.slice(0,1),blockId:e.id,align:"right"}):null]})}function ds({block:e}){return v(P,{testID:`buoy-block-file-${e.id}`,children:[v(s,{style:D.row,children:[p(s,{style:c.fileIcon,children:p(l,{style:c.fileExt,children:(e.type??e.name.split(".").pop()??"file").toUpperCase().slice(0,4)})}),v(s,{style:c.flex,children:[p(l,{style:D.rowTitle,numberOfLines:1,children:e.name}),e.size?p(l,{style:D.rowSub,children:e.size}):null]})]}),p(Ee,{actions:e.actions,blockId:e.id})]})}function us({block:e}){let t=Z(),o=t.answered[e.id];return v(P,{testID:`buoy-block-upload-${e.id}`,tone:o?void 0:"info",children:[p(l,{style:c.question,children:e.label}),o?p(l,{style:c.decided,children:o.kind==="upload"?`Attached ${o.name}`:"(skipped)"}):p(s,{style:[c.rowEnd,{justifyContent:"flex-start"}],children:p(m,{onPress:()=>t.answer({blockId:e.id,kind:"upload",name:"screenshot.png"}),style:[c.button,c.buttonPlate],children:p(l,{style:c.buttonTextPlate,children:e.accept==="image"?"Choose a screenshot":"Choose a file"})})})]})}var c=w.create({flex:{flex:1},pad:{paddingHorizontal:12,paddingBottom:8},muted:{color:d.color.textSecondary},dim:{opacity:.45},disabled:{opacity:.5},pressed:{opacity:.7},question:{color:d.color.text,fontSize:d.font.row,fontWeight:"600",lineHeight:20,paddingHorizontal:12,paddingTop:12,paddingBottom:8},hint:{color:d.color.textTertiary,fontSize:d.font.micro,paddingHorizontal:12,paddingBottom:10},decided:{color:d.color.textSecondary,fontSize:d.font.caption,fontWeight:"600",paddingHorizontal:12,paddingVertical:10},rowEnd:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:12,paddingBottom:12,gap:8},actionsRow:{flexDirection:"row",gap:8,paddingHorizontal:12,paddingVertical:12,alignItems:"center"},button:{paddingHorizontal:14,paddingVertical:9,borderRadius:d.radius.row},buttonPrimary:{backgroundColor:d.color.accent},buttonPlate:{backgroundColor:d.color.button},buttonTextPrimary:{color:d.color.onAccent,fontSize:d.font.caption,fontWeight:"600"},buttonTextPlate:{color:d.color.text,fontSize:d.font.caption,fontWeight:"600"},chips:{flexDirection:"row",flexWrap:"wrap",gap:6},chip:{paddingHorizontal:12,paddingVertical:7,borderRadius:d.radius.chip,backgroundColor:d.color.fill,borderWidth:w.hairlineWidth,borderColor:d.color.border},chipOn:{backgroundColor:d.color.accentSoft,borderColor:d.color.accentBorderStrong},chipText:{color:d.color.text,fontSize:d.font.caption},chipTextOn:{color:d.color.accent,fontWeight:"600"},optionsBox:{marginHorizontal:8,marginBottom:8,borderRadius:d.radius.row,backgroundColor:d.color.surfaceElevated,overflow:"hidden"},option:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:10},optionLabel:{color:d.color.text,fontSize:d.font.body,fontWeight:"500"},optionDetail:{color:d.color.textSecondary,fontSize:d.font.caption},checkbox:{width:20,height:20,borderRadius:6,borderWidth:1.5,borderColor:d.color.textTertiary,alignItems:"center",justifyContent:"center"},checkboxOn:{backgroundColor:d.color.accent,borderColor:d.color.accent},selectBox:{marginHorizontal:12,marginBottom:12,borderRadius:d.radius.row,backgroundColor:d.color.surfaceElevated,overflow:"hidden"},selectField:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:11},selectPlaceholder:{color:d.color.textSecondary,fontSize:d.font.body},search:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:6,borderTopWidth:w.hairlineWidth,borderTopColor:d.color.separator},searchInput:{flex:1,color:d.color.text,fontSize:d.font.caption,paddingVertical:4},sliderRow:{flexDirection:"row",alignItems:"center",gap:8},stepBtn:{width:28,height:28,borderRadius:14,backgroundColor:d.color.fill,alignItems:"center",justifyContent:"center"},stepText:{color:d.color.text,fontSize:16,fontWeight:"600"},trackHit:{flex:1,height:36,justifyContent:"center"},track:{height:6,borderRadius:3,backgroundColor:d.color.fillTertiary,justifyContent:"center"},fill:{height:6,borderRadius:3,backgroundColor:d.color.accent},thumb:{position:"absolute",width:20,height:20,borderRadius:10,backgroundColor:d.color.knob,marginLeft:-10,shadowColor:"#000",shadowOpacity:.35,shadowRadius:3,shadowOffset:{width:0,height:1}},sliderValue:{width:64,textAlign:"right",color:d.color.text,fontSize:d.font.caption,fontWeight:"600"},inputRow:{flexDirection:"row",alignItems:"center",gap:8,paddingBottom:12},input:{flex:1,height:38,paddingHorizontal:12,borderRadius:d.radius.row,backgroundColor:d.color.surfaceElevated,color:d.color.text,fontSize:d.font.body},fieldRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:10,paddingVertical:6},fieldCol:{paddingVertical:6,gap:6},fieldLabel:{color:d.color.textSecondary,fontSize:d.font.caption,width:110},fieldInput:{flex:1,height:34,paddingHorizontal:10,borderRadius:d.radius.segment,backgroundColor:d.color.surfaceElevated,color:d.color.text,fontSize:d.font.caption},confirmTitle:{color:d.color.text,fontSize:d.font.row,fontWeight:"600",paddingHorizontal:12,paddingTop:12},confirmChange:{color:d.color.text,fontSize:d.font.body,lineHeight:19,paddingHorizontal:12,paddingTop:6,paddingBottom:6},consequence:{color:d.color.warning,fontSize:d.font.caption,paddingHorizontal:12},claim:{gap:6,paddingHorizontal:2},claimText:{color:d.color.text,fontSize:d.font.row,lineHeight:22},cite:{color:d.color.accent,fontSize:d.font.caption,fontWeight:"700"},verified:{color:d.color.accent,fontSize:d.font.caption,fontWeight:"600"},citeBox:{padding:10,borderRadius:d.radius.row,backgroundColor:d.color.surface,borderWidth:w.hairlineWidth,borderColor:d.color.border,gap:2},citeLabel:{color:d.color.text,fontSize:d.font.caption,fontWeight:"600"},citeDetail:{color:d.color.textSecondary,fontSize:d.font.caption,fontFamily:we.OS==="web"?So:"Menlo"},verifyBtn:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:5,paddingHorizontal:10,paddingVertical:5,borderRadius:d.radius.chip,backgroundColor:d.color.accentSoft},verifyText:{color:d.color.accent,fontSize:d.font.micro,fontWeight:"700"},detailsBody:{color:d.color.textSecondary,fontSize:d.font.caption,lineHeight:18,paddingHorizontal:12,paddingBottom:12},tabsWrap:{gap:8},tabBar:{flexDirection:"row",gap:6},tab:{paddingHorizontal:12,paddingVertical:6,borderRadius:d.radius.badge,backgroundColor:d.color.fill},tabOn:{backgroundColor:d.color.accentSoft},tabText:{color:d.color.textSecondary,fontSize:d.font.caption,fontWeight:"600"},tabTextOn:{color:d.color.accent},tlRow:{flexDirection:"row",gap:10,paddingHorizontal:12,paddingVertical:4,alignItems:"flex-start"},tlAt:{width:46,color:d.color.textTertiary,fontSize:d.font.micro,fontFamily:we.OS==="web"?So:"Menlo",paddingTop:3},tlLine:{width:12,alignItems:"center"},tlDot:{width:8,height:8,borderRadius:4,marginTop:5},tlStem:{width:1,flex:1,minHeight:18,backgroundColor:d.color.separator,marginTop:2},tlSource:{color:d.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.6},sparkHead:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingTop:8},sparkCurrent:{color:d.color.text,fontSize:22,fontWeight:"700"},sparkUnit:{color:d.color.textSecondary,fontSize:d.font.caption,fontWeight:"500"},spark:{flexDirection:"row",alignItems:"flex-end",gap:2,paddingHorizontal:12,paddingTop:6,paddingBottom:6},sparkBar:{flex:1,borderRadius:1},live:{flexDirection:"row",alignItems:"center",gap:5,paddingHorizontal:8,paddingVertical:3,borderRadius:d.radius.badge,backgroundColor:d.color.dangerSoft},liveDot:{width:6,height:6,borderRadius:3,backgroundColor:d.color.danger},liveText:{color:d.color.danger,fontSize:9,fontWeight:"800",letterSpacing:.8},cmpHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,backgroundColor:d.color.fill,gap:8},cmpCol:{flex:1,color:d.color.textTertiary,fontSize:d.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},cmpRow:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"flex-start"},cmpDiff:{backgroundColor:d.color.fill},cmpKey:{width:90,color:d.color.textSecondary,fontSize:d.font.caption},cmpVal:{flex:1,color:d.color.text,fontSize:d.font.caption,fontFamily:we.OS==="web"?So:"Menlo"},cardImage:{width:"100%",height:140,backgroundColor:d.color.fill},cardText:{paddingHorizontal:12,paddingTop:10,paddingBottom:4,gap:4},cardTitle:{color:d.color.text,fontSize:d.font.row,fontWeight:"600"},fact:{flexDirection:"row",justifyContent:"space-between",gap:8},factLabel:{color:d.color.textSecondary,fontSize:d.font.caption},factValue:{color:d.color.text,fontSize:d.font.caption,fontWeight:"500"},carouselTitle:{color:d.color.text,fontSize:d.font.caption,fontWeight:"600",paddingBottom:8},carousel:{gap:8,paddingRight:8},carouselCard:{width:224,borderRadius:d.radius.card,borderWidth:w.hairlineWidth,borderColor:d.color.border,backgroundColor:d.color.surface,overflow:"hidden"},shot:{width:"100%",height:220,backgroundColor:d.color.fill},shotBig:{height:520},progress:{height:4,backgroundColor:d.color.fill,marginHorizontal:12,marginTop:6,marginBottom:8,borderRadius:2,overflow:"hidden"},progressFill:{height:4,backgroundColor:d.color.accent},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:d.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:d.color.accent},stepFailed:{backgroundColor:d.color.danger},stepRunning:{backgroundColor:d.color.info},stepNum:{color:d.color.text,fontSize:d.font.micro,fontWeight:"700"},checkpoint:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:7,borderRadius:d.radius.chip,backgroundColor:d.color.fill},cpFlag:{width:8,height:8,borderRadius:2,backgroundColor:d.color.info},cpText:{color:d.color.textSecondary,fontSize:d.font.caption},cpRestore:{color:d.color.accent,fontSize:d.font.caption,fontWeight:"600"},taskHead:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:8,paddingHorizontal:12,paddingTop:12},banner:{flexDirection:"row",alignItems:"center",gap:8,paddingLeft:12,paddingRight:4,paddingVertical:4,borderRadius:d.radius.row,borderWidth:w.hairlineWidth},bannerText:{flex:1,fontSize:d.font.caption,fontWeight:"600"},fileIcon:{width:40,height:40,borderRadius:8,backgroundColor:d.color.fill,alignItems:"center",justifyContent:"center"},fileExt:{color:d.color.textSecondary,fontSize:10,fontWeight:"800"}});import{jsx as A}from"react/jsx-runtime";var ps=class extends sl{constructor(){super(...arguments);this.state={failed:false}}static getDerivedStateFromError(){return{failed:true}}render(){return this.state.failed?A(l,{style:hs.fallback,testID:"buoy-block-render-failed",children:"This card couldn't be drawn \u2014 the data behind it is still in the conversation."}):this.props.children}},hs=w.create({fallback:{color:pr.color.textTertiary,fontSize:pr.font.micro,fontStyle:"italic",paddingVertical:6}}),gs=e=>A(io,{block:e});function io({block:e}){return A(ps,{children:A(fs,{block:e})})}function fs({block:e}){switch(e.kind){case"choice":return A(Ol,{block:e});case"confirm":return A(Pl,{block:e});case"input":return A(Wl,{block:e});case"table":return A(la,{block:e});case"keyValue":return A(aa,{block:e});case"list":return A(ca,{block:e});case"imageGrid":return A(wa,{block:e});case"diff":return A(ua,{block:e});case"chart":return A(pa,{block:e});case"steps":return A(ha,{block:e});case"code":return A(ya,{block:e});case"actions":return A(Ee,{actions:e.actions,blockId:e.id});case"notice":return A(ma,{block:e});case"finding":return A(xa,{block:e});case"requestList":return A(za,{block:e});case"requestCard":return A(Ra,{block:e});case"ruleCard":return A($a,{block:e});case"screenElements":return A(Aa,{block:e});case"routeChips":return A(Ba,{block:e});case"logList":return A(Ha,{block:e});case"crash":return A(La,{block:e});case"peek":return A(Oa,{block:e});case"suggestions":return A(Ma,{block:e});case"multiSelect":return A(qa,{block:e});case"select":return A(_a,{block:e});case"slider":return A(Ua,{block:e});case"dateTime":return A(Ka,{block:e});case"form":return A(Ga,{block:e});case"proposal":return A(Ja,{block:e});case"claim":return A(Qa,{block:e});case"details":return A(Ya,{block:e});case"tabs":return A(Xa,{block:e,renderNested:gs});case"timeline":return A(es,{block:e});case"sparkline":return A(ts,{block:e});case"compare":return A(os,{block:e});case"card":return A(rs,{block:e});case"cardCarousel":return A(ns,{block:e});case"screenshot":return A(is,{block:e});case"plan":return A(ls,{block:e});case"checkpoint":return A(as,{block:e});case"task":return A(ss,{block:e});case"banner":return A(cs,{block:e});case"file":return A(ds,{block:e});case"upload":return A(us,{block:e});default:return null}}import{monoFont as bs}from"@buoy-gg/shared-ui/web";import{useEffect as ys,useState as vt}from"react";import{ChevronDown as ms,ChevronRight as xs,Copy as ks,night as C,RefreshCw as ws}from"@buoy-gg/shared-ui/web";import{jsx as E,jsxs as De}from"react/jsx-runtime";function qt({label:e,onPress:t,children:o}){return E(m,{onPress:t,accessibilityRole:"button",accessibilityLabel:e,style:({pressed:r})=>[L.iconBtn,r&&L.pressed],children:o})}function vs({id:e="chrome-actions"}){let t=Z(),[o,r]=vt(null),n=i=>void t.runAction({label:i,send:`__chrome__:${i}`},e);return De(s,{style:L.actions,testID:"chrome-message-actions",children:[E(qt,{label:"Copy",onPress:()=>n("copy"),children:E(ks,{size:13,color:C.color.textSecondary})}),E(qt,{label:"Retry",onPress:()=>n("retry"),children:E(ws,{size:13,color:C.color.textSecondary})}),E(qt,{label:"Good answer",onPress:()=>{r("up"),n("thumbs up")},children:E(l,{style:[L.glyph,o==="up"&&L.glyphOn],children:"\u{1F44D}"})}),E(qt,{label:"Bad answer",onPress:()=>{r("down"),n("thumbs down")},children:E(l,{style:[L.glyph,o==="down"&&L.glyphOn],children:"\u{1F44E}"})}),E(qt,{label:"Export",onPress:()=>n("export transcript"),children:E(l,{style:L.textBtn,children:"Export"})})]})}function Ss({text:e,live:t}){let[o,r]=vt(false);return De(s,{style:L.reasoning,testID:"chrome-reasoning",children:[De(m,{onPress:()=>r(n=>!n),style:L.reasoningHead,accessibilityRole:"button",accessibilityState:{expanded:o},children:[t?E(Nt,{size:"small",color:C.color.textTertiary}):null,E(l,{style:L.reasoningTitle,children:t?"Working it out\u2026":"How I got here"}),o?E(ms,{size:12,color:C.color.textTertiary}):E(xs,{size:12,color:C.color.textTertiary})]}),o?E(l,{style:L.reasoningBody,children:e}):null]})}function Ts({label:e}){let[t,o]=vt(0);return ys(()=>{let r=setInterval(()=>o(n=>n+250),250);return()=>clearInterval(r)},[]),De(s,{style:L.elapsed,testID:"chrome-elapsed",children:[E(Nt,{size:"small",color:C.color.textSecondary}),E(l,{style:L.elapsedLabel,children:e}),De(l,{style:L.elapsedMs,children:[(t/1e3).toFixed(1),"s"]})]})}function Cs(){let[e,t]=vt(""),[o,r]=vt(null);return De(s,{style:L.composerWrap,testID:"chrome-queue",children:[o?De(s,{style:L.queuedRow,children:[De(l,{style:L.queuedText,numberOfLines:1,children:['Queued: "',o,'"']}),E(m,{onPress:()=>r(null),children:E(l,{style:L.queuedCancel,children:"Cancel"})})]}):null,De(s,{style:L.composer,children:[E(et,{style:L.composerInput,value:e,onChangeText:t,placeholder:"Agent is busy \u2014 type and it sends next",placeholderTextColor:C.color.placeholder}),E(m,{disabled:!e.trim(),onPress:()=>{r(e.trim()),t("")},style:[L.queueBtn,!e.trim()&&{opacity:.5}],children:E(l,{style:L.queueBtnText,children:"Queue"})})]})]})}function Is({at:e}){return De(s,{style:L.divider,testID:"chrome-divider",children:[E(s,{style:L.dividerLine}),De(l,{style:L.dividerText,children:["App reloaded \xB7 ",e]}),E(s,{style:L.dividerLine})]})}function zs({at:e}){return E(l,{style:L.timestamp,children:e})}function Ds({text:e}){let t=Z(),[o,r]=vt(false),[n,i]=vt(e);return E(s,{style:L.userWrap,testID:"chrome-edit-bubble",children:o?De(s,{style:L.editBox,children:[E(et,{style:L.editInput,value:n,onChangeText:i,multiline:true}),De(s,{style:L.editActions,children:[E(m,{onPress:()=>{r(false),t.runAction({label:"re-run edited",send:`__chrome__:re-run "${n}"`},"chrome-edit")},style:L.editPrimary,children:E(l,{style:L.editPrimaryText,children:"Re-run from here"})}),E(m,{onPress:()=>{r(false),t.runAction({label:"branch",send:`__chrome__:branch "${n}"`},"chrome-edit")},style:L.editPlate,children:E(l,{style:L.editPlateText,children:"Branch"})}),E(m,{onPress:()=>r(false),style:L.editPlate,children:E(l,{style:L.editPlateText,children:"Cancel"})})]})]}):De(m,{onLongPress:()=>r(true),onPress:()=>r(true),style:L.bubble,accessibilityRole:"button",accessibilityLabel:"Edit message",children:[E(l,{style:L.bubbleText,children:n}),E(l,{style:L.bubbleHint,children:"tap to edit \xB7 2 branches"})]})})}var L=w.create({actions:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:2},iconBtn:{paddingHorizontal:8,paddingVertical:6,borderRadius:C.radius.badge},pressed:{backgroundColor:C.color.fill},glyph:{fontSize:13,opacity:.6},glyphOn:{opacity:1},textBtn:{color:C.color.textSecondary,fontSize:C.font.micro,fontWeight:"600"},reasoning:{borderRadius:C.radius.row,backgroundColor:C.color.fill,overflow:"hidden"},reasoningHead:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:8},reasoningTitle:{flex:1,color:C.color.textSecondary,fontSize:C.font.caption,fontStyle:"italic"},reasoningBody:{color:C.color.textSecondary,fontSize:C.font.caption,lineHeight:18,paddingHorizontal:12,paddingBottom:10},elapsed:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:10,borderRadius:C.radius.card,borderWidth:w.hairlineWidth,borderColor:C.color.border,backgroundColor:C.color.surface},elapsedLabel:{flex:1,color:C.color.text,fontSize:C.font.body},elapsedMs:{color:C.color.textTertiary,fontSize:C.font.caption,fontFamily:we.OS==="web"?bs:"Menlo"},composerWrap:{gap:6},queuedRow:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:6,borderRadius:C.radius.row,backgroundColor:C.color.infoSoft},queuedText:{flex:1,color:C.color.text,fontSize:C.font.caption},queuedCancel:{color:C.color.info,fontSize:C.font.caption,fontWeight:"600"},composer:{flexDirection:"row",alignItems:"center",gap:8},composerInput:{flex:1,height:40,paddingHorizontal:16,borderRadius:20,borderWidth:w.hairlineWidth,borderColor:C.color.border,backgroundColor:C.color.surfaceElevated,color:C.color.text,fontSize:C.font.body},queueBtn:{paddingHorizontal:14,height:40,borderRadius:20,backgroundColor:C.color.button,alignItems:"center",justifyContent:"center"},queueBtnText:{color:C.color.text,fontSize:C.font.caption,fontWeight:"600"},divider:{flexDirection:"row",alignItems:"center",gap:10,paddingVertical:4},dividerLine:{flex:1,height:w.hairlineWidth,backgroundColor:C.color.border},dividerText:{color:C.color.textTertiary,fontSize:C.font.micro},timestamp:{alignSelf:"center",color:C.color.textTertiary,fontSize:C.font.micro},userWrap:{alignItems:"flex-end"},bubble:{maxWidth:"84%",paddingHorizontal:14,paddingVertical:9,borderRadius:18,borderBottomRightRadius:6,backgroundColor:C.color.accentFill,borderWidth:w.hairlineWidth,borderColor:C.color.accentBorder,gap:4},bubbleText:{color:C.color.text,fontSize:C.font.row,lineHeight:21},bubbleHint:{color:C.color.textTertiary,fontSize:10,textAlign:"right"},editBox:{width:"100%",gap:8},editInput:{minHeight:60,padding:12,borderRadius:C.radius.row,backgroundColor:C.color.surfaceElevated,color:C.color.text,fontSize:C.font.row,borderWidth:w.hairlineWidth,borderColor:C.color.accentBorderStrong},editActions:{flexDirection:"row",gap:8,justifyContent:"flex-end",flexWrap:"wrap"},editPrimary:{paddingHorizontal:12,paddingVertical:8,borderRadius:C.radius.row,backgroundColor:C.color.accent},editPrimaryText:{color:C.color.onAccent,fontSize:C.font.caption,fontWeight:"600"},editPlate:{paddingHorizontal:12,paddingVertical:8,borderRadius:C.radius.row,backgroundColor:C.color.button},editPlateText:{color:C.color.text,fontSize:C.font.caption,fontWeight:"600"}});import{useState as _r}from"react";import{AlertTriangle as Rs,ChevronDown as $s,night as W}from"@buoy-gg/shared-ui/web";import{jsx as me,jsxs as Ft}from"react/jsx-runtime";function Ur({pending:e,onAnswer:t}){let[o,r]=_r("");return Ft(s,{style:J.card,testID:"buoy-ask-buoy-approval",children:[Ft(s,{style:J.titleRow,children:[me(Rs,{size:14,color:W.color.warning}),me(l,{style:J.title,children:"Allow this change?"})]}),e.restored?me(l,{style:J.restored,testID:"buoy-ask-buoy-approval-restored",children:"Asked before the app restarted \u2014 check it still applies."}):null,me(l,{style:J.label,children:e.label}),me(l,{style:J.reason,children:e.reason}),e.description?me(As,{text:e.description}):null,me(et,{testID:"buoy-ask-buoy-approval-note",value:o,onChangeText:r,placeholder:"Add a note for the agent (optional)",placeholderTextColor:W.color.textTertiary,style:J.note,returnKeyType:"done",blurOnSubmit:true}),Ft(s,{style:J.actions,children:[me(m,{testID:"buoy-ask-buoy-approve",accessibilityRole:"button",onPress:()=>t({approved:true,reason:o}),style:({pressed:n})=>[J.button,J.approve,n&&J.pressed],children:me(l,{style:J.approveText,children:"Allow"})}),e.restored?null:me(m,{testID:"buoy-ask-buoy-approve-trust",accessibilityRole:"button",onPress:()=>t({approved:true,reason:o,trust:true}),style:({pressed:n})=>[J.button,J.trust,n&&J.pressed],children:me(l,{style:J.trustText,children:"Allow for this chat"})}),me(m,{testID:"buoy-ask-buoy-reject",accessibilityRole:"button",onPress:()=>t({approved:false,reason:o}),style:({pressed:n})=>[J.button,J.reject,n&&J.pressed],children:me(l,{style:J.rejectText,children:"Not now"})})]})]})}function As({text:e}){let[t,o]=_r(false);return Ft(s,{children:[Ft(m,{testID:"buoy-ask-buoy-approval-details",accessibilityRole:"button",accessibilityState:{expanded:t},onPress:()=>o(r=>!r),style:({pressed:r})=>[J.disclosure,r&&J.pressed],hitSlop:6,children:[me(s,{style:t?J.chevronOpen:J.chevronClosed,children:me($s,{size:12,color:W.color.textTertiary})}),me(l,{style:J.disclosureText,children:t?"Hide details":"Details"})]}),t?me(_e,{style:J.detail,contentContainerStyle:J.detailContent,nestedScrollEnabled:true,children:me(l,{style:J.description,children:e})}):null]})}var J=w.create({card:{marginHorizontal:W.gutter,marginBottom:10,padding:W.cardPad,borderRadius:W.radius.card,borderWidth:w.hairlineWidth,borderColor:W.color.accentBorderStrong,backgroundColor:W.color.surface,gap:6},titleRow:{flexDirection:"row",alignItems:"center",gap:6},title:{color:W.color.text,fontSize:W.font.caption,fontWeight:"600"},label:{color:W.color.text,fontSize:W.font.row,fontWeight:"600",lineHeight:20},description:{color:W.color.textSecondary,fontSize:W.font.caption,lineHeight:18},reason:{color:W.color.warning,fontSize:W.font.caption,lineHeight:18},restored:{color:W.color.info,backgroundColor:W.color.infoSoft,fontSize:W.font.micro,lineHeight:16,paddingHorizontal:8,paddingVertical:5,borderRadius:8},disclosure:{flexDirection:"row",alignItems:"center",gap:4,paddingVertical:4},disclosureText:{color:W.color.textTertiary,fontSize:W.font.micro,fontWeight:"600"},chevronOpen:{transform:[{rotate:"0deg"}]},chevronClosed:{transform:[{rotate:"-90deg"}]},detail:{maxHeight:150,marginTop:2},detailContent:{paddingBottom:2},note:{color:W.color.text,fontSize:W.font.caption,paddingHorizontal:10,paddingVertical:7,borderRadius:W.radius.row,borderWidth:w.hairlineWidth,borderColor:W.color.border,backgroundColor:W.color.button,marginTop:2},actions:{flexDirection:"row",flexWrap:"wrap",gap:8,marginTop:6},button:{paddingHorizontal:16,paddingVertical:9,borderRadius:W.radius.row},approve:{backgroundColor:W.color.accent},approveText:{color:W.color.onAccent,fontWeight:"600",fontSize:W.font.caption},trust:{backgroundColor:W.color.button,borderWidth:w.hairlineWidth,borderColor:W.color.accentBorderStrong},trustText:{color:W.color.accent,fontWeight:"600",fontSize:W.font.caption},reject:{backgroundColor:W.color.button},rejectText:{color:W.color.text,fontSize:W.font.caption},pressed:{opacity:.7}});import{useSyncExternalStore as Bs}from"react";import{ChevronDown as Hs,ChevronRight as Ls,night as oe}from"@buoy-gg/shared-ui/web";import{isReversible as Kr}from"@buoy-gg/agent-core/web";import{jsx as nt,jsxs as dt}from"react/jsx-runtime";var Gr=[];function Jr(e){return Bs(t=>e?.subscribe(t)??(()=>{}),()=>e?.list()??Gr,()=>e?.list()??Gr)}function Qr({ledger:e,onUndoAll:t,expanded:o,onToggle:r}){let n=Jr(e).filter(S=>!S.undoneAt),i=n.filter(S=>S.effect.kind!=="transient");if(i.length===0)return null;let a=i.filter(S=>Kr(S.effect)),h=i.length-a.length,u=n.length-i.length,g=o?Hs:Ls,f=[a.length>0?`${a.length} undoable`:null,h>0?`${h} permanent`:null].filter(Boolean).join(" \xB7 ");return dt(s,{style:ge.wrap,children:[dt(m,{testID:"buoy-ask-buoy-changes-bar",accessibilityRole:"button",accessibilityState:{expanded:o},onPress:r,style:ge.bar,children:[nt(s,{style:ge.dot}),nt(l,{style:ge.summary,numberOfLines:1,children:"Changed this app"}),nt(l,{style:ge.counts,numberOfLines:1,children:f}),nt(g,{size:12,color:oe.color.textSecondary})]}),o&&dt(s,{style:ge.panel,children:[dt(_e,{style:ge.panelScroll,testID:"buoy-ask-buoy-changes-scroll",keyboardShouldPersistTaps:"handled",children:[i.map(S=>{let j=!Kr(S.effect);return dt(s,{style:ge.row,children:[nt(l,{style:ge.rowLabel,children:S.effect.label}),nt(l,{style:[ge.rowTag,j&&ge.rowTagMuted],children:j?"Permanent":"Undoable"})]},S.id)}),u>0&&nt(s,{style:ge.row,children:dt(l,{style:[ge.rowLabel,ge.rowLabelMuted],children:["Also did ",u," one-shot action",u===1?"":"s"," (navigation, taps) \u2014 nothing to undo."]})})]}),dt(s,{style:ge.footer,children:[a.length>0&&nt(m,{testID:"buoy-ask-buoy-undo-all",accessibilityRole:"button",onPress:t,style:({pressed:S})=>[ge.undo,S&&ge.pressed],children:dt(l,{style:ge.undoText,children:["Undo ",a.length," change",a.length===1?"":"s"]})}),h>0&&nt(l,{style:ge.footnote,children:"Permanent changes can't be undone from here."})]})]})]})}var ge=w.create({wrap:{borderBottomWidth:w.hairlineWidth,borderBottomColor:oe.color.border,backgroundColor:oe.color.warningSoft},bar:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:oe.gutter,paddingVertical:10},dot:{width:7,height:7,borderRadius:4,backgroundColor:oe.color.warning},summary:{color:oe.color.text,fontSize:oe.font.caption,fontWeight:"600"},counts:{flex:1,color:oe.color.textSecondary,fontSize:oe.font.caption},panel:{paddingHorizontal:oe.gutter,paddingBottom:12,gap:10},panelScroll:{maxHeight:180},row:{flexDirection:"row",alignItems:"flex-start",gap:10,paddingVertical:8,borderTopWidth:w.hairlineWidth,borderTopColor:oe.color.separator},rowLabel:{flex:1,color:oe.color.text,fontSize:oe.font.caption,lineHeight:18},rowTag:{color:oe.color.accent,fontSize:oe.font.micro,fontWeight:"600",letterSpacing:.6,textTransform:"uppercase",paddingTop:2},rowTagMuted:{color:oe.color.textTertiary},rowLabelMuted:{color:oe.color.textTertiary},footer:{flexDirection:"row",alignItems:"center",gap:12,flexWrap:"wrap"},undo:{paddingHorizontal:14,paddingVertical:8,borderRadius:oe.radius.row,backgroundColor:oe.color.button},undoText:{color:oe.color.accent,fontSize:oe.font.caption,fontWeight:"600"},footnote:{flex:1,color:oe.color.textTertiary,fontSize:oe.font.micro},pressed:{opacity:.7}});function Os(e){let t={};for(let o of e){let r=o.effect;if(r.kind==="network-override")t[r.ruleId]=o.undoneAt?{deleted:true}:{enabled:true};else if(r.kind==="inverse-call"&&r.toolId==="network"&&r.action==="setOverrideRuleEnabled"&&typeof r.params.id=="string"){let n=r.params.enabled===true;if(t[r.params.id]?.deleted)continue;t[r.params.id]={enabled:o.undoneAt?n:!n}}}return t}import{useCallback as Ps,useEffect as Yr,useRef as Ws,useState as Es}from"react";import{night as Ce}from"@buoy-gg/shared-ui/web";import{jsx as ut,jsxs as Vs}from"react/jsx-runtime";var Xr=40,Ns=120,Zr=we.OS==="ios"?10:6,js=16;function en({onSend:e,onStop:t,busy:o,draft:r,onDraftTaken:n,disabled:i,placeholder:a,focusKey:h,canFocus:u=true}){let[g,f]=Es(""),S=Ws(null);Yr(()=>{!h||!u||i||S.current?.focus()},[h,u,i]),Yr(()=>{r&&(f(ee=>ee?`${ee} ${r}`:r),n?.())},[r,n]);let j=Ps(()=>{let ee=g.trim();ee&&(f(""),e(ee))},[g,e]),q=g.trim().length>0&&!o&&!i,X=g.trim().length>0&&o&&!i;return Vs(s,{style:xe.wrap,children:[ut(s,{style:[xe.field,i&&xe.fieldDisabled],children:ut(et,{ref:S,testID:"buoy-ask-buoy-input",style:[xe.input,g.length===0&&xe.inputEmpty],value:g,onChangeText:f,placeholder:a??(i?"Ask Buoy isn't set up yet":"Ask, or tell it what to change\u2026"),placeholderTextColor:Ce.color.placeholder,multiline:true,editable:!i,keyboardType:"ascii-capable",autoCorrect:true,autoCapitalize:"sentences",blurOnSubmit:false,onSubmitEditing:j,returnKeyType:"send",maxLength:4e3})}),X&&ut(m,{testID:"buoy-ask-buoy-queue",accessibilityRole:"button",accessibilityLabel:"Queue message",onPress:j,style:({pressed:ee})=>[xe.button,xe.queue,ee&&xe.pressed],children:ut(l,{style:[xe.sendGlyph,{color:Ce.color.accent}],children:"\u2191"})}),o?ut(m,{testID:"buoy-ask-buoy-stop",accessibilityRole:"button",accessibilityLabel:"Stop",onPress:t,style:({pressed:ee})=>[xe.button,xe.stop,ee&&xe.pressed],children:ut(s,{style:xe.stopGlyph})}):ut(m,{testID:"buoy-ask-buoy-send",accessibilityRole:"button",accessibilityLabel:"Send",disabled:!q,onPress:j,style:({pressed:ee})=>[xe.button,q?xe.sendOn:xe.sendOff,ee&&q&&xe.pressed],children:ut(l,{style:[xe.sendGlyph,{color:q?Ce.color.onAccent:Ce.color.textTertiary}],children:"\u2191"})})]})}var xe=w.create({wrap:{flexDirection:"row",alignItems:"flex-end",gap:8,paddingHorizontal:Ce.gutter,paddingTop:10,paddingBottom:6,borderTopWidth:w.hairlineWidth,borderTopColor:Ce.color.border,backgroundColor:Ce.color.bg},field:{flex:1,minHeight:Xr,justifyContent:"center",borderRadius:20,borderWidth:w.hairlineWidth,borderColor:Ce.color.border,backgroundColor:Ce.color.surfaceElevated},fieldDisabled:{opacity:.6},input:{maxHeight:Ns,paddingHorizontal:js,paddingTop:Zr,paddingBottom:Zr,color:Ce.color.text,fontSize:Ce.font.row},inputEmpty:{height:Xr},button:{width:40,height:40,borderRadius:20,alignItems:"center",justifyContent:"center"},sendGlyph:{fontSize:20,fontWeight:"700",lineHeight:22},sendOn:{backgroundColor:Ce.color.accent},sendOff:{backgroundColor:Ce.color.fill},stop:{backgroundColor:Ce.color.fillTertiary},queue:{backgroundColor:"transparent",borderWidth:w.hairlineWidth,borderColor:Ce.color.accentBorderStrong},stopGlyph:{width:12,height:12,borderRadius:2,backgroundColor:Ce.color.text},pressed:{opacity:.7}});import{useEffect as Ms,useRef as tn}from"react";import{jsx as qs}from"react/jsx-runtime";function Fs({children:e}){let t=tn(null),o=tn(new ce.Value(0)).current;return Ms(()=>{if(we.OS!=="ios")return;let r=(h,u)=>{ce.timing(o,{toValue:h,duration:u.duration||250,easing:$t.bezier(.17,.59,.4,.77),useNativeDriver:false}).start()},n=h=>{let u=t.current;u&&u.measureInWindow((g,f,S,j)=>{let q=f+j-h.endCoordinates.screenY;r(Math.max(0,q),h)})},i=h=>r(0,h),a=[fo.addListener("keyboardWillChangeFrame",n),fo.addListener("keyboardWillHide",i)];return()=>a.forEach(h=>h.remove())},[o]),qs(ce.View,{ref:t,style:[_s.flex,{paddingBottom:o}],children:e})}var _s=w.create({flex:{flex:1}});import{useEffect as on,useState as rn}from"react";import{Check as Us,Copy as Ks,FileText as Gs,ModalHeader as lo,night as Ge,Otto as Js,Plus as Qs,SettingsSolid as Ys,realNow as To}from"@buoy-gg/shared-ui/web";import{toolTitle as Xs}from"@buoy-gg/agent-core/web";var Zs=e=>e.effect==="read"&&e.status==="ok";function ec(e){let t=[],o=[],r=()=>{if(o.length!==0){if(o.length===1)t.push({kind:"call",call:o[0]});else{let n=[...new Set(o.map(i=>Xs(i.toolId)))];t.push({kind:"reads",id:o.map(i=>i.id).join("+"),calls:o,label:`Looked at ${tc(n)}`,count:o.length})}o=[]}};for(let n of e){if(Zs(n)){o.push(n);continue}r(),t.push({kind:"call",call:n})}return r(),t}function tc(e){return e.length<=1?e[0]??"":e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function oc(e){let t=[];e.startedAt!==void 0&&e.endedAt!==void 0&&e.endedAt>=e.startedAt&&t.push(nn(e.endedAt-e.startedAt));let o=e.toolCalls.length;if(o>0){t.push(`${o} action${o===1?"":"s"}`);let r=u=>e.toolCalls.filter(g=>g.status===u).length,n=r("failed"),i=r("refused"),a=r("declined"),h=r("stopped");n&&t.push(`${n} failed`),i&&t.push(`${i} refused`),a&&t.push(`${a} declined`),h&&t.push(`${h} not run`)}return t.length?t.join(" \xB7 "):null}function nn(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let o=Math.floor(t/60),r=t%60;return o<60?`${o}m ${String(r).padStart(2,"0")}s`:`${Math.floor(o/60)}h ${String(o%60).padStart(2,"0")}m`}import{jsx as He,jsxs as ln}from"react/jsx-runtime";var rc=200,nc=()=>"";function an({configured:e,busy:t,failed:o=false,activeLabel:r,awaitingApproval:n=false,startedAt:i=null,stopping:a=false,readOnly:h=false,toolCount:u,hasMessages:g,onBack:f,onReset:S,getTranscript:j,onOpenSettings:q,onTicket:X}){let{copied:ee,copy:ke}=oo(j??nc),[Je,$e]=rn(false);on(()=>{t?r&&$e(true):$e(false)},[t,r]);let Qe=t&&!n&&i!==null,[Ye,bt]=rn(()=>To());on(()=>{if(!Qe)return;bt(To());let ct=setInterval(()=>bt(To()),1e3);return()=>clearInterval(ct)},[Qe]);let yt=Qe&&i!==null?nn(Ye-i):null,zt=e?o?"error":t?r||Je?"robot":"thinking":"idle":"confused",Ne=a?"Stopping":r??"Thinking",st=e?n?"Waiting for you":t?yt?`${Ne} \xB7 ${yt}`:`${Ne}\u2026`:h?`Read only${u>0?` \xB7 ${u} tool${u===1?"":"s"}`:""}`:u>0?`Ready \xB7 ${u} tool${u===1?"":"s"} available`:"Ready":"Not set up in this app";return ln(lo,{children:[f?He(lo.Navigation,{onBack:f}):null,He(s,{style:pt.otto,testID:"buoy-ask-buoy-otto",children:He(Js,{state:zt,pixelSize:2,tickMs:rc,water:false})}),He(lo.Content,{title:"Ask Buoy",subtitle:st,testID:"buoy-ask-buoy-title"}),ln(lo.Actions,{children:[X?He(Vt,{testID:"buoy-ask-buoy-ticket",accessibilityRole:"button",accessibilityLabel:"Summarize for a ticket",disabled:!g||t,onPress:X,style:[pt.actionBtn,(!g||t)&&pt.actionBtnDisabled],children:He(Gs,{size:14,color:g&&!t?Ge.color.textSecondary:Ge.color.textTertiary})}):null,j?He(Vt,{testID:"buoy-ask-buoy-copy-chat",accessibilityRole:"button",accessibilityLabel:ee?"Conversation copied":"Copy conversation",disabled:!g,onPress:ke,style:[pt.actionBtn,!g&&pt.actionBtnDisabled],children:ee?He(Us,{size:14,color:Ge.color.accent}):He(Ks,{size:14,color:g?Ge.color.textSecondary:Ge.color.textTertiary})}):null,q?He(Vt,{testID:"buoy-ask-buoy-settings",accessibilityRole:"button",accessibilityLabel:"Settings",onPress:q,style:pt.actionBtn,children:He(Ys,{size:14,color:Ge.color.textSecondary})}):null,He(Vt,{testID:"buoy-ask-buoy-reset",accessibilityRole:"button",accessibilityLabel:"New conversation",disabled:!g,onPress:S,style:[pt.actionBtn,!g&&pt.actionBtnDisabled],children:He(Qs,{size:14,color:g?Ge.color.textSecondary:Ge.color.textTertiary})})]})]})}var pt=w.create({otto:{marginRight:8,justifyContent:"center"},actionBtn:{width:32,height:32,borderRadius:8,backgroundColor:Ge.color.buttonSurface,borderWidth:1,borderColor:Ge.color.border,alignItems:"center",justifyContent:"center"},actionBtnDisabled:{opacity:.55}});import{useCallback as ic,useEffect as lc,useState as ac}from"react";import{AlertTriangle as sc,night as de,ToggleRow as Co}from"@buoy-gg/shared-ui/web";import{useSyncExternalStore as cc}from"react";import{definePersistedSetting as dc,devToolsStorageKeys as uc}from"@buoy-gg/shared-ui/web";var Io={showThinking:false,bypassApprovals:false,readOnly:false,hostedNoticeSeen:false},zo=dc(`${uc.base}_ask_buoy_settings`,Io,{sanitize:e=>({showThinking:e.showThinking===true,bypassApprovals:e.bypassApprovals===true,readOnly:e.readOnly===true,hostedNoticeSeen:e.hostedNoticeSeen===true})}),St=Io,Do=false,Ro=new Set;function sn(){for(let e of Ro)try{e()}catch{}}var ht={get:()=>St,subscribe(e){return Ro.add(e),Do||(Do=true,zo.load().then(t=>{St=t,sn()})),()=>Ro.delete(e)},set(e,t){St[e]!==t&&(St={...St,[e]:t},sn(),zo.save(St))},reset(){St=Io,Do=false,zo.clear()}};function Ht(){return cc(ht.subscribe,ht.get,ht.get)}import{idFactory as cn}from"@buoy-gg/agent-core/web";import{realNow as _t}from"@buoy-gg/shared-ui/web";var ao=cn("m"),dn=400;function pc(e){if(!(!e||Object.keys(e).length===0))try{let t=JSON.stringify(e);return t.length>dn?`${t.slice(0,dn)}\u2026`:t}catch{return}}var hc=cn("q"),H={messages:[],busy:false,stopping:false,pending:null,trusted:[],notice:null,configured:false,answers:{},awaitingBlockId:null,actionState:{},queued:[],draft:null,usage:{input:0,output:0,requests:0},credits:null,meta:{}},un=null,pn=null,$o=new Set,hn=null,Ao=null;function Q(e){H={...H,...e};for(let t of $o)try{t()}catch{}}var y={getState:()=>H,subscribe(e){return $o.add(e),()=>$o.delete(e)},setLedger(e){hn=e},getLedger(){return hn},holdSession(e,t){Ao={session:e,signature:t}},getHeldSession(){return Ao},setReporter(e){un=e},getReporter(){return un},setUsageReader(e){pn=e},getUsageReader(){return pn},setNotice(e){Q({notice:e})},setConfigured(e){e!==H.configured&&Q({configured:e})},setMeta(e){Object.keys(e).every(t=>H.meta[t]===e[t])||Q({meta:{...H.meta,...e}})},addUser(e){Q({messages:[...H.messages,{id:ao(),role:"user",text:e,toolCalls:[],blocks:[]}],busy:true})},beginTurn(){Q({busy:true})},enqueue(e){let t={id:hc(),text:e};return Q({queued:[...H.queued,t]}),t},removeQueued(e){H.queued.some(t=>t.id===e)&&Q({queued:H.queued.filter(t=>t.id!==e)})},shiftQueued(){let[e,...t]=H.queued;if(e)return Q({queued:t}),e},takeQueuedToDraft(e){let t=H.queued.find(o=>o.id===e);t&&Q({queued:H.queued.filter(o=>o.id!==e),draft:t.text})},requestStop(){!H.busy||H.stopping||Q({stopping:true})},clearDraft(){H.draft!==null&&Q({draft:null})},removeMessage(e){Q({messages:H.messages.filter(t=>t.id!==e)})},recordAnswer(e){Q({answers:{...H.answers,[e.blockId]:e},awaitingBlockId:H.awaitingBlockId===e.blockId?null:H.awaitingBlockId})},setActionState(e,t){let o={...H.actionState};t===null?delete o[e]:o[e]=t,Q({actionState:o})},startAssistant(){let e=ao();return Q({messages:[...H.messages,{id:e,role:"assistant",text:"",toolCalls:[],blocks:[],streaming:true,startedAt:_t()}]}),e},applyEvent(e,t){if(t.type==="history-trimmed"){let r=H.messages.findIndex(a=>a.id===e),n={id:ao(),role:"assistant",system:true,text:`Older messages were trimmed from the agent's memory (${t.droppedRounds} exchange${t.droppedRounds===1?"":"s"}).`+(t.droppedPinned?` ${t.droppedPinned===1?"One of them made a change that is":`${t.droppedPinned} of them made changes that are`} still applied \u2014 the changes bar still lists ${t.droppedPinned===1?"it":"them"}, but the agent no longer remembers making ${t.droppedPinned===1?"it":"them"}.`:" It may not recall setup from earlier in this chat \u2014 the changes bar still lists what is applied."),toolCalls:[],blocks:[],endedAt:_t()},i=[...H.messages];i.splice(r<0?i.length:r,0,n),Q({messages:i});return}let o=H.messages.map(r=>{if(r.id!==e)return r;switch(t.type){case"retrying":{let n=Math.max(1,Math.round(t.inMs/1e3));return{...r,waiting:t.reason==="throttled"?`Endpoint busy \u2014 retrying in ${n}s (${t.attempt} of ${t.maxAttempts})`:"Request too large \u2014 trimming older messages and retrying"}}case"text":return{...r,waiting:void 0,text:(r.breakBeforeNextText||t.breakBefore)&&r.text?`${r.text.trimEnd()}
|
|
7
|
+
`)}case"notice":return e.text;case"claim":return e.text;case"diff":case"chart":case"imageGrid":case"requestList":case"requestCard":case"logList":case"crash":case"screenElements":return`[${e.kind} card${"title"in e&&typeof e.title=="string"?`: ${e.title}`:""}]`;default:return null}}function ba(e){return e.map(Nr).filter(t=>!!t)}import{Fragment as ya,jsx as z,jsxs as ge}from"react/jsx-runtime";function Bo(e){if(e===void 0)return"\u2014";if(e===null)return"null";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{let t=JSON.stringify(e);return t.length>120?`${t.slice(0,117)}\u2026`:t}catch{return String(e)}}function ma({block:e}){let t=it(e.rows,Yt.tableRows),{visible:o}=t,r=e.columns.slice(0,4);return ge(W,{title:e.title,source:e.source,testID:`buoy-block-table-${e.id}`,children:[z(s,{style:$.tableHead,children:r.map((n,i)=>z(l,{style:[$.th,i===0&&$.firstCol],numberOfLines:1,children:n},n))}),o.map((n,i)=>z(s,{style:[$.tr,i>0&&D.rowDivider],children:r.map((a,g)=>{let u=n[g],h=typeof u=="string"?u:u?.text??"",f=typeof u=="string"?void 0:u?.tone;return z(l,{style:[$.td,g===0&&$.firstCol,g===0&&$.tdFirst,f&&{color:vt(f)}],numberOfLines:2,children:Lt(h,$.td)},g)})},i)),z(lt,{paged:t})]})}function ka({block:e}){let t=it(e.pairs,Yt.keyValuePairs),{visible:o}=t,[r,n]=Or(null);return ge(W,{title:e.title,source:e.source,testID:`buoy-block-keyvalue-${e.id}`,children:[o.map((i,a)=>{let g=typeof i.value=="object"&&i.value!==null,u=r===i.key;return ge(m,{onPress:g?()=>n(u?null:i.key):void 0,style:[$.kvRow,a>0&&D.rowDivider],children:[z(l,{style:$.kvKey,numberOfLines:1,children:i.key}),z(l,{style:[$.kvValue,u&&D.mono],numberOfLines:u?void 0:2,selectable:true,children:u?JSON.stringify(i.value,null,2):Bo(i.value)})]},i.key)}),z(lt,{paged:t})]})}function xa(e){let t=!!e.image;return{canExpand:t,rowRunsAction:!!e.action&&!t,actionIsOwnControl:!!e.action&&t}}function wa({block:e}){let t=oe(),o=it(e.items,Yt.listItems),{visible:r}=o,[n,i]=Or(null);return ge(W,{title:e.title,source:e.source,testID:`buoy-block-list-${e.id}`,children:[r.map((a,g)=>{let u=`${a.id??a.title}-${g}`,h=n===u,{canExpand:f,rowRunsAction:T,actionIsOwnControl:O}=xa(a),_=f||T?m:s,ee=f?{onPress:()=>i(h?null:u),accessibilityRole:"button",accessibilityState:{expanded:h},accessibilityLabel:`${a.title}, ${h?"hide":"show"} picture`,testID:`buoy-block-list-row-${u}`}:T?{onPress:()=>void t.runAction(a.action,e.id),accessibilityRole:"button"}:{};return ge(s,{style:g>0?D.rowDivider:void 0,children:[h&&a.image?z(m,{onPress:()=>i(null),accessibilityRole:"button",accessibilityLabel:`Hide ${a.title}`,testID:`buoy-block-list-hero-${u}`,style:$.listHero,children:z(wt,{testID:"buoy-internal-chat-image",source:{uri:a.image},style:$.listHeroImage,resizeMode:"contain",accessibilityLabel:a.title})}):null,ge(_,{...ee,style:D.row,children:[a.image&&!h?z(wt,{testID:"buoy-internal-chat-image",source:{uri:a.image},style:$.thumb,resizeMode:"contain",accessibilityLabel:a.title}):a.icon?z(Dr,{name:a.icon}):null,ge(s,{style:$.flex,children:[z(l,{style:[D.rowTitle,a.tone&&{color:vt(a.tone)}],numberOfLines:h?void 0:2,children:Lt(a.title,D.rowTitle)}),a.subtitle?z(l,{style:D.rowSub,numberOfLines:h?void 0:2,children:Lt(a.subtitle,D.rowSub)}):null]}),a.trailing?z(l,{style:[D.rowTrailing,a.tone&&{color:vt(a.tone)}],numberOfLines:1,children:a.trailing}):null,a.action?O?z(m,{onPress:()=>void t.runAction(a.action,e.id),accessibilityRole:"button",accessibilityLabel:a.action.label,hitSlop:8,children:z(l,{style:$.rowAction,children:a.action.label})}):z(l,{style:$.rowAction,children:a.action.label}):null]})]},u)}),z(lt,{paged:o})]})}function Vr(e){return e!==null&&typeof e=="object"}function va(e){let t=e.map(n=>n.path),o=t.slice(0,3).join(", "),r=t.length-3;return`${t.length===1?"1 field":`${t.length} fields`} \xB7 ${o}${r>0?`, +${r}`:""}`}function Sa({block:e}){let t=it(e.changes,Yt.keyValuePairs);return ge(W,{title:e.title??"What changed",source:e.source,testID:`buoy-block-diff-${e.id}`,collapsible:true,summary:va(e.changes),children:[t.visible.map((o,r)=>{let n=o.before===void 0&&o.after!==void 0,i=o.after===void 0&&o.before!==void 0;return ge(s,{style:[$.diffRow,r>0&&D.rowDivider],children:[z(l,{style:$.diffPath,numberOfLines:1,children:o.path}),Vr(o.before)||Vr(o.after)?z(s,{style:$.diffTree,children:z(ta,{oldValue:o.before,newValue:o.after,showUnchanged:false,scrollEnabled:false})}):ge(ya,{children:[n?null:ge(s,{style:$.diffLine,children:[z(l,{style:[$.diffMark,{color:B.color.danger}],children:"\u2212"}),z(l,{style:[$.diffValue,{color:B.color.danger}],numberOfLines:3,selectable:true,children:Bo(o.before)})]}),i?null:ge(s,{style:$.diffLine,children:[z(l,{style:[$.diffMark,{color:B.color.accent}],children:"+"}),z(l,{style:[$.diffValue,{color:B.color.accent}],numberOfLines:3,selectable:true,children:Bo(o.after)})]})]})]},`${o.path}-${r}`)}),z(lt,{paged:t})]})}function Ta({block:e}){let t=e.bars.slice(0,Yt.chartBars),o=e.max??Math.max(1,...t.map(r=>r.value));return z(W,{title:e.title,source:e.source,testID:`buoy-block-chart-${e.id}`,children:z(s,{style:$.chart,children:t.map((r,n)=>ge(s,{style:$.barRow,children:[z(l,{style:$.barLabel,numberOfLines:1,children:r.label}),z(s,{style:$.barTrack,children:z(s,{style:[$.bar,{width:`${Math.max(2,Math.round(r.value/o*100))}%`,backgroundColor:vt(r.tone??"accent")}]})}),ge(l,{style:$.barValue,numberOfLines:1,children:[r.value,r.unit?` ${r.unit}`:""]})]},`${r.label}-${n}`))})})}function Ca({block:e}){return z(W,{title:e.title,testID:`buoy-block-steps-${e.id}`,children:e.steps.map((t,o)=>ge(s,{style:[$.step,o>0&&D.rowDivider],children:[z(s,{style:[$.stepMark,t.state==="done"&&$.stepDone,t.state==="failed"&&$.stepFailed],children:t.state==="done"?z(Ql,{size:10,color:B.color.onAccent}):t.state==="failed"?z(Zl,{size:10,color:B.color.text}):z(l,{style:$.stepNum,children:o+1})}),z(l,{style:[D.rowTitle,t.state==="done"&&$.stepTextDone],children:t.text})]},o))})}function Ia(e){try{let t=JSON.parse(e);return t!==null&&typeof t=="object"?t:void 0}catch{return}}function za({block:e,value:t}){return z(W,{title:e.title,testID:`buoy-block-code-${e.id}`,children:z(s,{style:$.viewer,children:z(ea,{title:e.title??"Payload",data:t,initialExpanded:true,showTypeFilter:false,testIDPrefix:`buoy-block-code-${e.id}`})})})}function Da({block:e}){return z(W,{title:e.title,testID:`buoy-block-code-${e.id}`,children:z(l,{style:[D.mono,$.code],selectable:true,children:e.text})})}function Ra({block:e}){let t=Ia(e.text);return t===void 0?z(Da,{block:e}):z(za,{block:e,value:t})}function $a({block:e}){let t=e.tone==="danger"?B.color.danger:e.tone==="warning"?B.color.warning:B.color.info,o=e.tone==="info"?Xl:Yl;return ge(W,{tone:e.tone,testID:`buoy-block-notice-${e.id}`,children:[ge(s,{style:$.noticeRow,children:[z(o,{size:14,color:t}),z(l,{style:$.noticeText,children:e.text})]}),z(Ve,{actions:e.actions,blockId:e.id})]})}function Aa({block:e}){let{copied:t,copy:o}=uo(()=>Nr(e)??e.title);return ge(W,{title:e.title,source:e.source,testID:`buoy-block-finding-${e.id}`,tone:"warning",children:[e.evidence.map((r,n)=>ge(s,{style:[$.kvRow,n>0&&D.rowDivider],children:[z(l,{style:$.kvKey,numberOfLines:1,children:r.label}),z(l,{style:[$.kvValue,r.tone&&{color:vt(r.tone)}],selectable:true,children:r.value})]},`${r.label}-${n}`)),z(s,{style:$.findingFoot,children:z(m,{testID:`buoy-block-finding-copy-${e.id}`,accessibilityRole:"button",accessibilityLabel:t?"Copied":"Copy this finding",onPress:o,style:({pressed:r})=>[$.findingCopy,r&&{opacity:.7}],children:z(l,{style:[$.findingCopyText,t&&{color:B.color.accent}],children:t?"Copied":"Copy finding"})})}),z(Ve,{actions:e.actions,blockId:e.id})]})}var $=w.create({flex:{flex:1},tableHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,gap:8,backgroundColor:B.color.fill},th:{flex:1,color:B.color.textTertiary,fontSize:B.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},tr:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"center"},td:{flex:1,color:B.color.textSecondary,fontSize:B.font.caption,lineHeight:17},tdFirst:{color:B.color.text,fontWeight:"500"},firstCol:{flex:1.4},kvRow:{flexDirection:"row",gap:12,paddingHorizontal:12,paddingVertical:8,alignItems:"flex-start"},kvKey:{width:110,color:B.color.textSecondary,fontSize:B.font.caption,paddingTop:1},kvValue:{flex:1,color:B.color.text,fontSize:B.font.caption,lineHeight:17},findingFoot:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,borderTopWidth:w.hairlineWidth,borderTopColor:B.color.separator},findingCopy:{paddingHorizontal:10,paddingVertical:5,borderRadius:B.radius.badge,backgroundColor:B.color.fill},findingCopyText:{color:B.color.textSecondary,fontSize:B.font.micro,fontWeight:"600"},thumb:{width:40,height:40,borderRadius:8,backgroundColor:B.color.fill},listHero:{paddingHorizontal:12,paddingTop:12},listHeroImage:{width:"100%",height:240,borderRadius:B.radius.row,backgroundColor:B.color.fill},rowAction:{color:B.color.accent,fontSize:B.font.caption,fontWeight:"600"},diffRow:{paddingHorizontal:12,paddingVertical:8,gap:3},diffPath:{color:B.color.textSecondary,fontSize:B.font.micro,fontWeight:"600",letterSpacing:.3},diffLine:{flexDirection:"row",gap:8,alignItems:"flex-start"},diffMark:{fontFamily:we.OS==="web"?Lr:"Menlo",fontSize:12,width:10},diffValue:{flex:1,fontFamily:we.OS==="web"?Lr:"Menlo",fontSize:12,lineHeight:16},diffTree:{borderRadius:B.radius.row,overflow:"hidden"},chart:{paddingHorizontal:12,paddingVertical:10,gap:8},barRow:{flexDirection:"row",alignItems:"center",gap:8},barLabel:{width:96,color:B.color.textSecondary,fontSize:B.font.caption},barTrack:{flex:1,height:10,borderRadius:5,backgroundColor:B.color.fill,overflow:"hidden"},bar:{height:10,borderRadius:5},barValue:{width:72,textAlign:"right",color:B.color.text,fontSize:B.font.caption,fontWeight:"600"},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:B.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:B.color.accent},stepFailed:{backgroundColor:B.color.danger},stepNum:{color:B.color.text,fontSize:B.font.micro,fontWeight:"700"},stepTextDone:{color:B.color.textSecondary},viewer:{paddingHorizontal:4,paddingBottom:8},code:{paddingHorizontal:12,paddingVertical:10,lineHeight:17},noticeRow:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingTop:10,paddingBottom:4},noticeText:{flex:1,color:B.color.text,fontSize:B.font.caption,lineHeight:18}});import{useState as Ba}from"react";import{night as Me}from"@buoy-gg/shared-ui/web";import{CAPS as Mr}from"@buoy-gg/agent-core/web";import{jsx as Fe,jsxs as Lo}from"react/jsx-runtime";function La({block:e}){let[t,o]=Ba(null),{width:r}=yr(),n=e.images.slice(0,Mr.gridMax),i=n.length>Mr.gridImages,a=Math.min(150,Math.floor((r-2*Me.gutter-24-8)/2)),g=({img:u,i:h})=>Lo(m,{testID:`buoy-block-image-${h}`,accessibilityRole:"imagebutton",accessibilityLabel:u.alt,onPress:()=>o(t===h?null:h),style:[_e.tile,{width:a},i&&_e.tileCarousel],children:[Fe(wt,{testID:"buoy-internal-chat-image",source:{uri:u.url},style:[_e.image,{width:a,height:a}],resizeMode:"contain",accessibilityLabel:u.alt}),Fe(l,{style:_e.name,numberOfLines:1,children:u.alt}),u.caption?Fe(l,{style:_e.caption,numberOfLines:1,children:u.caption}):null]},`${u.url}-${h}`);return Lo(W,{title:e.title,source:e.source,testID:`buoy-block-imagegrid-${e.id}`,children:[t!==null&&n[t]?Lo(m,{onPress:()=>o(null),style:_e.hero,accessibilityRole:"button",accessibilityLabel:`Close ${n[t].alt}`,children:[Fe(wt,{testID:"buoy-internal-chat-image",source:{uri:n[t].url},style:_e.heroImage,resizeMode:"contain",accessibilityLabel:n[t].alt}),Fe(l,{style:_e.heroCaption,children:n[t].alt}),n[t].caption?Fe(l,{style:_e.caption,children:n[t].caption}):null]}):null,i?Fe(Je,{horizontal:true,showsHorizontalScrollIndicator:false,snapToInterval:a+8,decelerationRate:"fast",contentContainerStyle:_e.carousel,children:n.map((u,h)=>Fe(g,{img:u,i:h},h))}):Fe(s,{style:_e.grid,children:n.map((u,h)=>Fe(g,{img:u,i:h},h))}),Fe(_l,{shown:n.length,total:e.total})]})}var _e=w.create({grid:{flexDirection:"row",flexWrap:"wrap",gap:8,padding:12},carousel:{gap:8,paddingHorizontal:12,paddingVertical:12},tile:{gap:4},tileCarousel:{},image:{borderRadius:Me.radius.row,backgroundColor:Me.color.fill},name:{color:Me.color.text,fontSize:Me.font.micro,fontWeight:"600"},caption:{color:Me.color.textSecondary,fontSize:Me.font.micro},hero:{alignItems:"center",padding:12,gap:6,borderBottomWidth:w.hairlineWidth,borderBottomColor:Me.color.separator},heroImage:{width:"100%",height:240,borderRadius:Me.radius.row,backgroundColor:Me.color.fill},heroCaption:{color:Me.color.text,fontSize:Me.font.caption}});import{monoFont as Oa}from"@buoy-gg/shared-ui/web";import{useState as Ha}from"react";import{AlertTriangle as Pa,ChevronRight as Wa,Eye as jr,night as R,NightSegmented as Ea}from"@buoy-gg/shared-ui/web";import{CAPS as po}from"@buoy-gg/agent-core/web";import{jsx as P,jsxs as ae}from"react/jsx-runtime";function qr(e){return e===void 0?R.color.textTertiary:e>=500?R.color.danger:e>=400?R.color.warning:e>=300?R.color.info:R.color.accent}function Fr(e){try{let t=new URL(e);return t.pathname+(t.search?"?\u2026":"")}catch{return e}}function _r({status:e}){return P(s,{style:[D.pill,{backgroundColor:`${qr(e)}22`}],children:P(l,{style:[D.pillText,{color:qr(e)}],children:e??"\u2026"})})}function Na({block:e}){let t=oe(),o=t.supports?.openTool!==false,r=it(e.requests,po.listItems),{visible:n}=r;return ae(W,{title:e.title??"Network requests",source:e.source,testID:`buoy-block-requests-${e.id}`,children:[n.map((i,a)=>ae(m,{disabled:!o,onPress:()=>void t.runAction({label:"Open in Network",openTool:{toolId:"network",select:i.id}},e.id),style:[D.row,a>0&&D.rowDivider],accessibilityRole:o?"button":void 0,children:[P(l,{style:G.method,children:i.method}),P(l,{style:D.rowTitle,numberOfLines:1,children:Fr(i.url)}),i.mocked?P(l,{style:G.mockedChip,children:"MOCKED"}):null,i.durationMs!==void 0?ae(l,{style:D.rowTrailing,children:[i.durationMs," ms"]}):null,P(_r,{status:i.status}),o?P(Wa,{size:12,color:R.color.textTertiary}):null]},`${i.id}-${a}`)),P(lt,{paged:r})]})}var Va=[{key:"response",label:"Response"},{key:"request",label:"Request"}];function Ma({block:e}){let[t,o]=Ha("response"),r=t==="response"?e.responseBody:e.requestBody,n=r===void 0?"(none)":typeof r=="string"?r:JSON.stringify(r,null,2),i=oe();return ae(W,{source:e.source,testID:`buoy-block-request-${e.id}`,children:[ae(s,{style:[D.row,G.reqHead],children:[P(l,{style:G.method,children:e.request.method}),P(l,{style:D.rowTitle,numberOfLines:2,children:Fr(e.request.url)}),e.request.mocked?P(l,{style:G.mockedChip,children:"MOCKED"}):null,P(_r,{status:e.request.status})]}),P(s,{style:G.tabs,children:P(Ea,{tabs:Va,activeKey:t,onChange:a=>o(a),size:"sm"})}),P(l,{style:[D.mono,G.body],numberOfLines:14,selectable:true,children:n.length>1600?`${n.slice(0,1600)}
|
|
8
|
+
\u2026`:n}),P(Ve,{blockId:e.id,actions:[{label:"Open in Network",openTool:{toolId:"network",select:e.request.id}}]}),(i.supports?.openTool===false,null)]})}function ja({block:e}){let t=oe().rules?.[e.rule.id],o=t?.deleted===true,r={...e.rule,enabled:o?false:t?.enabled??e.rule.enabled},n=r.kind==="fail"?"fails (no network)":r.kind==="delay"?`delayed ${r.delayMs??0} ms`:`returns ${r.status??200}`;return ae(W,{title:r.name??"Network override",source:e.source,testID:`buoy-block-rule-${e.id}`,tone:r.enabled?"warning":void 0,children:[ae(s,{style:G.ruleBody,children:[ae(l,{style:G.ruleLine,children:[ae(l,{style:G.ruleKey,children:[r.methods?.length?r.methods.join("/"):"ANY"," "]}),P(l,{style:D.mono,children:r.urlPattern})]}),ae(l,{style:G.ruleLine,children:[P(l,{style:G.ruleKey,children:"\u2192 "}),n,r.times?` \xB7 ${r.times===1?"once":`${r.times} times`}`:" \xB7 every time",r.hits!==void 0?` \xB7 ${r.hits} hit${r.hits===1?"":"s"}`:""]}),P(s,{style:[D.pill,r.enabled?G.on:G.off],children:P(l,{style:[D.pillText,{color:r.enabled?R.color.onAccent:R.color.textSecondary}],children:o?"DELETED":r.enabled?"ON":"OFF"})})]}),o?null:P(Ve,{blockId:e.id,actions:[r.enabled?{label:"Turn off",dispatch:{toolId:"network",action:"setOverrideRuleEnabled",params:{id:r.id,enabled:false}}}:{label:"Turn on",primary:true,dispatch:{toolId:"network",action:"setOverrideRuleEnabled",params:{id:r.id,enabled:true}}},{label:"Delete",dispatch:{toolId:"network",action:"deleteOverrideRule",params:{id:r.id}}}]})]})}function qa({block:e}){let t=oe(),o=it(e.elements,po.chips),{visible:r}=o;return ae(W,{title:e.title??"On screen right now",source:e.source,testID:`buoy-block-screen-${e.id}`,children:[r.map((n,i)=>ae(m,{onPress:()=>void t.runAction({label:"Highlight",dispatch:{toolId:"highlight-updates",action:"setSpotlight",params:{nativeTag:n.nativeTag}}},e.id),disabled:t.supports?.dispatch===false,style:[D.row,i>0&&D.rowDivider],accessibilityRole:"button",children:[P(jr,{size:12,color:R.color.textTertiary}),P(l,{style:D.rowTitle,numberOfLines:1,children:n.label??n.testID??n.name}),P(l,{style:D.rowTrailing,numberOfLines:1,children:n.name})]},`${n.nativeTag}-${i}`)),P(lt,{paged:o})]})}function Fa({block:e}){let t=oe(),o=it(e.routes,po.chips),r=o.visible;return ae(W,{title:e.current?`Routes \xB7 you're on ${e.current}`:"Routes",source:e.source,testID:`buoy-block-routes-${e.id}`,children:[P(s,{style:G.chips,children:r.map((n,i)=>P(m,{disabled:t.supports?.dispatch===false,onPress:()=>n.dynamic?t.answer({blockId:e.id,kind:"input",value:`Open ${n.path} \u2014 which id?`}):void t.runAction({label:`Open ${n.path}`,dispatch:{toolId:"route-events",action:"navigate",params:{path:n.path}}},e.id),style:[G.chip,n.path===e.current&&G.chipCurrent],accessibilityRole:"button",children:P(l,{style:[G.chipText,n.dynamic&&G.chipDynamic],children:n.path})},`${n.path}-${i}`))}),P(lt,{paged:o})]})}var Ur={error:R.color.danger,warn:R.color.warning,warning:R.color.warning,info:R.color.info};function _a({block:e}){let t=it(e.entries,po.listItems),{visible:o}=t;return ae(W,{title:"Console",source:e.source,testID:`buoy-block-logs-${e.id}`,children:[o.map((r,n)=>ae(s,{style:[D.row,n>0&&D.rowDivider,G.logRow],children:[P(s,{style:[D.pill,{backgroundColor:`${Ur[r.level]??R.color.textTertiary}22`}],children:P(l,{style:[D.pillText,{color:Ur[r.level]??R.color.textSecondary}],children:r.level.toUpperCase()})}),P(l,{style:[D.rowTitle,D.mono],numberOfLines:3,children:r.message}),r.count>1?ae(l,{style:D.rowTrailing,children:["\xD7",r.count]}):null]},`${r.level}-${r.message}-${n}`)),P(lt,{paged:t})]})}function Ua({block:e}){return ae(W,{tone:"danger",testID:`buoy-block-crash-${e.id}`,children:[ae(s,{style:G.crashHead,children:[P(Pa,{size:14,color:R.color.danger}),ae(l,{style:G.crashTitle,children:["The app crashed",e.route?` on ${e.route}`:""]})]}),P(l,{style:[D.mono,G.crashMsg],numberOfLines:4,selectable:true,children:e.message}),e.suspect?ae(l,{style:G.suspect,children:["Most likely cause: ",e.suspect.label]}):null,P(Ve,{blockId:e.id,actions:[...e.suspect?.action?[{...e.suspect.action,primary:true}]:[],...e.actions??[]].slice(0,2)})]})}function Ka({block:e}){let t=oe(),o=t.supports?.minimize!==false;return ae(m,{testID:`buoy-block-peek-${e.id}`,disabled:!o,onPress:()=>void t.runAction({label:"Look",minimize:true},e.id),style:({pressed:r})=>[G.peek,r&&{opacity:.7}],accessibilityRole:"button",accessibilityLabel:`${e.label}. Look at the app`,children:[P(l,{style:G.peekText,children:e.label}),o?ae(s,{style:G.peekLook,children:[P(jr,{size:12,color:R.color.accent}),P(l,{style:G.peekLookText,children:"Look"})]}):null]})}var G=w.create({method:{color:R.color.textSecondary,fontSize:R.font.micro,fontWeight:"700",letterSpacing:.4,width:44},mockedChip:{color:R.color.warning,backgroundColor:R.color.warningSoft,fontSize:9,fontWeight:"700",letterSpacing:.6,paddingHorizontal:5,paddingVertical:1,borderRadius:R.radius.badge,overflow:"hidden"},reqHead:{paddingTop:12},tabs:{paddingHorizontal:12,paddingTop:4,paddingBottom:8},tab:{paddingHorizontal:10,paddingVertical:5,borderRadius:R.radius.badge,backgroundColor:R.color.fill},tabOn:{backgroundColor:R.color.accentSoft},tabText:{color:R.color.textSecondary,fontSize:R.font.micro,fontWeight:"600"},tabTextOn:{color:R.color.accent},body:{paddingHorizontal:12,paddingBottom:4,lineHeight:16,color:R.color.textSecondary},ruleBody:{paddingHorizontal:12,paddingTop:4,paddingBottom:4,gap:4},ruleLine:{color:R.color.text,fontSize:R.font.caption,lineHeight:18},ruleKey:{color:R.color.textSecondary,fontWeight:"700"},on:{alignSelf:"flex-start",backgroundColor:R.color.accent,marginTop:4},off:{alignSelf:"flex-start",backgroundColor:R.color.fillTertiary,marginTop:4},chips:{flexDirection:"row",flexWrap:"wrap",gap:6,padding:12},chip:{paddingHorizontal:10,paddingVertical:6,borderRadius:R.radius.chip,backgroundColor:R.color.fill,borderWidth:w.hairlineWidth,borderColor:R.color.border},chipCurrent:{backgroundColor:R.color.accentSoft,borderColor:R.color.accentBorderStrong},chipText:{color:R.color.text,fontSize:R.font.caption,fontFamily:we.OS==="web"?Oa:"Menlo"},chipDynamic:{color:R.color.textSecondary},logRow:{alignItems:"flex-start"},crashHead:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingTop:12},crashTitle:{color:R.color.danger,fontSize:R.font.row,fontWeight:"600"},crashMsg:{paddingHorizontal:12,paddingTop:6,color:R.color.text},suspect:{color:R.color.textSecondary,fontSize:R.font.caption,paddingHorizontal:12,paddingTop:6},peek:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:10,paddingLeft:12,paddingRight:10,paddingVertical:7,borderRadius:R.radius.chip,backgroundColor:R.color.fill},peekText:{color:R.color.textSecondary,fontSize:R.font.caption},peekLook:{flexDirection:"row",alignItems:"center",gap:4},peekLookText:{color:R.color.accent,fontSize:R.font.caption,fontWeight:"600"}});import{monoFont as Oo}from"@buoy-gg/shared-ui/web";import{useEffect as Ja,useRef as Kr,useState as Ye}from"react";import{AlertTriangle as Ga,Check as Jr,ChevronDown as Gr,ChevronRight as Yr,night as d,NightSegmented as Ya,RefreshCw as Qa,Search as Xa,X as Za}from"@buoy-gg/shared-ui/web";import{Fragment as ho,jsx as p,jsxs as v}from"react/jsx-runtime";var Qr=e=>typeof e=="string"?e:e===void 0?"\u2014":JSON.stringify(e);function es({block:e}){let t=oe();return p(s,{style:c.chips,testID:`buoy-block-suggestions-${e.id}`,children:e.chips.slice(0,4).map(o=>p(m,{disabled:!!t.busy,onPress:()=>void t.runAction({label:o.label,send:o.send??o.label},e.id),style:({pressed:r})=>[c.chip,r&&c.pressed],accessibilityRole:"button",children:p(l,{style:c.chipText,children:o.label})},o.label))})}function ts({block:e}){let t=oe(),o=t.answered[e.id],r=!!o,[n,i]=Ye([]),a=o?.kind==="multi"?o.optionIds:n,g=h=>i(f=>f.includes(h)?f.filter(T=>T!==h):[...f,h]),u=n.length>=(e.min??1)&&(!e.max||n.length<=e.max);return v(W,{testID:`buoy-block-multi-${e.id}`,tone:r?void 0:"info",children:[p(l,{style:c.question,children:e.question}),p(s,{style:c.optionsBox,children:e.options.map((h,f)=>{let T=a.includes(h.id);return v(m,{disabled:r,onPress:()=>g(h.id),style:[c.option,f>0&&D.rowDivider,r&&!T&&c.dim],accessibilityRole:"checkbox",accessibilityState:{checked:T},children:[p(s,{style:[c.checkbox,T&&c.checkboxOn],children:T?p(Jr,{size:11,color:d.color.onAccent}):null}),v(s,{style:c.flex,children:[p(l,{style:c.optionLabel,children:h.label}),h.detail?p(l,{style:c.optionDetail,children:h.detail}):null]})]},h.id)})}),r?null:p(s,{style:c.rowEnd,children:p(m,{testID:"buoy-block-multi-submit",disabled:!u,onPress:()=>t.answer({blockId:e.id,kind:"multi",optionIds:n,labels:e.options.filter(h=>n.includes(h.id)).map(h=>h.label)}),style:[c.button,c.buttonPrimary,!u&&c.disabled],children:p(l,{style:c.buttonTextPrimary,children:e.submitLabel??`Use ${n.length||""}`.trim()})})})]})}var os=8;function rs({block:e}){let t=oe(),o=t.answered[e.id],[r,n]=Ye(""),[i,a]=Ye(false),g=o?.kind==="select"?o.label:null,u=e.options.filter(f=>!r||f.label.toLowerCase().includes(r.toLowerCase())).slice(0,8),h=e.searchable!==false&&e.options.length>=os;return v(W,{testID:`buoy-block-select-${e.id}`,tone:o?void 0:"info",children:[p(l,{style:c.question,children:e.label}),g?p(l,{style:c.decided,children:g}):v(s,{style:c.selectBox,children:[v(m,{onPress:()=>a(f=>!f),style:c.selectField,accessibilityRole:"button",children:[p(l,{style:c.selectPlaceholder,children:i?"Choose\u2026":`${e.options.length} options`}),p(Gr,{size:14,color:d.color.textSecondary})]}),i&&v(ho,{children:[h&&v(s,{style:c.search,children:[p(Xa,{size:12,color:d.color.textSecondary}),p(rt,{style:c.searchInput,value:r,onChangeText:n,placeholder:"Search",placeholderTextColor:d.color.placeholder,autoCapitalize:"none",autoCorrect:false})]}),u.map((f,T)=>v(m,{onPress:()=>t.answer({blockId:e.id,kind:"select",optionId:f.id,label:f.label}),style:[c.option,T>0&&D.rowDivider],accessibilityRole:"button",children:[v(s,{style:c.flex,children:[p(l,{style:c.optionLabel,children:f.label}),f.detail?p(l,{style:c.optionDetail,children:f.detail}):null]}),p(Yr,{size:12,color:d.color.textTertiary})]},f.id)),e.options.length>u.length?v(l,{style:c.hint,children:[e.options.length-u.length," more \u2014 keep typing"]}):null]})]})]})}function Xr({min:e,max:t,step:o=1,value:r,unit:n,onChange:i,disabled:a}){let g=Kr(0),u=t>e?(r-e)/(t-e)*100:0,h=_=>Math.min(t,Math.max(e,+(Math.round((_-e)/o)*o+e).toFixed(6))),f=_=>!a&&i(h(r+_*o)),T=_=>{if(a||g.current<=0)return;let ee=Math.min(1,Math.max(0,_.nativeEvent.locationX/g.current));i(h(e+ee*(t-e)))},O=_=>{g.current=_.nativeEvent.layout.width};return v(s,{style:c.sliderRow,children:[p(m,{disabled:a,onPress:()=>f(-1),style:c.stepBtn,accessibilityRole:"button",accessibilityLabel:"Decrease",children:p(l,{style:c.stepText,children:"\u2212"})}),p(m,{style:c.trackHit,onLayout:O,onPress:T,disabled:a,accessibilityRole:"adjustable",accessibilityValue:{min:e,max:t,now:r},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:_=>f(_.nativeEvent.actionName==="increment"?1:-1),children:v(s,{style:c.track,pointerEvents:"none",children:[p(s,{style:[c.fill,{width:`${u}%`}]}),p(s,{style:[c.thumb,{left:`${u}%`}]})]})}),p(m,{disabled:a,onPress:()=>f(1),style:c.stepBtn,accessibilityRole:"button",accessibilityLabel:"Increase",children:p(l,{style:c.stepText,children:"+"})}),v(l,{style:c.sliderValue,children:[r,n?` ${n}`:""]})]})}function ns({block:e}){let t=oe(),o=t.answered[e.id],[r,n]=Ye(e.value??e.min);return v(W,{testID:`buoy-block-slider-${e.id}`,tone:o?void 0:"info",children:[p(l,{style:c.question,children:e.label}),p(s,{style:c.pad,children:p(Xr,{min:e.min,max:e.max,step:e.step,value:o?.kind==="slider"?o.value:r,unit:e.unit,onChange:n,disabled:!!o})}),o?null:p(s,{style:c.rowEnd,children:p(m,{onPress:()=>t.answer({blockId:e.id,kind:"slider",value:r,unit:e.unit}),style:[c.button,c.buttonPrimary],children:v(l,{style:c.buttonTextPrimary,children:["Use ",r,e.unit?` ${e.unit}`:""]})})})]})}function is({block:e}){let t=oe(),o=t.answered[e.id],[r,n]=Ye(""),i=e.presets??[{label:"Now",value:new Date().toISOString()},{label:"Tomorrow",value:new Date(Date.now()+864e5).toISOString()},{label:"+7 days",value:new Date(Date.now()+7*864e5).toISOString()},{label:"+30 days",value:new Date(Date.now()+30*864e5).toISOString()}];return v(W,{testID:`buoy-block-datetime-${e.id}`,tone:o?void 0:"info",children:[p(l,{style:c.question,children:e.label}),o?p(l,{style:c.decided,children:o.kind==="dateTime"?o.label??o.value:"(skipped)"}):v(ho,{children:[p(s,{style:[c.chips,c.pad],children:i.map(a=>p(m,{onPress:()=>t.answer({blockId:e.id,kind:"dateTime",value:a.value,label:a.label}),style:c.chip,children:p(l,{style:c.chipText,children:a.label})},a.label))}),v(s,{style:[c.inputRow,c.pad],children:[p(rt,{style:c.input,value:r,onChangeText:n,placeholder:e.mode==="time"?"14:30":"2026-09-15",placeholderTextColor:d.color.placeholder,keyboardType:"numbers-and-punctuation"}),p(m,{disabled:!r.trim(),onPress:()=>t.answer({blockId:e.id,kind:"dateTime",value:r.trim()}),style:[c.button,c.buttonPrimary,!r.trim()&&c.disabled],children:p(l,{style:c.buttonTextPrimary,children:"Use"})})]})]})]})}function Zr({f:e,value:t,onChange:o,disabled:r}){return e.type==="toggle"?v(s,{style:c.fieldRow,children:[p(l,{style:c.fieldLabel,children:e.label}),p(vr,{value:!!t,onValueChange:o,disabled:r,trackColor:{true:d.color.accent,false:d.color.fillTertiary},thumbColor:d.color.knob})]}):e.type==="select"?v(s,{style:c.fieldCol,children:[p(l,{style:c.fieldLabel,children:e.label}),p(s,{style:c.chips,children:e.options.map(n=>p(m,{disabled:r,onPress:()=>o(n.id),style:[c.chip,t===n.id&&c.chipOn],children:p(l,{style:[c.chipText,t===n.id&&c.chipTextOn],children:n.label})},n.id))})]}):e.type==="slider"?v(s,{style:c.fieldCol,children:[p(l,{style:c.fieldLabel,children:e.label}),p(Xr,{min:e.min,max:e.max,step:e.step,unit:e.unit,value:typeof t=="number"?t:e.min,onChange:o,disabled:r})]}):v(s,{style:c.fieldRow,children:[p(l,{style:c.fieldLabel,children:e.label}),p(rt,{style:c.fieldInput,value:t==null?"":String(t),onChangeText:o,editable:!r,placeholder:e.placeholder??"",placeholderTextColor:d.color.placeholder,keyboardType:e.type==="number"?"numeric":"ascii-capable",secureTextEntry:e.type==="secret",autoCapitalize:"none",autoCorrect:false})]})}function en(e){let[t,o]=Ye(()=>Object.fromEntries(e.map(r=>[r.key,r.value])));return{values:t,set:(r,n)=>o(i=>({...i,[r]:n}))}}function ls({block:e}){let t=oe(),o=t.answered[e.id],{values:r,set:n}=en(e.fields);return v(W,{title:e.title,testID:`buoy-block-form-${e.id}`,tone:o?void 0:"info",children:[p(s,{style:c.pad,children:e.fields.map(i=>p(Zr,{f:i,value:r[i.key],onChange:a=>n(i.key,a),disabled:!!o},i.key))}),o?p(l,{style:c.decided,children:"Sent"}):p(s,{style:c.rowEnd,children:p(m,{onPress:()=>t.answer({blockId:e.id,kind:"form",values:r}),style:[c.button,c.buttonPrimary],children:p(l,{style:c.buttonTextPrimary,children:e.submitLabel??"Send"})})})]})}function as({block:e}){let t=oe(),o=t.answered[e.id],{values:r,set:n}=en(e.fields),i=o?.kind==="proposal"?o.approved:null;return v(W,{testID:`buoy-block-proposal-${e.id}`,tone:o?void 0:"warning",children:[p(l,{style:c.confirmTitle,children:e.title}),p(l,{style:c.confirmChange,children:e.change}),p(s,{style:c.pad,children:e.fields.map(a=>p(Zr,{f:a,value:r[a.key],onChange:g=>n(a.key,g),disabled:!!o},a.key))}),e.consequence?p(l,{style:c.consequence,children:e.consequence}):null,p(s,{style:c.actionsRow,children:o?p(l,{style:c.decided,children:i?"\u2713 Applied with these values":"\u2715 Not applied"}):v(ho,{children:[p(m,{onPress:()=>t.answer({blockId:e.id,kind:"proposal",approved:true,values:r}),style:[c.button,c.buttonPrimary],children:p(l,{style:c.buttonTextPrimary,children:e.approveLabel??"Apply"})}),p(m,{onPress:()=>t.answer({blockId:e.id,kind:"proposal",approved:false}),style:[c.button,c.buttonPlate],children:p(l,{style:c.buttonTextPlate,children:"Not now"})})]})})]})}function ss({block:e}){let t=oe(),[o,r]=Ye(null),n=t.actionState?.[`${e.id}:${e.verify?.label??"Verify"}`],i=e.verified||n==="done";return v(s,{style:c.claim,testID:`buoy-block-claim-${e.id}`,children:[v(l,{style:c.claimText,children:[e.text,e.sources.map((a,g)=>v(l,{onPress:()=>r(o===g?null:g),style:c.cite,children:[" [",g+1,"]"]},g)),i?p(l,{style:c.verified,children:" \u2713 verified"}):null]}),o!==null&&e.sources[o]?v(s,{style:c.citeBox,children:[v(l,{style:c.citeLabel,children:["[",o+1,"] ",e.sources[o].label]}),e.sources[o].detail?p(l,{style:c.citeDetail,children:e.sources[o].detail}):null]}):null,e.verify&&!i?v(m,{onPress:()=>void t.runAction(e.verify,e.id),style:c.verifyBtn,accessibilityRole:"button",children:[p(Qa,{size:11,color:d.color.accent}),p(l,{style:c.verifyText,children:n==="running"?"Checking\u2026":e.verify.label})]}):null]})}function cs({block:e}){let[t,o]=Ye(!!e.open);return v(W,{testID:`buoy-block-details-${e.id}`,children:[v(m,{onPress:()=>o(r=>!r),style:D.row,accessibilityRole:"button",accessibilityState:{expanded:t},children:[p(l,{style:D.rowTitle,children:e.summary}),t?p(Gr,{size:12,color:d.color.textTertiary}):p(Yr,{size:12,color:d.color.textTertiary})]}),t?p(l,{style:c.detailsBody,selectable:true,children:e.body}):null]})}function ds({block:e,renderNested:t}){let[o,r]=Ye(0),n=e.tabs.map((a,g)=>({key:String(g),label:a.label})),i=e.tabs[o];return v(s,{style:c.tabsWrap,testID:`buoy-block-tabs-${e.id}`,children:[p(Ya,{tabs:n,activeKey:String(o),onChange:a=>r(Number(a)),size:"sm"}),i&&t?t(i.block):null]})}var us=10;function ps({block:e}){let t=it(e.events,us);return v(W,{title:e.title??"What happened",source:e.source,testID:`buoy-block-timeline-${e.id}`,children:[t.visible.map((o,r)=>v(s,{style:c.tlRow,children:[p(l,{style:c.tlAt,children:o.at}),v(s,{style:c.tlLine,children:[p(s,{style:[c.tlDot,{backgroundColor:vt(o.tone??"muted")}]}),r<t.visible.length-1?p(s,{style:c.tlStem}):null]}),v(s,{style:c.flex,children:[p(l,{style:c.tlSource,children:o.source.toUpperCase()}),p(l,{style:D.rowTitle,numberOfLines:2,children:o.label})]})]},r)),p(lt,{paged:t})]})}function hs({block:e}){let t=e.series.slice(-60),o=Math.max(1,...t),r=Math.min(...t,0),n=44;return v(W,{title:e.title,source:e.source,testID:`buoy-block-sparkline-${e.id}`,children:[v(s,{style:c.sparkHead,children:[v(l,{style:c.sparkCurrent,children:[e.current??t[t.length-1],e.unit?v(l,{style:c.sparkUnit,children:[" ",e.unit]}):null]}),e.live?p(tn,{}):null]}),p(s,{style:[c.spark,{height:n}],children:t.map((i,a)=>p(s,{style:[c.sparkBar,{height:Math.max(2,(i-r)/(o-r||1)*n),backgroundColor:a===t.length-1?d.color.accent:d.color.accentBorderStrong}]},a))}),e.label?p(l,{style:c.hint,children:e.label}):null]})}function tn(){let e=Kr(new ue.Value(1)).current;return Ja(()=>{let t=ue.loop(ue.sequence([ue.timing(e,{toValue:.3,duration:700,useNativeDriver:true}),ue.timing(e,{toValue:1,duration:700,useNativeDriver:true})]));return t.start(),()=>t.stop()},[e]),v(s,{style:c.live,children:[p(ue.View,{style:[c.liveDot,{opacity:e}]}),p(l,{style:c.liveText,children:"LIVE"})]})}function gs({block:e}){let t=[...new Set([...e.left.pairs.map(n=>n.key),...e.right.pairs.map(n=>n.key)])],o=Object.fromEntries(e.left.pairs.map(n=>[n.key,n.value])),r=Object.fromEntries(e.right.pairs.map(n=>[n.key,n.value]));return v(W,{title:e.title,source:e.source,testID:`buoy-block-compare-${e.id}`,children:[v(s,{style:c.cmpHead,children:[p(l,{style:c.cmpKey}),p(l,{style:c.cmpCol,children:e.left.title}),p(l,{style:c.cmpCol,children:e.right.title})]}),t.map((n,i)=>{let a=JSON.stringify(o[n])!==JSON.stringify(r[n]);return v(s,{style:[c.cmpRow,i>0&&D.rowDivider,a&&c.cmpDiff],children:[p(l,{style:c.cmpKey,numberOfLines:1,children:n}),p(l,{style:[c.cmpVal,a&&{color:d.color.danger}],numberOfLines:2,children:Qr(o[n])}),p(l,{style:[c.cmpVal,a&&{color:d.color.accent}],numberOfLines:2,children:Qr(r[n])})]},n)})]})}function on({c:e,id:t}){return v(ho,{children:[e.image?p(wt,{testID:"buoy-internal-chat-image",source:{uri:e.image},style:c.cardImage,resizeMode:"contain",accessibilityLabel:e.title}):null,v(s,{style:c.cardText,children:[p(l,{style:c.cardTitle,numberOfLines:2,children:e.title}),e.subtitle?p(l,{style:D.rowSub,numberOfLines:2,children:e.subtitle}):null,e.facts?.slice(0,4).map(o=>v(s,{style:c.fact,children:[p(l,{style:c.factLabel,children:o.label}),p(l,{style:[c.factValue,o.tone&&{color:vt(o.tone)}],children:o.value})]},o.label))]}),p(Ve,{actions:e.actions,blockId:t})]})}function fs({block:e}){return p(W,{source:e.source,testID:`buoy-block-card-${e.id}`,children:p(on,{c:e,id:e.id})})}function bs({block:e}){return v(s,{testID:`buoy-block-cardcarousel-${e.id}`,children:[e.title?p(l,{style:c.carouselTitle,children:e.title}):null,p(Je,{horizontal:true,showsHorizontalScrollIndicator:false,snapToInterval:232,decelerationRate:"fast",contentContainerStyle:c.carousel,children:e.cards.slice(0,8).map((t,o)=>p(s,{style:c.carouselCard,children:p(on,{c:t,id:`${e.id}-${o}`})},`${t.title}-${o}`))})]})}function ys({block:e}){let[t,o]=Ye(false);return v(W,{title:e.route?`Screen \xB7 ${e.route}`:"Screen",source:e.source,testID:`buoy-block-screenshot-${e.id}`,children:[p(m,{onPress:()=>o(r=>!r),accessibilityRole:"imagebutton",accessibilityLabel:e.caption??"Screenshot",children:p(wt,{testID:"buoy-internal-chat-image",source:{uri:e.url},style:[c.shot,t&&c.shotBig],resizeMode:"contain"})}),e.caption?p(l,{style:c.hint,children:e.caption}):null]})}function ms({block:e}){let t=e.steps.filter(o=>o.state==="done").length;return v(W,{title:e.title,testID:`buoy-block-plan-${e.id}`,tone:e.pending?"info":void 0,children:[p(s,{style:c.progress,children:p(s,{style:[c.progressFill,{width:`${t/Math.max(1,e.steps.length)*100}%`}]})}),e.steps.map((o,r)=>v(s,{style:[c.step,r>0&&D.rowDivider],children:[p(s,{style:[c.stepMark,o.state==="done"&&c.stepDone,o.state==="failed"&&c.stepFailed,o.state==="running"&&c.stepRunning],children:o.state==="done"?p(Jr,{size:10,color:d.color.onAccent}):o.state==="failed"?p(Za,{size:10,color:d.color.text}):p(l,{style:c.stepNum,children:r+1})}),v(l,{style:[D.rowTitle,o.state==="done"&&c.muted],children:[o.text,o.state==="running"?"\u2026":""]})]},r)),p(Ve,{actions:e.actions??(e.pending?[{label:"Go",primary:true,send:"Go ahead with the plan."},{label:"Change it",send:"Let me change the plan first."}]:void 0),blockId:e.id})]})}function ks({block:e}){let t=oe();return v(m,{testID:`buoy-block-checkpoint-${e.id}`,disabled:!e.restore,onPress:()=>e.restore&&void t.runAction(e.restore,e.id),style:c.checkpoint,accessibilityRole:"button",children:[p(s,{style:c.cpFlag}),v(l,{style:c.cpText,children:[e.label,e.at?` \xB7 ${e.at}`:""]}),e.restore?p(l,{style:c.cpRestore,children:e.restore.label}):null]})}function xs({block:e}){let t=e.status==="failed"?d.color.danger:e.status==="done"?d.color.accent:d.color.info;return v(W,{testID:`buoy-block-task-${e.id}`,children:[v(s,{style:c.taskHead,children:[p(l,{style:c.cardTitle,children:e.title}),p(s,{style:[D.pill,{backgroundColor:`${t}22`}],children:p(l,{style:[D.pillText,{color:t}],children:e.status.toUpperCase()})})]}),e.progress!==void 0?p(s,{style:[c.progress,c.pad],children:p(s,{style:[c.progressFill,{width:`${Math.round(e.progress*100)}%`,backgroundColor:t}]})}):null,e.detail?p(l,{style:c.hint,children:e.detail}):null,p(Ve,{actions:e.actions,blockId:e.id})]})}function ws({block:e}){let t=e.tone==="danger"?d.color.danger:e.tone==="warning"?d.color.warning:d.color.info;return v(s,{style:[c.banner,{borderColor:t,backgroundColor:`${t}1A`}],testID:`buoy-block-banner-${e.id}`,children:[p(Ga,{size:13,color:t}),p(l,{style:[c.bannerText,{color:t}],numberOfLines:2,children:e.text}),e.actions?.[0]?p(Ve,{actions:e.actions.slice(0,1),blockId:e.id,align:"right"}):null]})}function vs({block:e}){return v(W,{testID:`buoy-block-file-${e.id}`,children:[v(s,{style:D.row,children:[p(s,{style:c.fileIcon,children:p(l,{style:c.fileExt,children:(e.type??e.name.split(".").pop()??"file").toUpperCase().slice(0,4)})}),v(s,{style:c.flex,children:[p(l,{style:D.rowTitle,numberOfLines:1,children:e.name}),e.size?p(l,{style:D.rowSub,children:e.size}):null]})]}),p(Ve,{actions:e.actions,blockId:e.id})]})}function Ss({block:e}){let t=oe(),o=t.answered[e.id];return v(W,{testID:`buoy-block-upload-${e.id}`,tone:o?void 0:"info",children:[p(l,{style:c.question,children:e.label}),o?p(l,{style:c.decided,children:o.kind==="upload"?`Attached ${o.name}`:"(skipped)"}):p(s,{style:[c.rowEnd,{justifyContent:"flex-start"}],children:p(m,{onPress:()=>t.answer({blockId:e.id,kind:"upload",name:"screenshot.png"}),style:[c.button,c.buttonPlate],children:p(l,{style:c.buttonTextPlate,children:e.accept==="image"?"Choose a screenshot":"Choose a file"})})})]})}var c=w.create({flex:{flex:1},pad:{paddingHorizontal:12,paddingBottom:8},muted:{color:d.color.textSecondary},dim:{opacity:.45},disabled:{opacity:.5},pressed:{opacity:.7},question:{color:d.color.text,fontSize:d.font.row,fontWeight:"600",lineHeight:20,paddingHorizontal:12,paddingTop:12,paddingBottom:8},hint:{color:d.color.textTertiary,fontSize:d.font.micro,paddingHorizontal:12,paddingBottom:10},decided:{color:d.color.textSecondary,fontSize:d.font.caption,fontWeight:"600",paddingHorizontal:12,paddingVertical:10},rowEnd:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:12,paddingBottom:12,gap:8},actionsRow:{flexDirection:"row",gap:8,paddingHorizontal:12,paddingVertical:12,alignItems:"center"},button:{paddingHorizontal:14,paddingVertical:9,borderRadius:d.radius.row},buttonPrimary:{backgroundColor:d.color.accent},buttonPlate:{backgroundColor:d.color.button},buttonTextPrimary:{color:d.color.onAccent,fontSize:d.font.caption,fontWeight:"600"},buttonTextPlate:{color:d.color.text,fontSize:d.font.caption,fontWeight:"600"},chips:{flexDirection:"row",flexWrap:"wrap",gap:6},chip:{paddingHorizontal:12,paddingVertical:7,borderRadius:d.radius.chip,backgroundColor:d.color.fill,borderWidth:w.hairlineWidth,borderColor:d.color.border},chipOn:{backgroundColor:d.color.accentSoft,borderColor:d.color.accentBorderStrong},chipText:{color:d.color.text,fontSize:d.font.caption},chipTextOn:{color:d.color.accent,fontWeight:"600"},optionsBox:{marginHorizontal:8,marginBottom:8,borderRadius:d.radius.row,backgroundColor:d.color.surfaceElevated,overflow:"hidden"},option:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:10},optionLabel:{color:d.color.text,fontSize:d.font.body,fontWeight:"500"},optionDetail:{color:d.color.textSecondary,fontSize:d.font.caption},checkbox:{width:20,height:20,borderRadius:6,borderWidth:1.5,borderColor:d.color.textTertiary,alignItems:"center",justifyContent:"center"},checkboxOn:{backgroundColor:d.color.accent,borderColor:d.color.accent},selectBox:{marginHorizontal:12,marginBottom:12,borderRadius:d.radius.row,backgroundColor:d.color.surfaceElevated,overflow:"hidden"},selectField:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:11},selectPlaceholder:{color:d.color.textSecondary,fontSize:d.font.body},search:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:6,borderTopWidth:w.hairlineWidth,borderTopColor:d.color.separator},searchInput:{flex:1,color:d.color.text,fontSize:d.font.caption,paddingVertical:4},sliderRow:{flexDirection:"row",alignItems:"center",gap:8},stepBtn:{width:28,height:28,borderRadius:14,backgroundColor:d.color.fill,alignItems:"center",justifyContent:"center"},stepText:{color:d.color.text,fontSize:16,fontWeight:"600"},trackHit:{flex:1,height:36,justifyContent:"center"},track:{height:6,borderRadius:3,backgroundColor:d.color.fillTertiary,justifyContent:"center"},fill:{height:6,borderRadius:3,backgroundColor:d.color.accent},thumb:{position:"absolute",width:20,height:20,borderRadius:10,backgroundColor:d.color.knob,marginLeft:-10,shadowColor:"#000",shadowOpacity:.35,shadowRadius:3,shadowOffset:{width:0,height:1}},sliderValue:{width:64,textAlign:"right",color:d.color.text,fontSize:d.font.caption,fontWeight:"600"},inputRow:{flexDirection:"row",alignItems:"center",gap:8,paddingBottom:12},input:{flex:1,height:38,paddingHorizontal:12,borderRadius:d.radius.row,backgroundColor:d.color.surfaceElevated,color:d.color.text,fontSize:d.font.body},fieldRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:10,paddingVertical:6},fieldCol:{paddingVertical:6,gap:6},fieldLabel:{color:d.color.textSecondary,fontSize:d.font.caption,width:110},fieldInput:{flex:1,height:34,paddingHorizontal:10,borderRadius:d.radius.segment,backgroundColor:d.color.surfaceElevated,color:d.color.text,fontSize:d.font.caption},confirmTitle:{color:d.color.text,fontSize:d.font.row,fontWeight:"600",paddingHorizontal:12,paddingTop:12},confirmChange:{color:d.color.text,fontSize:d.font.body,lineHeight:19,paddingHorizontal:12,paddingTop:6,paddingBottom:6},consequence:{color:d.color.warning,fontSize:d.font.caption,paddingHorizontal:12},claim:{gap:6,paddingHorizontal:2},claimText:{color:d.color.text,fontSize:d.font.row,lineHeight:22},cite:{color:d.color.accent,fontSize:d.font.caption,fontWeight:"700"},verified:{color:d.color.accent,fontSize:d.font.caption,fontWeight:"600"},citeBox:{padding:10,borderRadius:d.radius.row,backgroundColor:d.color.surface,borderWidth:w.hairlineWidth,borderColor:d.color.border,gap:2},citeLabel:{color:d.color.text,fontSize:d.font.caption,fontWeight:"600"},citeDetail:{color:d.color.textSecondary,fontSize:d.font.caption,fontFamily:we.OS==="web"?Oo:"Menlo"},verifyBtn:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:5,paddingHorizontal:10,paddingVertical:5,borderRadius:d.radius.chip,backgroundColor:d.color.accentSoft},verifyText:{color:d.color.accent,fontSize:d.font.micro,fontWeight:"700"},detailsBody:{color:d.color.textSecondary,fontSize:d.font.caption,lineHeight:18,paddingHorizontal:12,paddingBottom:12},tabsWrap:{gap:8},tabBar:{flexDirection:"row",gap:6},tab:{paddingHorizontal:12,paddingVertical:6,borderRadius:d.radius.badge,backgroundColor:d.color.fill},tabOn:{backgroundColor:d.color.accentSoft},tabText:{color:d.color.textSecondary,fontSize:d.font.caption,fontWeight:"600"},tabTextOn:{color:d.color.accent},tlRow:{flexDirection:"row",gap:10,paddingHorizontal:12,paddingVertical:4,alignItems:"flex-start"},tlAt:{width:46,color:d.color.textTertiary,fontSize:d.font.micro,fontFamily:we.OS==="web"?Oo:"Menlo",paddingTop:3},tlLine:{width:12,alignItems:"center"},tlDot:{width:8,height:8,borderRadius:4,marginTop:5},tlStem:{width:1,flex:1,minHeight:18,backgroundColor:d.color.separator,marginTop:2},tlSource:{color:d.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.6},sparkHead:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingTop:8},sparkCurrent:{color:d.color.text,fontSize:22,fontWeight:"700"},sparkUnit:{color:d.color.textSecondary,fontSize:d.font.caption,fontWeight:"500"},spark:{flexDirection:"row",alignItems:"flex-end",gap:2,paddingHorizontal:12,paddingTop:6,paddingBottom:6},sparkBar:{flex:1,borderRadius:1},live:{flexDirection:"row",alignItems:"center",gap:5,paddingHorizontal:8,paddingVertical:3,borderRadius:d.radius.badge,backgroundColor:d.color.dangerSoft},liveDot:{width:6,height:6,borderRadius:3,backgroundColor:d.color.danger},liveText:{color:d.color.danger,fontSize:9,fontWeight:"800",letterSpacing:.8},cmpHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,backgroundColor:d.color.fill,gap:8},cmpCol:{flex:1,color:d.color.textTertiary,fontSize:d.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},cmpRow:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"flex-start"},cmpDiff:{backgroundColor:d.color.fill},cmpKey:{width:90,color:d.color.textSecondary,fontSize:d.font.caption},cmpVal:{flex:1,color:d.color.text,fontSize:d.font.caption,fontFamily:we.OS==="web"?Oo:"Menlo"},cardImage:{width:"100%",height:140,backgroundColor:d.color.fill},cardText:{paddingHorizontal:12,paddingTop:10,paddingBottom:4,gap:4},cardTitle:{color:d.color.text,fontSize:d.font.row,fontWeight:"600"},fact:{flexDirection:"row",justifyContent:"space-between",gap:8},factLabel:{color:d.color.textSecondary,fontSize:d.font.caption},factValue:{color:d.color.text,fontSize:d.font.caption,fontWeight:"500"},carouselTitle:{color:d.color.text,fontSize:d.font.caption,fontWeight:"600",paddingBottom:8},carousel:{gap:8,paddingRight:8},carouselCard:{width:224,borderRadius:d.radius.card,borderWidth:w.hairlineWidth,borderColor:d.color.border,backgroundColor:d.color.surface,overflow:"hidden"},shot:{width:"100%",height:220,backgroundColor:d.color.fill},shotBig:{height:520},progress:{height:4,backgroundColor:d.color.fill,marginHorizontal:12,marginTop:6,marginBottom:8,borderRadius:2,overflow:"hidden"},progressFill:{height:4,backgroundColor:d.color.accent},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:d.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:d.color.accent},stepFailed:{backgroundColor:d.color.danger},stepRunning:{backgroundColor:d.color.info},stepNum:{color:d.color.text,fontSize:d.font.micro,fontWeight:"700"},checkpoint:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:7,borderRadius:d.radius.chip,backgroundColor:d.color.fill},cpFlag:{width:8,height:8,borderRadius:2,backgroundColor:d.color.info},cpText:{color:d.color.textSecondary,fontSize:d.font.caption},cpRestore:{color:d.color.accent,fontSize:d.font.caption,fontWeight:"600"},taskHead:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:8,paddingHorizontal:12,paddingTop:12},banner:{flexDirection:"row",alignItems:"center",gap:8,paddingLeft:12,paddingRight:4,paddingVertical:4,borderRadius:d.radius.row,borderWidth:w.hairlineWidth},bannerText:{flex:1,fontSize:d.font.caption,fontWeight:"600"},fileIcon:{width:40,height:40,borderRadius:8,backgroundColor:d.color.fill,alignItems:"center",justifyContent:"center"},fileExt:{color:d.color.textSecondary,fontSize:10,fontWeight:"800"}});import{jsx as A}from"react/jsx-runtime";var Ts=class extends xl{constructor(){super(...arguments);this.state={failed:false}}static getDerivedStateFromError(){return{failed:true}}render(){return this.state.failed?A(l,{style:Cs.fallback,testID:"buoy-block-render-failed",children:"This card couldn't be drawn \u2014 the data behind it is still in the conversation."}):this.props.children}},Cs=w.create({fallback:{color:Tr.color.textTertiary,fontSize:Tr.font.micro,fontStyle:"italic",paddingVertical:6}}),Is=e=>A(go,{block:e});function go({block:e}){return A(Ts,{children:A(zs,{block:e})})}function zs({block:e}){switch(e.kind){case"choice":return A(Kl,{block:e});case"confirm":return A(Jl,{block:e});case"input":return A(Gl,{block:e});case"table":return A(ma,{block:e});case"keyValue":return A(ka,{block:e});case"list":return A(wa,{block:e});case"imageGrid":return A(La,{block:e});case"diff":return A(Sa,{block:e});case"chart":return A(Ta,{block:e});case"steps":return A(Ca,{block:e});case"code":return A(Ra,{block:e});case"actions":return A(Ve,{actions:e.actions,blockId:e.id});case"notice":return A($a,{block:e});case"finding":return A(Aa,{block:e});case"requestList":return A(Na,{block:e});case"requestCard":return A(Ma,{block:e});case"ruleCard":return A(ja,{block:e});case"screenElements":return A(qa,{block:e});case"routeChips":return A(Fa,{block:e});case"logList":return A(_a,{block:e});case"crash":return A(Ua,{block:e});case"peek":return A(Ka,{block:e});case"suggestions":return A(es,{block:e});case"multiSelect":return A(ts,{block:e});case"select":return A(rs,{block:e});case"slider":return A(ns,{block:e});case"dateTime":return A(is,{block:e});case"form":return A(ls,{block:e});case"proposal":return A(as,{block:e});case"claim":return A(ss,{block:e});case"details":return A(cs,{block:e});case"tabs":return A(ds,{block:e,renderNested:Is});case"timeline":return A(ps,{block:e});case"sparkline":return A(hs,{block:e});case"compare":return A(gs,{block:e});case"card":return A(fs,{block:e});case"cardCarousel":return A(bs,{block:e});case"screenshot":return A(ys,{block:e});case"plan":return A(ms,{block:e});case"checkpoint":return A(ks,{block:e});case"task":return A(xs,{block:e});case"banner":return A(ws,{block:e});case"file":return A(vs,{block:e});case"upload":return A(Ss,{block:e});default:return null}}import{monoFont as Ds}from"@buoy-gg/shared-ui/web";import{useEffect as Rs,useState as Tt}from"react";import{ChevronDown as $s,ChevronRight as As,Copy as Bs,night as C,RefreshCw as Ls}from"@buoy-gg/shared-ui/web";import{jsx as N,jsxs as ze}from"react/jsx-runtime";function Qt({label:e,onPress:t,children:o}){return N(m,{onPress:t,accessibilityRole:"button",accessibilityLabel:e,style:({pressed:r})=>[H.iconBtn,r&&H.pressed],children:o})}function Os({id:e="chrome-actions"}){let t=oe(),[o,r]=Tt(null),n=i=>void t.runAction({label:i,send:`__chrome__:${i}`},e);return ze(s,{style:H.actions,testID:"chrome-message-actions",children:[N(Qt,{label:"Copy",onPress:()=>n("copy"),children:N(Bs,{size:13,color:C.color.textSecondary})}),N(Qt,{label:"Retry",onPress:()=>n("retry"),children:N(Ls,{size:13,color:C.color.textSecondary})}),N(Qt,{label:"Good answer",onPress:()=>{r("up"),n("thumbs up")},children:N(l,{style:[H.glyph,o==="up"&&H.glyphOn],children:"\u{1F44D}"})}),N(Qt,{label:"Bad answer",onPress:()=>{r("down"),n("thumbs down")},children:N(l,{style:[H.glyph,o==="down"&&H.glyphOn],children:"\u{1F44E}"})}),N(Qt,{label:"Export",onPress:()=>n("export transcript"),children:N(l,{style:H.textBtn,children:"Export"})})]})}function Hs({text:e,live:t}){let[o,r]=Tt(false);return ze(s,{style:H.reasoning,testID:"chrome-reasoning",children:[ze(m,{onPress:()=>r(n=>!n),style:H.reasoningHead,accessibilityRole:"button",accessibilityState:{expanded:o},children:[t?N(Jt,{size:"small",color:C.color.textTertiary}):null,N(l,{style:H.reasoningTitle,children:t?"Working it out\u2026":"How I got here"}),o?N($s,{size:12,color:C.color.textTertiary}):N(As,{size:12,color:C.color.textTertiary})]}),o?N(l,{style:H.reasoningBody,children:e}):null]})}function Ps({label:e}){let[t,o]=Tt(0);return Rs(()=>{let r=setInterval(()=>o(n=>n+250),250);return()=>clearInterval(r)},[]),ze(s,{style:H.elapsed,testID:"chrome-elapsed",children:[N(Jt,{size:"small",color:C.color.textSecondary}),N(l,{style:H.elapsedLabel,children:e}),ze(l,{style:H.elapsedMs,children:[(t/1e3).toFixed(1),"s"]})]})}function Ws(){let[e,t]=Tt(""),[o,r]=Tt(null);return ze(s,{style:H.composerWrap,testID:"chrome-queue",children:[o?ze(s,{style:H.queuedRow,children:[ze(l,{style:H.queuedText,numberOfLines:1,children:['Queued: "',o,'"']}),N(m,{onPress:()=>r(null),children:N(l,{style:H.queuedCancel,children:"Cancel"})})]}):null,ze(s,{style:H.composer,children:[N(rt,{style:H.composerInput,value:e,onChangeText:t,placeholder:"Agent is busy \u2014 type and it sends next",placeholderTextColor:C.color.placeholder}),N(m,{disabled:!e.trim(),onPress:()=>{r(e.trim()),t("")},style:[H.queueBtn,!e.trim()&&{opacity:.5}],children:N(l,{style:H.queueBtnText,children:"Queue"})})]})]})}function Es({at:e}){return ze(s,{style:H.divider,testID:"chrome-divider",children:[N(s,{style:H.dividerLine}),ze(l,{style:H.dividerText,children:["App reloaded \xB7 ",e]}),N(s,{style:H.dividerLine})]})}function Ns({at:e}){return N(l,{style:H.timestamp,children:e})}function Vs({text:e}){let t=oe(),[o,r]=Tt(false),[n,i]=Tt(e);return N(s,{style:H.userWrap,testID:"chrome-edit-bubble",children:o?ze(s,{style:H.editBox,children:[N(rt,{style:H.editInput,value:n,onChangeText:i,multiline:true}),ze(s,{style:H.editActions,children:[N(m,{onPress:()=>{r(false),t.runAction({label:"re-run edited",send:`__chrome__:re-run "${n}"`},"chrome-edit")},style:H.editPrimary,children:N(l,{style:H.editPrimaryText,children:"Re-run from here"})}),N(m,{onPress:()=>{r(false),t.runAction({label:"branch",send:`__chrome__:branch "${n}"`},"chrome-edit")},style:H.editPlate,children:N(l,{style:H.editPlateText,children:"Branch"})}),N(m,{onPress:()=>r(false),style:H.editPlate,children:N(l,{style:H.editPlateText,children:"Cancel"})})]})]}):ze(m,{onLongPress:()=>r(true),onPress:()=>r(true),style:H.bubble,accessibilityRole:"button",accessibilityLabel:"Edit message",children:[N(l,{style:H.bubbleText,children:n}),N(l,{style:H.bubbleHint,children:"tap to edit \xB7 2 branches"})]})})}var H=w.create({actions:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:2},iconBtn:{paddingHorizontal:8,paddingVertical:6,borderRadius:C.radius.badge},pressed:{backgroundColor:C.color.fill},glyph:{fontSize:13,opacity:.6},glyphOn:{opacity:1},textBtn:{color:C.color.textSecondary,fontSize:C.font.micro,fontWeight:"600"},reasoning:{borderRadius:C.radius.row,backgroundColor:C.color.fill,overflow:"hidden"},reasoningHead:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:8},reasoningTitle:{flex:1,color:C.color.textSecondary,fontSize:C.font.caption,fontStyle:"italic"},reasoningBody:{color:C.color.textSecondary,fontSize:C.font.caption,lineHeight:18,paddingHorizontal:12,paddingBottom:10},elapsed:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:10,borderRadius:C.radius.card,borderWidth:w.hairlineWidth,borderColor:C.color.border,backgroundColor:C.color.surface},elapsedLabel:{flex:1,color:C.color.text,fontSize:C.font.body},elapsedMs:{color:C.color.textTertiary,fontSize:C.font.caption,fontFamily:we.OS==="web"?Ds:"Menlo"},composerWrap:{gap:6},queuedRow:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:6,borderRadius:C.radius.row,backgroundColor:C.color.infoSoft},queuedText:{flex:1,color:C.color.text,fontSize:C.font.caption},queuedCancel:{color:C.color.info,fontSize:C.font.caption,fontWeight:"600"},composer:{flexDirection:"row",alignItems:"center",gap:8},composerInput:{flex:1,height:40,paddingHorizontal:16,borderRadius:20,borderWidth:w.hairlineWidth,borderColor:C.color.border,backgroundColor:C.color.surfaceElevated,color:C.color.text,fontSize:C.font.body},queueBtn:{paddingHorizontal:14,height:40,borderRadius:20,backgroundColor:C.color.button,alignItems:"center",justifyContent:"center"},queueBtnText:{color:C.color.text,fontSize:C.font.caption,fontWeight:"600"},divider:{flexDirection:"row",alignItems:"center",gap:10,paddingVertical:4},dividerLine:{flex:1,height:w.hairlineWidth,backgroundColor:C.color.border},dividerText:{color:C.color.textTertiary,fontSize:C.font.micro},timestamp:{alignSelf:"center",color:C.color.textTertiary,fontSize:C.font.micro},userWrap:{alignItems:"flex-end"},bubble:{maxWidth:"84%",paddingHorizontal:14,paddingVertical:9,borderRadius:18,borderBottomRightRadius:6,backgroundColor:C.color.accentFill,borderWidth:w.hairlineWidth,borderColor:C.color.accentBorder,gap:4},bubbleText:{color:C.color.text,fontSize:C.font.row,lineHeight:21},bubbleHint:{color:C.color.textTertiary,fontSize:10,textAlign:"right"},editBox:{width:"100%",gap:8},editInput:{minHeight:60,padding:12,borderRadius:C.radius.row,backgroundColor:C.color.surfaceElevated,color:C.color.text,fontSize:C.font.row,borderWidth:w.hairlineWidth,borderColor:C.color.accentBorderStrong},editActions:{flexDirection:"row",gap:8,justifyContent:"flex-end",flexWrap:"wrap"},editPrimary:{paddingHorizontal:12,paddingVertical:8,borderRadius:C.radius.row,backgroundColor:C.color.accent},editPrimaryText:{color:C.color.onAccent,fontSize:C.font.caption,fontWeight:"600"},editPlate:{paddingHorizontal:12,paddingVertical:8,borderRadius:C.radius.row,backgroundColor:C.color.button},editPlateText:{color:C.color.text,fontSize:C.font.caption,fontWeight:"600"}});import{useState as rn}from"react";import{AlertTriangle as Ms,ChevronDown as js,night as E}from"@buoy-gg/shared-ui/web";import{jsx as ke,jsxs as Xt}from"react/jsx-runtime";function nn({pending:e,onAnswer:t}){let[o,r]=rn("");return Xt(s,{style:Y.card,testID:"buoy-ask-buoy-approval",children:[Xt(s,{style:Y.titleRow,children:[ke(Ms,{size:14,color:E.color.warning}),ke(l,{style:Y.title,children:"Allow this change?"})]}),e.restored?ke(l,{style:Y.restored,testID:"buoy-ask-buoy-approval-restored",children:"Asked before the app restarted \u2014 check it still applies."}):null,ke(l,{style:Y.label,children:e.label}),ke(l,{style:Y.reason,children:e.reason}),e.description?ke(qs,{text:e.description}):null,ke(rt,{testID:"buoy-ask-buoy-approval-note",value:o,onChangeText:r,placeholder:"Add a note for the agent (optional)",placeholderTextColor:E.color.textTertiary,style:Y.note,returnKeyType:"done",blurOnSubmit:true}),Xt(s,{style:Y.actions,children:[ke(m,{testID:"buoy-ask-buoy-approve",accessibilityRole:"button",onPress:()=>t({approved:true,reason:o}),style:({pressed:n})=>[Y.button,Y.approve,n&&Y.pressed],children:ke(l,{style:Y.approveText,children:"Allow"})}),e.restored?null:ke(m,{testID:"buoy-ask-buoy-approve-trust",accessibilityRole:"button",onPress:()=>t({approved:true,reason:o,trust:true}),style:({pressed:n})=>[Y.button,Y.trust,n&&Y.pressed],children:ke(l,{style:Y.trustText,children:"Allow for this chat"})}),ke(m,{testID:"buoy-ask-buoy-reject",accessibilityRole:"button",onPress:()=>t({approved:false,reason:o}),style:({pressed:n})=>[Y.button,Y.reject,n&&Y.pressed],children:ke(l,{style:Y.rejectText,children:"Not now"})})]})]})}function qs({text:e}){let[t,o]=rn(false);return Xt(s,{children:[Xt(m,{testID:"buoy-ask-buoy-approval-details",accessibilityRole:"button",accessibilityState:{expanded:t},onPress:()=>o(r=>!r),style:({pressed:r})=>[Y.disclosure,r&&Y.pressed],hitSlop:6,children:[ke(s,{style:t?Y.chevronOpen:Y.chevronClosed,children:ke(js,{size:12,color:E.color.textTertiary})}),ke(l,{style:Y.disclosureText,children:t?"Hide details":"Details"})]}),t?ke(Je,{style:Y.detail,contentContainerStyle:Y.detailContent,nestedScrollEnabled:true,children:ke(l,{style:Y.description,children:e})}):null]})}var Y=w.create({card:{marginHorizontal:E.gutter,marginBottom:10,padding:E.cardPad,borderRadius:E.radius.card,borderWidth:w.hairlineWidth,borderColor:E.color.accentBorderStrong,backgroundColor:E.color.surface,gap:6},titleRow:{flexDirection:"row",alignItems:"center",gap:6},title:{color:E.color.text,fontSize:E.font.caption,fontWeight:"600"},label:{color:E.color.text,fontSize:E.font.row,fontWeight:"600",lineHeight:20},description:{color:E.color.textSecondary,fontSize:E.font.caption,lineHeight:18},reason:{color:E.color.warning,fontSize:E.font.caption,lineHeight:18},restored:{color:E.color.info,backgroundColor:E.color.infoSoft,fontSize:E.font.micro,lineHeight:16,paddingHorizontal:8,paddingVertical:5,borderRadius:8},disclosure:{flexDirection:"row",alignItems:"center",gap:4,paddingVertical:4},disclosureText:{color:E.color.textTertiary,fontSize:E.font.micro,fontWeight:"600"},chevronOpen:{transform:[{rotate:"0deg"}]},chevronClosed:{transform:[{rotate:"-90deg"}]},detail:{maxHeight:150,marginTop:2},detailContent:{paddingBottom:2},note:{color:E.color.text,fontSize:E.font.caption,paddingHorizontal:10,paddingVertical:7,borderRadius:E.radius.row,borderWidth:w.hairlineWidth,borderColor:E.color.border,backgroundColor:E.color.button,marginTop:2},actions:{flexDirection:"row",flexWrap:"wrap",gap:8,marginTop:6},button:{paddingHorizontal:16,paddingVertical:9,borderRadius:E.radius.row},approve:{backgroundColor:E.color.accent},approveText:{color:E.color.onAccent,fontWeight:"600",fontSize:E.font.caption},trust:{backgroundColor:E.color.button,borderWidth:w.hairlineWidth,borderColor:E.color.accentBorderStrong},trustText:{color:E.color.accent,fontWeight:"600",fontSize:E.font.caption},reject:{backgroundColor:E.color.button},rejectText:{color:E.color.text,fontSize:E.font.caption},pressed:{opacity:.7}});import{useSyncExternalStore as Fs}from"react";import{ChevronDown as _s,ChevronRight as Us,night as re}from"@buoy-gg/shared-ui/web";import{isReversible as ln}from"@buoy-gg/agent-core/web";import{jsx as at,jsxs as bt}from"react/jsx-runtime";var an=[];function sn(e){return Fs(t=>e?.subscribe(t)??(()=>{}),()=>e?.list()??an,()=>e?.list()??an)}function cn({ledger:e,onUndoAll:t,expanded:o,onToggle:r}){let n=sn(e).filter(T=>!T.undoneAt),i=n.filter(T=>T.effect.kind!=="transient");if(i.length===0)return null;let a=i.filter(T=>ln(T.effect)),g=i.length-a.length,u=n.length-i.length,h=o?_s:Us,f=[a.length>0?`${a.length} undoable`:null,g>0?`${g} permanent`:null].filter(Boolean).join(" \xB7 ");return bt(s,{style:fe.wrap,children:[bt(m,{testID:"buoy-ask-buoy-changes-bar",accessibilityRole:"button",accessibilityState:{expanded:o},onPress:r,style:fe.bar,children:[at(s,{style:fe.dot}),at(l,{style:fe.summary,numberOfLines:1,children:"Changed this app"}),at(l,{style:fe.counts,numberOfLines:1,children:f}),at(h,{size:12,color:re.color.textSecondary})]}),o&&bt(s,{style:fe.panel,children:[bt(Je,{style:fe.panelScroll,testID:"buoy-ask-buoy-changes-scroll",keyboardShouldPersistTaps:"handled",children:[i.map(T=>{let O=!ln(T.effect);return bt(s,{style:fe.row,children:[at(l,{style:fe.rowLabel,children:T.effect.label}),at(l,{style:[fe.rowTag,O&&fe.rowTagMuted],children:O?"Permanent":"Undoable"})]},T.id)}),u>0&&at(s,{style:fe.row,children:bt(l,{style:[fe.rowLabel,fe.rowLabelMuted],children:["Also did ",u," one-shot action",u===1?"":"s"," (navigation, taps) \u2014 nothing to undo."]})})]}),bt(s,{style:fe.footer,children:[a.length>0&&at(m,{testID:"buoy-ask-buoy-undo-all",accessibilityRole:"button",onPress:t,style:({pressed:T})=>[fe.undo,T&&fe.pressed],children:bt(l,{style:fe.undoText,children:["Undo ",a.length," change",a.length===1?"":"s"]})}),g>0&&at(l,{style:fe.footnote,children:"Permanent changes can't be undone from here."})]})]})]})}var fe=w.create({wrap:{borderBottomWidth:w.hairlineWidth,borderBottomColor:re.color.border,backgroundColor:re.color.warningSoft},bar:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:re.gutter,paddingVertical:10},dot:{width:7,height:7,borderRadius:4,backgroundColor:re.color.warning},summary:{color:re.color.text,fontSize:re.font.caption,fontWeight:"600"},counts:{flex:1,color:re.color.textSecondary,fontSize:re.font.caption},panel:{paddingHorizontal:re.gutter,paddingBottom:12,gap:10},panelScroll:{maxHeight:180},row:{flexDirection:"row",alignItems:"flex-start",gap:10,paddingVertical:8,borderTopWidth:w.hairlineWidth,borderTopColor:re.color.separator},rowLabel:{flex:1,color:re.color.text,fontSize:re.font.caption,lineHeight:18},rowTag:{color:re.color.accent,fontSize:re.font.micro,fontWeight:"600",letterSpacing:.6,textTransform:"uppercase",paddingTop:2},rowTagMuted:{color:re.color.textTertiary},rowLabelMuted:{color:re.color.textTertiary},footer:{flexDirection:"row",alignItems:"center",gap:12,flexWrap:"wrap"},undo:{paddingHorizontal:14,paddingVertical:8,borderRadius:re.radius.row,backgroundColor:re.color.button},undoText:{color:re.color.accent,fontSize:re.font.caption,fontWeight:"600"},footnote:{flex:1,color:re.color.textTertiary,fontSize:re.font.micro},pressed:{opacity:.7}});function Ks(e){let t={};for(let o of e){let r=o.effect;if(r.kind==="network-override")t[r.ruleId]=o.undoneAt?{deleted:true}:{enabled:true};else if(r.kind==="inverse-call"&&r.toolId==="network"&&r.action==="setOverrideRuleEnabled"&&typeof r.params.id=="string"){let n=r.params.enabled===true;if(t[r.params.id]?.deleted)continue;t[r.params.id]={enabled:o.undoneAt?n:!n}}}return t}import{useCallback as Js,useEffect as dn,useRef as Gs,useState as Ys}from"react";import{night as Te}from"@buoy-gg/shared-ui/web";import{jsx as yt,jsxs as Qs}from"react/jsx-runtime";var un=40,Xs=120,pn=we.OS==="ios"?10:6,Zs=16;function hn({onSend:e,onStop:t,busy:o,draft:r,onDraftTaken:n,disabled:i,placeholder:a,focusKey:g,canFocus:u=true}){let[h,f]=Ys(""),T=Gs(null);dn(()=>{!g||!u||i||T.current?.focus()},[g,u,i]),dn(()=>{r&&(f(ce=>ce?`${ce} ${r}`:r),n?.())},[r,n]);let O=Js(()=>{let ce=h.trim();ce&&(f(""),e(ce))},[h,e]),_=h.trim().length>0&&!o&&!i,ee=h.trim().length>0&&o&&!i;return Qs(s,{style:xe.wrap,children:[yt(s,{style:[xe.field,i&&xe.fieldDisabled],children:yt(rt,{ref:T,testID:"buoy-ask-buoy-input",style:[xe.input,h.length===0&&xe.inputEmpty],value:h,onChangeText:f,placeholder:a??(i?"Ask Buoy isn't set up yet":"Ask, or tell it what to change\u2026"),placeholderTextColor:Te.color.placeholder,multiline:true,editable:!i,keyboardType:"ascii-capable",autoCorrect:true,autoCapitalize:"sentences",blurOnSubmit:false,onSubmitEditing:O,returnKeyType:"send",maxLength:4e3})}),ee&&yt(m,{testID:"buoy-ask-buoy-queue",accessibilityRole:"button",accessibilityLabel:"Queue message",onPress:O,style:({pressed:ce})=>[xe.button,xe.queue,ce&&xe.pressed],children:yt(l,{style:[xe.sendGlyph,{color:Te.color.accent}],children:"\u2191"})}),o?yt(m,{testID:"buoy-ask-buoy-stop",accessibilityRole:"button",accessibilityLabel:"Stop",onPress:t,style:({pressed:ce})=>[xe.button,xe.stop,ce&&xe.pressed],children:yt(s,{style:xe.stopGlyph})}):yt(m,{testID:"buoy-ask-buoy-send",accessibilityRole:"button",accessibilityLabel:"Send",disabled:!_,onPress:O,style:({pressed:ce})=>[xe.button,_?xe.sendOn:xe.sendOff,ce&&_&&xe.pressed],children:yt(l,{style:[xe.sendGlyph,{color:_?Te.color.onAccent:Te.color.textTertiary}],children:"\u2191"})})]})}var xe=w.create({wrap:{flexDirection:"row",alignItems:"flex-end",gap:8,paddingHorizontal:Te.gutter,paddingTop:10,paddingBottom:6,borderTopWidth:w.hairlineWidth,borderTopColor:Te.color.border,backgroundColor:Te.color.bg},field:{flex:1,minHeight:un,justifyContent:"center",borderRadius:20,borderWidth:w.hairlineWidth,borderColor:Te.color.border,backgroundColor:Te.color.surfaceElevated},fieldDisabled:{opacity:.6},input:{maxHeight:Xs,paddingHorizontal:Zs,paddingTop:pn,paddingBottom:pn,color:Te.color.text,fontSize:Te.font.row},inputEmpty:{height:un},button:{width:40,height:40,borderRadius:20,alignItems:"center",justifyContent:"center"},sendGlyph:{fontSize:20,fontWeight:"700",lineHeight:22},sendOn:{backgroundColor:Te.color.accent},sendOff:{backgroundColor:Te.color.fill},stop:{backgroundColor:Te.color.fillTertiary},queue:{backgroundColor:"transparent",borderWidth:w.hairlineWidth,borderColor:Te.color.accentBorderStrong},stopGlyph:{width:12,height:12,borderRadius:2,backgroundColor:Te.color.text},pressed:{opacity:.7}});import{useEffect as ec,useRef as gn}from"react";import{jsx as tc}from"react/jsx-runtime";function oc({children:e}){let t=gn(null),o=gn(new ue.Value(0)).current;return ec(()=>{if(we.OS!=="ios")return;let r=(g,u)=>{ue.timing(o,{toValue:g,duration:u.duration||250,easing:At.bezier(.17,.59,.4,.77),useNativeDriver:false}).start()},n=g=>{let u=t.current;u&&u.measureInWindow((h,f,T,O)=>{let _=f+O-g.endCoordinates.screenY;r(Math.max(0,_),g)})},i=g=>r(0,g),a=[Io.addListener("keyboardWillChangeFrame",n),Io.addListener("keyboardWillHide",i)];return()=>a.forEach(g=>g.remove())},[o]),tc(ue.View,{ref:t,style:[rc.flex,{paddingBottom:o}],children:e})}var rc=w.create({flex:{flex:1}});import{useEffect as fn,useState as bn}from"react";import{Check as nc,Copy as ic,FileText as lc,ModalHeader as fo,night as Qe,Otto as ac,Plus as sc,SettingsSolid as cc,realNow as Ho}from"@buoy-gg/shared-ui/web";import{toolTitle as dc}from"@buoy-gg/agent-core/web";var uc=e=>e.effect==="read"&&e.status==="ok";function pc(e){let t=[],o=[],r=()=>{if(o.length!==0){if(o.length===1)t.push({kind:"call",call:o[0]});else{let n=[...new Set(o.map(i=>dc(i.toolId)))];t.push({kind:"reads",id:o.map(i=>i.id).join("+"),calls:o,label:`Looked at ${hc(n)}`,count:o.length})}o=[]}};for(let n of e){if(uc(n)){o.push(n);continue}r(),t.push({kind:"call",call:n})}return r(),t}function hc(e){return e.length<=1?e[0]??"":e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function gc(e){let t=[];e.startedAt!==void 0&&e.endedAt!==void 0&&e.endedAt>=e.startedAt&&t.push(yn(e.endedAt-e.startedAt));let o=e.toolCalls.length;if(o>0){t.push(`${o} action${o===1?"":"s"}`);let r=u=>e.toolCalls.filter(h=>h.status===u).length,n=r("failed"),i=r("refused"),a=r("declined"),g=r("stopped");n&&t.push(`${n} failed`),i&&t.push(`${i} refused`),a&&t.push(`${a} declined`),g&&t.push(`${g} not run`)}return t.length?t.join(" \xB7 "):null}function yn(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let o=Math.floor(t/60),r=t%60;return o<60?`${o}m ${String(r).padStart(2,"0")}s`:`${Math.floor(o/60)}h ${String(o%60).padStart(2,"0")}m`}import{jsx as Be,jsxs as mn}from"react/jsx-runtime";var fc=200,bc=()=>"";function kn({configured:e,busy:t,failed:o=false,activeLabel:r,awaitingApproval:n=false,startedAt:i=null,stopping:a=false,readOnly:g=false,toolCount:u,hasMessages:h,onBack:f,onReset:T,getTranscript:O,onOpenSettings:_,onTicket:ee}){let{copied:ce,copy:pe}=uo(O??bc),[Pe,qe]=bn(false);fn(()=>{t?r&&qe(true):qe(false)},[t,r]);let We=t&&!n&&i!==null,[Xe,Ze]=bn(()=>Ho());fn(()=>{if(!We)return;Ze(Ho());let Et=setInterval(()=>Ze(Ho()),1e3);return()=>clearInterval(Et)},[We]);let et=We&&i!==null?yn(Xe-i):null,Wt=e?o?"error":t?r||Pe?"robot":"thinking":"idle":"confused",tt=a?"Stopping":r??"Thinking",Ee=e?n?"Waiting for you":t?et?`${tt} \xB7 ${et}`:`${tt}\u2026`:g?`Read only${u>0?` \xB7 ${u} tool${u===1?"":"s"}`:""}`:u>0?`Ready \xB7 ${u} tool${u===1?"":"s"} available`:"Ready":"Not set up in this app";return mn(fo,{children:[f?Be(fo.Navigation,{onBack:f}):null,Be(s,{style:mt.otto,testID:"buoy-ask-buoy-otto",children:Be(ac,{state:Wt,pixelSize:2,tickMs:fc,water:false})}),Be(fo.Content,{title:"Ask Buoy",subtitle:Ee,testID:"buoy-ask-buoy-title"}),mn(fo.Actions,{children:[ee?Be(Kt,{testID:"buoy-ask-buoy-ticket",accessibilityRole:"button",accessibilityLabel:"Summarize for a ticket",disabled:!h||t,onPress:ee,style:[mt.actionBtn,(!h||t)&&mt.actionBtnDisabled],children:Be(lc,{size:14,color:h&&!t?Qe.color.textSecondary:Qe.color.textTertiary})}):null,O?Be(Kt,{testID:"buoy-ask-buoy-copy-chat",accessibilityRole:"button",accessibilityLabel:ce?"Conversation copied":"Copy conversation",disabled:!h,onPress:pe,style:[mt.actionBtn,!h&&mt.actionBtnDisabled],children:ce?Be(nc,{size:14,color:Qe.color.accent}):Be(ic,{size:14,color:h?Qe.color.textSecondary:Qe.color.textTertiary})}):null,_?Be(Kt,{testID:"buoy-ask-buoy-settings",accessibilityRole:"button",accessibilityLabel:"Settings",onPress:_,style:mt.actionBtn,children:Be(cc,{size:14,color:Qe.color.textSecondary})}):null,Be(Kt,{testID:"buoy-ask-buoy-reset",accessibilityRole:"button",accessibilityLabel:"New conversation",disabled:!h,onPress:T,style:[mt.actionBtn,!h&&mt.actionBtnDisabled],children:Be(sc,{size:14,color:h?Qe.color.textSecondary:Qe.color.textTertiary})})]})]})}var mt=w.create({otto:{marginRight:8,justifyContent:"center"},actionBtn:{width:32,height:32,borderRadius:8,backgroundColor:Qe.color.buttonSurface,borderWidth:1,borderColor:Qe.color.border,alignItems:"center",justifyContent:"center"},actionBtnDisabled:{opacity:.55}});import{useCallback as yc,useEffect as mc,useState as kc}from"react";import{AlertTriangle as xc,night as se,ToggleRow as Po}from"@buoy-gg/shared-ui/web";import{useSyncExternalStore as wc}from"react";import{definePersistedSetting as vc,devToolsStorageKeys as Sc}from"@buoy-gg/shared-ui/web";var Wo={showThinking:false,bypassApprovals:false,readOnly:false,hostedNoticeSeen:false,claudeNoticeSeen:false},Eo=vc(`${Sc.base}_ask_buoy_settings`,Wo,{sanitize:e=>({showThinking:e.showThinking===true,bypassApprovals:e.bypassApprovals===true,readOnly:e.readOnly===true,hostedNoticeSeen:e.hostedNoticeSeen===true,claudeNoticeSeen:e.claudeNoticeSeen===true})}),Ct=Wo,No=false,Vo=new Set;function xn(){for(let e of Vo)try{e()}catch{}}var st={get:()=>Ct,subscribe(e){return Vo.add(e),No||(No=true,Eo.load().then(t=>{Ct=t,xn()})),()=>Vo.delete(e)},set(e,t){Ct[e]!==t&&(Ct={...Ct,[e]:t},xn(),Eo.save(Ct))},reset(){Ct=Wo,No=false,Eo.clear()}};function Ot(){return wc(st.subscribe,st.get,st.get)}import{useSyncExternalStore as Tc}from"react";import{definePersistedSetting as Cc,devToolsStorageKeys as Ic,subscribeStorageWrites as zc}from"@buoy-gg/shared-ui/web";var Mo="claude",wn=Ic.askBuoy.model(),vn=e=>e==="luna"?"luna":"claude",Sn=Cc(wn,Mo,{sanitize:vn}),bo=Mo,Tn=false,jo=new Set;function Dc(){for(let e of jo)try{e()}catch{}}function qo(e){e!==bo&&(bo=e,Dc())}var yo={get:()=>bo,subscribe(e){return jo.add(e),Tn||(Tn=true,Sn.load().then(qo),zc((t,o)=>{if(t===wn)try{qo(vn(o===null?Mo:JSON.parse(o)))}catch{}})),()=>jo.delete(e)},set(e){e!==bo&&(qo(e),Sn.save(e))}};function Cn(){return Tc(yo.subscribe,yo.get,yo.get)}import{idFactory as In}from"@buoy-gg/agent-core/web";import{realNow as Zt}from"@buoy-gg/shared-ui/web";var mo=In("m"),zn=400;function Rc(e){if(!(!e||Object.keys(e).length===0))try{let t=JSON.stringify(e);return t.length>zn?`${t.slice(0,zn)}\u2026`:t}catch{return}}var $c=In("q"),L={messages:[],busy:false,stopping:false,pending:null,trusted:[],notice:null,configured:false,answers:{},awaitingBlockId:null,actionState:{},queued:[],draft:null,usage:{input:0,output:0,requests:0},credits:null,claudeOut:false,meta:{}},Dn=null,Rn=null,Fo=new Set,$n=null,_o=null;function X(e){L={...L,...e};for(let t of Fo)try{t()}catch{}}var b={getState:()=>L,subscribe(e){return Fo.add(e),()=>Fo.delete(e)},setLedger(e){$n=e},getLedger(){return $n},holdSession(e,t){_o={session:e,signature:t}},getHeldSession(){return _o},setReporter(e){Dn=e},getReporter(){return Dn},setUsageReader(e){Rn=e},getUsageReader(){return Rn},setNotice(e){X({notice:e})},setConfigured(e){e!==L.configured&&X({configured:e})},setClaudeOut(e){L.claudeOut!==e&&X({claudeOut:e})},setMeta(e){Object.keys(e).every(t=>L.meta[t]===e[t])||X({meta:{...L.meta,...e}})},addUser(e){X({messages:[...L.messages,{id:mo(),role:"user",text:e,toolCalls:[],blocks:[]}],busy:true})},beginTurn(){X({busy:true})},enqueue(e){let t={id:$c(),text:e};return X({queued:[...L.queued,t]}),t},removeQueued(e){L.queued.some(t=>t.id===e)&&X({queued:L.queued.filter(t=>t.id!==e)})},shiftQueued(){let[e,...t]=L.queued;if(e)return X({queued:t}),e},takeQueuedToDraft(e){let t=L.queued.find(o=>o.id===e);t&&X({queued:L.queued.filter(o=>o.id!==e),draft:t.text})},requestStop(){!L.busy||L.stopping||X({stopping:true})},clearDraft(){L.draft!==null&&X({draft:null})},removeMessage(e){X({messages:L.messages.filter(t=>t.id!==e)})},recordAnswer(e){X({answers:{...L.answers,[e.blockId]:e},awaitingBlockId:L.awaitingBlockId===e.blockId?null:L.awaitingBlockId})},setActionState(e,t){let o={...L.actionState};t===null?delete o[e]:o[e]=t,X({actionState:o})},startAssistant(){let e=mo();return X({messages:[...L.messages,{id:e,role:"assistant",text:"",toolCalls:[],blocks:[],streaming:true,startedAt:Zt()}]}),e},applyEvent(e,t){if(t.type==="history-trimmed"){let r=L.messages.findIndex(a=>a.id===e),n={id:mo(),role:"assistant",system:true,text:`Older messages were trimmed from the agent's memory (${t.droppedRounds} exchange${t.droppedRounds===1?"":"s"}).`+(t.droppedPinned?` ${t.droppedPinned===1?"One of them made a change that is":`${t.droppedPinned} of them made changes that are`} still applied \u2014 the changes bar still lists ${t.droppedPinned===1?"it":"them"}, but the agent no longer remembers making ${t.droppedPinned===1?"it":"them"}.`:" It may not recall setup from earlier in this chat \u2014 the changes bar still lists what is applied."),toolCalls:[],blocks:[],endedAt:Zt()},i=[...L.messages];i.splice(r<0?i.length:r,0,n),X({messages:i});return}let o=L.messages.map(r=>{if(r.id!==e)return r;switch(t.type){case"retrying":{let n=Math.max(1,Math.round(t.inMs/1e3));return{...r,waiting:t.reason==="throttled"?`Endpoint busy \u2014 retrying in ${n}s (${t.attempt} of ${t.maxAttempts})`:"Request too large \u2014 trimming older messages and retrying"}}case"text":return{...r,waiting:void 0,text:(r.breakBeforeNextText||t.breakBefore)&&r.text?`${r.text.trimEnd()}
|
|
9
9
|
|
|
10
|
-
${t.delta}`:r.text+t.delta,breakBeforeNextText:false};case"reasoning":return{...r,breakBeforeNextText:true,reasoning:[...r.reasoning??[],{text:t.text,afterCalls:r.toolCalls.length}]};case"tool-start":return{...r,waiting:void 0,toolCalls:[...r.toolCalls,{id:t.id,toolId:t.toolId,action:t.action,label:t.label,description:t.description,status:"running",params:pc(t.params),effect:t.effect,startedAt:_t()}]};case"tool-end":return{...r,breakBeforeNextText:true,toolCalls:r.toolCalls.map(n=>n.id===t.id?{...n,status:!t.ok&&t.summary==="refused"?"refused":!t.ok&&t.summary==="declined"?"declined":!t.ok&&t.summary==="stopped"?"stopped":t.ok?"ok":"failed",summary:t.summary,durationMs:t.durationMs,result:t.result}:n)};case"tool-verified":return{...r,toolCalls:r.toolCalls.map(n=>n.id===t.id?{...n,verification:t.verification}:n)};case"block":return{...r,breakBeforeNextText:true,blocks:[...r.blocks,{block:t.block,forToolCallId:t.forToolCallId}]};case"usage":return{...r,usage:{input:(r.usage?.input??0)+t.input,output:(r.usage?.output??0)+t.output,requests:(r.usage?.requests??0)+1}};case"error":return{...r,waiting:void 0,error:t.message,...t.hosted?{errorInfo:{code:t.hosted.code,requestId:t.hosted.request_id,action:t.hosted.action,resetAt:t.hosted.reset_at,helpUrl:t.hosted.help_url}}:{}};default:return r}});Q({messages:o,...t.type==="awaiting-user"?{awaitingBlockId:t.blockId}:{},...t.type==="meter"&&t.frame.phase==="end"?{credits:{left:t.frame.credits_left??H.credits?.left??null,resetAt:t.frame.credits_reset??H.credits?.resetAt??null,pending:t.frame.pending===true}}:{},...t.type==="usage"?{usage:{input:H.usage.input+t.input,output:H.usage.output+t.output,requests:H.usage.requests+1}}:{}})},markStopped(e){Q({messages:H.messages.map(t=>t.id===e?{...t,stopped:true}:t)})},finishAssistant(e){Q({messages:H.messages.map(t=>t.id===e?{...t,streaming:false,endedAt:_t()}:t),busy:false,stopping:false})},askApproval(e){return new Promise(t=>{Q({pending:{...e,resolve:t}})})},answerApproval(e){let t=H.pending,o=typeof e=="boolean"?e:e.approved,r=typeof e!="boolean"&&e.trust===true&&o,n=t?`${t.toolId}.${t.action}`:"";Q({pending:null,...r&&t&&!H.trusted.some(i=>i.key===n)?{trusted:[...H.trusted,{key:n,label:t.label}]}:{}}),t?.resolve(e)},untrust(e){Ao?.session.untrust(e),Q({trusted:H.trusted.filter(t=>t.key!==e)})},restorePending(e){return H.pending||H.busy?false:(Q({pending:{...e,restored:true,resolve:()=>{}}}),true)},addNote(e){Q({messages:[...H.messages,{id:ao(),role:"assistant",text:e,toolCalls:[],blocks:[],endedAt:_t()}]})},hydrate(e){return H.messages.length>0||H.busy?false:(Q({messages:e.messages.map(t=>({...t,restored:true})),answers:e.answers,usage:e.usage,queued:e.queued??[]}),true)},reset(){H.pending?.resolve(false),Q({messages:[],busy:false,stopping:false,pending:null,trusted:[],notice:null,answers:{},awaitingBlockId:null,actionState:{},queued:[],draft:null,usage:{input:0,output:0,requests:0}})}};function gn(e){return e.pending?"awaitingApproval":e.busy?e.stopping?"stopping":"running":e.awaitingBlockId?"awaitingAnswer":"idle"}function fn(e){let t=gn(e);if(t==="running"||t==="stopping")return null;if(t==="awaitingApproval")return"Paused \u2014 answer the approval above first.";if(t==="awaitingAnswer")return"Paused \u2014 answer the question above first.";let o=e.messages[e.messages.length-1];return o?.role==="assistant"&&o.error?"Paused \u2014 the last turn failed.":o?.role==="assistant"&&o.stopped?"Paused \u2014 you stopped the last turn.":null}import{getUseIsPro as gc,hasAccountAccess as Ut,subscribeAccountAccess as fc}from"@buoy-gg/shared-ui/web";import{useCallback as Re,useEffect as gt,useMemo as bc,useRef as Tt,useState as yc,useSyncExternalStore as mc}from"react";import{dispatchToolAction as bn,listSnapshotToolIds as xc,listToolActions as kc,readToolSnapshot as wc,waitForToolRegistry as yn}from"@buoy-gg/shared-ui/web";import{answerToText as mn,CATALOG as Bo,createAskBuoySession as vc,readTargetDigest as Sc,runGatedAction as xn,SNAPSHOT_ACTION as kn}from"@buoy-gg/agent-core/web";import{persistentStorage as Ho,devToolsStorageKeys as Tc}from"@buoy-gg/shared-ui/web";import{dispatchToolAction as wn}from"@buoy-gg/shared-ui/web";var Cc=[{re:/\bBearer\s+[A-Za-z0-9._~+/-]{12,}=*/gi,label:"[bearer token removed]"},{re:/\beyJ[A-Za-z0-9._-]{20,}/g,label:"[jwt removed]"},{re:/\bsk-[A-Za-z0-9_-]{16,}/g,label:"[api key removed]"},{re:/\bBUOY-[A-Z0-9-]{8,}/g,label:"[license key removed]"},{re:/("|')?(authorization|x-api-key|api[_-]?key|password|secret|access_token|refresh_token)\1?\s*[:=]\s*("|')?(?!(?:authorization|bearer|cookie|header)\b)[^\s"',}]{6,}/gi,label:"[credential removed]"}];function Kt(e){if(!e)return e;let t=e;for(let{re:o,label:r}of Cc)t=t.replace(o,r);return t}var Lo=`${Tc.base}_ask_buoy_transcript`,Oo=1,vn=60,Ic=256e3,zc="[not kept across a restart \u2014 read it again if you need it]";function it(e){return e&&Kt(e)}function Dc(e){let t=e.streaming===true;return{...e,text:it(e.text),streaming:false,reasoning:e.reasoning?.map(o=>({...o,text:it(o.text)})),toolCalls:e.toolCalls.map(o=>{let r=o.params?it(o.params):void 0,{result:n,...i}=o;return o.status==="running"?{...i,params:r,status:"failed",summary:"Interrupted"}:{...i,params:r}}),error:e.error??(t&&!e.text?"This answer was interrupted \u2014 the app restarted mid-turn.":void 0)}}function Rc(e){return e.map(t=>t.role==="tool-results"?{...t,results:t.results.map(o=>({...o,content:zc}))}:t.role==="assistant"?{...t,text:it(t.text)}:{...t,text:it(t.text)})}function $c(e){let t={...e,messages:e.messages.slice(-vn),history:e.history.slice(-vn*2)},o=JSON.stringify(t);for(;o.length>Ic&&t.messages.length>1;)t={...t,messages:t.messages.slice(1),history:t.history.slice(Math.min(2,t.history.length))},o=JSON.stringify(t);return t}function Ac(e){if(!e)return null;let t=e.params;if(!t)return null;let o;try{o=JSON.stringify(t)}catch{return null}return Kt(o)!==o?null:{id:e.id,toolId:e.toolId,action:e.action,label:it(e.label),description:e.description?it(e.description):void 0,reason:it(e.reason),params:t,targetDigest:e.targetDigest}}function Bc(e){if(typeof e!="object"||e===null)return false;let t=e;return typeof t.id=="string"&&typeof t.toolId=="string"&&typeof t.action=="string"&&typeof t.label=="string"&&typeof t.reason=="string"&&typeof t.params=="object"&&t.params!==null}function Hc(e){if(!e?.length)return;let t=e.filter(o=>{try{let r=JSON.stringify(o);return Kt(r)===r}catch{return false}});return t.length?t:void 0}function Lc(e){return $c({v:Oo,savedAt:Date.now(),messages:e.messages.map(Dc),history:Rc(e.history),answers:e.answers,usage:e.usage,pending:Ac(e.pending),ledger:Hc(e.ledger),queued:e.queued?.length?e.queued.map(t=>({id:t.id,text:it(t.text)})):void 0})}function Oc(e){if(!e)return null;try{let t=JSON.parse(e);return t?.v!==Oo||!Array.isArray(t.messages)||t.messages.length===0?null:{v:Oo,savedAt:typeof t.savedAt=="number"?t.savedAt:0,messages:t.messages,history:Array.isArray(t.history)?t.history:[],answers:t.answers??{},usage:t.usage??{input:0,output:0,requests:0},pending:Bc(t.pending)?t.pending:null,ledger:Array.isArray(t.ledger)?t.ledger.filter(o=>typeof o=="object"&&o!==null&&typeof o.id=="string"):void 0,queued:Array.isArray(t.queued)?t.queued.filter(o=>typeof o=="object"&&o!==null&&typeof o.id=="string"&&typeof o.text=="string"):void 0}}catch{return null}}async function Pc(){try{return Oc(await Ho.getItem(Lo))}catch{return null}}async function Wc(e){try{await Ho.setItem(Lo,JSON.stringify(e))}catch{}}async function Ec(){try{await Ho.removeItem(Lo)}catch{}}function Po(){y.getHeldSession()?.session.reset(),y.reset(),Ec()}async function Sn(e){if(y.getState().busy)return{cleared:false,reverted:0,failed:[{label:"A turn is running",error:"Stop it first."}]};let t=y.getLedger();if(e.undoFirst&&t){let o=await t.revertAll(e.dispatch);return o.failed.length>0?{cleared:false,reverted:o.reverted,failed:o.failed}:(Po(),{cleared:true,reverted:o.reverted,failed:[]})}return Po(),{cleared:true,reverted:0,failed:[]}}var Gt=typeof Zt<"u"&&!Zt;function Vc(e){for(let t of y.getState().messages)if(t.restored)for(let o of t.blocks){let r=o.block;if(r?.id!==e)continue;let n=r.question??r.label??r.title;return typeof n=="string"&&n.trim()?n.trim():void 0}}function Tn(){try{let e=kc();for(let t of xc())e[t]||(e[t]=[]),e[t].includes(kn)||(e[t]=[kn,...e[t]]);return e}catch{return{}}}var Nc=600;function Wo(){return mc(y.subscribe,y.getState,y.getState)}function Cn(e){let t=Wo(),o=gc()(),r=Tt(o);r.current=o;let n=Re((...T)=>!Ut()||!r.current?Promise.reject(new Error("Ask Buoy requires Pro access.")):bn(...T),[]),i=Tt(null),a=Tt(false),h=Tt(null),u=Tt(e);u.current=e;let g=!!e?.endpoint&&!!e?.model,f=e?.persistTranscript!==false,{bypassApprovals:S,readOnly:j}=Ht(),q=Tt(S);q.current=S;let X=Tt(j);X.current=j;let ee=Re(()=>X.current?{...e?.policy??{},readOnly:true}:e?.policy??{},[e]),[ke,Je]=yc(0);gt(()=>{let T=false;return yn().then(()=>{T||Je(V=>V+1)}),()=>{T=true}},[]);let $e=bc(()=>Tn(),[ke]),Qe=Object.keys($e).sort().join(",");gt(()=>{if(y.setConfigured(g),y.setMeta({model:e?.model,protocol:e?.protocol??(e?"anthropic":void 0),appName:e?.appName,platform:we.OS,build:Gt?"release":"development"}),!g||!e){i.current=null,y.setNotice("Ask Buoy isn't set up in this app yet. A developer needs to point it at your team's AI endpoint.");return}let T=e.protocol??"anthropic";Gt&&e.apiKey?y.setNotice("This build carries a plaintext apiKey \u2014 that's dev-only and it ships to every install. Use the headers callback with your own gateway for distributed builds."):T==="anthropic"&&/^https?:\/\/api\.openai\.com\//i.test(e.endpoint)?y.setNotice('This endpoint is api.openai.com but the protocol is "anthropic". Set protocol: "openai" in the askBuoy config.'):T==="openai"&&/^https?:\/\/api\.anthropic\.com\//i.test(e.endpoint)?y.setNotice('This endpoint is api.anthropic.com but the protocol is "openai". Remove protocol or set it to "anthropic".'):y.setNotice(null),y.setReporter(e.reportProblem??null),y.setUsageReader(e.readUsage??null);let V=[e.endpoint,e.protocol??"anthropic",e.model].join("|"),_=y.getHeldSession();if(_&&_.signature===V){i.current=_.session,_.session.setAvailableActions($e),_.session.setApprovalBypass(q.current),_.session.setReadOnly(X.current),y.setLedger(_.session.ledger);return}let ne=vc({endpoint:e.endpoint,protocol:e.protocol??"anthropic",model:e.model,headers:e.headers,apiKey:e.apiKey,maxTokens:e.maxTokens,anthropicVersion:e.anthropicVersion,requestOverrides:e.requestOverrides,hosted:e.hosted===true,catalog:e.tools?.length?[...Bo,...e.tools]:void 0,dispatch:n,readSnapshot:wc,availableActions:$e,policy:e.policy,context:e.context,isRelease:Gt,appName:e.appName,platform:we.OS,requestApproval:te=>y.askApproval(te)});i.current=ne,ne.setApprovalBypass(q.current),ne.setReadOnly(X.current),y.holdSession(ne,V),y.setLedger(ne.ledger);let Te=false;return yn().then(te=>{te&&!Te&&ne.prime()}),f&&!a.current&&(a.current=true,Pc().then(te=>{!te||!y.hydrate({messages:te.messages,answers:te.answers,usage:te.usage,queued:te.queued})||(i.current?.restore(te.history),te.ledger?.length&&i.current?.ledger.restore(te.ledger),te.pending&&y.restorePending(te.pending))})),()=>{Te=true}},[g,e,$e,Qe,f]),gt(()=>{i.current?.setApprovalBypass(S)},[S]),gt(()=>{i.current?.setReadOnly(j)},[j]);let Ye=t.messages,bt=t.answers,yt=t.usage,zt=t.busy,Ne=t.pending,st=t.queued;gt(()=>{if(!f||Ye.length===0)return;let T=()=>{Wc(Lc({messages:Ye,history:i.current?.messages??[],answers:bt,usage:yt,pending:Ne,ledger:y.getLedger()?.list(),queued:st}))};if(!zt||Ne){T();return}let V=setTimeout(T,Nc);return()=>clearTimeout(V)},[f,zt,Ye,bt,yt,Ne,st]);let ct=Re(T=>{if(!Ut()||!r.current)return;let V=i.current;if(!V)return;y.beginTurn();let _=y.startAssistant(),ne=new AbortController;h.current=ne,V.setAvailableActions(Tn());let Te=u.current?.onEvent;(async()=>{try{for await(let te of V.send(T,ne.signal))if(y.applyEvent(_,te),Te)try{Te(te)}catch{}}catch(te){ne.signal.aborted||y.applyEvent(_,{type:"error",message:te instanceof Error?te.message:"Something went wrong talking to your AI endpoint."})}finally{ne.signal.aborted&&y.markStopped(_),y.finishAssistant(_),h.current=null}})()},[]),Xe=Re(T=>{if(!Ut()||!r.current)return;let V=T.trim();if(!i.current||!V)return;if(y.getState().busy){y.enqueue(V);return}let _=y.getState().awaitingBlockId;_&&y.recordAnswer({blockId:_,kind:"skipped"}),y.addUser(V),ct(V)},[ct]),mt=Re(()=>{let{messages:T,busy:V}=y.getState();if(V||!i.current)return;let _=[...T].reverse().find(ne=>ne.role==="user");_&&ct(_.text)},[ct]),Ze=Re(()=>{y.requestStop(),y.getState().pending&&y.answerApproval(false),h.current?.abort(),h.current=null},[]);gt(()=>{let T=fc(()=>{Ut()||Ze()});return()=>{T(),Ze()}},[Ze]),gt(()=>{o||Ze()},[o,Ze]),gt(()=>{if(t.queued.length===0||gn(t)!=="idle"||fn(t)!==null)return;let T=y.shiftQueued();T&&Xe(T.text)},[t,Xe]);let ze=Re(T=>y.takeQueuedToDraft(T),[]),Dt=Re(T=>y.removeQueued(T),[]),Qt=Re(()=>{h.current?.abort(),h.current=null,Po()},[]),co=Re(()=>Sn({dispatch:bn,undoFirst:true}),[]),Yt=Re(async T=>{let V=y.getLedger();if(!V){y.setNotice(`${T.label} couldn't run \u2014 no active Ask Buoy session.`);return}let _=e?.tools?.length?[...Bo,...e.tools]:void 0;if(T.targetDigest){let Te=await Sc({toolId:T.toolId,action:T.action,params:T.params??{},dispatch:n,catalog:_});if(Te!==void 0&&Te!==T.targetDigest){y.addNote(`\u201C${T.label}\u201D wasn't applied \u2014 what it would change has moved on since the app restarted. Nothing was written. Ask again if you still want it.`);return}}let ne=await xn({toolId:T.toolId,action:T.action,params:T.params??{},dispatch:n,ledger:V,policy:ee(),isRelease:Gt,catalog:_});ne.ok?y.addNote(`Applied \u201C${T.label}\u201D, which was still waiting when the app restarted. Whatever else that answer was going to do is gone \u2014 ask again if there was more to it.`):y.setNotice(`${T.label} failed \u2014 ${ne.error}`)},[e,ee]),uo=Re(T=>{let V=y.getState().pending,_=typeof T=="boolean"?T:T.approved;if(y.answerApproval(T),!!V?.restored){if(!_){y.addNote(`Skipped \u201C${V.label}\u201D. Nothing was changed.`);return}Yt(V)}},[Yt]),po=Re(T=>{y.recordAnswer(T);let V=Vc(T.blockId);Xe(V?`${V} \u2014 ${mn(T)}`:mn(T))},[Xe]),ho=Re(async(T,V)=>{if(!Ut()||!r.current){y.setNotice("Ask Buoy requires Pro access.");return}if(T.send){Xe(T.send);return}if(!T.dispatch)return;let _=`${V}:${T.label}`,ne=y.getLedger();if(!ne){y.setNotice(`${T.label} failed \u2014 no active Ask Buoy session.`);return}y.setActionState(_,"running");let Te=await xn({toolId:T.dispatch.toolId,action:T.dispatch.action,params:T.dispatch.params??{},dispatch:n,ledger:ne,policy:ee(),isRelease:Gt,catalog:e?.tools?.length?[...Bo,...e.tools]:void 0});Te.ok?y.setActionState(_,"done"):(y.setActionState(_,"failed"),y.setNotice(`${T.label} failed \u2014 ${Te.error}`))},[Xe,e,ee]);return{state:t,send:Xe,stop:Ze,reset:Qt,undoThenReset:co,approve:uo,retry:mt,answer:po,runAction:ho,editQueued:ze,removeQueued:Dt,configured:g,toolCount:Object.keys($e).length,availableToolIds:Object.keys($e)}}import{Fragment as jc,jsx as ue,jsxs as lt}from"react/jsx-runtime";function In(){let e=Ht(),t=Wo().trusted;return lt(_e,{style:re.scroll,contentContainerStyle:re.content,testID:"buoy-ask-buoy-settings",children:[ue(qc,{}),ue(l,{style:re.section,children:"CHAT"}),ue(Co,{testID:"buoy-ask-buoy-setting-thinking",label:"Show agent thinking",description:"Adds a collapsed strip under each answer: the model's reasoning, and every step it ran with its parameters, result, duration and token cost. Copy includes the steps and reasoning while this is on, so you can read the run outside the app.",value:e.showThinking,onValueChange:o=>ht.set("showThinking",o)}),ue(l,{style:re.note,children:"Not every model reports reasoning. Claude thinks by default; most OpenAI models return none, and the strip then shows the steps alone."}),ue(l,{style:re.section,children:"PERMISSIONS"}),ue(Co,{testID:"buoy-ask-buoy-setting-readonly",label:"Read only",description:"Inspect the app, change nothing. Every write and simulation is refused until this is off. Undo still works \u2014 putting things back is the safe direction.",value:e.readOnly,onValueChange:o=>ht.set("readOnly",o)}),e.readOnly?ue(l,{style:re.note,testID:"buoy-ask-buoy-readonly-note",children:"On across reloads until you turn it off here. The header says \u201CRead only\u201D while it is on. It adds to whatever this app already restricts \u2014 it never loosens anything."}):null,ue(Co,{testID:"buoy-ask-buoy-setting-bypass",tone:"warning",emphasizeLabel:e.bypassApprovals,disabled:e.readOnly,label:"Skip approval prompts",description:e.readOnly?"Unavailable while Read only is on \u2014 nothing can be approved.":"Runs every action the moment the agent calls it, with no Allow card \u2014 including the destructive ones that wipe or reset data.",value:e.bypassApprovals,onValueChange:o=>ht.set("bypassApprovals",o)}),e.bypassApprovals&&!e.readOnly?lt(s,{style:re.warning,testID:"buoy-ask-buoy-bypass-warning",children:[ue(sc,{size:14,color:de.color.warning}),ue(l,{style:re.warningText,children:"Nothing will ask before a change lands. A wipe or a reset runs on the model's word alone, and Undo only reverses the changes that can be reversed \u2014 the bar tells you which. This stays on across reloads and app restarts until you turn it off here, so leave it off on any device holding data you care about. It does not widen what the agent may reach: read-only mode, this app's deny list and the release-build refusals still apply."})]}):ue(l,{style:re.note,children:"On by default for destructive actions only \u2014 reads and ordinary writes already run without asking, and the changes bar records them."}),t.length>0?lt(s,{style:re.trustedBox,testID:"buoy-ask-buoy-trusted",children:[ue(l,{style:re.section,children:"ALLOWED WITHOUT ASKING \u2014 THIS CHAT"}),t.map(o=>lt(s,{style:re.trustedRow,children:[ue(l,{style:re.trustedLabel,numberOfLines:2,children:o.label}),ue(m,{testID:`buoy-ask-buoy-untrust-${o.key}`,accessibilityRole:"button",onPress:()=>y.untrust(o.key),style:({pressed:r})=>[re.forget,r&&{opacity:.7}],hitSlop:6,children:ue(l,{style:re.forgetText,children:"Ask again"})})]},o.key))]}):null]})}function Mc(e){let t=Date.parse(e.length===10?`${e}T00:00:00Z`:e);if(Number.isNaN(t))return e;let o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=new Date(t);return`${o[r.getUTCMonth()]} ${r.getUTCDate()}`}function qc(){let e=y.getUsageReader(),[t,o]=ac({kind:"loading"}),r=ic(()=>{e&&(o({kind:"loading"}),e().then(n=>o({kind:"ok",usage:n})).catch(n=>o({kind:"error",message:n instanceof Error?n.message:"Could not load credits."})))},[e]);return lc(r,[r]),e?lt(s,{testID:"buoy-ask-buoy-credits",children:[ue(l,{style:re.section,children:"HOSTED AI CREDITS"}),lt(s,{style:re.trustedRow,children:[ue(s,{style:{flex:1,gap:2},children:t.kind==="ok"?lt(jc,{children:[lt(l,{style:re.trustedLabel,children:[t.usage.creditsLeft.toLocaleString()," of ",t.usage.grantCredits.toLocaleString()," credits left"]}),lt(l,{style:re.note,children:[t.usage.resetAt?`Resets ${Mc(t.usage.resetAt)}. `:"","1 credit is $0.001 of AI use, included with your plan."]})]}):t.kind==="error"?ue(l,{style:re.note,children:t.message}):ue(l,{style:re.note,children:"Loading\u2026"})}),ue(m,{testID:"buoy-ask-buoy-credits-refresh",accessibilityRole:"button",onPress:r,style:({pressed:n})=>[re.forget,n&&{opacity:.7}],hitSlop:6,children:ue(l,{style:re.forgetText,children:"Refresh"})})]})]}):null}var re=w.create({scroll:{flex:1},content:{padding:de.gutter,gap:10,paddingBottom:32},section:{color:de.color.textTertiary,fontSize:10,fontWeight:"700",letterSpacing:.6,paddingHorizontal:4,paddingTop:4},warning:{flexDirection:"row",gap:8,padding:de.cardPad,borderRadius:de.radius.card,borderWidth:w.hairlineWidth,borderColor:de.color.warning,backgroundColor:de.color.surface},warningText:{flex:1,color:de.color.warning,fontSize:de.font.micro,lineHeight:16},trustedBox:{gap:6,paddingTop:6},trustedRow:{flexDirection:"row",alignItems:"center",gap:10,padding:de.cardPad,borderRadius:de.radius.card,borderWidth:w.hairlineWidth,borderColor:de.color.border,backgroundColor:de.color.surface},trustedLabel:{flex:1,color:de.color.text,fontSize:de.font.caption,lineHeight:18},forget:{paddingHorizontal:10,paddingVertical:6,borderRadius:de.radius.row,backgroundColor:de.color.button},forgetText:{color:de.color.text,fontSize:de.font.micro,fontWeight:"600"},note:{color:de.color.textTertiary,fontSize:de.font.micro,lineHeight:16,paddingHorizontal:4}});import{monoFont as Fc}from"@buoy-gg/shared-ui/web";import{ChevronRight as _c,night as Se,NightSectionLabel as Uc}from"@buoy-gg/shared-ui/web";var Kc=[{text:"Why is this screen empty?"},{text:"What did the last few network calls return?",needs:"network"},{text:"Show me what's saved for this user",needs:"storage"},{text:"Make the next request to this screen fail with a 500",needs:"network",write:true,devOnly:true},{text:"Who am I signed in as right now?"},{text:"Did anything crash or log an error recently?",needs:"console"}],Gc=4;function Jc(e){let t=e.availableToolIds.length>0;return Kc.filter(o=>o.write&&e.readOnly||o.devOnly&&e.isRelease?false:o.needs?t&&e.availableToolIds.includes(o.needs):true).slice(0,Gc).map(o=>o.text)}import{jsx as qe,jsxs as Jt}from"react/jsx-runtime";var zn=typeof Zt<"u"&&!Zt;function Qc({configured:e,onPick:t,availableToolIds:o=[],readOnly:r=false}){let n=Jc({availableToolIds:o,readOnly:r,isRelease:zn});return e?Jt(s,{style:Ie.wrap,testID:"buoy-ask-buoy-empty",children:[qe(l,{style:Ie.title,children:"Ask about this app"}),qe(l,{style:Ie.body,children:"Ask what the app is doing right now, or tell it to change something. Anything it changes shows up in a bar at the top, with what can be undone."}),qe(l,{style:Ie.buildLine,testID:"buoy-ask-buoy-build-line",children:zn?"Release build \u2014 reading, impersonation and navigation work; simulations (forcing server responses, driving the screen) need a dev build.":"Dev build \u2014 full simulation available."}),Jt(s,{style:Ie.group,children:[qe(Uc,{children:"Try asking"}),qe(s,{style:Ie.card,children:n.map((i,a)=>qe(Yc,{text:i,onPick:t,last:a===n.length-1},i))})]})]}):Jt(s,{style:Ie.wrap,testID:"buoy-ask-buoy-unconfigured",children:[qe(l,{style:Ie.title,children:"Not set up yet"}),Jt(l,{style:Ie.body,children:["Ask Buoy talks to your own company's AI endpoint \u2014 nothing goes to Buoy. A developer needs to add the ",qe(l,{style:Ie.code,children:"askBuoy"})," prop to"," ",qe(l,{style:Ie.code,children:"<FloatingDevTools />"})," with your team's endpoint and model."]})]})}function Yc({text:e,onPick:t,last:o}){return Jt(m,{testID:`buoy-ask-buoy-suggestion-${e.slice(0,12)}`,accessibilityRole:"button",onPress:()=>t(e),style:({pressed:r})=>[Ie.row,!o&&Ie.rowDivider,r&&Ie.pressed],children:[qe(l,{style:Ie.rowText,children:e}),qe(_c,{size:14,color:Se.color.textTertiary})]})}var Ie=w.create({wrap:{flex:1,justifyContent:"center",paddingHorizontal:Se.gutter,paddingVertical:24,gap:8},title:{color:Se.color.text,fontSize:22,fontWeight:"700",letterSpacing:-.3},body:{color:Se.color.textSecondary,fontSize:Se.font.body,lineHeight:20},code:{color:Se.color.text,fontFamily:we.OS==="web"?Fc:"Menlo"},buildLine:{marginTop:8,color:Se.color.textTertiary,fontSize:Se.font.micro,lineHeight:15},group:{marginTop:Se.groupGap-8},card:{borderRadius:Se.radius.card,borderWidth:w.hairlineWidth,borderColor:Se.color.border,backgroundColor:Se.color.surface,overflow:"hidden"},row:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:Se.rowPadH,paddingVertical:13},rowDivider:{borderBottomWidth:w.hairlineWidth,borderBottomColor:Se.color.separator},rowText:{flex:1,color:Se.color.text,fontSize:Se.font.body,lineHeight:19},pressed:{backgroundColor:Se.color.fill}});import{memo as Xc,useCallback as Ct,useEffect as Zc,useRef as Eo,useState as Vo}from"react";import{AlertTriangle as No,Check as Dn,ChevronDown as Rn,ChevronRight as $n,Copy as ed,night as k,X as td}from"@buoy-gg/shared-ui/web";import{toolTitle as od}from"@buoy-gg/agent-core/web";import{isAskBlock as rd}from"@buoy-gg/agent-core/web";function nd({block:e,forToolCallId:t}){if(!t)return false;let o="source"in e?e.source:void 0;return o==="live"||o==="mocked"}function id(e,t){let o=new Set(t),r=new Map,n=[],i=[];for(let a of e){if(rd(a.block)){i.push(a);continue}if(nd(a)&&o.has(a.forToolCallId)){let h=r.get(a.forToolCallId)??[];h.push(a.block),r.set(a.forToolCallId,h)}else n.push(a)}return{nested:r,afterText:n,ask:i}}import{useState as An}from"react";import{Activity as ld,ChevronDown as ad,ChevronRight as sd,night as Y}from"@buoy-gg/shared-ui/web";function jo(e){let t=[...e.reasoning??[]].sort((i,a)=>i.afterCalls-a.afterCalls),o=[],r=0,n=i=>{for(;r<t.length&&t[r].afterCalls<=i;)o.push({kind:"thought",text:t[r].text}),r+=1};return e.toolCalls.forEach((i,a)=>{n(a),o.push({kind:"step",n:a+1,call:i})}),n(e.toolCalls.length),o}function Bn(e){return(e.reasoning?.length??0)>0||e.toolCalls.length>0}var cd=e=>e.status==="ok"?e.summary||"done":e.status==="running"?"running":`${e.status}${e.summary?` \u2014 ${e.summary}`:""}`;function Hn(e,t=" "){let o=[];for(let r of jo(e))if(r.kind==="thought"){o.push(`${t}[thinking]`);for(let n of r.text.trim().split(`
|
|
11
|
-
`))o.push(`${t} ${n}`)}else{let{n,call:i}=r;o.push(`${t}[${n}] ${i.toolId}.${i.action} \u2014 ${cd(i)}`),i.params&&o.push(`${t} ${i.params}`)}return o}import{Fragment as dd,jsx as Le,jsxs as at}from"react/jsx-runtime";function ud({n:e,call:t}){let[o,r]=An(false),n=t.status==="failed"||t.status==="refused";return at(m,{onPress:()=>r(i=>!i),accessibilityRole:"button",accessibilityState:{expanded:o},style:fe.step,children:[at(s,{style:fe.stepLine,children:[Le(l,{style:fe.stepN,children:e}),at(l,{style:[fe.stepName,n&&fe.stepFailed],numberOfLines:1,children:[t.toolId,".",t.action]}),t.durationMs!==void 0?at(l,{style:fe.stepMs,children:[t.durationMs,"ms"]}):null,Le(l,{style:[fe.stepStatus,n&&fe.stepFailed],numberOfLines:1,children:t.status==="ok"?t.summary||"done":t.status})]}),o?at(s,{style:fe.detail,children:[Le(l,{style:fe.detailLabel,children:"SENT"}),Le(l,{style:fe.code,selectable:true,children:t.params??"no parameters"}),t.result?at(dd,{children:[Le(l,{style:fe.detailLabel,children:"RETURNED"}),Le(l,{style:fe.code,selectable:true,children:t.result})]}):null]}):null]})}function Ln({message:e}){let[t,o]=An(false);if(!Bn(e))return null;let r=jo(e),n=r.filter(u=>u.kind==="step").length,i=r.length-n,a=e.startedAt!==void 0&&e.endedAt!==void 0?`${((e.endedAt-e.startedAt)/1e3).toFixed(1)}s`:null,h=[n?`${n} step${n===1?"":"s"}`:null,i?`${i} thought${i===1?"":"s"}`:null,a,e.usage?`${e.usage.input+e.usage.output} tokens`:null].filter(Boolean).join(" \xB7 ");return at(s,{style:fe.wrap,testID:"buoy-ask-buoy-thinking",children:[at(m,{testID:"buoy-ask-buoy-thinking-toggle",onPress:()=>o(u=>!u),accessibilityRole:"button",accessibilityLabel:t?"Hide agent thinking":"Show agent thinking",accessibilityState:{expanded:t},style:fe.head,children:[Le(ld,{size:12,color:Y.color.textTertiary}),Le(l,{style:fe.headText,children:h}),t?Le(ad,{size:12,color:Y.color.textTertiary}):Le(sd,{size:12,color:Y.color.textTertiary})]}),t?at(s,{style:fe.body,children:[r.map((u,g)=>u.kind==="thought"?Le(l,{style:fe.thought,selectable:true,children:u.text.trim()},`t${g}`):Le(ud,{n:u.n,call:u.call},u.call.id)),i===0?Le(l,{style:fe.none,children:"This model reports no reasoning \u2014 the steps above are the whole trace."}):null]}):null]})}var fe=w.create({wrap:{marginTop:8,borderRadius:Y.radius.badge,borderWidth:w.hairlineWidth,borderColor:Y.color.separator,backgroundColor:Y.color.fill,overflow:"hidden"},head:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:7},headText:{flex:1,color:Y.color.textTertiary,fontSize:Y.font.micro,fontWeight:"600"},body:{borderTopWidth:w.hairlineWidth,borderTopColor:Y.color.separator},thought:{color:Y.color.textSecondary,fontSize:Y.font.micro,lineHeight:17,fontStyle:"italic",paddingHorizontal:10,paddingVertical:8},step:{paddingHorizontal:10,paddingVertical:7},stepLine:{flexDirection:"row",alignItems:"center",gap:8},stepN:{color:Y.color.textTertiary,fontSize:Y.font.micro,width:14},stepName:{flex:1,color:Y.color.textSecondary,fontSize:Y.font.micro,fontWeight:"600"},stepMs:{color:Y.color.textTertiary,fontSize:Y.font.micro},stepStatus:{color:Y.color.textTertiary,fontSize:Y.font.micro,maxWidth:110},stepFailed:{color:Y.color.danger},detail:{marginTop:6,marginLeft:22,gap:3},detailLabel:{color:Y.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5},code:{color:Y.color.textSecondary,fontSize:Y.font.micro,lineHeight:16,marginBottom:3},none:{color:Y.color.textTertiary,fontSize:Y.font.micro,fontStyle:"italic",paddingHorizontal:10,paddingVertical:8}});import{useEffect as pd,useRef as hd}from"react";import{night as gd}from"@buoy-gg/shared-ui/web";import{jsx as On}from"react/jsx-runtime";function fd(){let e=hd([0,1,2].map(()=>new ce.Value(.25))).current;return pd(()=>{let t=e.map((o,r)=>ce.loop(ce.sequence([ce.delay(r*140),ce.timing(o,{toValue:1,duration:320,easing:$t.inOut($t.ease),useNativeDriver:true}),ce.timing(o,{toValue:.25,duration:320,easing:$t.inOut($t.ease),useNativeDriver:true}),ce.delay((2-r)*140)])));return t.forEach(o=>o.start()),()=>t.forEach(o=>o.stop())},[e]),On(s,{style:Pn.wrap,testID:"buoy-ask-buoy-typing",accessibilityLabel:"Thinking",children:e.map((t,o)=>On(ce.View,{style:[Pn.dot,{opacity:t}]},o))})}var Pn=w.create({wrap:{flexDirection:"row",alignItems:"center",gap:5,paddingVertical:8,paddingHorizontal:2},dot:{width:7,height:7,borderRadius:4,backgroundColor:gd.color.textSecondary}});import{jsx as x,jsxs as be}from"react/jsx-runtime";function Wn({status:e}){switch(e){case"running":return x(Nt,{size:"small",color:k.color.textSecondary});case"ok":return x(s,{style:[b.mark,b.markOk],children:x(Dn,{size:10,color:k.color.onAccent})});case"failed":return x(s,{style:[b.mark,b.markFailed],children:x(td,{size:10,color:k.color.text})});case"refused":return x(s,{style:[b.mark,b.markRefused],children:x(No,{size:10,color:k.color.onAccent})});case"declined":case"stopped":return x(s,{style:[b.mark,b.markNotRun],children:x(s,{style:b.markNotRunBar})})}}function bd(e){return e.status==="running"?{text:"",tone:"muted"}:e.status==="refused"?{text:"Refused",tone:"warning"}:e.status==="failed"?{text:"Failed",tone:"danger"}:e.status==="declined"?{text:"You declined",tone:"muted"}:e.status==="stopped"?{text:"Not run \u2014 stopped",tone:"muted"}:e.verification?.status==="verified"?{text:"Verified",tone:"ok"}:e.verification?.status==="unverified"?{text:"Done \xB7 not yet visible",tone:"muted"}:e.verification?.status==="failed"?{text:"Done \xB7 check failed",tone:"warning"}:{text:e.summary||"Done",tone:"muted"}}var yd=e=>e.status==="failed"||e.status==="refused"||e.status==="declined"||e.status==="stopped";function En({call:e,receipts:t,last:o}){let[r,n]=Vo(false),i=bd(e),a=r?Rn:$n,h=e.status==="failed"&&e.summary&&e.summary!=="Failed"?e.summary:null;return be(s,{style:[b.row,!o&&b.rowDivider],children:[be(m,{testID:`buoy-ask-buoy-tool-${e.toolId}`,accessibilityRole:"button",accessibilityLabel:`${e.label}, ${i.text||"running"}`,accessibilityState:{expanded:r},onPress:()=>n(u=>!u),children:[be(s,{style:b.rowLine,children:[x(s,{style:b.markSlot,children:x(Wn,{status:e.status})}),x(l,{style:b.rowTitle,children:e.label}),i.text?x(l,{style:[b.rowStatus,i.tone==="danger"&&b.rowStatusDanger,i.tone==="warning"&&b.rowStatusWarning,i.tone==="ok"&&b.rowStatusOk],numberOfLines:1,children:i.text}):null,x(a,{size:12,color:k.color.textTertiary})]}),r&&be(s,{style:b.rowDetail,children:[x(l,{style:b.rowTool,children:od(e.toolId).toUpperCase()}),e.description?x(l,{style:b.rowDescription,children:e.description}):null,h?x(l,{style:b.rowFailure,children:h}):null,e.verification?x(l,{style:[b.rowDescription,e.verification.status==="failed"&&b.rowFailure,e.verification.status==="verified"&&b.rowVerified],testID:`buoy-ask-buoy-verification-${e.verification.status}`,children:e.verification.detail}):null]})]}),r&&t.length>0&&x(s,{style:b.rowReceipts,testID:`buoy-ask-buoy-tool-receipt-${e.toolId}`,children:t.map(u=>x(io,{block:u},u.id))})]})}function md({label:e,count:t,calls:o,receipts:r,last:n}){let[i,a]=Vo(false),h=i?Rn:$n;return be(s,{style:!n&&!i&&b.rowDivider,children:[x(m,{testID:"buoy-ask-buoy-reads-group",accessibilityRole:"button",accessibilityLabel:`${e}, ${t} reads`,accessibilityState:{expanded:i},onPress:()=>a(u=>!u),style:[b.row,i&&b.rowDivider],children:be(s,{style:b.rowLine,children:[x(s,{style:b.markSlot,children:x(Wn,{status:"ok"})}),x(l,{style:b.rowTitle,children:e}),be(l,{style:b.rowStatus,numberOfLines:1,children:[t," reads"]}),x(h,{size:12,color:k.color.textTertiary})]})}),i&&x(s,{style:b.groupBody,children:o.map((u,g)=>x(En,{call:u,receipts:r.get(u.id)??[],last:n&&g===o.length-1},u.id))})]})}function xd({calls:e,receipts:t}){let o=ec(e);return x(s,{style:b.card,testID:"buoy-ask-buoy-activity",children:o.map((r,n)=>r.kind==="reads"?x(md,{label:r.label,count:r.count,calls:r.calls,receipts:t,last:n===o.length-1},r.id):x(En,{call:r.call,receipts:t.get(r.call.id)??[],last:n===o.length-1},r.call.id))})}function Vn({blocks:e}){return e.length===0?null:x(s,{style:b.blocks,children:e.map(({block:t})=>x(io,{block:t},t.id))})}function kd({message:e}){return x(s,{style:b.systemLine,testID:"buoy-ask-buoy-system-line",children:x(l,{style:b.systemText,children:e.text})})}function wd({message:e}){return x(s,{style:b.userWrap,children:x(s,{style:b.userBubble,children:x(l,{style:b.userText,selectable:true,children:e.text})})})}function vd({message:e,onRetry:t,waitingOnUser:o}){let{showThinking:r}=Ht(),n=!!e.streaming&&!o,{nested:i,afterText:a,ask:h}=id(e.blocks,e.toolCalls.map(u=>u.id));return be(s,{style:b.assistantWrap,children:[e.toolCalls.length>0&&x(xd,{calls:e.toolCalls,receipts:i}),e.text.length>0&&x(Ir,{text:e.text,style:b.assistantText}),x(Vn,{blocks:a}),x(Vn,{blocks:h}),r&&!e.streaming&&x(Ln,{message:e}),n&&be(s,{style:b.waitingRow,children:[x(fd,{}),e.waiting?x(l,{style:b.waitingText,testID:"buoy-ask-buoy-waiting",children:e.waiting}):null]}),e.error&&(e.errorInfo?x(Id,{error:e.error,info:e.errorInfo,onRetry:t}):x(Td,{error:e.error,onRetry:t})),e.stopped&&!e.error&&x(Sd,{onRetry:t,changed:e.toolCalls.some(u=>u.status==="ok"&&!!u.effect&&u.effect!=="read")})]})}function Sd({onRetry:e,changed:t}){return be(s,{style:b.stoppedBox,testID:"buoy-ask-buoy-stopped",children:[x(l,{style:b.stoppedText,children:t?"Stopped. Changes already made are listed above.":"Stopped."}),e&&x(m,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:e,style:({pressed:o})=>[b.retry,o&&b.retryPressed],children:x(l,{style:b.retryText,children:"Try again"})})]})}function Td({error:e,onRetry:t}){let o=/fetch failed|network|ECONN|timed? ?out|socket/i.test(e)?"Couldn't reach your AI endpoint. Check the connection and try again.":"Something went wrong with that turn.";return be(s,{style:b.errorBox,testID:"buoy-ask-buoy-error",children:[x(No,{size:14,color:k.color.danger}),be(s,{style:b.errorBody,children:[x(l,{style:b.errorText,children:o}),x(l,{style:b.errorDetail,selectable:true,children:e}),t&&x(m,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:t,style:({pressed:r})=>[b.retry,r&&b.retryPressed],children:x(l,{style:b.retryText,children:"Try again"})})]})]})}var Cd=new Set(["credits_out","member_cap","plan_not_eligible","not_in_pilot","team_hosted_off","account_frozen","token_not_allowed","client_too_old","media_not_allowed","session_missing","session_revoked"]);function Id({error:e,info:t,onRetry:o}){let[r,n]=Vo("idle"),i=`Ask Buoy error ${t.code}${t.requestId?` \xB7 request ${t.requestId}`:""} \xB7 ${new Date().toISOString()}`,{copied:a,copy:h}=oo(()=>i),u=y.getReporter(),g=Ct(()=>{u&&(n("sending"),u({requestId:t.requestId,code:t.code,note:"Reported from the error card."}).then(f=>n({id:f.reportId})).catch(()=>n("failed")))},[u,t.code,t.requestId]);return be(s,{style:b.errorBox,testID:"buoy-ask-buoy-error",children:[x(No,{size:14,color:k.color.danger}),be(s,{style:b.errorBody,children:[x(l,{style:b.errorText,children:e}),be(l,{style:b.errorDetail,selectable:true,testID:"buoy-ask-buoy-error-code",children:[t.code,t.requestId?` \xB7 ${t.requestId}`:""]}),be(s,{style:b.transcriptActions,children:[o&&!Cd.has(t.code)&&x(m,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:o,style:({pressed:f})=>[b.retry,f&&b.retryPressed],children:x(l,{style:b.retryText,children:"Try again"})}),x(m,{testID:"buoy-ask-buoy-error-copy",accessibilityRole:"button",accessibilityLabel:"Copy details",onPress:h,style:({pressed:f})=>[b.retry,f&&b.retryPressed],children:x(l,{style:b.retryText,children:a?"Copied":"Copy details"})}),u&&x(m,{testID:"buoy-ask-buoy-error-report",accessibilityRole:"button",accessibilityLabel:"Report problem",disabled:r!=="idle"&&r!=="failed",onPress:g,style:({pressed:f})=>[b.retry,f&&b.retryPressed],children:x(l,{style:b.retryText,children:r==="sending"?"Sending\u2026":r==="failed"?"Report failed. Try again":typeof r=="object"?`Reported \xB7 ${r.id}`:"Report problem"})})]})]})]})}function Nn(e,t=false){let o=[];for(let r of e){if(r.role==="user"){o.push(`You: ${r.text}`);continue}if(r.system){o.push(` \u2014 ${r.text}`);continue}if(t)o.push(...Hn(r));else for(let n of r.toolCalls){let i=yd(n)?` (${n.status})`:"";o.push(` \xB7 ${n.label}${n.summary?` \u2014 ${n.summary}`:""}${i}`)}r.text&&o.push(`Ask Buoy: ${r.text}`);for(let n of na(r.blocks.map(i=>i.block)))o.push(n);r.error&&o.push(` ! ${r.error}`),r.stopped&&!r.error&&o.push(" ! Stopped by the user.")}return o.join(`
|
|
12
|
-
`)}function zd({testID:e,label:t,getText:o}){let{copied:r,copy:n}=oo(o);return be(m,{testID:e,accessibilityRole:"button",accessibilityLabel:t,onPress:n,style:({pressed:i})=>[b.copyBtn,b.iconBtn,i&&b.copyPressed],children:[r?x(Dn,{size:11,color:k.color.accent}):x(ed,{size:11,color:k.color.textSecondary}),x(l,{style:[b.copyText,r&&b.copiedText],children:r?"Copied":t})]})}function Dd({message:e}){let{showThinking:t}=Ht(),o=Ct(()=>Nn(y.getState().messages,t),[t]),r=oc(e);return be(s,{style:b.transcriptActions,children:[r?x(l,{style:b.turnFooter,testID:"buoy-ask-buoy-turn-footer",children:r}):null,x(zd,{testID:"buoy-ask-buoy-copy",label:"Copy conversation",getText:o})]})}var Rd=Xc(function({message:e,onRetry:t,waitingOnUser:o}){if(e.role==="user")return x(wd,{message:e});if(e.system)return x(kd,{message:e});let r=!e.streaming&&!e.error;return be(s,{children:[x(vd,{message:e,onRetry:t,waitingOnUser:o}),r&&x(Dd,{message:e})]})});function jn({messages:e,ListHeaderComponent:t,ListEmptyComponent:o,ListFooterComponent:r,onRetry:n,waitingOnUser:i}){let a=Eo(null),h=Eo(true),u=Eo(false),g=Ct(ke=>{let{contentOffset:Je,contentSize:$e,layoutMeasurement:Qe}=ke.nativeEvent,Ye=$e.height-Qe.height-Je.y;h.current=Ye<80},[]),f=Ct(()=>{u.current=true},[]),S=Ct(ke=>{u.current&&g(ke)},[g]),j=Ct(ke=>{u.current=false,g(ke)},[g]),q=Ct(()=>{h.current&&(a.current?.scrollToEnd({animated:false}),requestAnimationFrame(()=>a.current?.scrollToEnd({animated:false})))},[]),X=e[e.length-1],ee=X?`${X.id}:${X.text.length}:${X.toolCalls.length}:${X.error??""}`:"";return Zc(()=>{q()},[ee,q]),x(nr,{ref:a,testID:"buoy-ask-buoy-messages-scroll",style:b.list,contentContainerStyle:b.listContent,data:e,keyExtractor:ke=>ke.id,renderItem:({item:ke})=>x(Rd,{message:ke,onRetry:ke.id===X?.id?n:void 0,waitingOnUser:ke.id===X?.id?i:false}),onScroll:S,onScrollBeginDrag:f,onScrollEndDrag:j,onMomentumScrollEnd:g,scrollEventThrottle:32,onContentSizeChange:q,keyboardShouldPersistTaps:"handled",keyboardDismissMode:"interactive",ListHeaderComponent:t,ListEmptyComponent:o,ListFooterComponent:r})}var b=w.create({list:{flex:1,backgroundColor:"transparent"},listContent:{paddingHorizontal:k.gutter,paddingTop:12,paddingBottom:16,gap:16,flexGrow:1},userWrap:{alignItems:"flex-end"},userBubble:{maxWidth:"84%",paddingHorizontal:14,paddingVertical:9,borderRadius:18,borderBottomRightRadius:6,backgroundColor:k.color.accentFill,borderWidth:w.hairlineWidth,borderColor:k.color.accentBorder},userText:{color:k.color.text,fontSize:k.font.row,lineHeight:21},systemLine:{alignSelf:"stretch",paddingHorizontal:12,paddingVertical:7,borderRadius:k.radius.row,backgroundColor:k.color.fill},systemText:{color:k.color.textSecondary,fontSize:k.font.micro,lineHeight:16,textAlign:"center"},assistantWrap:{alignItems:"stretch",gap:10},blocks:{gap:10},waitingRow:{flexDirection:"row",alignItems:"center",gap:8},waitingText:{color:k.color.textSecondary,fontSize:k.font.caption},assistantText:{color:k.color.text,fontSize:k.font.row,lineHeight:22,paddingHorizontal:2},card:{borderRadius:k.radius.card,borderWidth:w.hairlineWidth,borderColor:k.color.border,backgroundColor:k.color.surface,overflow:"hidden"},row:{paddingHorizontal:12,paddingVertical:10},rowDivider:{borderBottomWidth:w.hairlineWidth,borderBottomColor:k.color.separator},rowLine:{flexDirection:"row",alignItems:"center",gap:10},markSlot:{width:18,height:18,alignItems:"center",justifyContent:"center"},mark:{width:16,height:16,borderRadius:8,alignItems:"center",justifyContent:"center"},markOk:{backgroundColor:k.color.accent},markFailed:{backgroundColor:k.color.danger},markRefused:{backgroundColor:k.color.warning},markNotRun:{borderWidth:1.5,borderColor:k.color.textTertiary},markNotRunBar:{width:7,height:1.5,borderRadius:1,backgroundColor:k.color.textSecondary},rowTitle:{flex:1,color:k.color.text,fontSize:k.font.body,lineHeight:19},rowStatus:{color:k.color.textTertiary,fontSize:k.font.caption,maxWidth:120},rowStatusDanger:{color:k.color.danger},rowStatusWarning:{color:k.color.warning},rowStatusOk:{color:k.color.accent},rowVerified:{color:k.color.accent},rowDetail:{paddingLeft:28,paddingTop:8,gap:4},rowTool:{color:k.color.textTertiary,fontSize:k.font.micro,fontWeight:"600",letterSpacing:.8},rowDescription:{color:k.color.textSecondary,fontSize:k.font.caption,lineHeight:18},rowFailure:{color:k.color.danger,fontSize:k.font.caption,lineHeight:18},rowReceipts:{paddingTop:10,gap:10},groupBody:{paddingLeft:14,backgroundColor:k.color.fill},stoppedBox:{alignItems:"flex-start",gap:2,paddingHorizontal:12,paddingVertical:8},stoppedText:{color:k.color.textTertiary,fontSize:k.font.caption,lineHeight:18},errorBox:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingVertical:10,borderRadius:k.radius.row,backgroundColor:k.color.dangerSoft},errorBody:{flex:1,gap:4},errorText:{color:k.color.danger,fontSize:k.font.caption,fontWeight:"600",lineHeight:18},errorDetail:{color:k.color.textSecondary,fontSize:k.font.micro,lineHeight:15},retry:{alignSelf:"flex-start",marginTop:6,paddingHorizontal:14,paddingVertical:7,borderRadius:k.radius.row,backgroundColor:k.color.button},retryPressed:{opacity:.7},retryText:{color:k.color.accent,fontSize:k.font.caption,fontWeight:"600"},transcriptActions:{flexDirection:"row",alignItems:"center",gap:10,marginTop:8},turnFooter:{flex:1,color:k.color.textTertiary,fontSize:k.font.micro,fontVariant:["tabular-nums"]},copyBtn:{paddingHorizontal:10,paddingVertical:5,borderRadius:k.radius.badge,backgroundColor:k.color.fill},iconBtn:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8},copyPressed:{opacity:.7},copyText:{color:k.color.textSecondary,fontSize:k.font.micro,fontWeight:"600"},copiedText:{color:k.color.accent}});import{night as Oe,X as $d}from"@buoy-gg/shared-ui/web";import{jsx as Lt,jsxs as Mo}from"react/jsx-runtime";var Ad=132;function Bd({items:e,paused:t,onEdit:o,onRemove:r}){return e.length===0?null:Mo(s,{style:Pe.wrap,testID:"buoy-ask-buoy-queued",children:[Lt(_e,{style:Pe.list,contentContainerStyle:Pe.listContent,keyboardShouldPersistTaps:"handled",children:e.map((n,i)=>Mo(s,{style:[Pe.row,t!==null&&Pe.rowPaused],children:[Mo(m,{testID:`buoy-ask-buoy-queue-item-${i}`,accessibilityRole:"button",accessibilityLabel:`Edit queued message: ${n.text}`,onPress:()=>o(n.id),style:({pressed:a})=>[Pe.rowBody,a&&Pe.pressed],children:[Lt(l,{style:Pe.ordinal,children:i===0?"NEXT":"THEN"}),Lt(l,{style:Pe.text,numberOfLines:3,children:n.text})]}),Lt(m,{testID:`buoy-ask-buoy-queue-remove-${i}`,accessibilityRole:"button",accessibilityLabel:"Remove queued message",onPress:()=>r(n.id),hitSlop:8,style:({pressed:a})=>[Pe.remove,a&&Pe.pressed],children:Lt($d,{size:11,color:Oe.color.textTertiary})})]},n.id))}),Lt(l,{style:[Pe.hint,t!==null&&Pe.hintPaused],testID:"buoy-ask-buoy-queue-hint",children:t??"Sends one at a time when this turn finishes \xB7 tap to edit"})]})}var Pe=w.create({wrap:{paddingHorizontal:Oe.gutter,paddingTop:8,gap:6,backgroundColor:Oe.color.bg},list:{maxHeight:Ad},listContent:{gap:6},row:{flexDirection:"row",alignItems:"center",borderRadius:Oe.radius.row,borderWidth:w.hairlineWidth,borderColor:Oe.color.border,backgroundColor:Oe.color.surface},rowPaused:{borderColor:Oe.color.warning},rowBody:{flex:1,flexDirection:"row",alignItems:"center",gap:8,paddingVertical:7,paddingLeft:10},ordinal:{color:Oe.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.6,width:30},text:{flex:1,color:Oe.color.textSecondary,fontSize:Oe.font.caption,lineHeight:17},remove:{width:32,height:32,alignItems:"center",justifyContent:"center"},pressed:{opacity:.7},hint:{color:Oe.color.textTertiary,fontSize:Oe.font.micro},hintPaused:{color:Oe.color.warning}});var Hd="Summarize this conversation as a bug ticket, using one buoy_ui finding block and nothing else. Title it with the problem in one line. Evidence rows, in this order: Steps (what we did), Expected, Observed, Build (dev or release, platform), Evidence (the exact requests, statuses, logs or values you actually saw this conversation), Still applied (overrides or changes from your changes list that are still live, or 'none'). Only facts you observed in this conversation; write 'unknown' where you don't know rather than guessing, and put anything you inferred rather than saw in a final row labelled Inference. Do not run any tool or change anything to produce this.";import{Fragment as Ld,jsx as pe,jsxs as Ot}from"react/jsx-runtime";function qo({visible:e,onClose:t,onBack:o,onMinimize:r,persistenceKey:n,config:i}){let{state:a,send:h,stop:u,reset:g,undoThenReset:f,approve:S,retry:j,answer:q,runAction:X,editQueued:ee,removeQueued:ke,configured:Je,toolCount:$e,availableToolIds:Qe}=Cn(i),[Ye,bt]=go(false),yt=Fe(()=>{u(),t()},[u,t]),zt=Fe(()=>y.clearDraft(),[]),[Ne,st]=go(false),ct=Fe(()=>st(false),[]),Xe=Fe(()=>st(true),[]),mt=!e,Ze=!!a.pending||!!a.awaitingBlockId,ze=a.messages[a.messages.length-1],Dt=Wt(false),Qt=Wt(a.busy);Pt(()=>{mt&&Qt.current&&!a.busy&&(Dt.current=true),mt||(Dt.current=false),Qt.current=a.busy},[mt,a.busy]),Pt(()=>{if(!mt){At("ask-buoy",null);return}Ze?At("ask-buoy",{kind:"needsInput",label:a.pending?"Needs your approval":"Has a question for you"}):Dt.current&&ze?.role==="assistant"&&ze.error?At("ask-buoy",{kind:"failed",label:"The last turn failed"}):Dt.current&&!a.busy?At("ask-buoy",{kind:"done",label:"Finished"}):At("ask-buoy",null)},[mt,Ze,a.busy,a.pending,ze]),Pt(()=>()=>At("ask-buoy",null),[]),Pt(()=>{a.pending&&Ne&&st(false)},[a.pending,Ne]);let co=al({minBottom:16}),[Yt,uo]=go("bottomSheet"),po=Yt==="floating"?0:co.bottom,ho=Fe(()=>{let K=y.getLedger();K&&(async()=>{let ie=await K.revertAll(nl);if(ie.failed.length===0){y.setNotice(null);return}let Rt=ie.failed.map(Xt=>`${Xt.label} (${Xt.error})`).join("; ");y.setNotice(`Couldn't undo ${ie.failed.length} change${ie.failed.length===1?"":"s"} \u2014 ${Rt}`)})()},[]),T=Fe(()=>bt(K=>!K),[]),V=Wt(new ce.Value(560)).current,_=Wt(false),ne=Fe(()=>{_.current||(_.current=true,V.stopAnimation(K=>{let ie=typeof K=="number"&&K>200?K:560;ce.timing(V,{toValue:120,duration:220,useNativeDriver:false}).start(()=>{setTimeout(()=>{ce.spring(V,{toValue:ie,friction:9,useNativeDriver:false}).start(()=>{_.current=false})},2500)})}))},[V]),Te=eo(()=>{let K=a.messages[a.messages.length-1];if(!K||K.role!=="assistant")return"";let ie=K.blocks.filter(Rt=>Rt.block.kind==="peek").length;return ie>0?`${K.id}:${ie}`:""},[a.messages]),te=Wt("");Pt(()=>{Te&&Te!==te.current&&i?.peek!==false&&ne(),te.current=Te},[Te,ne,i]);let Gn=Fe(()=>{let K=y.getLedger()?.list().filter(ie=>!ie.undoneAt&&rl(ie.effect)).length??0;if(K===0){g();return}yo.alert("Undo changes first?",`Ask Buoy made ${K} change${K===1?"":"s"} that can still be undone. Clearing the conversation loses the only automatic undo for ${K===1?"it":"them"}.`,[{text:"Undo, then clear",onPress:()=>{(async()=>{let ie=await f();if(ie.cleared)return;let Rt=ie.reverted+ie.failed.length,Xt=ie.failed.map(Zo=>`${Zo.label} (${Zo.error})`).join(`
|
|
13
|
-
`);
|
|
10
|
+
${t.delta}`:r.text+t.delta,breakBeforeNextText:false};case"reasoning":return{...r,breakBeforeNextText:true,reasoning:[...r.reasoning??[],{text:t.text,afterCalls:r.toolCalls.length}]};case"tool-start":return{...r,waiting:void 0,toolCalls:[...r.toolCalls,{id:t.id,toolId:t.toolId,action:t.action,label:t.label,description:t.description,status:"running",params:Rc(t.params),effect:t.effect,startedAt:Zt()}]};case"tool-end":return{...r,breakBeforeNextText:true,toolCalls:r.toolCalls.map(n=>n.id===t.id?{...n,status:!t.ok&&t.summary==="refused"?"refused":!t.ok&&t.summary==="declined"?"declined":!t.ok&&t.summary==="stopped"?"stopped":t.ok?"ok":"failed",summary:t.summary,durationMs:t.durationMs,result:t.result}:n)};case"tool-verified":return{...r,toolCalls:r.toolCalls.map(n=>n.id===t.id?{...n,verification:t.verification}:n)};case"block":return{...r,breakBeforeNextText:true,blocks:[...r.blocks,{block:t.block,forToolCallId:t.forToolCallId}]};case"usage":return{...r,usage:{input:(r.usage?.input??0)+t.input,output:(r.usage?.output??0)+t.output,requests:(r.usage?.requests??0)+1}};case"error":return{...r,waiting:void 0,error:t.message,...t.hosted?{errorInfo:{code:t.hosted.code,requestId:t.hosted.request_id,action:t.hosted.action,resetAt:t.hosted.reset_at,helpUrl:t.hosted.help_url}}:{}};default:return r}});X({messages:o,...t.type==="awaiting-user"?{awaitingBlockId:t.blockId}:{},...t.type==="error"&&t.hosted?.code==="claude_paused"?{claudeOut:true}:{},...t.type==="meter"&&t.frame.phase==="end"?{credits:{left:t.frame.credits_left??L.credits?.left??null,resetAt:t.frame.credits_reset??L.credits?.resetAt??null,pending:t.frame.pending===true}}:{},...t.type==="usage"?{usage:{input:L.usage.input+t.input,output:L.usage.output+t.output,requests:L.usage.requests+1}}:{}})},markStopped(e){X({messages:L.messages.map(t=>t.id===e?{...t,stopped:true}:t)})},finishAssistant(e){X({messages:L.messages.map(t=>t.id===e?{...t,streaming:false,endedAt:Zt()}:t),busy:false,stopping:false})},askApproval(e){return new Promise(t=>{X({pending:{...e,resolve:t}})})},answerApproval(e){let t=L.pending,o=typeof e=="boolean"?e:e.approved,r=typeof e!="boolean"&&e.trust===true&&o,n=t?`${t.toolId}.${t.action}`:"";X({pending:null,...r&&t&&!L.trusted.some(i=>i.key===n)?{trusted:[...L.trusted,{key:n,label:t.label}]}:{}}),t?.resolve(e)},untrust(e){_o?.session.untrust(e),X({trusted:L.trusted.filter(t=>t.key!==e)})},restorePending(e){return L.pending||L.busy?false:(X({pending:{...e,restored:true,resolve:()=>{}}}),true)},addNote(e){X({messages:[...L.messages,{id:mo(),role:"assistant",text:e,toolCalls:[],blocks:[],endedAt:Zt()}]})},hydrate(e){return L.messages.length>0||L.busy?false:(X({messages:e.messages.map(t=>({...t,restored:true})),answers:e.answers,usage:e.usage,queued:e.queued??[]}),true)},reset(){L.pending?.resolve(false),X({messages:[],busy:false,stopping:false,pending:null,trusted:[],notice:null,answers:{},awaitingBlockId:null,actionState:{},queued:[],draft:null,usage:{input:0,output:0,requests:0}})}};function An(e){return e.pending?"awaitingApproval":e.busy?e.stopping?"stopping":"running":e.awaitingBlockId?"awaitingAnswer":"idle"}function Bn(e){let t=An(e);if(t==="running"||t==="stopping")return null;if(t==="awaitingApproval")return"Paused \u2014 answer the approval above first.";if(t==="awaitingAnswer")return"Paused \u2014 answer the question above first.";let o=e.messages[e.messages.length-1];return o?.role==="assistant"&&o.error?"Paused \u2014 the last turn failed.":o?.role==="assistant"&&o.stopped?"Paused \u2014 you stopped the last turn.":null}import{getUseIsPro as Ac,hasAccountAccess as eo,subscribeAccountAccess as Bc}from"@buoy-gg/shared-ui/web";import{useCallback as De,useEffect as ct,useMemo as Ln,useRef as dt,useState as Lc,useSyncExternalStore as Oc}from"react";import{dispatchToolAction as On,listSnapshotToolIds as Hc,listToolActions as Pc,readToolSnapshot as Wc,waitForToolRegistry as Hn}from"@buoy-gg/shared-ui/web";import{answerToText as Pn,CATALOG as Uo,createAskBuoySession as Ec,readTargetDigest as Nc,runGatedAction as Wn,SNAPSHOT_ACTION as En}from"@buoy-gg/agent-core/web";import{persistentStorage as Ko,devToolsStorageKeys as Vc}from"@buoy-gg/shared-ui/web";import{dispatchToolAction as Nn}from"@buoy-gg/shared-ui/web";var Mc=[{re:/\bBearer\s+[A-Za-z0-9._~+/-]{12,}=*/gi,label:"[bearer token removed]"},{re:/\beyJ[A-Za-z0-9._-]{20,}/g,label:"[jwt removed]"},{re:/\bsk-[A-Za-z0-9_-]{16,}/g,label:"[api key removed]"},{re:/\bBUOY-[A-Z0-9-]{8,}/g,label:"[license key removed]"},{re:/("|')?(authorization|x-api-key|api[_-]?key|password|secret|access_token|refresh_token)\1?\s*[:=]\s*("|')?(?!(?:authorization|bearer|cookie|header)\b)[^\s"',}]{6,}/gi,label:"[credential removed]"}];function to(e){if(!e)return e;let t=e;for(let{re:o,label:r}of Mc)t=t.replace(o,r);return t}var Jo=`${Vc.base}_ask_buoy_transcript`,Go=1,Vn=60,jc=256e3,qc="[not kept across a restart \u2014 read it again if you need it]";function ut(e){return e&&to(e)}function Fc(e){let t=e.streaming===true;return{...e,text:ut(e.text),streaming:false,reasoning:e.reasoning?.map(o=>({...o,text:ut(o.text)})),toolCalls:e.toolCalls.map(o=>{let r=o.params?ut(o.params):void 0,{result:n,...i}=o;return o.status==="running"?{...i,params:r,status:"failed",summary:"Interrupted"}:{...i,params:r}}),error:e.error??(t&&!e.text?"This answer was interrupted \u2014 the app restarted mid-turn.":void 0)}}function _c(e){return e.map(t=>t.role==="tool-results"?{...t,results:t.results.map(o=>({...o,content:qc}))}:t.role==="assistant"?{...t,text:ut(t.text)}:{...t,text:ut(t.text)})}function Uc(e){let t={...e,messages:e.messages.slice(-Vn),history:e.history.slice(-Vn*2)},o=JSON.stringify(t);for(;o.length>jc&&t.messages.length>1;)t={...t,messages:t.messages.slice(1),history:t.history.slice(Math.min(2,t.history.length))},o=JSON.stringify(t);return t}function Kc(e){if(!e)return null;let t=e.params;if(!t)return null;let o;try{o=JSON.stringify(t)}catch{return null}return to(o)!==o?null:{id:e.id,toolId:e.toolId,action:e.action,label:ut(e.label),description:e.description?ut(e.description):void 0,reason:ut(e.reason),params:t,targetDigest:e.targetDigest}}function Jc(e){if(typeof e!="object"||e===null)return false;let t=e;return typeof t.id=="string"&&typeof t.toolId=="string"&&typeof t.action=="string"&&typeof t.label=="string"&&typeof t.reason=="string"&&typeof t.params=="object"&&t.params!==null}function Gc(e){if(!e?.length)return;let t=e.filter(o=>{try{let r=JSON.stringify(o);return to(r)===r}catch{return false}});return t.length?t:void 0}function Yc(e){return Uc({v:Go,savedAt:Date.now(),messages:e.messages.map(Fc),history:_c(e.history),answers:e.answers,usage:e.usage,pending:Kc(e.pending),ledger:Gc(e.ledger),queued:e.queued?.length?e.queued.map(t=>({id:t.id,text:ut(t.text)})):void 0})}function Qc(e){if(!e)return null;try{let t=JSON.parse(e);return t?.v!==Go||!Array.isArray(t.messages)||t.messages.length===0?null:{v:Go,savedAt:typeof t.savedAt=="number"?t.savedAt:0,messages:t.messages,history:Array.isArray(t.history)?t.history:[],answers:t.answers??{},usage:t.usage??{input:0,output:0,requests:0},pending:Jc(t.pending)?t.pending:null,ledger:Array.isArray(t.ledger)?t.ledger.filter(o=>typeof o=="object"&&o!==null&&typeof o.id=="string"):void 0,queued:Array.isArray(t.queued)?t.queued.filter(o=>typeof o=="object"&&o!==null&&typeof o.id=="string"&&typeof o.text=="string"):void 0}}catch{return null}}async function Xc(){try{return Qc(await Ko.getItem(Jo))}catch{return null}}async function Zc(e){try{await Ko.setItem(Jo,JSON.stringify(e))}catch{}}async function ed(){try{await Ko.removeItem(Jo)}catch{}}function Yo(){b.getHeldSession()?.session.reset(),b.reset(),ed()}async function Mn(e){if(b.getState().busy)return{cleared:false,reverted:0,failed:[{label:"A turn is running",error:"Stop it first."}]};let t=b.getLedger();if(e.undoFirst&&t){let o=await t.revertAll(e.dispatch);return o.failed.length>0?{cleared:false,reverted:o.reverted,failed:o.failed}:(Yo(),{cleared:true,reverted:o.reverted,failed:[]})}return Yo(),{cleared:true,reverted:0,failed:[]}}var jn="claude-haiku-5-5";function td(e,t,o){let r=e?.hostedModels;if(!e||!r?.claude||!r.luna)return e;let n=t==="claude"&&!o?r.claude:r.luna,i=n===r.claude?r.luna:r.claude;return{...e,...n,hostedFallback:i}}var oo=typeof ao<"u"&&!ao;function od(e){for(let t of b.getState().messages)if(t.restored)for(let o of t.blocks){let r=o.block;if(r?.id!==e)continue;let n=r.question??r.label??r.title;return typeof n=="string"&&n.trim()?n.trim():void 0}}function qn(){try{let e=Pc();for(let t of Hc())e[t]||(e[t]=[]),e[t].includes(En)||(e[t]=[En,...e[t]]);return e}catch{return{}}}var rd=600;function ko(){return Oc(b.subscribe,b.getState,b.getState)}function Fn(e){let t=ko(),o=Cn(),r=Ln(()=>td(e,o,t.claudeOut),[e,o,t.claudeOut]),n=dt(r);(t.messages.length===0||!n.current)&&(n.current=r);let i=n.current,a=dt(e);a.current=e;let g=!!e?.hostedModels?.claude,u=t.messages.length===0;ct(()=>{let S=a.current?.readUsage;if(!g||o!=="claude"||!u||!S)return;let V=true;return S().then(q=>{V&&q.claude&&b.setClaudeOut(!q.claude.available)}).catch(()=>{}),()=>{V=false}},[g,o,u]);let h=Ac()(),f=dt(h);f.current=h;let T=De((...S)=>!eo()||!f.current?Promise.reject(new Error("Ask Buoy requires Pro access.")):On(...S),[]),O=dt(null),_=dt(false),ee=dt(null),ce=dt(i);ce.current=i;let pe=!!i?.endpoint&&!!i?.model,Pe=i?.persistTranscript!==false,{bypassApprovals:qe,readOnly:We}=Ot(),Xe=dt(qe);Xe.current=qe;let Ze=dt(We);Ze.current=We;let et=De(()=>Ze.current?{...i?.policy??{},readOnly:true}:i?.policy??{},[i]),[Wt,tt]=Lc(0);ct(()=>{let S=false;return Hn().then(()=>{S||tt(V=>V+1)}),()=>{S=true}},[]);let Ee=Ln(()=>qn(),[Wt]),Et=Object.keys(Ee).sort().join(",");ct(()=>{if(b.setConfigured(pe),b.setMeta({model:i?.model,protocol:i?.protocol??(i?"anthropic":void 0),appName:i?.appName,platform:we.OS,build:oo?"release":"development"}),!pe||!i){O.current=null,b.setNotice("Ask Buoy isn't set up in this app yet. A developer needs to point it at your team's AI endpoint.");return}let S=i.protocol??"anthropic";oo&&i.apiKey?b.setNotice("This build carries a plaintext apiKey \u2014 that's dev-only and it ships to every install. Use the headers callback with your own gateway for distributed builds."):S==="anthropic"&&/^https?:\/\/api\.openai\.com\//i.test(i.endpoint)?b.setNotice('This endpoint is api.openai.com but the protocol is "anthropic". Set protocol: "openai" in the askBuoy config.'):S==="openai"&&/^https?:\/\/api\.anthropic\.com\//i.test(i.endpoint)?b.setNotice('This endpoint is api.anthropic.com but the protocol is "openai". Remove protocol or set it to "anthropic".'):b.setNotice(null),b.setReporter(i.reportProblem??null),b.setUsageReader(i.readUsage??null);let V=[i.endpoint,i.protocol??"anthropic",i.model].join("|"),q=b.getHeldSession();if(q&&q.signature===V){O.current=q.session,q.session.setAvailableActions(Ee),q.session.setApprovalBypass(Xe.current),q.session.setReadOnly(Ze.current),b.setLedger(q.session.ledger);return}let de=Ec({endpoint:i.endpoint,protocol:i.protocol??"anthropic",model:i.model,headers:i.headers,apiKey:i.apiKey,maxTokens:i.maxTokens,anthropicVersion:i.anthropicVersion,requestOverrides:i.requestOverrides,hosted:i.hosted===true,...i.hostedFallback?{fallback:i.hostedFallback,onModelSwitch:Q=>{let io=(Q==="fallback"?i.hostedFallback?.model:i.model)===jn;b.setMeta({model:Q==="fallback"?i.hostedFallback?.model:i.model}),Q==="fallback"?(io||b.setClaudeOut(true),b.setNotice(io?"Luna is down right now, so Claude is answering.":"Claude is busy right now, so Luna is answering.")):b.setNotice(null)}}:{},catalog:i.tools?.length?[...Uo,...i.tools]:void 0,dispatch:T,readSnapshot:Wc,availableActions:Ee,policy:i.policy,context:i.context,isRelease:oo,appName:i.appName,platform:we.OS,requestApproval:Q=>b.askApproval(Q)});O.current=de,de.setApprovalBypass(Xe.current),de.setReadOnly(Ze.current),b.holdSession(de,V),b.setLedger(de.ledger);let Re=false;return Hn().then(Q=>{Q&&!Re&&de.prime()}),Pe&&!_.current&&(_.current=true,Xc().then(Q=>{!Q||!b.hydrate({messages:Q.messages,answers:Q.answers,usage:Q.usage,queued:Q.queued})||(O.current?.restore(Q.history),Q.ledger?.length&&O.current?.ledger.restore(Q.ledger),Q.pending&&b.restorePending(Q.pending))})),()=>{Re=true}},[pe,i,Ee,Et,Pe]),ct(()=>{O.current?.setApprovalBypass(qe)},[qe]),ct(()=>{O.current?.setReadOnly(We)},[We]);let Nt=t.messages,ht=t.answers,Vt=t.usage,Ce=t.busy,gt=t.pending,Mt=t.queued;ct(()=>{if(!Pe||Nt.length===0)return;let S=()=>{Zc(Yc({messages:Nt,history:O.current?.messages??[],answers:ht,usage:Vt,pending:gt,ledger:b.getLedger()?.list(),queued:Mt}))};if(!Ce||gt){S();return}let V=setTimeout(S,rd);return()=>clearTimeout(V)},[Pe,Ce,Nt,ht,Vt,gt,Mt]);let Dt=De(S=>{if(!eo()||!f.current)return;let V=O.current;if(!V)return;b.beginTurn();let q=b.startAssistant(),de=new AbortController;ee.current=de,V.setAvailableActions(qn());let Re=ce.current?.onEvent;(async()=>{try{for await(let Q of V.send(S,de.signal))if(b.applyEvent(q,Q),Re)try{Re(Q)}catch{}}catch(Q){de.signal.aborted||b.applyEvent(q,{type:"error",message:Q instanceof Error?Q.message:"Something went wrong talking to your AI endpoint."})}finally{de.signal.aborted&&b.markStopped(q),b.finishAssistant(q),ee.current=null}})()},[]),ot=De(S=>{if(!eo()||!f.current)return;let V=S.trim();if(!O.current||!V)return;if(b.getState().busy){b.enqueue(V);return}let q=b.getState().awaitingBlockId;q&&b.recordAnswer({blockId:q,kind:"skipped"}),b.addUser(V),Dt(V)},[Dt]),wo=De(()=>{let{messages:S,busy:V}=b.getState();if(V||!O.current)return;let q=[...S].reverse().find(de=>de.role==="user");q&&Dt(q.text)},[Dt]),ft=De(()=>{b.requestStop(),b.getState().pending&&b.answerApproval(false),ee.current?.abort(),ee.current=null},[]);ct(()=>{let S=Bc(()=>{eo()||ft()});return()=>{S(),ft()}},[ft]),ct(()=>{h||ft()},[h,ft]),ct(()=>{if(t.queued.length===0||An(t)!=="idle"||Bn(t)!==null)return;let S=b.shiftQueued();S&&ot(S.text)},[t,ot]);let vo=De(S=>b.takeQueuedToDraft(S),[]),So=De(S=>b.removeQueued(S),[]),xt=De(()=>{ee.current?.abort(),ee.current=null,Yo()},[]),jt=De(()=>Mn({dispatch:On,undoFirst:true}),[]),qt=De(async S=>{let V=b.getLedger();if(!V){b.setNotice(`${S.label} couldn't run \u2014 no active Ask Buoy session.`);return}let q=i?.tools?.length?[...Uo,...i.tools]:void 0;if(S.targetDigest){let Re=await Nc({toolId:S.toolId,action:S.action,params:S.params??{},dispatch:T,catalog:q});if(Re!==void 0&&Re!==S.targetDigest){b.addNote(`\u201C${S.label}\u201D wasn't applied \u2014 what it would change has moved on since the app restarted. Nothing was written. Ask again if you still want it.`);return}}let de=await Wn({toolId:S.toolId,action:S.action,params:S.params??{},dispatch:T,ledger:V,policy:et(),isRelease:oo,catalog:q});de.ok?b.addNote(`Applied \u201C${S.label}\u201D, which was still waiting when the app restarted. Whatever else that answer was going to do is gone \u2014 ask again if there was more to it.`):b.setNotice(`${S.label} failed \u2014 ${de.error}`)},[i,et]),Rt=De(S=>{let V=b.getState().pending,q=typeof S=="boolean"?S:S.approved;if(b.answerApproval(S),!!V?.restored){if(!q){b.addNote(`Skipped \u201C${V.label}\u201D. Nothing was changed.`);return}qt(V)}},[qt]),no=De(S=>{b.recordAnswer(S);let V=od(S.blockId);ot(V?`${V} \u2014 ${Pn(S)}`:Pn(S))},[ot]),To=De(async(S,V)=>{if(!eo()||!f.current){b.setNotice("Ask Buoy requires Pro access.");return}if(S.send){ot(S.send);return}if(!S.dispatch)return;let q=`${V}:${S.label}`,de=b.getLedger();if(!de){b.setNotice(`${S.label} failed \u2014 no active Ask Buoy session.`);return}b.setActionState(q,"running");let Re=await Wn({toolId:S.dispatch.toolId,action:S.dispatch.action,params:S.dispatch.params??{},dispatch:T,ledger:de,policy:et(),isRelease:oo,catalog:i?.tools?.length?[...Uo,...i.tools]:void 0});Re.ok?b.setActionState(q,"done"):(b.setActionState(q,"failed"),b.setNotice(`${S.label} failed \u2014 ${Re.error}`))},[ot,i,et]);return{state:t,send:ot,stop:ft,reset:xt,undoThenReset:jt,approve:Rt,retry:wo,answer:no,runAction:To,editQueued:vo,removeQueued:So,configured:pe,toolCount:Object.keys(Ee).length,availableToolIds:Object.keys(Ee)}}import{Fragment as nd,jsx as Z,jsxs as je}from"react/jsx-runtime";function _n(){let e=Ot(),t=ko().trusted;return je(Je,{style:U.scroll,contentContainerStyle:U.content,testID:"buoy-ask-buoy-settings",children:[Z(ld,{}),Z(sd,{}),Z(l,{style:U.section,children:"CHAT"}),Z(Po,{testID:"buoy-ask-buoy-setting-thinking",label:"Show agent thinking",description:"Adds a collapsed strip under each answer: the model's reasoning, and every step it ran with its parameters, result, duration and token cost. Copy includes the steps and reasoning while this is on, so you can read the run outside the app.",value:e.showThinking,onValueChange:o=>st.set("showThinking",o)}),Z(l,{style:U.note,children:"Not every model reports reasoning. Claude thinks by default; most OpenAI models return none, and the strip then shows the steps alone."}),Z(l,{style:U.section,children:"PERMISSIONS"}),Z(Po,{testID:"buoy-ask-buoy-setting-readonly",label:"Read only",description:"Inspect the app, change nothing. Every write and simulation is refused until this is off. Undo still works \u2014 putting things back is the safe direction.",value:e.readOnly,onValueChange:o=>st.set("readOnly",o)}),e.readOnly?Z(l,{style:U.note,testID:"buoy-ask-buoy-readonly-note",children:"On across reloads until you turn it off here. The header says \u201CRead only\u201D while it is on. It adds to whatever this app already restricts \u2014 it never loosens anything."}):null,Z(Po,{testID:"buoy-ask-buoy-setting-bypass",tone:"warning",emphasizeLabel:e.bypassApprovals,disabled:e.readOnly,label:"Skip approval prompts",description:e.readOnly?"Unavailable while Read only is on \u2014 nothing can be approved.":"Runs every action the moment the agent calls it, with no Allow card \u2014 including the destructive ones that wipe or reset data.",value:e.bypassApprovals,onValueChange:o=>st.set("bypassApprovals",o)}),e.bypassApprovals&&!e.readOnly?je(s,{style:U.warning,testID:"buoy-ask-buoy-bypass-warning",children:[Z(xc,{size:14,color:se.color.warning}),Z(l,{style:U.warningText,children:"Nothing will ask before a change lands. A wipe or a reset runs on the model's word alone, and Undo only reverses the changes that can be reversed \u2014 the bar tells you which. This stays on across reloads and app restarts until you turn it off here, so leave it off on any device holding data you care about. It does not widen what the agent may reach: read-only mode, this app's deny list and the release-build refusals still apply."})]}):Z(l,{style:U.note,children:"On by default for destructive actions only \u2014 reads and ordinary writes already run without asking, and the changes bar records them."}),t.length>0?je(s,{style:U.trustedBox,testID:"buoy-ask-buoy-trusted",children:[Z(l,{style:U.section,children:"ALLOWED WITHOUT ASKING \u2014 THIS CHAT"}),t.map(o=>je(s,{style:U.trustedRow,children:[Z(l,{style:U.trustedLabel,numberOfLines:2,children:o.label}),Z(m,{testID:`buoy-ask-buoy-untrust-${o.key}`,accessibilityRole:"button",onPress:()=>b.untrust(o.key),style:({pressed:r})=>[U.forget,r&&{opacity:.7}],hitSlop:6,children:Z(l,{style:U.forgetText,children:"Ask again"})})]},o.key))]}):null]})}function id(e){let t=Date.parse(e.length===10?`${e}T00:00:00Z`:e);if(Number.isNaN(t))return e;let o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=new Date(t);return`${o[r.getUTCMonth()]} ${r.getUTCDate()}`}function ld(){let e=b.getUsageReader(),[t,o]=kc({kind:"loading"}),r=yc(()=>{e&&(o({kind:"loading"}),e().then(n=>{n.claude&&b.setClaudeOut(!n.claude.available),o({kind:"ok",usage:n})}).catch(n=>o({kind:"error",message:n instanceof Error?n.message:"Could not load credits."})))},[e]);return mc(r,[r]),e?je(s,{testID:"buoy-ask-buoy-credits",children:[Z(l,{style:U.section,children:"HOSTED AI CREDITS"}),je(s,{style:U.trustedRow,children:[Z(s,{style:{flex:1,gap:2},children:t.kind==="ok"?je(nd,{children:[je(l,{style:U.trustedLabel,children:[t.usage.creditsLeft.toLocaleString()," of ",t.usage.grantCredits.toLocaleString()," credits left"]}),je(l,{style:U.note,children:[t.usage.resetAt?`Resets ${id(t.usage.resetAt)}. `:"","That's about ",Math.floor(t.usage.creditsLeft/5).toLocaleString()," more asks, included with your plan."]})]}):t.kind==="error"?Z(l,{style:U.note,children:t.message}):Z(l,{style:U.note,children:"Loading\u2026"})}),Z(m,{testID:"buoy-ask-buoy-credits-refresh",accessibilityRole:"button",onPress:r,style:({pressed:n})=>[U.forget,n&&{opacity:.7}],hitSlop:6,children:Z(l,{style:U.forgetText,children:"Refresh"})})]})]}):null}var ad=[{id:"claude",label:"Claude Haiku 5.5",note:"The default. Answers faster."},{id:"luna",label:"GPT-6 Luna",note:"Uses fewer credits."}];function sd(){let e=Cn(),{claudeOut:t}=ko();return b.getUsageReader()?je(s,{testID:"buoy-ask-buoy-model",style:{gap:6},children:[Z(l,{style:U.section,children:"MODEL"}),ad.map(o=>{let r=e===o.id;return je(m,{testID:`buoy-ask-buoy-model-${o.id}`,accessibilityRole:"radio",accessibilityState:{checked:r},onPress:()=>yo.set(o.id),style:({pressed:n})=>[U.trustedRow,r&&U.picked,n&&{opacity:.7}],children:[je(s,{style:{flex:1,gap:2},children:[Z(l,{style:U.trustedLabel,children:o.label}),Z(l,{style:U.note,children:o.note})]}),Z(l,{style:U.forgetText,children:r?"On":""})]},o.id)}),Z(l,{style:U.note,testID:"buoy-ask-buoy-model-note",children:e==="claude"&&t?"Claude is busy right now. New chats use Luna until it opens again.":"If one model is down, the other answers. A change starts with your next new chat. You can also pick it on buoy.gg, on the Ask Buoy tab."})]}):null}var U=w.create({picked:{borderColor:se.color.info},scroll:{flex:1},content:{padding:se.gutter,gap:10,paddingBottom:32},section:{color:se.color.textTertiary,fontSize:10,fontWeight:"700",letterSpacing:.6,paddingHorizontal:4,paddingTop:4},warning:{flexDirection:"row",gap:8,padding:se.cardPad,borderRadius:se.radius.card,borderWidth:w.hairlineWidth,borderColor:se.color.warning,backgroundColor:se.color.surface},warningText:{flex:1,color:se.color.warning,fontSize:se.font.micro,lineHeight:16},trustedBox:{gap:6,paddingTop:6},trustedRow:{flexDirection:"row",alignItems:"center",gap:10,padding:se.cardPad,borderRadius:se.radius.card,borderWidth:w.hairlineWidth,borderColor:se.color.border,backgroundColor:se.color.surface},trustedLabel:{flex:1,color:se.color.text,fontSize:se.font.caption,lineHeight:18},forget:{paddingHorizontal:10,paddingVertical:6,borderRadius:se.radius.row,backgroundColor:se.color.button},forgetText:{color:se.color.text,fontSize:se.font.micro,fontWeight:"600"},note:{color:se.color.textTertiary,fontSize:se.font.micro,lineHeight:16,paddingHorizontal:4}});import{monoFont as cd}from"@buoy-gg/shared-ui/web";import{ChevronRight as dd,night as Se,NightSectionLabel as ud}from"@buoy-gg/shared-ui/web";var pd=[{text:"Why is this screen empty?"},{text:"What did the last few network calls return?",needs:"network"},{text:"Show me what's saved for this user",needs:"storage"},{text:"Make the next request to this screen fail with a 500",needs:"network",write:true,devOnly:true},{text:"Who am I signed in as right now?"},{text:"Did anything crash or log an error recently?",needs:"console"}],hd=4;function gd(e){let t=e.availableToolIds.length>0;return pd.filter(o=>o.write&&e.readOnly||o.devOnly&&e.isRelease?false:o.needs?t&&e.availableToolIds.includes(o.needs):true).slice(0,hd).map(o=>o.text)}import{jsx as Ue,jsxs as ro}from"react/jsx-runtime";var Un=typeof ao<"u"&&!ao;function fd({configured:e,onPick:t,availableToolIds:o=[],readOnly:r=false}){let n=gd({availableToolIds:o,readOnly:r,isRelease:Un});return e?ro(s,{style:Ie.wrap,testID:"buoy-ask-buoy-empty",children:[Ue(l,{style:Ie.title,children:"Ask about this app"}),Ue(l,{style:Ie.body,children:"Ask what the app is doing right now, or tell it to change something. Anything it changes shows up in a bar at the top, with what can be undone."}),Ue(l,{style:Ie.buildLine,testID:"buoy-ask-buoy-build-line",children:Un?"Release build \u2014 reading, impersonation and navigation work; simulations (forcing server responses, driving the screen) need a dev build.":"Dev build \u2014 full simulation available."}),ro(s,{style:Ie.group,children:[Ue(ud,{children:"Try asking"}),Ue(s,{style:Ie.card,children:n.map((i,a)=>Ue(bd,{text:i,onPick:t,last:a===n.length-1},i))})]})]}):ro(s,{style:Ie.wrap,testID:"buoy-ask-buoy-unconfigured",children:[Ue(l,{style:Ie.title,children:"Not set up yet"}),ro(l,{style:Ie.body,children:["Ask Buoy talks to your own company's AI endpoint \u2014 nothing goes to Buoy. A developer needs to add the ",Ue(l,{style:Ie.code,children:"askBuoy"})," prop to"," ",Ue(l,{style:Ie.code,children:"<FloatingDevTools />"})," with your team's endpoint and model."]})]})}function bd({text:e,onPick:t,last:o}){return ro(m,{testID:`buoy-ask-buoy-suggestion-${e.slice(0,12)}`,accessibilityRole:"button",onPress:()=>t(e),style:({pressed:r})=>[Ie.row,!o&&Ie.rowDivider,r&&Ie.pressed],children:[Ue(l,{style:Ie.rowText,children:e}),Ue(dd,{size:14,color:Se.color.textTertiary})]})}var Ie=w.create({wrap:{flex:1,justifyContent:"center",paddingHorizontal:Se.gutter,paddingVertical:24,gap:8},title:{color:Se.color.text,fontSize:22,fontWeight:"700",letterSpacing:-.3},body:{color:Se.color.textSecondary,fontSize:Se.font.body,lineHeight:20},code:{color:Se.color.text,fontFamily:we.OS==="web"?cd:"Menlo"},buildLine:{marginTop:8,color:Se.color.textTertiary,fontSize:Se.font.micro,lineHeight:15},group:{marginTop:Se.groupGap-8},card:{borderRadius:Se.radius.card,borderWidth:w.hairlineWidth,borderColor:Se.color.border,backgroundColor:Se.color.surface,overflow:"hidden"},row:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:Se.rowPadH,paddingVertical:13},rowDivider:{borderBottomWidth:w.hairlineWidth,borderBottomColor:Se.color.separator},rowText:{flex:1,color:Se.color.text,fontSize:Se.font.body,lineHeight:19},pressed:{backgroundColor:Se.color.fill}});import{memo as yd,useCallback as It,useEffect as md,useRef as Qo,useState as Xo}from"react";import{AlertTriangle as Zo,Check as Kn,ChevronDown as Jn,ChevronRight as Gn,Copy as kd,night as x,X as xd}from"@buoy-gg/shared-ui/web";import{toolTitle as wd}from"@buoy-gg/agent-core/web";import{isAskBlock as vd}from"@buoy-gg/agent-core/web";function Sd({block:e,forToolCallId:t}){if(!t)return false;let o="source"in e?e.source:void 0;return o==="live"||o==="mocked"}function Td(e,t){let o=new Set(t),r=new Map,n=[],i=[];for(let a of e){if(vd(a.block)){i.push(a);continue}if(Sd(a)&&o.has(a.forToolCallId)){let g=r.get(a.forToolCallId)??[];g.push(a.block),r.set(a.forToolCallId,g)}else n.push(a)}return{nested:r,afterText:n,ask:i}}import{useState as Yn}from"react";import{Activity as Cd,ChevronDown as Id,ChevronRight as zd,night as te}from"@buoy-gg/shared-ui/web";function er(e){let t=[...e.reasoning??[]].sort((i,a)=>i.afterCalls-a.afterCalls),o=[],r=0,n=i=>{for(;r<t.length&&t[r].afterCalls<=i;)o.push({kind:"thought",text:t[r].text}),r+=1};return e.toolCalls.forEach((i,a)=>{n(a),o.push({kind:"step",n:a+1,call:i})}),n(e.toolCalls.length),o}function Qn(e){return(e.reasoning?.length??0)>0||e.toolCalls.length>0}var Dd=e=>e.status==="ok"?e.summary||"done":e.status==="running"?"running":`${e.status}${e.summary?` \u2014 ${e.summary}`:""}`;function Xn(e,t=" "){let o=[];for(let r of er(e))if(r.kind==="thought"){o.push(`${t}[thinking]`);for(let n of r.text.trim().split(`
|
|
11
|
+
`))o.push(`${t} ${n}`)}else{let{n,call:i}=r;o.push(`${t}[${n}] ${i.toolId}.${i.action} \u2014 ${Dd(i)}`),i.params&&o.push(`${t} ${i.params}`)}return o}import{Fragment as Rd,jsx as Le,jsxs as pt}from"react/jsx-runtime";function $d({n:e,call:t}){let[o,r]=Yn(false),n=t.status==="failed"||t.status==="refused";return pt(m,{onPress:()=>r(i=>!i),accessibilityRole:"button",accessibilityState:{expanded:o},style:be.step,children:[pt(s,{style:be.stepLine,children:[Le(l,{style:be.stepN,children:e}),pt(l,{style:[be.stepName,n&&be.stepFailed],numberOfLines:1,children:[t.toolId,".",t.action]}),t.durationMs!==void 0?pt(l,{style:be.stepMs,children:[t.durationMs,"ms"]}):null,Le(l,{style:[be.stepStatus,n&&be.stepFailed],numberOfLines:1,children:t.status==="ok"?t.summary||"done":t.status})]}),o?pt(s,{style:be.detail,children:[Le(l,{style:be.detailLabel,children:"SENT"}),Le(l,{style:be.code,selectable:true,children:t.params??"no parameters"}),t.result?pt(Rd,{children:[Le(l,{style:be.detailLabel,children:"RETURNED"}),Le(l,{style:be.code,selectable:true,children:t.result})]}):null]}):null]})}function Zn({message:e}){let[t,o]=Yn(false);if(!Qn(e))return null;let r=er(e),n=r.filter(u=>u.kind==="step").length,i=r.length-n,a=e.startedAt!==void 0&&e.endedAt!==void 0?`${((e.endedAt-e.startedAt)/1e3).toFixed(1)}s`:null,g=[n?`${n} step${n===1?"":"s"}`:null,i?`${i} thought${i===1?"":"s"}`:null,a,e.usage?`${e.usage.input+e.usage.output} tokens`:null].filter(Boolean).join(" \xB7 ");return pt(s,{style:be.wrap,testID:"buoy-ask-buoy-thinking",children:[pt(m,{testID:"buoy-ask-buoy-thinking-toggle",onPress:()=>o(u=>!u),accessibilityRole:"button",accessibilityLabel:t?"Hide agent thinking":"Show agent thinking",accessibilityState:{expanded:t},style:be.head,children:[Le(Cd,{size:12,color:te.color.textTertiary}),Le(l,{style:be.headText,children:g}),t?Le(Id,{size:12,color:te.color.textTertiary}):Le(zd,{size:12,color:te.color.textTertiary})]}),t?pt(s,{style:be.body,children:[r.map((u,h)=>u.kind==="thought"?Le(l,{style:be.thought,selectable:true,children:u.text.trim()},`t${h}`):Le($d,{n:u.n,call:u.call},u.call.id)),i===0?Le(l,{style:be.none,children:"This model reports no reasoning \u2014 the steps above are the whole trace."}):null]}):null]})}var be=w.create({wrap:{marginTop:8,borderRadius:te.radius.badge,borderWidth:w.hairlineWidth,borderColor:te.color.separator,backgroundColor:te.color.fill,overflow:"hidden"},head:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:7},headText:{flex:1,color:te.color.textTertiary,fontSize:te.font.micro,fontWeight:"600"},body:{borderTopWidth:w.hairlineWidth,borderTopColor:te.color.separator},thought:{color:te.color.textSecondary,fontSize:te.font.micro,lineHeight:17,fontStyle:"italic",paddingHorizontal:10,paddingVertical:8},step:{paddingHorizontal:10,paddingVertical:7},stepLine:{flexDirection:"row",alignItems:"center",gap:8},stepN:{color:te.color.textTertiary,fontSize:te.font.micro,width:14},stepName:{flex:1,color:te.color.textSecondary,fontSize:te.font.micro,fontWeight:"600"},stepMs:{color:te.color.textTertiary,fontSize:te.font.micro},stepStatus:{color:te.color.textTertiary,fontSize:te.font.micro,maxWidth:110},stepFailed:{color:te.color.danger},detail:{marginTop:6,marginLeft:22,gap:3},detailLabel:{color:te.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5},code:{color:te.color.textSecondary,fontSize:te.font.micro,lineHeight:16,marginBottom:3},none:{color:te.color.textTertiary,fontSize:te.font.micro,fontStyle:"italic",paddingHorizontal:10,paddingVertical:8}});import{useEffect as Ad,useRef as Bd}from"react";import{night as Ld}from"@buoy-gg/shared-ui/web";import{jsx as ei}from"react/jsx-runtime";function Od(){let e=Bd([0,1,2].map(()=>new ue.Value(.25))).current;return Ad(()=>{let t=e.map((o,r)=>ue.loop(ue.sequence([ue.delay(r*140),ue.timing(o,{toValue:1,duration:320,easing:At.inOut(At.ease),useNativeDriver:true}),ue.timing(o,{toValue:.25,duration:320,easing:At.inOut(At.ease),useNativeDriver:true}),ue.delay((2-r)*140)])));return t.forEach(o=>o.start()),()=>t.forEach(o=>o.stop())},[e]),ei(s,{style:ti.wrap,testID:"buoy-ask-buoy-typing",accessibilityLabel:"Thinking",children:e.map((t,o)=>ei(ue.View,{style:[ti.dot,{opacity:t}]},o))})}var ti=w.create({wrap:{flexDirection:"row",alignItems:"center",gap:5,paddingVertical:8,paddingHorizontal:2},dot:{width:7,height:7,borderRadius:4,backgroundColor:Ld.color.textSecondary}});import{jsx as k,jsxs as ye}from"react/jsx-runtime";function oi({status:e}){switch(e){case"running":return k(Jt,{size:"small",color:x.color.textSecondary});case"ok":return k(s,{style:[y.mark,y.markOk],children:k(Kn,{size:10,color:x.color.onAccent})});case"failed":return k(s,{style:[y.mark,y.markFailed],children:k(xd,{size:10,color:x.color.text})});case"refused":return k(s,{style:[y.mark,y.markRefused],children:k(Zo,{size:10,color:x.color.onAccent})});case"declined":case"stopped":return k(s,{style:[y.mark,y.markNotRun],children:k(s,{style:y.markNotRunBar})})}}function Hd(e){return e.status==="running"?{text:"",tone:"muted"}:e.status==="refused"?{text:"Refused",tone:"warning"}:e.status==="failed"?{text:"Failed",tone:"danger"}:e.status==="declined"?{text:"You declined",tone:"muted"}:e.status==="stopped"?{text:"Not run \u2014 stopped",tone:"muted"}:e.verification?.status==="verified"?{text:"Verified",tone:"ok"}:e.verification?.status==="unverified"?{text:"Done \xB7 not yet visible",tone:"muted"}:e.verification?.status==="failed"?{text:"Done \xB7 check failed",tone:"warning"}:{text:e.summary||"Done",tone:"muted"}}var Pd=e=>e.status==="failed"||e.status==="refused"||e.status==="declined"||e.status==="stopped";function ri({call:e,receipts:t,last:o}){let[r,n]=Xo(false),i=Hd(e),a=r?Jn:Gn,g=e.status==="failed"&&e.summary&&e.summary!=="Failed"?e.summary:null;return ye(s,{style:[y.row,!o&&y.rowDivider],children:[ye(m,{testID:`buoy-ask-buoy-tool-${e.toolId}`,accessibilityRole:"button",accessibilityLabel:`${e.label}, ${i.text||"running"}`,accessibilityState:{expanded:r},onPress:()=>n(u=>!u),children:[ye(s,{style:y.rowLine,children:[k(s,{style:y.markSlot,children:k(oi,{status:e.status})}),k(l,{style:y.rowTitle,children:e.label}),i.text?k(l,{style:[y.rowStatus,i.tone==="danger"&&y.rowStatusDanger,i.tone==="warning"&&y.rowStatusWarning,i.tone==="ok"&&y.rowStatusOk],numberOfLines:1,children:i.text}):null,k(a,{size:12,color:x.color.textTertiary})]}),r&&ye(s,{style:y.rowDetail,children:[k(l,{style:y.rowTool,children:wd(e.toolId).toUpperCase()}),e.description?k(l,{style:y.rowDescription,children:e.description}):null,g?k(l,{style:y.rowFailure,children:g}):null,e.verification?k(l,{style:[y.rowDescription,e.verification.status==="failed"&&y.rowFailure,e.verification.status==="verified"&&y.rowVerified],testID:`buoy-ask-buoy-verification-${e.verification.status}`,children:e.verification.detail}):null]})]}),r&&t.length>0&&k(s,{style:y.rowReceipts,testID:`buoy-ask-buoy-tool-receipt-${e.toolId}`,children:t.map(u=>k(go,{block:u},u.id))})]})}function Wd({label:e,count:t,calls:o,receipts:r,last:n}){let[i,a]=Xo(false),g=i?Jn:Gn;return ye(s,{style:!n&&!i&&y.rowDivider,children:[k(m,{testID:"buoy-ask-buoy-reads-group",accessibilityRole:"button",accessibilityLabel:`${e}, ${t} reads`,accessibilityState:{expanded:i},onPress:()=>a(u=>!u),style:[y.row,i&&y.rowDivider],children:ye(s,{style:y.rowLine,children:[k(s,{style:y.markSlot,children:k(oi,{status:"ok"})}),k(l,{style:y.rowTitle,children:e}),ye(l,{style:y.rowStatus,numberOfLines:1,children:[t," reads"]}),k(g,{size:12,color:x.color.textTertiary})]})}),i&&k(s,{style:y.groupBody,children:o.map((u,h)=>k(ri,{call:u,receipts:r.get(u.id)??[],last:n&&h===o.length-1},u.id))})]})}function Ed({calls:e,receipts:t}){let o=pc(e);return k(s,{style:y.card,testID:"buoy-ask-buoy-activity",children:o.map((r,n)=>r.kind==="reads"?k(Wd,{label:r.label,count:r.count,calls:r.calls,receipts:t,last:n===o.length-1},r.id):k(ri,{call:r.call,receipts:t.get(r.call.id)??[],last:n===o.length-1},r.call.id))})}function ni({blocks:e}){return e.length===0?null:k(s,{style:y.blocks,children:e.map(({block:t})=>k(go,{block:t},t.id))})}function Nd({message:e}){return k(s,{style:y.systemLine,testID:"buoy-ask-buoy-system-line",children:k(l,{style:y.systemText,children:e.text})})}function Vd({message:e}){return k(s,{style:y.userWrap,children:k(s,{style:y.userBubble,children:k(l,{style:y.userText,selectable:true,children:e.text})})})}function Md({message:e,onRetry:t,waitingOnUser:o}){let{showThinking:r}=Ot(),n=!!e.streaming&&!o,{nested:i,afterText:a,ask:g}=Td(e.blocks,e.toolCalls.map(u=>u.id));return ye(s,{style:y.assistantWrap,children:[e.toolCalls.length>0&&k(Ed,{calls:e.toolCalls,receipts:i}),e.text.length>0&&k(Er,{text:e.text,style:y.assistantText}),k(ni,{blocks:a}),k(ni,{blocks:g}),r&&!e.streaming&&k(Zn,{message:e}),n&&ye(s,{style:y.waitingRow,children:[k(Od,{}),e.waiting?k(l,{style:y.waitingText,testID:"buoy-ask-buoy-waiting",children:e.waiting}):null]}),e.error&&(e.errorInfo?k(_d,{error:e.error,info:e.errorInfo,onRetry:t}):k(qd,{error:e.error,onRetry:t})),e.stopped&&!e.error&&k(jd,{onRetry:t,changed:e.toolCalls.some(u=>u.status==="ok"&&!!u.effect&&u.effect!=="read")})]})}function jd({onRetry:e,changed:t}){return ye(s,{style:y.stoppedBox,testID:"buoy-ask-buoy-stopped",children:[k(l,{style:y.stoppedText,children:t?"Stopped. Changes already made are listed above.":"Stopped."}),e&&k(m,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:e,style:({pressed:o})=>[y.retry,o&&y.retryPressed],children:k(l,{style:y.retryText,children:"Try again"})})]})}function qd({error:e,onRetry:t}){let o=/fetch failed|network|ECONN|timed? ?out|socket/i.test(e)?"Couldn't reach your AI endpoint. Check the connection and try again.":"Something went wrong with that turn.";return ye(s,{style:y.errorBox,testID:"buoy-ask-buoy-error",children:[k(Zo,{size:14,color:x.color.danger}),ye(s,{style:y.errorBody,children:[k(l,{style:y.errorText,children:o}),k(l,{style:y.errorDetail,selectable:true,children:e}),t&&k(m,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:t,style:({pressed:r})=>[y.retry,r&&y.retryPressed],children:k(l,{style:y.retryText,children:"Try again"})})]})]})}var Fd=new Set(["credits_out","member_cap","plan_not_eligible","not_in_pilot","team_hosted_off","account_frozen","token_not_allowed","client_too_old","media_not_allowed","session_missing","session_revoked"]);function _d({error:e,info:t,onRetry:o}){let[r,n]=Xo("idle"),i=`Ask Buoy error ${t.code}${t.requestId?` \xB7 request ${t.requestId}`:""} \xB7 ${new Date().toISOString()}`,{copied:a,copy:g}=uo(()=>i),u=b.getReporter(),h=It(()=>{u&&(n("sending"),u({requestId:t.requestId,code:t.code,note:"Reported from the error card."}).then(f=>n({id:f.reportId})).catch(()=>n("failed")))},[u,t.code,t.requestId]);return ye(s,{style:y.errorBox,testID:"buoy-ask-buoy-error",children:[k(Zo,{size:14,color:x.color.danger}),ye(s,{style:y.errorBody,children:[k(l,{style:y.errorText,children:e}),ye(l,{style:y.errorDetail,selectable:true,testID:"buoy-ask-buoy-error-code",children:[t.code,t.requestId?` \xB7 ${t.requestId}`:""]}),ye(s,{style:y.transcriptActions,children:[o&&!Fd.has(t.code)&&k(m,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:o,style:({pressed:f})=>[y.retry,f&&y.retryPressed],children:k(l,{style:y.retryText,children:"Try again"})}),k(m,{testID:"buoy-ask-buoy-error-copy",accessibilityRole:"button",accessibilityLabel:"Copy details",onPress:g,style:({pressed:f})=>[y.retry,f&&y.retryPressed],children:k(l,{style:y.retryText,children:a?"Copied":"Copy details"})}),u&&k(m,{testID:"buoy-ask-buoy-error-report",accessibilityRole:"button",accessibilityLabel:"Report problem",disabled:r!=="idle"&&r!=="failed",onPress:h,style:({pressed:f})=>[y.retry,f&&y.retryPressed],children:k(l,{style:y.retryText,children:r==="sending"?"Sending\u2026":r==="failed"?"Report failed. Try again":typeof r=="object"?`Reported \xB7 ${r.id}`:"Report problem"})})]})]})]})}function ii(e,t=false){let o=[];for(let r of e){if(r.role==="user"){o.push(`You: ${r.text}`);continue}if(r.system){o.push(` \u2014 ${r.text}`);continue}if(t)o.push(...Xn(r));else for(let n of r.toolCalls){let i=Pd(n)?` (${n.status})`:"";o.push(` \xB7 ${n.label}${n.summary?` \u2014 ${n.summary}`:""}${i}`)}r.text&&o.push(`Ask Buoy: ${r.text}`);for(let n of ba(r.blocks.map(i=>i.block)))o.push(n);r.error&&o.push(` ! ${r.error}`),r.stopped&&!r.error&&o.push(" ! Stopped by the user.")}return o.join(`
|
|
12
|
+
`)}function Ud({testID:e,label:t,getText:o}){let{copied:r,copy:n}=uo(o);return ye(m,{testID:e,accessibilityRole:"button",accessibilityLabel:t,onPress:n,style:({pressed:i})=>[y.copyBtn,y.iconBtn,i&&y.copyPressed],children:[r?k(Kn,{size:11,color:x.color.accent}):k(kd,{size:11,color:x.color.textSecondary}),k(l,{style:[y.copyText,r&&y.copiedText],children:r?"Copied":t})]})}function Kd({message:e}){let{showThinking:t}=Ot(),o=It(()=>ii(b.getState().messages,t),[t]),r=gc(e);return ye(s,{style:y.transcriptActions,children:[r?k(l,{style:y.turnFooter,testID:"buoy-ask-buoy-turn-footer",children:r}):null,k(Ud,{testID:"buoy-ask-buoy-copy",label:"Copy conversation",getText:o})]})}var Jd=yd(function({message:e,onRetry:t,waitingOnUser:o}){if(e.role==="user")return k(Vd,{message:e});if(e.system)return k(Nd,{message:e});let r=!e.streaming&&!e.error;return ye(s,{children:[k(Md,{message:e,onRetry:t,waitingOnUser:o}),r&&k(Kd,{message:e})]})});function li({messages:e,ListHeaderComponent:t,ListEmptyComponent:o,ListFooterComponent:r,onRetry:n,waitingOnUser:i}){let a=Qo(null),g=Qo(true),u=Qo(false),h=It(pe=>{let{contentOffset:Pe,contentSize:qe,layoutMeasurement:We}=pe.nativeEvent,Xe=qe.height-We.height-Pe.y;g.current=Xe<80},[]),f=It(()=>{u.current=true},[]),T=It(pe=>{u.current&&h(pe)},[h]),O=It(pe=>{u.current=false,h(pe)},[h]),_=It(()=>{g.current&&(a.current?.scrollToEnd({animated:false}),requestAnimationFrame(()=>a.current?.scrollToEnd({animated:false})))},[]),ee=e[e.length-1],ce=ee?`${ee.id}:${ee.text.length}:${ee.toolCalls.length}:${ee.error??""}`:"";return md(()=>{_()},[ce,_]),k(br,{ref:a,testID:"buoy-ask-buoy-messages-scroll",style:y.list,contentContainerStyle:y.listContent,data:e,keyExtractor:pe=>pe.id,renderItem:({item:pe})=>k(Jd,{message:pe,onRetry:pe.id===ee?.id?n:void 0,waitingOnUser:pe.id===ee?.id?i:false}),onScroll:T,onScrollBeginDrag:f,onScrollEndDrag:O,onMomentumScrollEnd:h,scrollEventThrottle:32,onContentSizeChange:_,keyboardShouldPersistTaps:"handled",keyboardDismissMode:"interactive",ListHeaderComponent:t,ListEmptyComponent:o,ListFooterComponent:r})}var y=w.create({list:{flex:1,backgroundColor:"transparent"},listContent:{paddingHorizontal:x.gutter,paddingTop:12,paddingBottom:16,gap:16,flexGrow:1},userWrap:{alignItems:"flex-end"},userBubble:{maxWidth:"84%",paddingHorizontal:14,paddingVertical:9,borderRadius:18,borderBottomRightRadius:6,backgroundColor:x.color.accentFill,borderWidth:w.hairlineWidth,borderColor:x.color.accentBorder},userText:{color:x.color.text,fontSize:x.font.row,lineHeight:21},systemLine:{alignSelf:"stretch",paddingHorizontal:12,paddingVertical:7,borderRadius:x.radius.row,backgroundColor:x.color.fill},systemText:{color:x.color.textSecondary,fontSize:x.font.micro,lineHeight:16,textAlign:"center"},assistantWrap:{alignItems:"stretch",gap:10},blocks:{gap:10},waitingRow:{flexDirection:"row",alignItems:"center",gap:8},waitingText:{color:x.color.textSecondary,fontSize:x.font.caption},assistantText:{color:x.color.text,fontSize:x.font.row,lineHeight:22,paddingHorizontal:2},card:{borderRadius:x.radius.card,borderWidth:w.hairlineWidth,borderColor:x.color.border,backgroundColor:x.color.surface,overflow:"hidden"},row:{paddingHorizontal:12,paddingVertical:10},rowDivider:{borderBottomWidth:w.hairlineWidth,borderBottomColor:x.color.separator},rowLine:{flexDirection:"row",alignItems:"center",gap:10},markSlot:{width:18,height:18,alignItems:"center",justifyContent:"center"},mark:{width:16,height:16,borderRadius:8,alignItems:"center",justifyContent:"center"},markOk:{backgroundColor:x.color.accent},markFailed:{backgroundColor:x.color.danger},markRefused:{backgroundColor:x.color.warning},markNotRun:{borderWidth:1.5,borderColor:x.color.textTertiary},markNotRunBar:{width:7,height:1.5,borderRadius:1,backgroundColor:x.color.textSecondary},rowTitle:{flex:1,color:x.color.text,fontSize:x.font.body,lineHeight:19},rowStatus:{color:x.color.textTertiary,fontSize:x.font.caption,maxWidth:120},rowStatusDanger:{color:x.color.danger},rowStatusWarning:{color:x.color.warning},rowStatusOk:{color:x.color.accent},rowVerified:{color:x.color.accent},rowDetail:{paddingLeft:28,paddingTop:8,gap:4},rowTool:{color:x.color.textTertiary,fontSize:x.font.micro,fontWeight:"600",letterSpacing:.8},rowDescription:{color:x.color.textSecondary,fontSize:x.font.caption,lineHeight:18},rowFailure:{color:x.color.danger,fontSize:x.font.caption,lineHeight:18},rowReceipts:{paddingTop:10,gap:10},groupBody:{paddingLeft:14,backgroundColor:x.color.fill},stoppedBox:{alignItems:"flex-start",gap:2,paddingHorizontal:12,paddingVertical:8},stoppedText:{color:x.color.textTertiary,fontSize:x.font.caption,lineHeight:18},errorBox:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingVertical:10,borderRadius:x.radius.row,backgroundColor:x.color.dangerSoft},errorBody:{flex:1,gap:4},errorText:{color:x.color.danger,fontSize:x.font.caption,fontWeight:"600",lineHeight:18},errorDetail:{color:x.color.textSecondary,fontSize:x.font.micro,lineHeight:15},retry:{alignSelf:"flex-start",marginTop:6,paddingHorizontal:14,paddingVertical:7,borderRadius:x.radius.row,backgroundColor:x.color.button},retryPressed:{opacity:.7},retryText:{color:x.color.accent,fontSize:x.font.caption,fontWeight:"600"},transcriptActions:{flexDirection:"row",alignItems:"center",gap:10,marginTop:8},turnFooter:{flex:1,color:x.color.textTertiary,fontSize:x.font.micro,fontVariant:["tabular-nums"]},copyBtn:{paddingHorizontal:10,paddingVertical:5,borderRadius:x.radius.badge,backgroundColor:x.color.fill},iconBtn:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8},copyPressed:{opacity:.7},copyText:{color:x.color.textSecondary,fontSize:x.font.micro,fontWeight:"600"},copiedText:{color:x.color.accent}});import{night as Oe,X as Gd}from"@buoy-gg/shared-ui/web";import{jsx as Ht,jsxs as tr}from"react/jsx-runtime";var Yd=132;function Qd({items:e,paused:t,onEdit:o,onRemove:r}){return e.length===0?null:tr(s,{style:He.wrap,testID:"buoy-ask-buoy-queued",children:[Ht(Je,{style:He.list,contentContainerStyle:He.listContent,keyboardShouldPersistTaps:"handled",children:e.map((n,i)=>tr(s,{style:[He.row,t!==null&&He.rowPaused],children:[tr(m,{testID:`buoy-ask-buoy-queue-item-${i}`,accessibilityRole:"button",accessibilityLabel:`Edit queued message: ${n.text}`,onPress:()=>o(n.id),style:({pressed:a})=>[He.rowBody,a&&He.pressed],children:[Ht(l,{style:He.ordinal,children:i===0?"NEXT":"THEN"}),Ht(l,{style:He.text,numberOfLines:3,children:n.text})]}),Ht(m,{testID:`buoy-ask-buoy-queue-remove-${i}`,accessibilityRole:"button",accessibilityLabel:"Remove queued message",onPress:()=>r(n.id),hitSlop:8,style:({pressed:a})=>[He.remove,a&&He.pressed],children:Ht(Gd,{size:11,color:Oe.color.textTertiary})})]},n.id))}),Ht(l,{style:[He.hint,t!==null&&He.hintPaused],testID:"buoy-ask-buoy-queue-hint",children:t??"Sends one at a time when this turn finishes \xB7 tap to edit"})]})}var He=w.create({wrap:{paddingHorizontal:Oe.gutter,paddingTop:8,gap:6,backgroundColor:Oe.color.bg},list:{maxHeight:Yd},listContent:{gap:6},row:{flexDirection:"row",alignItems:"center",borderRadius:Oe.radius.row,borderWidth:w.hairlineWidth,borderColor:Oe.color.border,backgroundColor:Oe.color.surface},rowPaused:{borderColor:Oe.color.warning},rowBody:{flex:1,flexDirection:"row",alignItems:"center",gap:8,paddingVertical:7,paddingLeft:10},ordinal:{color:Oe.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.6,width:30},text:{flex:1,color:Oe.color.textSecondary,fontSize:Oe.font.caption,lineHeight:17},remove:{width:32,height:32,alignItems:"center",justifyContent:"center"},pressed:{opacity:.7},hint:{color:Oe.color.textTertiary,fontSize:Oe.font.micro},hintPaused:{color:Oe.color.warning}});var Xd="Summarize this conversation as a bug ticket, using one buoy_ui finding block and nothing else. Title it with the problem in one line. Evidence rows, in this order: Steps (what we did), Expected, Observed, Build (dev or release, platform), Evidence (the exact requests, statuses, logs or values you actually saw this conversation), Still applied (overrides or changes from your changes list that are still live, or 'none'). Only facts you observed in this conversation; write 'unknown' where you don't know rather than guessing, and put anything you inferred rather than saw in a final row labelled Inference. Do not run any tool or change anything to produce this.";import{Fragment as Zd,jsx as he,jsxs as Pt}from"react/jsx-runtime";function or({visible:e,onClose:t,onBack:o,onMinimize:r,persistenceKey:n,config:i}){let{state:a,send:g,stop:u,reset:h,undoThenReset:f,approve:T,retry:O,answer:_,runAction:ee,editQueued:ce,removeQueued:pe,configured:Pe,toolCount:qe,availableToolIds:We}=Fn(i),[Xe,Ze]=Co(false),et=Ke(()=>{u(),t()},[u,t]),Wt=Ke(()=>b.clearDraft(),[]),[tt,Ee]=Co(false),Et=Ke(()=>Ee(false),[]),Nt=Ke(()=>Ee(true),[]),ht=!e,Vt=!!a.pending||!!a.awaitingBlockId,Ce=a.messages[a.messages.length-1],gt=_t(false),Mt=_t(a.busy);Ft(()=>{ht&&Mt.current&&!a.busy&&(gt.current=true),ht||(gt.current=false),Mt.current=a.busy},[ht,a.busy]),Ft(()=>{if(!ht){Bt("ask-buoy",null);return}Vt?Bt("ask-buoy",{kind:"needsInput",label:a.pending?"Needs your approval":"Has a question for you"}):gt.current&&Ce?.role==="assistant"&&Ce.error?Bt("ask-buoy",{kind:"failed",label:"The last turn failed"}):gt.current&&!a.busy?Bt("ask-buoy",{kind:"done",label:"Finished"}):Bt("ask-buoy",null)},[ht,Vt,a.busy,a.pending,Ce]),Ft(()=>()=>Bt("ask-buoy",null),[]),Ft(()=>{a.pending&&tt&&Ee(false)},[a.pending,tt]);let Dt=kl({minBottom:16}),[ot,wo]=Co("bottomSheet"),ft=ot==="floating"?0:Dt.bottom,vo=Ke(()=>{let J=b.getLedger();J&&(async()=>{let ne=await J.revertAll(bl);if(ne.failed.length===0){b.setNotice(null);return}let $t=ne.failed.map(lo=>`${lo.label} (${lo.error})`).join("; ");b.setNotice(`Couldn't undo ${ne.failed.length} change${ne.failed.length===1?"":"s"} \u2014 ${$t}`)})()},[]),So=Ke(()=>Ze(J=>!J),[]),xt=_t(new ue.Value(560)).current,jt=_t(false),qt=Ke(()=>{jt.current||(jt.current=true,xt.stopAnimation(J=>{let ne=typeof J=="number"&&J>200?J:560;ue.timing(xt,{toValue:120,duration:220,useNativeDriver:false}).start(()=>{setTimeout(()=>{ue.spring(xt,{toValue:ne,friction:9,useNativeDriver:false}).start(()=>{jt.current=false})},2500)})}))},[xt]),Rt=so(()=>{let J=a.messages[a.messages.length-1];if(!J||J.role!=="assistant")return"";let ne=J.blocks.filter($t=>$t.block.kind==="peek").length;return ne>0?`${J.id}:${ne}`:""},[a.messages]),no=_t("");Ft(()=>{Rt&&Rt!==no.current&&i?.peek!==false&&qt(),no.current=Rt},[Rt,qt,i]);let To=Ke(()=>{let J=b.getLedger()?.list().filter(ne=>!ne.undoneAt&&fl(ne.effect)).length??0;if(J===0){h();return}Do.alert("Undo changes first?",`Ask Buoy made ${J} change${J===1?"":"s"} that can still be undone. Clearing the conversation loses the only automatic undo for ${J===1?"it":"them"}.`,[{text:"Undo, then clear",onPress:()=>{(async()=>{let ne=await f();if(ne.cleared)return;let $t=ne.reverted+ne.failed.length,lo=ne.failed.map(ur=>`${ur.label} (${ur.error})`).join(`
|
|
13
|
+
`);Do.alert(`Couldn't undo ${ne.failed.length} of ${$t} change${$t===1?"":"s"}`,`${lo}
|
|
14
14
|
|
|
15
|
-
Still applied in the app. Clear the conversation anyway?`,[{text:"Keep conversation",style:"cancel"},{text:"Clear anyway",style:"destructive",onPress:
|
|
15
|
+
Still applied in the app. Clear the conversation anyway?`,[{text:"Keep conversation",style:"cancel"},{text:"Clear anyway",style:"destructive",onPress:h}])})()}},{text:"Clear anyway",style:"destructive",onPress:h},{text:"Cancel",style:"cancel"}])},[h,f]),S=so(()=>{let J=a.messages[a.messages.length-1];return!J||J.role!=="assistant"||!J.streaming?null:J.toolCalls.find(ne=>ne.status==="running")?.label??null},[a.messages]),V=sn(b.getLedger()),q=so(()=>Ks(V),[V]),de=so(()=>({answer:_,runAction:(J,ne)=>{if(J.minimize){r?.({mode:"bottomSheet"});return}return ee(J,ne)},answered:a.answers,actionState:a.actionState,busy:a.busy,supports:{openTool:false,minimize:!!r,dispatch:true},rules:q}),[_,ee,r,a.answers,a.actionState,a.busy,q]),Re=!a.busy&&Ce?.role==="assistant"&&!!Ce.error,Q=!a.busy&&Ce?.role==="assistant"&&Ce.stopped&&!Ce.error?Ce.id:null,io=Bn(a),{showThinking:sr,readOnly:cr,claudeNoticeSeen:ui}=Ot(),dr=i?.hosted===true&&!ui,pi=Ke(()=>ii(a.messages,sr),[a.messages,sr]),hi=Ke(()=>g(Xd),[g]),gi=tt?Pt(Ro,{children:[he(Ro.Navigation,{onBack:Et}),he(Ro.Content,{title:"Settings",subtitle:"Ask Buoy",testID:"buoy-ask-buoy-settings-title"})]}):he(kn,{configured:Pe,busy:a.busy,failed:Re,activeLabel:S,awaitingApproval:!!a.pending,startedAt:Ce?.role==="assistant"&&Ce.streaming?Ce.startedAt??null:null,stopping:a.stopping,readOnly:cr,toolCount:qe,hasMessages:a.messages.length>0,onBack:o,onReset:To,getTranscript:pi,onOpenSettings:Nt,onTicket:hi});return he(ml,{visible:e,onClose:et,disableScrollWrapper:true,background:false,initialHeight:560,animatedHeight:xt,header:{customContent:gi,showToggleButton:false},onBack:o,onMinimize:r,onModeChange:wo,persistenceKey:n??"buoy-ask-buoy",enablePersistence:true,children:he(Ir,{value:de,children:Pt(s,{style:[zt.root,{paddingBottom:ft}],children:[he(cn,{ledger:b.getLedger(),onUndoAll:vo,expanded:Xe,onToggle:So}),dr&&Pt(s,{style:zt.notice,testID:"buoy-ask-buoy-hosted-notice",children:[he(Sr,{size:14,color:Ge.color.info}),Pt(s,{style:{flex:1,gap:8},children:[he(l,{style:zt.noticeText,children:"Hosted Ask Buoy (beta) sends your question, and the app data it needs to answer, to Anthropic for Claude. If Claude is down, it goes to OpenAI through OpenRouter for Luna instead. Buoy keeps the cost of each answer, never the chat. Your plan includes weekly credits."}),he(m,{testID:"buoy-ask-buoy-hosted-notice-ok",accessibilityRole:"button",onPress:()=>{st.set("claudeNoticeSeen",true),st.set("hostedNoticeSeen",true)},style:({pressed:J})=>[zt.noticeButton,J&&{opacity:.7}],children:he(l,{style:zt.noticeButtonText,children:"Got it"})})]})]}),a.notice&&Pt(s,{style:zt.notice,testID:"buoy-ask-buoy-notice",children:[he(Sr,{size:14,color:Ge.color.info}),he(l,{style:zt.noticeText,children:a.notice})]}),he(oc,{children:he(yl,{featureName:"Ask Buoy",children:tt?he(_n,{}):Pt(Zd,{children:[he(li,{messages:a.messages,onRetry:O,waitingOnUser:!!a.pending||!!a.awaitingBlockId,ListEmptyComponent:he(fd,{configured:Pe,onPick:g,availableToolIds:We,readOnly:cr||!!i?.policy?.readOnly})}),he(Qd,{items:a.queued,paused:io,onEdit:ce,onRemove:pe}),a.pending&&he(nn,{pending:a.pending,onAnswer:T}),he(hn,{onSend:g,onStop:u,busy:a.busy,draft:a.draft,onDraftTaken:Wt,disabled:!Pe||dr,focusKey:Q,canFocus:e,placeholder:Q?"Tell it what to do differently\u2026":a.awaitingBlockId?"Pick an option above, or type\u2026":void 0})]})})})]})})})}var zt=w.create({root:{flex:1,backgroundColor:"transparent"},notice:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:Ge.gutter,paddingVertical:10,backgroundColor:Ge.color.infoSoft},noticeText:{flex:1,color:Ge.color.text,fontSize:Ge.font.caption,lineHeight:18},noticeButton:{alignSelf:"flex-start",paddingHorizontal:12,paddingVertical:6,borderRadius:Ge.radius.row,backgroundColor:Ge.color.button},noticeButtonText:{color:Ge.color.text,fontSize:Ge.font.caption,fontWeight:"600"}});import{AskBuoyIcon as ai,ASK_BUOY_ICON_COLOR as si}from"@buoy-gg/floating-tools-core/web";import{jsx as ci}from"react/jsx-runtime";var xo={id:"ask-buoy",name:"ASK BUOY",description:"Ask about this app in plain English",slot:"both",color:si,icon:({size:e,slot:t})=>ci(ai,{size:t==="dial"?e*1.5:e}),component:or};function eu(e){let{name:t,description:o,...r}=e,n=r;return{...xo,name:t??xo.name,description:o??xo.description,component:i=>ci(or,{...i,config:n})}}import{isReversible as rr}from"@buoy-gg/agent-core/web";var nr=1,tu={version:nr,async dispose(e){let t=b.getLedger();for(let o of t?.list()??[])o.undoneAt||o.effect.kind==="network-override"&&await e("network","deleteOverrideRule",{id:o.effect.ruleId})},getSnapshot(){let e=b.getState(),t=(b.getLedger()?.list()??[]).filter(o=>!o.undoneAt);return{version:nr,busy:e.busy,configured:e.configured,notice:e.notice,messageCount:e.messages.length,messages:e.messages.map(o=>({id:o.id,role:o.role,text:to(o.text),streaming:!!o.streaming,toolCalls:o.toolCalls.map(r=>({toolId:r.toolId,action:r.action,status:r.status}))})),usage:e.usage,pendingApproval:e.pending?{toolId:e.pending.toolId,action:e.pending.action,label:e.pending.label}:null,changes:{reversible:t.filter(o=>rr(o.effect)).length,permanent:t.filter(o=>o.effect.kind!=="transient"&&!rr(o.effect)).length,transients:t.filter(o=>o.effect.kind==="transient").length,items:t.map(o=>({kind:o.effect.kind,label:o.effect.label}))}}},subscribe(e){let t=b.subscribe(e),o=b.getLedger()?.subscribe(e);return()=>{t(),o?.()}},actions:{listChanges:()=>(b.getLedger()?.list()??[]).filter(e=>!e.undoneAt).map(e=>({id:e.id,at:e.at,toolId:e.toolId,action:e.action,kind:e.effect.kind,label:e.effect.label,reversible:rr(e.effect)})),undoAll:async()=>{let e=b.getLedger();return e?{ok:true,...await e.revertAll(Nn)}:{ok:false,error:"No Ask Buoy session on this device."}},reset:async()=>{let e=await Mn({dispatch:Nn,undoFirst:true});return e.cleared?{ok:true,reverted:e.reverted}:{ok:false,error:`Couldn't undo ${e.failed.length} change${e.failed.length===1?"":"s"} \u2014 conversation kept.`,failed:e.failed}}}};import*as ou from"@buoy-gg/license/web";import{HOSTED_HEADERS as kt,HOSTED_PROTOCOL_VERSION as ru}from"@buoy-gg/agent-core/web";var di="https://ai.buoy.gg/v1/chat/completions",ir="openai/gpt-6-luna",nu=10*6e4;async function lr(e=false){let t=ou.SessionManager;if(!t)return null;let o=t.getStatus();return o.state==="active"&&(e||o.grace||(o.validUntil??0)-Date.now()<nu)&&await t.refresh(true),t.getAccessToken()}function ar(e){let t=/^(https?:\/\/[^/]+)/.exec(e);return t?t[1]:e}function iu(e={}){let{endpoint:t=di,...o}=e,r=`ask-buoy ${we.OS}`;return{...o,endpoint:t,hosted:true,protocol:"openai",model:ir,hostedModels:{luna:{endpoint:t,protocol:"openai",model:ir},claude:{endpoint:`${ar(t)}/v1/messages`,protocol:"anthropic",model:jn}},maxTokens:8192,headers:async n=>{let i=await lr((n?.attempt??1)>1);return{...i?{[kt.session]:i}:{},[kt.ask]:n?.askId??"ask_unknown000",[kt.round]:String(n?.round??1),[kt.attempt]:String(n?.attempt??1),[kt.protocol]:String(ru),[kt.client]:r}},readUsage:async()=>{let n=await lr();if(!n)throw new Error("Sign in to see hosted credits.");let i=await fetch(`${ar(t)}/v1/usage`,{headers:{[kt.session]:n}});if(!i.ok)throw new Error(`usage HTTP ${i.status}`);let a=await i.json();return{creditsLeft:a.creditsLeft??0,grantCredits:a.grantCredits??0,spentCredits:a.spentCredits??0,resetAt:a.resetAt??null,...a.claude?{claude:{available:a.claude.available===true,reason:typeof a.claude.reason=="string"?a.claude.reason:null}}:{}}},reportProblem:async({requestId:n,code:i,note:a})=>{let g=await lr(),u=await fetch(`${ar(t)}/v1/report`,{method:"POST",headers:{"Content-Type":"application/json",...g?{[kt.session]:g}:{}},body:JSON.stringify({request_id:n,code:i,note:a,client:r})});if(!u.ok)throw new Error(`report HTTP ${u.status}`);let h=await u.json();if(!h.report_id)throw new Error("report: no id");return{reportId:h.report_id}}}}export{nr as ASK_BUOY_ADAPTER_VERSION,si as ASK_BUOY_ICON_COLOR,nn as ApprovalCard,kn as AskBuoyHeader,ai as AskBuoyIcon,or as AskBuoyModal,_n as AskBuoySettings,Ve as BlockActionRow,W as BlockCard,Ir as BlockHandlersProvider,go as BlockRenderer,cn as ChangesBar,hn as Composer,Vs as EditableUserBubble,Ps as ElapsedRow,di as HOSTED_ENDPOINT,ir as HOSTED_MODEL,tn as LivePill,Er as Markdown,Os as MessageActions,li as MessageList,Br as ProvenanceBadge,Ws as QueuedComposer,Hs as ReasoningStrip,Es as ReloadDivider,Zn as ThinkingStrip,Ns as Timestamp,st as askBuoySettings,b as askBuoyStore,tu as askBuoySyncAdapter,xo as askBuoyToolPreset,eu as createAskBuoyTool,Qn as hasTrace,iu as hostedAskBuoy,to as redactForWire,er as traceEntries,Xn as traceToText,Fn as useAskBuoy,Ot as useAskBuoySettings,ko as useAskBuoyState,oe as useBlockHandlers};
|