@buoy-gg/ask-buoy 7.0.77 → 7.0.79
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/blocks/ExtraBlocks.js +1 -1
- package/lib/commonjs/blocks/choiceLogic.js +1 -0
- package/lib/commonjs/blocks/choiceLogic.test.js +1 -0
- package/lib/commonjs/components/ApprovalCard.js +1 -1
- package/lib/commonjs/components/AskBuoyModal.js +2 -2
- package/lib/commonjs/components/AskBuoySettings.js +1 -1
- package/lib/commonjs/components/EmptyState.js +1 -1
- package/lib/commonjs/components/Markdown.js +1 -1
- package/lib/commonjs/components/sheetText.test.js +1 -0
- package/lib/commonjs/store/askBuoyStore.js +2 -2
- package/lib/commonjs/store/transcriptPersistence.js +1 -1
- package/lib/commonjs/store/transcriptPersistence.test.js +1 -1
- package/lib/commonjs/store/useAskBuoy.js +1 -1
- package/lib/module/blocks/ExtraBlocks.js +1 -1
- package/lib/module/blocks/choiceLogic.js +1 -0
- package/lib/module/blocks/choiceLogic.test.js +1 -0
- package/lib/module/components/ApprovalCard.js +1 -1
- package/lib/module/components/AskBuoyModal.js +2 -2
- package/lib/module/components/AskBuoySettings.js +1 -1
- package/lib/module/components/EmptyState.js +1 -1
- package/lib/module/components/Markdown.js +1 -1
- package/lib/module/components/sheetText.test.js +1 -0
- package/lib/module/store/askBuoyStore.js +1 -1
- package/lib/module/store/transcriptPersistence.js +1 -1
- package/lib/module/store/transcriptPersistence.test.js +1 -1
- package/lib/module/store/useAskBuoy.js +1 -1
- package/lib/typescript/blocks/choiceLogic.d.ts +41 -0
- package/lib/typescript/blocks/choiceLogic.test.d.ts +2 -0
- package/lib/typescript/components/sheetText.test.d.ts +2 -0
- package/lib/typescript/store/askBuoyStore.d.ts +6 -0
- package/lib/typescript/store/transcriptPersistence.d.ts +14 -0
- package/lib/typescript/sync/wire.d.ts +8 -6
- package/lib/web/index.mjs +11 -11
- package/package.json +7 -7
- package/lib/commonjs/blocks/AskBlocks.test.js +0 -1
- package/lib/commonjs/components/Composer.test.js +0 -1
- package/lib/commonjs/components/EmptyState.test.js +0 -1
- package/lib/module/blocks/AskBlocks.test.js +0 -1
- package/lib/module/components/Composer.test.js +0 -1
- package/lib/module/components/EmptyState.test.js +0 -1
- package/lib/typescript/blocks/AskBlocks.test.d.ts +0 -2
- package/lib/typescript/components/Composer.test.d.ts +0 -2
- package/lib/typescript/components/EmptyState.test.d.ts +0 -2
package/lib/web/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use client";var yr=Object.defineProperty;var Ci=Object.getOwnPropertyDescriptor;var Ii=Object.getOwnPropertyNames;var zi=Object.prototype.hasOwnProperty;var Di=(e,t)=>{for(var o in t)yr(e,o,{get:t[o],enumerable:true})},mr=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ii(t))!zi.call(e,n)&&n!==o&&yr(e,n,{get:()=>t[n],enumerable:!(r=Ci(t,n))||r.enumerable});return e},Ri=(e,t,o)=>(mr(e,t,"default"),o&&mr(o,t,"default"));var co=(()=>{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 Ue,useEffect as Ut,useMemo as uo,useRef as Kt,useState as Do}from"react";var xr={};Di(xr,{AccessibilityInfo:()=>Li,ActivityIndicator:()=>Yt,Alert:()=>Bo,Animated:()=>ue,AppRegistry:()=>Hi,AppState:()=>Pi,Appearance:()=>Oi,BackHandler:()=>Wi,Button:()=>Cl,CheckBox:()=>Ji,Clipboard:()=>Ei,DeviceEventEmitter:()=>cl,Dimensions:()=>Vi,Easing:()=>At,FlatList:()=>wr,I18nManager:()=>Ni,Image:()=>wt,ImageBackground:()=>Yi,InteractionManager:()=>ji,Keyboard:()=>Ro,KeyboardAvoidingView:()=>Qi,LayoutAnimation:()=>Mi,Linking:()=>qi,LogBox:()=>sl,Modal:()=>Tl,NativeEventEmitter:()=>Fi,NativeModules:()=>Bi,PanResponder:()=>_i,Picker:()=>Xi,PixelRatio:()=>Ui,Platform:()=>we,Pressable:()=>x,ProgressBar:()=>Zi,RefreshControl:()=>el,SafeAreaView:()=>tl,ScrollView:()=>Ke,SectionList:()=>ol,Share:()=>kr,StatusBar:()=>rl,StyleSheet:()=>v,Switch:()=>Dr,Text:()=>l,TextInput:()=>rt,Touchable:()=>nl,TouchableHighlight:()=>vl,TouchableNativeFeedback:()=>il,TouchableOpacity:()=>Jt,TouchableWithoutFeedback:()=>Sl,UIManager:()=>Ki,Vibration:()=>Gi,View:()=>s,VirtualizedList:()=>ll,YellowBox:()=>al,findNodeHandle:()=>Il,unstable_createElement:()=>Ai,useColorScheme:()=>dl,useLocaleContext:()=>ul,useWindowDimensions:()=>vr});Ri(xr,$i);import*as $i from"react-native-web";import{unstable_createElement as Ai,NativeModules as Bi,AccessibilityInfo as Li,Appearance as Oi,AppRegistry as Hi,AppState as Pi,BackHandler as Wi,Clipboard as Ei,Dimensions as Vi,Easing as At,I18nManager as Ni,Keyboard as Ro,InteractionManager as ji,LayoutAnimation as Mi,Linking as qi,NativeEventEmitter as Fi,PanResponder as _i,PixelRatio as Ui,Platform as we,Share as kr,UIManager as Ki,Vibration as Gi,CheckBox as Ji,FlatList as wr,Image as wt,ImageBackground as Yi,KeyboardAvoidingView as Qi,Picker as Xi,ProgressBar as Zi,RefreshControl as el,SafeAreaView as tl,SectionList as ol,StatusBar as rl,Touchable as nl,TouchableNativeFeedback as il,VirtualizedList as ll,YellowBox as al,LogBox as sl,DeviceEventEmitter as cl,useColorScheme as dl,useLocaleContext as ul,useWindowDimensions as vr}from"react-native-web";import*as Ie from"react-native-web";import{createElement as $o,forwardRef as Sr,useCallback as pl,useRef as hl}from"react";import{useEffect as gl,useState as fl}from"react";import{createPortal as bl}from"react-dom";var yl='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as ml}from"react/jsx-runtime";var Gt=Symbol.for("@buoy-gg/portal-host"),Tr=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 Cr(){let e=document;if(e[Gt])return e[Gt].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:yl});let o=()=>{let f=document.fullscreenElement,m=f&&f.tagName!=="CANVAS"?f:document.body;t.parentElement!==m&&m.appendChild(t)},r=new Map,n=f=>{(!t.contains(f.target)||!Tr(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 m of f)document.dispatchEvent(new KeyboardEvent("keyup",{...m,bubbles:true}))},d=f=>{Tr(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",d),t.addEventListener("keyup",d),t.addEventListener("keypress",d),t.addEventListener("wheel",h,{passive:true}),e[Gt]={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[Gt]}},t}function xl({children:e}){let[t,o]=fl(null);return gl(()=>{let r=Cr(),n=document[Gt];return n.users++,o(r),()=>{--n.users===0&&n.dispose()}},[]),t?bl(ml("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var Bt=Ie,kl=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],Lt=e=>typeof e=="number"?`${e}px`:e;function Ao(e){if(Array.isArray(e)){let m=e.map(Ao);return m.some((L,V)=>L!==e[V])?m:e}if(!e||typeof e!="object"||!kl.some(m=>e[m]!=null))return e;let{shadowColor:t,shadowOffset:o,shadowOpacity:r,shadowRadius:n,textShadowColor:i,textShadowOffset:a,textShadowRadius:g,...d}=e;if(t!=null||o!=null||r!=null||n!=null){let m=t??"black",L=r==null?m:`color-mix(in srgb, ${m} ${Math.min(r,1)*100}%, transparent)`,V=`${Lt(o?.width??0)} ${Lt(o?.height??0)} ${Lt(n??0)} ${L}`;d.boxShadow=typeof d.boxShadow=="string"?`${d.boxShadow}, ${V}`:d.boxShadow??V}let{width:h=0,height:f=0}=a??{};if(i&&(h||f||g)){let m=`${Lt(h)} ${Lt(f)} ${Lt(g??0)} ${i}`;d.textShadow=d.textShadow?`${d.textShadow}, ${m}`:m}return d}var wl=Bt.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});function Ir(e,t){if(typeof e=="function")return r=>Ir(e(r),t);let o=Ao(e);return t?[o,wl[t]]:o}var v={...Bt.StyleSheet,create:e=>Bt.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,o])=>[t,Ao(o)])))};function Ve(e){let t=Sr((r,n)=>{let{accessibilityState:i,accessibilityValue:a,pointerEvents:g,...d}=r;for(let f of["busy","checked","disabled","expanded","selected"])i?.[f]!==void 0&&d[`aria-${f}`]===void 0&&(d[`aria-${f}`]=i[f]);for(let[f,m]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))a?.[f]!==void 0&&d[`aria-${m}`]===void 0&&(d[`aria-${m}`]=a[f]);let h=Ir(d.style,g);return h!==d.style&&(d.style=h),$o(e,{...d,ref:n})}),o=e.State;return o&&Object.assign(t,{State:o}),t.displayName=e.displayName??e.name??"NativeWebView",t}var s=Ve(Ie.View),l=Ve(Ie.Text),ue={...Bt.Animated,View:Bt.Animated.createAnimatedComponent(s),Text:Bt.Animated.createAnimatedComponent(l)},rt=Ve(Ie.TextInput),Jt=Ve(Ie.TouchableOpacity),vl=Ve(Ie.TouchableHighlight),Sl=Ve(Ie.TouchableWithoutFeedback),x=Ve(Ie.Pressable),Ke=Ve(Ie.ScrollView),zr=Sr((e,t)=>{let o=hl(null),r=pl(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"}),Cr().appendChild(i))}else o.current&&(document.body.appendChild(o.current),o.current=null);typeof t=="function"?t(n):t&&(t.current=n)},[t]);return $o(xl,null,$o(Ie.Modal,{...e,ref:r}))});zr.displayName="Modal";var Tl=Ve(zr),Dr=Ve(Ie.Switch),Yt=Ve(Ie.ActivityIndicator),Cl=Ve(Ie.Button),Il=Ie.findNodeHandle,Bo={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"}],d=()=>{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=()=>{d(),h.onPress?.()},a.appendChild(f)}n.addEventListener("cancel",h=>{h.preventDefault(),r?.cancelable!==false&&(d(),r?.onDismiss?.())}),n.appendChild(a),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}};import{isReversible as zl}from"@buoy-gg/agent-core/web";import{dispatchToolAction as Dl,FeatureGate as Rl,Info as Rr,JsModal as $l,ModalHeader as Lo,night as Ge,setToolAttention as Ot,useSafeAreaInsets as Al}from"@buoy-gg/shared-ui/web";import{Component as Bl}from"react";import{night as $r}from"@buoy-gg/shared-ui/web";import{useState as Ll}from"react";import{Check as Ol,ChevronRight as Hl,night as M}from"@buoy-gg/shared-ui/web";import{createContext as Pl,useContext as Wl}from"react";import{jsx as El}from"react/jsx-runtime";var Vl={answer:()=>{},runAction:()=>{},answered:{},supports:{}},Ar=Pl(Vl);function Br({value:e,children:t}){return El(Ar.Provider,{value:e,children:t})}function oe(){return Wl(Ar)}function Nl(e,t){return`${e}:${t.label}`}import{AlertTriangle as jl,Check as Ml,Clock as ql,Database as Fl,Eye as _l,Globe as Ul,Image as Kl,Info as Gl,Layers as Lr,Navigation as Jl,night as Qt,User as Yl}from"@buoy-gg/shared-ui/web";import{jsx as Ae}from"react/jsx-runtime";function Or({name:e,size:t=14}){let o=Qt.color.textSecondary,r=(()=>{switch(e){case"network":return Ae(Ul,{size:t,color:o});case"storage":return Ae(Fl,{size:t,color:o});case"route":return Ae(Jl,{size:t,color:o});case"screen":return Ae(_l,{size:t,color:o});case"user":return Ae(Yl,{size:t,color:o});case"image":return Ae(Kl,{size:t,color:o});case"check":return Ae(Ml,{size:t,color:Qt.color.accent});case"warn":return Ae(jl,{size:t,color:Qt.color.warning});case"info":return Ae(Gl,{size:t,color:Qt.color.info});case"store":return Ae(Lr,{size:t,color:o});case"query":return Ae(Lr,{size:t,color:o});case"clock":return Ae(ql,{size:t,color:o})}})();return Ae(s,{style:Ql.wrap,children:r})}var Ql=v.create({wrap:{width:24,height:24,borderRadius:6,backgroundColor:Qt.color.fill,alignItems:"center",justifyContent:"center"}});import{monoFont as Xl}from"@buoy-gg/shared-ui/web";import{useState as Hr}from"react";import{Check as Zl,ChevronDown as Pr,ChevronUp as Wr,night as I,X as ea}from"@buoy-gg/shared-ui/web";function ta(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 Er({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:[_.badge,{borderColor:o}],children:ve(l,{style:[_.badgeText,{color:o}],children:t})})}function W({title:e,source:t,children:o,testID:r,tone:n,collapsible:i,summary:a}){let[g,d]=Hr(false),h=!!i&&!g;return nt(s,{style:[_.card,n==="warning"&&_.cardWarning,n==="danger"&&_.cardDanger,n==="info"&&_.cardInfo],testID:r,children:[(e||t&&t!=="live")&&nt(s,{style:_.titleRow,children:[e?ve(l,{style:_.title,numberOfLines:2,children:e}):ve(s,{style:_.flex}),ve(Er,{source:t})]}),i?nt(x,{testID:r?`${r}-toggle`:void 0,onPress:()=>d(f=>!f),accessibilityRole:"button",accessibilityState:{expanded:g},accessibilityLabel:`${a??"Details"}, ${g?"hide":"show"}`,style:({pressed:f})=>[_.disclosure,!h&&_.disclosureOpen,f&&_.pressed],children:[ve(l,{style:_.disclosureText,numberOfLines:1,children:a??"Details"}),h?ve(Pr,{size:12,color:I.color.textTertiary}):ve(Wr,{size:12,color:I.color.textTertiary})]}):null,h?null:o]})}var oa=5;function it(e,t,o=oa){let[r,n]=Hr(t),{hidden:i,next:a,expanded:g,canExpand:d,canCollapse:h}=ta(e.length,t,r,o);return{visible:e.slice(0,r),hidden:i,next:a,expanded:g,showMore:d?()=>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:_.moreRow,children:[o?nt(x,{testID:"buoy-block-show-more",onPress:o,style:[_.more,_.moreCell],accessibilityRole:"button",children:[nt(l,{style:_.moreText,children:["Show ",t," more"]}),ve(Pr,{size:12,color:I.color.textTertiary})]}):null,r?nt(x,{testID:"buoy-block-show-fewer",onPress:r,style:[_.more,_.moreCell],accessibilityRole:"button",children:[ve(l,{style:_.moreText,children:"Show fewer"}),ve(Wr,{size:12,color:I.color.textTertiary})]}):null]})}function ra({shown:e,total:t}){return!t||t<=e?null:ve(s,{style:_.more,children:nt(l,{style:_.moreNote,children:[e," of ",t," shown"]})})}function Ne({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:[_.actions,o==="right"&&_.actionsRight],children:n.slice(0,2).map(i=>{let a=r.actionState?.[Nl(t,i)],g=!!r.busy||a==="running"||a==="done";return nt(x,{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:d})=>[_.button,i.primary?_.buttonPrimary:_.buttonPlate,g&&_.buttonDisabled,d&&!g&&_.pressed],children:[a==="running"?ve(Yt,{size:"small",color:i.primary?I.color.onAccent:I.color.text}):a==="done"?ve(Zl,{size:12,color:i.primary?I.color.onAccent:I.color.accent}):a==="failed"?ve(ea,{size:12,color:I.color.danger}):null,ve(l,{style:[_.buttonText,i.primary?_.buttonTextPrimary:_.buttonTextPlate],children:i.label})]},i.label)})})}var D=v.create({row:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},rowDivider:{borderTopWidth:v.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"?Xl:"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}}),_=v.create({card:{borderRadius:I.radius.card,borderWidth:v.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:v.hairlineWidth,borderBottomColor:I.color.separator},disclosureText:{flex:1,color:I.color.textSecondary,fontSize:I.font.caption},badge:{borderWidth:v.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:v.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 na,jsx as ie,jsxs as St}from"react/jsx-runtime";function ia({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:[e.questionInAnswer?null:ie(l,{style:q.question,children:e.question}),ie(s,{style:[q.options,e.questionInAnswer&&q.optionsAlone],children:e.options.slice(0,5).map((i,a)=>{let g=r===i.id;return St(x,{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:d})=>[q.option,a>0&&q.optionDivider,g&&q.optionChosen,n&&!g&&q.optionDimmed,d&&!n&&q.pressed],children:[i.icon?ie(Or,{name:i.icon}):null,St(s,{style:q.optionText,children:[ie(l,{style:[q.optionLabel,g&&q.optionLabelChosen],children:i.label}),i.detail?ie(l,{style:q.optionDetail,children:i.detail}):null]}),g?ie(Ol,{size:14,color:M.color.accent}):n?null:ie(Hl,{size:14,color:M.color.textTertiary})]},i.id)})}),!n&&e.allowFreeText!==false?ie(l,{style:q.hint,children:"Or just type your answer below."}):null]})}function la({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:q.confirmTitle,children:e.title}),ie(l,{style:q.confirmChange,children:e.change}),e.consequence?ie(l,{style:q.confirmConsequence,children:e.consequence}):null,ie(s,{style:q.confirmActions,children:r?ie(l,{style:q.decided,children:n?`\u2713 ${e.approveLabel??"Done"}`:`\u2715 ${e.declineLabel??"Not now"}`}):St(na,{children:[ie(x,{testID:"buoy-block-approve",accessibilityRole:"button",onPress:()=>t.answer({blockId:e.id,kind:"confirm",approved:true}),style:({pressed:i})=>[q.button,q.buttonPrimary,i&&q.pressed],children:ie(l,{style:q.buttonTextPrimary,children:e.approveLabel??"Do it"})}),ie(x,{testID:"buoy-block-decline",accessibilityRole:"button",onPress:()=>t.answer({blockId:e.id,kind:"confirm",approved:false}),style:({pressed:i})=>[q.button,q.buttonPlate,i&&q.pressed],children:ie(l,{style:q.buttonTextPlate,children:e.declineLabel??"Not now"})})]})})]})}function aa({block:e}){let t=oe(),o=t.answered[e.id],r=!!o,[n,i]=Ll(""),a=e.type==="secret",g=()=>{let d=n.trim();d&&t.answer({blockId:e.id,kind:"input",value:d})};return St(W,{testID:`buoy-block-input-${e.id}`,tone:r?void 0:"info",children:[ie(l,{style:q.question,children:e.label}),r?ie(l,{style:q.decided,children:o.kind==="input"?a?"\u2022\u2022\u2022\u2022\u2022\u2022":o.value:"(skipped)"}):St(s,{style:q.inputRow,children:[ie(rt,{testID:"buoy-block-input-field",style:q.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(x,{testID:"buoy-block-input-submit",accessibilityRole:"button",disabled:!n.trim(),onPress:g,style:({pressed:d})=>[q.button,q.buttonPrimary,!n.trim()&&q.buttonDisabled,d&&q.pressed],children:ie(l,{style:q.buttonTextPrimary,children:e.submitLabel??"Send"})})]})]})}var q=v.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"},optionsAlone:{marginTop:8},option:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:11},optionDivider:{borderTopWidth:v.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 Vr}from"@buoy-gg/shared-ui/web";import{useState as Nr}from"react";import{AlertTriangle as sa,Check as ca,Info as da,night as B,X as ua}from"@buoy-gg/shared-ui/web";import{DataViewer as pa,TreeDiffViewer as ha}from"@buoy-gg/shared-ui/web/dataViewer";import{CAPS as Xt}from"@buoy-gg/agent-core/web";import{monoFont as jr}from"@buoy-gg/shared-ui/web";import{useState as ga}from"react";import{night as le}from"@buoy-gg/shared-ui/web";var Mr=e=>/^\s*\|.*\|\s*$/.test(e),fa=e=>/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(e),qr=e=>e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>t.trim()),ba=/^\s*```\s*([\w+-]*)\s*$/;function ya(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 yr=Object.defineProperty;var Di=Object.getOwnPropertyDescriptor;var Ri=Object.getOwnPropertyNames;var $i=Object.prototype.hasOwnProperty;var Ai=(e,t)=>{for(var o in t)yr(e,o,{get:t[o],enumerable:true})},mr=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ri(t))!$i.call(e,n)&&n!==o&&yr(e,n,{get:()=>t[n],enumerable:!(r=Di(t,n))||r.enumerable});return e},Bi=(e,t,o)=>(mr(e,t,"default"),o&&mr(o,t,"default"));var ho=(()=>{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 Je,useEffect as Gt,useMemo as go,useRef as Yt,useState as $o}from"react";var kr={};Ai(kr,{AccessibilityInfo:()=>Pi,ActivityIndicator:()=>Xt,Alert:()=>Oo,Animated:()=>pe,AppRegistry:()=>Ei,AppState:()=>Vi,Appearance:()=>Wi,BackHandler:()=>Ni,Button:()=>Dl,CheckBox:()=>Zi,Clipboard:()=>ji,DeviceEventEmitter:()=>pl,Dimensions:()=>Mi,Easing:()=>Ht,FlatList:()=>wr,I18nManager:()=>qi,Image:()=>Tt,ImageBackground:()=>Xi,InteractionManager:()=>Fi,Keyboard:()=>Ao,KeyboardAvoidingView:()=>el,LayoutAnimation:()=>_i,Linking:()=>Ui,LogBox:()=>ul,Modal:()=>zl,NativeEventEmitter:()=>Ki,NativeModules:()=>Hi,PanResponder:()=>Ji,Picker:()=>tl,PixelRatio:()=>Gi,Platform:()=>we,Pressable:()=>k,ProgressBar:()=>ol,RefreshControl:()=>rl,SafeAreaView:()=>nl,ScrollView:()=>Ge,SectionList:()=>il,Share:()=>xr,StatusBar:()=>ll,StyleSheet:()=>v,Switch:()=>Dr,Text:()=>l,TextInput:()=>rt,Touchable:()=>al,TouchableHighlight:()=>Cl,TouchableNativeFeedback:()=>sl,TouchableOpacity:()=>Zt,TouchableWithoutFeedback:()=>Il,UIManager:()=>Yi,Vibration:()=>Qi,View:()=>s,VirtualizedList:()=>cl,YellowBox:()=>dl,findNodeHandle:()=>Rl,unstable_createElement:()=>Oi,useColorScheme:()=>hl,useLocaleContext:()=>gl,useWindowDimensions:()=>vr});Bi(kr,Li);import*as Li from"react-native-web";import{unstable_createElement as Oi,NativeModules as Hi,AccessibilityInfo as Pi,Appearance as Wi,AppRegistry as Ei,AppState as Vi,BackHandler as Ni,Clipboard as ji,Dimensions as Mi,Easing as Ht,I18nManager as qi,Keyboard as Ao,InteractionManager as Fi,LayoutAnimation as _i,Linking as Ui,NativeEventEmitter as Ki,PanResponder as Ji,PixelRatio as Gi,Platform as we,Share as xr,UIManager as Yi,Vibration as Qi,CheckBox as Zi,FlatList as wr,Image as Tt,ImageBackground as Xi,KeyboardAvoidingView as el,Picker as tl,ProgressBar as ol,RefreshControl as rl,SafeAreaView as nl,SectionList as il,StatusBar as ll,Touchable as al,TouchableNativeFeedback as sl,VirtualizedList as cl,YellowBox as dl,LogBox as ul,DeviceEventEmitter as pl,useColorScheme as hl,useLocaleContext as gl,useWindowDimensions as vr}from"react-native-web";import*as Ie from"react-native-web";import{createElement as Bo,forwardRef as Sr,useCallback as fl,useRef as bl}from"react";import{useEffect as yl,useState as ml}from"react";import{createPortal as kl}from"react-dom";var xl='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as wl}from"react/jsx-runtime";var Qt=Symbol.for("@buoy-gg/portal-host"),Tr=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 Cr(){let e=document;if(e[Qt])return e[Qt].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:xl});let o=()=>{let f=document.fullscreenElement,y=f&&f.tagName!=="CANVAS"?f:document.body;t.parentElement!==y&&y.appendChild(t)},r=new Map,n=f=>{(!t.contains(f.target)||!Tr(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 y of f)document.dispatchEvent(new KeyboardEvent("keyup",{...y,bubbles:true}))},d=f=>{Tr(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",d),t.addEventListener("keyup",d),t.addEventListener("keypress",d),t.addEventListener("wheel",g,{passive:true}),e[Qt]={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[Qt]}},t}function vl({children:e}){let[t,o]=ml(null);return yl(()=>{let r=Cr(),n=document[Qt];return n.users++,o(r),()=>{--n.users===0&&n.dispose()}},[]),t?kl(wl("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var Pt=Ie,Sl=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],Wt=e=>typeof e=="number"?`${e}px`:e;function Lo(e){if(Array.isArray(e)){let y=e.map(Lo);return y.some(($,V)=>$!==e[V])?y:e}if(!e||typeof e!="object"||!Sl.some(y=>e[y]!=null))return e;let{shadowColor:t,shadowOffset:o,shadowOpacity:r,shadowRadius:n,textShadowColor:i,textShadowOffset:a,textShadowRadius:h,...d}=e;if(t!=null||o!=null||r!=null||n!=null){let y=t??"black",$=r==null?y:`color-mix(in srgb, ${y} ${Math.min(r,1)*100}%, transparent)`,V=`${Wt(o?.width??0)} ${Wt(o?.height??0)} ${Wt(n??0)} ${$}`;d.boxShadow=typeof d.boxShadow=="string"?`${d.boxShadow}, ${V}`:d.boxShadow??V}let{width:g=0,height:f=0}=a??{};if(i&&(g||f||h)){let y=`${Wt(g)} ${Wt(f)} ${Wt(h??0)} ${i}`;d.textShadow=d.textShadow?`${d.textShadow}, ${y}`:y}return d}var Tl=Pt.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});function Ir(e,t){if(typeof e=="function")return r=>Ir(e(r),t);let o=Lo(e);return t?[o,Tl[t]]:o}var v={...Pt.StyleSheet,create:e=>Pt.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,o])=>[t,Lo(o)])))};function Ee(e){let t=Sr((r,n)=>{let{accessibilityState:i,accessibilityValue:a,pointerEvents:h,...d}=r;for(let f of["busy","checked","disabled","expanded","selected"])i?.[f]!==void 0&&d[`aria-${f}`]===void 0&&(d[`aria-${f}`]=i[f]);for(let[f,y]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))a?.[f]!==void 0&&d[`aria-${y}`]===void 0&&(d[`aria-${y}`]=a[f]);let g=Ir(d.style,h);return g!==d.style&&(d.style=g),Bo(e,{...d,ref:n})}),o=e.State;return o&&Object.assign(t,{State:o}),t.displayName=e.displayName??e.name??"NativeWebView",t}var s=Ee(Ie.View),l=Ee(Ie.Text),pe={...Pt.Animated,View:Pt.Animated.createAnimatedComponent(s),Text:Pt.Animated.createAnimatedComponent(l)},rt=Ee(Ie.TextInput),Zt=Ee(Ie.TouchableOpacity),Cl=Ee(Ie.TouchableHighlight),Il=Ee(Ie.TouchableWithoutFeedback),k=Ee(Ie.Pressable),Ge=Ee(Ie.ScrollView),zr=Sr((e,t)=>{let o=bl(null),r=fl(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"}),Cr().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(vl,null,Bo(Ie.Modal,{...e,ref:r}))});zr.displayName="Modal";var zl=Ee(zr),Dr=Ee(Ie.Switch),Xt=Ee(Ie.ActivityIndicator),Dl=Ee(Ie.Button),Rl=Ie.findNodeHandle,Oo={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"}],d=()=>{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=()=>{d(),g.onPress?.()},a.appendChild(f)}n.addEventListener("cancel",g=>{g.preventDefault(),r?.cancelable!==false&&(d(),r?.onDismiss?.())}),n.appendChild(a),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}};import{isReversible as $l}from"@buoy-gg/agent-core/web";import{dispatchToolAction as Al,FeatureGate as Bl,Info as Rr,JsModal as Ll,ModalHeader as Ho,night as Ye,setToolAttention as Et,useSafeAreaInsets as Ol}from"@buoy-gg/shared-ui/web";import{Component as Hl}from"react";import{night as $r}from"@buoy-gg/shared-ui/web";import{useState as Pl}from"react";import{Check as Wl,ChevronRight as El,night as j}from"@buoy-gg/shared-ui/web";import{createContext as Vl,useContext as Nl}from"react";import{jsx as jl}from"react/jsx-runtime";var Ml={answer:()=>{},runAction:()=>{},answered:{},supports:{}},Ar=Vl(Ml);function Br({value:e,children:t}){return jl(Ar.Provider,{value:e,children:t})}function te(){return Nl(Ar)}function ql(e,t){return`${e}:${t.label}`}import{AlertTriangle as Fl,Check as _l,Clock as Ul,Database as Kl,Eye as Jl,Globe as Gl,Image as Yl,Info as Ql,Layers as Lr,Navigation as Zl,night as eo,User as Xl}from"@buoy-gg/shared-ui/web";import{jsx as Ae}from"react/jsx-runtime";function Or({name:e,size:t=14}){let o=eo.color.textSecondary,r=(()=>{switch(e){case"network":return Ae(Gl,{size:t,color:o});case"storage":return Ae(Kl,{size:t,color:o});case"route":return Ae(Zl,{size:t,color:o});case"screen":return Ae(Jl,{size:t,color:o});case"user":return Ae(Xl,{size:t,color:o});case"image":return Ae(Yl,{size:t,color:o});case"check":return Ae(_l,{size:t,color:eo.color.accent});case"warn":return Ae(Fl,{size:t,color:eo.color.warning});case"info":return Ae(Ql,{size:t,color:eo.color.info});case"store":return Ae(Lr,{size:t,color:o});case"query":return Ae(Lr,{size:t,color:o});case"clock":return Ae(Ul,{size:t,color:o})}})();return Ae(s,{style:ea.wrap,children:r})}var ea=v.create({wrap:{width:24,height:24,borderRadius:6,backgroundColor:eo.color.fill,alignItems:"center",justifyContent:"center"}});import{monoFont as ta}from"@buoy-gg/shared-ui/web";import{useState as Hr}from"react";import{Check as oa,ChevronDown as Pr,ChevronUp as Wr,night as I,X as ra}from"@buoy-gg/shared-ui/web";function na(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 Ct(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 Er({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:[_.badge,{borderColor:o}],children:ve(l,{style:[_.badgeText,{color:o}],children:t})})}function W({title:e,source:t,children:o,testID:r,tone:n,collapsible:i,summary:a}){let[h,d]=Hr(false),g=!!i&&!h;return nt(s,{style:[_.card,n==="warning"&&_.cardWarning,n==="danger"&&_.cardDanger,n==="info"&&_.cardInfo],testID:r,children:[(e||t&&t!=="live")&&nt(s,{style:_.titleRow,children:[e?ve(l,{style:_.title,numberOfLines:2,children:e}):ve(s,{style:_.flex}),ve(Er,{source:t})]}),i?nt(k,{testID:r?`${r}-toggle`:void 0,onPress:()=>d(f=>!f),accessibilityRole:"button",accessibilityState:{expanded:h},accessibilityLabel:`${a??"Details"}, ${h?"hide":"show"}`,style:({pressed:f})=>[_.disclosure,!g&&_.disclosureOpen,f&&_.pressed],children:[ve(l,{style:_.disclosureText,numberOfLines:1,children:a??"Details"}),g?ve(Pr,{size:12,color:I.color.textTertiary}):ve(Wr,{size:12,color:I.color.textTertiary})]}):null,g?null:o]})}var ia=5;function it(e,t,o=ia){let[r,n]=Hr(t),{hidden:i,next:a,expanded:h,canExpand:d,canCollapse:g}=na(e.length,t,r,o);return{visible:e.slice(0,r),hidden:i,next:a,expanded:h,showMore:d?()=>n(f=>f+o):void 0,showLess:g?()=>n(t):void 0}}function lt({paged:e}){let{next:t,showMore:o,showLess:r}=e;return!o&&!r?null:nt(s,{style:_.moreRow,children:[o?nt(k,{testID:"buoy-block-show-more",onPress:o,style:[_.more,_.moreCell],accessibilityRole:"button",children:[nt(l,{style:_.moreText,children:["Show ",t," more"]}),ve(Pr,{size:12,color:I.color.textTertiary})]}):null,r?nt(k,{testID:"buoy-block-show-fewer",onPress:r,style:[_.more,_.moreCell],accessibilityRole:"button",children:[ve(l,{style:_.moreText,children:"Show fewer"}),ve(Wr,{size:12,color:I.color.textTertiary})]}):null]})}function la({shown:e,total:t}){return!t||t<=e?null:ve(s,{style:_.more,children:nt(l,{style:_.moreNote,children:[e," of ",t," shown"]})})}function Ve({actions:e,blockId:t,align:o="left"}){let r=te();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:[_.actions,o==="right"&&_.actionsRight],children:n.slice(0,2).map(i=>{let a=r.actionState?.[ql(t,i)],h=!!r.busy||a==="running"||a==="done";return nt(k,{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:d})=>[_.button,i.primary?_.buttonPrimary:_.buttonPlate,h&&_.buttonDisabled,d&&!h&&_.pressed],children:[a==="running"?ve(Xt,{size:"small",color:i.primary?I.color.onAccent:I.color.text}):a==="done"?ve(oa,{size:12,color:i.primary?I.color.onAccent:I.color.accent}):a==="failed"?ve(ra,{size:12,color:I.color.danger}):null,ve(l,{style:[_.buttonText,i.primary?_.buttonTextPrimary:_.buttonTextPlate],children:i.label})]},i.label)})})}var D=v.create({row:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},rowDivider:{borderTopWidth:v.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"?ta:"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}}),_=v.create({card:{borderRadius:I.radius.card,borderWidth:v.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:v.hairlineWidth,borderBottomColor:I.color.separator},disclosureText:{flex:1,color:I.color.textSecondary,fontSize:I.font.caption},badge:{borderWidth:v.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:v.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 aa,jsx as ae,jsxs as It}from"react/jsx-runtime";function sa({block:e}){let t=te(),o=t.answered[e.id],r=o?.kind==="choice"?o.optionId:null,n=!!o;return It(W,{testID:`buoy-block-choice-${e.id}`,tone:n?void 0:"info",children:[e.questionInAnswer?null:ae(l,{style:M.question,children:e.question}),ae(s,{style:[M.options,e.questionInAnswer&&M.optionsAlone],children:e.options.slice(0,5).map((i,a)=>{let h=r===i.id;return It(k,{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:d})=>[M.option,a>0&&M.optionDivider,h&&M.optionChosen,n&&!h&&M.optionDimmed,d&&!n&&M.pressed],children:[i.icon?ae(Or,{name:i.icon}):null,It(s,{style:M.optionText,children:[ae(l,{style:[M.optionLabel,h&&M.optionLabelChosen],children:i.label}),i.detail?ae(l,{style:M.optionDetail,children:i.detail}):null]}),h?ae(Wl,{size:14,color:j.color.accent}):n?null:ae(El,{size:14,color:j.color.textTertiary})]},i.id)})}),!n&&e.allowFreeText!==false?ae(l,{style:M.hint,children:"Or just type your answer below."}):null]})}function ca({block:e}){let t=te(),o=t.answered[e.id],r=!!o,n=o?.kind==="confirm"?o.approved:null;return It(W,{testID:`buoy-block-confirm-${e.id}`,tone:r?void 0:"warning",children:[ae(l,{style:M.confirmTitle,children:e.title}),ae(l,{style:M.confirmChange,children:e.change}),e.consequence?ae(l,{style:M.confirmConsequence,children:e.consequence}):null,ae(s,{style:M.confirmActions,children:r?ae(l,{style:M.decided,children:n?`\u2713 ${e.approveLabel??"Done"}`:`\u2715 ${e.declineLabel??"Not now"}`}):It(aa,{children:[ae(k,{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:ae(l,{style:M.buttonTextPrimary,children:e.approveLabel??"Do it"})}),ae(k,{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:ae(l,{style:M.buttonTextPlate,children:e.declineLabel??"Not now"})})]})})]})}function da({block:e}){let t=te(),o=t.answered[e.id],r=!!o,[n,i]=Pl(""),a=e.type==="secret",h=()=>{let d=n.trim();d&&t.answer({blockId:e.id,kind:"input",value:d})};return It(W,{testID:`buoy-block-input-${e.id}`,tone:r?void 0:"info",children:[ae(l,{style:M.question,children:e.label}),r?ae(l,{style:M.decided,children:o.kind==="input"?a?"\u2022\u2022\u2022\u2022\u2022\u2022":o.value:"(skipped)"}):It(s,{style:M.inputRow,children:[ae(rt,{testID:"buoy-block-input-field",style:M.input,value:n,onChangeText:i,placeholder:e.placeholder??"",placeholderTextColor:j.color.placeholder,keyboardType:e.type==="number"?"numeric":"ascii-capable",secureTextEntry:a,autoCapitalize:"none",autoCorrect:false,returnKeyType:"send",onSubmitEditing:h}),ae(k,{testID:"buoy-block-input-submit",accessibilityRole:"button",disabled:!n.trim(),onPress:h,style:({pressed:d})=>[M.button,M.buttonPrimary,!n.trim()&&M.buttonDisabled,d&&M.pressed],children:ae(l,{style:M.buttonTextPrimary,children:e.submitLabel??"Send"})})]})]})}var M=v.create({question:{color:j.color.text,fontSize:j.font.row,fontWeight:"600",lineHeight:20,paddingHorizontal:12,paddingTop:12,paddingBottom:8},options:{marginHorizontal:8,marginBottom:8,borderRadius:j.radius.row,backgroundColor:j.color.surfaceElevated,overflow:"hidden"},optionsAlone:{marginTop:8},option:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:11},optionDivider:{borderTopWidth:v.hairlineWidth,borderTopColor:j.color.separator},optionChosen:{backgroundColor:j.color.accentSoft},optionDimmed:{opacity:.45},optionText:{flex:1,gap:2},optionLabel:{color:j.color.text,fontSize:j.font.body,fontWeight:"500"},optionLabelChosen:{color:j.color.accent},optionDetail:{color:j.color.textSecondary,fontSize:j.font.caption,lineHeight:17},hint:{color:j.color.textTertiary,fontSize:j.font.micro,paddingHorizontal:12,paddingBottom:10},confirmTitle:{color:j.color.text,fontSize:j.font.row,fontWeight:"600",paddingHorizontal:12,paddingTop:12},confirmChange:{color:j.color.text,fontSize:j.font.body,lineHeight:19,paddingHorizontal:12,paddingTop:6},confirmConsequence:{color:j.color.warning,fontSize:j.font.caption,lineHeight:17,paddingHorizontal:12,paddingTop:6},confirmActions:{flexDirection:"row",gap:8,paddingHorizontal:12,paddingVertical:12,alignItems:"center"},decided:{color:j.color.textSecondary,fontSize:j.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:j.radius.row,backgroundColor:j.color.surfaceElevated,color:j.color.text,fontSize:j.font.body},button:{paddingHorizontal:14,paddingVertical:9,borderRadius:j.radius.row},buttonPrimary:{backgroundColor:j.color.accent},buttonPlate:{backgroundColor:j.color.button},buttonDisabled:{opacity:.5},buttonTextPrimary:{color:j.color.onAccent,fontSize:j.font.caption,fontWeight:"600"},buttonTextPlate:{color:j.color.text,fontSize:j.font.caption,fontWeight:"600"},pressed:{opacity:.7}});import{monoFont as Vr}from"@buoy-gg/shared-ui/web";import{useState as Nr}from"react";import{AlertTriangle as ua,Check as pa,Info as ha,night as L,X as ga}from"@buoy-gg/shared-ui/web";import{DataViewer as fa,TreeDiffViewer as ba}from"@buoy-gg/shared-ui/web/dataViewer";import{CAPS as to}from"@buoy-gg/agent-core/web";import{monoFont as jr}from"@buoy-gg/shared-ui/web";import{useState as ya}from"react";import{night as se}from"@buoy-gg/shared-ui/web";var Mr=e=>/^\s*\|.*\|\s*$/.test(e),ma=e=>/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(e),qr=e=>e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>t.trim()),ka=/^\s*```\s*([\w+-]*)\s*$/;function xa(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+$/,""),h=ka.exec(a);if(h){r();let f=[],y=i+1,$=false;for(;y<n.length;){if(/^\s*```\s*$/.test(n[y])){$=true;break}f.push(n[y]),y++}t.push({kind:"code",lang:h[1]??"",text:f.join(`
|
|
3
|
+
`),closed:$}),i=$?y:n.length;continue}if(!a.trim()){r();continue}if(Mr(a)&&n[i+1]&&ma(n[i+1])){r();let f=qr(a),y=[],$=i+2;for(;$<n.length&&Mr(n[$]);)y.push(qr(n[$])),$++;t.push({kind:"table",header:f,rows:y}),i=$-1;continue}let d=/^#{1,6}\s+(.*)$/.exec(a);if(d){r(),t.push({kind:"h",text:d[1]});continue}let g=/^(\s*)([-*•]|\d+[.)])\s+(.*)$/.exec(a);if(g){r();let f=Math.min(2,Math.floor(g[1].length/2)),y=/^\d/.test(g[2])?g[2].replace(")","."):"\u2022";t.push({kind:"li",text:g[3],marker:y,depth:f});continue}o.push(a.trim())}return r(),t}var Po=12,Wo=4;function wa(e,t){let o=[];return t.length>Po&&o.push(`${Po} of ${t.length} rows`),e.length>Wo&&o.push(`${Wo} of ${e.length} columns`),o.length?`Showing ${o.join(" \xB7 ")}`:null}import{jsx as me,jsxs as fo}from"react/jsx-runtime";function Vt(e,t){let o=e.replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1"),r=[],n=/(\*\*[^*]+\*\*|`[^`]+`|\*[^*\s][^*]*\*|_[^_\s][^_]*_)/g,i=0,a,h=0;for(;a=n.exec(o);){a.index>i&&r.push(o.slice(i,a.index));let d=a[0];d.startsWith("**")?r.push(me(l,{style:[t,K.bold],children:d.slice(2,-2)},h++)):d.startsWith("`")?r.push(me(l,{style:[t,K.code],children:d.slice(1,-1)},h++)):r.push(me(l,{style:[t,K.italic],children:d.slice(1,-1)},h++)),i=a.index+d.length}return i<o.length&&r.push(o.slice(i)),r}var va=e=>e.replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1");function Sa({header:e,rows:t}){let[o,r]=ya(false),n=wa(e,t),i=o?e:e.slice(0,Wo),a=o?t:t.slice(0,Po),h=fo(s,{style:o&&K.tableWide,children:[me(s,{style:K.tableHead,children:i.map((d,g)=>me(l,{style:[K.th,g===0&&K.firstCol,o&&K.colFixed],numberOfLines:1,children:d.replace(/\*\*/g,"")},g))}),a.map((d,g)=>me(s,{style:[K.tr,g>0&&K.trDivider],children:i.map((f,y)=>me(l,{style:[K.td,y===0&&K.firstCol,y===0&&K.tdFirst,o&&K.colFixed],numberOfLines:o?3:2,children:Vt(va(d[y]??""),K.td)},y))},g))]});return fo(s,{style:K.table,testID:"buoy-ask-buoy-md-table",children:[o?me(Ge,{keyboardShouldPersistTaps:"handled",style:K.tableScrollV,nestedScrollEnabled:true,children:me(Ge,{horizontal:true,showsHorizontalScrollIndicator:true,children:h})}):h,n?fo(k,{testID:"buoy-ask-buoy-md-table-toggle",accessibilityRole:"button",accessibilityLabel:o?"Show fewer rows":"Show all rows and columns",onPress:()=>r(d=>!d),style:({pressed:d})=>[K.tfoot,d&&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 Fr({text:e,style:t}){let o=xa(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(Ge,{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"?fo(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:Vt(r.text,t)})]},n):me(l,{style:[t,r.kind==="h"&&K.bold],selectable:true,children:Vt(r.text,t)},n))})}var K=v.create({wrap:{gap:8},bold:{fontWeight:"600"},italic:{fontStyle:"italic"},code:{fontFamily:we.OS==="web"?jr:"Menlo",fontSize:13,color:se.color.accent,backgroundColor:se.color.fill},codeBlock:{borderRadius:se.radius.row,borderWidth:v.hairlineWidth,borderColor:se.color.border,backgroundColor:se.color.surface},codeBlockContent:{paddingHorizontal:12,paddingVertical:10},codeText:{fontFamily:we.OS==="web"?jr:"Menlo",fontSize:12,lineHeight:18,color:se.color.text},li:{flexDirection:"row",gap:8},table:{borderRadius:se.radius.row,borderWidth:v.hairlineWidth,borderColor:se.color.border,backgroundColor:se.color.surface,overflow:"hidden"},tableWide:{minWidth:"100%"},tableScrollV:{maxHeight:320},tableHead:{flexDirection:"row",paddingHorizontal:10,paddingVertical:6,gap:8,backgroundColor:se.color.fill},th:{flex:1,color:se.color.textTertiary,fontSize:se.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},tr:{flexDirection:"row",paddingHorizontal:10,paddingVertical:7,gap:8},trDivider:{borderTopWidth:v.hairlineWidth,borderTopColor:se.color.separator},td:{flex:1,color:se.color.textSecondary,fontSize:se.font.caption,lineHeight:17},tdFirst:{color:se.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:v.hairlineWidth,borderTopColor:se.color.border},tfootText:{color:se.color.textSecondary,fontSize:se.font.micro},tfootAction:{color:se.color.accent,fontSize:se.font.micro,fontWeight:"600"},pressed:{opacity:.7},marker:{color:se.color.textSecondary,minWidth:14,textAlign:"right"},liText:{flex:1}});import{useCallback as Ta,useEffect as Ca,useRef as Ia,useState as za}from"react";import{copyToClipboard as Da}from"@buoy-gg/shared-ui/web";var Ra=1500;function bo(e){let[t,o]=za(false),r=Ia(null);Ca(()=>()=>{r.current&&clearTimeout(r.current)},[]);let n=Ta(()=>{let i=e();Da(i).then(a=>{if(!a){xr.share({message:i}).catch(()=>{});return}o(true),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>o(false),Ra)}).catch(()=>{})},[e]);return{copied:t,copy:n}}var $a=e=>typeof e=="string"?e:e.text;function _r(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($a).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 Da(e){return e.map(_r).filter(t=>!!t)}import{Fragment as Ra,jsx as z,jsxs as ge}from"react/jsx-runtime";function Po(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 $a({block:e}){let t=it(e.rows,Xt.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 d=n[g],h=typeof d=="string"?d:d?.text??"",f=typeof d=="string"?void 0:d?.tone;return z(l,{style:[$.td,g===0&&$.firstCol,g===0&&$.tdFirst,f&&{color:vt(f)}],numberOfLines:2,children:Ht(h,$.td)},g)})},i)),z(lt,{paged:t})]})}function Aa({block:e}){let t=it(e.pairs,Xt.keyValuePairs),{visible:o}=t,[r,n]=Nr(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,d=r===i.key;return ge(x,{onPress:g?()=>n(d?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,d&&D.mono],numberOfLines:d?void 0:2,selectable:true,children:d?JSON.stringify(i.value,null,2):Po(i.value)})]},i.key)}),z(lt,{paged:t})]})}function Ba(e){let t=!!e.image;return{canExpand:t,rowRunsAction:!!e.action&&!t,actionIsOwnControl:!!e.action&&t}}function La({block:e}){let t=oe(),o=it(e.items,Xt.listItems),{visible:r}=o,[n,i]=Nr(null);return ge(W,{title:e.title,source:e.source,testID:`buoy-block-list-${e.id}`,children:[r.map((a,g)=>{let d=`${a.id??a.title}-${g}`,h=n===d,{canExpand:f,rowRunsAction:m,actionIsOwnControl:L}=Ba(a),V=f||m?x:s,ee=f?{onPress:()=>i(h?null:d),accessibilityRole:"button",accessibilityState:{expanded:h},accessibilityLabel:`${a.title}, ${h?"hide":"show"} picture`,testID:`buoy-block-list-row-${d}`}:m?{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(x,{onPress:()=>i(null),accessibilityRole:"button",accessibilityLabel:`Hide ${a.title}`,testID:`buoy-block-list-hero-${d}`,style:$.listHero,children:z(wt,{testID:"buoy-internal-chat-image",source:{uri:a.image},style:$.listHeroImage,resizeMode:"contain",accessibilityLabel:a.title})}):null,ge(V,{...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(Or,{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:Ht(a.title,D.rowTitle)}),a.subtitle?z(l,{style:D.rowSub,numberOfLines:h?void 0:2,children:Ht(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?L?z(x,{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]})]},d)}),z(lt,{paged:o})]})}function Ur(e){return e!==null&&typeof e=="object"}function Oa(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 Ha({block:e}){let t=it(e.changes,Xt.keyValuePairs);return ge(W,{title:e.title??"What changed",source:e.source,testID:`buoy-block-diff-${e.id}`,collapsible:true,summary:Oa(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}),Ur(o.before)||Ur(o.after)?z(s,{style:$.diffTree,children:z(ha,{oldValue:o.before,newValue:o.after,showUnchanged:false,scrollEnabled:false})}):ge(Ra,{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:Po(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:Po(o.after)})]})]})]},`${o.path}-${r}`)}),z(lt,{paged:t})]})}function Pa({block:e}){let t=e.bars.slice(0,Xt.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 Wa({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(ca,{size:10,color:B.color.onAccent}):t.state==="failed"?z(ua,{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 Ea(e){try{let t=JSON.parse(e);return t!==null&&typeof t=="object"?t:void 0}catch{return}}function Va({block:e,value:t}){return z(W,{title:e.title,testID:`buoy-block-code-${e.id}`,children:z(s,{style:$.viewer,children:z(pa,{title:e.title??"Payload",data:t,initialExpanded:true,showTypeFilter:false,testIDPrefix:`buoy-block-code-${e.id}`})})})}function Na({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 ja({block:e}){let t=Ea(e.text);return t===void 0?z(Na,{block:e}):z(Va,{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"?da:sa;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(Ne,{actions:e.actions,blockId:e.id})]})}function qa({block:e}){let{copied:t,copy:o}=ho(()=>_r(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(x,{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(Ne,{actions:e.actions,blockId:e.id})]})}var $=v.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:v.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"?Vr:"Menlo",fontSize:12,width:10},diffValue:{flex:1,fontFamily:we.OS==="web"?Vr:"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 Fa}from"react";import{night as je}from"@buoy-gg/shared-ui/web";import{CAPS as Kr}from"@buoy-gg/agent-core/web";import{jsx as Fe,jsxs as Wo}from"react/jsx-runtime";function _a({block:e}){let[t,o]=Fa(null),{width:r}=vr(),n=e.images.slice(0,Kr.gridMax),i=n.length>Kr.gridImages,a=Math.min(150,Math.floor((r-2*je.gutter-24-8)/2)),g=({img:d,i:h})=>Wo(x,{testID:`buoy-block-image-${h}`,accessibilityRole:"imagebutton",accessibilityLabel:d.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:d.url},style:[_e.image,{width:a,height:a}],resizeMode:"contain",accessibilityLabel:d.alt}),Fe(l,{style:_e.name,numberOfLines:1,children:d.alt}),d.caption?Fe(l,{style:_e.caption,numberOfLines:1,children:d.caption}):null]},`${d.url}-${h}`);return Wo(W,{title:e.title,source:e.source,testID:`buoy-block-imagegrid-${e.id}`,children:[t!==null&&n[t]?Wo(x,{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(Ke,{horizontal:true,showsHorizontalScrollIndicator:false,snapToInterval:a+8,decelerationRate:"fast",contentContainerStyle:_e.carousel,children:n.map((d,h)=>Fe(g,{img:d,i:h},h))}):Fe(s,{style:_e.grid,children:n.map((d,h)=>Fe(g,{img:d,i:h},h))}),Fe(ra,{shown:n.length,total:e.total})]})}var _e=v.create({grid:{flexDirection:"row",flexWrap:"wrap",gap:8,padding:12},carousel:{gap:8,paddingHorizontal:12,paddingVertical:12},tile:{gap:4},tileCarousel:{},image:{borderRadius:je.radius.row,backgroundColor:je.color.fill},name:{color:je.color.text,fontSize:je.font.micro,fontWeight:"600"},caption:{color:je.color.textSecondary,fontSize:je.font.micro},hero:{alignItems:"center",padding:12,gap:6,borderBottomWidth:v.hairlineWidth,borderBottomColor:je.color.separator},heroImage:{width:"100%",height:240,borderRadius:je.radius.row,backgroundColor:je.color.fill},heroCaption:{color:je.color.text,fontSize:je.font.caption}});import{monoFont as Ua}from"@buoy-gg/shared-ui/web";import{useState as Ka}from"react";import{AlertTriangle as Ga,ChevronRight as Ja,Eye as Gr,night as R,NightSegmented as Ya}from"@buoy-gg/shared-ui/web";import{CAPS as go}from"@buoy-gg/agent-core/web";import{jsx as P,jsxs as ae}from"react/jsx-runtime";function Jr(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 Yr(e){try{let t=new URL(e);return t.pathname+(t.search?"?\u2026":"")}catch{return e}}function Qr({status:e}){return P(s,{style:[D.pill,{backgroundColor:`${Jr(e)}22`}],children:P(l,{style:[D.pillText,{color:Jr(e)}],children:e??"\u2026"})})}function Qa({block:e}){let t=oe(),o=t.supports?.openTool!==false,r=it(e.requests,go.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(x,{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:J.method,children:i.method}),P(l,{style:D.rowTitle,numberOfLines:1,children:Yr(i.url)}),i.mocked?P(l,{style:J.mockedChip,children:"MOCKED"}):null,i.durationMs!==void 0?ae(l,{style:D.rowTrailing,children:[i.durationMs," ms"]}):null,P(Qr,{status:i.status}),o?P(Ja,{size:12,color:R.color.textTertiary}):null]},`${i.id}-${a}`)),P(lt,{paged:r})]})}var Xa=[{key:"response",label:"Response"},{key:"request",label:"Request"}];function Za({block:e}){let[t,o]=Ka("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,J.reqHead],children:[P(l,{style:J.method,children:e.request.method}),P(l,{style:D.rowTitle,numberOfLines:2,children:Yr(e.request.url)}),e.request.mocked?P(l,{style:J.mockedChip,children:"MOCKED"}):null,P(Qr,{status:e.request.status})]}),P(s,{style:J.tabs,children:P(Ya,{tabs:Xa,activeKey:t,onChange:a=>o(a),size:"sm"})}),P(l,{style:[D.mono,J.body],numberOfLines:14,selectable:true,children:n.length>1600?`${n.slice(0,1600)}
|
|
8
|
-
\u2026`:n}),P(Ne,{blockId:e.id,actions:[{label:"Open in Network",openTool:{toolId:"network",select:e.request.id}}]}),(i.supports?.openTool===false,null)]})}function es({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:J.ruleBody,children:[ae(l,{style:J.ruleLine,children:[ae(l,{style:J.ruleKey,children:[r.methods?.length?r.methods.join("/"):"ANY"," "]}),P(l,{style:D.mono,children:r.urlPattern})]}),ae(l,{style:J.ruleLine,children:[P(l,{style:J.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?J.on:J.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(Ne,{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 ts({block:e}){let t=oe(),o=it(e.elements,go.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(x,{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(Gr,{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 os({block:e}){let t=oe(),o=it(e.routes,go.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:J.chips,children:r.map((n,i)=>P(x,{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:[J.chip,n.path===e.current&&J.chipCurrent],accessibilityRole:"button",children:P(l,{style:[J.chipText,n.dynamic&&J.chipDynamic],children:n.path})},`${n.path}-${i}`))}),P(lt,{paged:o})]})}var Xr={error:R.color.danger,warn:R.color.warning,warning:R.color.warning,info:R.color.info};function rs({block:e}){let t=it(e.entries,go.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,J.logRow],children:[P(s,{style:[D.pill,{backgroundColor:`${Xr[r.level]??R.color.textTertiary}22`}],children:P(l,{style:[D.pillText,{color:Xr[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 ns({block:e}){return ae(W,{tone:"danger",testID:`buoy-block-crash-${e.id}`,children:[ae(s,{style:J.crashHead,children:[P(Ga,{size:14,color:R.color.danger}),ae(l,{style:J.crashTitle,children:["The app crashed",e.route?` on ${e.route}`:""]})]}),P(l,{style:[D.mono,J.crashMsg],numberOfLines:4,selectable:true,children:e.message}),e.suspect?ae(l,{style:J.suspect,children:["Most likely cause: ",e.suspect.label]}):null,P(Ne,{blockId:e.id,actions:[...e.suspect?.action?[{...e.suspect.action,primary:true}]:[],...e.actions??[]].slice(0,2)})]})}function is({block:e}){let t=oe(),o=t.supports?.minimize!==false;return ae(x,{testID:`buoy-block-peek-${e.id}`,disabled:!o,onPress:()=>void t.runAction({label:"Look",minimize:true},e.id),style:({pressed:r})=>[J.peek,r&&{opacity:.7}],accessibilityRole:"button",accessibilityLabel:`${e.label}. Look at the app`,children:[P(l,{style:J.peekText,children:e.label}),o?ae(s,{style:J.peekLook,children:[P(Gr,{size:12,color:R.color.accent}),P(l,{style:J.peekLookText,children:"Look"})]}):null]})}var J=v.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:v.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"?Ua:"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 Eo}from"@buoy-gg/shared-ui/web";import{useEffect as ls,useRef as Zr,useState as Je}from"react";import{AlertTriangle as as,Check as en,ChevronDown as tn,ChevronRight as on,night as u,NightSegmented as ss,RefreshCw as cs,Search as ds,X as us}from"@buoy-gg/shared-ui/web";import{Fragment as fo,jsx as p,jsxs as S}from"react/jsx-runtime";var rn=e=>typeof e=="string"?e:e===void 0?"\u2014":JSON.stringify(e);function ps({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(x,{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 hs({block:e}){let t=oe(),o=t.answered[e.id],r=!!o,[n,i]=Je([]),a=o?.kind==="multi"?o.optionIds:n,g=h=>i(f=>f.includes(h)?f.filter(m=>m!==h):[...f,h]),d=n.length>=(e.min??1)&&(!e.max||n.length<=e.max);return S(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 m=a.includes(h.id);return S(x,{disabled:r,onPress:()=>g(h.id),style:[c.option,f>0&&D.rowDivider,r&&!m&&c.dim],accessibilityRole:"checkbox",accessibilityState:{checked:m},children:[p(s,{style:[c.checkbox,m&&c.checkboxOn],children:m?p(en,{size:11,color:u.color.onAccent}):null}),S(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(x,{testID:"buoy-block-multi-submit",disabled:!d,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,!d&&c.disabled],children:p(l,{style:c.buttonTextPrimary,children:e.submitLabel??`Use ${n.length||""}`.trim()})})})]})}var gs=8;function fs({block:e}){let t=oe(),o=t.answered[e.id],[r,n]=Je(""),[i,a]=Je(false),g=o?.kind==="select"?o.label:null,d=e.options.filter(f=>!r||f.label.toLowerCase().includes(r.toLowerCase())).slice(0,8),h=e.searchable!==false&&e.options.length>=gs;return S(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}):S(s,{style:c.selectBox,children:[S(x,{onPress:()=>a(f=>!f),style:c.selectField,accessibilityRole:"button",children:[p(l,{style:c.selectPlaceholder,children:i?"Choose\u2026":`${e.options.length} options`}),p(tn,{size:14,color:u.color.textSecondary})]}),i&&S(fo,{children:[h&&S(s,{style:c.search,children:[p(ds,{size:12,color:u.color.textSecondary}),p(rt,{style:c.searchInput,value:r,onChangeText:n,placeholder:"Search",placeholderTextColor:u.color.placeholder,autoCapitalize:"none",autoCorrect:false})]}),d.map((f,m)=>S(x,{onPress:()=>t.answer({blockId:e.id,kind:"select",optionId:f.id,label:f.label}),style:[c.option,m>0&&D.rowDivider],accessibilityRole:"button",children:[S(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(on,{size:12,color:u.color.textTertiary})]},f.id)),e.options.length>d.length?S(l,{style:c.hint,children:[e.options.length-d.length," more \u2014 keep typing"]}):null]})]})]})}function nn({min:e,max:t,step:o=1,value:r,unit:n,onChange:i,disabled:a}){let g=Zr(0),d=t>e?(r-e)/(t-e)*100:0,h=V=>Math.min(t,Math.max(e,+(Math.round((V-e)/o)*o+e).toFixed(6))),f=V=>!a&&i(h(r+V*o)),m=V=>{if(a||g.current<=0)return;let ee=Math.min(1,Math.max(0,V.nativeEvent.locationX/g.current));i(h(e+ee*(t-e)))},L=V=>{g.current=V.nativeEvent.layout.width};return S(s,{style:c.sliderRow,children:[p(x,{disabled:a,onPress:()=>f(-1),style:c.stepBtn,accessibilityRole:"button",accessibilityLabel:"Decrease",children:p(l,{style:c.stepText,children:"\u2212"})}),p(x,{style:c.trackHit,onLayout:L,onPress:m,disabled:a,accessibilityRole:"adjustable",accessibilityValue:{min:e,max:t,now:r},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:V=>f(V.nativeEvent.actionName==="increment"?1:-1),children:S(s,{style:c.track,pointerEvents:"none",children:[p(s,{style:[c.fill,{width:`${d}%`}]}),p(s,{style:[c.thumb,{left:`${d}%`}]})]})}),p(x,{disabled:a,onPress:()=>f(1),style:c.stepBtn,accessibilityRole:"button",accessibilityLabel:"Increase",children:p(l,{style:c.stepText,children:"+"})}),S(l,{style:c.sliderValue,children:[r,n?` ${n}`:""]})]})}function bs({block:e}){let t=oe(),o=t.answered[e.id],[r,n]=Je(e.value??e.min);return S(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(nn,{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(x,{onPress:()=>t.answer({blockId:e.id,kind:"slider",value:r,unit:e.unit}),style:[c.button,c.buttonPrimary],children:S(l,{style:c.buttonTextPrimary,children:["Use ",r,e.unit?` ${e.unit}`:""]})})})]})}function ys({block:e}){let t=oe(),o=t.answered[e.id],[r,n]=Je(""),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 S(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)"}):S(fo,{children:[p(s,{style:[c.chips,c.pad],children:i.map(a=>p(x,{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))}),S(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:u.color.placeholder,keyboardType:"numbers-and-punctuation"}),p(x,{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 ln({f:e,value:t,onChange:o,disabled:r}){return e.type==="toggle"?S(s,{style:c.fieldRow,children:[p(l,{style:c.fieldLabel,children:e.label}),p(Dr,{value:!!t,onValueChange:o,disabled:r,trackColor:{true:u.color.accent,false:u.color.fillTertiary},thumbColor:u.color.knob})]}):e.type==="select"?S(s,{style:c.fieldCol,children:[p(l,{style:c.fieldLabel,children:e.label}),p(s,{style:c.chips,children:e.options.map(n=>p(x,{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"?S(s,{style:c.fieldCol,children:[p(l,{style:c.fieldLabel,children:e.label}),p(nn,{min:e.min,max:e.max,step:e.step,unit:e.unit,value:typeof t=="number"?t:e.min,onChange:o,disabled:r})]}):S(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:u.color.placeholder,keyboardType:e.type==="number"?"numeric":"ascii-capable",secureTextEntry:e.type==="secret",autoCapitalize:"none",autoCorrect:false})]})}function an(e){let[t,o]=Je(()=>Object.fromEntries(e.map(r=>[r.key,r.value])));return{values:t,set:(r,n)=>o(i=>({...i,[r]:n}))}}function ms({block:e}){let t=oe(),o=t.answered[e.id],{values:r,set:n}=an(e.fields);return S(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(ln,{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(x,{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 xs({block:e}){let t=oe(),o=t.answered[e.id],{values:r,set:n}=an(e.fields),i=o?.kind==="proposal"?o.approved:null;return S(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(ln,{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"}):S(fo,{children:[p(x,{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(x,{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 ks({block:e}){let t=oe(),[o,r]=Je(null),n=t.actionState?.[`${e.id}:${e.verify?.label??"Verify"}`],i=e.verified||n==="done";return S(s,{style:c.claim,testID:`buoy-block-claim-${e.id}`,children:[S(l,{style:c.claimText,children:[e.text,e.sources.map((a,g)=>S(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]?S(s,{style:c.citeBox,children:[S(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?S(x,{onPress:()=>void t.runAction(e.verify,e.id),style:c.verifyBtn,accessibilityRole:"button",children:[p(cs,{size:11,color:u.color.accent}),p(l,{style:c.verifyText,children:n==="running"?"Checking\u2026":e.verify.label})]}):null]})}function ws({block:e}){let[t,o]=Je(!!e.open);return S(W,{testID:`buoy-block-details-${e.id}`,children:[S(x,{onPress:()=>o(r=>!r),style:D.row,accessibilityRole:"button",accessibilityState:{expanded:t},children:[p(l,{style:D.rowTitle,children:e.summary}),t?p(tn,{size:12,color:u.color.textTertiary}):p(on,{size:12,color:u.color.textTertiary})]}),t?p(l,{style:c.detailsBody,selectable:true,children:e.body}):null]})}function vs({block:e,renderNested:t}){let[o,r]=Je(0),n=e.tabs.map((a,g)=>({key:String(g),label:a.label})),i=e.tabs[o];return S(s,{style:c.tabsWrap,testID:`buoy-block-tabs-${e.id}`,children:[p(ss,{tabs:n,activeKey:String(o),onChange:a=>r(Number(a)),size:"sm"}),i&&t?t(i.block):null]})}var Ss=10;function Ts({block:e}){let t=it(e.events,Ss);return S(W,{title:e.title??"What happened",source:e.source,testID:`buoy-block-timeline-${e.id}`,children:[t.visible.map((o,r)=>S(s,{style:c.tlRow,children:[p(l,{style:c.tlAt,children:o.at}),S(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]}),S(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 Cs({block:e}){let t=e.series.slice(-60),o=Math.max(1,...t),r=Math.min(...t,0),n=44;return S(W,{title:e.title,source:e.source,testID:`buoy-block-sparkline-${e.id}`,children:[S(s,{style:c.sparkHead,children:[S(l,{style:c.sparkCurrent,children:[e.current??t[t.length-1],e.unit?S(l,{style:c.sparkUnit,children:[" ",e.unit]}):null]}),e.live?p(sn,{}):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?u.color.accent:u.color.accentBorderStrong}]},a))}),e.label?p(l,{style:c.hint,children:e.label}):null]})}function sn(){let e=Zr(new ue.Value(1)).current;return ls(()=>{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]),S(s,{style:c.live,children:[p(ue.View,{style:[c.liveDot,{opacity:e}]}),p(l,{style:c.liveText,children:"LIVE"})]})}function Is({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 S(W,{title:e.title,source:e.source,testID:`buoy-block-compare-${e.id}`,children:[S(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 S(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:u.color.danger}],numberOfLines:2,children:rn(o[n])}),p(l,{style:[c.cmpVal,a&&{color:u.color.accent}],numberOfLines:2,children:rn(r[n])})]},n)})]})}function cn({c:e,id:t}){return S(fo,{children:[e.image?p(wt,{testID:"buoy-internal-chat-image",source:{uri:e.image},style:c.cardImage,resizeMode:"contain",accessibilityLabel:e.title}):null,S(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=>S(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(Ne,{actions:e.actions,blockId:t})]})}function zs({block:e}){return p(W,{source:e.source,testID:`buoy-block-card-${e.id}`,children:p(cn,{c:e,id:e.id})})}function Ds({block:e}){return S(s,{testID:`buoy-block-cardcarousel-${e.id}`,children:[e.title?p(l,{style:c.carouselTitle,children:e.title}):null,p(Ke,{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(cn,{c:t,id:`${e.id}-${o}`})},`${t.title}-${o}`))})]})}function Rs({block:e}){let[t,o]=Je(false);return S(W,{title:e.route?`Screen \xB7 ${e.route}`:"Screen",source:e.source,testID:`buoy-block-screenshot-${e.id}`,children:[p(x,{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 $s({block:e}){let t=e.steps.filter(o=>o.state==="done").length;return S(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)=>S(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(en,{size:10,color:u.color.onAccent}):o.state==="failed"?p(us,{size:10,color:u.color.text}):p(l,{style:c.stepNum,children:r+1})}),S(l,{style:[D.rowTitle,o.state==="done"&&c.muted],children:[o.text,o.state==="running"?"\u2026":""]})]},r)),p(Ne,{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=oe();return S(x,{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}),S(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 Bs({block:e}){let t=e.status==="failed"?u.color.danger:e.status==="done"?u.color.accent:u.color.info;return S(W,{testID:`buoy-block-task-${e.id}`,children:[S(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(Ne,{actions:e.actions,blockId:e.id})]})}function Ls({block:e}){let t=e.tone==="danger"?u.color.danger:e.tone==="warning"?u.color.warning:u.color.info;return S(s,{style:[c.banner,{borderColor:t,backgroundColor:`${t}1A`}],testID:`buoy-block-banner-${e.id}`,children:[p(as,{size:13,color:t}),p(l,{style:[c.bannerText,{color:t}],numberOfLines:2,children:e.text}),e.actions?.[0]?p(Ne,{actions:e.actions.slice(0,1),blockId:e.id,align:"right"}):null]})}function Os({block:e}){return S(W,{testID:`buoy-block-file-${e.id}`,children:[S(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)})}),S(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(Ne,{actions:e.actions,blockId:e.id})]})}function Hs({block:e}){let t=oe(),o=t.answered[e.id];return S(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(x,{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=v.create({flex:{flex:1},pad:{paddingHorizontal:12,paddingBottom:8},muted:{color:u.color.textSecondary},dim:{opacity:.45},disabled:{opacity:.5},pressed:{opacity:.7},question:{color:u.color.text,fontSize:u.font.row,fontWeight:"600",lineHeight:20,paddingHorizontal:12,paddingTop:12,paddingBottom:8},hint:{color:u.color.textTertiary,fontSize:u.font.micro,paddingHorizontal:12,paddingBottom:10},decided:{color:u.color.textSecondary,fontSize:u.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:u.radius.row},buttonPrimary:{backgroundColor:u.color.accent},buttonPlate:{backgroundColor:u.color.button},buttonTextPrimary:{color:u.color.onAccent,fontSize:u.font.caption,fontWeight:"600"},buttonTextPlate:{color:u.color.text,fontSize:u.font.caption,fontWeight:"600"},chips:{flexDirection:"row",flexWrap:"wrap",gap:6},chip:{paddingHorizontal:12,paddingVertical:7,borderRadius:u.radius.chip,backgroundColor:u.color.fill,borderWidth:v.hairlineWidth,borderColor:u.color.border},chipOn:{backgroundColor:u.color.accentSoft,borderColor:u.color.accentBorderStrong},chipText:{color:u.color.text,fontSize:u.font.caption},chipTextOn:{color:u.color.accent,fontWeight:"600"},optionsBox:{marginHorizontal:8,marginBottom:8,borderRadius:u.radius.row,backgroundColor:u.color.surfaceElevated,overflow:"hidden"},option:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:10},optionLabel:{color:u.color.text,fontSize:u.font.body,fontWeight:"500"},optionDetail:{color:u.color.textSecondary,fontSize:u.font.caption},checkbox:{width:20,height:20,borderRadius:6,borderWidth:1.5,borderColor:u.color.textTertiary,alignItems:"center",justifyContent:"center"},checkboxOn:{backgroundColor:u.color.accent,borderColor:u.color.accent},selectBox:{marginHorizontal:12,marginBottom:12,borderRadius:u.radius.row,backgroundColor:u.color.surfaceElevated,overflow:"hidden"},selectField:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:11},selectPlaceholder:{color:u.color.textSecondary,fontSize:u.font.body},search:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:6,borderTopWidth:v.hairlineWidth,borderTopColor:u.color.separator},searchInput:{flex:1,color:u.color.text,fontSize:u.font.caption,paddingVertical:4},sliderRow:{flexDirection:"row",alignItems:"center",gap:8},stepBtn:{width:28,height:28,borderRadius:14,backgroundColor:u.color.fill,alignItems:"center",justifyContent:"center"},stepText:{color:u.color.text,fontSize:16,fontWeight:"600"},trackHit:{flex:1,height:36,justifyContent:"center"},track:{height:6,borderRadius:3,backgroundColor:u.color.fillTertiary,justifyContent:"center"},fill:{height:6,borderRadius:3,backgroundColor:u.color.accent},thumb:{position:"absolute",width:20,height:20,borderRadius:10,backgroundColor:u.color.knob,marginLeft:-10,shadowColor:"#000",shadowOpacity:.35,shadowRadius:3,shadowOffset:{width:0,height:1}},sliderValue:{width:64,textAlign:"right",color:u.color.text,fontSize:u.font.caption,fontWeight:"600"},inputRow:{flexDirection:"row",alignItems:"center",gap:8,paddingBottom:12},input:{flex:1,height:38,paddingHorizontal:12,borderRadius:u.radius.row,backgroundColor:u.color.surfaceElevated,color:u.color.text,fontSize:u.font.body},fieldRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:10,paddingVertical:6},fieldCol:{paddingVertical:6,gap:6},fieldLabel:{color:u.color.textSecondary,fontSize:u.font.caption,width:110},fieldInput:{flex:1,height:34,paddingHorizontal:10,borderRadius:u.radius.segment,backgroundColor:u.color.surfaceElevated,color:u.color.text,fontSize:u.font.caption},confirmTitle:{color:u.color.text,fontSize:u.font.row,fontWeight:"600",paddingHorizontal:12,paddingTop:12},confirmChange:{color:u.color.text,fontSize:u.font.body,lineHeight:19,paddingHorizontal:12,paddingTop:6,paddingBottom:6},consequence:{color:u.color.warning,fontSize:u.font.caption,paddingHorizontal:12},claim:{gap:6,paddingHorizontal:2},claimText:{color:u.color.text,fontSize:u.font.row,lineHeight:22},cite:{color:u.color.accent,fontSize:u.font.caption,fontWeight:"700"},verified:{color:u.color.accent,fontSize:u.font.caption,fontWeight:"600"},citeBox:{padding:10,borderRadius:u.radius.row,backgroundColor:u.color.surface,borderWidth:v.hairlineWidth,borderColor:u.color.border,gap:2},citeLabel:{color:u.color.text,fontSize:u.font.caption,fontWeight:"600"},citeDetail:{color:u.color.textSecondary,fontSize:u.font.caption,fontFamily:we.OS==="web"?Eo:"Menlo"},verifyBtn:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:5,paddingHorizontal:10,paddingVertical:5,borderRadius:u.radius.chip,backgroundColor:u.color.accentSoft},verifyText:{color:u.color.accent,fontSize:u.font.micro,fontWeight:"700"},detailsBody:{color:u.color.textSecondary,fontSize:u.font.caption,lineHeight:18,paddingHorizontal:12,paddingBottom:12},tabsWrap:{gap:8},tabBar:{flexDirection:"row",gap:6},tab:{paddingHorizontal:12,paddingVertical:6,borderRadius:u.radius.badge,backgroundColor:u.color.fill},tabOn:{backgroundColor:u.color.accentSoft},tabText:{color:u.color.textSecondary,fontSize:u.font.caption,fontWeight:"600"},tabTextOn:{color:u.color.accent},tlRow:{flexDirection:"row",gap:10,paddingHorizontal:12,paddingVertical:4,alignItems:"flex-start"},tlAt:{width:46,color:u.color.textTertiary,fontSize:u.font.micro,fontFamily:we.OS==="web"?Eo:"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:u.color.separator,marginTop:2},tlSource:{color:u.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.6},sparkHead:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingTop:8},sparkCurrent:{color:u.color.text,fontSize:22,fontWeight:"700"},sparkUnit:{color:u.color.textSecondary,fontSize:u.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:u.radius.badge,backgroundColor:u.color.dangerSoft},liveDot:{width:6,height:6,borderRadius:3,backgroundColor:u.color.danger},liveText:{color:u.color.danger,fontSize:9,fontWeight:"800",letterSpacing:.8},cmpHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,backgroundColor:u.color.fill,gap:8},cmpCol:{flex:1,color:u.color.textTertiary,fontSize:u.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},cmpRow:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"flex-start"},cmpDiff:{backgroundColor:u.color.fill},cmpKey:{width:90,color:u.color.textSecondary,fontSize:u.font.caption},cmpVal:{flex:1,color:u.color.text,fontSize:u.font.caption,fontFamily:we.OS==="web"?Eo:"Menlo"},cardImage:{width:"100%",height:140,backgroundColor:u.color.fill},cardText:{paddingHorizontal:12,paddingTop:10,paddingBottom:4,gap:4},cardTitle:{color:u.color.text,fontSize:u.font.row,fontWeight:"600"},fact:{flexDirection:"row",justifyContent:"space-between",gap:8},factLabel:{color:u.color.textSecondary,fontSize:u.font.caption},factValue:{color:u.color.text,fontSize:u.font.caption,fontWeight:"500"},carouselTitle:{color:u.color.text,fontSize:u.font.caption,fontWeight:"600",paddingBottom:8},carousel:{gap:8,paddingRight:8},carouselCard:{width:224,borderRadius:u.radius.card,borderWidth:v.hairlineWidth,borderColor:u.color.border,backgroundColor:u.color.surface,overflow:"hidden"},shot:{width:"100%",height:220,backgroundColor:u.color.fill},shotBig:{height:520},progress:{height:4,backgroundColor:u.color.fill,marginHorizontal:12,marginTop:6,marginBottom:8,borderRadius:2,overflow:"hidden"},progressFill:{height:4,backgroundColor:u.color.accent},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:u.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:u.color.accent},stepFailed:{backgroundColor:u.color.danger},stepRunning:{backgroundColor:u.color.info},stepNum:{color:u.color.text,fontSize:u.font.micro,fontWeight:"700"},checkpoint:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:7,borderRadius:u.radius.chip,backgroundColor:u.color.fill},cpFlag:{width:8,height:8,borderRadius:2,backgroundColor:u.color.info},cpText:{color:u.color.textSecondary,fontSize:u.font.caption},cpRestore:{color:u.color.accent,fontSize:u.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:u.radius.row,borderWidth:v.hairlineWidth},bannerText:{flex:1,fontSize:u.font.caption,fontWeight:"600"},fileIcon:{width:40,height:40,borderRadius:8,backgroundColor:u.color.fill,alignItems:"center",justifyContent:"center"},fileExt:{color:u.color.textSecondary,fontSize:10,fontWeight:"800"}});import{jsx as A}from"react/jsx-runtime";var Ps=class extends Bl{constructor(){super(...arguments);this.state={failed:false}}static getDerivedStateFromError(){return{failed:true}}render(){return this.state.failed?A(l,{style:Ws.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}},Ws=v.create({fallback:{color:$r.color.textTertiary,fontSize:$r.font.micro,fontStyle:"italic",paddingVertical:6}}),Es=e=>A(bo,{block:e});function bo({block:e}){return A(Ps,{children:A(Vs,{block:e})})}function Vs({block:e}){switch(e.kind){case"choice":return A(ia,{block:e});case"confirm":return A(la,{block:e});case"input":return A(aa,{block:e});case"table":return A($a,{block:e});case"keyValue":return A(Aa,{block:e});case"list":return A(La,{block:e});case"imageGrid":return A(_a,{block:e});case"diff":return A(Ha,{block:e});case"chart":return A(Pa,{block:e});case"steps":return A(Wa,{block:e});case"code":return A(ja,{block:e});case"actions":return A(Ne,{actions:e.actions,blockId:e.id});case"notice":return A(Ma,{block:e});case"finding":return A(qa,{block:e});case"requestList":return A(Qa,{block:e});case"requestCard":return A(Za,{block:e});case"ruleCard":return A(es,{block:e});case"screenElements":return A(ts,{block:e});case"routeChips":return A(os,{block:e});case"logList":return A(rs,{block:e});case"crash":return A(ns,{block:e});case"peek":return A(is,{block:e});case"suggestions":return A(ps,{block:e});case"multiSelect":return A(hs,{block:e});case"select":return A(fs,{block:e});case"slider":return A(bs,{block:e});case"dateTime":return A(ys,{block:e});case"form":return A(ms,{block:e});case"proposal":return A(xs,{block:e});case"claim":return A(ks,{block:e});case"details":return A(ws,{block:e});case"tabs":return A(vs,{block:e,renderNested:Es});case"timeline":return A(Ts,{block:e});case"sparkline":return A(Cs,{block:e});case"compare":return A(Is,{block:e});case"card":return A(zs,{block:e});case"cardCarousel":return A(Ds,{block:e});case"screenshot":return A(Rs,{block:e});case"plan":return A($s,{block:e});case"checkpoint":return A(As,{block:e});case"task":return A(Bs,{block:e});case"banner":return A(Ls,{block:e});case"file":return A(Os,{block:e});case"upload":return A(Hs,{block:e});default:return null}}import{monoFont as Ns}from"@buoy-gg/shared-ui/web";import{useEffect as js,useState as Tt}from"react";import{ChevronDown as Ms,ChevronRight as qs,Copy as Fs,night as C,RefreshCw as _s}from"@buoy-gg/shared-ui/web";import{jsx as N,jsxs as ze}from"react/jsx-runtime";function Zt({label:e,onPress:t,children:o}){return N(x,{onPress:t,accessibilityRole:"button",accessibilityLabel:e,style:({pressed:r})=>[H.iconBtn,r&&H.pressed],children:o})}function Us({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(Zt,{label:"Copy",onPress:()=>n("copy"),children:N(Fs,{size:13,color:C.color.textSecondary})}),N(Zt,{label:"Retry",onPress:()=>n("retry"),children:N(_s,{size:13,color:C.color.textSecondary})}),N(Zt,{label:"Good answer",onPress:()=>{r("up"),n("thumbs up")},children:N(l,{style:[H.glyph,o==="up"&&H.glyphOn],children:"\u{1F44D}"})}),N(Zt,{label:"Bad answer",onPress:()=>{r("down"),n("thumbs down")},children:N(l,{style:[H.glyph,o==="down"&&H.glyphOn],children:"\u{1F44E}"})}),N(Zt,{label:"Export",onPress:()=>n("export transcript"),children:N(l,{style:H.textBtn,children:"Export"})})]})}function Ks({text:e,live:t}){let[o,r]=Tt(false);return ze(s,{style:H.reasoning,testID:"chrome-reasoning",children:[ze(x,{onPress:()=>r(n=>!n),style:H.reasoningHead,accessibilityRole:"button",accessibilityState:{expanded:o},children:[t?N(Yt,{size:"small",color:C.color.textTertiary}):null,N(l,{style:H.reasoningTitle,children:t?"Working it out\u2026":"How I got here"}),o?N(Ms,{size:12,color:C.color.textTertiary}):N(qs,{size:12,color:C.color.textTertiary})]}),o?N(l,{style:H.reasoningBody,children:e}):null]})}function Gs({label:e}){let[t,o]=Tt(0);return js(()=>{let r=setInterval(()=>o(n=>n+250),250);return()=>clearInterval(r)},[]),ze(s,{style:H.elapsed,testID:"chrome-elapsed",children:[N(Yt,{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 Js(){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(x,{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(x,{disabled:!e.trim(),onPress:()=>{r(e.trim()),t("")},style:[H.queueBtn,!e.trim()&&{opacity:.5}],children:N(l,{style:H.queueBtnText,children:"Queue"})})]})]})}function Ys({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 Qs({at:e}){return N(l,{style:H.timestamp,children:e})}function Xs({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(x,{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(x,{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(x,{onPress:()=>r(false),style:H.editPlate,children:N(l,{style:H.editPlateText,children:"Cancel"})})]})]}):ze(x,{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=v.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:v.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"?Ns:"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:v.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:v.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:v.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:v.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 dn}from"react";import{AlertTriangle as Zs,ChevronDown as ec,night as E}from"@buoy-gg/shared-ui/web";import{jsx as xe,jsxs as eo}from"react/jsx-runtime";function un({pending:e,onAnswer:t}){let[o,r]=dn("");return eo(s,{style:Y.card,testID:"buoy-ask-buoy-approval",children:[eo(s,{style:Y.titleRow,children:[xe(Zs,{size:14,color:E.color.warning}),xe(l,{style:Y.title,children:"Allow this change?"})]}),e.restored?xe(l,{style:Y.restored,testID:"buoy-ask-buoy-approval-restored",children:"Asked before the app restarted \u2014 check it still applies."}):null,xe(l,{style:Y.label,children:e.label}),xe(l,{style:Y.reason,children:e.reason}),e.description?xe(tc,{text:e.description}):null,xe(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}),eo(s,{style:Y.actions,children:[xe(x,{testID:"buoy-ask-buoy-approve",accessibilityRole:"button",onPress:()=>t({approved:true,reason:o}),style:({pressed:n})=>[Y.button,Y.approve,n&&Y.pressed],children:xe(l,{style:Y.approveText,children:"Allow"})}),e.restored?null:xe(x,{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:xe(l,{style:Y.trustText,children:"Allow for this chat"})}),xe(x,{testID:"buoy-ask-buoy-reject",accessibilityRole:"button",onPress:()=>t({approved:false,reason:o}),style:({pressed:n})=>[Y.button,Y.reject,n&&Y.pressed],children:xe(l,{style:Y.rejectText,children:"Not now"})})]})]})}function tc({text:e}){let[t,o]=dn(false);return eo(s,{children:[eo(x,{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:[xe(s,{style:t?Y.chevronOpen:Y.chevronClosed,children:xe(ec,{size:12,color:E.color.textTertiary})}),xe(l,{style:Y.disclosureText,children:t?"Hide details":"Details"})]}),t?xe(Ke,{style:Y.detail,contentContainerStyle:Y.detailContent,nestedScrollEnabled:true,children:xe(l,{style:Y.description,children:e})}):null]})}var Y=v.create({card:{marginHorizontal:E.gutter,marginBottom:10,padding:E.cardPad,borderRadius:E.radius.card,borderWidth:v.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:v.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:v.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 oc}from"react";import{ChevronDown as rc,ChevronRight as nc,night as re}from"@buoy-gg/shared-ui/web";import{isReversible as pn}from"@buoy-gg/agent-core/web";import{jsx as at,jsxs as bt}from"react/jsx-runtime";var hn=[];function gn(e){return oc(t=>e?.subscribe(t)??(()=>{}),()=>e?.list()??hn,()=>e?.list()??hn)}function fn({ledger:e,onUndoAll:t,expanded:o,onToggle:r}){let n=gn(e).filter(m=>!m.undoneAt),i=n.filter(m=>m.effect.kind!=="transient");if(i.length===0)return null;let a=i.filter(m=>pn(m.effect)),g=i.length-a.length,d=n.length-i.length,h=o?rc:nc,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(x,{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(Ke,{style:fe.panelScroll,testID:"buoy-ask-buoy-changes-scroll",keyboardShouldPersistTaps:"handled",children:[i.map(m=>{let L=!pn(m.effect);return bt(s,{style:fe.row,children:[at(l,{style:fe.rowLabel,children:m.effect.label}),at(l,{style:[fe.rowTag,L&&fe.rowTagMuted],children:L?"Permanent":"Undoable"})]},m.id)}),d>0&&at(s,{style:fe.row,children:bt(l,{style:[fe.rowLabel,fe.rowLabelMuted],children:["Also did ",d," one-shot action",d===1?"":"s"," (navigation, taps) \u2014 nothing to undo."]})})]}),bt(s,{style:fe.footer,children:[a.length>0&&at(x,{testID:"buoy-ask-buoy-undo-all",accessibilityRole:"button",onPress:t,style:({pressed:m})=>[fe.undo,m&&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=v.create({wrap:{borderBottomWidth:v.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:v.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 ic(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 lc,useEffect as bn,useRef as ac,useState as sc}from"react";import{night as Te}from"@buoy-gg/shared-ui/web";import{jsx as yt,jsxs as cc}from"react/jsx-runtime";var yn=40,dc=120,mn=we.OS==="ios"?10:6,uc=16;function xn({onSend:e,onStop:t,busy:o,draft:r,onDraftTaken:n,disabled:i,placeholder:a,focusKey:g,canFocus:d=true}){let[h,f]=sc(""),m=ac(null);bn(()=>{!g||!d||i||m.current?.focus()},[g,d,i]),bn(()=>{r&&(f(ce=>ce?`${ce} ${r}`:r),n?.())},[r,n]);let L=lc(()=>{let ce=h.trim();ce&&(f(""),e(ce))},[h,e]),V=h.trim().length>0&&!o&&!i,ee=h.trim().length>0&&o&&!i;return cc(s,{style:ke.wrap,children:[yt(s,{style:[ke.field,i&&ke.fieldDisabled],children:yt(rt,{ref:m,testID:"buoy-ask-buoy-input",accessibilityLabel:"Message for Ask Buoy",style:[ke.input,h.length===0&&ke.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:L,returnKeyType:"send",maxLength:4e3})}),ee&&yt(x,{testID:"buoy-ask-buoy-queue",accessibilityRole:"button",accessibilityLabel:"Queue message",onPress:L,style:({pressed:ce})=>[ke.button,ke.queue,ce&&ke.pressed],children:yt(l,{style:[ke.sendGlyph,{color:Te.color.accent}],children:"\u2191"})}),o?yt(x,{testID:"buoy-ask-buoy-stop",accessibilityRole:"button",accessibilityLabel:"Stop",onPress:t,style:({pressed:ce})=>[ke.button,ke.stop,ce&&ke.pressed],children:yt(s,{style:ke.stopGlyph})}):yt(x,{testID:"buoy-ask-buoy-send",accessibilityRole:"button",accessibilityLabel:"Send",disabled:!V,onPress:L,style:({pressed:ce})=>[ke.button,V?ke.sendOn:ke.sendOff,ce&&V&&ke.pressed],children:yt(l,{style:[ke.sendGlyph,{color:V?Te.color.onAccent:Te.color.textTertiary}],children:"\u2191"})})]})}var ke=v.create({wrap:{flexDirection:"row",alignItems:"flex-end",gap:8,paddingHorizontal:Te.gutter,paddingTop:10,paddingBottom:6,borderTopWidth:v.hairlineWidth,borderTopColor:Te.color.border,backgroundColor:Te.color.bg},field:{flex:1,minHeight:yn,justifyContent:"center",borderRadius:20,borderWidth:v.hairlineWidth,borderColor:Te.color.border,backgroundColor:Te.color.surfaceElevated},fieldDisabled:{opacity:.6},input:{maxHeight:dc,paddingHorizontal:uc,paddingTop:mn,paddingBottom:mn,color:Te.color.text,fontSize:Te.font.row},inputEmpty:{height:yn},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:v.hairlineWidth,borderColor:Te.color.accentBorderStrong},stopGlyph:{width:12,height:12,borderRadius:2,backgroundColor:Te.color.text},pressed:{opacity:.7}});import{useEffect as pc,useRef as kn}from"react";import{jsx as hc}from"react/jsx-runtime";function gc({children:e}){let t=kn(null),o=kn(new ue.Value(0)).current;return pc(()=>{if(we.OS!=="ios")return;let r=(g,d)=>{ue.timing(o,{toValue:g,duration:d.duration||250,easing:At.bezier(.17,.59,.4,.77),useNativeDriver:false}).start()},n=g=>{let d=t.current;d&&d.measureInWindow((h,f,m,L)=>{let V=f+L-g.endCoordinates.screenY;r(Math.max(0,V),g)})},i=g=>r(0,g),a=[Ro.addListener("keyboardWillChangeFrame",n),Ro.addListener("keyboardWillHide",i)];return()=>a.forEach(g=>g.remove())},[o]),hc(ue.View,{ref:t,style:[fc.flex,{paddingBottom:o}],children:e})}var fc=v.create({flex:{flex:1}});import{useEffect as wn,useState as vn}from"react";import{Check as bc,Copy as yc,FileText as mc,ModalHeader as yo,night as Ye,Otto as xc,Plus as kc,SettingsSolid as wc,realNow as Vo}from"@buoy-gg/shared-ui/web";import{toolTitle as vc}from"@buoy-gg/agent-core/web";var Sc=e=>e.effect==="read"&&e.status==="ok";function Tc(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=>vc(i.toolId)))];t.push({kind:"reads",id:o.map(i=>i.id).join("+"),calls:o,label:`Looked at ${Cc(n)}`,count:o.length})}o=[]}};for(let n of e){if(Sc(n)){o.push(n);continue}r(),t.push({kind:"call",call:n})}return r(),t}function Cc(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 Ic(e){let t=[];e.startedAt!==void 0&&e.endedAt!==void 0&&e.endedAt>=e.startedAt&&t.push(Sn(e.endedAt-e.startedAt));let o=e.toolCalls.length;if(o>0){t.push(`${o} action${o===1?"":"s"}`);let r=d=>e.toolCalls.filter(h=>h.status===d).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 Sn(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 Tn}from"react/jsx-runtime";var zc=200,Dc=()=>"";function Cn({configured:e,busy:t,failed:o=false,activeLabel:r,awaitingApproval:n=false,startedAt:i=null,stopping:a=false,readOnly:g=false,toolCount:d,hasMessages:h,onBack:f,onReset:m,getTranscript:L,onOpenSettings:V,onTicket:ee}){let{copied:ce,copy:pe}=ho(L??Dc),[Pe,qe]=vn(false);wn(()=>{t?r&&qe(true):qe(false)},[t,r]);let We=t&&!n&&i!==null,[Xe,Ze]=vn(()=>Vo());wn(()=>{if(!We)return;Ze(Vo());let Nt=setInterval(()=>Ze(Vo()),1e3);return()=>clearInterval(Nt)},[We]);let et=We&&i!==null?Sn(Xe-i):null,Vt=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${d>0?` \xB7 ${d} tool${d===1?"":"s"}`:""}`:d>0?`Ready \xB7 ${d} tool${d===1?"":"s"} available`:"Ready":"Not set up in this app";return Tn(yo,{children:[f?Be(yo.Navigation,{onBack:f}):null,Be(s,{style:mt.otto,testID:"buoy-ask-buoy-otto",children:Be(xc,{state:Vt,pixelSize:2,tickMs:zc,water:false})}),Be(yo.Content,{title:"Ask Buoy",subtitle:Ee,testID:"buoy-ask-buoy-title"}),Tn(yo.Actions,{children:[ee?Be(Jt,{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(mc,{size:14,color:h&&!t?Ye.color.textSecondary:Ye.color.textTertiary})}):null,L?Be(Jt,{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(bc,{size:14,color:Ye.color.accent}):Be(yc,{size:14,color:h?Ye.color.textSecondary:Ye.color.textTertiary})}):null,V?Be(Jt,{testID:"buoy-ask-buoy-settings",accessibilityRole:"button",accessibilityLabel:"Settings",onPress:V,style:mt.actionBtn,children:Be(wc,{size:14,color:Ye.color.textSecondary})}):null,Be(Jt,{testID:"buoy-ask-buoy-reset",accessibilityRole:"button",accessibilityLabel:"New conversation",disabled:!h,onPress:m,style:[mt.actionBtn,!h&&mt.actionBtnDisabled],children:Be(kc,{size:14,color:h?Ye.color.textSecondary:Ye.color.textTertiary})})]})]})}var mt=v.create({otto:{marginRight:8,justifyContent:"center"},actionBtn:{width:32,height:32,borderRadius:8,backgroundColor:Ye.color.buttonSurface,borderWidth:1,borderColor:Ye.color.border,alignItems:"center",justifyContent:"center"},actionBtnDisabled:{opacity:.55}});import{useCallback as Rc,useEffect as $c,useState as Ac}from"react";import{AlertTriangle as Bc,night as se,ToggleRow as No}from"@buoy-gg/shared-ui/web";import{useSyncExternalStore as Lc}from"react";import{definePersistedSetting as Oc,devToolsStorageKeys as Hc}from"@buoy-gg/shared-ui/web";var jo={showThinking:false,bypassApprovals:false,readOnly:false,hostedNoticeSeen:false,claudeNoticeSeen:false},Mo=Oc(`${Hc.base}_ask_buoy_settings`,jo,{sanitize:e=>({showThinking:e.showThinking===true,bypassApprovals:e.bypassApprovals===true,readOnly:e.readOnly===true,hostedNoticeSeen:e.hostedNoticeSeen===true,claudeNoticeSeen:e.claudeNoticeSeen===true})}),Ct=jo,qo=false,Fo=new Set;function In(){for(let e of Fo)try{e()}catch{}}var st={get:()=>Ct,subscribe(e){return Fo.add(e),qo||(qo=true,Mo.load().then(t=>{Ct=t,In()})),()=>Fo.delete(e)},set(e,t){Ct[e]!==t&&(Ct={...Ct,[e]:t},In(),Mo.save(Ct))},reset(){Ct=jo,qo=false,Mo.clear()}};function Pt(){return Lc(st.subscribe,st.get,st.get)}import{useSyncExternalStore as Pc}from"react";import{definePersistedSetting as Wc,devToolsStorageKeys as Ec,subscribeStorageWrites as Vc}from"@buoy-gg/shared-ui/web";var _o="claude",zn=Ec.askBuoy.model(),Dn=e=>e==="luna"?"luna":"claude",Rn=Wc(zn,_o,{sanitize:Dn}),mo=_o,$n=false,Uo=new Set;function Nc(){for(let e of Uo)try{e()}catch{}}function Ko(e){e!==mo&&(mo=e,Nc())}var xo={get:()=>mo,subscribe(e){return Uo.add(e),$n||($n=true,Rn.load().then(Ko),Vc((t,o)=>{if(t===zn)try{Ko(Dn(o===null?_o:JSON.parse(o)))}catch{}})),()=>Uo.delete(e)},set(e){e!==mo&&(Ko(e),Rn.save(e))}};function An(){return Pc(xo.subscribe,xo.get,xo.get)}import{idFactory as Bn}from"@buoy-gg/agent-core/web";import{realNow as to}from"@buoy-gg/shared-ui/web";import{persistentStorage as Go,devToolsStorageKeys as jc}from"@buoy-gg/shared-ui/web";import{dispatchToolAction as Ln}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 oo(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=`${jc.base}_ask_buoy_transcript`,Yo=1,On=60,qc=256e3,Fc="[not kept across a restart \u2014 read it again if you need it]";function ct(e){return e&&oo(e)}function _c(e){let t=e.streaming===true;return{...e,text:ct(e.text),streaming:false,reasoning:e.reasoning?.map(o=>({...o,text:ct(o.text)})),toolCalls:e.toolCalls.map(o=>{let r=o.params?ct(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 Uc(e){return e.map(t=>t.role==="tool-results"?{...t,results:t.results.map(o=>({...o,content:Fc}))}:t.role==="assistant"?{...t,text:ct(t.text)}:{...t,text:ct(t.text)})}function Hn(e){let t={...e,messages:e.messages.slice(-On),history:e.history.slice(-On*2)},o=JSON.stringify(t);for(;o.length>qc&&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 oo(o)!==o?null:{id:e.id,toolId:e.toolId,action:e.action,label:ct(e.label),description:e.description?ct(e.description):void 0,reason:ct(e.reason),params:t,targetDigest:e.targetDigest}}function Gc(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 Pn(e){if(!e?.length)return;let t=e.filter(o=>{try{let r=JSON.stringify(o);return oo(r)===r}catch{return false}});return t.length?t:void 0}function Jc(e){return Hn({v:Yo,savedAt:Date.now(),messages:e.messages.map(_c),history:Uc(e.history),answers:e.answers,usage:e.usage,pending:Kc(e.pending),ledger:Pn(e.ledger),queued:e.queued?.length?e.queued.map(t=>({id:t.id,text:ct(t.text)})):void 0})}function Yc(e){if(!e)return null;try{let t=JSON.parse(e);return t?.v!==Yo||!Array.isArray(t.messages)||t.messages.length===0?null:{v:Yo,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:Gc(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 Wn(){try{return Yc(await Go.getItem(Jo))}catch{return null}}var ko=0;async function En(e){ko+=1;try{await Go.setItem(Jo,JSON.stringify(e))}catch{}}async function Qc(e){let t=ko,o=await Wn();!o||t!==ko||await En(Hn({...o,ledger:Pn(e)}))}async function Xc(){ko+=1;try{await Go.removeItem(Jo)}catch{}}var wo=Bn("m"),Vn=400;function Zc(e){if(!(!e||Object.keys(e).length===0))try{let t=JSON.stringify(e);return t.length>Vn?`${t.slice(0,Vn)}\u2026`:t}catch{return}}var ed=Bn("q"),O={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:{}},Nn=null,jn=null,Qo=new Set,Xo=null,Mn=null,Zo=null;function X(e){O={...O,...e};for(let t of Qo)try{t()}catch{}}var b={getState:()=>O,subscribe(e){return Qo.add(e),()=>Qo.delete(e)},setLedger(e){e!==Xo&&(Mn?.(),Xo=e,Mn=e?e.subscribe(()=>void Qc(e.list())):null)},getLedger(){return Xo},holdSession(e,t){Zo={session:e,signature:t}},getHeldSession(){return Zo},setReporter(e){Nn=e},getReporter(){return Nn},setUsageReader(e){jn=e},getUsageReader(){return jn},setNotice(e){X({notice:e})},setConfigured(e){e!==O.configured&&X({configured:e})},setClaudeOut(e){O.claudeOut!==e&&X({claudeOut:e})},setMeta(e){Object.keys(e).every(t=>O.meta[t]===e[t])||X({meta:{...O.meta,...e}})},addUser(e){X({messages:[...O.messages,{id:wo(),role:"user",text:e,toolCalls:[],blocks:[]}],busy:true})},beginTurn(){X({busy:true})},enqueue(e){let t={id:ed(),text:e};return X({queued:[...O.queued,t]}),t},removeQueued(e){O.queued.some(t=>t.id===e)&&X({queued:O.queued.filter(t=>t.id!==e)})},shiftQueued(){let[e,...t]=O.queued;if(e)return X({queued:t}),e},takeQueuedToDraft(e){let t=O.queued.find(o=>o.id===e);t&&X({queued:O.queued.filter(o=>o.id!==e),draft:t.text})},requestStop(){!O.busy||O.stopping||X({stopping:true})},clearDraft(){O.draft!==null&&X({draft:null})},removeMessage(e){X({messages:O.messages.filter(t=>t.id!==e)})},recordAnswer(e){X({answers:{...O.answers,[e.blockId]:e},awaitingBlockId:O.awaitingBlockId===e.blockId?null:O.awaitingBlockId})},setActionState(e,t){let o={...O.actionState};t===null?delete o[e]:o[e]=t,X({actionState:o})},startAssistant(){let e=wo();return X({messages:[...O.messages,{id:e,role:"assistant",text:"",toolCalls:[],blocks:[],streaming:true,startedAt:to()}]}),e},applyEvent(e,t){if(t.type==="history-trimmed"){let r=O.messages.findIndex(a=>a.id===e),n={id:wo(),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:to()},i=[...O.messages];i.splice(r<0?i.length:r,0,n),X({messages:i});return}let o=O.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})`:t.reason==="network"?"Connection dropped \u2014 trying again":"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 Aa(e){return e.map(_r).filter(t=>!!t)}import{Fragment as Ba,jsx as z,jsxs as ge}from"react/jsx-runtime";function Eo(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=it(e.rows,to.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:A.tableHead,children:r.map((n,i)=>z(l,{style:[A.th,i===0&&A.firstCol],numberOfLines:1,children:n},n))}),o.map((n,i)=>z(s,{style:[A.tr,i>0&&D.rowDivider],children:r.map((a,h)=>{let d=n[h],g=typeof d=="string"?d:d?.text??"",f=typeof d=="string"?void 0:d?.tone;return z(l,{style:[A.td,h===0&&A.firstCol,h===0&&A.tdFirst,f&&{color:Ct(f)}],numberOfLines:2,children:Vt(g,A.td)},h)})},i)),z(lt,{paged:t})]})}function Oa({block:e}){let t=it(e.pairs,to.keyValuePairs),{visible:o}=t,[r,n]=Nr(null);return ge(W,{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,d=r===i.key;return ge(k,{onPress:h?()=>n(d?null:i.key):void 0,style:[A.kvRow,a>0&&D.rowDivider],children:[z(l,{style:A.kvKey,numberOfLines:1,children:i.key}),z(l,{style:[A.kvValue,d&&D.mono],numberOfLines:d?void 0:2,selectable:true,children:d?JSON.stringify(i.value,null,2):Eo(i.value)})]},i.key)}),z(lt,{paged:t})]})}function Ha(e){let t=!!e.image;return{canExpand:t,rowRunsAction:!!e.action&&!t,actionIsOwnControl:!!e.action&&t}}function Pa({block:e}){let t=te(),o=it(e.items,to.listItems),{visible:r}=o,[n,i]=Nr(null);return ge(W,{title:e.title,source:e.source,testID:`buoy-block-list-${e.id}`,children:[r.map((a,h)=>{let d=`${a.id??a.title}-${h}`,g=n===d,{canExpand:f,rowRunsAction:y,actionIsOwnControl:$}=Ha(a),V=f||y?k:s,re=f?{onPress:()=>i(g?null:d),accessibilityRole:"button",accessibilityState:{expanded:g},accessibilityLabel:`${a.title}, ${g?"hide":"show"} picture`,testID:`buoy-block-list-row-${d}`}:y?{onPress:()=>void t.runAction(a.action,e.id),accessibilityRole:"button"}:{};return ge(s,{style:h>0?D.rowDivider:void 0,children:[g&&a.image?z(k,{onPress:()=>i(null),accessibilityRole:"button",accessibilityLabel:`Hide ${a.title}`,testID:`buoy-block-list-hero-${d}`,style:A.listHero,children:z(Tt,{testID:"buoy-internal-chat-image",source:{uri:a.image},style:A.listHeroImage,resizeMode:"contain",accessibilityLabel:a.title})}):null,ge(V,{...re,style:D.row,children:[a.image&&!g?z(Tt,{testID:"buoy-internal-chat-image",source:{uri:a.image},style:A.thumb,resizeMode:"contain",accessibilityLabel:a.title}):a.icon?z(Or,{name:a.icon}):null,ge(s,{style:A.flex,children:[z(l,{style:[D.rowTitle,a.tone&&{color:Ct(a.tone)}],numberOfLines:g?void 0:2,children:Vt(a.title,D.rowTitle)}),a.subtitle?z(l,{style:D.rowSub,numberOfLines:g?void 0:2,children:Vt(a.subtitle,D.rowSub)}):null]}),a.trailing?z(l,{style:[D.rowTrailing,a.tone&&{color:Ct(a.tone)}],numberOfLines:1,children:a.trailing}):null,a.action?$?z(k,{onPress:()=>void t.runAction(a.action,e.id),accessibilityRole:"button",accessibilityLabel:a.action.label,hitSlop:8,children:z(l,{style:A.rowAction,children:a.action.label})}):z(l,{style:A.rowAction,children:a.action.label}):null]})]},d)}),z(lt,{paged:o})]})}function Ur(e){return e!==null&&typeof e=="object"}function Wa(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 Ea({block:e}){let t=it(e.changes,to.keyValuePairs);return ge(W,{title:e.title??"What changed",source:e.source,testID:`buoy-block-diff-${e.id}`,collapsible:true,summary:Wa(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:[A.diffRow,r>0&&D.rowDivider],children:[z(l,{style:A.diffPath,numberOfLines:1,children:o.path}),Ur(o.before)||Ur(o.after)?z(s,{style:A.diffTree,children:z(ba,{oldValue:o.before,newValue:o.after,showUnchanged:false,scrollEnabled:false})}):ge(Ba,{children:[n?null:ge(s,{style:A.diffLine,children:[z(l,{style:[A.diffMark,{color:L.color.danger}],children:"\u2212"}),z(l,{style:[A.diffValue,{color:L.color.danger}],numberOfLines:3,selectable:true,children:Eo(o.before)})]}),i?null:ge(s,{style:A.diffLine,children:[z(l,{style:[A.diffMark,{color:L.color.accent}],children:"+"}),z(l,{style:[A.diffValue,{color:L.color.accent}],numberOfLines:3,selectable:true,children:Eo(o.after)})]})]})]},`${o.path}-${r}`)}),z(lt,{paged:t})]})}function Va({block:e}){let t=e.bars.slice(0,to.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:A.chart,children:t.map((r,n)=>ge(s,{style:A.barRow,children:[z(l,{style:A.barLabel,numberOfLines:1,children:r.label}),z(s,{style:A.barTrack,children:z(s,{style:[A.bar,{width:`${Math.max(2,Math.round(r.value/o*100))}%`,backgroundColor:Ct(r.tone??"accent")}]})}),ge(l,{style:A.barValue,numberOfLines:1,children:[r.value,r.unit?` ${r.unit}`:""]})]},`${r.label}-${n}`))})})}function Na({block:e}){return z(W,{title:e.title,testID:`buoy-block-steps-${e.id}`,children:e.steps.map((t,o)=>ge(s,{style:[A.step,o>0&&D.rowDivider],children:[z(s,{style:[A.stepMark,t.state==="done"&&A.stepDone,t.state==="failed"&&A.stepFailed],children:t.state==="done"?z(pa,{size:10,color:L.color.onAccent}):t.state==="failed"?z(ga,{size:10,color:L.color.text}):z(l,{style:A.stepNum,children:o+1})}),z(l,{style:[D.rowTitle,t.state==="done"&&A.stepTextDone],children:t.text})]},o))})}function ja(e){try{let t=JSON.parse(e);return t!==null&&typeof t=="object"?t:void 0}catch{return}}function Ma({block:e,value:t}){return z(W,{title:e.title,testID:`buoy-block-code-${e.id}`,children:z(s,{style:A.viewer,children:z(fa,{title:e.title??"Payload",data:t,initialExpanded:true,showTypeFilter:false,testIDPrefix:`buoy-block-code-${e.id}`})})})}function qa({block:e}){return z(W,{title:e.title,testID:`buoy-block-code-${e.id}`,children:z(l,{style:[D.mono,A.code],selectable:true,children:e.text})})}function Fa({block:e}){let t=ja(e.text);return t===void 0?z(qa,{block:e}):z(Ma,{block:e,value:t})}function _a({block:e}){let t=e.tone==="danger"?L.color.danger:e.tone==="warning"?L.color.warning:L.color.info,o=e.tone==="info"?ha:ua;return ge(W,{tone:e.tone,testID:`buoy-block-notice-${e.id}`,children:[ge(s,{style:A.noticeRow,children:[z(o,{size:14,color:t}),z(l,{style:A.noticeText,children:e.text})]}),z(Ve,{actions:e.actions,blockId:e.id})]})}function Ua({block:e}){let{copied:t,copy:o}=bo(()=>_r(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:[A.kvRow,n>0&&D.rowDivider],children:[z(l,{style:A.kvKey,numberOfLines:1,children:r.label}),z(l,{style:[A.kvValue,r.tone&&{color:Ct(r.tone)}],selectable:true,children:r.value})]},`${r.label}-${n}`)),z(s,{style:A.findingFoot,children:z(k,{testID:`buoy-block-finding-copy-${e.id}`,accessibilityRole:"button",accessibilityLabel:t?"Copied":"Copy this finding",onPress:o,style:({pressed:r})=>[A.findingCopy,r&&{opacity:.7}],children:z(l,{style:[A.findingCopyText,t&&{color:L.color.accent}],children:t?"Copied":"Copy finding"})})}),z(Ve,{actions:e.actions,blockId:e.id})]})}var A=v.create({flex:{flex:1},tableHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,gap:8,backgroundColor:L.color.fill},th:{flex:1,color:L.color.textTertiary,fontSize:L.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},tr:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"center"},td:{flex:1,color:L.color.textSecondary,fontSize:L.font.caption,lineHeight:17},tdFirst:{color:L.color.text,fontWeight:"500"},firstCol:{flex:1.4},kvRow:{flexDirection:"row",gap:12,paddingHorizontal:12,paddingVertical:8,alignItems:"flex-start"},kvKey:{width:110,color:L.color.textSecondary,fontSize:L.font.caption,paddingTop:1},kvValue:{flex:1,color:L.color.text,fontSize:L.font.caption,lineHeight:17},findingFoot:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,borderTopWidth:v.hairlineWidth,borderTopColor:L.color.separator},findingCopy:{paddingHorizontal:10,paddingVertical:5,borderRadius:L.radius.badge,backgroundColor:L.color.fill},findingCopyText:{color:L.color.textSecondary,fontSize:L.font.micro,fontWeight:"600"},thumb:{width:40,height:40,borderRadius:8,backgroundColor:L.color.fill},listHero:{paddingHorizontal:12,paddingTop:12},listHeroImage:{width:"100%",height:240,borderRadius:L.radius.row,backgroundColor:L.color.fill},rowAction:{color:L.color.accent,fontSize:L.font.caption,fontWeight:"600"},diffRow:{paddingHorizontal:12,paddingVertical:8,gap:3},diffPath:{color:L.color.textSecondary,fontSize:L.font.micro,fontWeight:"600",letterSpacing:.3},diffLine:{flexDirection:"row",gap:8,alignItems:"flex-start"},diffMark:{fontFamily:we.OS==="web"?Vr:"Menlo",fontSize:12,width:10},diffValue:{flex:1,fontFamily:we.OS==="web"?Vr:"Menlo",fontSize:12,lineHeight:16},diffTree:{borderRadius:L.radius.row,overflow:"hidden"},chart:{paddingHorizontal:12,paddingVertical:10,gap:8},barRow:{flexDirection:"row",alignItems:"center",gap:8},barLabel:{width:96,color:L.color.textSecondary,fontSize:L.font.caption},barTrack:{flex:1,height:10,borderRadius:5,backgroundColor:L.color.fill,overflow:"hidden"},bar:{height:10,borderRadius:5},barValue:{width:72,textAlign:"right",color:L.color.text,fontSize:L.font.caption,fontWeight:"600"},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:L.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:L.color.accent},stepFailed:{backgroundColor:L.color.danger},stepNum:{color:L.color.text,fontSize:L.font.micro,fontWeight:"700"},stepTextDone:{color:L.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:L.color.text,fontSize:L.font.caption,lineHeight:18}});import{useState as Ka}from"react";import{night as Ne}from"@buoy-gg/shared-ui/web";import{CAPS as Kr}from"@buoy-gg/agent-core/web";import{jsx as Fe,jsxs as Vo}from"react/jsx-runtime";function Ja({block:e}){let[t,o]=Ka(null),{width:r}=vr(),n=e.images.slice(0,Kr.gridMax),i=n.length>Kr.gridImages,a=Math.min(150,Math.floor((r-2*Ne.gutter-24-8)/2)),h=({img:d,i:g})=>Vo(k,{testID:`buoy-block-image-${g}`,accessibilityRole:"imagebutton",accessibilityLabel:d.alt,onPress:()=>o(t===g?null:g),style:[_e.tile,{width:a},i&&_e.tileCarousel],children:[Fe(Tt,{testID:"buoy-internal-chat-image",source:{uri:d.url},style:[_e.image,{width:a,height:a}],resizeMode:"contain",accessibilityLabel:d.alt}),Fe(l,{style:_e.name,numberOfLines:1,children:d.alt}),d.caption?Fe(l,{style:_e.caption,numberOfLines:1,children:d.caption}):null]},`${d.url}-${g}`);return Vo(W,{title:e.title,source:e.source,testID:`buoy-block-imagegrid-${e.id}`,children:[t!==null&&n[t]?Vo(k,{onPress:()=>o(null),style:_e.hero,accessibilityRole:"button",accessibilityLabel:`Close ${n[t].alt}`,children:[Fe(Tt,{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(Ge,{horizontal:true,showsHorizontalScrollIndicator:false,snapToInterval:a+8,decelerationRate:"fast",contentContainerStyle:_e.carousel,children:n.map((d,g)=>Fe(h,{img:d,i:g},g))}):Fe(s,{style:_e.grid,children:n.map((d,g)=>Fe(h,{img:d,i:g},g))}),Fe(la,{shown:n.length,total:e.total})]})}var _e=v.create({grid:{flexDirection:"row",flexWrap:"wrap",gap:8,padding:12},carousel:{gap:8,paddingHorizontal:12,paddingVertical:12},tile:{gap:4},tileCarousel:{},image:{borderRadius:Ne.radius.row,backgroundColor:Ne.color.fill},name:{color:Ne.color.text,fontSize:Ne.font.micro,fontWeight:"600"},caption:{color:Ne.color.textSecondary,fontSize:Ne.font.micro},hero:{alignItems:"center",padding:12,gap:6,borderBottomWidth:v.hairlineWidth,borderBottomColor:Ne.color.separator},heroImage:{width:"100%",height:240,borderRadius:Ne.radius.row,backgroundColor:Ne.color.fill},heroCaption:{color:Ne.color.text,fontSize:Ne.font.caption}});import{monoFont as Ga}from"@buoy-gg/shared-ui/web";import{useState as Ya}from"react";import{AlertTriangle as Qa,ChevronRight as Za,Eye as Jr,night as R,NightSegmented as Xa}from"@buoy-gg/shared-ui/web";import{CAPS as yo}from"@buoy-gg/agent-core/web";import{jsx as P,jsxs as ce}from"react/jsx-runtime";function Gr(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 Yr(e){try{let t=new URL(e);return t.pathname+(t.search?"?\u2026":"")}catch{return e}}function Qr({status:e}){return P(s,{style:[D.pill,{backgroundColor:`${Gr(e)}22`}],children:P(l,{style:[D.pillText,{color:Gr(e)}],children:e??"\u2026"})})}function es({block:e}){let t=te(),o=t.supports?.openTool!==false,r=it(e.requests,yo.listItems),{visible:n}=r;return ce(W,{title:e.title??"Network requests",source:e.source,testID:`buoy-block-requests-${e.id}`,children:[n.map((i,a)=>ce(k,{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:Y.method,children:i.method}),P(l,{style:D.rowTitle,numberOfLines:1,children:Yr(i.url)}),i.mocked?P(l,{style:Y.mockedChip,children:"MOCKED"}):null,i.durationMs!==void 0?ce(l,{style:D.rowTrailing,children:[i.durationMs," ms"]}):null,P(Qr,{status:i.status}),o?P(Za,{size:12,color:R.color.textTertiary}):null]},`${i.id}-${a}`)),P(lt,{paged:r})]})}var ts=[{key:"response",label:"Response"},{key:"request",label:"Request"}];function os({block:e}){let[t,o]=Ya("response"),r=t==="response"?e.responseBody:e.requestBody,n=r===void 0?"(none)":typeof r=="string"?r:JSON.stringify(r,null,2),i=te();return ce(W,{source:e.source,testID:`buoy-block-request-${e.id}`,children:[ce(s,{style:[D.row,Y.reqHead],children:[P(l,{style:Y.method,children:e.request.method}),P(l,{style:D.rowTitle,numberOfLines:2,children:Yr(e.request.url)}),e.request.mocked?P(l,{style:Y.mockedChip,children:"MOCKED"}):null,P(Qr,{status:e.request.status})]}),P(s,{style:Y.tabs,children:P(Xa,{tabs:ts,activeKey:t,onChange:a=>o(a),size:"sm"})}),P(l,{style:[D.mono,Y.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 rs({block:e}){let t=te().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 ce(W,{title:r.name??"Network override",source:e.source,testID:`buoy-block-rule-${e.id}`,tone:r.enabled?"warning":void 0,children:[ce(s,{style:Y.ruleBody,children:[ce(l,{style:Y.ruleLine,children:[ce(l,{style:Y.ruleKey,children:[r.methods?.length?r.methods.join("/"):"ANY"," "]}),P(l,{style:D.mono,children:r.urlPattern})]}),ce(l,{style:Y.ruleLine,children:[P(l,{style:Y.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?Y.on:Y.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 ns({block:e}){let t=te(),o=it(e.elements,yo.chips),{visible:r}=o;return ce(W,{title:e.title??"On screen right now",source:e.source,testID:`buoy-block-screen-${e.id}`,children:[r.map((n,i)=>ce(k,{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 is({block:e}){let t=te(),o=it(e.routes,yo.chips),r=o.visible;return ce(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:Y.chips,children:r.map((n,i)=>P(k,{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:[Y.chip,n.path===e.current&&Y.chipCurrent],accessibilityRole:"button",children:P(l,{style:[Y.chipText,n.dynamic&&Y.chipDynamic],children:n.path})},`${n.path}-${i}`))}),P(lt,{paged:o})]})}var Zr={error:R.color.danger,warn:R.color.warning,warning:R.color.warning,info:R.color.info};function ls({block:e}){let t=it(e.entries,yo.listItems),{visible:o}=t;return ce(W,{title:"Console",source:e.source,testID:`buoy-block-logs-${e.id}`,children:[o.map((r,n)=>ce(s,{style:[D.row,n>0&&D.rowDivider,Y.logRow],children:[P(s,{style:[D.pill,{backgroundColor:`${Zr[r.level]??R.color.textTertiary}22`}],children:P(l,{style:[D.pillText,{color:Zr[r.level]??R.color.textSecondary}],children:r.level.toUpperCase()})}),P(l,{style:[D.rowTitle,D.mono],numberOfLines:3,children:r.message}),r.count>1?ce(l,{style:D.rowTrailing,children:["\xD7",r.count]}):null]},`${r.level}-${r.message}-${n}`)),P(lt,{paged:t})]})}function as({block:e}){return ce(W,{tone:"danger",testID:`buoy-block-crash-${e.id}`,children:[ce(s,{style:Y.crashHead,children:[P(Qa,{size:14,color:R.color.danger}),ce(l,{style:Y.crashTitle,children:["The app crashed",e.route?` on ${e.route}`:""]})]}),P(l,{style:[D.mono,Y.crashMsg],numberOfLines:4,selectable:true,children:e.message}),e.suspect?ce(l,{style:Y.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 ss({block:e}){let t=te(),o=t.supports?.minimize!==false;return ce(k,{testID:`buoy-block-peek-${e.id}`,disabled:!o,onPress:()=>void t.runAction({label:"Look",minimize:true},e.id),style:({pressed:r})=>[Y.peek,r&&{opacity:.7}],accessibilityRole:"button",accessibilityLabel:`${e.label}. Look at the app`,children:[P(l,{style:Y.peekText,children:e.label}),o?ce(s,{style:Y.peekLook,children:[P(Jr,{size:12,color:R.color.accent}),P(l,{style:Y.peekLookText,children:"Look"})]}):null]})}var Y=v.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:v.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"?Ga:"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 No}from"@buoy-gg/shared-ui/web";import{useEffect as cs,useRef as Xr,useState as Qe}from"react";import{AlertTriangle as ds,Check as en,ChevronDown as tn,ChevronRight as on,night as u,NightSegmented as us,RefreshCw as ps,Search as hs,X as gs}from"@buoy-gg/shared-ui/web";function fs(e,t,o){let r=o!==false&&e.length>=8,n=r?t.trim().toLowerCase():"",i=n?e.filter(h=>h.label.toLowerCase().includes(n)):e,a=r?i.slice(0,8):i;return{showSearch:r,items:a,hidden:i.length-a.length}}function bs(e,t){let o=e.filter(r=>t.includes(r.id));return{optionIds:o.map(r=>r.id),labels:o.map(r=>r.label)}}function rn(e,t){return e?.kind==="form"||e?.kind==="proposal"&&e.approved&&e.values?e.values:t}import{Fragment as mo,jsx as p,jsxs as T}from"react/jsx-runtime";var nn=e=>typeof e=="string"?e:e===void 0?"\u2014":JSON.stringify(e);function ys({block:e}){let t=te();return p(s,{style:c.chips,testID:`buoy-block-suggestions-${e.id}`,children:e.chips.slice(0,4).map(o=>p(k,{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 ms({block:e}){let t=te(),o=t.answered[e.id],r=!!o,[n,i]=Qe([]),a=o?.kind==="multi"?o.optionIds:n,h=g=>i(f=>f.includes(g)?f.filter(y=>y!==g):[...f,g]),d=n.length>=(e.min??1)&&(!e.max||n.length<=e.max);return T(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((g,f)=>{let y=a.includes(g.id);return T(k,{disabled:r,onPress:()=>h(g.id),style:[c.option,f>0&&D.rowDivider,r&&!y&&c.dim],accessibilityRole:"checkbox",accessibilityState:{checked:y},children:[p(s,{style:[c.checkbox,y&&c.checkboxOn],children:y?p(en,{size:11,color:u.color.onAccent}):null}),T(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(k,{testID:"buoy-block-multi-submit",disabled:!d,onPress:()=>t.answer({blockId:e.id,kind:"multi",...bs(e.options,n)}),style:[c.button,c.buttonPrimary,!d&&c.disabled],children:p(l,{style:c.buttonTextPrimary,children:e.submitLabel??`Use ${n.length||""}`.trim()})})})]})}function ks({block:e}){let t=te(),o=t.answered[e.id],[r,n]=Qe(""),[i,a]=Qe(false),h=o?.kind==="select"?o.label:null,{showSearch:d,items:g,hidden:f}=fs(e.options,r,e.searchable);return T(W,{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}):T(s,{style:c.selectBox,children:[T(k,{onPress:()=>a(y=>!y),style:c.selectField,accessibilityRole:"button",children:[p(l,{style:c.selectPlaceholder,children:i?"Choose\u2026":`${e.options.length} options`}),p(tn,{size:14,color:u.color.textSecondary})]}),i&&T(mo,{children:[d&&T(s,{style:c.search,children:[p(hs,{size:12,color:u.color.textSecondary}),p(rt,{style:c.searchInput,value:r,onChangeText:n,placeholder:"Search",placeholderTextColor:u.color.placeholder,autoCapitalize:"none",autoCorrect:false})]}),g.map((y,$)=>T(k,{onPress:()=>t.answer({blockId:e.id,kind:"select",optionId:y.id,label:y.label}),style:[c.option,$>0&&D.rowDivider],accessibilityRole:"button",children:[T(s,{style:c.flex,children:[p(l,{style:c.optionLabel,children:y.label}),y.detail?p(l,{style:c.optionDetail,children:y.detail}):null]}),p(on,{size:12,color:u.color.textTertiary})]},y.id)),f>0?T(l,{style:c.hint,children:[f," more \u2014 keep typing"]}):null]})]})]})}function ln({min:e,max:t,step:o=1,value:r,unit:n,onChange:i,disabled:a}){let h=Xr(0),d=t>e?(r-e)/(t-e)*100:0,g=V=>Math.min(t,Math.max(e,+(Math.round((V-e)/o)*o+e).toFixed(6))),f=V=>!a&&i(g(r+V*o)),y=V=>{if(a||h.current<=0)return;let re=Math.min(1,Math.max(0,V.nativeEvent.locationX/h.current));i(g(e+re*(t-e)))},$=V=>{h.current=V.nativeEvent.layout.width};return T(s,{style:c.sliderRow,children:[p(k,{disabled:a,onPress:()=>f(-1),style:c.stepBtn,accessibilityRole:"button",accessibilityLabel:"Decrease",children:p(l,{style:c.stepText,children:"\u2212"})}),p(k,{style:c.trackHit,onLayout:$,onPress:y,disabled:a,accessibilityRole:"adjustable",accessibilityValue:{min:e,max:t,now:r},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:V=>f(V.nativeEvent.actionName==="increment"?1:-1),children:T(s,{style:c.track,pointerEvents:"none",children:[p(s,{style:[c.fill,{width:`${d}%`}]}),p(s,{style:[c.thumb,{left:`${d}%`}]})]})}),p(k,{disabled:a,onPress:()=>f(1),style:c.stepBtn,accessibilityRole:"button",accessibilityLabel:"Increase",children:p(l,{style:c.stepText,children:"+"})}),T(l,{style:c.sliderValue,children:[r,n?` ${n}`:""]})]})}function xs({block:e}){let t=te(),o=t.answered[e.id],[r,n]=Qe(e.value??e.min);return T(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(ln,{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(k,{onPress:()=>t.answer({blockId:e.id,kind:"slider",value:r,unit:e.unit}),style:[c.button,c.buttonPrimary],children:T(l,{style:c.buttonTextPrimary,children:["Use ",r,e.unit?` ${e.unit}`:""]})})})]})}function ws({block:e}){let t=te(),o=t.answered[e.id],[r,n]=Qe(""),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 T(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)"}):T(mo,{children:[p(s,{style:[c.chips,c.pad],children:i.map(a=>p(k,{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))}),T(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:u.color.placeholder,keyboardType:"numbers-and-punctuation"}),p(k,{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 an({f:e,value:t,onChange:o,disabled:r}){return e.type==="toggle"?T(s,{style:c.fieldRow,children:[p(l,{style:c.fieldLabel,children:e.label}),p(Dr,{value:!!t,onValueChange:o,disabled:r,trackColor:{true:u.color.accent,false:u.color.fillTertiary},thumbColor:u.color.knob})]}):e.type==="select"?T(s,{style:c.fieldCol,children:[p(l,{style:c.fieldLabel,children:e.label}),p(s,{style:c.chips,children:e.options.map(n=>p(k,{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"?T(s,{style:c.fieldCol,children:[p(l,{style:c.fieldLabel,children:e.label}),p(ln,{min:e.min,max:e.max,step:e.step,unit:e.unit,value:typeof t=="number"?t:e.min,onChange:o,disabled:r})]}):T(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:u.color.placeholder,keyboardType:e.type==="number"?"numeric":"ascii-capable",secureTextEntry:e.type==="secret",autoCapitalize:"none",autoCorrect:false})]})}function sn(e){let[t,o]=Qe(()=>Object.fromEntries(e.map(r=>[r.key,r.value])));return{values:t,set:(r,n)=>o(i=>({...i,[r]:n}))}}function vs({block:e}){let t=te(),o=t.answered[e.id],{values:r,set:n}=sn(e.fields),i=rn(o,r);return T(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(a=>p(an,{f:a,value:i[a.key],onChange:h=>n(a.key,h),disabled:!!o},a.key))}),o?p(l,{style:c.decided,children:"Sent"}):p(s,{style:c.rowEnd,children:p(k,{onPress:()=>t.answer({blockId:e.id,kind:"form",values:i}),style:[c.button,c.buttonPrimary],children:p(l,{style:c.buttonTextPrimary,children:e.submitLabel??"Send"})})})]})}function Ss({block:e}){let t=te(),o=t.answered[e.id],{values:r,set:n}=sn(e.fields),i=rn(o,r),a=o?.kind==="proposal"?o.approved:null;return T(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(h=>p(an,{f:h,value:i[h.key],onChange:d=>n(h.key,d),disabled:!!o},h.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:a?"\u2713 Applied with these values":"\u2715 Not applied"}):T(mo,{children:[p(k,{onPress:()=>t.answer({blockId:e.id,kind:"proposal",approved:true,values:i}),style:[c.button,c.buttonPrimary],children:p(l,{style:c.buttonTextPrimary,children:e.approveLabel??"Apply"})}),p(k,{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 Ts({block:e}){let t=te(),[o,r]=Qe(null),n=t.actionState?.[`${e.id}:${e.verify?.label??"Verify"}`],i=e.verified||n==="done";return T(s,{style:c.claim,testID:`buoy-block-claim-${e.id}`,children:[T(l,{style:c.claimText,children:[e.text,e.sources.map((a,h)=>T(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]?T(s,{style:c.citeBox,children:[T(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?T(k,{onPress:()=>void t.runAction(e.verify,e.id),style:c.verifyBtn,accessibilityRole:"button",children:[p(ps,{size:11,color:u.color.accent}),p(l,{style:c.verifyText,children:n==="running"?"Checking\u2026":e.verify.label})]}):null]})}function Cs({block:e}){let[t,o]=Qe(!!e.open);return T(W,{testID:`buoy-block-details-${e.id}`,children:[T(k,{onPress:()=>o(r=>!r),style:D.row,accessibilityRole:"button",accessibilityState:{expanded:t},children:[p(l,{style:D.rowTitle,children:e.summary}),t?p(tn,{size:12,color:u.color.textTertiary}):p(on,{size:12,color:u.color.textTertiary})]}),t?p(l,{style:c.detailsBody,selectable:true,children:e.body}):null]})}function Is({block:e,renderNested:t}){let[o,r]=Qe(0),n=e.tabs.map((a,h)=>({key:String(h),label:a.label})),i=e.tabs[o];return T(s,{style:c.tabsWrap,testID:`buoy-block-tabs-${e.id}`,children:[p(us,{tabs:n,activeKey:String(o),onChange:a=>r(Number(a)),size:"sm"}),i&&t?t(i.block):null]})}var zs=10;function Ds({block:e}){let t=it(e.events,zs);return T(W,{title:e.title??"What happened",source:e.source,testID:`buoy-block-timeline-${e.id}`,children:[t.visible.map((o,r)=>T(s,{style:c.tlRow,children:[p(l,{style:c.tlAt,children:o.at}),T(s,{style:c.tlLine,children:[p(s,{style:[c.tlDot,{backgroundColor:Ct(o.tone??"muted")}]}),r<t.visible.length-1?p(s,{style:c.tlStem}):null]}),T(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 Rs({block:e}){let t=e.series.slice(-60),o=Math.max(1,...t),r=Math.min(...t,0),n=44;return T(W,{title:e.title,source:e.source,testID:`buoy-block-sparkline-${e.id}`,children:[T(s,{style:c.sparkHead,children:[T(l,{style:c.sparkCurrent,children:[e.current??t[t.length-1],e.unit?T(l,{style:c.sparkUnit,children:[" ",e.unit]}):null]}),e.live?p(cn,{}):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?u.color.accent:u.color.accentBorderStrong}]},a))}),e.label?p(l,{style:c.hint,children:e.label}):null]})}function cn(){let e=Xr(new pe.Value(1)).current;return cs(()=>{let t=pe.loop(pe.sequence([pe.timing(e,{toValue:.3,duration:700,useNativeDriver:true}),pe.timing(e,{toValue:1,duration:700,useNativeDriver:true})]));return t.start(),()=>t.stop()},[e]),T(s,{style:c.live,children:[p(pe.View,{style:[c.liveDot,{opacity:e}]}),p(l,{style:c.liveText,children:"LIVE"})]})}function $s({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 T(W,{title:e.title,source:e.source,testID:`buoy-block-compare-${e.id}`,children:[T(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 T(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:u.color.danger}],numberOfLines:2,children:nn(o[n])}),p(l,{style:[c.cmpVal,a&&{color:u.color.accent}],numberOfLines:2,children:nn(r[n])})]},n)})]})}function dn({c:e,id:t}){return T(mo,{children:[e.image?p(Tt,{testID:"buoy-internal-chat-image",source:{uri:e.image},style:c.cardImage,resizeMode:"contain",accessibilityLabel:e.title}):null,T(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=>T(s,{style:c.fact,children:[p(l,{style:c.factLabel,children:o.label}),p(l,{style:[c.factValue,o.tone&&{color:Ct(o.tone)}],children:o.value})]},o.label))]}),p(Ve,{actions:e.actions,blockId:t})]})}function As({block:e}){return p(W,{source:e.source,testID:`buoy-block-card-${e.id}`,children:p(dn,{c:e,id:e.id})})}function Bs({block:e}){return T(s,{testID:`buoy-block-cardcarousel-${e.id}`,children:[e.title?p(l,{style:c.carouselTitle,children:e.title}):null,p(Ge,{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(dn,{c:t,id:`${e.id}-${o}`})},`${t.title}-${o}`))})]})}function Ls({block:e}){let[t,o]=Qe(false);return T(W,{title:e.route?`Screen \xB7 ${e.route}`:"Screen",source:e.source,testID:`buoy-block-screenshot-${e.id}`,children:[p(k,{onPress:()=>o(r=>!r),accessibilityRole:"imagebutton",accessibilityLabel:e.caption??"Screenshot",children:p(Tt,{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 Os({block:e}){let t=e.steps.filter(o=>o.state==="done").length;return T(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)=>T(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(en,{size:10,color:u.color.onAccent}):o.state==="failed"?p(gs,{size:10,color:u.color.text}):p(l,{style:c.stepNum,children:r+1})}),T(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 Hs({block:e}){let t=te();return T(k,{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}),T(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 Ps({block:e}){let t=e.status==="failed"?u.color.danger:e.status==="done"?u.color.accent:u.color.info;return T(W,{testID:`buoy-block-task-${e.id}`,children:[T(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"?u.color.danger:e.tone==="warning"?u.color.warning:u.color.info;return T(s,{style:[c.banner,{borderColor:t,backgroundColor:`${t}1A`}],testID:`buoy-block-banner-${e.id}`,children:[p(ds,{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 Es({block:e}){return T(W,{testID:`buoy-block-file-${e.id}`,children:[T(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)})}),T(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 Vs({block:e}){let t=te(),o=t.answered[e.id];return T(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(k,{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=v.create({flex:{flex:1},pad:{paddingHorizontal:12,paddingBottom:8},muted:{color:u.color.textSecondary},dim:{opacity:.45},disabled:{opacity:.5},pressed:{opacity:.7},question:{color:u.color.text,fontSize:u.font.row,fontWeight:"600",lineHeight:20,paddingHorizontal:12,paddingTop:12,paddingBottom:8},hint:{color:u.color.textTertiary,fontSize:u.font.micro,paddingHorizontal:12,paddingBottom:10},decided:{color:u.color.textSecondary,fontSize:u.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:u.radius.row},buttonPrimary:{backgroundColor:u.color.accent},buttonPlate:{backgroundColor:u.color.button},buttonTextPrimary:{color:u.color.onAccent,fontSize:u.font.caption,fontWeight:"600"},buttonTextPlate:{color:u.color.text,fontSize:u.font.caption,fontWeight:"600"},chips:{flexDirection:"row",flexWrap:"wrap",gap:6},chip:{paddingHorizontal:12,paddingVertical:7,borderRadius:u.radius.chip,backgroundColor:u.color.fill,borderWidth:v.hairlineWidth,borderColor:u.color.border},chipOn:{backgroundColor:u.color.accentSoft,borderColor:u.color.accentBorderStrong},chipText:{color:u.color.text,fontSize:u.font.caption},chipTextOn:{color:u.color.accent,fontWeight:"600"},optionsBox:{marginHorizontal:8,marginBottom:8,borderRadius:u.radius.row,backgroundColor:u.color.surfaceElevated,overflow:"hidden"},option:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:10},optionLabel:{color:u.color.text,fontSize:u.font.body,fontWeight:"500"},optionDetail:{color:u.color.textSecondary,fontSize:u.font.caption},checkbox:{width:20,height:20,borderRadius:6,borderWidth:1.5,borderColor:u.color.textTertiary,alignItems:"center",justifyContent:"center"},checkboxOn:{backgroundColor:u.color.accent,borderColor:u.color.accent},selectBox:{marginHorizontal:12,marginBottom:12,borderRadius:u.radius.row,backgroundColor:u.color.surfaceElevated,overflow:"hidden"},selectField:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:11},selectPlaceholder:{color:u.color.textSecondary,fontSize:u.font.body},search:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:6,borderTopWidth:v.hairlineWidth,borderTopColor:u.color.separator},searchInput:{flex:1,color:u.color.text,fontSize:u.font.caption,paddingVertical:4},sliderRow:{flexDirection:"row",alignItems:"center",gap:8},stepBtn:{width:28,height:28,borderRadius:14,backgroundColor:u.color.fill,alignItems:"center",justifyContent:"center"},stepText:{color:u.color.text,fontSize:16,fontWeight:"600"},trackHit:{flex:1,height:36,justifyContent:"center"},track:{height:6,borderRadius:3,backgroundColor:u.color.fillTertiary,justifyContent:"center"},fill:{height:6,borderRadius:3,backgroundColor:u.color.accent},thumb:{position:"absolute",width:20,height:20,borderRadius:10,backgroundColor:u.color.knob,marginLeft:-10,shadowColor:"#000",shadowOpacity:.35,shadowRadius:3,shadowOffset:{width:0,height:1}},sliderValue:{width:64,textAlign:"right",color:u.color.text,fontSize:u.font.caption,fontWeight:"600"},inputRow:{flexDirection:"row",alignItems:"center",gap:8,paddingBottom:12},input:{flex:1,height:38,paddingHorizontal:12,borderRadius:u.radius.row,backgroundColor:u.color.surfaceElevated,color:u.color.text,fontSize:u.font.body},fieldRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:10,paddingVertical:6},fieldCol:{paddingVertical:6,gap:6},fieldLabel:{color:u.color.textSecondary,fontSize:u.font.caption,width:110},fieldInput:{flex:1,height:34,paddingHorizontal:10,borderRadius:u.radius.segment,backgroundColor:u.color.surfaceElevated,color:u.color.text,fontSize:u.font.caption},confirmTitle:{color:u.color.text,fontSize:u.font.row,fontWeight:"600",paddingHorizontal:12,paddingTop:12},confirmChange:{color:u.color.text,fontSize:u.font.body,lineHeight:19,paddingHorizontal:12,paddingTop:6,paddingBottom:6},consequence:{color:u.color.warning,fontSize:u.font.caption,paddingHorizontal:12},claim:{gap:6,paddingHorizontal:2},claimText:{color:u.color.text,fontSize:u.font.row,lineHeight:22},cite:{color:u.color.accent,fontSize:u.font.caption,fontWeight:"700"},verified:{color:u.color.accent,fontSize:u.font.caption,fontWeight:"600"},citeBox:{padding:10,borderRadius:u.radius.row,backgroundColor:u.color.surface,borderWidth:v.hairlineWidth,borderColor:u.color.border,gap:2},citeLabel:{color:u.color.text,fontSize:u.font.caption,fontWeight:"600"},citeDetail:{color:u.color.textSecondary,fontSize:u.font.caption,fontFamily:we.OS==="web"?No:"Menlo"},verifyBtn:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:5,paddingHorizontal:10,paddingVertical:5,borderRadius:u.radius.chip,backgroundColor:u.color.accentSoft},verifyText:{color:u.color.accent,fontSize:u.font.micro,fontWeight:"700"},detailsBody:{color:u.color.textSecondary,fontSize:u.font.caption,lineHeight:18,paddingHorizontal:12,paddingBottom:12},tabsWrap:{gap:8},tabBar:{flexDirection:"row",gap:6},tab:{paddingHorizontal:12,paddingVertical:6,borderRadius:u.radius.badge,backgroundColor:u.color.fill},tabOn:{backgroundColor:u.color.accentSoft},tabText:{color:u.color.textSecondary,fontSize:u.font.caption,fontWeight:"600"},tabTextOn:{color:u.color.accent},tlRow:{flexDirection:"row",gap:10,paddingHorizontal:12,paddingVertical:4,alignItems:"flex-start"},tlAt:{width:46,color:u.color.textTertiary,fontSize:u.font.micro,fontFamily:we.OS==="web"?No:"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:u.color.separator,marginTop:2},tlSource:{color:u.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.6},sparkHead:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingTop:8},sparkCurrent:{color:u.color.text,fontSize:22,fontWeight:"700"},sparkUnit:{color:u.color.textSecondary,fontSize:u.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:u.radius.badge,backgroundColor:u.color.dangerSoft},liveDot:{width:6,height:6,borderRadius:3,backgroundColor:u.color.danger},liveText:{color:u.color.danger,fontSize:9,fontWeight:"800",letterSpacing:.8},cmpHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,backgroundColor:u.color.fill,gap:8},cmpCol:{flex:1,color:u.color.textTertiary,fontSize:u.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},cmpRow:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"flex-start"},cmpDiff:{backgroundColor:u.color.fill},cmpKey:{width:90,color:u.color.textSecondary,fontSize:u.font.caption},cmpVal:{flex:1,color:u.color.text,fontSize:u.font.caption,fontFamily:we.OS==="web"?No:"Menlo"},cardImage:{width:"100%",height:140,backgroundColor:u.color.fill},cardText:{paddingHorizontal:12,paddingTop:10,paddingBottom:4,gap:4},cardTitle:{color:u.color.text,fontSize:u.font.row,fontWeight:"600"},fact:{flexDirection:"row",justifyContent:"space-between",gap:8},factLabel:{color:u.color.textSecondary,fontSize:u.font.caption},factValue:{color:u.color.text,fontSize:u.font.caption,fontWeight:"500"},carouselTitle:{color:u.color.text,fontSize:u.font.caption,fontWeight:"600",paddingBottom:8},carousel:{gap:8,paddingRight:8},carouselCard:{width:224,borderRadius:u.radius.card,borderWidth:v.hairlineWidth,borderColor:u.color.border,backgroundColor:u.color.surface,overflow:"hidden"},shot:{width:"100%",height:220,backgroundColor:u.color.fill},shotBig:{height:520},progress:{height:4,backgroundColor:u.color.fill,marginHorizontal:12,marginTop:6,marginBottom:8,borderRadius:2,overflow:"hidden"},progressFill:{height:4,backgroundColor:u.color.accent},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:u.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:u.color.accent},stepFailed:{backgroundColor:u.color.danger},stepRunning:{backgroundColor:u.color.info},stepNum:{color:u.color.text,fontSize:u.font.micro,fontWeight:"700"},checkpoint:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:7,borderRadius:u.radius.chip,backgroundColor:u.color.fill},cpFlag:{width:8,height:8,borderRadius:2,backgroundColor:u.color.info},cpText:{color:u.color.textSecondary,fontSize:u.font.caption},cpRestore:{color:u.color.accent,fontSize:u.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:u.radius.row,borderWidth:v.hairlineWidth},bannerText:{flex:1,fontSize:u.font.caption,fontWeight:"600"},fileIcon:{width:40,height:40,borderRadius:8,backgroundColor:u.color.fill,alignItems:"center",justifyContent:"center"},fileExt:{color:u.color.textSecondary,fontSize:10,fontWeight:"800"}});import{jsx as B}from"react/jsx-runtime";var Ns=class extends Hl{constructor(){super(...arguments);this.state={failed:false}}static getDerivedStateFromError(){return{failed:true}}render(){return this.state.failed?B(l,{style:js.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}},js=v.create({fallback:{color:$r.color.textTertiary,fontSize:$r.font.micro,fontStyle:"italic",paddingVertical:6}}),Ms=e=>B(ko,{block:e});function ko({block:e}){return B(Ns,{children:B(qs,{block:e})})}function qs({block:e}){switch(e.kind){case"choice":return B(sa,{block:e});case"confirm":return B(ca,{block:e});case"input":return B(da,{block:e});case"table":return B(La,{block:e});case"keyValue":return B(Oa,{block:e});case"list":return B(Pa,{block:e});case"imageGrid":return B(Ja,{block:e});case"diff":return B(Ea,{block:e});case"chart":return B(Va,{block:e});case"steps":return B(Na,{block:e});case"code":return B(Fa,{block:e});case"actions":return B(Ve,{actions:e.actions,blockId:e.id});case"notice":return B(_a,{block:e});case"finding":return B(Ua,{block:e});case"requestList":return B(es,{block:e});case"requestCard":return B(os,{block:e});case"ruleCard":return B(rs,{block:e});case"screenElements":return B(ns,{block:e});case"routeChips":return B(is,{block:e});case"logList":return B(ls,{block:e});case"crash":return B(as,{block:e});case"peek":return B(ss,{block:e});case"suggestions":return B(ys,{block:e});case"multiSelect":return B(ms,{block:e});case"select":return B(ks,{block:e});case"slider":return B(xs,{block:e});case"dateTime":return B(ws,{block:e});case"form":return B(vs,{block:e});case"proposal":return B(Ss,{block:e});case"claim":return B(Ts,{block:e});case"details":return B(Cs,{block:e});case"tabs":return B(Is,{block:e,renderNested:Ms});case"timeline":return B(Ds,{block:e});case"sparkline":return B(Rs,{block:e});case"compare":return B($s,{block:e});case"card":return B(As,{block:e});case"cardCarousel":return B(Bs,{block:e});case"screenshot":return B(Ls,{block:e});case"plan":return B(Os,{block:e});case"checkpoint":return B(Hs,{block:e});case"task":return B(Ps,{block:e});case"banner":return B(Ws,{block:e});case"file":return B(Es,{block:e});case"upload":return B(Vs,{block:e});default:return null}}import{monoFont as Fs}from"@buoy-gg/shared-ui/web";import{useEffect as _s,useState as zt}from"react";import{ChevronDown as Us,ChevronRight as Ks,Copy as Js,night as C,RefreshCw as Gs}from"@buoy-gg/shared-ui/web";import{jsx as N,jsxs as ze}from"react/jsx-runtime";function oo({label:e,onPress:t,children:o}){return N(k,{onPress:t,accessibilityRole:"button",accessibilityLabel:e,style:({pressed:r})=>[H.iconBtn,r&&H.pressed],children:o})}function Ys({id:e="chrome-actions"}){let t=te(),[o,r]=zt(null),n=i=>void t.runAction({label:i,send:`__chrome__:${i}`},e);return ze(s,{style:H.actions,testID:"chrome-message-actions",children:[N(oo,{label:"Copy",onPress:()=>n("copy"),children:N(Js,{size:13,color:C.color.textSecondary})}),N(oo,{label:"Retry",onPress:()=>n("retry"),children:N(Gs,{size:13,color:C.color.textSecondary})}),N(oo,{label:"Good answer",onPress:()=>{r("up"),n("thumbs up")},children:N(l,{style:[H.glyph,o==="up"&&H.glyphOn],children:"\u{1F44D}"})}),N(oo,{label:"Bad answer",onPress:()=>{r("down"),n("thumbs down")},children:N(l,{style:[H.glyph,o==="down"&&H.glyphOn],children:"\u{1F44E}"})}),N(oo,{label:"Export",onPress:()=>n("export transcript"),children:N(l,{style:H.textBtn,children:"Export"})})]})}function Qs({text:e,live:t}){let[o,r]=zt(false);return ze(s,{style:H.reasoning,testID:"chrome-reasoning",children:[ze(k,{onPress:()=>r(n=>!n),style:H.reasoningHead,accessibilityRole:"button",accessibilityState:{expanded:o},children:[t?N(Xt,{size:"small",color:C.color.textTertiary}):null,N(l,{style:H.reasoningTitle,children:t?"Working it out\u2026":"How I got here"}),o?N(Us,{size:12,color:C.color.textTertiary}):N(Ks,{size:12,color:C.color.textTertiary})]}),o?N(l,{style:H.reasoningBody,children:e}):null]})}function Zs({label:e}){let[t,o]=zt(0);return _s(()=>{let r=setInterval(()=>o(n=>n+250),250);return()=>clearInterval(r)},[]),ze(s,{style:H.elapsed,testID:"chrome-elapsed",children:[N(Xt,{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 Xs(){let[e,t]=zt(""),[o,r]=zt(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(k,{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(k,{disabled:!e.trim(),onPress:()=>{r(e.trim()),t("")},style:[H.queueBtn,!e.trim()&&{opacity:.5}],children:N(l,{style:H.queueBtnText,children:"Queue"})})]})]})}function ec({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 tc({at:e}){return N(l,{style:H.timestamp,children:e})}function oc({text:e}){let t=te(),[o,r]=zt(false),[n,i]=zt(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(k,{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(k,{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(k,{onPress:()=>r(false),style:H.editPlate,children:N(l,{style:H.editPlateText,children:"Cancel"})})]})]}):ze(k,{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=v.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:v.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"?Fs:"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:v.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:v.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:v.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:v.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 un}from"react";import{AlertTriangle as rc,ChevronDown as nc,night as E}from"@buoy-gg/shared-ui/web";import{jsx as ke,jsxs as ro}from"react/jsx-runtime";function pn({pending:e,onAnswer:t}){let[o,r]=un("");return ro(s,{style:Q.card,testID:"buoy-ask-buoy-approval",children:[ro(s,{style:Q.titleRow,children:[ke(rc,{size:14,color:E.color.warning}),ke(l,{style:Q.title,children:"Allow this change?"})]}),e.restored?ke(l,{style:Q.restored,testID:"buoy-ask-buoy-approval-restored",children:"Asked before the app restarted \u2014 check it still applies."}):null,ke(l,{style:Q.label,children:e.label}),ke(l,{style:Q.reason,children:e.reason}),e.description?ke(ic,{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:Q.note,returnKeyType:"done",blurOnSubmit:true}),ro(s,{style:Q.actions,children:[ke(k,{testID:"buoy-ask-buoy-approve",accessibilityRole:"button",onPress:()=>t({approved:true,reason:o}),style:({pressed:n})=>[Q.button,Q.approve,n&&Q.pressed],children:ke(l,{style:Q.approveText,children:"Allow"})}),e.restored?null:ke(k,{testID:"buoy-ask-buoy-approve-trust",accessibilityRole:"button",onPress:()=>t({approved:true,reason:o,trust:true}),style:({pressed:n})=>[Q.button,Q.trust,n&&Q.pressed],children:ke(l,{style:Q.trustText,children:"Allow for this chat"})}),ke(k,{testID:"buoy-ask-buoy-reject",accessibilityRole:"button",onPress:()=>t({approved:false,reason:o}),style:({pressed:n})=>[Q.button,Q.reject,n&&Q.pressed],children:ke(l,{style:Q.rejectText,children:"Not now"})})]})]})}function ic({text:e}){let[t,o]=un(false);return ro(s,{children:[ro(k,{testID:"buoy-ask-buoy-approval-details",accessibilityRole:"button",accessibilityState:{expanded:t},onPress:()=>o(r=>!r),style:({pressed:r})=>[Q.disclosure,r&&Q.pressed],hitSlop:6,children:[ke(s,{style:t?Q.chevronOpen:Q.chevronClosed,children:ke(nc,{size:12,color:E.color.textTertiary})}),ke(l,{style:Q.disclosureText,children:t?"Hide details":"Details"})]}),t?ke(Ge,{keyboardShouldPersistTaps:"handled",style:Q.detail,contentContainerStyle:Q.detailContent,nestedScrollEnabled:true,children:ke(l,{style:Q.description,children:e})}):null]})}var Q=v.create({card:{marginHorizontal:E.gutter,marginBottom:10,padding:E.cardPad,borderRadius:E.radius.card,borderWidth:v.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:v.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:v.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 lc}from"react";import{ChevronDown as ac,ChevronRight as sc,night as oe}from"@buoy-gg/shared-ui/web";import{isReversible as hn}from"@buoy-gg/agent-core/web";import{jsx as at,jsxs as yt}from"react/jsx-runtime";var gn=[];function fn(e){return lc(t=>e?.subscribe(t)??(()=>{}),()=>e?.list()??gn,()=>e?.list()??gn)}function bn({ledger:e,onUndoAll:t,expanded:o,onToggle:r}){let n=fn(e).filter(y=>!y.undoneAt),i=n.filter(y=>y.effect.kind!=="transient");if(i.length===0)return null;let a=i.filter(y=>hn(y.effect)),h=i.length-a.length,d=n.length-i.length,g=o?ac:sc,f=[a.length>0?`${a.length} undoable`:null,h>0?`${h} permanent`:null].filter(Boolean).join(" \xB7 ");return yt(s,{style:fe.wrap,children:[yt(k,{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(g,{size:12,color:oe.color.textSecondary})]}),o&&yt(s,{style:fe.panel,children:[yt(Ge,{style:fe.panelScroll,testID:"buoy-ask-buoy-changes-scroll",keyboardShouldPersistTaps:"handled",children:[i.map(y=>{let $=!hn(y.effect);return yt(s,{style:fe.row,children:[at(l,{style:fe.rowLabel,children:y.effect.label}),at(l,{style:[fe.rowTag,$&&fe.rowTagMuted],children:$?"Permanent":"Undoable"})]},y.id)}),d>0&&at(s,{style:fe.row,children:yt(l,{style:[fe.rowLabel,fe.rowLabelMuted],children:["Also did ",d," one-shot action",d===1?"":"s"," (navigation, taps) \u2014 nothing to undo."]})})]}),yt(s,{style:fe.footer,children:[a.length>0&&at(k,{testID:"buoy-ask-buoy-undo-all",accessibilityRole:"button",onPress:t,style:({pressed:y})=>[fe.undo,y&&fe.pressed],children:yt(l,{style:fe.undoText,children:["Undo ",a.length," change",a.length===1?"":"s"]})}),h>0&&at(l,{style:fe.footnote,children:"Permanent changes can't be undone from here."})]})]})]})}var fe=v.create({wrap:{borderBottomWidth:v.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:v.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 cc(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 dc,useEffect as yn,useRef as uc,useState as pc}from"react";import{night as Te}from"@buoy-gg/shared-ui/web";import{jsx as mt,jsxs as hc}from"react/jsx-runtime";var mn=40,gc=120,kn=we.OS==="ios"?10:6,fc=16;function xn({onSend:e,onStop:t,busy:o,draft:r,onDraftTaken:n,disabled:i,placeholder:a,focusKey:h,canFocus:d=true}){let[g,f]=pc(""),y=uc(null);yn(()=>{!h||!d||i||y.current?.focus()},[h,d,i]),yn(()=>{r&&(f(ue=>ue?`${ue} ${r}`:r),n?.())},[r,n]);let $=dc(()=>{let ue=g.trim();ue&&(f(""),e(ue))},[g,e]),V=g.trim().length>0&&!o&&!i,re=g.trim().length>0&&o&&!i;return hc(s,{style:xe.wrap,children:[mt(s,{style:[xe.field,i&&xe.fieldDisabled],children:mt(rt,{ref:y,testID:"buoy-ask-buoy-input",accessibilityLabel:"Message for Ask Buoy",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:Te.color.placeholder,multiline:true,editable:!i,keyboardType:"ascii-capable",autoCorrect:true,autoCapitalize:"sentences",blurOnSubmit:false,onSubmitEditing:$,returnKeyType:"send",maxLength:4e3})}),re&&mt(k,{testID:"buoy-ask-buoy-queue",accessibilityRole:"button",accessibilityLabel:"Queue message",onPress:$,style:({pressed:ue})=>[xe.button,xe.queue,ue&&xe.pressed],children:mt(l,{style:[xe.sendGlyph,{color:Te.color.accent}],children:"\u2191"})}),o?mt(k,{testID:"buoy-ask-buoy-stop",accessibilityRole:"button",accessibilityLabel:"Stop",onPress:t,style:({pressed:ue})=>[xe.button,xe.stop,ue&&xe.pressed],children:mt(s,{style:xe.stopGlyph})}):mt(k,{testID:"buoy-ask-buoy-send",accessibilityRole:"button",accessibilityLabel:"Send",disabled:!V,onPress:$,style:({pressed:ue})=>[xe.button,V?xe.sendOn:xe.sendOff,ue&&V&&xe.pressed],children:mt(l,{style:[xe.sendGlyph,{color:V?Te.color.onAccent:Te.color.textTertiary}],children:"\u2191"})})]})}var xe=v.create({wrap:{flexDirection:"row",alignItems:"flex-end",gap:8,paddingHorizontal:Te.gutter,paddingTop:10,paddingBottom:6,borderTopWidth:v.hairlineWidth,borderTopColor:Te.color.border,backgroundColor:Te.color.bg},field:{flex:1,minHeight:mn,justifyContent:"center",borderRadius:20,borderWidth:v.hairlineWidth,borderColor:Te.color.border,backgroundColor:Te.color.surfaceElevated},fieldDisabled:{opacity:.6},input:{maxHeight:gc,paddingHorizontal:fc,paddingTop:kn,paddingBottom:kn,color:Te.color.text,fontSize:Te.font.row},inputEmpty:{height:mn},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:v.hairlineWidth,borderColor:Te.color.accentBorderStrong},stopGlyph:{width:12,height:12,borderRadius:2,backgroundColor:Te.color.text},pressed:{opacity:.7}});import{useEffect as bc,useRef as wn}from"react";import{jsx as yc}from"react/jsx-runtime";function mc({children:e}){let t=wn(null),o=wn(new pe.Value(0)).current;return bc(()=>{if(we.OS!=="ios")return;let r=(h,d)=>{pe.timing(o,{toValue:h,duration:d.duration||250,easing:Ht.bezier(.17,.59,.4,.77),useNativeDriver:false}).start()},n=h=>{let d=t.current;d&&d.measureInWindow((g,f,y,$)=>{let V=f+$-h.endCoordinates.screenY;r(Math.max(0,V),h)})},i=h=>r(0,h),a=[Ao.addListener("keyboardWillChangeFrame",n),Ao.addListener("keyboardWillHide",i)];return()=>a.forEach(h=>h.remove())},[o]),yc(pe.View,{ref:t,style:[kc.flex,{paddingBottom:o}],children:e})}var kc=v.create({flex:{flex:1}});import{useEffect as vn,useState as Sn}from"react";import{Check as xc,Copy as wc,FileText as vc,ModalHeader as xo,night as Ze,Otto as Sc,Plus as Tc,SettingsSolid as Cc,realNow as jo}from"@buoy-gg/shared-ui/web";import{toolTitle as Ic}from"@buoy-gg/agent-core/web";var zc=e=>e.effect==="read"&&e.status==="ok";function Dc(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=>Ic(i.toolId)))];t.push({kind:"reads",id:o.map(i=>i.id).join("+"),calls:o,label:`Looked at ${Rc(n)}`,count:o.length})}o=[]}};for(let n of e){if(zc(n)){o.push(n);continue}r(),t.push({kind:"call",call:n})}return r(),t}function Rc(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 $c(e){let t=[];e.startedAt!==void 0&&e.endedAt!==void 0&&e.endedAt>=e.startedAt&&t.push(Tn(e.endedAt-e.startedAt));let o=e.toolCalls.length;if(o>0){t.push(`${o} action${o===1?"":"s"}`);let r=d=>e.toolCalls.filter(g=>g.status===d).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 Tn(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 Cn}from"react/jsx-runtime";var Ac=200,Bc=()=>"";function In({configured:e,busy:t,failed:o=false,activeLabel:r,awaitingApproval:n=false,startedAt:i=null,stopping:a=false,readOnly:h=false,toolCount:d,hasMessages:g,onBack:f,onReset:y,getTranscript:$,onOpenSettings:V,onTicket:re}){let{copied:ue,copy:ne}=bo($??Bc),[Ue,Me]=Sn(false);vn(()=>{t?r&&Me(true):Me(false)},[t,r]);let Pe=t&&!n&&i!==null,[Ke,tt]=Sn(()=>jo());vn(()=>{if(!Pe)return;tt(jo());let Ft=setInterval(()=>tt(jo()),1e3);return()=>clearInterval(Ft)},[Pe]);let pt=Pe&&i!==null?Tn(Ke-i):null,ht=e?o?"error":t?r||Ue?"robot":"thinking":"idle":"confused",We=a?"Stopping":r??"Thinking",ot=e?n?"Waiting for you":t?pt?`${We} \xB7 ${pt}`:`${We}\u2026`:h?`Read only${d>0?` \xB7 ${d} tool${d===1?"":"s"}`:""}`:d>0?`Ready \xB7 ${d} tool${d===1?"":"s"} available`:"Ready":"Not set up in this app";return Cn(xo,{children:[f?Be(xo.Navigation,{onBack:f}):null,Be(s,{style:kt.otto,testID:"buoy-ask-buoy-otto",children:Be(Sc,{state:ht,pixelSize:2,tickMs:Ac,water:false})}),Be(xo.Content,{title:"Ask Buoy",subtitle:ot,testID:"buoy-ask-buoy-title"}),Cn(xo.Actions,{children:[re?Be(Zt,{testID:"buoy-ask-buoy-ticket",accessibilityRole:"button",accessibilityLabel:"Summarize for a ticket",disabled:!g||t,onPress:re,style:[kt.actionBtn,(!g||t)&&kt.actionBtnDisabled],children:Be(vc,{size:14,color:g&&!t?Ze.color.textSecondary:Ze.color.textTertiary})}):null,$?Be(Zt,{testID:"buoy-ask-buoy-copy-chat",accessibilityRole:"button",accessibilityLabel:ue?"Conversation copied":"Copy conversation",disabled:!g,onPress:ne,style:[kt.actionBtn,!g&&kt.actionBtnDisabled],children:ue?Be(xc,{size:14,color:Ze.color.accent}):Be(wc,{size:14,color:g?Ze.color.textSecondary:Ze.color.textTertiary})}):null,V?Be(Zt,{testID:"buoy-ask-buoy-settings",accessibilityRole:"button",accessibilityLabel:"Settings",onPress:V,style:kt.actionBtn,children:Be(Cc,{size:14,color:Ze.color.textSecondary})}):null,Be(Zt,{testID:"buoy-ask-buoy-reset",accessibilityRole:"button",accessibilityLabel:"New conversation",disabled:!g,onPress:y,style:[kt.actionBtn,!g&&kt.actionBtnDisabled],children:Be(Tc,{size:14,color:g?Ze.color.textSecondary:Ze.color.textTertiary})})]})]})}var kt=v.create({otto:{marginRight:8,justifyContent:"center"},actionBtn:{width:32,height:32,borderRadius:8,backgroundColor:Ze.color.buttonSurface,borderWidth:1,borderColor:Ze.color.border,alignItems:"center",justifyContent:"center"},actionBtnDisabled:{opacity:.55}});import{useCallback as Lc,useEffect as Oc,useState as Hc}from"react";import{AlertTriangle as Pc,night as de,ToggleRow as Mo}from"@buoy-gg/shared-ui/web";import{useSyncExternalStore as Wc}from"react";import{definePersistedSetting as Ec,devToolsStorageKeys as Vc}from"@buoy-gg/shared-ui/web";var qo={showThinking:false,bypassApprovals:false,readOnly:false,hostedNoticeSeen:false,claudeNoticeSeen:false},Fo=Ec(`${Vc.base}_ask_buoy_settings`,qo,{sanitize:e=>({showThinking:e.showThinking===true,bypassApprovals:e.bypassApprovals===true,readOnly:e.readOnly===true,hostedNoticeSeen:e.hostedNoticeSeen===true,claudeNoticeSeen:e.claudeNoticeSeen===true})}),Dt=qo,_o=false,Uo=new Set;function zn(){for(let e of Uo)try{e()}catch{}}var st={get:()=>Dt,subscribe(e){return Uo.add(e),_o||(_o=true,Fo.load().then(t=>{Dt=t,zn()})),()=>Uo.delete(e)},set(e,t){Dt[e]!==t&&(Dt={...Dt,[e]:t},zn(),Fo.save(Dt))},reset(){Dt=qo,_o=false,Fo.clear()}};function Nt(){return Wc(st.subscribe,st.get,st.get)}import{useSyncExternalStore as Nc}from"react";import{definePersistedSetting as jc,devToolsStorageKeys as Mc,subscribeStorageWrites as qc}from"@buoy-gg/shared-ui/web";var Ko="claude",Dn=Mc.askBuoy.model(),Rn=e=>e==="luna"?"luna":"claude",$n=jc(Dn,Ko,{sanitize:Rn}),wo=Ko,An=false,Jo=new Set;function Fc(){for(let e of Jo)try{e()}catch{}}function Go(e){e!==wo&&(wo=e,Fc())}var vo={get:()=>wo,subscribe(e){return Jo.add(e),An||(An=true,$n.load().then(Go),qc((t,o)=>{if(t===Dn)try{Go(Rn(o===null?Ko:JSON.parse(o)))}catch{}})),()=>Jo.delete(e)},set(e){e!==wo&&(Go(e),$n.save(e))}};function Bn(){return Nc(vo.subscribe,vo.get,vo.get)}import{idFactory as Ln}from"@buoy-gg/agent-core/web";import{realNow as no}from"@buoy-gg/shared-ui/web";import{persistentStorage as Yo,devToolsStorageKeys as _c}from"@buoy-gg/shared-ui/web";import{dispatchToolAction as On}from"@buoy-gg/shared-ui/web";var Uc=[{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 io(e){if(!e)return e;let t=e;for(let{re:o,label:r}of Uc)t=t.replace(o,r);return t}var Qo=`${_c.base}_ask_buoy_transcript`,Zo=1,Hn=60,Kc=256e3,Jc="[not kept across a restart \u2014 read it again if you need it]";function ct(e){return e&&io(e)}function Gc(e){let t=e.streaming===true;return{...e,text:ct(e.text),streaming:false,reasoning:e.reasoning?.map(o=>({...o,text:ct(o.text)})),toolCalls:e.toolCalls.map(o=>{let r=o.params?ct(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 Yc(e){return e.map(t=>t.role==="tool-results"?{...t,results:t.results.map(o=>({...o,content:Jc}))}:t.role==="assistant"?{...t,text:ct(t.text)}:{...t,text:ct(t.text)})}function Pn(e){let t={...e,messages:e.messages.slice(-Hn),history:e.history.slice(-Hn*2)},o=JSON.stringify(t);for(;o.length>Kc&&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 Qc(e){if(!e)return null;let t=e.params;if(!t)return null;let o;try{o=JSON.stringify(t)}catch{return null}return io(o)!==o?null:{id:e.id,toolId:e.toolId,action:e.action,label:ct(e.label),description:e.description?ct(e.description):void 0,reason:ct(e.reason),params:t,targetDigest:e.targetDigest}}function Zc(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 Wn(e){if(!e?.length)return;let t=e.filter(o=>{try{let r=JSON.stringify(o);return io(r)===r}catch{return false}});return t.length?t:void 0}function Xc(e){return Pn({v:Zo,savedAt:Date.now(),messages:e.messages.map(Gc),history:Yc(e.history),answers:e.answers,usage:e.usage,pending:Qc(e.pending),ledger:Wn(e.ledger),queued:e.queued?.length?e.queued.map(t=>({id:t.id,text:ct(t.text)})):void 0})}function ed(e){if(!e)return null;try{let t=JSON.parse(e);return t?.v!==Zo||!Array.isArray(t.messages)||t.messages.length===0?null:{v:Zo,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:Zc(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}}var En="The app reloaded. Please finish what you were doing.",td='The app reloaded during my last step. Say "continue" to finish.',od=2*6e4;function rd(e,t){let o=e.messages[e.messages.length-1];if(o?.role!=="assistant"||!o.reloadedApp)return null;let r=[...e.messages].reverse().find(n=>n.role==="user");return t-e.savedAt<od&&r?.text!==En?"resume":"note"}async function Vn(){try{return ed(await Yo.getItem(Qo))}catch{return null}}var So=0;async function Nn(e){So+=1;try{await Yo.setItem(Qo,JSON.stringify(e))}catch{}}async function nd(e){let t=So,o=await Vn();!o||t!==So||await Nn(Pn({...o,ledger:Wn(e)}))}async function id(){So+=1;try{await Yo.removeItem(Qo)}catch{}}var To=Ln("m"),jn=400;function ld(e){if(!(!e||Object.keys(e).length===0))try{let t=JSON.stringify(e);return t.length>jn?`${t.slice(0,jn)}\u2026`:t}catch{return}}var ad=Ln("q"),O={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:{}},Mn=null,qn=null,Xo=new Set,er=null,Fn=null,tr=null;function Z(e){O={...O,...e};for(let t of Xo)try{t()}catch{}}var b={getState:()=>O,subscribe(e){return Xo.add(e),()=>Xo.delete(e)},setLedger(e){e!==er&&(Fn?.(),er=e,Fn=e?e.subscribe(()=>void nd(e.list())):null)},getLedger(){return er},holdSession(e,t){tr={session:e,signature:t}},getHeldSession(){return tr},setReporter(e){Mn=e},getReporter(){return Mn},setUsageReader(e){qn=e},getUsageReader(){return qn},setNotice(e){Z({notice:e})},setConfigured(e){e!==O.configured&&Z({configured:e})},setClaudeOut(e){O.claudeOut!==e&&Z({claudeOut:e})},setMeta(e){Object.keys(e).every(t=>O.meta[t]===e[t])||Z({meta:{...O.meta,...e}})},addUser(e){Z({messages:[...O.messages,{id:To(),role:"user",text:e,toolCalls:[],blocks:[]}],busy:true})},beginTurn(){Z({busy:true})},enqueue(e){let t={id:ad(),text:e};return Z({queued:[...O.queued,t]}),t},removeQueued(e){O.queued.some(t=>t.id===e)&&Z({queued:O.queued.filter(t=>t.id!==e)})},shiftQueued(){let[e,...t]=O.queued;if(e)return Z({queued:t}),e},takeQueuedToDraft(e){let t=O.queued.find(o=>o.id===e);t&&Z({queued:O.queued.filter(o=>o.id!==e),draft:t.text})},requestStop(){!O.busy||O.stopping||Z({stopping:true})},clearDraft(){O.draft!==null&&Z({draft:null})},removeMessage(e){Z({messages:O.messages.filter(t=>t.id!==e)})},recordAnswer(e){Z({answers:{...O.answers,[e.blockId]:e},awaitingBlockId:O.awaitingBlockId===e.blockId?null:O.awaitingBlockId})},setActionState(e,t){let o={...O.actionState};t===null?delete o[e]:o[e]=t,Z({actionState:o})},startAssistant(){let e=To();return Z({messages:[...O.messages,{id:e,role:"assistant",text:"",toolCalls:[],blocks:[],streaming:true,startedAt:no()}]}),e},applyEvent(e,t){if(t.type==="history-trimmed"){let r=O.messages.findIndex(a=>a.id===e),n={id:To(),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:no()},i=[...O.messages];i.splice(r<0?i.length:r,0,n),Z({messages:i});return}let o=O.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})`:t.reason==="network"?"Connection dropped \u2014 trying again":"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:Zc(t.params),effect:t.effect,startedAt:to()}]};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??O.credits?.left??null,resetAt:t.frame.credits_reset??O.credits?.resetAt??null,pending:t.frame.pending===true}}:{},...t.type==="usage"?{usage:{input:O.usage.input+t.input,output:O.usage.output+t.output,requests:O.usage.requests+1}}:{}})},markStopped(e){X({messages:O.messages.map(t=>t.id===e?{...t,stopped:true}:t)})},finishAssistant(e){X({messages:O.messages.map(t=>t.id===e?{...t,streaming:false,endedAt:to()}:t),busy:false,stopping:false})},askApproval(e){return new Promise(t=>{X({pending:{...e,resolve:t}})})},answerApproval(e){let t=O.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&&!O.trusted.some(i=>i.key===n)?{trusted:[...O.trusted,{key:n,label:t.label}]}:{}}),t?.resolve(e)},untrust(e){Zo?.session.untrust(e),X({trusted:O.trusted.filter(t=>t.key!==e)})},restorePending(e){return O.pending||O.busy?false:(X({pending:{...e,restored:true,resolve:()=>{}}}),true)},addNote(e){X({messages:[...O.messages,{id:wo(),role:"assistant",text:e,toolCalls:[],blocks:[],endedAt:to()}]})},hydrate(e){return O.messages.length>0||O.busy?false:(X({messages:e.messages.map(t=>({...t,restored:true})),answers:e.answers,usage:e.usage,queued:e.queued??[]}),true)},reset(){O.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 qn(e){return e.pending?"awaitingApproval":e.busy?e.stopping?"stopping":"running":e.awaitingBlockId?"awaitingAnswer":"idle"}function Fn(e){let t=qn(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 td,hasAccountAccess as ro,subscribeAccountAccess as od}from"@buoy-gg/shared-ui/web";import{useCallback as De,useEffect as dt,useMemo as _n,useRef as ut,useState as rd,useSyncExternalStore as nd}from"react";import{dispatchToolAction as Un,listSnapshotToolIds as id,listToolActions as ld,readToolSnapshot as ad,waitForToolRegistry as Kn}from"@buoy-gg/shared-ui/web";import{answerToText as Gn,CATALOG as er,createAskBuoySession as sd,readTargetDigest as cd,runGatedAction as Jn,SNAPSHOT_ACTION as Yn}from"@buoy-gg/agent-core/web";function tr(){b.getHeldSession()?.session.reset(),b.reset(),Xc()}async function Qn(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}:(tr(),{cleared:true,reverted:o.reverted,failed:[]})}return tr(),{cleared:true,reverted:0,failed:[]}}var Xn="claude-haiku-5-5";function dd(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 no=typeof co<"u"&&!co;function ud(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 Zn(){try{let e=ld();for(let t of id())e[t]||(e[t]=[]),e[t].includes(Yn)||(e[t]=[Yn,...e[t]]);return e}catch{return{}}}var pd=600;function vo(){return nd(b.subscribe,b.getState,b.getState)}function ei(e){let t=vo(),o=An(),r=_n(()=>dd(e,o,t.claudeOut),[e,o,t.claudeOut]),n=ut(r);(t.messages.length===0||!n.current)&&(n.current=r);let i=n.current,a=ut(e);a.current=e;let g=!!e?.hostedModels?.claude,d=t.messages.length===0;dt(()=>{let T=a.current?.readUsage;if(!g||o!=="claude"||!d||!T)return;let j=true;return T().then(F=>{j&&F.claude&&b.setClaudeOut(!F.claude.available)}).catch(()=>{}),()=>{j=false}},[g,o,d]);let h=td()(),f=ut(h);f.current=h;let m=De((...T)=>!ro()||!f.current?Promise.reject(new Error("Ask Buoy requires Pro access.")):Un(...T),[]),L=ut(null),V=ut(false),ee=ut(null),ce=ut(i);ce.current=i;let pe=!!i?.endpoint&&!!i?.model,Pe=i?.persistTranscript!==false,{bypassApprovals:qe,readOnly:We}=Pt(),Xe=ut(qe);Xe.current=qe;let Ze=ut(We);Ze.current=We;let et=De(()=>Ze.current?{...i?.policy??{},readOnly:true}:i?.policy??{},[i]),[Vt,tt]=rd(0);dt(()=>{let T=false;return Kn().then(()=>{T||tt(j=>j+1)}),()=>{T=true}},[]);let Ee=_n(()=>Zn(),[Vt]),Nt=Object.keys(Ee).sort().join(",");dt(()=>{if(b.setConfigured(pe),b.setMeta({model:i?.model,protocol:i?.protocol??(i?"anthropic":void 0),appName:i?.appName,platform:we.OS,build:no?"release":"development"}),!pe||!i){L.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 T=i.protocol??"anthropic";no&&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."):T==="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.'):T==="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 j=[i.endpoint,i.protocol??"anthropic",i.model].join("|"),F=b.getHeldSession();if(F&&F.signature===j){L.current=F.session,F.session.setAvailableActions(Ee),F.session.setApprovalBypass(Xe.current),F.session.setReadOnly(Ze.current),b.setLedger(F.session.ledger);return}let de=sd({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 ao=(Q==="fallback"?i.hostedFallback?.model:i.model)===Xn;b.setMeta({model:Q==="fallback"?i.hostedFallback?.model:i.model}),Q==="fallback"?(ao||b.setClaudeOut(true),b.setNotice(ao?"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?[...er,...i.tools]:void 0,dispatch:m,readSnapshot:ad,availableActions:Ee,policy:i.policy,context:i.context,isRelease:no,appName:i.appName,platform:we.OS,requestApproval:Q=>b.askApproval(Q)});L.current=de,de.setApprovalBypass(Xe.current),de.setReadOnly(Ze.current),b.holdSession(de,j),b.setLedger(de.ledger);let $e=false;return Kn().then(Q=>{Q&&!$e&&de.prime()}),Pe&&!V.current&&(V.current=true,Wn().then(Q=>{!Q||!b.hydrate({messages:Q.messages,answers:Q.answers,usage:Q.usage,queued:Q.queued})||(L.current?.restore(Q.history),Q.ledger?.length&&L.current?.ledger.restore(Q.ledger),Q.pending&&b.restorePending(Q.pending))})),()=>{$e=true}},[pe,i,Ee,Nt,Pe]),dt(()=>{L.current?.setApprovalBypass(qe)},[qe]),dt(()=>{L.current?.setReadOnly(We)},[We]);let jt=t.messages,ht=t.answers,Mt=t.usage,Ce=t.busy,gt=t.pending,qt=t.queued;dt(()=>{if(!Pe||jt.length===0)return;let T=()=>{En(Jc({messages:jt,history:L.current?.messages??[],answers:ht,usage:Mt,pending:gt,ledger:b.getLedger()?.list(),queued:qt}))};if(!Ce||gt){T();return}let j=setTimeout(T,pd);return()=>clearTimeout(j)},[Pe,Ce,jt,ht,Mt,gt,qt]);let Dt=De(T=>{if(!ro()||!f.current)return;let j=L.current;if(!j)return;b.beginTurn();let F=b.startAssistant(),de=new AbortController;ee.current=de,j.setAvailableActions(Zn());let $e=ce.current?.onEvent;(async()=>{try{for await(let Q of j.send(T,de.signal))if(b.applyEvent(F,Q),$e)try{$e(Q)}catch{}}catch(Q){de.signal.aborted||b.applyEvent(F,{type:"error",message:Q instanceof Error?Q.message:"Something went wrong talking to your AI endpoint."})}finally{de.signal.aborted&&b.markStopped(F),b.finishAssistant(F),ee.current=null}})()},[]),ot=De(T=>{if(!ro()||!f.current)return;let j=T.trim();if(!L.current||!j)return;if(b.getState().busy){b.enqueue(j);return}let F=b.getState().awaitingBlockId;F&&b.recordAnswer({blockId:F,kind:"skipped"}),b.addUser(j),Dt(j)},[Dt]),To=De(()=>{let{messages:T,busy:j}=b.getState();if(j||!L.current)return;let F=[...T].reverse().find(de=>de.role==="user");F&&Dt(F.text)},[Dt]),ft=De(()=>{b.requestStop(),b.getState().pending&&b.answerApproval(false),ee.current?.abort(),ee.current=null},[]);dt(()=>{let T=od(()=>{ro()||ft()});return()=>{T(),ft()}},[ft]),dt(()=>{h||ft()},[h,ft]),dt(()=>{if(t.queued.length===0||qn(t)!=="idle"||Fn(t)!==null)return;let T=b.shiftQueued();T&&ot(T.text)},[t,ot]);let Co=De(T=>b.takeQueuedToDraft(T),[]),Io=De(T=>b.removeQueued(T),[]),kt=De(()=>{ee.current?.abort(),ee.current=null,tr()},[]),Ft=De(()=>Qn({dispatch:Un,undoFirst:true}),[]),_t=De(async T=>{let j=b.getLedger();if(!j){b.setNotice(`${T.label} couldn't run \u2014 no active Ask Buoy session.`);return}let F=i?.tools?.length?[...er,...i.tools]:void 0;if(T.targetDigest){let $e=await cd({toolId:T.toolId,action:T.action,params:T.params??{},dispatch:m,catalog:F});if($e!==void 0&&$e!==T.targetDigest){b.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 de=await Jn({toolId:T.toolId,action:T.action,params:T.params??{},dispatch:m,ledger:j,policy:et(),isRelease:no,catalog:F});de.ok?b.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.`):b.setNotice(`${T.label} failed \u2014 ${de.error}`)},[i,et]),Rt=De(T=>{let j=b.getState().pending,F=typeof T=="boolean"?T:T.approved;if(b.answerApproval(T),!!j?.restored){if(!F){b.addNote(`Skipped \u201C${j.label}\u201D. Nothing was changed.`);return}_t(j)}},[_t]),lo=De(T=>{b.recordAnswer(T);let j=ud(T.blockId);ot(j?`${j} \u2014 ${Gn(T)}`:Gn(T))},[ot]),zo=De(async(T,j)=>{if(!ro()||!f.current){b.setNotice("Ask Buoy requires Pro access.");return}if(T.send){ot(T.send);return}if(!T.dispatch)return;let F=`${j}:${T.label}`,de=b.getLedger();if(!de){b.setNotice(`${T.label} failed \u2014 no active Ask Buoy session.`);return}b.setActionState(F,"running");let $e=await Jn({toolId:T.dispatch.toolId,action:T.dispatch.action,params:T.dispatch.params??{},dispatch:m,ledger:de,policy:et(),isRelease:no,catalog:i?.tools?.length?[...er,...i.tools]:void 0});$e.ok?b.setActionState(F,"done"):(b.setActionState(F,"failed"),b.setNotice(`${T.label} failed \u2014 ${$e.error}`))},[ot,i,et]);return{state:t,send:ot,stop:ft,reset:kt,undoThenReset:Ft,approve:Rt,retry:To,answer:lo,runAction:zo,editQueued:Co,removeQueued:Io,configured:pe,toolCount:Object.keys(Ee).length,availableToolIds:Object.keys(Ee)}}import{Fragment as hd,jsx as Z,jsxs as Me}from"react/jsx-runtime";function ti(){let e=Pt(),t=vo().trusted;return Me(Ke,{style:U.scroll,contentContainerStyle:U.content,testID:"buoy-ask-buoy-settings",children:[Z(fd,{}),Z(yd,{}),Z(l,{style:U.section,children:"CHAT"}),Z(No,{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(No,{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(No,{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?Me(s,{style:U.warning,testID:"buoy-ask-buoy-bypass-warning",children:[Z(Bc,{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?Me(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=>Me(s,{style:U.trustedRow,children:[Z(l,{style:U.trustedLabel,numberOfLines:2,children:o.label}),Z(x,{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 gd(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 fd(){let e=b.getUsageReader(),[t,o]=Ac({kind:"loading"}),r=Rc(()=>{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 $c(r,[r]),e?Me(s,{testID:"buoy-ask-buoy-credits",children:[Z(l,{style:U.section,children:"HOSTED AI CREDITS"}),Me(s,{style:U.trustedRow,children:[Z(s,{style:{flex:1,gap:2},children:t.kind==="ok"?Me(hd,{children:[Me(l,{style:U.trustedLabel,children:[t.usage.creditsLeft.toLocaleString()," of ",t.usage.grantCredits.toLocaleString()," credits left"]}),Me(l,{style:U.note,children:[t.usage.resetAt?`Resets ${gd(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(x,{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 bd=[{id:"claude",label:"Claude Haiku 5.5",note:"The default. Answers faster."},{id:"luna",label:"GPT-6 Luna",note:"Uses fewer credits."}];function yd(){let e=An(),{claudeOut:t}=vo();return b.getUsageReader()?Me(s,{testID:"buoy-ask-buoy-model",style:{gap:6},children:[Z(l,{style:U.section,children:"MODEL"}),bd.map(o=>{let r=e===o.id;return Me(x,{testID:`buoy-ask-buoy-model-${o.id}`,accessibilityRole:"radio",accessibilityState:{checked:r},onPress:()=>xo.set(o.id),style:({pressed:n})=>[U.trustedRow,r&&U.picked,n&&{opacity:.7}],children:[Me(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=v.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:v.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:v.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 md}from"@buoy-gg/shared-ui/web";import{ChevronRight as xd,night as Se,NightSectionLabel as kd}from"@buoy-gg/shared-ui/web";var wd=[{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"}],vd=4;function Sd(e){let t=e.availableToolIds.length>0;return wd.filter(o=>o.write&&e.readOnly||o.devOnly&&e.isRelease?false:o.needs?t&&e.availableToolIds.includes(o.needs):true).slice(0,vd).map(o=>o.text)}import{jsx as Qe,jsxs as io}from"react/jsx-runtime";var oi=typeof co<"u"&&!co;function Td({configured:e,onPick:t,availableToolIds:o=[],readOnly:r=false}){let n=Sd({availableToolIds:o,readOnly:r,isRelease:oi});return e?io(s,{style:Re.wrap,testID:"buoy-ask-buoy-empty",children:[Qe(l,{style:Re.title,children:"Ask about this app"}),Qe(l,{style:Re.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:Re.buildLine,testID:"buoy-ask-buoy-build-line",children:oi?"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."}),io(s,{style:Re.group,children:[Qe(kd,{children:"Try asking"}),Qe(s,{style:Re.card,children:n.map((i,a)=>Qe(Cd,{text:i,onPick:t,last:a===n.length-1},i))})]})]}):io(s,{style:Re.wrap,testID:"buoy-ask-buoy-unconfigured",children:[Qe(l,{style:Re.title,children:"Not set up yet"}),io(l,{style:Re.body,children:["Ask Buoy talks to your own company's AI endpoint. Nothing goes to Buoy. A developer needs to add the ",Qe(l,{style:Re.code,children:"askBuoy"})," setting where the app sets up Buoy. It needs your team's endpoint and model."]})]})}function Cd({text:e,onPick:t,last:o}){return io(x,{testID:`buoy-ask-buoy-suggestion-${e.slice(0,12)}`,accessibilityRole:"button",onPress:()=>t(e),style:({pressed:r})=>[Re.row,!o&&Re.rowDivider,r&&Re.pressed],children:[Qe(l,{style:Re.rowText,children:e}),Qe(xd,{size:14,color:Se.color.textTertiary})]})}var Re=v.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"?md:"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:v.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:v.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 Id,useCallback as It,useEffect as zd,useRef as or,useState as rr}from"react";import{AlertTriangle as nr,Check as ri,ChevronDown as ni,ChevronRight as ii,Copy as Dd,night as w,X as Rd}from"@buoy-gg/shared-ui/web";import{toolTitle as $d}from"@buoy-gg/agent-core/web";import{isAskBlock as Ad}from"@buoy-gg/agent-core/web";function Bd({block:e,forToolCallId:t}){if(!t)return false;let o="source"in e?e.source:void 0;return o==="live"||o==="mocked"}function Ld(e,t){let o=new Set(t),r=new Map,n=[],i=[];for(let a of e){if(Ad(a.block)){i.push(a);continue}if(Bd(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 li}from"react";import{Activity as Od,ChevronDown as Hd,ChevronRight as Pd,night as te}from"@buoy-gg/shared-ui/web";function ir(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 ai(e){return(e.reasoning?.length??0)>0||e.toolCalls.length>0}var Wd=e=>e.status==="ok"?e.summary||"done":e.status==="running"?"running":`${e.status}${e.summary?` \u2014 ${e.summary}`:""}`;function si(e,t=" "){let o=[];for(let r of ir(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 ${Wd(i)}`),i.params&&o.push(`${t} ${i.params}`)}return o}import{Fragment as Ed,jsx as Le,jsxs as pt}from"react/jsx-runtime";function Vd({n:e,call:t}){let[o,r]=li(false),n=t.status==="failed"||t.status==="refused";return pt(x,{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(Ed,{children:[Le(l,{style:be.detailLabel,children:"RETURNED"}),Le(l,{style:be.code,selectable:true,children:t.result})]}):null]}):null]})}function ci({message:e}){let[t,o]=li(false);if(!ai(e))return null;let r=ir(e),n=r.filter(d=>d.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(x,{testID:"buoy-ask-buoy-thinking-toggle",onPress:()=>o(d=>!d),accessibilityRole:"button",accessibilityLabel:t?"Hide agent thinking":"Show agent thinking",accessibilityState:{expanded:t},style:be.head,children:[Le(Od,{size:12,color:te.color.textTertiary}),Le(l,{style:be.headText,children:g}),t?Le(Hd,{size:12,color:te.color.textTertiary}):Le(Pd,{size:12,color:te.color.textTertiary})]}),t?pt(s,{style:be.body,children:[r.map((d,h)=>d.kind==="thought"?Le(l,{style:be.thought,selectable:true,children:d.text.trim()},`t${h}`):Le(Vd,{n:d.n,call:d.call},d.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=v.create({wrap:{marginTop:8,borderRadius:te.radius.badge,borderWidth:v.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:v.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 Nd,useRef as jd}from"react";import{night as Md}from"@buoy-gg/shared-ui/web";import{jsx as di}from"react/jsx-runtime";function qd(){let e=jd([0,1,2].map(()=>new ue.Value(.25))).current;return Nd(()=>{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]),di(s,{style:ui.wrap,testID:"buoy-ask-buoy-typing",accessibilityLabel:"Thinking",children:e.map((t,o)=>di(ue.View,{style:[ui.dot,{opacity:t}]},o))})}var ui=v.create({wrap:{flexDirection:"row",alignItems:"center",gap:5,paddingVertical:8,paddingHorizontal:2},dot:{width:7,height:7,borderRadius:4,backgroundColor:Md.color.textSecondary}});import{jsx as k,jsxs as ye}from"react/jsx-runtime";function pi({status:e}){switch(e){case"running":return k(Yt,{size:"small",color:w.color.textSecondary});case"ok":return k(s,{style:[y.mark,y.markOk],children:k(ri,{size:10,color:w.color.onAccent})});case"failed":return k(s,{style:[y.mark,y.markFailed],children:k(Rd,{size:10,color:w.color.text})});case"refused":return k(s,{style:[y.mark,y.markRefused],children:k(nr,{size:10,color:w.color.onAccent})});case"declined":case"stopped":return k(s,{style:[y.mark,y.markNotRun],children:k(s,{style:y.markNotRunBar})})}}function Fd(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 _d=e=>e.status==="failed"||e.status==="refused"||e.status==="declined"||e.status==="stopped";function hi({call:e,receipts:t,last:o}){let[r,n]=rr(false),i=Fd(e),a=r?ni:ii,g=e.status==="failed"&&e.summary&&e.summary!=="Failed"?e.summary:null;return ye(s,{style:[y.row,!o&&y.rowDivider],children:[ye(x,{testID:`buoy-ask-buoy-tool-${e.toolId}`,accessibilityRole:"button",accessibilityLabel:`${e.label}, ${i.text||"running"}`,accessibilityState:{expanded:r},onPress:()=>n(d=>!d),children:[ye(s,{style:y.rowLine,children:[k(s,{style:y.markSlot,children:k(pi,{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:w.color.textTertiary})]}),r&&ye(s,{style:y.rowDetail,children:[k(l,{style:y.rowTool,children:$d(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(d=>k(bo,{block:d},d.id))})]})}function Ud({label:e,count:t,calls:o,receipts:r,last:n}){let[i,a]=rr(false),g=i?ni:ii;return ye(s,{style:!n&&!i&&y.rowDivider,children:[k(x,{testID:"buoy-ask-buoy-reads-group",accessibilityRole:"button",accessibilityLabel:`${e}, ${t} reads`,accessibilityState:{expanded:i},onPress:()=>a(d=>!d),style:[y.row,i&&y.rowDivider],children:ye(s,{style:y.rowLine,children:[k(s,{style:y.markSlot,children:k(pi,{status:"ok"})}),k(l,{style:y.rowTitle,children:e}),ye(l,{style:y.rowStatus,numberOfLines:1,children:[t," reads"]}),k(g,{size:12,color:w.color.textTertiary})]})}),i&&k(s,{style:y.groupBody,children:o.map((d,h)=>k(hi,{call:d,receipts:r.get(d.id)??[],last:n&&h===o.length-1},d.id))})]})}function Kd({calls:e,receipts:t}){let o=Tc(e);return k(s,{style:y.card,testID:"buoy-ask-buoy-activity",children:o.map((r,n)=>r.kind==="reads"?k(Ud,{label:r.label,count:r.count,calls:r.calls,receipts:t,last:n===o.length-1},r.id):k(hi,{call:r.call,receipts:t.get(r.call.id)??[],last:n===o.length-1},r.call.id))})}function gi({blocks:e}){return e.length===0?null:k(s,{style:y.blocks,children:e.map(({block:t})=>k(bo,{block:t},t.id))})}function Gd({message:e}){return k(s,{style:y.systemLine,testID:"buoy-ask-buoy-system-line",children:k(l,{style:y.systemText,children:e.text})})}function Jd({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 Yd({message:e,onRetry:t,waitingOnUser:o}){let{showThinking:r}=Pt(),n=!!e.streaming&&!o,{nested:i,afterText:a,ask:g}=Ld(e.blocks,e.toolCalls.map(d=>d.id));return ye(s,{style:y.assistantWrap,children:[e.toolCalls.length>0&&k(Kd,{calls:e.toolCalls,receipts:i}),e.text.length>0&&k(Fr,{text:e.text,style:y.assistantText}),k(gi,{blocks:a}),k(gi,{blocks:g}),r&&!e.streaming&&k(ci,{message:e}),n&&ye(s,{style:y.waitingRow,children:[k(qd,{}),e.waiting?k(l,{style:y.waitingText,testID:"buoy-ask-buoy-waiting",children:e.waiting}):null]}),e.error&&(e.errorInfo?k(eu,{error:e.error,info:e.errorInfo,onRetry:t}):k(Xd,{error:e.error,onRetry:t})),e.stopped&&!e.error&&k(Qd,{onRetry:t,changed:e.toolCalls.some(d=>d.status==="ok"&&!!d.effect&&d.effect!=="read")})]})}function Qd({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(x,{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 Xd({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(nr,{size:14,color:w.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(x,{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 Zd=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 eu({error:e,info:t,onRetry:o}){let[r,n]=rr("idle"),i=`Ask Buoy error ${t.code}${t.requestId?` \xB7 request ${t.requestId}`:""} \xB7 ${new Date().toISOString()}`,{copied:a,copy:g}=ho(()=>i),d=b.getReporter(),h=It(()=>{d&&(n("sending"),d({requestId:t.requestId,code:t.code,note:"Reported from the error card."}).then(f=>n({id:f.reportId})).catch(()=>n("failed")))},[d,t.code,t.requestId]);return ye(s,{style:y.errorBox,testID:"buoy-ask-buoy-error",children:[k(nr,{size:14,color:w.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&&!Zd.has(t.code)&&k(x,{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(x,{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"})}),d&&k(x,{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 fi(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(...si(r));else for(let n of r.toolCalls){let i=_d(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 Da(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 tu({testID:e,label:t,getText:o}){let{copied:r,copy:n}=ho(o);return ye(x,{testID:e,accessibilityRole:"button",accessibilityLabel:t,onPress:n,style:({pressed:i})=>[y.copyBtn,y.iconBtn,i&&y.copyPressed],children:[r?k(ri,{size:11,color:w.color.accent}):k(Dd,{size:11,color:w.color.textSecondary}),k(l,{style:[y.copyText,r&&y.copiedText],children:r?"Copied":t})]})}function ou({message:e}){let{showThinking:t}=Pt(),o=It(()=>fi(b.getState().messages,t),[t]),r=Ic(e);return ye(s,{style:y.transcriptActions,children:[r?k(l,{style:y.turnFooter,testID:"buoy-ask-buoy-turn-footer",children:r}):null,k(tu,{testID:"buoy-ask-buoy-copy",label:"Copy conversation",getText:o})]})}var ru=Id(function({message:e,onRetry:t,waitingOnUser:o}){if(e.role==="user")return k(Jd,{message:e});if(e.system)return k(Gd,{message:e});let r=!e.streaming&&!e.error;return ye(s,{children:[k(Yd,{message:e,onRetry:t,waitingOnUser:o}),r&&k(ou,{message:e})]})});function bi({messages:e,ListHeaderComponent:t,ListEmptyComponent:o,ListFooterComponent:r,onRetry:n,waitingOnUser:i}){let a=or(null),g=or(true),d=or(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(()=>{d.current=true},[]),m=It(pe=>{d.current&&h(pe)},[h]),L=It(pe=>{d.current=false,h(pe)},[h]),V=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 zd(()=>{V()},[ce,V]),k(wr,{ref:a,testID:"buoy-ask-buoy-messages-scroll",style:y.list,contentContainerStyle:y.listContent,data:e,keyExtractor:pe=>pe.id,renderItem:({item:pe})=>k(ru,{message:pe,onRetry:pe.id===ee?.id?n:void 0,waitingOnUser:pe.id===ee?.id?i:false}),onScroll:m,onScrollBeginDrag:f,onScrollEndDrag:L,onMomentumScrollEnd:h,scrollEventThrottle:32,onContentSizeChange:V,keyboardShouldPersistTaps:"handled",keyboardDismissMode:"interactive",ListHeaderComponent:t,ListEmptyComponent:o,ListFooterComponent:r})}var y=v.create({list:{flex:1,backgroundColor:"transparent"},listContent:{paddingHorizontal:w.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:w.color.accentFill,borderWidth:v.hairlineWidth,borderColor:w.color.accentBorder},userText:{color:w.color.text,fontSize:w.font.row,lineHeight:21},systemLine:{alignSelf:"stretch",paddingHorizontal:12,paddingVertical:7,borderRadius:w.radius.row,backgroundColor:w.color.fill},systemText:{color:w.color.textSecondary,fontSize:w.font.micro,lineHeight:16,textAlign:"center"},assistantWrap:{alignItems:"stretch",gap:10},blocks:{gap:10},waitingRow:{flexDirection:"row",alignItems:"center",gap:8},waitingText:{color:w.color.textSecondary,fontSize:w.font.caption},assistantText:{color:w.color.text,fontSize:w.font.row,lineHeight:22,paddingHorizontal:2},card:{borderRadius:w.radius.card,borderWidth:v.hairlineWidth,borderColor:w.color.border,backgroundColor:w.color.surface,overflow:"hidden"},row:{paddingHorizontal:12,paddingVertical:10},rowDivider:{borderBottomWidth:v.hairlineWidth,borderBottomColor:w.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:w.color.accent},markFailed:{backgroundColor:w.color.danger},markRefused:{backgroundColor:w.color.warning},markNotRun:{borderWidth:1.5,borderColor:w.color.textTertiary},markNotRunBar:{width:7,height:1.5,borderRadius:1,backgroundColor:w.color.textSecondary},rowTitle:{flex:1,color:w.color.text,fontSize:w.font.body,lineHeight:19},rowStatus:{color:w.color.textTertiary,fontSize:w.font.caption,maxWidth:120},rowStatusDanger:{color:w.color.danger},rowStatusWarning:{color:w.color.warning},rowStatusOk:{color:w.color.accent},rowVerified:{color:w.color.accent},rowDetail:{paddingLeft:28,paddingTop:8,gap:4},rowTool:{color:w.color.textTertiary,fontSize:w.font.micro,fontWeight:"600",letterSpacing:.8},rowDescription:{color:w.color.textSecondary,fontSize:w.font.caption,lineHeight:18},rowFailure:{color:w.color.danger,fontSize:w.font.caption,lineHeight:18},rowReceipts:{paddingTop:10,gap:10},groupBody:{paddingLeft:14,backgroundColor:w.color.fill},stoppedBox:{alignItems:"flex-start",gap:2,paddingHorizontal:12,paddingVertical:8},stoppedText:{color:w.color.textTertiary,fontSize:w.font.caption,lineHeight:18},errorBox:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingVertical:10,borderRadius:w.radius.row,backgroundColor:w.color.dangerSoft},errorBody:{flex:1,gap:4},errorText:{color:w.color.danger,fontSize:w.font.caption,fontWeight:"600",lineHeight:18},errorDetail:{color:w.color.textSecondary,fontSize:w.font.micro,lineHeight:15},retry:{alignSelf:"flex-start",marginTop:6,paddingHorizontal:14,paddingVertical:7,borderRadius:w.radius.row,backgroundColor:w.color.button},retryPressed:{opacity:.7},retryText:{color:w.color.accent,fontSize:w.font.caption,fontWeight:"600"},transcriptActions:{flexDirection:"row",alignItems:"center",gap:10,marginTop:8},turnFooter:{flex:1,color:w.color.textTertiary,fontSize:w.font.micro,fontVariant:["tabular-nums"]},copyBtn:{paddingHorizontal:10,paddingVertical:5,borderRadius:w.radius.badge,backgroundColor:w.color.fill},iconBtn:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8},copyPressed:{opacity:.7},copyText:{color:w.color.textSecondary,fontSize:w.font.micro,fontWeight:"600"},copiedText:{color:w.color.accent}});import{night as Oe,X as nu}from"@buoy-gg/shared-ui/web";import{jsx as Wt,jsxs as lr}from"react/jsx-runtime";var iu=132;function lu({items:e,paused:t,onEdit:o,onRemove:r}){return e.length===0?null:lr(s,{style:He.wrap,testID:"buoy-ask-buoy-queued",children:[Wt(Ke,{style:He.list,contentContainerStyle:He.listContent,keyboardShouldPersistTaps:"handled",children:e.map((n,i)=>lr(s,{style:[He.row,t!==null&&He.rowPaused],children:[lr(x,{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:[Wt(l,{style:He.ordinal,children:i===0?"NEXT":"THEN"}),Wt(l,{style:He.text,numberOfLines:3,children:n.text})]}),Wt(x,{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:Wt(nu,{size:11,color:Oe.color.textTertiary})})]},n.id))}),Wt(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=v.create({wrap:{paddingHorizontal:Oe.gutter,paddingTop:8,gap:6,backgroundColor:Oe.color.bg},list:{maxHeight:iu},listContent:{gap:6},row:{flexDirection:"row",alignItems:"center",borderRadius:Oe.radius.row,borderWidth:v.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 au="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 su,jsx as he,jsxs as Et}from"react/jsx-runtime";function ar({visible:e,onClose:t,onBack:o,onMinimize:r,persistenceKey:n,config:i}){let{state:a,send:g,stop:d,reset:h,undoThenReset:f,approve:m,retry:L,answer:V,runAction:ee,editQueued:ce,removeQueued:pe,configured:Pe,toolCount:qe,availableToolIds:We}=ei(i),[Xe,Ze]=Do(false),et=Ue(()=>{d(),t()},[d,t]),Vt=Ue(()=>b.clearDraft(),[]),[tt,Ee]=Do(false),Nt=Ue(()=>Ee(false),[]),jt=Ue(()=>Ee(true),[]),ht=!e,Mt=!!a.pending||!!a.awaitingBlockId,Ce=a.messages[a.messages.length-1],gt=Kt(false),qt=Kt(a.busy);Ut(()=>{ht&&qt.current&&!a.busy&&(gt.current=true),ht||(gt.current=false),qt.current=a.busy},[ht,a.busy]),Ut(()=>{if(!ht){Ot("ask-buoy",null);return}Mt?Ot("ask-buoy",{kind:"needsInput",label:a.pending?"Needs your approval":"Has a question for you"}):gt.current&&Ce?.role==="assistant"&&Ce.error?Ot("ask-buoy",{kind:"failed",label:"The last turn failed"}):gt.current&&!a.busy?Ot("ask-buoy",{kind:"done",label:"Finished"}):Ot("ask-buoy",null)},[ht,Mt,a.busy,a.pending,Ce]),Ut(()=>()=>Ot("ask-buoy",null),[]),Ut(()=>{a.pending&&tt&&Ee(false)},[a.pending,tt]);let Dt=Al({minBottom:16}),[ot,To]=Do("bottomSheet"),ft=ot==="floating"?0:Dt.bottom,Co=Ue(()=>{let G=b.getLedger();G&&(async()=>{let ne=await G.revertAll(Dl);if(ne.failed.length===0){b.setNotice(null);return}let $t=ne.failed.map(so=>`${so.label} (${so.error})`).join("; ");b.setNotice(`Couldn't undo ${ne.failed.length} change${ne.failed.length===1?"":"s"} \u2014 ${$t}`)})()},[]),Io=Ue(()=>Ze(G=>!G),[]),kt=Kt(new ue.Value(560)).current,Ft=Kt(false),_t=Ue(()=>{Ft.current||(Ft.current=true,kt.stopAnimation(G=>{let ne=typeof G=="number"&&G>200?G:560;ue.timing(kt,{toValue:120,duration:220,useNativeDriver:false}).start(()=>{setTimeout(()=>{ue.spring(kt,{toValue:ne,friction:9,useNativeDriver:false}).start(()=>{Ft.current=false})},2500)})}))},[kt]),Rt=uo(()=>{let G=a.messages[a.messages.length-1];if(!G||G.role!=="assistant")return"";let ne=G.blocks.filter($t=>$t.block.kind==="peek").length;return ne>0?`${G.id}:${ne}`:""},[a.messages]),lo=Kt("");Ut(()=>{Rt&&Rt!==lo.current&&i?.peek!==false&&_t(),lo.current=Rt},[Rt,_t,i]);let zo=Ue(()=>{let G=b.getLedger()?.list().filter(ne=>!ne.undoneAt&&zl(ne.effect)).length??0;if(G===0){h();return}Bo.alert("Undo changes first?",`Ask Buoy made ${G} change${G===1?"":"s"} that can still be undone. Clearing the conversation loses the only automatic undo for ${G===1?"it":"them"}.`,[{text:"Undo, then clear",onPress:()=>{(async()=>{let ne=await f();if(ne.cleared)return;let $t=ne.reverted+ne.failed.length,so=ne.failed.map(br=>`${br.label} (${br.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:ld(t.params),effect:t.effect,startedAt:no()}]};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"done":return t.stopReason==="realm-died"?{...r,reloadedApp:true}:r;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}});Z({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??O.credits?.left??null,resetAt:t.frame.credits_reset??O.credits?.resetAt??null,pending:t.frame.pending===true}}:{},...t.type==="usage"?{usage:{input:O.usage.input+t.input,output:O.usage.output+t.output,requests:O.usage.requests+1}}:{}})},markStopped(e){Z({messages:O.messages.map(t=>t.id===e?{...t,stopped:true}:t)})},finishAssistant(e){Z({messages:O.messages.map(t=>t.id===e?{...t,streaming:false,endedAt:no()}:t),busy:false,stopping:false})},askApproval(e){return new Promise(t=>{Z({pending:{...e,resolve:t}})})},answerApproval(e){let t=O.pending,o=typeof e=="boolean"?e:e.approved,r=typeof e!="boolean"&&e.trust===true&&o,n=t?`${t.toolId}.${t.action}`:"";Z({pending:null,...r&&t&&!O.trusted.some(i=>i.key===n)?{trusted:[...O.trusted,{key:n,label:t.label}]}:{}}),t?.resolve(e)},untrust(e){tr?.session.untrust(e),Z({trusted:O.trusted.filter(t=>t.key!==e)})},restorePending(e){return O.pending||O.busy?false:(Z({pending:{...e,restored:true,resolve:()=>{}}}),true)},addNote(e){Z({messages:[...O.messages,{id:To(),role:"assistant",text:e,toolCalls:[],blocks:[],endedAt:no()}]})},hydrate(e){return O.messages.length>0||O.busy?false:(Z({messages:e.messages.map(t=>({...t,restored:true})),answers:e.answers,usage:e.usage,queued:e.queued??[]}),true)},reset(){O.pending?.resolve(false),Z({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 _n(e){return e.pending?"awaitingApproval":e.busy?e.stopping?"stopping":"running":e.awaitingBlockId?"awaitingAnswer":"idle"}function Un(e){let t=_n(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 sd,hasAccountAccess as jt,subscribeAccountAccess as cd}from"@buoy-gg/shared-ui/web";import{useCallback as De,useEffect as Xe,useMemo as Kn,useRef as dt,useState as Jn,useSyncExternalStore as dd}from"react";import{dispatchToolAction as Gn,listSnapshotToolIds as ud,listToolActions as pd,readToolSnapshot as hd,waitForToolRegistry as Yn}from"@buoy-gg/shared-ui/web";import{answerToText as Qn,CATALOG as or,createAskBuoySession as gd,readTargetDigest as fd,runGatedAction as Zn,SNAPSHOT_ACTION as Xn}from"@buoy-gg/agent-core/web";function rr(){b.getHeldSession()?.session.reset(),b.reset(),id()}async function ei(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}:(rr(),{cleared:true,reverted:o.reverted,failed:[]})}return rr(),{cleared:true,reverted:0,failed:[]}}var ti="claude-haiku-5-5";function bd(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 lo=typeof ho<"u"&&!ho;function yd(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 oi(){try{let e=pd();for(let t of ud())e[t]||(e[t]=[]),e[t].includes(Xn)||(e[t]=[Xn,...e[t]]);return e}catch{return{}}}var md=600;function Co(){return dd(b.subscribe,b.getState,b.getState)}function ri(e){let t=Co(),o=Bn(),r=Kn(()=>bd(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 h=!!e?.hostedModels?.claude,d=t.messages.length===0;Xe(()=>{let S=a.current?.readUsage;if(!h||o!=="claude"||!d||!S)return;let q=true;return S().then(F=>{q&&F.claude&&b.setClaudeOut(!F.claude.available)}).catch(()=>{}),()=>{q=false}},[h,o,d]);let g=sd()(),f=dt(g);f.current=g;let y=De((...S)=>!jt()||!f.current?Promise.reject(new Error("Ask Buoy requires Pro access.")):Gn(...S),[]),$=dt(null),V=dt(false),[re,ue]=Jn(false),ne=dt(null),Ue=dt(i);Ue.current=i;let Me=!!i?.endpoint&&!!i?.model,Pe=i?.persistTranscript!==false,{bypassApprovals:Ke,readOnly:tt}=Nt(),pt=dt(Ke);pt.current=Ke;let ht=dt(tt);ht.current=tt;let We=De(()=>ht.current?{...i?.policy??{},readOnly:true}:i?.policy??{},[i]),[ot,Ft]=Jn(0);Xe(()=>{let S=false;return Yn().then(()=>{S||Ft(q=>q+1)}),()=>{S=true}},[]);let gt=Kn(()=>oi(),[ot]),wt=Object.keys(gt).sort().join(",");Xe(()=>{if(b.setConfigured(Me),b.setMeta({model:i?.model,protocol:i?.protocol??(i?"anthropic":void 0),appName:i?.appName,platform:we.OS,build:lo?"release":"development"}),!Me||!i){$.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";lo&&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 q=[i.endpoint,i.protocol??"anthropic",i.model].join("|"),F=b.getHeldSession();if(F&&F.signature===q){$.current=F.session,F.session.setAvailableActions(gt),F.session.setApprovalBypass(pt.current),F.session.setReadOnly(ht.current),b.setLedger(F.session.ledger);return}let ie=gd({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:J=>{let bt=(J==="fallback"?i.hostedFallback?.model:i.model)===ti;b.setMeta({model:J==="fallback"?i.hostedFallback?.model:i.model}),J==="fallback"?(bt||b.setClaudeOut(true),b.setNotice(bt?"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?[...or,...i.tools]:void 0,dispatch:y,readSnapshot:hd,availableActions:gt,policy:i.policy,context:i.context,isRelease:lo,inApp:true,appName:i.appName,platform:we.OS,requestApproval:J=>b.askApproval(J)});$.current=ie,ie.setApprovalBypass(pt.current),ie.setReadOnly(ht.current),b.holdSession(ie,q),b.setLedger(ie.ledger);let $e=false;return Yn().then(J=>{J&&!$e&&ie.prime()}),Pe&&!V.current&&(V.current=true,Vn().then(J=>{if(!J||!b.hydrate({messages:J.messages,answers:J.answers,usage:J.usage,queued:J.queued}))return;$.current?.restore(J.history),J.ledger?.length&&$.current?.ledger.restore(J.ledger),J.pending&&b.restorePending(J.pending);let bt=rd(J,Date.now());bt==="resume"?ue(true):bt==="note"&&b.addNote(td)})),()=>{$e=true}},[Me,i,gt,wt,Pe]),Xe(()=>{$.current?.setApprovalBypass(Ke)},[Ke]),Xe(()=>{$.current?.setReadOnly(tt)},[tt]);let At=t.messages,Ce=t.answers,vt=t.usage,_t=t.busy,Ut=t.pending,so=t.queued;Xe(()=>{if(!Pe||At.length===0)return;let S=()=>{Nn(Xc({messages:At,history:$.current?.messages??[],answers:Ce,usage:vt,pending:Ut,ledger:b.getLedger()?.list(),queued:so}))};if(!_t||Ut){S();return}let q=setTimeout(S,md);return()=>clearTimeout(q)},[Pe,_t,At,Ce,vt,Ut,so]);let Bt=De(S=>{if(!jt()||!f.current)return;let q=$.current;if(!q)return;b.beginTurn();let F=b.startAssistant(),ie=new AbortController;ne.current=ie,q.setAvailableActions(oi());let $e=Ue.current?.onEvent;(async()=>{try{for await(let J of q.send(S,ie.signal))if(b.applyEvent(F,J),$e)try{$e(J)}catch{}}catch(J){ie.signal.aborted||b.applyEvent(F,{type:"error",message:J instanceof Error?J.message:"Something went wrong talking to your AI endpoint."})}finally{ie.signal.aborted&&b.markStopped(F),b.finishAssistant(F),ne.current=null}})()},[]),qe=De(S=>{if(!jt()||!f.current)return;let q=S.trim();if(!$.current||!q)return;if(b.getState().busy){b.enqueue(q);return}let F=b.getState().awaitingBlockId;F&&b.recordAnswer({blockId:F,kind:"skipped"}),b.addUser(q),Bt(q)},[Bt]);Xe(()=>{!re||!g||!jt()||!$.current||ot===0||(ue(false),qe(En))},[re,g,ot,qe]);let zo=De(()=>{let{messages:S,busy:q}=b.getState();if(q||!$.current)return;let F=[...S].reverse().find(ie=>ie.role==="user");F&&Bt(F.text)},[Bt]),ft=De(()=>{b.requestStop(),b.getState().pending&&b.answerApproval(false),ne.current?.abort(),ne.current=null},[]);Xe(()=>{let S=cd(()=>{jt()||ft()});return()=>{S(),ft()}},[ft]),Xe(()=>{g||ft()},[g,ft]),Xe(()=>{if(t.queued.length===0||_n(t)!=="idle"||Un(t)!==null)return;let S=b.shiftQueued();S&&qe(S.text)},[t,qe]);let St=De(S=>b.takeQueuedToDraft(S),[]),Kt=De(S=>b.removeQueued(S),[]),co=De(()=>{ne.current?.abort(),ne.current=null,rr()},[]),Lt=De(()=>ei({dispatch:Gn,undoFirst:true}),[]),Jt=De(async S=>{let q=b.getLedger();if(!q){b.setNotice(`${S.label} couldn't run \u2014 no active Ask Buoy session.`);return}let F=i?.tools?.length?[...or,...i.tools]:void 0;if(S.targetDigest){let $e=await fd({toolId:S.toolId,action:S.action,params:S.params??{},dispatch:y,catalog:F});if($e!==void 0&&$e!==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 ie=await Zn({toolId:S.toolId,action:S.action,params:S.params??{},dispatch:y,ledger:q,policy:We(),isRelease:lo,catalog:F});ie.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 ${ie.error}`)},[i,We]),Do=De(S=>{let q=b.getState().pending,F=typeof S=="boolean"?S:S.approved;if(b.answerApproval(S),!!q?.restored){if(!F){b.addNote(`Skipped \u201C${q.label}\u201D. Nothing was changed.`);return}Jt(q)}},[Jt]),Ro=De(S=>{b.recordAnswer(S);let q=yd(S.blockId);qe(q?`${q} \u2014 ${Qn(S)}`:Qn(S))},[qe]),uo=De(async(S,q)=>{if(!jt()||!f.current){b.setNotice("Ask Buoy requires Pro access.");return}if(S.send){qe(S.send);return}if(!S.dispatch)return;let F=`${q}:${S.label}`,ie=b.getLedger();if(!ie){b.setNotice(`${S.label} failed \u2014 no active Ask Buoy session.`);return}b.setActionState(F,"running");let $e=await Zn({toolId:S.dispatch.toolId,action:S.dispatch.action,params:S.dispatch.params??{},dispatch:y,ledger:ie,policy:We(),isRelease:lo,catalog:i?.tools?.length?[...or,...i.tools]:void 0});$e.ok?b.setActionState(F,"done"):(b.setActionState(F,"failed"),b.setNotice(`${S.label} failed \u2014 ${$e.error}`))},[qe,i,We]);return{state:t,send:qe,stop:ft,reset:co,undoThenReset:Lt,approve:Do,retry:zo,answer:Ro,runAction:uo,editQueued:St,removeQueued:Kt,configured:Me,toolCount:Object.keys(gt).length,availableToolIds:Object.keys(gt)}}import{Fragment as kd,jsx as X,jsxs as je}from"react/jsx-runtime";function ni(){let e=Nt(),t=Co().trusted;return je(Ge,{keyboardShouldPersistTaps:"handled",style:U.scroll,contentContainerStyle:U.content,testID:"buoy-ask-buoy-settings",children:[X(wd,{}),X(Sd,{}),X(l,{style:U.section,children:"CHAT"}),X(Mo,{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)}),X(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."}),X(l,{style:U.section,children:"PERMISSIONS"}),X(Mo,{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?X(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,X(Mo,{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:[X(Pc,{size:14,color:de.color.warning}),X(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."})]}):X(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:[X(l,{style:U.section,children:"ALLOWED WITHOUT ASKING \u2014 THIS CHAT"}),t.map(o=>je(s,{style:U.trustedRow,children:[X(l,{style:U.trustedLabel,numberOfLines:2,children:o.label}),X(k,{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:X(l,{style:U.forgetText,children:"Ask again"})})]},o.key))]}):null]})}function xd(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 wd(){let e=b.getUsageReader(),[t,o]=Hc({kind:"loading"}),r=Lc(()=>{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 Oc(r,[r]),e?je(s,{testID:"buoy-ask-buoy-credits",children:[X(l,{style:U.section,children:"HOSTED AI CREDITS"}),je(s,{style:U.trustedRow,children:[X(s,{style:{flex:1,gap:2},children:t.kind==="ok"?je(kd,{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 ${xd(t.usage.resetAt)}. `:"","That's about ",Math.floor(t.usage.creditsLeft/5).toLocaleString()," more asks, included with your plan."]})]}):t.kind==="error"?X(l,{style:U.note,children:t.message}):X(l,{style:U.note,children:"Loading\u2026"})}),X(k,{testID:"buoy-ask-buoy-credits-refresh",accessibilityRole:"button",onPress:r,style:({pressed:n})=>[U.forget,n&&{opacity:.7}],hitSlop:6,children:X(l,{style:U.forgetText,children:"Refresh"})})]})]}):null}var vd=[{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=Bn(),{claudeOut:t}=Co();return b.getUsageReader()?je(s,{testID:"buoy-ask-buoy-model",style:{gap:6},children:[X(l,{style:U.section,children:"MODEL"}),vd.map(o=>{let r=e===o.id;return je(k,{testID:`buoy-ask-buoy-model-${o.id}`,accessibilityRole:"radio",accessibilityState:{checked:r},onPress:()=>vo.set(o.id),style:({pressed:n})=>[U.trustedRow,r&&U.picked,n&&{opacity:.7}],children:[je(s,{style:{flex:1,gap:2},children:[X(l,{style:U.trustedLabel,children:o.label}),X(l,{style:U.note,children:o.note})]}),X(l,{style:U.forgetText,children:r?"On":""})]},o.id)}),X(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=v.create({picked:{borderColor:de.color.info},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:v.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:v.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 Td}from"@buoy-gg/shared-ui/web";import{ChevronRight as Cd,night as Se,NightSectionLabel as Id}from"@buoy-gg/shared-ui/web";var zd=[{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"}],Dd=4;function Rd(e){let t=e.availableToolIds.length>0;return zd.filter(o=>o.write&&e.readOnly||o.devOnly&&e.isRelease?false:o.needs?t&&e.availableToolIds.includes(o.needs):true).slice(0,Dd).map(o=>o.text)}import{jsx as et,jsxs as ao}from"react/jsx-runtime";var ii=typeof ho<"u"&&!ho;function $d({configured:e,onPick:t,availableToolIds:o=[],readOnly:r=false}){let n=Rd({availableToolIds:o,readOnly:r,isRelease:ii});return e?ao(s,{style:Re.wrap,testID:"buoy-ask-buoy-empty",children:[et(l,{style:Re.title,children:"Ask about this app"}),et(l,{style:Re.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."}),et(l,{style:Re.buildLine,testID:"buoy-ask-buoy-build-line",children:ii?"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."}),ao(s,{style:Re.group,children:[et(Id,{children:"Try asking"}),et(s,{style:Re.card,children:n.map((i,a)=>et(Ad,{text:i,onPick:t,last:a===n.length-1},i))})]})]}):ao(s,{style:Re.wrap,testID:"buoy-ask-buoy-unconfigured",children:[et(l,{style:Re.title,children:"Not set up yet"}),ao(l,{style:Re.body,children:["Ask Buoy talks to your own company's AI endpoint. Nothing goes to Buoy. A developer needs to add the ",et(l,{style:Re.code,children:"askBuoy"})," setting. It goes where the app sets up Buoy. It needs your team's endpoint and model."]})]})}function Ad({text:e,onPick:t,last:o}){return ao(k,{testID:`buoy-ask-buoy-suggestion-${e.slice(0,12)}`,accessibilityRole:"button",onPress:()=>t(e),style:({pressed:r})=>[Re.row,!o&&Re.rowDivider,r&&Re.pressed],children:[et(l,{style:Re.rowText,children:e}),et(Cd,{size:14,color:Se.color.textTertiary})]})}var Re=v.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"?Td:"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:v.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:v.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 Bd,useCallback as Rt,useEffect as Ld,useRef as nr,useState as ir}from"react";import{AlertTriangle as lr,Check as li,ChevronDown as ai,ChevronRight as si,Copy as Od,night as w,X as Hd}from"@buoy-gg/shared-ui/web";import{toolTitle as Pd}from"@buoy-gg/agent-core/web";import{isAskBlock as Wd}from"@buoy-gg/agent-core/web";function Ed({block:e,forToolCallId:t}){if(!t)return false;let o="source"in e?e.source:void 0;return o==="live"||o==="mocked"}function Vd(e,t){let o=new Set(t),r=new Map,n=[],i=[];for(let a of e){if(Wd(a.block)){i.push(a);continue}if(Ed(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 ci}from"react";import{Activity as Nd,ChevronDown as jd,ChevronRight as Md,night as ee}from"@buoy-gg/shared-ui/web";function ar(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 di(e){return(e.reasoning?.length??0)>0||e.toolCalls.length>0}var qd=e=>e.status==="ok"?e.summary||"done":e.status==="running"?"running":`${e.status}${e.summary?` \u2014 ${e.summary}`:""}`;function ui(e,t=" "){let o=[];for(let r of ar(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 ${qd(i)}`),i.params&&o.push(`${t} ${i.params}`)}return o}import{Fragment as Fd,jsx as Le,jsxs as ut}from"react/jsx-runtime";function _d({n:e,call:t}){let[o,r]=ci(false),n=t.status==="failed"||t.status==="refused";return ut(k,{onPress:()=>r(i=>!i),accessibilityRole:"button",accessibilityState:{expanded:o},style:be.step,children:[ut(s,{style:be.stepLine,children:[Le(l,{style:be.stepN,children:e}),ut(l,{style:[be.stepName,n&&be.stepFailed],numberOfLines:1,children:[t.toolId,".",t.action]}),t.durationMs!==void 0?ut(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?ut(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?ut(Fd,{children:[Le(l,{style:be.detailLabel,children:"RETURNED"}),Le(l,{style:be.code,selectable:true,children:t.result})]}):null]}):null]})}function pi({message:e}){let[t,o]=ci(false);if(!di(e))return null;let r=ar(e),n=r.filter(d=>d.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 ut(s,{style:be.wrap,testID:"buoy-ask-buoy-thinking",children:[ut(k,{testID:"buoy-ask-buoy-thinking-toggle",onPress:()=>o(d=>!d),accessibilityRole:"button",accessibilityLabel:t?"Hide agent thinking":"Show agent thinking",accessibilityState:{expanded:t},style:be.head,children:[Le(Nd,{size:12,color:ee.color.textTertiary}),Le(l,{style:be.headText,children:h}),t?Le(jd,{size:12,color:ee.color.textTertiary}):Le(Md,{size:12,color:ee.color.textTertiary})]}),t?ut(s,{style:be.body,children:[r.map((d,g)=>d.kind==="thought"?Le(l,{style:be.thought,selectable:true,children:d.text.trim()},`t${g}`):Le(_d,{n:d.n,call:d.call},d.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=v.create({wrap:{marginTop:8,borderRadius:ee.radius.badge,borderWidth:v.hairlineWidth,borderColor:ee.color.separator,backgroundColor:ee.color.fill,overflow:"hidden"},head:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:7},headText:{flex:1,color:ee.color.textTertiary,fontSize:ee.font.micro,fontWeight:"600"},body:{borderTopWidth:v.hairlineWidth,borderTopColor:ee.color.separator},thought:{color:ee.color.textSecondary,fontSize:ee.font.micro,lineHeight:17,fontStyle:"italic",paddingHorizontal:10,paddingVertical:8},step:{paddingHorizontal:10,paddingVertical:7},stepLine:{flexDirection:"row",alignItems:"center",gap:8},stepN:{color:ee.color.textTertiary,fontSize:ee.font.micro,width:14},stepName:{flex:1,color:ee.color.textSecondary,fontSize:ee.font.micro,fontWeight:"600"},stepMs:{color:ee.color.textTertiary,fontSize:ee.font.micro},stepStatus:{color:ee.color.textTertiary,fontSize:ee.font.micro,maxWidth:110},stepFailed:{color:ee.color.danger},detail:{marginTop:6,marginLeft:22,gap:3},detailLabel:{color:ee.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5},code:{color:ee.color.textSecondary,fontSize:ee.font.micro,lineHeight:16,marginBottom:3},none:{color:ee.color.textTertiary,fontSize:ee.font.micro,fontStyle:"italic",paddingHorizontal:10,paddingVertical:8}});import{useEffect as Ud,useRef as Kd}from"react";import{night as Jd}from"@buoy-gg/shared-ui/web";import{jsx as hi}from"react/jsx-runtime";function Gd(){let e=Kd([0,1,2].map(()=>new pe.Value(.25))).current;return Ud(()=>{let t=e.map((o,r)=>pe.loop(pe.sequence([pe.delay(r*140),pe.timing(o,{toValue:1,duration:320,easing:Ht.inOut(Ht.ease),useNativeDriver:true}),pe.timing(o,{toValue:.25,duration:320,easing:Ht.inOut(Ht.ease),useNativeDriver:true}),pe.delay((2-r)*140)])));return t.forEach(o=>o.start()),()=>t.forEach(o=>o.stop())},[e]),hi(s,{style:gi.wrap,testID:"buoy-ask-buoy-typing",accessibilityLabel:"Thinking",children:e.map((t,o)=>hi(pe.View,{style:[gi.dot,{opacity:t}]},o))})}var gi=v.create({wrap:{flexDirection:"row",alignItems:"center",gap:5,paddingVertical:8,paddingHorizontal:2},dot:{width:7,height:7,borderRadius:4,backgroundColor:Jd.color.textSecondary}});import{jsx as x,jsxs as ye}from"react/jsx-runtime";function fi({status:e}){switch(e){case"running":return x(Xt,{size:"small",color:w.color.textSecondary});case"ok":return x(s,{style:[m.mark,m.markOk],children:x(li,{size:10,color:w.color.onAccent})});case"failed":return x(s,{style:[m.mark,m.markFailed],children:x(Hd,{size:10,color:w.color.text})});case"refused":return x(s,{style:[m.mark,m.markRefused],children:x(lr,{size:10,color:w.color.onAccent})});case"declined":case"stopped":return x(s,{style:[m.mark,m.markNotRun],children:x(s,{style:m.markNotRunBar})})}}function Yd(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 Qd=e=>e.status==="failed"||e.status==="refused"||e.status==="declined"||e.status==="stopped";function bi({call:e,receipts:t,last:o}){let[r,n]=ir(false),i=Yd(e),a=r?ai:si,h=e.status==="failed"&&e.summary&&e.summary!=="Failed"?e.summary:null;return ye(s,{style:[m.row,!o&&m.rowDivider],children:[ye(k,{testID:`buoy-ask-buoy-tool-${e.toolId}`,accessibilityRole:"button",accessibilityLabel:`${e.label}, ${i.text||"running"}`,accessibilityState:{expanded:r},onPress:()=>n(d=>!d),children:[ye(s,{style:m.rowLine,children:[x(s,{style:m.markSlot,children:x(fi,{status:e.status})}),x(l,{style:m.rowTitle,children:e.label}),i.text?x(l,{style:[m.rowStatus,i.tone==="danger"&&m.rowStatusDanger,i.tone==="warning"&&m.rowStatusWarning,i.tone==="ok"&&m.rowStatusOk],numberOfLines:1,children:i.text}):null,x(a,{size:12,color:w.color.textTertiary})]}),r&&ye(s,{style:m.rowDetail,children:[x(l,{style:m.rowTool,children:Pd(e.toolId).toUpperCase()}),e.description?x(l,{style:m.rowDescription,children:e.description}):null,h?x(l,{style:m.rowFailure,children:h}):null,e.verification?x(l,{style:[m.rowDescription,e.verification.status==="failed"&&m.rowFailure,e.verification.status==="verified"&&m.rowVerified],testID:`buoy-ask-buoy-verification-${e.verification.status}`,children:e.verification.detail}):null]})]}),r&&t.length>0&&x(s,{style:m.rowReceipts,testID:`buoy-ask-buoy-tool-receipt-${e.toolId}`,children:t.map(d=>x(ko,{block:d},d.id))})]})}function Zd({label:e,count:t,calls:o,receipts:r,last:n}){let[i,a]=ir(false),h=i?ai:si;return ye(s,{style:!n&&!i&&m.rowDivider,children:[x(k,{testID:"buoy-ask-buoy-reads-group",accessibilityRole:"button",accessibilityLabel:`${e}, ${t} reads`,accessibilityState:{expanded:i},onPress:()=>a(d=>!d),style:[m.row,i&&m.rowDivider],children:ye(s,{style:m.rowLine,children:[x(s,{style:m.markSlot,children:x(fi,{status:"ok"})}),x(l,{style:m.rowTitle,children:e}),ye(l,{style:m.rowStatus,numberOfLines:1,children:[t," reads"]}),x(h,{size:12,color:w.color.textTertiary})]})}),i&&x(s,{style:m.groupBody,children:o.map((d,g)=>x(bi,{call:d,receipts:r.get(d.id)??[],last:n&&g===o.length-1},d.id))})]})}function Xd({calls:e,receipts:t}){let o=Dc(e);return x(s,{style:m.card,testID:"buoy-ask-buoy-activity",children:o.map((r,n)=>r.kind==="reads"?x(Zd,{label:r.label,count:r.count,calls:r.calls,receipts:t,last:n===o.length-1},r.id):x(bi,{call:r.call,receipts:t.get(r.call.id)??[],last:n===o.length-1},r.call.id))})}function yi({blocks:e}){return e.length===0?null:x(s,{style:m.blocks,children:e.map(({block:t})=>x(ko,{block:t},t.id))})}function eu({message:e}){return x(s,{style:m.systemLine,testID:"buoy-ask-buoy-system-line",children:x(l,{style:m.systemText,children:e.text})})}function tu({message:e}){return x(s,{style:m.userWrap,children:x(s,{style:m.userBubble,children:x(l,{style:m.userText,selectable:true,children:e.text})})})}function ou({message:e,onRetry:t,waitingOnUser:o}){let{showThinking:r}=Nt(),n=!!e.streaming&&!o,{nested:i,afterText:a,ask:h}=Vd(e.blocks,e.toolCalls.map(d=>d.id));return ye(s,{style:m.assistantWrap,children:[e.toolCalls.length>0&&x(Xd,{calls:e.toolCalls,receipts:i}),e.text.length>0&&x(Fr,{text:e.text,style:m.assistantText}),x(yi,{blocks:a}),x(yi,{blocks:h}),r&&!e.streaming&&x(pi,{message:e}),n&&ye(s,{style:m.waitingRow,children:[x(Gd,{}),e.waiting?x(l,{style:m.waitingText,testID:"buoy-ask-buoy-waiting",children:e.waiting}):null]}),e.error&&(e.errorInfo?x(lu,{error:e.error,info:e.errorInfo,onRetry:t}):x(nu,{error:e.error,onRetry:t})),e.stopped&&!e.error&&x(ru,{onRetry:t,changed:e.toolCalls.some(d=>d.status==="ok"&&!!d.effect&&d.effect!=="read")})]})}function ru({onRetry:e,changed:t}){return ye(s,{style:m.stoppedBox,testID:"buoy-ask-buoy-stopped",children:[x(l,{style:m.stoppedText,children:t?"Stopped. Changes already made are listed above.":"Stopped."}),e&&x(k,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:e,style:({pressed:o})=>[m.retry,o&&m.retryPressed],children:x(l,{style:m.retryText,children:"Try again"})})]})}function nu({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:m.errorBox,testID:"buoy-ask-buoy-error",children:[x(lr,{size:14,color:w.color.danger}),ye(s,{style:m.errorBody,children:[x(l,{style:m.errorText,children:o}),x(l,{style:m.errorDetail,selectable:true,children:e}),t&&x(k,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:t,style:({pressed:r})=>[m.retry,r&&m.retryPressed],children:x(l,{style:m.retryText,children:"Try again"})})]})]})}var iu=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 lu({error:e,info:t,onRetry:o}){let[r,n]=ir("idle"),i=`Ask Buoy error ${t.code}${t.requestId?` \xB7 request ${t.requestId}`:""} \xB7 ${new Date().toISOString()}`,{copied:a,copy:h}=bo(()=>i),d=b.getReporter(),g=Rt(()=>{d&&(n("sending"),d({requestId:t.requestId,code:t.code,note:"Reported from the error card."}).then(f=>n({id:f.reportId})).catch(()=>n("failed")))},[d,t.code,t.requestId]);return ye(s,{style:m.errorBox,testID:"buoy-ask-buoy-error",children:[x(lr,{size:14,color:w.color.danger}),ye(s,{style:m.errorBody,children:[x(l,{style:m.errorText,children:e}),ye(l,{style:m.errorDetail,selectable:true,testID:"buoy-ask-buoy-error-code",children:[t.code,t.requestId?` \xB7 ${t.requestId}`:""]}),ye(s,{style:m.transcriptActions,children:[o&&!iu.has(t.code)&&x(k,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:o,style:({pressed:f})=>[m.retry,f&&m.retryPressed],children:x(l,{style:m.retryText,children:"Try again"})}),x(k,{testID:"buoy-ask-buoy-error-copy",accessibilityRole:"button",accessibilityLabel:"Copy details",onPress:h,style:({pressed:f})=>[m.retry,f&&m.retryPressed],children:x(l,{style:m.retryText,children:a?"Copied":"Copy details"})}),d&&x(k,{testID:"buoy-ask-buoy-error-report",accessibilityRole:"button",accessibilityLabel:"Report problem",disabled:r!=="idle"&&r!=="failed",onPress:g,style:({pressed:f})=>[m.retry,f&&m.retryPressed],children:x(l,{style:m.retryText,children:r==="sending"?"Sending\u2026":r==="failed"?"Report failed. Try again":typeof r=="object"?`Reported \xB7 ${r.id}`:"Report problem"})})]})]})]})}function mi(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(...ui(r));else for(let n of r.toolCalls){let i=Qd(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 Aa(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 au({testID:e,label:t,getText:o}){let{copied:r,copy:n}=bo(o);return ye(k,{testID:e,accessibilityRole:"button",accessibilityLabel:t,onPress:n,style:({pressed:i})=>[m.copyBtn,m.iconBtn,i&&m.copyPressed],children:[r?x(li,{size:11,color:w.color.accent}):x(Od,{size:11,color:w.color.textSecondary}),x(l,{style:[m.copyText,r&&m.copiedText],children:r?"Copied":t})]})}function su({message:e}){let{showThinking:t}=Nt(),o=Rt(()=>mi(b.getState().messages,t),[t]),r=$c(e);return ye(s,{style:m.transcriptActions,children:[r?x(l,{style:m.turnFooter,testID:"buoy-ask-buoy-turn-footer",children:r}):null,x(au,{testID:"buoy-ask-buoy-copy",label:"Copy conversation",getText:o})]})}var cu=Bd(function({message:e,onRetry:t,waitingOnUser:o}){if(e.role==="user")return x(tu,{message:e});if(e.system)return x(eu,{message:e});let r=!e.streaming&&!e.error;return ye(s,{children:[x(ou,{message:e,onRetry:t,waitingOnUser:o}),r&&x(su,{message:e})]})});function ki({messages:e,ListHeaderComponent:t,ListEmptyComponent:o,ListFooterComponent:r,onRetry:n,waitingOnUser:i}){let a=nr(null),h=nr(true),d=nr(false),g=Rt(ne=>{let{contentOffset:Ue,contentSize:Me,layoutMeasurement:Pe}=ne.nativeEvent,Ke=Me.height-Pe.height-Ue.y;h.current=Ke<80},[]),f=Rt(()=>{d.current=true},[]),y=Rt(ne=>{d.current&&g(ne)},[g]),$=Rt(ne=>{d.current=false,g(ne)},[g]),V=Rt(()=>{h.current&&(a.current?.scrollToEnd({animated:false}),requestAnimationFrame(()=>a.current?.scrollToEnd({animated:false})))},[]),re=e[e.length-1],ue=re?`${re.id}:${re.text.length}:${re.toolCalls.length}:${re.error??""}`:"";return Ld(()=>{V()},[ue,V]),x(wr,{ref:a,testID:"buoy-ask-buoy-messages-scroll",style:m.list,contentContainerStyle:m.listContent,data:e,keyExtractor:ne=>ne.id,renderItem:({item:ne})=>x(cu,{message:ne,onRetry:ne.id===re?.id?n:void 0,waitingOnUser:ne.id===re?.id?i:false}),onScroll:y,onScrollBeginDrag:f,onScrollEndDrag:$,onMomentumScrollEnd:g,scrollEventThrottle:32,onContentSizeChange:V,keyboardShouldPersistTaps:"handled",keyboardDismissMode:"interactive",ListHeaderComponent:t,ListEmptyComponent:o,ListFooterComponent:r})}var m=v.create({list:{flex:1,backgroundColor:"transparent"},listContent:{paddingHorizontal:w.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:w.color.accentFill,borderWidth:v.hairlineWidth,borderColor:w.color.accentBorder},userText:{color:w.color.text,fontSize:w.font.row,lineHeight:21},systemLine:{alignSelf:"stretch",paddingHorizontal:12,paddingVertical:7,borderRadius:w.radius.row,backgroundColor:w.color.fill},systemText:{color:w.color.textSecondary,fontSize:w.font.micro,lineHeight:16,textAlign:"center"},assistantWrap:{alignItems:"stretch",gap:10},blocks:{gap:10},waitingRow:{flexDirection:"row",alignItems:"center",gap:8},waitingText:{color:w.color.textSecondary,fontSize:w.font.caption},assistantText:{color:w.color.text,fontSize:w.font.row,lineHeight:22,paddingHorizontal:2},card:{borderRadius:w.radius.card,borderWidth:v.hairlineWidth,borderColor:w.color.border,backgroundColor:w.color.surface,overflow:"hidden"},row:{paddingHorizontal:12,paddingVertical:10},rowDivider:{borderBottomWidth:v.hairlineWidth,borderBottomColor:w.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:w.color.accent},markFailed:{backgroundColor:w.color.danger},markRefused:{backgroundColor:w.color.warning},markNotRun:{borderWidth:1.5,borderColor:w.color.textTertiary},markNotRunBar:{width:7,height:1.5,borderRadius:1,backgroundColor:w.color.textSecondary},rowTitle:{flex:1,color:w.color.text,fontSize:w.font.body,lineHeight:19},rowStatus:{color:w.color.textTertiary,fontSize:w.font.caption,maxWidth:120},rowStatusDanger:{color:w.color.danger},rowStatusWarning:{color:w.color.warning},rowStatusOk:{color:w.color.accent},rowVerified:{color:w.color.accent},rowDetail:{paddingLeft:28,paddingTop:8,gap:4},rowTool:{color:w.color.textTertiary,fontSize:w.font.micro,fontWeight:"600",letterSpacing:.8},rowDescription:{color:w.color.textSecondary,fontSize:w.font.caption,lineHeight:18},rowFailure:{color:w.color.danger,fontSize:w.font.caption,lineHeight:18},rowReceipts:{paddingTop:10,gap:10},groupBody:{paddingLeft:14,backgroundColor:w.color.fill},stoppedBox:{alignItems:"flex-start",gap:2,paddingHorizontal:12,paddingVertical:8},stoppedText:{color:w.color.textTertiary,fontSize:w.font.caption,lineHeight:18},errorBox:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingVertical:10,borderRadius:w.radius.row,backgroundColor:w.color.dangerSoft},errorBody:{flex:1,gap:4},errorText:{color:w.color.danger,fontSize:w.font.caption,fontWeight:"600",lineHeight:18},errorDetail:{color:w.color.textSecondary,fontSize:w.font.micro,lineHeight:15},retry:{alignSelf:"flex-start",marginTop:6,paddingHorizontal:14,paddingVertical:7,borderRadius:w.radius.row,backgroundColor:w.color.button},retryPressed:{opacity:.7},retryText:{color:w.color.accent,fontSize:w.font.caption,fontWeight:"600"},transcriptActions:{flexDirection:"row",alignItems:"center",gap:10,marginTop:8},turnFooter:{flex:1,color:w.color.textTertiary,fontSize:w.font.micro,fontVariant:["tabular-nums"]},copyBtn:{paddingHorizontal:10,paddingVertical:5,borderRadius:w.radius.badge,backgroundColor:w.color.fill},iconBtn:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8},copyPressed:{opacity:.7},copyText:{color:w.color.textSecondary,fontSize:w.font.micro,fontWeight:"600"},copiedText:{color:w.color.accent}});import{night as Oe,X as du}from"@buoy-gg/shared-ui/web";import{jsx as Mt,jsxs as sr}from"react/jsx-runtime";var uu=132;function pu({items:e,paused:t,onEdit:o,onRemove:r}){return e.length===0?null:sr(s,{style:He.wrap,testID:"buoy-ask-buoy-queued",children:[Mt(Ge,{style:He.list,contentContainerStyle:He.listContent,keyboardShouldPersistTaps:"handled",children:e.map((n,i)=>sr(s,{style:[He.row,t!==null&&He.rowPaused],children:[sr(k,{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:[Mt(l,{style:He.ordinal,children:i===0?"NEXT":"THEN"}),Mt(l,{style:He.text,numberOfLines:3,children:n.text})]}),Mt(k,{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:Mt(du,{size:11,color:Oe.color.textTertiary})})]},n.id))}),Mt(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=v.create({wrap:{paddingHorizontal:Oe.gutter,paddingTop:8,gap:6,backgroundColor:Oe.color.bg},list:{maxHeight:uu},listContent:{gap:6},row:{flexDirection:"row",alignItems:"center",borderRadius:Oe.radius.row,borderWidth:v.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 hu="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 gu,jsx as he,jsxs as qt}from"react/jsx-runtime";function cr({visible:e,onClose:t,onBack:o,onMinimize:r,persistenceKey:n,config:i}){let{state:a,send:h,stop:d,reset:g,undoThenReset:f,approve:y,retry:$,answer:V,runAction:re,editQueued:ue,removeQueued:ne,configured:Ue,toolCount:Me,availableToolIds:Pe}=ri(i),[Ke,tt]=$o(false),pt=Je(()=>{d(),t()},[d,t]),ht=Je(()=>b.clearDraft(),[]),[We,ot]=$o(false),Ft=Je(()=>ot(false),[]),gt=Je(()=>ot(true),[]),wt=!e,At=!!a.pending||!!a.awaitingBlockId,Ce=a.messages[a.messages.length-1],vt=Yt(false),_t=Yt(a.busy);Gt(()=>{wt&&_t.current&&!a.busy&&(vt.current=true),wt||(vt.current=false),_t.current=a.busy},[wt,a.busy]),Gt(()=>{if(!wt){Et("ask-buoy",null);return}At?Et("ask-buoy",{kind:"needsInput",label:a.pending?"Needs your approval":"Has a question for you"}):vt.current&&Ce?.role==="assistant"&&Ce.error?Et("ask-buoy",{kind:"failed",label:"The last turn failed"}):vt.current&&!a.busy?Et("ask-buoy",{kind:"done",label:"Finished"}):Et("ask-buoy",null)},[wt,At,a.busy,a.pending,Ce]),Gt(()=>()=>Et("ask-buoy",null),[]),Gt(()=>{a.pending&&We&&ot(false)},[a.pending,We]);let Ut=Ol({minBottom:16}),[so,Bt]=$o("bottomSheet"),qe=so==="floating"?0:Ut.bottom,zo=Je(()=>{let G=b.getLedger();G&&(async()=>{let le=await G.revertAll(Al);if(le.failed.length===0){b.setNotice(null);return}let Ot=le.failed.map(po=>`${po.label} (${po.error})`).join("; ");b.setNotice(`Couldn't undo ${le.failed.length} change${le.failed.length===1?"":"s"} \u2014 ${Ot}`)})()},[]),ft=Je(()=>tt(G=>!G),[]),St=Yt(new pe.Value(560)).current,Kt=Yt(false),co=Je(()=>{Kt.current||(Kt.current=true,St.stopAnimation(G=>{let le=typeof G=="number"&&G>200?G:560;pe.timing(St,{toValue:120,duration:220,useNativeDriver:false}).start(()=>{setTimeout(()=>{pe.spring(St,{toValue:le,friction:9,useNativeDriver:false}).start(()=>{Kt.current=false})},2500)})}))},[St]),Lt=go(()=>{let G=a.messages[a.messages.length-1];if(!G||G.role!=="assistant")return"";let le=G.blocks.filter(Ot=>Ot.block.kind==="peek").length;return le>0?`${G.id}:${le}`:""},[a.messages]),Jt=Yt("");Gt(()=>{Lt&&Lt!==Jt.current&&i?.peek!==false&&co(),Jt.current=Lt},[Lt,co,i]);let Do=Je(()=>{let G=b.getLedger()?.list().filter(le=>!le.undoneAt&&$l(le.effect)).length??0;if(G===0){g();return}Oo.alert("Undo changes first?",`Ask Buoy made ${G} change${G===1?"":"s"} that can still be undone. Clearing the conversation loses the only automatic undo for ${G===1?"it":"them"}.`,[{text:"Undo, then clear",onPress:()=>{(async()=>{let le=await f();if(le.cleared)return;let Ot=le.reverted+le.failed.length,po=le.failed.map(br=>`${br.label} (${br.error})`).join(`
|
|
13
|
+
`);Oo.alert(`Couldn't undo ${le.failed.length} of ${Ot} change${Ot===1?"":"s"}`,`${po}
|
|
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:g}])})()}},{text:"Clear anyway",style:"destructive",onPress:g},{text:"Cancel",style:"cancel"}])},[g,f]),Ro=go(()=>{let G=a.messages[a.messages.length-1];return!G||G.role!=="assistant"||!G.streaming?null:G.toolCalls.find(le=>le.status==="running")?.label??null},[a.messages]),uo=fn(b.getLedger()),S=go(()=>cc(uo),[uo]),q=go(()=>({answer:V,runAction:(G,le)=>{if(G.minimize){r?.({mode:"bottomSheet"});return}return re(G,le)},answered:a.answers,actionState:a.actionState,busy:a.busy,supports:{openTool:false,minimize:!!r,dispatch:true},rules:S}),[V,re,r,a.answers,a.actionState,a.busy,S]),F=!a.busy&&Ce?.role==="assistant"&&!!Ce.error,ie=!a.busy&&Ce?.role==="assistant"&&Ce.stopped&&!Ce.error?Ce.id:null,$e=Un(a),{showThinking:J,readOnly:bt,claudeNoticeSeen:Ti}=Nt(),fr=i?.hosted===true&&!Ti,Ci=Je(()=>mi(a.messages,J),[a.messages,J]),Ii=Je(()=>h(hu),[h]),zi=We?qt(Ho,{children:[he(Ho.Navigation,{onBack:Ft}),he(Ho.Content,{title:"Settings",subtitle:"Ask Buoy",testID:"buoy-ask-buoy-settings-title"})]}):he(In,{configured:Ue,busy:a.busy,failed:F,activeLabel:Ro,awaitingApproval:!!a.pending,startedAt:Ce?.role==="assistant"&&Ce.streaming?Ce.startedAt??null:null,stopping:a.stopping,readOnly:bt,toolCount:Me,hasMessages:a.messages.length>0,onBack:o,onReset:Do,getTranscript:Ci,onOpenSettings:gt,onTicket:Ii});return he(Ll,{avoidKeyboard:false,visible:e,onClose:pt,disableScrollWrapper:true,background:false,initialHeight:560,animatedHeight:St,header:{customContent:zi,showToggleButton:false},onBack:o,onMinimize:r,onModeChange:Bt,persistenceKey:n??"buoy-ask-buoy",enablePersistence:true,children:he(Br,{value:q,children:qt(s,{style:[$t.root,{paddingBottom:qe}],children:[he(bn,{ledger:b.getLedger(),onUndoAll:zo,expanded:Ke,onToggle:ft}),fr&&qt(s,{style:$t.notice,testID:"buoy-ask-buoy-hosted-notice",children:[he(Rr,{size:14,color:Ye.color.info}),qt(s,{style:{flex:1,gap:8},children:[he(l,{style:$t.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(k,{testID:"buoy-ask-buoy-hosted-notice-ok",accessibilityRole:"button",onPress:()=>{st.set("claudeNoticeSeen",true),st.set("hostedNoticeSeen",true)},style:({pressed:G})=>[$t.noticeButton,G&&{opacity:.7}],children:he(l,{style:$t.noticeButtonText,children:"Got it"})})]})]}),a.notice&&qt(s,{style:$t.notice,testID:"buoy-ask-buoy-notice",children:[he(Rr,{size:14,color:Ye.color.info}),he(l,{style:$t.noticeText,children:a.notice})]}),he(mc,{children:he(Bl,{featureName:"Ask Buoy",children:We?he(ni,{}):qt(gu,{children:[he(ki,{messages:a.messages,onRetry:$,waitingOnUser:!!a.pending||!!a.awaitingBlockId,ListEmptyComponent:he($d,{configured:Ue,onPick:h,availableToolIds:Pe,readOnly:bt||!!i?.policy?.readOnly})}),he(pu,{items:a.queued,paused:$e,onEdit:ue,onRemove:ne}),a.pending&&he(pn,{pending:a.pending,onAnswer:y}),he(xn,{onSend:h,onStop:d,busy:a.busy,draft:a.draft,onDraftTaken:ht,disabled:!Ue||fr,focusKey:ie,canFocus:e,placeholder:ie?"Tell it what to do differently\u2026":a.awaitingBlockId?"Pick an option above, or type\u2026":void 0})]})})})]})})})}var $t=v.create({root:{flex:1,backgroundColor:"transparent"},notice:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:Ye.gutter,paddingVertical:10,backgroundColor:Ye.color.infoSoft},noticeText:{flex:1,color:Ye.color.text,fontSize:Ye.font.caption,lineHeight:18},noticeButton:{alignSelf:"flex-start",paddingHorizontal:12,paddingVertical:6,borderRadius:Ye.radius.row,backgroundColor:Ye.color.button},noticeButtonText:{color:Ye.color.text,fontSize:Ye.font.caption,fontWeight:"600"}});import{AskBuoyIcon as xi,ASK_BUOY_ICON_COLOR as wi}from"@buoy-gg/floating-tools-core/web";import{jsx as vi}from"react/jsx-runtime";var Io={id:"ask-buoy",name:"ASK BUOY",description:"Ask about this app in plain English",slot:"both",color:wi,icon:({size:e,slot:t})=>vi(xi,{size:t==="dial"?e*1.5:e}),component:cr};function fu(e){let{name:t,description:o,...r}=e,n=r;return{...Io,name:t??Io.name,description:o??Io.description,component:i=>vi(cr,{...i,config:n})}}import{isReversible as dr}from"@buoy-gg/agent-core/web";var ur=1,bu={version:ur,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:ur,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:io(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=>dr(o.effect)).length,permanent:t.filter(o=>o.effect.kind!=="transient"&&!dr(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:dr(e.effect)})),undoAll:async()=>{let e=b.getLedger();return e?{ok:true,...await e.revertAll(On)}:{ok:false,error:"No Ask Buoy session on this device."}},reset:async()=>{let e=await ei({dispatch:On,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 yu from"@buoy-gg/license/web";import{HOSTED_HEADERS as xt,HOSTED_PROTOCOL_VERSION as mu}from"@buoy-gg/agent-core/web";var Si="https://ai.buoy.gg/v1/chat/completions",pr="openai/gpt-6-luna",ku=10*6e4;async function hr(e=false){let t=yu.SessionManager;if(!t)return null;let o=t.getStatus();return o.state==="active"&&(e||o.grace||(o.validUntil??0)-Date.now()<ku)&&await t.refresh(true),t.getAccessToken()}function gr(e){let t=/^(https?:\/\/[^/]+)/.exec(e);return t?t[1]:e}function xu(e={}){let{endpoint:t=Si,...o}=e,r=`ask-buoy ${we.OS}`;return{...o,endpoint:t,hosted:true,protocol:"openai",model:pr,hostedModels:{luna:{endpoint:t,protocol:"openai",model:pr},claude:{endpoint:`${gr(t)}/v1/messages`,protocol:"anthropic",model:ti}},maxTokens:8192,headers:async n=>{let i=await hr((n?.attempt??1)>1);return{...i?{[xt.session]:i}:{},[xt.ask]:n?.askId??"ask_unknown000",[xt.round]:String(n?.round??1),[xt.attempt]:String(n?.attempt??1),[xt.protocol]:String(mu),[xt.client]:r}},readUsage:async()=>{let n=await hr();if(!n)throw new Error("Sign in to see hosted credits.");let i=await fetch(`${gr(t)}/v1/usage`,{headers:{[xt.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 h=await hr(),d=await fetch(`${gr(t)}/v1/report`,{method:"POST",headers:{"Content-Type":"application/json",...h?{[xt.session]:h}:{}},body:JSON.stringify({request_id:n,code:i,note:a,client:r})});if(!d.ok)throw new Error(`report HTTP ${d.status}`);let g=await d.json();if(!g.report_id)throw new Error("report: no id");return{reportId:g.report_id}}}}export{ur as ASK_BUOY_ADAPTER_VERSION,wi as ASK_BUOY_ICON_COLOR,pn as ApprovalCard,In as AskBuoyHeader,xi as AskBuoyIcon,cr as AskBuoyModal,ni as AskBuoySettings,Ve as BlockActionRow,W as BlockCard,Br as BlockHandlersProvider,ko as BlockRenderer,bn as ChangesBar,xn as Composer,oc as EditableUserBubble,Zs as ElapsedRow,Si as HOSTED_ENDPOINT,pr as HOSTED_MODEL,cn as LivePill,Fr as Markdown,Ys as MessageActions,ki as MessageList,Er as ProvenanceBadge,Xs as QueuedComposer,Qs as ReasoningStrip,ec as ReloadDivider,pi as ThinkingStrip,tc as Timestamp,st as askBuoySettings,b as askBuoyStore,bu as askBuoySyncAdapter,Io as askBuoyToolPreset,fu as createAskBuoyTool,di as hasTrace,xu as hostedAskBuoy,io as redactForWire,ar as traceEntries,ui as traceToText,ri as useAskBuoy,Nt as useAskBuoySettings,Co as useAskBuoyState,te as useBlockHandlers};
|