@blinkk/root-cms 3.1.6 → 3.1.7

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.
Files changed (105) hide show
  1. package/dist/app.js +1 -1
  2. package/dist/{chunk-U4TMO2LI.js → chunk-NIBAHWGP.js} +2 -2
  3. package/dist/plugin.js +1 -1
  4. package/dist/ui/AIPage-XPE7F5AF.js +1 -0
  5. package/dist/ui/AssetsPage-C3ZEENBO.js +1 -0
  6. package/dist/ui/CollectionPage-VQ4WJHJB.js +1 -0
  7. package/dist/ui/ComparePage-VKOXKID4.js +1 -0
  8. package/dist/ui/{DataPage-YEIS7HBN.js → DataPage-JXZ2Z3DG.js} +1 -1
  9. package/dist/ui/{DataSourcePage-VD6YBDRW.js → DataSourcePage-X3NSUOTP.js} +1 -1
  10. package/dist/ui/{DocTranslationsPage-6XLREBPQ.js → DocTranslationsPage-AJGT52XQ.js} +1 -1
  11. package/dist/ui/DocumentPage-ZFD2KE3A.js +1 -0
  12. package/dist/ui/{EditDataSourcePage-E4PSKSG3.js → EditDataSourcePage-EMK3F6HD.js} +1 -1
  13. package/dist/ui/EditReleasePage-3IAERDSH.js +1 -0
  14. package/dist/ui/EmbeddedAIPage-2W5F7QFL.js +1 -0
  15. package/dist/ui/EmbeddedDocumentPage-BESFW2YZ.js +1 -0
  16. package/dist/ui/{ImageEditorDialog-YDKOGVJV.js → ImageEditorDialog-JDXMU2FC.js} +1 -1
  17. package/dist/ui/LogsPage-KCD4XZ2N.js +1 -0
  18. package/dist/ui/{NewDataSourcePage-NJJDHGPX.js → NewDataSourcePage-EZDU7HGA.js} +1 -1
  19. package/dist/ui/NewReleasePage-FFTRUIP4.js +1 -0
  20. package/dist/ui/{NotFoundPage-CA7XVXUO.js → NotFoundPage-JGG2NTUE.js} +1 -1
  21. package/dist/ui/{ProjectPage-XUBJSCWB.js → ProjectPage-HT5JKR33.js} +1 -1
  22. package/dist/ui/ReleasePage-OYWLGV4D.js +1 -0
  23. package/dist/ui/{ReleasesPage-OY7OKC3C.js → ReleasesPage-XEII7FBC.js} +1 -1
  24. package/dist/ui/{SettingsPage-5EQUY52A.js → SettingsPage-7GIBTPB5.js} +1 -1
  25. package/dist/ui/SidebarToolsPage-GQYTZDAC.js +1 -0
  26. package/dist/ui/TaskPage-SNDDYDZY.js +1 -0
  27. package/dist/ui/TasksPage-CEVWOY67.js +1 -0
  28. package/dist/ui/{TranslationsArbPage-PG5USRYB.js → TranslationsArbPage-ADRLLAIW.js} +1 -1
  29. package/dist/ui/{TranslationsEditPage-GV3ZJXTY.js → TranslationsEditPage-PSKA7K44.js} +1 -1
  30. package/dist/ui/{TranslationsPage-3AKSMCNF.js → TranslationsPage-NGCLDSK7.js} +2 -2
  31. package/dist/ui/{chunk-75NMQ3LW.js → chunk-3YBRRPAN.js} +1 -1
  32. package/dist/ui/{chunk-QLIIVG5Q.js → chunk-5F5XJPKD.js} +1 -1
  33. package/dist/ui/{chunk-ST6QNIWT.js → chunk-6ZVMJXLE.js} +7 -7
  34. package/dist/ui/chunk-7OU4ERTS.js +87 -0
  35. package/dist/ui/chunk-A2JZYRE3.js +1 -0
  36. package/dist/ui/chunk-B74M7NEV.js +1 -0
  37. package/dist/ui/{chunk-UOKVF54Y.js → chunk-BLHXP3SR.js} +1 -1
  38. package/dist/ui/{chunk-UJX25CXD.js → chunk-BOIY4J2R.js} +1 -1
  39. package/dist/ui/chunk-CEWU5VSJ.js +1 -0
  40. package/dist/ui/{chunk-34W6H4YG.js → chunk-CXMVFNX3.js} +1 -1
  41. package/dist/ui/{chunk-F7RQT4XN.js → chunk-EET5AS64.js} +1 -1
  42. package/dist/ui/{chunk-WASID5UU.js → chunk-GJ7ES2LA.js} +1 -1
  43. package/dist/ui/{chunk-2RRM4HEQ.js → chunk-H5JL376P.js} +1 -1
  44. package/dist/ui/{chunk-H37RXS4R.js → chunk-HKCOKHA2.js} +1 -1
  45. package/dist/ui/{chunk-QGAPMQEJ.js → chunk-HUYP5U4K.js} +1 -1
  46. package/dist/ui/{chunk-NCZD5IWS.js → chunk-HWON6MV4.js} +1 -1
  47. package/dist/ui/{chunk-HXSB6YB2.js → chunk-I3H465Z6.js} +1 -1
  48. package/dist/ui/{chunk-535JU7FU.js → chunk-ILFWJKSS.js} +1 -1
  49. package/dist/ui/chunk-K7IG7PO2.js +1 -0
  50. package/dist/ui/{chunk-LAXQZPE3.js → chunk-LKTN7YVM.js} +1 -1
  51. package/dist/ui/{chunk-PLYSJ7W5.js → chunk-LS2JH5QF.js} +1 -1
  52. package/dist/ui/{chunk-QFDU6FXP.js → chunk-MALK5YEV.js} +1 -1
  53. package/dist/ui/{chunk-YP6ZH3MT.js → chunk-MFRPYPCF.js} +1 -1
  54. package/dist/ui/{chunk-RB23LLKL.js → chunk-OKNBFTYR.js} +1 -1
  55. package/dist/ui/{chunk-A7IZAHBZ.js → chunk-P2RVKNG4.js} +1 -1
  56. package/dist/ui/{chunk-JBLSUM6W.js → chunk-P57AFOMR.js} +1 -1
  57. package/dist/ui/{chunk-HV3JJ5UT.js → chunk-PLTI4NG7.js} +1 -1
  58. package/dist/ui/chunk-PY4JH5SN.js +1 -0
  59. package/dist/ui/{chunk-44ZU5WMI.js → chunk-SBAY52SC.js} +1 -1
  60. package/dist/ui/{chunk-Y5EOMMNI.js → chunk-TCKR2BL4.js} +1 -1
  61. package/dist/ui/{chunk-C5FRMXDS.js → chunk-TCRDGNM4.js} +1 -1
  62. package/dist/ui/chunk-TCWN5YRW.js +1 -0
  63. package/dist/ui/{chunk-U7LSFUHT.js → chunk-TZWCCNSA.js} +1 -1
  64. package/dist/ui/{chunk-2PTLQRTU.js → chunk-U5OXKKBN.js} +1 -1
  65. package/dist/ui/{chunk-O7ESOZQO.js → chunk-VZGDXWRK.js} +1 -1
  66. package/dist/ui/{chunk-3LEYSXZP.js → chunk-X3VDQDHP.js} +1 -1
  67. package/dist/ui/chunk-XBYMUPZF.js +19 -0
  68. package/dist/ui/{chunk-QRAFYIAW.js → chunk-XYXL5HSZ.js} +1 -1
  69. package/dist/ui/chunk-Y7RYSRP7.js +7 -0
  70. package/dist/ui/{chunk-WRA24P66.js.LEGAL.txt → chunk-Y7RYSRP7.js.LEGAL.txt} +1 -0
  71. package/dist/ui/chunk-YIKHJONY.js +1 -0
  72. package/dist/ui/{chunk-UCYWQEAS.js → chunk-ZD3ORGA6.js} +1 -1
  73. package/dist/ui/{chunk-YBHFGQ3Z.js → chunk-ZQDUWURP.js} +1 -1
  74. package/dist/ui/{chunk-PIJ3E47R.js → chunk-ZYSR5UIW.js} +1 -1
  75. package/dist/ui/ui.css +1 -1
  76. package/dist/ui/ui.js +1 -1
  77. package/package.json +3 -3
  78. package/dist/ui/AIPage-EO5WH25R.js +0 -1
  79. package/dist/ui/AssetsPage-ESLB4R3I.js +0 -1
  80. package/dist/ui/CollectionPage-MXN7XKUX.js +0 -1
  81. package/dist/ui/ComparePage-TY7VJVE3.js +0 -1
  82. package/dist/ui/DocumentPage-2HNNEGRI.js +0 -1
  83. package/dist/ui/EditReleasePage-DOMXJXCU.js +0 -1
  84. package/dist/ui/EmbeddedAIPage-U5LONYH2.js +0 -1
  85. package/dist/ui/EmbeddedDocumentPage-HYV5GPK6.js +0 -1
  86. package/dist/ui/LogsPage-6KV3CQLH.js +0 -1
  87. package/dist/ui/NewReleasePage-FXHPFUVG.js +0 -1
  88. package/dist/ui/ReleasePage-NLGRYJX7.js +0 -1
  89. package/dist/ui/SidebarToolsPage-FWG6TIDI.js +0 -1
  90. package/dist/ui/TaskPage-APNRUOYG.js +0 -1
  91. package/dist/ui/TasksPage-FTEELXVZ.js +0 -1
  92. package/dist/ui/chunk-235TRWJF.js +0 -81
  93. package/dist/ui/chunk-56NMZYX6.js +0 -19
  94. package/dist/ui/chunk-6WJQBFN5.js +0 -1
  95. package/dist/ui/chunk-EYJ6GKZR.js +0 -1
  96. package/dist/ui/chunk-G5647K25.js +0 -1
  97. package/dist/ui/chunk-OWYV43BT.js +0 -1
  98. package/dist/ui/chunk-QWB6MAPJ.js +0 -7
  99. package/dist/ui/chunk-VJRMR2JM.js +0 -1
  100. package/dist/ui/chunk-WRA24P66.js +0 -7
  101. package/dist/ui/chunk-Z3ZJJWFT.js +0 -1
  102. package/dist/ui/chunk-ZAJPNVYS.js +0 -1
  103. /package/dist/ui/{ImageEditorDialog-YDKOGVJV.js.LEGAL.txt → ImageEditorDialog-JDXMU2FC.js.LEGAL.txt} +0 -0
  104. /package/dist/ui/{chunk-ST6QNIWT.js.LEGAL.txt → chunk-6ZVMJXLE.js.LEGAL.txt} +0 -0
  105. /package/dist/ui/{chunk-235TRWJF.js.LEGAL.txt → chunk-7OU4ERTS.js.LEGAL.txt} +0 -0
@@ -1,4 +1,4 @@
1
- import{A as ce,B as xo,C as We,D as te,E as se,F as Be,G as ue,H as ie,I as ve,J as ye,K as xe,L as de,M as wo,N as Ee,O as Co,Q as Io,R as ko,S as So,X as To,Y as jo,Z as Ro,a as Ue,b as yt,c as _o,d as bt,e as $e,f as Nt,g as Ve,h as le,i as e,j as re,k as vt,l as fo,m as Ie,n as yo,o as _e,p as xt,q as nt,r as pe,s as Ne,t as bo,u as at,v as Je,w as wt,x as vo,y as I,z as k}from"./chunk-AAR7DBEN.js";import{a as Ct}from"./chunk-YDO2EDVY.js";import{S as mo,U as Ot,Y as ot,_ as ho}from"./chunk-ISUGBMXC.js";import{a as io,b as so,c as lo,g as co,j as uo,n as we,o as po,p as ft,q as At,v as Oe}from"./chunk-XOWWPE7X.js";import{Ga as go,c as jt,e as et,h as tt,k as _t,y as Rt}from"./chunk-WRA24P66.js";import{b as oa,d as na}from"./chunk-PVAE643M.js";var Oo=oa((Fl,Ao)=>{"use strict";function aa(t,o){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let n,a=0;return function(...i){clearTimeout(n);let c=Date.now(),s=c-a,g=o-s;g<=0?(a=c,t.apply(this,i)):n=setTimeout(()=>{a=Date.now(),t.apply(this,i)},g)}}Ao.exports=aa});Rt();var zo=na(Oo(),1);Rt();Rt();var Eo=(t,o,n)=>{if(!o.has(t))throw TypeError("Cannot "+n)},ge=(t,o,n)=>(Eo(t,o,"read from private field"),n?n.call(t):o.get(t)),Ae=(t,o,n)=>{if(o.has(t))throw TypeError("Cannot add the same private member more than once");o instanceof WeakSet?o.add(t):o.set(t,n)},ze=(t,o,n,a)=>(Eo(t,o,"write to private field"),a?a.call(t,n):o.set(t,n),n);function sa(t,o){return o!=null?(0,zo.default)(t,o):t}var Ce,It,kt,rt,it,st,Ge,Et,zt,la=class{constructor(t=[]){Ae(this,Ce,void 0),Ae(this,It,"ready"),Ae(this,kt,void 0),Ae(this,rt,new Set),Ae(this,it,new Set),Ae(this,st,new Set),this.pushMessage=o=>{ze(this,Ce,ge(this,Ce).concat(o)),ge(this,Ge).call(this)},this.popMessage=()=>{ze(this,Ce,ge(this,Ce).slice(0,-1)),ge(this,Ge).call(this)},this.replaceMessage=(o,n)=>{ze(this,Ce,[...ge(this,Ce).slice(0,o),this.snapshot(n),...ge(this,Ce).slice(o+1)]),ge(this,Ge).call(this)},this.snapshot=o=>structuredClone(o),this["~registerMessagesCallback"]=(o,n)=>{let a=n?sa(o,n):o;return ge(this,rt).add(a),()=>{ge(this,rt).delete(a)}},this["~registerStatusCallback"]=o=>(ge(this,it).add(o),()=>{ge(this,it).delete(o)}),this["~registerErrorCallback"]=o=>(ge(this,st).add(o),()=>{ge(this,st).delete(o)}),Ae(this,Ge,()=>{ge(this,rt).forEach(o=>o())}),Ae(this,Et,()=>{ge(this,it).forEach(o=>o())}),Ae(this,zt,()=>{ge(this,st).forEach(o=>o())}),ze(this,Ce,t)}get status(){return ge(this,It)}set status(t){ze(this,It,t),ge(this,Et).call(this)}get error(){return ge(this,kt)}set error(t){ze(this,kt,t),ge(this,zt).call(this)}get messages(){return ge(this,Ce)}set messages(t){ze(this,Ce,[...t]),ge(this,Ge).call(this)}};Ce=new WeakMap;It=new WeakMap;kt=new WeakMap;rt=new WeakMap;it=new WeakMap;st=new WeakMap;Ge=new WeakMap;Et=new WeakMap;zt=new WeakMap;var Ke,No=class extends So{constructor({messages:t,...o}){let n=new la(t);super({...o,state:n}),Ae(this,Ke,void 0),this["~registerMessagesCallback"]=(a,r)=>ge(this,Ke)["~registerMessagesCallback"](a,r),this["~registerStatusCallback"]=a=>ge(this,Ke)["~registerStatusCallback"](a),this["~registerErrorCallback"]=a=>ge(this,Ke)["~registerErrorCallback"](a),ze(this,Ke,n)}};Ke=new WeakMap;function Jl({experimental_throttle:t,resume:o=!1,...n}={}){let a=et("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(a.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});let r={...n,onToolCall:h=>{var v,_;return(_=(v=a.current).onToolCall)==null?void 0:_.call(v,h)},onData:h=>{var v,_;return(_=(v=a.current).onData)==null?void 0:_.call(v,h)},onFinish:h=>{var v,_;return(_=(v=a.current).onFinish)==null?void 0:_.call(v,h)},onError:h=>{var v,_;return(_=(v=a.current).onError)==null?void 0:_.call(v,h)},sendAutomaticallyWhen:h=>{var v,_,y;return(y=(_=(v=a.current).sendAutomaticallyWhen)==null?void 0:_.call(v,h))!=null?y:!1}},i=et("chat"in n?n.chat:new No(r));("chat"in n&&n.chat!==i.current||"id"in n&&i.current.id!==n.id)&&(i.current="chat"in n?n.chat:new No(r));let s=tt(h=>i.current["~registerMessagesCallback"](h,t),[t,i.current.id]),g=_t(s,()=>i.current.messages,()=>i.current.messages),m=_t(i.current["~registerStatusCallback"],()=>i.current.status,()=>i.current.status),l=_t(i.current["~registerErrorCallback"],()=>i.current.error,()=>i.current.error),p=tt(h=>{typeof h=="function"&&(h=h(i.current.messages)),i.current.messages=h},[i]);return jt(()=>{o&&i.current.resumeStream()},[o,i]),{id:i.current.id,messages:g,setMessages:p,sendMessage:i.current.sendMessage,regenerate:i.current.regenerate,clearError:i.current.clearError,stop:i.current.stop,error:l,resumeStream:i.current.resumeStream,status:m,addToolResult:i.current.addToolOutput,addToolOutput:i.current.addToolOutput,addToolApprovalResponse:i.current.addToolApprovalResponse}}function ec(t){let{size:o=14}=t,n=o*3.57,a=o*2;return go("div",{className:"BouncingLoader",style:{"--dot-size":`${o}px`,width:`${n}px`,height:`${a}px`}})}var ca="3.0.74",ua=I(()=>k(e.object({type:e.literal("error"),error:e.object({type:e.string(),message:e.string()})}))),Mo=ye({errorSchema:ua,errorToMessage:t=>t.error.message}),da=I(()=>k(e.object({type:e.literal("message"),id:e.string().nullish(),model:e.string().nullish(),content:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("text"),text:e.string(),citations:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("web_search_result_location"),cited_text:e.string(),url:e.string(),title:e.string(),encrypted_index:e.string()}),e.object({type:e.literal("page_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_page_number:e.number(),end_page_number:e.number()}),e.object({type:e.literal("char_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_char_index:e.number(),end_char_index:e.number()})])).optional()}),e.object({type:e.literal("thinking"),thinking:e.string(),signature:e.string()}),e.object({type:e.literal("redacted_thinking"),data:e.string()}),e.object({type:e.literal("compaction"),content:e.string()}),e.object({type:e.literal("tool_use"),id:e.string(),name:e.string(),input:e.unknown(),caller:e.union([e.object({type:e.literal("code_execution_20250825"),tool_id:e.string()}),e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()}),e.object({type:e.literal("server_tool_use"),id:e.string(),name:e.string(),input:e.record(e.string(),e.unknown()).nullish(),caller:e.union([e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()}),e.object({type:e.literal("mcp_tool_use"),id:e.string(),name:e.string(),input:e.unknown(),server_name:e.string()}),e.object({type:e.literal("mcp_tool_result"),tool_use_id:e.string(),is_error:e.boolean(),content:e.array(e.union([e.string(),e.object({type:e.literal("text"),text:e.string()})]))}),e.object({type:e.literal("web_fetch_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("web_fetch_result"),url:e.string(),retrieved_at:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),media_type:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),media_type:e.literal("text/plain"),data:e.string()})])})}),e.object({type:e.literal("web_fetch_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("web_search_tool_result"),tool_use_id:e.string(),content:e.union([e.array(e.object({type:e.literal("web_search_result"),url:e.string(),title:e.string(),encrypted_content:e.string(),page_age:e.string().nullish()})),e.object({type:e.literal("web_search_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("code_execution_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("encrypted_code_execution_result"),encrypted_stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("bash_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("text_editor_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})])}),e.object({type:e.literal("tool_search_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("tool_search_tool_search_result"),tool_references:e.array(e.object({type:e.literal("tool_reference"),tool_name:e.string()}))}),e.object({type:e.literal("tool_search_tool_result_error"),error_code:e.string()})])})])),stop_reason:e.string().nullish(),stop_sequence:e.string().nullish(),usage:e.looseObject({input_tokens:e.number(),output_tokens:e.number(),cache_creation_input_tokens:e.number().nullish(),cache_read_input_tokens:e.number().nullish(),iterations:e.array(e.object({type:e.union([e.literal("compaction"),e.literal("message")]),input_tokens:e.number(),output_tokens:e.number()})).nullish()}),container:e.object({expires_at:e.string(),id:e.string(),skills:e.array(e.object({type:e.union([e.literal("anthropic"),e.literal("custom")]),skill_id:e.string(),version:e.string()})).nullish()}).nullish(),context_management:e.object({applied_edits:e.array(e.union([e.object({type:e.literal("clear_tool_uses_20250919"),cleared_tool_uses:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("clear_thinking_20251015"),cleared_thinking_turns:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("compact_20260112")})]))}).nullish()}))),pa=I(()=>k(e.discriminatedUnion("type",[e.object({type:e.literal("message_start"),message:e.object({id:e.string().nullish(),model:e.string().nullish(),role:e.string().nullish(),usage:e.looseObject({input_tokens:e.number(),cache_creation_input_tokens:e.number().nullish(),cache_read_input_tokens:e.number().nullish()}),content:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("tool_use"),id:e.string(),name:e.string(),input:e.unknown(),caller:e.union([e.object({type:e.literal("code_execution_20250825"),tool_id:e.string()}),e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()})])).nullish(),stop_reason:e.string().nullish(),container:e.object({expires_at:e.string(),id:e.string()}).nullish()})}),e.object({type:e.literal("content_block_start"),index:e.number(),content_block:e.discriminatedUnion("type",[e.object({type:e.literal("text"),text:e.string()}),e.object({type:e.literal("thinking"),thinking:e.string()}),e.object({type:e.literal("tool_use"),id:e.string(),name:e.string(),input:e.record(e.string(),e.unknown()).optional(),caller:e.union([e.object({type:e.literal("code_execution_20250825"),tool_id:e.string()}),e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()}),e.object({type:e.literal("redacted_thinking"),data:e.string()}),e.object({type:e.literal("compaction"),content:e.string().nullish()}),e.object({type:e.literal("server_tool_use"),id:e.string(),name:e.string(),input:e.record(e.string(),e.unknown()).nullish(),caller:e.union([e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()}),e.object({type:e.literal("mcp_tool_use"),id:e.string(),name:e.string(),input:e.unknown(),server_name:e.string()}),e.object({type:e.literal("mcp_tool_result"),tool_use_id:e.string(),is_error:e.boolean(),content:e.array(e.union([e.string(),e.object({type:e.literal("text"),text:e.string()})]))}),e.object({type:e.literal("web_fetch_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("web_fetch_result"),url:e.string(),retrieved_at:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),media_type:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),media_type:e.literal("text/plain"),data:e.string()})])})}),e.object({type:e.literal("web_fetch_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("web_search_tool_result"),tool_use_id:e.string(),content:e.union([e.array(e.object({type:e.literal("web_search_result"),url:e.string(),title:e.string(),encrypted_content:e.string(),page_age:e.string().nullish()})),e.object({type:e.literal("web_search_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("code_execution_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("encrypted_code_execution_result"),encrypted_stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("bash_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("text_editor_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})])}),e.object({type:e.literal("tool_search_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("tool_search_tool_search_result"),tool_references:e.array(e.object({type:e.literal("tool_reference"),tool_name:e.string()}))}),e.object({type:e.literal("tool_search_tool_result_error"),error_code:e.string()})])})])}),e.object({type:e.literal("content_block_delta"),index:e.number(),delta:e.discriminatedUnion("type",[e.object({type:e.literal("input_json_delta"),partial_json:e.string()}),e.object({type:e.literal("text_delta"),text:e.string()}),e.object({type:e.literal("thinking_delta"),thinking:e.string()}),e.object({type:e.literal("signature_delta"),signature:e.string()}),e.object({type:e.literal("compaction_delta"),content:e.string().nullish()}),e.object({type:e.literal("citations_delta"),citation:e.discriminatedUnion("type",[e.object({type:e.literal("web_search_result_location"),cited_text:e.string(),url:e.string(),title:e.string(),encrypted_index:e.string()}),e.object({type:e.literal("page_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_page_number:e.number(),end_page_number:e.number()}),e.object({type:e.literal("char_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_char_index:e.number(),end_char_index:e.number()})])})])}),e.object({type:e.literal("content_block_stop"),index:e.number()}),e.object({type:e.literal("error"),error:e.object({type:e.string(),message:e.string()})}),e.object({type:e.literal("message_delta"),delta:e.object({stop_reason:e.string().nullish(),stop_sequence:e.string().nullish(),container:e.object({expires_at:e.string(),id:e.string(),skills:e.array(e.object({type:e.union([e.literal("anthropic"),e.literal("custom")]),skill_id:e.string(),version:e.string()})).nullish()}).nullish()}),usage:e.looseObject({input_tokens:e.number().nullish(),output_tokens:e.number(),cache_creation_input_tokens:e.number().nullish(),cache_read_input_tokens:e.number().nullish(),iterations:e.array(e.object({type:e.union([e.literal("compaction"),e.literal("message")]),input_tokens:e.number(),output_tokens:e.number()})).nullish()}),context_management:e.object({applied_edits:e.array(e.union([e.object({type:e.literal("clear_tool_uses_20250919"),cleared_tool_uses:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("clear_thinking_20251015"),cleared_thinking_turns:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("compact_20260112")})]))}).nullish()}),e.object({type:e.literal("message_stop")}),e.object({type:e.literal("ping")})]))),ma=I(()=>k(e.object({signature:e.string().optional(),redactedData:e.string().optional()}))),Po=e.object({citations:e.object({enabled:e.boolean()}).optional(),title:e.string().optional(),context:e.string().optional()}),Do=e.object({sendReasoning:e.boolean().optional(),structuredOutputMode:e.enum(["outputFormat","jsonTool","auto"]).optional(),thinking:e.discriminatedUnion("type",[e.object({type:e.literal("adaptive"),display:e.enum(["omitted","summarized"]).optional()}),e.object({type:e.literal("enabled"),budgetTokens:e.number().optional()}),e.object({type:e.literal("disabled")})]).optional(),disableParallelToolUse:e.boolean().optional(),cacheControl:e.object({type:e.literal("ephemeral"),ttl:e.union([e.literal("5m"),e.literal("1h")]).optional()}).optional(),metadata:e.object({userId:e.string().optional()}).optional(),mcpServers:e.array(e.object({type:e.literal("url"),name:e.string(),url:e.string(),authorizationToken:e.string().nullish(),toolConfiguration:e.object({enabled:e.boolean().nullish(),allowedTools:e.array(e.string()).nullish()}).nullish()})).optional(),container:e.object({id:e.string().optional(),skills:e.array(e.object({type:e.union([e.literal("anthropic"),e.literal("custom")]),skillId:e.string(),version:e.string().optional()})).optional()}).optional(),toolStreaming:e.boolean().optional(),effort:e.enum(["low","medium","high","xhigh","max"]).optional(),taskBudget:e.object({type:e.literal("tokens"),total:e.number().int().min(2e4),remaining:e.number().int().min(0).optional()}).optional(),speed:e.enum(["fast","standard"]).optional(),inferenceGeo:e.enum(["us","global"]).optional(),anthropicBeta:e.array(e.string()).optional(),contextManagement:e.object({edits:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("clear_tool_uses_20250919"),trigger:e.discriminatedUnion("type",[e.object({type:e.literal("input_tokens"),value:e.number()}),e.object({type:e.literal("tool_uses"),value:e.number()})]).optional(),keep:e.object({type:e.literal("tool_uses"),value:e.number()}).optional(),clearAtLeast:e.object({type:e.literal("input_tokens"),value:e.number()}).optional(),clearToolInputs:e.boolean().optional(),excludeTools:e.array(e.string()).optional()}),e.object({type:e.literal("clear_thinking_20251015"),keep:e.union([e.literal("all"),e.object({type:e.literal("thinking_turns"),value:e.number()})]).optional()}),e.object({type:e.literal("compact_20260112"),trigger:e.object({type:e.literal("input_tokens"),value:e.number()}).optional(),pauseAfterCompaction:e.boolean().optional(),instructions:e.string().optional()})]))}).optional()}),qo=4;function ha(t){var o;let n=t?.anthropic;return(o=n?.cacheControl)!=null?o:n?.cache_control}var qt=class{constructor(){this.breakpointCount=0,this.warnings=[]}getCacheControl(t,o){let n=ha(t);if(n){if(!o.canCache){this.warnings.push({type:"unsupported",feature:"cache_control on non-cacheable context",details:`cache_control cannot be set on ${o.type}. It will be ignored.`});return}if(this.breakpointCount++,this.breakpointCount>qo){this.warnings.push({type:"unsupported",feature:"cacheControl breakpoint limit",details:`Maximum ${qo} cache breakpoints exceeded (found ${this.breakpointCount}). This breakpoint will be ignored.`});return}return n}}getWarnings(){return this.warnings}},ga=I(()=>k(e.object({maxCharacters:e.number().optional()}))),_a=I(()=>k(e.object({command:e.enum(["view","create","str_replace","insert"]),path:e.string(),file_text:e.string().optional(),insert_line:e.number().int().optional(),new_str:e.string().optional(),insert_text:e.string().optional(),old_str:e.string().optional(),view_range:e.array(e.number().int()).optional()}))),fa=ue({id:"anthropic.text_editor_20250728",inputSchema:_a}),ya=(t={})=>fa(t),ba=I(()=>k(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),userLocation:e.object({type:e.literal("approximate"),city:e.string().optional(),region:e.string().optional(),country:e.string().optional(),timezone:e.string().optional()}).optional()}))),va=I(()=>k(e.array(e.object({url:e.string(),title:e.string().nullable(),pageAge:e.string().nullable(),encryptedContent:e.string(),type:e.literal("web_search_result")})))),xa=I(()=>k(e.object({query:e.string()}))),wa=ie({id:"anthropic.web_search_20260209",inputSchema:xa,outputSchema:va,supportsDeferredResults:!0}),Ca=(t={})=>wa(t),Ia=I(()=>k(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),userLocation:e.object({type:e.literal("approximate"),city:e.string().optional(),region:e.string().optional(),country:e.string().optional(),timezone:e.string().optional()}).optional()}))),Ho=I(()=>k(e.array(e.object({url:e.string(),title:e.string().nullable(),pageAge:e.string().nullable(),encryptedContent:e.string(),type:e.literal("web_search_result")})))),ka=I(()=>k(e.object({query:e.string()}))),Sa=ie({id:"anthropic.web_search_20250305",inputSchema:ka,outputSchema:Ho,supportsDeferredResults:!0}),Ta=(t={})=>Sa(t),ja=I(()=>k(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),citations:e.object({enabled:e.boolean()}).optional(),maxContentTokens:e.number().optional()}))),Ra=I(()=>k(e.object({type:e.literal("web_fetch_result"),url:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),mediaType:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),mediaType:e.literal("text/plain"),data:e.string()})])}),retrievedAt:e.string().nullable()}))),Aa=I(()=>k(e.object({url:e.string()}))),Oa=ie({id:"anthropic.web_fetch_20260209",inputSchema:Aa,outputSchema:Ra,supportsDeferredResults:!0}),Na=(t={})=>Oa(t),Ea=I(()=>k(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),citations:e.object({enabled:e.boolean()}).optional(),maxContentTokens:e.number().optional()}))),Vo=I(()=>k(e.object({type:e.literal("web_fetch_result"),url:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),mediaType:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),mediaType:e.literal("text/plain"),data:e.string()})])}),retrievedAt:e.string().nullable()}))),za=I(()=>k(e.object({url:e.string()}))),Ma=ie({id:"anthropic.web_fetch_20250910",inputSchema:za,outputSchema:Vo,supportsDeferredResults:!0}),Pa=(t={})=>Ma(t);async function Da({tools:t,toolChoice:o,disableParallelToolUse:n,cacheControlValidator:a,supportsStructuredOutput:r,supportsStrictTools:i,defaultEagerInputStreaming:c=!1}){var s,g;t=t?.length?t:void 0;let m=[],l=new Set,p=a||new qt;if(t==null)return{tools:void 0,toolChoice:void 0,toolWarnings:m,betas:l};let h=[];for(let _ of t)switch(_.type){case"function":{let y=p.getCacheControl(_.providerOptions,{type:"tool definition",canCache:!0}),S=(s=_.providerOptions)==null?void 0:s.anthropic,C=(g=S?.eagerInputStreaming)!=null?g:c,b=S?.deferLoading,R=S?.allowedCallers;!i&&_.strict!=null&&m.push({type:"unsupported",feature:"strict",details:`Tool '${_.name}' has strict: ${_.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`}),h.push({name:_.name,description:_.description,input_schema:_.inputSchema,cache_control:y,...C?{eager_input_streaming:!0}:{},...i===!0&&_.strict!=null?{strict:_.strict}:{},...b!=null?{defer_loading:b}:{},...R!=null?{allowed_callers:R}:{},..._.inputExamples!=null?{input_examples:_.inputExamples.map(O=>O.input)}:{}}),r===!0&&l.add("structured-outputs-2025-11-13"),(_.inputExamples!=null||R!=null)&&l.add("advanced-tool-use-2025-11-20");break}case"provider":{switch(_.id){case"anthropic.code_execution_20250522":{l.add("code-execution-2025-05-22"),h.push({type:"code_execution_20250522",name:"code_execution",cache_control:void 0});break}case"anthropic.code_execution_20250825":{l.add("code-execution-2025-08-25"),h.push({type:"code_execution_20250825",name:"code_execution"});break}case"anthropic.code_execution_20260120":{h.push({type:"code_execution_20260120",name:"code_execution"});break}case"anthropic.computer_20250124":{l.add("computer-use-2025-01-24"),h.push({name:"computer",type:"computer_20250124",display_width_px:_.args.displayWidthPx,display_height_px:_.args.displayHeightPx,display_number:_.args.displayNumber,cache_control:void 0});break}case"anthropic.computer_20251124":{l.add("computer-use-2025-11-24"),h.push({name:"computer",type:"computer_20251124",display_width_px:_.args.displayWidthPx,display_height_px:_.args.displayHeightPx,display_number:_.args.displayNumber,enable_zoom:_.args.enableZoom,cache_control:void 0});break}case"anthropic.computer_20241022":{l.add("computer-use-2024-10-22"),h.push({name:"computer",type:"computer_20241022",display_width_px:_.args.displayWidthPx,display_height_px:_.args.displayHeightPx,display_number:_.args.displayNumber,cache_control:void 0});break}case"anthropic.text_editor_20250124":{l.add("computer-use-2025-01-24"),h.push({name:"str_replace_editor",type:"text_editor_20250124",cache_control:void 0});break}case"anthropic.text_editor_20241022":{l.add("computer-use-2024-10-22"),h.push({name:"str_replace_editor",type:"text_editor_20241022",cache_control:void 0});break}case"anthropic.text_editor_20250429":{l.add("computer-use-2025-01-24"),h.push({name:"str_replace_based_edit_tool",type:"text_editor_20250429",cache_control:void 0});break}case"anthropic.text_editor_20250728":{let y=await ce({value:_.args,schema:ga});h.push({name:"str_replace_based_edit_tool",type:"text_editor_20250728",max_characters:y.maxCharacters,cache_control:void 0});break}case"anthropic.bash_20250124":{l.add("computer-use-2025-01-24"),h.push({name:"bash",type:"bash_20250124",cache_control:void 0});break}case"anthropic.bash_20241022":{l.add("computer-use-2024-10-22"),h.push({name:"bash",type:"bash_20241022",cache_control:void 0});break}case"anthropic.memory_20250818":{l.add("context-management-2025-06-27"),h.push({name:"memory",type:"memory_20250818"});break}case"anthropic.web_fetch_20250910":{l.add("web-fetch-2025-09-10");let y=await ce({value:_.args,schema:Ea});h.push({type:"web_fetch_20250910",name:"web_fetch",max_uses:y.maxUses,allowed_domains:y.allowedDomains,blocked_domains:y.blockedDomains,citations:y.citations,max_content_tokens:y.maxContentTokens,cache_control:void 0});break}case"anthropic.web_fetch_20260209":{l.add("code-execution-web-tools-2026-02-09");let y=await ce({value:_.args,schema:ja});h.push({type:"web_fetch_20260209",name:"web_fetch",max_uses:y.maxUses,allowed_domains:y.allowedDomains,blocked_domains:y.blockedDomains,citations:y.citations,max_content_tokens:y.maxContentTokens,cache_control:void 0});break}case"anthropic.web_search_20250305":{let y=await ce({value:_.args,schema:Ia});h.push({type:"web_search_20250305",name:"web_search",max_uses:y.maxUses,allowed_domains:y.allowedDomains,blocked_domains:y.blockedDomains,user_location:y.userLocation,cache_control:void 0});break}case"anthropic.web_search_20260209":{l.add("code-execution-web-tools-2026-02-09");let y=await ce({value:_.args,schema:ba});h.push({type:"web_search_20260209",name:"web_search",max_uses:y.maxUses,allowed_domains:y.allowedDomains,blocked_domains:y.blockedDomains,user_location:y.userLocation,cache_control:void 0});break}case"anthropic.tool_search_regex_20251119":{h.push({type:"tool_search_tool_regex_20251119",name:"tool_search_tool_regex"});break}case"anthropic.tool_search_bm25_20251119":{h.push({type:"tool_search_tool_bm25_20251119",name:"tool_search_tool_bm25"});break}default:{m.push({type:"unsupported",feature:`provider-defined tool ${_.id}`});break}}break}default:{m.push({type:"unsupported",feature:`tool ${_}`});break}}if(o==null)return{tools:h,toolChoice:n?{type:"auto",disable_parallel_tool_use:n}:void 0,toolWarnings:m,betas:l};let v=o.type;switch(v){case"auto":return{tools:h,toolChoice:{type:"auto",disable_parallel_tool_use:n},toolWarnings:m,betas:l};case"required":return{tools:h,toolChoice:{type:"any",disable_parallel_tool_use:n},toolWarnings:m,betas:l};case"none":return{tools:void 0,toolChoice:void 0,toolWarnings:m,betas:l};case"tool":return{tools:h,toolChoice:{type:"tool",name:o.toolName,disable_parallel_tool_use:n},toolWarnings:m,betas:l};default:{let _=v;throw new le({functionality:`tool choice type: ${_}`})}}}function Uo({usage:t,rawUsage:o}){var n,a;let r=(n=t.cache_creation_input_tokens)!=null?n:0,i=(a=t.cache_read_input_tokens)!=null?a:0,c,s;if(t.iterations&&t.iterations.length>0){let g=t.iterations.reduce((m,l)=>({input:m.input+l.input_tokens,output:m.output+l.output_tokens}),{input:0,output:0});c=g.input,s=g.output}else c=t.input_tokens,s=t.output_tokens;return{inputTokens:{total:c+r+i,noCache:c,cacheRead:i,cacheWrite:r},outputTokens:{total:s,text:void 0,reasoning:void 0},raw:o??t}}var Jo=I(()=>k(e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}))),qa=I(()=>k(e.object({code:e.string()}))),Ua=ie({id:"anthropic.code_execution_20250522",inputSchema:qa,outputSchema:Jo}),$a=(t={})=>Ua(t),Wo=I(()=>k(e.discriminatedUnion("type",[e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})]))),La=I(()=>k(e.discriminatedUnion("type",[e.object({type:e.literal("programmatic-tool-call"),code:e.string()}),e.object({type:e.literal("bash_code_execution"),command:e.string()}),e.discriminatedUnion("command",[e.object({type:e.literal("text_editor_code_execution"),command:e.literal("view"),path:e.string()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("create"),path:e.string(),file_text:e.string().nullish()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("str_replace"),path:e.string(),old_str:e.string(),new_str:e.string()})])]))),Fa=ie({id:"anthropic.code_execution_20250825",inputSchema:La,outputSchema:Wo,supportsDeferredResults:!0}),Ha=(t={})=>Fa(t),Bo=I(()=>k(e.discriminatedUnion("type",[e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("encrypted_code_execution_result"),encrypted_stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})]))),Va=I(()=>k(e.discriminatedUnion("type",[e.object({type:e.literal("programmatic-tool-call"),code:e.string()}),e.object({type:e.literal("bash_code_execution"),command:e.string()}),e.discriminatedUnion("command",[e.object({type:e.literal("text_editor_code_execution"),command:e.literal("view"),path:e.string()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("create"),path:e.string(),file_text:e.string().nullish()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("str_replace"),path:e.string(),old_str:e.string(),new_str:e.string()})])]))),Ja=ie({id:"anthropic.code_execution_20260120",inputSchema:Va,outputSchema:Bo,supportsDeferredResults:!0}),Wa=(t={})=>Ja(t),Go=I(()=>k(e.array(e.object({type:e.literal("tool_reference"),toolName:e.string()})))),Ba=I(()=>k(e.object({pattern:e.string(),limit:e.number().optional()}))),Ga=ie({id:"anthropic.tool_search_regex_20251119",inputSchema:Ba,outputSchema:Go,supportsDeferredResults:!0}),Ka=(t={})=>Ga(t);function Ya(t){if(typeof t=="string")return new TextDecoder().decode(Ie(t));if(t instanceof Uint8Array)return new TextDecoder().decode(t);throw t instanceof URL?new le({functionality:"URL-based text documents are not supported for citations"}):new le({functionality:`unsupported data type for text documents: ${typeof t}`})}function Mt(t){return t instanceof URL||Xa(t)}function Xa(t){return typeof t=="string"&&/^https?:\/\//i.test(t)}function Pt(t){return t instanceof URL?t.toString():t}async function Qa({prompt:t,sendReasoning:o,warnings:n,cacheControlValidator:a,toolNameMapping:r}){var i,c,s,g,m,l,p,h,v,_,y,S,C,b,R,O,V,L,P;let f=new Set,u=Za(t),H=a||new qt,U,W=[];async function Z(A){var $,j;let E=await te({provider:"anthropic",providerOptions:A,schema:Po});return(j=($=E?.citations)==null?void 0:$.enabled)!=null?j:!1}async function q(A){let $=await te({provider:"anthropic",providerOptions:A,schema:Po});return{title:$?.title,context:$?.context}}for(let A=0;A<u.length;A++){let $=u[A],j=A===u.length-1,E=$.type;switch(E){case"system":{if(U!=null)throw new le({functionality:"Multiple system messages that are separated by user/assistant messages"});U=$.messages.map(({content:D,providerOptions:J})=>({type:"text",text:D,cache_control:H.getCacheControl(J,{type:"system message",canCache:!0})}));break}case"user":{let D=[];for(let J of $.messages){let{role:z,content:B}=J;switch(z){case"user":{for(let ae=0;ae<B.length;ae++){let K=B[ae],ee=ae===B.length-1,w=(i=H.getCacheControl(K.providerOptions,{type:"user message part",canCache:!0}))!=null?i:ee?H.getCacheControl(J.providerOptions,{type:"user message",canCache:!0}):void 0;switch(K.type){case"text":{D.push({type:"text",text:K.text,cache_control:w});break}case"file":{if(K.mediaType.startsWith("image/"))D.push({type:"image",source:Mt(K.data)?{type:"url",url:Pt(K.data)}:{type:"base64",media_type:K.mediaType==="image/*"?"image/jpeg":K.mediaType,data:_e(K.data)},cache_control:w});else if(K.mediaType==="application/pdf"){f.add("pdfs-2024-09-25");let Y=await Z(K.providerOptions),G=await q(K.providerOptions);D.push({type:"document",source:Mt(K.data)?{type:"url",url:Pt(K.data)}:{type:"base64",media_type:"application/pdf",data:_e(K.data)},title:(c=G.title)!=null?c:K.filename,...G.context&&{context:G.context},...Y&&{citations:{enabled:!0}},cache_control:w})}else if(K.mediaType==="text/plain"){let Y=await Z(K.providerOptions),G=await q(K.providerOptions);D.push({type:"document",source:Mt(K.data)?{type:"url",url:Pt(K.data)}:{type:"text",media_type:"text/plain",data:Ya(K.data)},title:(s=G.title)!=null?s:K.filename,...G.context&&{context:G.context},...Y&&{citations:{enabled:!0}},cache_control:w})}else throw new le({functionality:`media type: ${K.mediaType}`});break}}}break}case"tool":{for(let ae=0;ae<B.length;ae++){let K=B[ae];if(K.type==="tool-approval-response")continue;let ee=ae===B.length-1,w=(g=H.getCacheControl(K.providerOptions,{type:"tool result part",canCache:!0}))!=null?g:ee?H.getCacheControl(J.providerOptions,{type:"tool result message",canCache:!0}):void 0,Y=K.output,G;switch(Y.type){case"content":G=Y.value.map(Q=>{var T;switch(Q.type){case"text":return{type:"text",text:Q.text};case"image-data":return{type:"image",source:{type:"base64",media_type:Q.mediaType,data:Q.data}};case"image-url":return{type:"image",source:{type:"url",url:Q.url}};case"file-url":return{type:"document",source:{type:"url",url:Q.url}};case"file-data":{if(Q.mediaType==="application/pdf")return f.add("pdfs-2024-09-25"),{type:"document",source:{type:"base64",media_type:Q.mediaType,data:Q.data}};n.push({type:"other",message:`unsupported tool content part type: ${Q.type} with media type: ${Q.mediaType}`});return}case"custom":{let M=(T=Q.providerOptions)==null?void 0:T.anthropic;if(M?.type==="tool-reference")return{type:"tool_reference",tool_name:M.toolName};n.push({type:"other",message:"unsupported custom tool content part"});return}default:{n.push({type:"other",message:`unsupported tool content part type: ${Q.type}`});return}}}).filter(at);break;case"text":case"error-text":G=Y.value;break;case"execution-denied":G=(m=Y.reason)!=null?m:"Tool execution denied.";break;default:G=JSON.stringify(Y.value);break}D.push({type:"tool_result",tool_use_id:K.toolCallId,content:G,is_error:Y.type==="error-text"||Y.type==="error-json"?!0:void 0,cache_control:w})}break}default:{let ae=z;throw new Error(`Unsupported role: ${ae}`)}}}W.push({role:"user",content:D});break}case"assistant":{let D=[],J=new Set;for(let z=0;z<$.messages.length;z++){let B=$.messages[z],ae=z===$.messages.length-1,{content:K}=B;for(let ee=0;ee<K.length;ee++){let w=K[ee],Y=ee===K.length-1,G=(l=H.getCacheControl(w.providerOptions,{type:"assistant message part",canCache:!0}))!=null?l:Y?H.getCacheControl(B.providerOptions,{type:"assistant message",canCache:!0}):void 0;switch(w.type){case"text":{let Q=(p=w.providerOptions)==null?void 0:p.anthropic;Q?.type==="compaction"?D.push({type:"compaction",content:w.text,cache_control:G}):D.push({type:"text",text:j&&ae&&Y?w.text.trim():w.text,cache_control:G});break}case"reasoning":{if(o){let Q=await te({provider:"anthropic",providerOptions:w.providerOptions,schema:ma});Q!=null?Q.signature!=null?(H.getCacheControl(w.providerOptions,{type:"thinking block",canCache:!1}),D.push({type:"thinking",thinking:w.text,signature:Q.signature})):Q.redactedData!=null?(H.getCacheControl(w.providerOptions,{type:"redacted thinking block",canCache:!1}),D.push({type:"redacted_thinking",data:Q.redactedData})):n.push({type:"other",message:"unsupported reasoning metadata"}):n.push({type:"other",message:"unsupported reasoning metadata"})}else n.push({type:"other",message:"sending reasoning content is disabled for this model"});break}case"tool-call":{if(w.providerExecuted){let M=r.toProviderToolName(w.toolName);if(((v=(h=w.providerOptions)==null?void 0:h.anthropic)==null?void 0:v.type)==="mcp-tool-use"){J.add(w.toolCallId);let x=(y=(_=w.providerOptions)==null?void 0:_.anthropic)==null?void 0:y.serverName;if(x==null||typeof x!="string"){n.push({type:"other",message:"mcp tool use server name is required and must be a string"});break}D.push({type:"mcp_tool_use",id:w.toolCallId,name:w.toolName,input:w.input,server_name:x,cache_control:G})}else if(M==="code_execution"&&w.input!=null&&typeof w.input=="object"&&"type"in w.input&&typeof w.input.type=="string"&&(w.input.type==="bash_code_execution"||w.input.type==="text_editor_code_execution"))D.push({type:"server_tool_use",id:w.toolCallId,name:w.input.type,input:w.input,cache_control:G});else if(M==="code_execution"&&w.input!=null&&typeof w.input=="object"&&"type"in w.input&&w.input.type==="programmatic-tool-call"){let{type:x,...ne}=w.input;D.push({type:"server_tool_use",id:w.toolCallId,name:"code_execution",input:ne,cache_control:G})}else M==="code_execution"||M==="web_fetch"||M==="web_search"?D.push({type:"server_tool_use",id:w.toolCallId,name:M,input:w.input,cache_control:G}):M==="tool_search_tool_regex"||M==="tool_search_tool_bm25"?D.push({type:"server_tool_use",id:w.toolCallId,name:M,input:w.input,cache_control:G}):n.push({type:"other",message:`provider executed tool call for tool ${w.toolName} is not supported`});break}let Q=(S=w.providerOptions)==null?void 0:S.anthropic,T=Q?.caller?(Q.caller.type==="code_execution_20250825"||Q.caller.type==="code_execution_20260120")&&Q.caller.toolId?{type:Q.caller.type,tool_id:Q.caller.toolId}:Q.caller.type==="direct"?{type:"direct"}:void 0:void 0;D.push({type:"tool_use",id:w.toolCallId,name:w.toolName,input:w.input,...T&&{caller:T},cache_control:G});break}case"tool-result":{let Q=r.toProviderToolName(w.toolName);if(J.has(w.toolCallId)){let T=w.output;if(T.type!=="json"&&T.type!=="error-json"){n.push({type:"other",message:`provider executed tool result output type ${T.type} for tool ${w.toolName} is not supported`});break}D.push({type:"mcp_tool_result",tool_use_id:w.toolCallId,is_error:T.type==="error-json",content:T.value,cache_control:G})}else if(Q==="code_execution"){let T=w.output;if(T.type==="error-text"||T.type==="error-json"){let M={};try{typeof T.value=="string"?M=JSON.parse(T.value):typeof T.value=="object"&&T.value!==null&&(M=T.value)}catch{}M.type==="code_execution_tool_result_error"?D.push({type:"code_execution_tool_result",tool_use_id:w.toolCallId,content:{type:"code_execution_tool_result_error",error_code:(C=M.errorCode)!=null?C:"unknown"},cache_control:G}):D.push({type:"bash_code_execution_tool_result",tool_use_id:w.toolCallId,cache_control:G,content:{type:"bash_code_execution_tool_result_error",error_code:(b=M.errorCode)!=null?b:"unknown"}});break}if(T.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${T.type} for tool ${w.toolName} is not supported`});break}if(T.value==null||typeof T.value!="object"||!("type"in T.value)||typeof T.value.type!="string"){n.push({type:"other",message:`provider executed tool result output value is not a valid code execution result for tool ${w.toolName}`});break}if(T.value.type==="code_execution_result"){let M=await ce({value:T.value,schema:Jo});D.push({type:"code_execution_tool_result",tool_use_id:w.toolCallId,content:{type:M.type,stdout:M.stdout,stderr:M.stderr,return_code:M.return_code,content:(R=M.content)!=null?R:[]},cache_control:G})}else if(T.value.type==="encrypted_code_execution_result"){let M=await ce({value:T.value,schema:Bo});M.type==="encrypted_code_execution_result"&&D.push({type:"code_execution_tool_result",tool_use_id:w.toolCallId,content:{type:M.type,encrypted_stdout:M.encrypted_stdout,stderr:M.stderr,return_code:M.return_code,content:(O=M.content)!=null?O:[]},cache_control:G})}else{let M=await ce({value:T.value,schema:Wo});M.type==="code_execution_result"?D.push({type:"code_execution_tool_result",tool_use_id:w.toolCallId,content:{type:M.type,stdout:M.stdout,stderr:M.stderr,return_code:M.return_code,content:(V=M.content)!=null?V:[]},cache_control:G}):M.type==="bash_code_execution_result"||M.type==="bash_code_execution_tool_result_error"?D.push({type:"bash_code_execution_tool_result",tool_use_id:w.toolCallId,cache_control:G,content:M}):D.push({type:"text_editor_code_execution_tool_result",tool_use_id:w.toolCallId,cache_control:G,content:M})}break}if(Q==="web_fetch"){let T=w.output;if(T.type==="error-json"){let N={};try{typeof T.value=="string"?N=JSON.parse(T.value):typeof T.value=="object"&&T.value!==null&&(N=T.value)}catch{let ne=(L=T.value)==null?void 0:L.errorCode;N={errorCode:typeof ne=="string"?ne:"unavailable"}}D.push({type:"web_fetch_tool_result",tool_use_id:w.toolCallId,content:{type:"web_fetch_tool_result_error",error_code:(P=N.errorCode)!=null?P:"unavailable"},cache_control:G});break}if(T.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${T.type} for tool ${w.toolName} is not supported`});break}let M=await ce({value:T.value,schema:Vo});D.push({type:"web_fetch_tool_result",tool_use_id:w.toolCallId,content:{type:"web_fetch_result",url:M.url,retrieved_at:M.retrievedAt,content:{type:"document",title:M.content.title,citations:M.content.citations,source:{type:M.content.source.type,media_type:M.content.source.mediaType,data:M.content.source.data}}},cache_control:G});break}if(Q==="web_search"){let T=w.output;if(T.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${T.type} for tool ${w.toolName} is not supported`});break}let M=await ce({value:T.value,schema:Ho});D.push({type:"web_search_tool_result",tool_use_id:w.toolCallId,content:M.map(N=>({url:N.url,title:N.title,page_age:N.pageAge,encrypted_content:N.encryptedContent,type:N.type})),cache_control:G});break}if(Q==="tool_search_tool_regex"||Q==="tool_search_tool_bm25"){let T=w.output;if(T.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${T.type} for tool ${w.toolName} is not supported`});break}let N=(await ce({value:T.value,schema:Go})).map(x=>({type:"tool_reference",tool_name:x.toolName}));D.push({type:"tool_search_tool_result",tool_use_id:w.toolCallId,content:{type:"tool_search_tool_search_result",tool_references:N},cache_control:G});break}n.push({type:"other",message:`provider executed tool result for tool ${w.toolName} is not supported`});break}}}}W.push({role:"assistant",content:D});break}default:{let D=E;throw new Error(`content type: ${D}`)}}}return{prompt:{system:U,messages:W},betas:f}}function Za(t){let o=[],n;for(let a of t){let{role:r}=a;switch(r){case"system":{n?.type!=="system"&&(n={type:"system",messages:[]},o.push(n)),n.messages.push(a);break}case"assistant":{n?.type!=="assistant"&&(n={type:"assistant",messages:[]},o.push(n)),n.messages.push(a);break}case"user":{n?.type!=="user"&&(n={type:"user",messages:[]},o.push(n)),n.messages.push(a);break}case"tool":{n?.type!=="user"&&(n={type:"user",messages:[]},o.push(n)),n.messages.push(a);break}default:{let i=r;throw new Error(`Unsupported role: ${i}`)}}}return o}function Dt({finishReason:t,isJsonResponseFromTool:o}){switch(t){case"pause_turn":case"end_turn":case"stop_sequence":return"stop";case"refusal":return"content-filter";case"tool_use":return o?"stop":"tool-calls";case"max_tokens":case"model_context_window_exceeded":return"length";case"compaction":return"other";default:return"other"}}var Ko=new Set(["date-time","time","date","duration","email","hostname","uri","ipv4","ipv6","uuid"]),er=["minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","minLength","maxLength","pattern","minItems","maxItems","uniqueItems","minProperties","maxProperties","not"];function tr(t){return Yo(t)}function Me(t){return typeof t=="boolean"||!rr(t)?t:Yo(t)}function Yo(t){let o={},n=t;if(t.$ref!=null)return{$ref:t.$ref};if(t.$schema!=null&&(o.$schema=t.$schema),t.$id!=null&&(o.$id=t.$id),t.title!=null&&(o.title=t.title),t.description!=null&&(o.description=t.description),t.default!==void 0&&(o.default=t.default),t.const!==void 0&&(o.const=t.const),t.enum!=null&&(o.enum=t.enum),t.type!=null&&(o.type=t.type),t.anyOf!=null?o.anyOf=t.anyOf.map(Me):t.oneOf!=null&&(o.anyOf=t.oneOf.map(Me)),t.allOf!=null&&(o.allOf=t.allOf.map(Me)),t.definitions!=null&&(o.definitions=Object.fromEntries(Object.entries(t.definitions).map(([r,i])=>[r,Me(i)]))),n.$defs!=null){let r=o;r.$defs=Object.fromEntries(Object.entries(n.$defs).map(([i,c])=>[i,Me(c)]))}(t.type==="object"||t.properties!=null)&&(t.properties!=null&&(o.properties=Object.fromEntries(Object.entries(t.properties).map(([r,i])=>[r,Me(i)]))),o.additionalProperties=!1,t.required!=null&&(o.required=t.required)),t.items!=null&&(o.items=Array.isArray(t.items)?t.items.map(Me):Me(t.items)),typeof t.format=="string"&&Ko.has(t.format)&&(o.format=t.format);let a=or(t);return a!=null&&(o.description=o.description==null?a:`${o.description}
1
+ import{A as ce,B as xo,C as We,D as te,E as se,F as Be,G as ue,H as ie,I as ve,J as ye,K as xe,L as de,M as wo,N as Ee,O as Co,Q as Io,R as ko,S as So,X as To,Y as jo,Z as Ro,a as Ue,b as yt,c as _o,d as bt,e as $e,f as Nt,g as Ve,h as le,i as e,j as re,k as vt,l as fo,m as Ie,n as yo,o as _e,p as xt,q as nt,r as pe,s as Ne,t as bo,u as at,v as Je,w as wt,x as vo,y as I,z as k}from"./chunk-AAR7DBEN.js";import{a as Ct}from"./chunk-YDO2EDVY.js";import{S as mo,U as Ot,Y as ot,_ as ho}from"./chunk-ISUGBMXC.js";import{a as io,b as so,c as lo,g as co,j as uo,n as we,o as po,p as ft,q as At,v as Oe}from"./chunk-XOWWPE7X.js";import{c as jt,e as et,fd as go,h as tt,k as _t,y as Rt}from"./chunk-Y7RYSRP7.js";import{b as oa,d as na}from"./chunk-PVAE643M.js";var Oo=oa((Fl,Ao)=>{"use strict";function aa(t,o){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let n,a=0;return function(...i){clearTimeout(n);let c=Date.now(),s=c-a,g=o-s;g<=0?(a=c,t.apply(this,i)):n=setTimeout(()=>{a=Date.now(),t.apply(this,i)},g)}}Ao.exports=aa});Rt();var zo=na(Oo(),1);Rt();Rt();var Eo=(t,o,n)=>{if(!o.has(t))throw TypeError("Cannot "+n)},ge=(t,o,n)=>(Eo(t,o,"read from private field"),n?n.call(t):o.get(t)),Ae=(t,o,n)=>{if(o.has(t))throw TypeError("Cannot add the same private member more than once");o instanceof WeakSet?o.add(t):o.set(t,n)},ze=(t,o,n,a)=>(Eo(t,o,"write to private field"),a?a.call(t,n):o.set(t,n),n);function sa(t,o){return o!=null?(0,zo.default)(t,o):t}var Ce,It,kt,rt,it,st,Ge,Et,zt,la=class{constructor(t=[]){Ae(this,Ce,void 0),Ae(this,It,"ready"),Ae(this,kt,void 0),Ae(this,rt,new Set),Ae(this,it,new Set),Ae(this,st,new Set),this.pushMessage=o=>{ze(this,Ce,ge(this,Ce).concat(o)),ge(this,Ge).call(this)},this.popMessage=()=>{ze(this,Ce,ge(this,Ce).slice(0,-1)),ge(this,Ge).call(this)},this.replaceMessage=(o,n)=>{ze(this,Ce,[...ge(this,Ce).slice(0,o),this.snapshot(n),...ge(this,Ce).slice(o+1)]),ge(this,Ge).call(this)},this.snapshot=o=>structuredClone(o),this["~registerMessagesCallback"]=(o,n)=>{let a=n?sa(o,n):o;return ge(this,rt).add(a),()=>{ge(this,rt).delete(a)}},this["~registerStatusCallback"]=o=>(ge(this,it).add(o),()=>{ge(this,it).delete(o)}),this["~registerErrorCallback"]=o=>(ge(this,st).add(o),()=>{ge(this,st).delete(o)}),Ae(this,Ge,()=>{ge(this,rt).forEach(o=>o())}),Ae(this,Et,()=>{ge(this,it).forEach(o=>o())}),Ae(this,zt,()=>{ge(this,st).forEach(o=>o())}),ze(this,Ce,t)}get status(){return ge(this,It)}set status(t){ze(this,It,t),ge(this,Et).call(this)}get error(){return ge(this,kt)}set error(t){ze(this,kt,t),ge(this,zt).call(this)}get messages(){return ge(this,Ce)}set messages(t){ze(this,Ce,[...t]),ge(this,Ge).call(this)}};Ce=new WeakMap;It=new WeakMap;kt=new WeakMap;rt=new WeakMap;it=new WeakMap;st=new WeakMap;Ge=new WeakMap;Et=new WeakMap;zt=new WeakMap;var Ke,No=class extends So{constructor({messages:t,...o}){let n=new la(t);super({...o,state:n}),Ae(this,Ke,void 0),this["~registerMessagesCallback"]=(a,r)=>ge(this,Ke)["~registerMessagesCallback"](a,r),this["~registerStatusCallback"]=a=>ge(this,Ke)["~registerStatusCallback"](a),this["~registerErrorCallback"]=a=>ge(this,Ke)["~registerErrorCallback"](a),ze(this,Ke,n)}};Ke=new WeakMap;function Jl({experimental_throttle:t,resume:o=!1,...n}={}){let a=et("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(a.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});let r={...n,onToolCall:h=>{var v,_;return(_=(v=a.current).onToolCall)==null?void 0:_.call(v,h)},onData:h=>{var v,_;return(_=(v=a.current).onData)==null?void 0:_.call(v,h)},onFinish:h=>{var v,_;return(_=(v=a.current).onFinish)==null?void 0:_.call(v,h)},onError:h=>{var v,_;return(_=(v=a.current).onError)==null?void 0:_.call(v,h)},sendAutomaticallyWhen:h=>{var v,_,y;return(y=(_=(v=a.current).sendAutomaticallyWhen)==null?void 0:_.call(v,h))!=null?y:!1}},i=et("chat"in n?n.chat:new No(r));("chat"in n&&n.chat!==i.current||"id"in n&&i.current.id!==n.id)&&(i.current="chat"in n?n.chat:new No(r));let s=tt(h=>i.current["~registerMessagesCallback"](h,t),[t,i.current.id]),g=_t(s,()=>i.current.messages,()=>i.current.messages),m=_t(i.current["~registerStatusCallback"],()=>i.current.status,()=>i.current.status),l=_t(i.current["~registerErrorCallback"],()=>i.current.error,()=>i.current.error),p=tt(h=>{typeof h=="function"&&(h=h(i.current.messages)),i.current.messages=h},[i]);return jt(()=>{o&&i.current.resumeStream()},[o,i]),{id:i.current.id,messages:g,setMessages:p,sendMessage:i.current.sendMessage,regenerate:i.current.regenerate,clearError:i.current.clearError,stop:i.current.stop,error:l,resumeStream:i.current.resumeStream,status:m,addToolResult:i.current.addToolOutput,addToolOutput:i.current.addToolOutput,addToolApprovalResponse:i.current.addToolApprovalResponse}}function ec(t){let{size:o=14}=t,n=o*3.57,a=o*2;return go("div",{className:"BouncingLoader",style:{"--dot-size":`${o}px`,width:`${n}px`,height:`${a}px`}})}var ca="3.0.74",ua=I(()=>k(e.object({type:e.literal("error"),error:e.object({type:e.string(),message:e.string()})}))),Mo=ye({errorSchema:ua,errorToMessage:t=>t.error.message}),da=I(()=>k(e.object({type:e.literal("message"),id:e.string().nullish(),model:e.string().nullish(),content:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("text"),text:e.string(),citations:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("web_search_result_location"),cited_text:e.string(),url:e.string(),title:e.string(),encrypted_index:e.string()}),e.object({type:e.literal("page_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_page_number:e.number(),end_page_number:e.number()}),e.object({type:e.literal("char_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_char_index:e.number(),end_char_index:e.number()})])).optional()}),e.object({type:e.literal("thinking"),thinking:e.string(),signature:e.string()}),e.object({type:e.literal("redacted_thinking"),data:e.string()}),e.object({type:e.literal("compaction"),content:e.string()}),e.object({type:e.literal("tool_use"),id:e.string(),name:e.string(),input:e.unknown(),caller:e.union([e.object({type:e.literal("code_execution_20250825"),tool_id:e.string()}),e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()}),e.object({type:e.literal("server_tool_use"),id:e.string(),name:e.string(),input:e.record(e.string(),e.unknown()).nullish(),caller:e.union([e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()}),e.object({type:e.literal("mcp_tool_use"),id:e.string(),name:e.string(),input:e.unknown(),server_name:e.string()}),e.object({type:e.literal("mcp_tool_result"),tool_use_id:e.string(),is_error:e.boolean(),content:e.array(e.union([e.string(),e.object({type:e.literal("text"),text:e.string()})]))}),e.object({type:e.literal("web_fetch_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("web_fetch_result"),url:e.string(),retrieved_at:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),media_type:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),media_type:e.literal("text/plain"),data:e.string()})])})}),e.object({type:e.literal("web_fetch_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("web_search_tool_result"),tool_use_id:e.string(),content:e.union([e.array(e.object({type:e.literal("web_search_result"),url:e.string(),title:e.string(),encrypted_content:e.string(),page_age:e.string().nullish()})),e.object({type:e.literal("web_search_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("code_execution_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("encrypted_code_execution_result"),encrypted_stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("bash_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("text_editor_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})])}),e.object({type:e.literal("tool_search_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("tool_search_tool_search_result"),tool_references:e.array(e.object({type:e.literal("tool_reference"),tool_name:e.string()}))}),e.object({type:e.literal("tool_search_tool_result_error"),error_code:e.string()})])})])),stop_reason:e.string().nullish(),stop_sequence:e.string().nullish(),usage:e.looseObject({input_tokens:e.number(),output_tokens:e.number(),cache_creation_input_tokens:e.number().nullish(),cache_read_input_tokens:e.number().nullish(),iterations:e.array(e.object({type:e.union([e.literal("compaction"),e.literal("message")]),input_tokens:e.number(),output_tokens:e.number()})).nullish()}),container:e.object({expires_at:e.string(),id:e.string(),skills:e.array(e.object({type:e.union([e.literal("anthropic"),e.literal("custom")]),skill_id:e.string(),version:e.string()})).nullish()}).nullish(),context_management:e.object({applied_edits:e.array(e.union([e.object({type:e.literal("clear_tool_uses_20250919"),cleared_tool_uses:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("clear_thinking_20251015"),cleared_thinking_turns:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("compact_20260112")})]))}).nullish()}))),pa=I(()=>k(e.discriminatedUnion("type",[e.object({type:e.literal("message_start"),message:e.object({id:e.string().nullish(),model:e.string().nullish(),role:e.string().nullish(),usage:e.looseObject({input_tokens:e.number(),cache_creation_input_tokens:e.number().nullish(),cache_read_input_tokens:e.number().nullish()}),content:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("tool_use"),id:e.string(),name:e.string(),input:e.unknown(),caller:e.union([e.object({type:e.literal("code_execution_20250825"),tool_id:e.string()}),e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()})])).nullish(),stop_reason:e.string().nullish(),container:e.object({expires_at:e.string(),id:e.string()}).nullish()})}),e.object({type:e.literal("content_block_start"),index:e.number(),content_block:e.discriminatedUnion("type",[e.object({type:e.literal("text"),text:e.string()}),e.object({type:e.literal("thinking"),thinking:e.string()}),e.object({type:e.literal("tool_use"),id:e.string(),name:e.string(),input:e.record(e.string(),e.unknown()).optional(),caller:e.union([e.object({type:e.literal("code_execution_20250825"),tool_id:e.string()}),e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()}),e.object({type:e.literal("redacted_thinking"),data:e.string()}),e.object({type:e.literal("compaction"),content:e.string().nullish()}),e.object({type:e.literal("server_tool_use"),id:e.string(),name:e.string(),input:e.record(e.string(),e.unknown()).nullish(),caller:e.union([e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()}),e.object({type:e.literal("mcp_tool_use"),id:e.string(),name:e.string(),input:e.unknown(),server_name:e.string()}),e.object({type:e.literal("mcp_tool_result"),tool_use_id:e.string(),is_error:e.boolean(),content:e.array(e.union([e.string(),e.object({type:e.literal("text"),text:e.string()})]))}),e.object({type:e.literal("web_fetch_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("web_fetch_result"),url:e.string(),retrieved_at:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),media_type:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),media_type:e.literal("text/plain"),data:e.string()})])})}),e.object({type:e.literal("web_fetch_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("web_search_tool_result"),tool_use_id:e.string(),content:e.union([e.array(e.object({type:e.literal("web_search_result"),url:e.string(),title:e.string(),encrypted_content:e.string(),page_age:e.string().nullish()})),e.object({type:e.literal("web_search_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("code_execution_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("encrypted_code_execution_result"),encrypted_stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("bash_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("text_editor_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})])}),e.object({type:e.literal("tool_search_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("tool_search_tool_search_result"),tool_references:e.array(e.object({type:e.literal("tool_reference"),tool_name:e.string()}))}),e.object({type:e.literal("tool_search_tool_result_error"),error_code:e.string()})])})])}),e.object({type:e.literal("content_block_delta"),index:e.number(),delta:e.discriminatedUnion("type",[e.object({type:e.literal("input_json_delta"),partial_json:e.string()}),e.object({type:e.literal("text_delta"),text:e.string()}),e.object({type:e.literal("thinking_delta"),thinking:e.string()}),e.object({type:e.literal("signature_delta"),signature:e.string()}),e.object({type:e.literal("compaction_delta"),content:e.string().nullish()}),e.object({type:e.literal("citations_delta"),citation:e.discriminatedUnion("type",[e.object({type:e.literal("web_search_result_location"),cited_text:e.string(),url:e.string(),title:e.string(),encrypted_index:e.string()}),e.object({type:e.literal("page_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_page_number:e.number(),end_page_number:e.number()}),e.object({type:e.literal("char_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_char_index:e.number(),end_char_index:e.number()})])})])}),e.object({type:e.literal("content_block_stop"),index:e.number()}),e.object({type:e.literal("error"),error:e.object({type:e.string(),message:e.string()})}),e.object({type:e.literal("message_delta"),delta:e.object({stop_reason:e.string().nullish(),stop_sequence:e.string().nullish(),container:e.object({expires_at:e.string(),id:e.string(),skills:e.array(e.object({type:e.union([e.literal("anthropic"),e.literal("custom")]),skill_id:e.string(),version:e.string()})).nullish()}).nullish()}),usage:e.looseObject({input_tokens:e.number().nullish(),output_tokens:e.number(),cache_creation_input_tokens:e.number().nullish(),cache_read_input_tokens:e.number().nullish(),iterations:e.array(e.object({type:e.union([e.literal("compaction"),e.literal("message")]),input_tokens:e.number(),output_tokens:e.number()})).nullish()}),context_management:e.object({applied_edits:e.array(e.union([e.object({type:e.literal("clear_tool_uses_20250919"),cleared_tool_uses:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("clear_thinking_20251015"),cleared_thinking_turns:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("compact_20260112")})]))}).nullish()}),e.object({type:e.literal("message_stop")}),e.object({type:e.literal("ping")})]))),ma=I(()=>k(e.object({signature:e.string().optional(),redactedData:e.string().optional()}))),Po=e.object({citations:e.object({enabled:e.boolean()}).optional(),title:e.string().optional(),context:e.string().optional()}),Do=e.object({sendReasoning:e.boolean().optional(),structuredOutputMode:e.enum(["outputFormat","jsonTool","auto"]).optional(),thinking:e.discriminatedUnion("type",[e.object({type:e.literal("adaptive"),display:e.enum(["omitted","summarized"]).optional()}),e.object({type:e.literal("enabled"),budgetTokens:e.number().optional()}),e.object({type:e.literal("disabled")})]).optional(),disableParallelToolUse:e.boolean().optional(),cacheControl:e.object({type:e.literal("ephemeral"),ttl:e.union([e.literal("5m"),e.literal("1h")]).optional()}).optional(),metadata:e.object({userId:e.string().optional()}).optional(),mcpServers:e.array(e.object({type:e.literal("url"),name:e.string(),url:e.string(),authorizationToken:e.string().nullish(),toolConfiguration:e.object({enabled:e.boolean().nullish(),allowedTools:e.array(e.string()).nullish()}).nullish()})).optional(),container:e.object({id:e.string().optional(),skills:e.array(e.object({type:e.union([e.literal("anthropic"),e.literal("custom")]),skillId:e.string(),version:e.string().optional()})).optional()}).optional(),toolStreaming:e.boolean().optional(),effort:e.enum(["low","medium","high","xhigh","max"]).optional(),taskBudget:e.object({type:e.literal("tokens"),total:e.number().int().min(2e4),remaining:e.number().int().min(0).optional()}).optional(),speed:e.enum(["fast","standard"]).optional(),inferenceGeo:e.enum(["us","global"]).optional(),anthropicBeta:e.array(e.string()).optional(),contextManagement:e.object({edits:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("clear_tool_uses_20250919"),trigger:e.discriminatedUnion("type",[e.object({type:e.literal("input_tokens"),value:e.number()}),e.object({type:e.literal("tool_uses"),value:e.number()})]).optional(),keep:e.object({type:e.literal("tool_uses"),value:e.number()}).optional(),clearAtLeast:e.object({type:e.literal("input_tokens"),value:e.number()}).optional(),clearToolInputs:e.boolean().optional(),excludeTools:e.array(e.string()).optional()}),e.object({type:e.literal("clear_thinking_20251015"),keep:e.union([e.literal("all"),e.object({type:e.literal("thinking_turns"),value:e.number()})]).optional()}),e.object({type:e.literal("compact_20260112"),trigger:e.object({type:e.literal("input_tokens"),value:e.number()}).optional(),pauseAfterCompaction:e.boolean().optional(),instructions:e.string().optional()})]))}).optional()}),qo=4;function ha(t){var o;let n=t?.anthropic;return(o=n?.cacheControl)!=null?o:n?.cache_control}var qt=class{constructor(){this.breakpointCount=0,this.warnings=[]}getCacheControl(t,o){let n=ha(t);if(n){if(!o.canCache){this.warnings.push({type:"unsupported",feature:"cache_control on non-cacheable context",details:`cache_control cannot be set on ${o.type}. It will be ignored.`});return}if(this.breakpointCount++,this.breakpointCount>qo){this.warnings.push({type:"unsupported",feature:"cacheControl breakpoint limit",details:`Maximum ${qo} cache breakpoints exceeded (found ${this.breakpointCount}). This breakpoint will be ignored.`});return}return n}}getWarnings(){return this.warnings}},ga=I(()=>k(e.object({maxCharacters:e.number().optional()}))),_a=I(()=>k(e.object({command:e.enum(["view","create","str_replace","insert"]),path:e.string(),file_text:e.string().optional(),insert_line:e.number().int().optional(),new_str:e.string().optional(),insert_text:e.string().optional(),old_str:e.string().optional(),view_range:e.array(e.number().int()).optional()}))),fa=ue({id:"anthropic.text_editor_20250728",inputSchema:_a}),ya=(t={})=>fa(t),ba=I(()=>k(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),userLocation:e.object({type:e.literal("approximate"),city:e.string().optional(),region:e.string().optional(),country:e.string().optional(),timezone:e.string().optional()}).optional()}))),va=I(()=>k(e.array(e.object({url:e.string(),title:e.string().nullable(),pageAge:e.string().nullable(),encryptedContent:e.string(),type:e.literal("web_search_result")})))),xa=I(()=>k(e.object({query:e.string()}))),wa=ie({id:"anthropic.web_search_20260209",inputSchema:xa,outputSchema:va,supportsDeferredResults:!0}),Ca=(t={})=>wa(t),Ia=I(()=>k(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),userLocation:e.object({type:e.literal("approximate"),city:e.string().optional(),region:e.string().optional(),country:e.string().optional(),timezone:e.string().optional()}).optional()}))),Ho=I(()=>k(e.array(e.object({url:e.string(),title:e.string().nullable(),pageAge:e.string().nullable(),encryptedContent:e.string(),type:e.literal("web_search_result")})))),ka=I(()=>k(e.object({query:e.string()}))),Sa=ie({id:"anthropic.web_search_20250305",inputSchema:ka,outputSchema:Ho,supportsDeferredResults:!0}),Ta=(t={})=>Sa(t),ja=I(()=>k(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),citations:e.object({enabled:e.boolean()}).optional(),maxContentTokens:e.number().optional()}))),Ra=I(()=>k(e.object({type:e.literal("web_fetch_result"),url:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),mediaType:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),mediaType:e.literal("text/plain"),data:e.string()})])}),retrievedAt:e.string().nullable()}))),Aa=I(()=>k(e.object({url:e.string()}))),Oa=ie({id:"anthropic.web_fetch_20260209",inputSchema:Aa,outputSchema:Ra,supportsDeferredResults:!0}),Na=(t={})=>Oa(t),Ea=I(()=>k(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),citations:e.object({enabled:e.boolean()}).optional(),maxContentTokens:e.number().optional()}))),Vo=I(()=>k(e.object({type:e.literal("web_fetch_result"),url:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),mediaType:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),mediaType:e.literal("text/plain"),data:e.string()})])}),retrievedAt:e.string().nullable()}))),za=I(()=>k(e.object({url:e.string()}))),Ma=ie({id:"anthropic.web_fetch_20250910",inputSchema:za,outputSchema:Vo,supportsDeferredResults:!0}),Pa=(t={})=>Ma(t);async function Da({tools:t,toolChoice:o,disableParallelToolUse:n,cacheControlValidator:a,supportsStructuredOutput:r,supportsStrictTools:i,defaultEagerInputStreaming:c=!1}){var s,g;t=t?.length?t:void 0;let m=[],l=new Set,p=a||new qt;if(t==null)return{tools:void 0,toolChoice:void 0,toolWarnings:m,betas:l};let h=[];for(let _ of t)switch(_.type){case"function":{let y=p.getCacheControl(_.providerOptions,{type:"tool definition",canCache:!0}),S=(s=_.providerOptions)==null?void 0:s.anthropic,C=(g=S?.eagerInputStreaming)!=null?g:c,b=S?.deferLoading,R=S?.allowedCallers;!i&&_.strict!=null&&m.push({type:"unsupported",feature:"strict",details:`Tool '${_.name}' has strict: ${_.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`}),h.push({name:_.name,description:_.description,input_schema:_.inputSchema,cache_control:y,...C?{eager_input_streaming:!0}:{},...i===!0&&_.strict!=null?{strict:_.strict}:{},...b!=null?{defer_loading:b}:{},...R!=null?{allowed_callers:R}:{},..._.inputExamples!=null?{input_examples:_.inputExamples.map(O=>O.input)}:{}}),r===!0&&l.add("structured-outputs-2025-11-13"),(_.inputExamples!=null||R!=null)&&l.add("advanced-tool-use-2025-11-20");break}case"provider":{switch(_.id){case"anthropic.code_execution_20250522":{l.add("code-execution-2025-05-22"),h.push({type:"code_execution_20250522",name:"code_execution",cache_control:void 0});break}case"anthropic.code_execution_20250825":{l.add("code-execution-2025-08-25"),h.push({type:"code_execution_20250825",name:"code_execution"});break}case"anthropic.code_execution_20260120":{h.push({type:"code_execution_20260120",name:"code_execution"});break}case"anthropic.computer_20250124":{l.add("computer-use-2025-01-24"),h.push({name:"computer",type:"computer_20250124",display_width_px:_.args.displayWidthPx,display_height_px:_.args.displayHeightPx,display_number:_.args.displayNumber,cache_control:void 0});break}case"anthropic.computer_20251124":{l.add("computer-use-2025-11-24"),h.push({name:"computer",type:"computer_20251124",display_width_px:_.args.displayWidthPx,display_height_px:_.args.displayHeightPx,display_number:_.args.displayNumber,enable_zoom:_.args.enableZoom,cache_control:void 0});break}case"anthropic.computer_20241022":{l.add("computer-use-2024-10-22"),h.push({name:"computer",type:"computer_20241022",display_width_px:_.args.displayWidthPx,display_height_px:_.args.displayHeightPx,display_number:_.args.displayNumber,cache_control:void 0});break}case"anthropic.text_editor_20250124":{l.add("computer-use-2025-01-24"),h.push({name:"str_replace_editor",type:"text_editor_20250124",cache_control:void 0});break}case"anthropic.text_editor_20241022":{l.add("computer-use-2024-10-22"),h.push({name:"str_replace_editor",type:"text_editor_20241022",cache_control:void 0});break}case"anthropic.text_editor_20250429":{l.add("computer-use-2025-01-24"),h.push({name:"str_replace_based_edit_tool",type:"text_editor_20250429",cache_control:void 0});break}case"anthropic.text_editor_20250728":{let y=await ce({value:_.args,schema:ga});h.push({name:"str_replace_based_edit_tool",type:"text_editor_20250728",max_characters:y.maxCharacters,cache_control:void 0});break}case"anthropic.bash_20250124":{l.add("computer-use-2025-01-24"),h.push({name:"bash",type:"bash_20250124",cache_control:void 0});break}case"anthropic.bash_20241022":{l.add("computer-use-2024-10-22"),h.push({name:"bash",type:"bash_20241022",cache_control:void 0});break}case"anthropic.memory_20250818":{l.add("context-management-2025-06-27"),h.push({name:"memory",type:"memory_20250818"});break}case"anthropic.web_fetch_20250910":{l.add("web-fetch-2025-09-10");let y=await ce({value:_.args,schema:Ea});h.push({type:"web_fetch_20250910",name:"web_fetch",max_uses:y.maxUses,allowed_domains:y.allowedDomains,blocked_domains:y.blockedDomains,citations:y.citations,max_content_tokens:y.maxContentTokens,cache_control:void 0});break}case"anthropic.web_fetch_20260209":{l.add("code-execution-web-tools-2026-02-09");let y=await ce({value:_.args,schema:ja});h.push({type:"web_fetch_20260209",name:"web_fetch",max_uses:y.maxUses,allowed_domains:y.allowedDomains,blocked_domains:y.blockedDomains,citations:y.citations,max_content_tokens:y.maxContentTokens,cache_control:void 0});break}case"anthropic.web_search_20250305":{let y=await ce({value:_.args,schema:Ia});h.push({type:"web_search_20250305",name:"web_search",max_uses:y.maxUses,allowed_domains:y.allowedDomains,blocked_domains:y.blockedDomains,user_location:y.userLocation,cache_control:void 0});break}case"anthropic.web_search_20260209":{l.add("code-execution-web-tools-2026-02-09");let y=await ce({value:_.args,schema:ba});h.push({type:"web_search_20260209",name:"web_search",max_uses:y.maxUses,allowed_domains:y.allowedDomains,blocked_domains:y.blockedDomains,user_location:y.userLocation,cache_control:void 0});break}case"anthropic.tool_search_regex_20251119":{h.push({type:"tool_search_tool_regex_20251119",name:"tool_search_tool_regex"});break}case"anthropic.tool_search_bm25_20251119":{h.push({type:"tool_search_tool_bm25_20251119",name:"tool_search_tool_bm25"});break}default:{m.push({type:"unsupported",feature:`provider-defined tool ${_.id}`});break}}break}default:{m.push({type:"unsupported",feature:`tool ${_}`});break}}if(o==null)return{tools:h,toolChoice:n?{type:"auto",disable_parallel_tool_use:n}:void 0,toolWarnings:m,betas:l};let v=o.type;switch(v){case"auto":return{tools:h,toolChoice:{type:"auto",disable_parallel_tool_use:n},toolWarnings:m,betas:l};case"required":return{tools:h,toolChoice:{type:"any",disable_parallel_tool_use:n},toolWarnings:m,betas:l};case"none":return{tools:void 0,toolChoice:void 0,toolWarnings:m,betas:l};case"tool":return{tools:h,toolChoice:{type:"tool",name:o.toolName,disable_parallel_tool_use:n},toolWarnings:m,betas:l};default:{let _=v;throw new le({functionality:`tool choice type: ${_}`})}}}function Uo({usage:t,rawUsage:o}){var n,a;let r=(n=t.cache_creation_input_tokens)!=null?n:0,i=(a=t.cache_read_input_tokens)!=null?a:0,c,s;if(t.iterations&&t.iterations.length>0){let g=t.iterations.reduce((m,l)=>({input:m.input+l.input_tokens,output:m.output+l.output_tokens}),{input:0,output:0});c=g.input,s=g.output}else c=t.input_tokens,s=t.output_tokens;return{inputTokens:{total:c+r+i,noCache:c,cacheRead:i,cacheWrite:r},outputTokens:{total:s,text:void 0,reasoning:void 0},raw:o??t}}var Jo=I(()=>k(e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}))),qa=I(()=>k(e.object({code:e.string()}))),Ua=ie({id:"anthropic.code_execution_20250522",inputSchema:qa,outputSchema:Jo}),$a=(t={})=>Ua(t),Wo=I(()=>k(e.discriminatedUnion("type",[e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})]))),La=I(()=>k(e.discriminatedUnion("type",[e.object({type:e.literal("programmatic-tool-call"),code:e.string()}),e.object({type:e.literal("bash_code_execution"),command:e.string()}),e.discriminatedUnion("command",[e.object({type:e.literal("text_editor_code_execution"),command:e.literal("view"),path:e.string()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("create"),path:e.string(),file_text:e.string().nullish()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("str_replace"),path:e.string(),old_str:e.string(),new_str:e.string()})])]))),Fa=ie({id:"anthropic.code_execution_20250825",inputSchema:La,outputSchema:Wo,supportsDeferredResults:!0}),Ha=(t={})=>Fa(t),Bo=I(()=>k(e.discriminatedUnion("type",[e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("encrypted_code_execution_result"),encrypted_stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})]))),Va=I(()=>k(e.discriminatedUnion("type",[e.object({type:e.literal("programmatic-tool-call"),code:e.string()}),e.object({type:e.literal("bash_code_execution"),command:e.string()}),e.discriminatedUnion("command",[e.object({type:e.literal("text_editor_code_execution"),command:e.literal("view"),path:e.string()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("create"),path:e.string(),file_text:e.string().nullish()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("str_replace"),path:e.string(),old_str:e.string(),new_str:e.string()})])]))),Ja=ie({id:"anthropic.code_execution_20260120",inputSchema:Va,outputSchema:Bo,supportsDeferredResults:!0}),Wa=(t={})=>Ja(t),Go=I(()=>k(e.array(e.object({type:e.literal("tool_reference"),toolName:e.string()})))),Ba=I(()=>k(e.object({pattern:e.string(),limit:e.number().optional()}))),Ga=ie({id:"anthropic.tool_search_regex_20251119",inputSchema:Ba,outputSchema:Go,supportsDeferredResults:!0}),Ka=(t={})=>Ga(t);function Ya(t){if(typeof t=="string")return new TextDecoder().decode(Ie(t));if(t instanceof Uint8Array)return new TextDecoder().decode(t);throw t instanceof URL?new le({functionality:"URL-based text documents are not supported for citations"}):new le({functionality:`unsupported data type for text documents: ${typeof t}`})}function Mt(t){return t instanceof URL||Xa(t)}function Xa(t){return typeof t=="string"&&/^https?:\/\//i.test(t)}function Pt(t){return t instanceof URL?t.toString():t}async function Qa({prompt:t,sendReasoning:o,warnings:n,cacheControlValidator:a,toolNameMapping:r}){var i,c,s,g,m,l,p,h,v,_,y,S,C,b,R,O,V,L,P;let f=new Set,u=Za(t),H=a||new qt,U,W=[];async function Z(A){var $,j;let E=await te({provider:"anthropic",providerOptions:A,schema:Po});return(j=($=E?.citations)==null?void 0:$.enabled)!=null?j:!1}async function q(A){let $=await te({provider:"anthropic",providerOptions:A,schema:Po});return{title:$?.title,context:$?.context}}for(let A=0;A<u.length;A++){let $=u[A],j=A===u.length-1,E=$.type;switch(E){case"system":{if(U!=null)throw new le({functionality:"Multiple system messages that are separated by user/assistant messages"});U=$.messages.map(({content:D,providerOptions:J})=>({type:"text",text:D,cache_control:H.getCacheControl(J,{type:"system message",canCache:!0})}));break}case"user":{let D=[];for(let J of $.messages){let{role:z,content:B}=J;switch(z){case"user":{for(let ae=0;ae<B.length;ae++){let K=B[ae],ee=ae===B.length-1,w=(i=H.getCacheControl(K.providerOptions,{type:"user message part",canCache:!0}))!=null?i:ee?H.getCacheControl(J.providerOptions,{type:"user message",canCache:!0}):void 0;switch(K.type){case"text":{D.push({type:"text",text:K.text,cache_control:w});break}case"file":{if(K.mediaType.startsWith("image/"))D.push({type:"image",source:Mt(K.data)?{type:"url",url:Pt(K.data)}:{type:"base64",media_type:K.mediaType==="image/*"?"image/jpeg":K.mediaType,data:_e(K.data)},cache_control:w});else if(K.mediaType==="application/pdf"){f.add("pdfs-2024-09-25");let Y=await Z(K.providerOptions),G=await q(K.providerOptions);D.push({type:"document",source:Mt(K.data)?{type:"url",url:Pt(K.data)}:{type:"base64",media_type:"application/pdf",data:_e(K.data)},title:(c=G.title)!=null?c:K.filename,...G.context&&{context:G.context},...Y&&{citations:{enabled:!0}},cache_control:w})}else if(K.mediaType==="text/plain"){let Y=await Z(K.providerOptions),G=await q(K.providerOptions);D.push({type:"document",source:Mt(K.data)?{type:"url",url:Pt(K.data)}:{type:"text",media_type:"text/plain",data:Ya(K.data)},title:(s=G.title)!=null?s:K.filename,...G.context&&{context:G.context},...Y&&{citations:{enabled:!0}},cache_control:w})}else throw new le({functionality:`media type: ${K.mediaType}`});break}}}break}case"tool":{for(let ae=0;ae<B.length;ae++){let K=B[ae];if(K.type==="tool-approval-response")continue;let ee=ae===B.length-1,w=(g=H.getCacheControl(K.providerOptions,{type:"tool result part",canCache:!0}))!=null?g:ee?H.getCacheControl(J.providerOptions,{type:"tool result message",canCache:!0}):void 0,Y=K.output,G;switch(Y.type){case"content":G=Y.value.map(Q=>{var T;switch(Q.type){case"text":return{type:"text",text:Q.text};case"image-data":return{type:"image",source:{type:"base64",media_type:Q.mediaType,data:Q.data}};case"image-url":return{type:"image",source:{type:"url",url:Q.url}};case"file-url":return{type:"document",source:{type:"url",url:Q.url}};case"file-data":{if(Q.mediaType==="application/pdf")return f.add("pdfs-2024-09-25"),{type:"document",source:{type:"base64",media_type:Q.mediaType,data:Q.data}};n.push({type:"other",message:`unsupported tool content part type: ${Q.type} with media type: ${Q.mediaType}`});return}case"custom":{let M=(T=Q.providerOptions)==null?void 0:T.anthropic;if(M?.type==="tool-reference")return{type:"tool_reference",tool_name:M.toolName};n.push({type:"other",message:"unsupported custom tool content part"});return}default:{n.push({type:"other",message:`unsupported tool content part type: ${Q.type}`});return}}}).filter(at);break;case"text":case"error-text":G=Y.value;break;case"execution-denied":G=(m=Y.reason)!=null?m:"Tool execution denied.";break;default:G=JSON.stringify(Y.value);break}D.push({type:"tool_result",tool_use_id:K.toolCallId,content:G,is_error:Y.type==="error-text"||Y.type==="error-json"?!0:void 0,cache_control:w})}break}default:{let ae=z;throw new Error(`Unsupported role: ${ae}`)}}}W.push({role:"user",content:D});break}case"assistant":{let D=[],J=new Set;for(let z=0;z<$.messages.length;z++){let B=$.messages[z],ae=z===$.messages.length-1,{content:K}=B;for(let ee=0;ee<K.length;ee++){let w=K[ee],Y=ee===K.length-1,G=(l=H.getCacheControl(w.providerOptions,{type:"assistant message part",canCache:!0}))!=null?l:Y?H.getCacheControl(B.providerOptions,{type:"assistant message",canCache:!0}):void 0;switch(w.type){case"text":{let Q=(p=w.providerOptions)==null?void 0:p.anthropic;Q?.type==="compaction"?D.push({type:"compaction",content:w.text,cache_control:G}):D.push({type:"text",text:j&&ae&&Y?w.text.trim():w.text,cache_control:G});break}case"reasoning":{if(o){let Q=await te({provider:"anthropic",providerOptions:w.providerOptions,schema:ma});Q!=null?Q.signature!=null?(H.getCacheControl(w.providerOptions,{type:"thinking block",canCache:!1}),D.push({type:"thinking",thinking:w.text,signature:Q.signature})):Q.redactedData!=null?(H.getCacheControl(w.providerOptions,{type:"redacted thinking block",canCache:!1}),D.push({type:"redacted_thinking",data:Q.redactedData})):n.push({type:"other",message:"unsupported reasoning metadata"}):n.push({type:"other",message:"unsupported reasoning metadata"})}else n.push({type:"other",message:"sending reasoning content is disabled for this model"});break}case"tool-call":{if(w.providerExecuted){let M=r.toProviderToolName(w.toolName);if(((v=(h=w.providerOptions)==null?void 0:h.anthropic)==null?void 0:v.type)==="mcp-tool-use"){J.add(w.toolCallId);let x=(y=(_=w.providerOptions)==null?void 0:_.anthropic)==null?void 0:y.serverName;if(x==null||typeof x!="string"){n.push({type:"other",message:"mcp tool use server name is required and must be a string"});break}D.push({type:"mcp_tool_use",id:w.toolCallId,name:w.toolName,input:w.input,server_name:x,cache_control:G})}else if(M==="code_execution"&&w.input!=null&&typeof w.input=="object"&&"type"in w.input&&typeof w.input.type=="string"&&(w.input.type==="bash_code_execution"||w.input.type==="text_editor_code_execution"))D.push({type:"server_tool_use",id:w.toolCallId,name:w.input.type,input:w.input,cache_control:G});else if(M==="code_execution"&&w.input!=null&&typeof w.input=="object"&&"type"in w.input&&w.input.type==="programmatic-tool-call"){let{type:x,...ne}=w.input;D.push({type:"server_tool_use",id:w.toolCallId,name:"code_execution",input:ne,cache_control:G})}else M==="code_execution"||M==="web_fetch"||M==="web_search"?D.push({type:"server_tool_use",id:w.toolCallId,name:M,input:w.input,cache_control:G}):M==="tool_search_tool_regex"||M==="tool_search_tool_bm25"?D.push({type:"server_tool_use",id:w.toolCallId,name:M,input:w.input,cache_control:G}):n.push({type:"other",message:`provider executed tool call for tool ${w.toolName} is not supported`});break}let Q=(S=w.providerOptions)==null?void 0:S.anthropic,T=Q?.caller?(Q.caller.type==="code_execution_20250825"||Q.caller.type==="code_execution_20260120")&&Q.caller.toolId?{type:Q.caller.type,tool_id:Q.caller.toolId}:Q.caller.type==="direct"?{type:"direct"}:void 0:void 0;D.push({type:"tool_use",id:w.toolCallId,name:w.toolName,input:w.input,...T&&{caller:T},cache_control:G});break}case"tool-result":{let Q=r.toProviderToolName(w.toolName);if(J.has(w.toolCallId)){let T=w.output;if(T.type!=="json"&&T.type!=="error-json"){n.push({type:"other",message:`provider executed tool result output type ${T.type} for tool ${w.toolName} is not supported`});break}D.push({type:"mcp_tool_result",tool_use_id:w.toolCallId,is_error:T.type==="error-json",content:T.value,cache_control:G})}else if(Q==="code_execution"){let T=w.output;if(T.type==="error-text"||T.type==="error-json"){let M={};try{typeof T.value=="string"?M=JSON.parse(T.value):typeof T.value=="object"&&T.value!==null&&(M=T.value)}catch{}M.type==="code_execution_tool_result_error"?D.push({type:"code_execution_tool_result",tool_use_id:w.toolCallId,content:{type:"code_execution_tool_result_error",error_code:(C=M.errorCode)!=null?C:"unknown"},cache_control:G}):D.push({type:"bash_code_execution_tool_result",tool_use_id:w.toolCallId,cache_control:G,content:{type:"bash_code_execution_tool_result_error",error_code:(b=M.errorCode)!=null?b:"unknown"}});break}if(T.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${T.type} for tool ${w.toolName} is not supported`});break}if(T.value==null||typeof T.value!="object"||!("type"in T.value)||typeof T.value.type!="string"){n.push({type:"other",message:`provider executed tool result output value is not a valid code execution result for tool ${w.toolName}`});break}if(T.value.type==="code_execution_result"){let M=await ce({value:T.value,schema:Jo});D.push({type:"code_execution_tool_result",tool_use_id:w.toolCallId,content:{type:M.type,stdout:M.stdout,stderr:M.stderr,return_code:M.return_code,content:(R=M.content)!=null?R:[]},cache_control:G})}else if(T.value.type==="encrypted_code_execution_result"){let M=await ce({value:T.value,schema:Bo});M.type==="encrypted_code_execution_result"&&D.push({type:"code_execution_tool_result",tool_use_id:w.toolCallId,content:{type:M.type,encrypted_stdout:M.encrypted_stdout,stderr:M.stderr,return_code:M.return_code,content:(O=M.content)!=null?O:[]},cache_control:G})}else{let M=await ce({value:T.value,schema:Wo});M.type==="code_execution_result"?D.push({type:"code_execution_tool_result",tool_use_id:w.toolCallId,content:{type:M.type,stdout:M.stdout,stderr:M.stderr,return_code:M.return_code,content:(V=M.content)!=null?V:[]},cache_control:G}):M.type==="bash_code_execution_result"||M.type==="bash_code_execution_tool_result_error"?D.push({type:"bash_code_execution_tool_result",tool_use_id:w.toolCallId,cache_control:G,content:M}):D.push({type:"text_editor_code_execution_tool_result",tool_use_id:w.toolCallId,cache_control:G,content:M})}break}if(Q==="web_fetch"){let T=w.output;if(T.type==="error-json"){let N={};try{typeof T.value=="string"?N=JSON.parse(T.value):typeof T.value=="object"&&T.value!==null&&(N=T.value)}catch{let ne=(L=T.value)==null?void 0:L.errorCode;N={errorCode:typeof ne=="string"?ne:"unavailable"}}D.push({type:"web_fetch_tool_result",tool_use_id:w.toolCallId,content:{type:"web_fetch_tool_result_error",error_code:(P=N.errorCode)!=null?P:"unavailable"},cache_control:G});break}if(T.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${T.type} for tool ${w.toolName} is not supported`});break}let M=await ce({value:T.value,schema:Vo});D.push({type:"web_fetch_tool_result",tool_use_id:w.toolCallId,content:{type:"web_fetch_result",url:M.url,retrieved_at:M.retrievedAt,content:{type:"document",title:M.content.title,citations:M.content.citations,source:{type:M.content.source.type,media_type:M.content.source.mediaType,data:M.content.source.data}}},cache_control:G});break}if(Q==="web_search"){let T=w.output;if(T.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${T.type} for tool ${w.toolName} is not supported`});break}let M=await ce({value:T.value,schema:Ho});D.push({type:"web_search_tool_result",tool_use_id:w.toolCallId,content:M.map(N=>({url:N.url,title:N.title,page_age:N.pageAge,encrypted_content:N.encryptedContent,type:N.type})),cache_control:G});break}if(Q==="tool_search_tool_regex"||Q==="tool_search_tool_bm25"){let T=w.output;if(T.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${T.type} for tool ${w.toolName} is not supported`});break}let N=(await ce({value:T.value,schema:Go})).map(x=>({type:"tool_reference",tool_name:x.toolName}));D.push({type:"tool_search_tool_result",tool_use_id:w.toolCallId,content:{type:"tool_search_tool_search_result",tool_references:N},cache_control:G});break}n.push({type:"other",message:`provider executed tool result for tool ${w.toolName} is not supported`});break}}}}W.push({role:"assistant",content:D});break}default:{let D=E;throw new Error(`content type: ${D}`)}}}return{prompt:{system:U,messages:W},betas:f}}function Za(t){let o=[],n;for(let a of t){let{role:r}=a;switch(r){case"system":{n?.type!=="system"&&(n={type:"system",messages:[]},o.push(n)),n.messages.push(a);break}case"assistant":{n?.type!=="assistant"&&(n={type:"assistant",messages:[]},o.push(n)),n.messages.push(a);break}case"user":{n?.type!=="user"&&(n={type:"user",messages:[]},o.push(n)),n.messages.push(a);break}case"tool":{n?.type!=="user"&&(n={type:"user",messages:[]},o.push(n)),n.messages.push(a);break}default:{let i=r;throw new Error(`Unsupported role: ${i}`)}}}return o}function Dt({finishReason:t,isJsonResponseFromTool:o}){switch(t){case"pause_turn":case"end_turn":case"stop_sequence":return"stop";case"refusal":return"content-filter";case"tool_use":return o?"stop":"tool-calls";case"max_tokens":case"model_context_window_exceeded":return"length";case"compaction":return"other";default:return"other"}}var Ko=new Set(["date-time","time","date","duration","email","hostname","uri","ipv4","ipv6","uuid"]),er=["minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","minLength","maxLength","pattern","minItems","maxItems","uniqueItems","minProperties","maxProperties","not"];function tr(t){return Yo(t)}function Me(t){return typeof t=="boolean"||!rr(t)?t:Yo(t)}function Yo(t){let o={},n=t;if(t.$ref!=null)return{$ref:t.$ref};if(t.$schema!=null&&(o.$schema=t.$schema),t.$id!=null&&(o.$id=t.$id),t.title!=null&&(o.title=t.title),t.description!=null&&(o.description=t.description),t.default!==void 0&&(o.default=t.default),t.const!==void 0&&(o.const=t.const),t.enum!=null&&(o.enum=t.enum),t.type!=null&&(o.type=t.type),t.anyOf!=null?o.anyOf=t.anyOf.map(Me):t.oneOf!=null&&(o.anyOf=t.oneOf.map(Me)),t.allOf!=null&&(o.allOf=t.allOf.map(Me)),t.definitions!=null&&(o.definitions=Object.fromEntries(Object.entries(t.definitions).map(([r,i])=>[r,Me(i)]))),n.$defs!=null){let r=o;r.$defs=Object.fromEntries(Object.entries(n.$defs).map(([i,c])=>[i,Me(c)]))}(t.type==="object"||t.properties!=null)&&(t.properties!=null&&(o.properties=Object.fromEntries(Object.entries(t.properties).map(([r,i])=>[r,Me(i)]))),o.additionalProperties=!1,t.required!=null&&(o.required=t.required)),t.items!=null&&(o.items=Array.isArray(t.items)?t.items.map(Me):Me(t.items)),typeof t.format=="string"&&Ko.has(t.format)&&(o.format=t.format);let a=or(t);return a!=null&&(o.description=o.description==null?a:`${o.description}
2
2
  ${a}`),o}function or(t){let o=er.flatMap(n=>{let a=t[n];return a==null||a===!1?[]:`${nr(n)}: ${ar(a)}`});return typeof t.format=="string"&&!Ko.has(t.format)&&o.push(`format: ${t.format}`),o.length===0?void 0:`${o.join("; ")}.`}function nr(t){return t.replace(/[A-Z]/g,o=>` ${o.toLowerCase()}`)}function ar(t){return typeof t=="string"?t:JSON.stringify(t)}function rr(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function $o(t,o,n){var a;if(t.type==="web_search_result_location")return{type:"source",sourceType:"url",id:n(),url:t.url,title:t.title,providerMetadata:{anthropic:{citedText:t.cited_text,encryptedIndex:t.encrypted_index}}};if(t.type!=="page_location"&&t.type!=="char_location")return;let r=o[t.document_index];if(r)return{type:"source",sourceType:"document",id:n(),mediaType:r.mediaType,title:(a=t.document_title)!=null?a:r.title,filename:r.filename,providerMetadata:{anthropic:t.type==="page_location"?{citedText:t.cited_text,startPageNumber:t.start_page_number,endPageNumber:t.end_page_number}:{citedText:t.cited_text,startCharIndex:t.start_char_index,endCharIndex:t.end_char_index}}}}var ir=class{constructor(t,o){this.specificationVersion="v3";var n;this.modelId=t,this.config=o,this.generateId=(n=o.generateId)!=null?n:pe}supportsUrl(t){return t.protocol==="https:"}get provider(){return this.config.provider}get providerOptionsName(){let t=this.config.provider,o=t.indexOf(".");return o===-1?t:t.substring(0,o)}get supportedUrls(){var t,o,n;return(n=(o=(t=this.config).supportedUrls)==null?void 0:o.call(t))!=null?n:{}}async getArgs({userSuppliedBetas:t,prompt:o,maxOutputTokens:n,temperature:a,topP:r,topK:i,frequencyPenalty:c,presencePenalty:s,stopSequences:g,responseFormat:m,seed:l,tools:p,toolChoice:h,providerOptions:v,stream:_}){var y,S,C,b,R,O,V,L,P,f;let u=[];c!=null&&u.push({type:"unsupported",feature:"frequencyPenalty"}),s!=null&&u.push({type:"unsupported",feature:"presencePenalty"}),l!=null&&u.push({type:"unsupported",feature:"seed"}),a!=null&&a>1?(u.push({type:"unsupported",feature:"temperature",details:`${a} exceeds anthropic maximum of 1.0. clamped to 1.0`}),a=1):a!=null&&a<0&&(u.push({type:"unsupported",feature:"temperature",details:`${a} is below anthropic minimum of 0. clamped to 0`}),a=0),m?.type==="json"&&m.schema==null&&u.push({type:"unsupported",feature:"responseFormat",details:"JSON response format requires a schema. The response format is ignored."});let H=this.providerOptionsName,U=await te({provider:"anthropic",providerOptions:v,schema:Do}),W=H!=="anthropic"?await te({provider:H,providerOptions:v,schema:Do}):null,Z=W!=null,q=Object.assign({},U??{},W??{}),{maxOutputTokens:A,supportsStructuredOutput:$,rejectsSamplingParameters:j,isKnownModel:E}=sr(this.modelId);j&&(a!=null&&(u.push({type:"unsupported",feature:"temperature",details:`temperature is not supported by ${this.modelId} and will be ignored`}),a=void 0),i!=null&&(u.push({type:"unsupported",feature:"topK",details:`topK is not supported by ${this.modelId} and will be ignored`}),i=void 0),r!=null&&(u.push({type:"unsupported",feature:"topP",details:`topP is not supported by ${this.modelId} and will be ignored`}),r=void 0));let D=E||this.modelId.startsWith("claude-"),J=((y=this.config.supportsNativeStructuredOutput)!=null?y:!0)&&$,z=((S=this.config.supportsStrictTools)!=null?S:!0)&&$,B=(C=q?.structuredOutputMode)!=null?C:"auto",ae=B==="outputFormat"||B==="auto"&&J,K=m?.type==="json"&&m.schema!=null&&!ae?{type:"function",name:"json",description:"Respond with a JSON object.",inputSchema:m.schema}:void 0,ee=q?.contextManagement,w=new qt,Y=vt({tools:p,providerToolNames:{"anthropic.code_execution_20250522":"code_execution","anthropic.code_execution_20250825":"code_execution","anthropic.code_execution_20260120":"code_execution","anthropic.computer_20241022":"computer","anthropic.computer_20250124":"computer","anthropic.text_editor_20241022":"str_replace_editor","anthropic.text_editor_20250124":"str_replace_editor","anthropic.text_editor_20250429":"str_replace_based_edit_tool","anthropic.text_editor_20250728":"str_replace_based_edit_tool","anthropic.bash_20241022":"bash","anthropic.bash_20250124":"bash","anthropic.memory_20250818":"memory","anthropic.web_search_20250305":"web_search","anthropic.web_search_20260209":"web_search","anthropic.web_fetch_20250910":"web_fetch","anthropic.web_fetch_20260209":"web_fetch","anthropic.tool_search_regex_20251119":"tool_search_tool_regex","anthropic.tool_search_bm25_20251119":"tool_search_tool_bm25"}}),{prompt:G,betas:Q}=await Qa({prompt:o,sendReasoning:(b=q?.sendReasoning)!=null?b:!0,warnings:u,cacheControlValidator:w,toolNameMapping:Y}),T=(R=q?.thinking)==null?void 0:R.type,M=T==="enabled"||T==="adaptive",N=T==="enabled"?(O=q?.thinking)==null?void 0:O.budgetTokens:void 0,x=T==="adaptive"?(V=q?.thinking)==null?void 0:V.display:void 0,ne=n??A,X={model:this.modelId,max_tokens:ne,temperature:a,top_k:i,top_p:r,stop_sequences:g,...M&&{thinking:{type:T,...N!=null&&{budget_tokens:N},...x!=null&&{display:x}}},...(q?.effort||q?.taskBudget||ae&&m?.type==="json"&&m.schema!=null)&&{output_config:{...q?.effort&&{effort:q.effort},...q?.taskBudget&&{task_budget:{type:q.taskBudget.type,total:q.taskBudget.total,...q.taskBudget.remaining!=null&&{remaining:q.taskBudget.remaining}}},...ae&&m?.type==="json"&&m.schema!=null&&{format:{type:"json_schema",schema:tr(m.schema)}}}},...q?.speed&&{speed:q.speed},...q?.inferenceGeo&&{inference_geo:q.inferenceGeo},...q?.cacheControl&&{cache_control:q.cacheControl},...((L=q?.metadata)==null?void 0:L.userId)!=null&&{metadata:{user_id:q.metadata.userId}},...q?.mcpServers&&q.mcpServers.length>0&&{mcp_servers:q.mcpServers.map(oe=>({type:oe.type,name:oe.name,url:oe.url,authorization_token:oe.authorizationToken,tool_configuration:oe.toolConfiguration?{allowed_tools:oe.toolConfiguration.allowedTools,enabled:oe.toolConfiguration.enabled}:void 0}))},...q?.container&&{container:q.container.skills&&q.container.skills.length>0?{id:q.container.id,skills:q.container.skills.map(oe=>({type:oe.type,skill_id:oe.skillId,version:oe.version}))}:q.container.id},system:G.system,messages:G.messages,...ee&&{context_management:{edits:ee.edits.map(oe=>{let Ze=oe.type;switch(Ze){case"clear_tool_uses_20250919":return{type:oe.type,...oe.trigger!==void 0&&{trigger:oe.trigger},...oe.keep!==void 0&&{keep:oe.keep},...oe.clearAtLeast!==void 0&&{clear_at_least:oe.clearAtLeast},...oe.clearToolInputs!==void 0&&{clear_tool_inputs:oe.clearToolInputs},...oe.excludeTools!==void 0&&{exclude_tools:oe.excludeTools}};case"clear_thinking_20251015":return{type:oe.type,...oe.keep!==void 0&&{keep:oe.keep}};case"compact_20260112":return{type:oe.type,...oe.trigger!==void 0&&{trigger:oe.trigger},...oe.pauseAfterCompaction!==void 0&&{pause_after_compaction:oe.pauseAfterCompaction},...oe.instructions!==void 0&&{instructions:oe.instructions}};default:u.push({type:"other",message:`Unknown context management strategy: ${Ze}`});return}}).filter(oe=>oe!==void 0)}}};M?(T==="enabled"&&N==null&&(u.push({type:"compatibility",feature:"extended thinking",details:"thinking budget is required when thinking is enabled. using default budget of 1024 tokens."}),X.thinking={type:"enabled",budget_tokens:1024},N=1024),X.temperature!=null&&(X.temperature=void 0,u.push({type:"unsupported",feature:"temperature",details:"temperature is not supported when thinking is enabled"})),i!=null&&(X.top_k=void 0,u.push({type:"unsupported",feature:"topK",details:"topK is not supported when thinking is enabled"})),r!=null&&(X.top_p=void 0,u.push({type:"unsupported",feature:"topP",details:"topP is not supported when thinking is enabled"})),X.max_tokens=ne+(N??0)):D&&r!=null&&a!=null&&(u.push({type:"unsupported",feature:"topP",details:"topP is not supported when temperature is set. topP is ignored."}),X.top_p=void 0),E&&X.max_tokens>A&&(n!=null&&u.push({type:"unsupported",feature:"maxOutputTokens",details:`${X.max_tokens} (maxOutputTokens + thinkingBudget) is greater than ${this.modelId} ${A} max output tokens. The max output tokens have been limited to ${A}.`}),X.max_tokens=A),q?.mcpServers&&q.mcpServers.length>0&&Q.add("mcp-client-2025-04-04"),ee&&(Q.add("context-management-2025-06-27"),ee.edits.some(oe=>oe.type==="compact_20260112")&&Q.add("compact-2026-01-12")),q?.container&&q.container.skills&&q.container.skills.length>0&&(Q.add("code-execution-2025-08-25"),Q.add("skills-2025-10-02"),Q.add("files-api-2025-04-14"),p?.some(oe=>oe.type==="provider"&&(oe.id==="anthropic.code_execution_20250825"||oe.id==="anthropic.code_execution_20260120"))||u.push({type:"other",message:"code execution tool is required when using skills"})),q?.effort&&Q.add("effort-2025-11-24"),q?.taskBudget&&Q.add("task-budgets-2026-03-13"),q?.speed==="fast"&&Q.add("fast-mode-2026-02-01");let me=_&&((P=q?.toolStreaming)!=null?P:!0),{tools:be,toolChoice:Qe,toolWarnings:qe,betas:ht}=await Da(K!=null?{tools:[...p??[],K],toolChoice:{type:"required"},disableParallelToolUse:!0,cacheControlValidator:w,supportsStructuredOutput:!1,supportsStrictTools:z,defaultEagerInputStreaming:me}:{tools:p??[],toolChoice:h,disableParallelToolUse:q?.disableParallelToolUse,cacheControlValidator:w,supportsStructuredOutput:J,supportsStrictTools:z,defaultEagerInputStreaming:me}),gt=w.getWarnings();return{args:{...X,tools:be,tool_choice:Qe,stream:_===!0?!0:void 0},warnings:[...u,...qe,...gt],betas:new Set([...Q,...ht,...t,...(f=q?.anthropicBeta)!=null?f:[]]),usesJsonResponseTool:K!=null,toolNameMapping:Y,providerOptionsName:H,usedCustomProviderKey:Z}}async getHeaders({betas:t,headers:o}){return re(await ve(this.config.headers),o,t.size>0?{"anthropic-beta":Array.from(t).join(",")}:{})}async getBetasFromHeaders(t){var o,n;let r=(o=(await ve(this.config.headers))["anthropic-beta"])!=null?o:"",i=(n=t?.["anthropic-beta"])!=null?n:"";return new Set([...r.toLowerCase().split(","),...i.toLowerCase().split(",")].map(c=>c.trim()).filter(c=>c!==""))}buildRequestUrl(t){var o,n,a;return(a=(n=(o=this.config).buildRequestUrl)==null?void 0:n.call(o,this.config.baseURL,t))!=null?a:`${this.config.baseURL}/messages`}transformRequestBody(t,o){var n,a,r;return(r=(a=(n=this.config).transformRequestBody)==null?void 0:a.call(n,t,o))!=null?r:t}extractCitationDocuments(t){let o=n=>{var a,r;if(n.type!=="file"||n.mediaType!=="application/pdf"&&n.mediaType!=="text/plain")return!1;let i=(a=n.providerOptions)==null?void 0:a.anthropic,c=i?.citations;return(r=c?.enabled)!=null?r:!1};return t.filter(n=>n.role==="user").flatMap(n=>n.content).filter(o).map(n=>{var a;let r=n;return{title:(a=r.filename)!=null?a:"Untitled Document",filename:r.filename,mediaType:r.mediaType}})}async doGenerate(t){var o,n,a,r,i,c,s;let{args:g,warnings:m,betas:l,usesJsonResponseTool:p,toolNameMapping:h,providerOptionsName:v,usedCustomProviderKey:_}=await this.getArgs({...t,stream:!1,userSuppliedBetas:await this.getBetasFromHeaders(t.headers)}),y=[...this.extractCitationDocuments(t.prompt)],S=Lo(g.tools),{responseHeaders:C,value:b,rawValue:R}=await se({url:this.buildRequestUrl(!1),headers:await this.getHeaders({betas:l,headers:t.headers}),body:this.transformRequestBody(g,l),failedResponseHandler:Mo,successfulResponseHandler:de(da),abortSignal:t.abortSignal,fetch:this.config.fetch}),O=[],V={},L={},P=!1;for(let f of b.content)switch(f.type){case"text":{if(!p&&(O.push({type:"text",text:f.text}),f.citations))for(let u of f.citations){let H=$o(u,y,this.generateId);H&&O.push(H)}break}case"thinking":{O.push({type:"reasoning",text:f.thinking,providerMetadata:{anthropic:{signature:f.signature}}});break}case"redacted_thinking":{O.push({type:"reasoning",text:"",providerMetadata:{anthropic:{redactedData:f.data}}});break}case"compaction":{O.push({type:"text",text:f.content,providerMetadata:{anthropic:{type:"compaction"}}});break}case"tool_use":{if(p&&f.name==="json")P=!0,O.push({type:"text",text:JSON.stringify(f.input)});else{let H=f.caller,U=H?{type:H.type,toolId:"tool_id"in H?H.tool_id:void 0}:void 0;O.push({type:"tool-call",toolCallId:f.id,toolName:f.name,input:JSON.stringify(f.input),...U&&{providerMetadata:{anthropic:{caller:U}}}})}break}case"server_tool_use":{if(f.name==="text_editor_code_execution"||f.name==="bash_code_execution")O.push({type:"tool-call",toolCallId:f.id,toolName:h.toCustomToolName("code_execution"),input:JSON.stringify({type:f.name,...f.input}),providerExecuted:!0});else if(f.name==="web_search"||f.name==="code_execution"||f.name==="web_fetch"){let u=f.name==="code_execution"&&f.input!=null&&typeof f.input=="object"&&"code"in f.input&&!("type"in f.input)?{type:"programmatic-tool-call",...f.input}:f.input;O.push({type:"tool-call",toolCallId:f.id,toolName:h.toCustomToolName(f.name),input:JSON.stringify(u),providerExecuted:!0,...S&&f.name==="code_execution"?{dynamic:!0}:{}})}else(f.name==="tool_search_tool_regex"||f.name==="tool_search_tool_bm25")&&(L[f.id]=f.name,O.push({type:"tool-call",toolCallId:f.id,toolName:h.toCustomToolName(f.name),input:JSON.stringify(f.input),providerExecuted:!0}));break}case"mcp_tool_use":{V[f.id]={type:"tool-call",toolCallId:f.id,toolName:f.name,input:JSON.stringify(f.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:"mcp-tool-use",serverName:f.server_name}}},O.push(V[f.id]);break}case"mcp_tool_result":{O.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:V[f.tool_use_id].toolName,isError:f.is_error,result:f.content,dynamic:!0,providerMetadata:V[f.tool_use_id].providerMetadata});break}case"web_fetch_tool_result":{f.content.type==="web_fetch_result"?(y.push({title:(o=f.content.content.title)!=null?o:f.content.url,mediaType:f.content.content.source.media_type}),O.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName("web_fetch"),result:{type:"web_fetch_result",url:f.content.url,retrievedAt:f.content.retrieved_at,content:{type:f.content.content.type,title:f.content.content.title,citations:f.content.content.citations,source:{type:f.content.content.source.type,mediaType:f.content.content.source.media_type,data:f.content.content.source.data}}}})):f.content.type==="web_fetch_tool_result_error"&&O.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName("web_fetch"),isError:!0,result:{type:"web_fetch_tool_result_error",errorCode:f.content.error_code}});break}case"web_search_tool_result":{if(Array.isArray(f.content)){O.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName("web_search"),result:f.content.map(u=>{var H;return{url:u.url,title:u.title,pageAge:(H=u.page_age)!=null?H:null,encryptedContent:u.encrypted_content,type:u.type}})});for(let u of f.content)O.push({type:"source",sourceType:"url",id:this.generateId(),url:u.url,title:u.title,providerMetadata:{anthropic:{pageAge:(n=u.page_age)!=null?n:null}}})}else O.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName("web_search"),isError:!0,result:{type:"web_search_tool_result_error",errorCode:f.content.error_code}});break}case"code_execution_tool_result":{f.content.type==="code_execution_result"?O.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName("code_execution"),result:{type:f.content.type,stdout:f.content.stdout,stderr:f.content.stderr,return_code:f.content.return_code,content:(a=f.content.content)!=null?a:[]}}):f.content.type==="encrypted_code_execution_result"?O.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName("code_execution"),result:{type:f.content.type,encrypted_stdout:f.content.encrypted_stdout,stderr:f.content.stderr,return_code:f.content.return_code,content:(r=f.content.content)!=null?r:[]}}):f.content.type==="code_execution_tool_result_error"&&O.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName("code_execution"),isError:!0,result:{type:"code_execution_tool_result_error",errorCode:f.content.error_code}});break}case"bash_code_execution_tool_result":case"text_editor_code_execution_tool_result":{O.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName("code_execution"),result:f.content});break}case"tool_search_tool_result":{let u=L[f.tool_use_id];if(u==null){let H=h.toCustomToolName("tool_search_tool_bm25"),U=h.toCustomToolName("tool_search_tool_regex");H!=="tool_search_tool_bm25"?u="tool_search_tool_bm25":u="tool_search_tool_regex"}f.content.type==="tool_search_tool_search_result"?O.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName(u),result:f.content.tool_references.map(H=>({type:H.type,toolName:H.tool_name}))}):O.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName(u),isError:!0,result:{type:"tool_search_tool_result_error",errorCode:f.content.error_code}});break}}return{content:O,finishReason:{unified:Dt({finishReason:b.stop_reason,isJsonResponseFromTool:P}),raw:(i=b.stop_reason)!=null?i:void 0},usage:Uo({usage:b.usage}),request:{body:g},response:{id:(c=b.id)!=null?c:void 0,modelId:(s=b.model)!=null?s:void 0,headers:C,body:R},warnings:m,providerMetadata:(()=>{var f,u,H,U,W;let Z={usage:b.usage,cacheCreationInputTokens:(f=b.usage.cache_creation_input_tokens)!=null?f:null,stopSequence:(u=b.stop_sequence)!=null?u:null,iterations:b.usage.iterations?b.usage.iterations.map(A=>({type:A.type,inputTokens:A.input_tokens,outputTokens:A.output_tokens})):null,container:b.container?{expiresAt:b.container.expires_at,id:b.container.id,skills:(U=(H=b.container.skills)==null?void 0:H.map(A=>({type:A.type,skillId:A.skill_id,version:A.version})))!=null?U:null}:null,contextManagement:(W=Fo(b.context_management))!=null?W:null},q={anthropic:Z};return _&&v!=="anthropic"&&(q[v]=Z),q})()}}async doStream(t){var o,n;let{args:a,warnings:r,betas:i,usesJsonResponseTool:c,toolNameMapping:s,providerOptionsName:g,usedCustomProviderKey:m}=await this.getArgs({...t,stream:!0,userSuppliedBetas:await this.getBetasFromHeaders(t.headers)}),l=[...this.extractCitationDocuments(t.prompt)],p=Lo(a.tools),h=this.buildRequestUrl(!0),{responseHeaders:v,value:_}=await se({url:h,headers:await this.getHeaders({betas:i,headers:t.headers}),body:this.transformRequestBody(a,i),failedResponseHandler:Mo,successfulResponseHandler:xe(pa),abortSignal:t.abortSignal,fetch:this.config.fetch}),y={unified:"other",raw:void 0},S={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0,iterations:null},C={},b={},R={},O=null,V,L=null,P=null,f=null,u=!1,H,U=this.generateId,W=_.pipeThrough(new TransformStream({start($){$.enqueue({type:"stream-start",warnings:r})},transform($,j){var E,D,J,z,B,ae,K,ee,w,Y,G,Q,T,M;if(t.includeRawChunks&&j.enqueue({type:"raw",rawValue:$.rawValue}),!$.success){j.enqueue({type:"error",error:$.error});return}let N=$.value;switch(N.type){case"ping":return;case"content_block_start":{let x=N.content_block,ne=x.type;switch(H=ne,ne){case"text":{if(c)return;C[N.index]={type:"text"},j.enqueue({type:"text-start",id:String(N.index)});return}case"thinking":{C[N.index]={type:"reasoning"},j.enqueue({type:"reasoning-start",id:String(N.index)});return}case"redacted_thinking":{C[N.index]={type:"reasoning"},j.enqueue({type:"reasoning-start",id:String(N.index),providerMetadata:{anthropic:{redactedData:x.data}}});return}case"compaction":{C[N.index]={type:"text"},j.enqueue({type:"text-start",id:String(N.index),providerMetadata:{anthropic:{type:"compaction"}}});return}case"tool_use":{if(c&&x.name==="json")u=!0,C[N.index]={type:"text"},j.enqueue({type:"text-start",id:String(N.index)});else{let me=x.caller,be=me?{type:me.type,toolId:"tool_id"in me?me.tool_id:void 0}:void 0,qe=x.input&&Object.keys(x.input).length>0?JSON.stringify(x.input):"";C[N.index]={type:"tool-call",toolCallId:x.id,toolName:x.name,input:qe,firstDelta:qe.length===0,...be&&{caller:be}},j.enqueue({type:"tool-input-start",id:x.id,toolName:x.name})}return}case"server_tool_use":{if(["web_fetch","web_search","code_execution","text_editor_code_execution","bash_code_execution"].includes(x.name)){let X=x.name==="text_editor_code_execution"||x.name==="bash_code_execution"?"code_execution":x.name,me=s.toCustomToolName(X),be=x.input!=null&&typeof x.input=="object"&&Object.keys(x.input).length>0?JSON.stringify(x.input):"";C[N.index]={type:"tool-call",toolCallId:x.id,toolName:me,input:be,providerExecuted:!0,...p&&X==="code_execution"?{dynamic:!0}:{},firstDelta:!0,providerToolName:x.name},j.enqueue({type:"tool-input-start",id:x.id,toolName:me,providerExecuted:!0,...p&&X==="code_execution"?{dynamic:!0}:{}})}else if(x.name==="tool_search_tool_regex"||x.name==="tool_search_tool_bm25"){R[x.id]=x.name;let X=s.toCustomToolName(x.name);C[N.index]={type:"tool-call",toolCallId:x.id,toolName:X,input:"",providerExecuted:!0,firstDelta:!0,providerToolName:x.name},j.enqueue({type:"tool-input-start",id:x.id,toolName:X,providerExecuted:!0})}return}case"web_fetch_tool_result":{x.content.type==="web_fetch_result"?(l.push({title:(E=x.content.content.title)!=null?E:x.content.url,mediaType:x.content.content.source.media_type}),j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName("web_fetch"),result:{type:"web_fetch_result",url:x.content.url,retrievedAt:x.content.retrieved_at,content:{type:x.content.content.type,title:x.content.content.title,citations:x.content.content.citations,source:{type:x.content.content.source.type,mediaType:x.content.content.source.media_type,data:x.content.content.source.data}}}})):x.content.type==="web_fetch_tool_result_error"&&j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName("web_fetch"),isError:!0,result:{type:"web_fetch_tool_result_error",errorCode:x.content.error_code}});return}case"web_search_tool_result":{if(Array.isArray(x.content)){j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName("web_search"),result:x.content.map(X=>{var me;return{url:X.url,title:X.title,pageAge:(me=X.page_age)!=null?me:null,encryptedContent:X.encrypted_content,type:X.type}})});for(let X of x.content)j.enqueue({type:"source",sourceType:"url",id:U(),url:X.url,title:X.title,providerMetadata:{anthropic:{pageAge:(D=X.page_age)!=null?D:null}}})}else j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName("web_search"),isError:!0,result:{type:"web_search_tool_result_error",errorCode:x.content.error_code}});return}case"code_execution_tool_result":{x.content.type==="code_execution_result"?j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName("code_execution"),result:{type:x.content.type,stdout:x.content.stdout,stderr:x.content.stderr,return_code:x.content.return_code,content:(J=x.content.content)!=null?J:[]}}):x.content.type==="encrypted_code_execution_result"?j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName("code_execution"),result:{type:x.content.type,encrypted_stdout:x.content.encrypted_stdout,stderr:x.content.stderr,return_code:x.content.return_code,content:(z=x.content.content)!=null?z:[]}}):x.content.type==="code_execution_tool_result_error"&&j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName("code_execution"),isError:!0,result:{type:"code_execution_tool_result_error",errorCode:x.content.error_code}});return}case"bash_code_execution_tool_result":case"text_editor_code_execution_tool_result":{j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName("code_execution"),result:x.content});return}case"tool_search_tool_result":{let X=R[x.tool_use_id];if(X==null){let me=s.toCustomToolName("tool_search_tool_bm25"),be=s.toCustomToolName("tool_search_tool_regex");me!=="tool_search_tool_bm25"?X="tool_search_tool_bm25":X="tool_search_tool_regex"}x.content.type==="tool_search_tool_search_result"?j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName(X),result:x.content.tool_references.map(me=>({type:me.type,toolName:me.tool_name}))}):j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName(X),isError:!0,result:{type:"tool_search_tool_result_error",errorCode:x.content.error_code}});return}case"mcp_tool_use":{b[x.id]={type:"tool-call",toolCallId:x.id,toolName:x.name,input:JSON.stringify(x.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:"mcp-tool-use",serverName:x.server_name}}},j.enqueue(b[x.id]);return}case"mcp_tool_result":{j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:b[x.tool_use_id].toolName,isError:x.is_error,result:x.content,dynamic:!0,providerMetadata:b[x.tool_use_id].providerMetadata});return}default:{let X=ne;throw new Error(`Unsupported content block type: ${X}`)}}}case"content_block_stop":{if(C[N.index]!=null){let x=C[N.index];switch(x.type){case"text":{j.enqueue({type:"text-end",id:String(N.index)});break}case"reasoning":{j.enqueue({type:"reasoning-end",id:String(N.index)});break}case"tool-call":if(!(c&&x.toolName==="json")){j.enqueue({type:"tool-input-end",id:x.toolCallId});let X=x.input===""?"{}":x.input;if(x.providerToolName==="code_execution")try{let me=JSON.parse(X);me!=null&&typeof me=="object"&&"code"in me&&!("type"in me)&&(X=JSON.stringify({type:"programmatic-tool-call",...me}))}catch{}j.enqueue({type:"tool-call",toolCallId:x.toolCallId,toolName:x.toolName,input:X,providerExecuted:x.providerExecuted,...p&&x.providerToolName==="code_execution"?{dynamic:!0}:{},...x.caller&&{providerMetadata:{anthropic:{caller:x.caller}}}})}break}delete C[N.index]}H=void 0;return}case"content_block_delta":{let x=N.delta.type;switch(x){case"text_delta":{if(c)return;j.enqueue({type:"text-delta",id:String(N.index),delta:N.delta.text});return}case"thinking_delta":{j.enqueue({type:"reasoning-delta",id:String(N.index),delta:N.delta.thinking});return}case"signature_delta":{H==="thinking"&&j.enqueue({type:"reasoning-delta",id:String(N.index),delta:"",providerMetadata:{anthropic:{signature:N.delta.signature}}});return}case"compaction_delta":{N.delta.content!=null&&j.enqueue({type:"text-delta",id:String(N.index),delta:N.delta.content});return}case"input_json_delta":{let ne=C[N.index],X=N.delta.partial_json;if(X.length===0)return;if(u){if(ne?.type!=="text")return;j.enqueue({type:"text-delta",id:String(N.index),delta:X})}else{if(ne?.type!=="tool-call")return;ne.firstDelta&&(ne.providerToolName==="bash_code_execution"||ne.providerToolName==="text_editor_code_execution")&&(X=`{"type": "${ne.providerToolName}",${X.substring(1)}`),j.enqueue({type:"tool-input-delta",id:ne.toolCallId,delta:X}),ne.input+=X,ne.firstDelta=!1}return}case"citations_delta":{let ne=N.delta.citation,X=$o(ne,l,U);X&&j.enqueue(X);return}default:{let ne=x;throw new Error(`Unsupported delta type: ${ne}`)}}}case"message_start":{if(S.input_tokens=N.message.usage.input_tokens,S.cache_read_input_tokens=(B=N.message.usage.cache_read_input_tokens)!=null?B:0,S.cache_creation_input_tokens=(ae=N.message.usage.cache_creation_input_tokens)!=null?ae:0,V={...N.message.usage},L=(K=N.message.usage.cache_creation_input_tokens)!=null?K:null,N.message.container!=null&&(f={expiresAt:N.message.container.expires_at,id:N.message.container.id,skills:null}),N.message.stop_reason!=null&&(y={unified:Dt({finishReason:N.message.stop_reason,isJsonResponseFromTool:u}),raw:N.message.stop_reason}),j.enqueue({type:"response-metadata",id:(ee=N.message.id)!=null?ee:void 0,modelId:(w=N.message.model)!=null?w:void 0}),N.message.content!=null)for(let x=0;x<N.message.content.length;x++){let ne=N.message.content[x];if(ne.type==="tool_use"){let X=ne.caller,me=X?{type:X.type,toolId:"tool_id"in X?X.tool_id:void 0}:void 0;j.enqueue({type:"tool-input-start",id:ne.id,toolName:ne.name});let be=JSON.stringify((Y=ne.input)!=null?Y:{});j.enqueue({type:"tool-input-delta",id:ne.id,delta:be}),j.enqueue({type:"tool-input-end",id:ne.id}),j.enqueue({type:"tool-call",toolCallId:ne.id,toolName:ne.name,input:be,...me&&{providerMetadata:{anthropic:{caller:me}}}})}}return}case"message_delta":{N.usage.input_tokens!=null&&S.input_tokens!==N.usage.input_tokens&&(S.input_tokens=N.usage.input_tokens),S.output_tokens=N.usage.output_tokens,N.usage.cache_read_input_tokens!=null&&(S.cache_read_input_tokens=N.usage.cache_read_input_tokens),N.usage.cache_creation_input_tokens!=null&&(S.cache_creation_input_tokens=N.usage.cache_creation_input_tokens,L=N.usage.cache_creation_input_tokens),N.usage.iterations!=null&&(S.iterations=N.usage.iterations),y={unified:Dt({finishReason:N.delta.stop_reason,isJsonResponseFromTool:u}),raw:(G=N.delta.stop_reason)!=null?G:void 0},P=(Q=N.delta.stop_sequence)!=null?Q:null,f=N.delta.container!=null?{expiresAt:N.delta.container.expires_at,id:N.delta.container.id,skills:(M=(T=N.delta.container.skills)==null?void 0:T.map(x=>({type:x.type,skillId:x.skill_id,version:x.version})))!=null?M:null}:null,N.context_management&&(O=Fo(N.context_management)),V={...V,...N.usage};return}case"message_stop":{let x={usage:V??null,cacheCreationInputTokens:L,stopSequence:P,iterations:S.iterations?S.iterations.map(X=>({type:X.type,inputTokens:X.input_tokens,outputTokens:X.output_tokens})):null,container:f,contextManagement:O},ne={anthropic:x};m&&g!=="anthropic"&&(ne[g]=x),j.enqueue({type:"finish",finishReason:y,usage:Uo({usage:S,rawUsage:V}),providerMetadata:ne});return}case"error":{j.enqueue({type:"error",error:N.error});return}default:{let x=N;throw new Error(`Unsupported chunk type: ${x}`)}}}})),[Z,q]=W.tee(),A=Z.getReader();try{await A.read();let $=await A.read();if(((o=$.value)==null?void 0:o.type)==="raw"&&($=await A.read()),((n=$.value)==null?void 0:n.type)==="error"){let j=$.value.error;throw new yt({message:j.message,url:h,requestBodyValues:a,statusCode:j.type==="overloaded_error"?529:500,responseHeaders:v,responseBody:JSON.stringify(j),isRetryable:j.type==="overloaded_error"})}}finally{A.cancel().catch(()=>{}),A.releaseLock()}return{stream:q,request:{body:a},response:{headers:v}}}};function sr(t){return t.includes("claude-opus-4-7")?{maxOutputTokens:128e3,supportsStructuredOutput:!0,rejectsSamplingParameters:!0,isKnownModel:!0}:t.includes("claude-sonnet-4-6")||t.includes("claude-opus-4-6")?{maxOutputTokens:128e3,supportsStructuredOutput:!0,rejectsSamplingParameters:!1,isKnownModel:!0}:t.includes("claude-sonnet-4-5")||t.includes("claude-opus-4-5")||t.includes("claude-haiku-4-5")?{maxOutputTokens:64e3,supportsStructuredOutput:!0,rejectsSamplingParameters:!1,isKnownModel:!0}:t.includes("claude-opus-4-1")?{maxOutputTokens:32e3,supportsStructuredOutput:!0,rejectsSamplingParameters:!1,isKnownModel:!0}:t.includes("claude-sonnet-4-")?{maxOutputTokens:64e3,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,isKnownModel:!0}:t.includes("claude-opus-4-")?{maxOutputTokens:32e3,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,isKnownModel:!0}:t.includes("claude-3-haiku")?{maxOutputTokens:4096,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,isKnownModel:!0}:{maxOutputTokens:4096,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,isKnownModel:!1}}function Lo(t){if(!t)return!1;let o=!1,n=!1;for(let a of t){if("type"in a&&(a.type==="web_fetch_20260209"||a.type==="web_search_20260209")){o=!0;continue}if(a.name==="code_execution"){n=!0;break}}return o&&!n}function Fo(t){return t?{appliedEdits:t.applied_edits.map(o=>{switch(o.type){case"clear_tool_uses_20250919":return{type:o.type,clearedToolUses:o.cleared_tool_uses,clearedInputTokens:o.cleared_input_tokens};case"clear_thinking_20251015":return{type:o.type,clearedThinkingTurns:o.cleared_thinking_turns,clearedInputTokens:o.cleared_input_tokens};case"compact_20260112":return{type:o.type}}}).filter(o=>o!==void 0)}:null}var lr=I(()=>k(e.object({command:e.string(),restart:e.boolean().optional()}))),cr=ue({id:"anthropic.bash_20241022",inputSchema:lr}),ur=I(()=>k(e.object({command:e.string(),restart:e.boolean().optional()}))),dr=ue({id:"anthropic.bash_20250124",inputSchema:ur}),pr=I(()=>k(e.object({action:e.enum(["key","type","mouse_move","left_click","left_click_drag","right_click","middle_click","double_click","screenshot","cursor_position"]),coordinate:e.array(e.number().int()).optional(),text:e.string().optional()}))),mr=ue({id:"anthropic.computer_20241022",inputSchema:pr}),hr=I(()=>k(e.object({action:e.enum(["key","hold_key","type","cursor_position","mouse_move","left_mouse_down","left_mouse_up","left_click","left_click_drag","right_click","middle_click","double_click","triple_click","scroll","wait","screenshot"]),coordinate:e.tuple([e.number().int(),e.number().int()]).optional(),duration:e.number().optional(),scroll_amount:e.number().optional(),scroll_direction:e.enum(["up","down","left","right"]).optional(),start_coordinate:e.tuple([e.number().int(),e.number().int()]).optional(),text:e.string().optional()}))),gr=ue({id:"anthropic.computer_20250124",inputSchema:hr}),_r=I(()=>k(e.object({action:e.enum(["key","hold_key","type","cursor_position","mouse_move","left_mouse_down","left_mouse_up","left_click","left_click_drag","right_click","middle_click","double_click","triple_click","scroll","wait","screenshot","zoom"]),coordinate:e.tuple([e.number().int(),e.number().int()]).optional(),duration:e.number().optional(),region:e.tuple([e.number().int(),e.number().int(),e.number().int(),e.number().int()]).optional(),scroll_amount:e.number().optional(),scroll_direction:e.enum(["up","down","left","right"]).optional(),start_coordinate:e.tuple([e.number().int(),e.number().int()]).optional(),text:e.string().optional()}))),fr=ue({id:"anthropic.computer_20251124",inputSchema:_r}),yr=I(()=>k(e.discriminatedUnion("command",[e.object({command:e.literal("view"),path:e.string(),view_range:e.tuple([e.number(),e.number()]).optional()}),e.object({command:e.literal("create"),path:e.string(),file_text:e.string()}),e.object({command:e.literal("str_replace"),path:e.string(),old_str:e.string(),new_str:e.string()}),e.object({command:e.literal("insert"),path:e.string(),insert_line:e.number(),insert_text:e.string()}),e.object({command:e.literal("delete"),path:e.string()}),e.object({command:e.literal("rename"),old_path:e.string(),new_path:e.string()})]))),br=ue({id:"anthropic.memory_20250818",inputSchema:yr}),vr=I(()=>k(e.object({command:e.enum(["view","create","str_replace","insert","undo_edit"]),path:e.string(),file_text:e.string().optional(),insert_line:e.number().int().optional(),new_str:e.string().optional(),insert_text:e.string().optional(),old_str:e.string().optional(),view_range:e.array(e.number().int()).optional()}))),xr=ue({id:"anthropic.text_editor_20241022",inputSchema:vr}),wr=I(()=>k(e.object({command:e.enum(["view","create","str_replace","insert","undo_edit"]),path:e.string(),file_text:e.string().optional(),insert_line:e.number().int().optional(),new_str:e.string().optional(),insert_text:e.string().optional(),old_str:e.string().optional(),view_range:e.array(e.number().int()).optional()}))),Cr=ue({id:"anthropic.text_editor_20250124",inputSchema:wr}),Ir=I(()=>k(e.object({command:e.enum(["view","create","str_replace","insert"]),path:e.string(),file_text:e.string().optional(),insert_line:e.number().int().optional(),new_str:e.string().optional(),insert_text:e.string().optional(),old_str:e.string().optional(),view_range:e.array(e.number().int()).optional()}))),kr=ue({id:"anthropic.text_editor_20250429",inputSchema:Ir}),Sr=I(()=>k(e.array(e.object({type:e.literal("tool_reference"),toolName:e.string()})))),Tr=I(()=>k(e.object({query:e.string(),limit:e.number().optional()}))),jr=ie({id:"anthropic.tool_search_bm25_20251119",inputSchema:Tr,outputSchema:Sr,supportsDeferredResults:!0}),Rr=(t={})=>jr(t),Ar={bash_20241022:cr,bash_20250124:dr,codeExecution_20250522:$a,codeExecution_20250825:Ha,codeExecution_20260120:Wa,computer_20241022:mr,computer_20250124:gr,computer_20251124:fr,memory_20250818:br,textEditor_20241022:xr,textEditor_20250124:Cr,textEditor_20250429:kr,textEditor_20250728:ya,webFetch_20250910:Pa,webFetch_20260209:Na,webSearch_20250305:Ta,webSearch_20260209:Ca,toolSearchRegex_20251119:Ka,toolSearchBm25_20251119:Rr};function Ut(t={}){var o,n;let a=(o=Ee(wt({settingValue:t.baseURL,environmentVariableName:"ANTHROPIC_BASE_URL"})))!=null?o:"https://api.anthropic.com/v1",r=(n=t.name)!=null?n:"anthropic.messages";if(t.apiKey&&t.authToken)throw new _o({argument:"apiKey/authToken",message:"Both apiKey and authToken were provided. Please use only one authentication method."});let i=()=>{let g=t.authToken?{Authorization:`Bearer ${t.authToken}`}:{"x-api-key":Je({apiKey:t.apiKey,environmentVariableName:"ANTHROPIC_API_KEY",description:"Anthropic"})};return Ne({"anthropic-version":"2023-06-01",...g,...t.headers},`ai-sdk/anthropic/${ca}`)},c=g=>{var m;return new ir(g,{provider:r,baseURL:a,headers:i,fetch:t.fetch,generateId:(m=t.generateId)!=null?m:pe,supportedUrls:()=>({"image/*":[/^https?:\/\/.*$/],"application/pdf":[/^https?:\/\/.*$/]})})},s=function(g){if(new.target)throw new Error("The Anthropic model function cannot be called with the new keyword.");return c(g)};return s.specificationVersion="v3",s.languageModel=c,s.chat=c,s.messages=c,s.embeddingModel=g=>{throw new Nt({modelId:g,modelType:"embeddingModel"})},s.textEmbeddingModel=s.embeddingModel,s.imageModel=g=>{throw new Nt({modelId:g,modelType:"imageModel"})},s.tools=Ar,s}var ou=Ut();var Or="3.0.67",Nr=I(()=>k(e.object({error:e.object({code:e.number().nullable(),message:e.string(),status:e.string()})}))),Le=ye({errorSchema:Nr,errorToMessage:t=>t.error.message}),Er=e.union([e.object({text:e.string()}),e.object({inlineData:e.object({mimeType:e.string(),data:e.string()})})]),zr=I(()=>k(e.object({outputDimensionality:e.number().optional(),taskType:e.enum(["SEMANTIC_SIMILARITY","CLASSIFICATION","CLUSTERING","RETRIEVAL_DOCUMENT","RETRIEVAL_QUERY","QUESTION_ANSWERING","FACT_VERIFICATION","CODE_RETRIEVAL_QUERY"]).optional(),content:e.array(e.array(Er).min(1).nullable()).optional()}))),Mr=class{constructor(t,o){this.specificationVersion="v3",this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0,this.modelId=t,this.config=o}get provider(){return this.config.provider}async doEmbed({values:t,headers:o,abortSignal:n,providerOptions:a}){let r=await te({provider:"google",providerOptions:a,schema:zr});if(t.length>this.maxEmbeddingsPerCall)throw new Ve({provider:this.provider,modelId:this.modelId,maxEmbeddingsPerCall:this.maxEmbeddingsPerCall,values:t});let i=re(await ve(this.config.headers),o),c=r?.content;if(c!=null&&c.length!==t.length)throw new Error(`The number of multimodal content entries (${c.length}) must match the number of values (${t.length}).`);if(t.length===1){let l=c?.[0],p=t[0]?[{text:t[0]}]:[],h=l!=null?[...p,...l]:[{text:t[0]}],{responseHeaders:v,value:_,rawValue:y}=await se({url:`${this.config.baseURL}/models/${this.modelId}:embedContent`,headers:i,body:{model:`models/${this.modelId}`,content:{parts:h},outputDimensionality:r?.outputDimensionality,taskType:r?.taskType},failedResponseHandler:Le,successfulResponseHandler:de(Dr),abortSignal:n,fetch:this.config.fetch});return{warnings:[],embeddings:[_.embedding.values],usage:void 0,response:{headers:v,body:y}}}let{responseHeaders:s,value:g,rawValue:m}=await se({url:`${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,headers:i,body:{requests:t.map((l,p)=>{let h=c?.[p],v=l?[{text:l}]:[];return{model:`models/${this.modelId}`,content:{role:"user",parts:h!=null?[...v,...h]:[{text:l}]},outputDimensionality:r?.outputDimensionality,taskType:r?.taskType}})},failedResponseHandler:Le,successfulResponseHandler:de(Pr),abortSignal:n,fetch:this.config.fetch});return{warnings:[],embeddings:g.embeddings.map(l=>l.values),usage:void 0,response:{headers:s,body:m}}}},Pr=I(()=>k(e.object({embeddings:e.array(e.object({values:e.array(e.number())}))}))),Dr=I(()=>k(e.object({embedding:e.object({values:e.array(e.number())})})));function Xo(t){var o,n,a,r;if(t==null)return{inputTokens:{total:void 0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:void 0,text:void 0,reasoning:void 0},raw:void 0};let i=(o=t.promptTokenCount)!=null?o:0,c=(n=t.candidatesTokenCount)!=null?n:0,s=(a=t.cachedContentTokenCount)!=null?a:0,g=(r=t.thoughtsTokenCount)!=null?r:0;return{inputTokens:{total:i,noCache:i-s,cacheRead:s,cacheWrite:void 0},outputTokens:{total:c+g,text:c,reasoning:g},raw:t}}function ke(t,o=!0){if(t==null)return;if(qr(t))return o?void 0:typeof t=="object"&&t.description?{type:"object",description:t.description}:{type:"object"};if(typeof t=="boolean")return{type:"boolean",properties:{}};let{type:n,description:a,required:r,properties:i,items:c,allOf:s,anyOf:g,oneOf:m,format:l,const:p,minLength:h,enum:v}=t,_={};if(a&&(_.description=a),r&&(_.required=r),l&&(_.format=l),p!==void 0&&(_.enum=[p]),n)if(Array.isArray(n)){let y=n.includes("null"),S=n.filter(C=>C!=="null");S.length===0?_.type="null":(_.anyOf=S.map(C=>({type:C})),y&&(_.nullable=!0))}else _.type=n;if(v!==void 0&&(_.enum=v),i!=null&&(_.properties=Object.entries(i).reduce((y,[S,C])=>(y[S]=ke(C,!1),y),{})),c&&(_.items=Array.isArray(c)?c.map(y=>ke(y,!1)):ke(c,!1)),s&&(_.allOf=s.map(y=>ke(y,!1))),g)if(g.some(y=>typeof y=="object"&&y?.type==="null")){let y=g.filter(S=>!(typeof S=="object"&&S?.type==="null"));if(y.length===1){let S=ke(y[0],!1);typeof S=="object"&&(_.nullable=!0,Object.assign(_,S))}else _.anyOf=y.map(S=>ke(S,!1)),_.nullable=!0}else _.anyOf=g.map(y=>ke(y,!1));return m&&(_.oneOf=m.map(y=>ke(y,!1))),h!==void 0&&(_.minLength=h),_}function qr(t){return t!=null&&typeof t=="object"&&t.type==="object"&&(t.properties==null||Object.keys(t.properties).length===0)&&!t.additionalProperties}var Ur=/^data:([^;,]+);base64,(.+)$/s;function $r(t){let o=Ur.exec(t);if(o!=null)return{mediaType:o[1],data:o[2]}}function Lr(t){let o=$r(t);if(o!=null)return{inlineData:{mimeType:o.mediaType,data:o.data}}}function Fr(t,o,n){let a=[],r=[];for(let i of n)switch(i.type){case"text":{r.push(i.text);break}case"image-data":case"file-data":{a.push({inlineData:{mimeType:i.mediaType,data:i.data}});break}case"image-url":case"file-url":{let c=Lr(i.url);c!=null?a.push(c):r.push(JSON.stringify(i));break}default:{r.push(JSON.stringify(i));break}}t.push({functionResponse:{name:o,response:{name:o,content:r.length>0?r.join(`
3
3
  `):"Tool executed successfully."},...a.length>0?{parts:a}:{}}})}function Hr(t,o,n){for(let a of n)switch(a.type){case"text":t.push({functionResponse:{name:o,response:{name:o,content:a.text}}});break;case"image-data":t.push({inlineData:{mimeType:String(a.mediaType),data:String(a.data)}},{text:"Tool executed successfully and returned this image as a response"});break;default:t.push({text:JSON.stringify(a)});break}}function Vr(t,o){var n,a,r,i,c,s,g,m;let l=[],p=[],h=!0,v=(n=o?.isGemmaModel)!=null?n:!1,_=(a=o?.providerOptionsName)!=null?a:"google",y=(r=o?.supportsFunctionResponseParts)!=null?r:!0;for(let{role:S,content:C}of t)switch(S){case"system":{if(!h)throw new le({functionality:"system messages are only supported at the beginning of the conversation"});l.push({text:C});break}case"user":{h=!1;let b=[];for(let R of C)switch(R.type){case"text":{b.push({text:R.text});break}case"file":{let O=R.mediaType==="image/*"?"image/jpeg":R.mediaType;b.push(R.data instanceof URL?{fileData:{mimeType:O,fileUri:R.data.toString()}}:{inlineData:{mimeType:O,data:_e(R.data)}});break}}p.push({role:"user",parts:b});break}case"assistant":{h=!1,p.push({role:"model",parts:C.map(b=>{var R,O,V,L;let P=(L=(R=b.providerOptions)==null?void 0:R[_])!=null?L:_!=="google"?(O=b.providerOptions)==null?void 0:O.google:(V=b.providerOptions)==null?void 0:V.vertex,f=P?.thoughtSignature!=null?String(P.thoughtSignature):void 0;switch(b.type){case"text":return b.text.length===0?void 0:{text:b.text,thoughtSignature:f};case"reasoning":return b.text.length===0?void 0:{text:b.text,thought:!0,thoughtSignature:f};case"file":{if(b.data instanceof URL)throw new le({functionality:"File data URLs in assistant messages are not supported"});return{inlineData:{mimeType:b.mediaType,data:_e(b.data)},...P?.thought===!0?{thought:!0}:{},thoughtSignature:f}}case"tool-call":{let u=P?.serverToolCallId!=null?String(P.serverToolCallId):void 0,H=P?.serverToolType!=null?String(P.serverToolType):void 0;return u&&H?{toolCall:{toolType:H,args:typeof b.input=="string"?JSON.parse(b.input):b.input,id:u},thoughtSignature:f}:{functionCall:{name:b.toolName,args:b.input},thoughtSignature:f}}case"tool-result":{let u=P?.serverToolCallId!=null?String(P.serverToolCallId):void 0,H=P?.serverToolType!=null?String(P.serverToolType):void 0;return u&&H?{toolResponse:{toolType:H,response:b.output.type==="json"?b.output.value:{},id:u},thoughtSignature:f}:void 0}}}).filter(b=>b!==void 0)});break}case"tool":{h=!1;let b=[];for(let R of C){if(R.type==="tool-approval-response")continue;let O=(g=(i=R.providerOptions)==null?void 0:i[_])!=null?g:_!=="google"?(c=R.providerOptions)==null?void 0:c.google:(s=R.providerOptions)==null?void 0:s.vertex,V=O?.serverToolCallId!=null?String(O.serverToolCallId):void 0,L=O?.serverToolType!=null?String(O.serverToolType):void 0;if(V&&L){let f=O?.thoughtSignature!=null?String(O.thoughtSignature):void 0;if(p.length>0){let u=p[p.length-1];if(u.role==="model"){u.parts.push({toolResponse:{toolType:L,response:R.output.type==="json"?R.output.value:{},id:V},thoughtSignature:f});continue}}}let P=R.output;P.type==="content"?y?Fr(b,R.toolName,P.value):Hr(b,R.toolName,P.value):b.push({functionResponse:{name:R.toolName,response:{name:R.toolName,content:P.type==="execution-denied"?(m=P.reason)!=null?m:"Tool execution denied.":P.value}}})}p.push({role:"user",parts:b});break}}if(v&&l.length>0&&p.length>0&&p[0].role==="user"){let S=l.map(C=>C.text).join(`
4
4
 
@@ -1 +1 @@
1
- import{a as p,d as U,e as g}from"./chunk-H37RXS4R.js";import{e as u}from"./chunk-WASID5UU.js";import{Fa as d,Ga as t,a as f,aa as v,j as x}from"./chunk-WRA24P66.js";import{d as c}from"./chunk-KUCVLANF.js";x();function A(e){let a=e.size||30,l=e.withTooltip!==!1,{profile:_}=g(e.profile===void 0?e.email:null),s=e.profile!==void 0?e.profile:_,r=s?.email||e.email||"",i=s?.displayName||"",o=s?.photoURL||"",[n,h]=f(!1),m=t(v,{className:u("UserAvatar",e.inactive&&"UserAvatar--inactive",e.className),src:!n&&o?o:void 0,alt:i||r,size:a,radius:"xl",style:!o||n?{backgroundColor:U(r||i||"?"),color:"#fff",fontWeight:600,fontSize:Math.max(10,Math.round(a*.4))}:void 0,imageProps:{onError:()=>h(!0)},children:!o||n?p(r,i):null});return l?t(A.Tooltip,{email:r,displayName:i,children:m}):m}A.Tooltip=function(a){if(!a.email&&!a.displayName)return t(c,{children:a.children});let l=t("div",{className:"UserAvatar__tooltip",children:[a.displayName&&t("div",{className:"UserAvatar__tooltip__name",children:a.displayName}),a.email&&t("div",{className:"UserAvatar__tooltip__email",children:a.email})]});return t(d,{label:l,position:"bottom",withArrow:!0,transition:"pop",children:a.children})};export{A as a};
1
+ import{a as p,d as U,e as g}from"./chunk-HKCOKHA2.js";import{e as u}from"./chunk-GJ7ES2LA.js";import{Fa as d,a as f,aa as v,fd as t,j as x}from"./chunk-Y7RYSRP7.js";import{d as c}from"./chunk-KUCVLANF.js";x();function A(e){let a=e.size||30,l=e.withTooltip!==!1,{profile:_}=g(e.profile===void 0?e.email:null),s=e.profile!==void 0?e.profile:_,r=s?.email||e.email||"",i=s?.displayName||"",o=s?.photoURL||"",[n,h]=f(!1),m=t(v,{className:u("UserAvatar",e.inactive&&"UserAvatar--inactive",e.className),src:!n&&o?o:void 0,alt:i||r,size:a,radius:"xl",style:!o||n?{backgroundColor:U(r||i||"?"),color:"#fff",fontWeight:600,fontSize:Math.max(10,Math.round(a*.4))}:void 0,imageProps:{onError:()=>h(!0)},children:!o||n?p(r,i):null});return l?t(A.Tooltip,{email:r,displayName:i,children:m}):m}A.Tooltip=function(a){if(!a.email&&!a.displayName)return t(c,{children:a.children});let l=t("div",{className:"UserAvatar__tooltip",children:[a.displayName&&t("div",{className:"UserAvatar__tooltip__name",children:a.displayName}),a.email&&t("div",{className:"UserAvatar__tooltip__email",children:a.email})]});return t(d,{label:l,position:"bottom",withArrow:!0,transition:"pop",children:a.children})};export{A as a};
@@ -1 +1 @@
1
- import{a,h as n,j as s}from"./chunk-WRA24P66.js";s();s();function T(e,r){let[c,i]=a(()=>{try{let t=window.localStorage.getItem(e);return t?JSON.parse(t):r}catch(t){return console.error(t),r}}),u=n(t=>{i(l=>{let o=typeof t=="function"?t(l):t;return window.localStorage.setItem(e,JSON.stringify(o)),o})},[e]);return[c,u]}export{T as a};
1
+ import{a,h as n,j as s}from"./chunk-Y7RYSRP7.js";s();s();function T(e,r){let[c,i]=a(()=>{try{let t=window.localStorage.getItem(e);return t?JSON.parse(t):r}catch(t){return console.error(t),r}}),u=n(t=>{i(l=>{let o=typeof t=="function"?t(l):t;return window.localStorage.setItem(e,JSON.stringify(o)),o})},[e]);return[c,u]}export{T as a};
@@ -1 +1 @@
1
- import{a as F,b as B,c as U}from"./chunk-2RRM4HEQ.js";import{a as H}from"./chunk-OWYV43BT.js";import{b as j}from"./chunk-ATTW36EM.js";import{a as N}from"./chunk-PLYSJ7W5.js";import{E as z,a as A}from"./chunk-XOWWPE7X.js";import{e as w}from"./chunk-WASID5UU.js";import{Da as O,F as P,Fa as f,Ga as t,Gc as E,U as y,V as x,a as _,c as T,da as l,g as b,j as tt,sa as v,ua as M,za as D}from"./chunk-WRA24P66.js";import{d as $}from"./chunk-KUCVLANF.js";tt();var et=50,at=["doc.save","doc.publish","doc.restore_version","doc.import_translations","doc.revert"],ot=[{value:"all",label:"All time"},{value:"1h",label:"Last hour"},{value:"24h",label:"Last 24 hours"},{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"}];function W(a){let[e,o]=_(!0),[n,s]=_([]);return T(()=>{z(a?{limit:a}:void 0).then(m=>{s(m),o(!1)})},[a]),{loading:e,actions:n}}function Pt(a){if(a.compact)return t(ct,{...a});let[e,o]=_(""),[n]=P(e,300),[s,m]=_([]),[h,V]=_([]),[g,q]=_("all"),{actions:r,loading:X}=W(),Y=b(()=>{let i=new Set;return r.forEach(c=>i.add(c.action)),Array.from(i).sort()},[r]),Z=b(()=>{let i=new Set;return r.forEach(c=>{c.by&&i.add(c.by)}),Array.from(i).sort()},[r]),S=b(()=>{let i=Date.now();return r.filter(c=>{if(n){let u=n.toLowerCase(),L=c.action.toLowerCase().includes(u),p=c.by?.toLowerCase().includes(u),K=ut(c.metadata).toLowerCase().includes(u);if(!L&&!p&&!K)return!1}if(s.length>0&&!s.includes(c.action)||h.length>0&&(!c.by||!h.includes(c.by)))return!1;if(g&&g!=="all"){let u=C(c.timestamp);if(!u)return!1;let L=u.toMillis(),p=0;switch(g){case"1h":p=i-3600*1e3;break;case"24h":p=i-1440*60*1e3;break;case"7d":p=i-10080*60*1e3;break;case"30d":p=i-720*60*60*1e3;break}if(L<p)return!1}return!0})},[r,n,s,h,g]),d=F(S,{pageSize:et,resetDeps:[n,s,h,g]}),k=d.pageItems;return X?t("div",{className:`ActionsLog ActionsLog--loading ${a.className||""}`,children:t(x,{color:"gray",size:"xl"})}):t("div",{className:`ActionsLog ${a.className||""}`,children:[!a.compact&&t("div",{className:"ActionsLog__tableHeader",children:[t("div",{className:"ActionsLog__filters",children:[t(M,{className:"ActionsLog__filters__search",placeholder:"Search actions...",icon:t(E,{size:16}),value:e,onChange:i=>o(i.target.value)}),t(v,{className:"ActionsLog__filters__select",placeholder:"Filter by action",clearable:!0,searchable:!0,data:Y,value:s,onChange:m}),t(v,{className:"ActionsLog__filters__select",placeholder:"Filter by user",clearable:!0,searchable:!0,data:Z,value:h,onChange:V}),t(D,{className:"ActionsLog__filters__select",placeholder:"Filter by time",data:ot,value:g,onChange:q})]}),t(U,{start:d.start,end:d.end,total:d.totalItems,noun:"action",note:S.length!==r.length?`filtered from ${r.length} total`:void 0})]}),t(H,{className:"ActionsLog__tableSurface",children:t(O,{className:"ActionsLog__table",children:[t("thead",{children:t("tr",{className:"ActionsLogs__table__row ActionsLogs__table__row--header",children:[t("th",{className:"ActionsLogs__table__header",children:"Timestamp"}),t("th",{className:"ActionsLogs__table__header",children:"User"}),t("th",{className:"ActionsLogs__table__header",children:"Action"}),t("th",{className:"ActionsLogs__table__header",children:"Details"}),t("th",{className:"ActionsLogs__table__header",children:"Links"})]})}),t("tbody",{children:[k.map((i,c)=>t("tr",{className:"ActionsLogs__table__row",children:[t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--nowrap",children:t(G,{timestamp:i.timestamp,format:"long"})}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--nowrap",children:t("span",{className:"ActionsLogs__user",children:i.by?t($,{children:[t(N,{email:i.by,size:20}),t("span",{className:"ActionsLogs__user__email",children:i.by})]}):"\u2014"})}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--action",children:t("span",{className:"ActionsLogs__action",children:i.action})}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--metadata",children:t(Q,{metadata:i.metadata})}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--links",children:t(I,{action:i})})]},c)),k.length===0&&t("tr",{children:t("td",{colSpan:5,className:"ActionsLogs__table__col ActionsLogs__table__col--empty",children:"No actions found matching your filters."})})]})]})}),t(B,{total:d.totalPages,page:d.page,onChange:d.setPage})]})}function Q(a){let{metadata:e}=a;if(!e||Object.keys(e).length===0)return t("span",{className:"ActionsLogs__metadata--empty",children:"\u2014"});let o=Object.entries(e);return t("div",{className:"ActionsLogs__metadata",children:o.map(([n,s])=>t("div",{className:"ActionsLogs__metadata__item",children:[t("span",{className:"ActionsLogs__metadata__key",children:[n,":"]})," ",t("span",{className:"ActionsLogs__metadata__value",children:nt(s)})]},n))})}function nt(a){if(a==null)return"\u2014";if(Array.isArray(a))return a.length===0?"[]":a.length<=3?a.join(", "):`${a.slice(0,3).join(", ")} (+${a.length-3} more)`;if(typeof a=="object"){let e=st(a);try{return JSON.stringify(e)}catch(o){console.error(o),console.error("failed to stringify json:",e)}}return String(a)}function st(a){let e={};return Object.entries(a).forEach(([o,n])=>{o.startsWith("_")||(e[o]=n)}),e}function I(a){let{action:e}=a,o=[];function n(s){return a.label||s}if(e.action!=="doc.delete"&&e.metadata?.docId&&o.push(t(f,{transition:"pop",label:e.metadata.docId,children:t(l,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/content/${e.metadata.docId}`,children:n("Open doc")})},"doc")),at.includes(e.action)&&e.metadata?.docId){let s=C(e.timestamp)?.toMillis();s&&o.push(t(f,{transition:"pop",label:`Show changes to ${e.metadata.docId}`,children:t(l,{component:"a",variant:"default",size:"xs",compact:!0,href:it(e.metadata.docId,s),children:n("Show changes")})},"changes"))}return e.action!=="datasource.delete"&&e.metadata?.datasourceId&&o.push(t(f,{transition:"pop",label:e.metadata.datasourceId,children:t(l,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/data/${e.metadata.datasourceId}`,children:n("Open data source")})},"datasource")),e.action!=="release.delete"&&e.metadata?.releaseId&&o.push(t(f,{transition:"pop",label:e.metadata.releaseId,children:t(l,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${e.metadata.releaseId}`,children:n("Open release")})},"release")),e.metadata?.sheetId&&o.push(t(l,{component:"a",variant:"default",size:"xs",compact:!0,href:j(e.metadata.sheetId),target:"_blank",children:n("Open sheet")},"sheet")),e.action.startsWith("acls.")&&o.push(t(l,{component:"a",variant:"default",size:"xs",compact:!0,href:"/cms/settings",children:n("Open settings")},"settings")),e.links&&e.links.forEach((s,m)=>{o.push(t(l,{component:"a",variant:"default",size:"xs",compact:!0,href:s.url,target:s.target,children:s.label},`link-${m}`))}),o.length===0?t("span",{className:"ActionsLogs__links--empty"}):(a.limit&&(o=o.slice(0,a.limit)),t("div",{className:"ActionsLogs__table__buttons",children:o}))}function it(a,e){let o=J(a,`before:${e}`),n=J(a,`after:${e}`);return`/cms/compare?left=${o}&right=${n}`}function J(a,e){return encodeURIComponent(`${a}@${e}`).replaceAll("%2F","/").replaceAll("%40","@").replaceAll("%3A",":")}function ct(a){let{actions:e,loading:o}=W(a.limit||10);return o?t("div",{className:w(a.className,"ActionLogsCompact","ActionLogsCompact--loading"),children:t(x,{color:"gray",size:"xl"})}):t("div",{className:w(a.className,"ActionLogsCompact"),children:t(y,{className:"ActionLogsCompact__table",multiple:!0,children:e.map((n,s)=>t(y.Item,{label:t(rt,{action:n}),children:t(lt,{action:n})},s))})})}function rt(a){let e=a.action,o=mt(e),n=a.action.by||"";return t("div",{className:"ActionLogsCompactItemPreview",children:[t("div",{className:"ActionLogsCompactItemPreview__user",children:t(N,{email:n,size:20})}),t("div",{className:"ActionLogsCompactItemPreview__timestamp",children:t(G,{timestamp:e.timestamp})}),t("div",{className:"ActionLogsCompactItemPreview__action",children:e.action}),t("div",{className:"ActionLogsCompactItemPreview__actionMetaId",children:o}),t("div",{className:"ActionLogsCompactItemPreview__buttons",children:t(I,{action:e,label:"Open",limit:1})})]})}function lt(a){let e=a.action,o={user:e.by,...e.metadata};return t("div",{className:"ActionLogsCompactItemDetails",children:[t(Q,{metadata:o}),t(I,{action:e})]})}function mt(a){for(let e of Object.keys(a.metadata||{}))if(e.toLowerCase().endsWith("id"))return a.metadata[e];return""}function C(a){return a?a instanceof A?a:typeof a=="object"&&typeof a._seconds=="number"?new A(a._seconds,a._nanoseconds||0):typeof a=="object"&&typeof a.seconds=="number"?new A(a.seconds,a.nanoseconds||0):typeof a=="number"?A.fromMillis(a):null:null}function G(a){let e=C(a.timestamp)?.toMillis()||0;if(!e)return t("span",{children:"Invalid date"});let o=a.format==="long"?_t(e):pt(e);return t(f,{transition:"pop",label:gt(e),children:t("span",{className:"ActionsLogs__timestamp",children:o})})}var dt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function R(a){let e=a.getHours(),o=e<12?"AM":"PM",n=String(e%12||12).padStart(2,"0"),s=String(a.getMinutes()).padStart(2,"0");return`${n}:${s} ${o}`}function pt(a){let e=new Date(a),o=String(e.getDate()).padStart(2,"0");return`${dt[e.getMonth()]} ${o}, ${R(e)}`}function _t(a){let e=new Date(a),o=e.toLocaleDateString("en",{month:"long"}),n=String(e.getDate()).padStart(2,"0");return`${o} ${n}, ${e.getFullYear()} ${R(e)}`}function gt(a){return new Date(a).toLocaleString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ut(a){function e(o){return o===null?"null":typeof o>"u"?"undefined":typeof o=="string"?`"${o.replaceAll('"','\\"')}"`:typeof o!="object"?String(o):Array.isArray(o)?`[${o.map(e).join(", ")}]`:`{${Object.entries(o).map(([s,m])=>`${s}: ${e(m)}`).join(", ")}}`}return e(a)}export{Pt as a};
1
+ import{a as F,b as B,c as U}from"./chunk-H5JL376P.js";import{a as H}from"./chunk-TCWN5YRW.js";import{b as j}from"./chunk-ATTW36EM.js";import{a as N}from"./chunk-LS2JH5QF.js";import{E as z,a as A}from"./chunk-XOWWPE7X.js";import{e as w}from"./chunk-GJ7ES2LA.js";import{Da as O,F as P,Fa as f,Gc as E,U as y,V as x,a as _,c as T,da as l,fd as t,g as b,j as tt,sa as v,ua as M,za as D}from"./chunk-Y7RYSRP7.js";import{d as $}from"./chunk-KUCVLANF.js";tt();var et=50,at=["doc.save","doc.publish","doc.restore_version","doc.import_translations","doc.revert"],ot=[{value:"all",label:"All time"},{value:"1h",label:"Last hour"},{value:"24h",label:"Last 24 hours"},{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"}];function W(a){let[e,o]=_(!0),[n,s]=_([]);return T(()=>{z(a?{limit:a}:void 0).then(m=>{s(m),o(!1)})},[a]),{loading:e,actions:n}}function Pt(a){if(a.compact)return t(ct,{...a});let[e,o]=_(""),[n]=P(e,300),[s,m]=_([]),[h,V]=_([]),[g,q]=_("all"),{actions:r,loading:X}=W(),Y=b(()=>{let i=new Set;return r.forEach(c=>i.add(c.action)),Array.from(i).sort()},[r]),Z=b(()=>{let i=new Set;return r.forEach(c=>{c.by&&i.add(c.by)}),Array.from(i).sort()},[r]),S=b(()=>{let i=Date.now();return r.filter(c=>{if(n){let u=n.toLowerCase(),L=c.action.toLowerCase().includes(u),p=c.by?.toLowerCase().includes(u),K=ut(c.metadata).toLowerCase().includes(u);if(!L&&!p&&!K)return!1}if(s.length>0&&!s.includes(c.action)||h.length>0&&(!c.by||!h.includes(c.by)))return!1;if(g&&g!=="all"){let u=C(c.timestamp);if(!u)return!1;let L=u.toMillis(),p=0;switch(g){case"1h":p=i-3600*1e3;break;case"24h":p=i-1440*60*1e3;break;case"7d":p=i-10080*60*1e3;break;case"30d":p=i-720*60*60*1e3;break}if(L<p)return!1}return!0})},[r,n,s,h,g]),d=F(S,{pageSize:et,resetDeps:[n,s,h,g]}),k=d.pageItems;return X?t("div",{className:`ActionsLog ActionsLog--loading ${a.className||""}`,children:t(x,{color:"gray",size:"xl"})}):t("div",{className:`ActionsLog ${a.className||""}`,children:[!a.compact&&t("div",{className:"ActionsLog__tableHeader",children:[t("div",{className:"ActionsLog__filters",children:[t(M,{className:"ActionsLog__filters__search",placeholder:"Search actions...",icon:t(E,{size:16}),value:e,onChange:i=>o(i.target.value)}),t(v,{className:"ActionsLog__filters__select",placeholder:"Filter by action",clearable:!0,searchable:!0,data:Y,value:s,onChange:m}),t(v,{className:"ActionsLog__filters__select",placeholder:"Filter by user",clearable:!0,searchable:!0,data:Z,value:h,onChange:V}),t(D,{className:"ActionsLog__filters__select",placeholder:"Filter by time",data:ot,value:g,onChange:q})]}),t(U,{start:d.start,end:d.end,total:d.totalItems,noun:"action",note:S.length!==r.length?`filtered from ${r.length} total`:void 0})]}),t(H,{className:"ActionsLog__tableSurface",children:t(O,{className:"ActionsLog__table",children:[t("thead",{children:t("tr",{className:"ActionsLogs__table__row ActionsLogs__table__row--header",children:[t("th",{className:"ActionsLogs__table__header",children:"Timestamp"}),t("th",{className:"ActionsLogs__table__header",children:"User"}),t("th",{className:"ActionsLogs__table__header",children:"Action"}),t("th",{className:"ActionsLogs__table__header",children:"Details"}),t("th",{className:"ActionsLogs__table__header",children:"Links"})]})}),t("tbody",{children:[k.map((i,c)=>t("tr",{className:"ActionsLogs__table__row",children:[t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--nowrap",children:t(G,{timestamp:i.timestamp,format:"long"})}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--nowrap",children:t("span",{className:"ActionsLogs__user",children:i.by?t($,{children:[t(N,{email:i.by,size:20}),t("span",{className:"ActionsLogs__user__email",children:i.by})]}):"\u2014"})}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--action",children:t("span",{className:"ActionsLogs__action",children:i.action})}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--metadata",children:t(Q,{metadata:i.metadata})}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--links",children:t(I,{action:i})})]},c)),k.length===0&&t("tr",{children:t("td",{colSpan:5,className:"ActionsLogs__table__col ActionsLogs__table__col--empty",children:"No actions found matching your filters."})})]})]})}),t(B,{total:d.totalPages,page:d.page,onChange:d.setPage})]})}function Q(a){let{metadata:e}=a;if(!e||Object.keys(e).length===0)return t("span",{className:"ActionsLogs__metadata--empty",children:"\u2014"});let o=Object.entries(e);return t("div",{className:"ActionsLogs__metadata",children:o.map(([n,s])=>t("div",{className:"ActionsLogs__metadata__item",children:[t("span",{className:"ActionsLogs__metadata__key",children:[n,":"]})," ",t("span",{className:"ActionsLogs__metadata__value",children:nt(s)})]},n))})}function nt(a){if(a==null)return"\u2014";if(Array.isArray(a))return a.length===0?"[]":a.length<=3?a.join(", "):`${a.slice(0,3).join(", ")} (+${a.length-3} more)`;if(typeof a=="object"){let e=st(a);try{return JSON.stringify(e)}catch(o){console.error(o),console.error("failed to stringify json:",e)}}return String(a)}function st(a){let e={};return Object.entries(a).forEach(([o,n])=>{o.startsWith("_")||(e[o]=n)}),e}function I(a){let{action:e}=a,o=[];function n(s){return a.label||s}if(e.action!=="doc.delete"&&e.metadata?.docId&&o.push(t(f,{transition:"pop",label:e.metadata.docId,children:t(l,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/content/${e.metadata.docId}`,children:n("Open doc")})},"doc")),at.includes(e.action)&&e.metadata?.docId){let s=C(e.timestamp)?.toMillis();s&&o.push(t(f,{transition:"pop",label:`Show changes to ${e.metadata.docId}`,children:t(l,{component:"a",variant:"default",size:"xs",compact:!0,href:it(e.metadata.docId,s),children:n("Show changes")})},"changes"))}return e.action!=="datasource.delete"&&e.metadata?.datasourceId&&o.push(t(f,{transition:"pop",label:e.metadata.datasourceId,children:t(l,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/data/${e.metadata.datasourceId}`,children:n("Open data source")})},"datasource")),e.action!=="release.delete"&&e.metadata?.releaseId&&o.push(t(f,{transition:"pop",label:e.metadata.releaseId,children:t(l,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${e.metadata.releaseId}`,children:n("Open release")})},"release")),e.metadata?.sheetId&&o.push(t(l,{component:"a",variant:"default",size:"xs",compact:!0,href:j(e.metadata.sheetId),target:"_blank",children:n("Open sheet")},"sheet")),e.action.startsWith("acls.")&&o.push(t(l,{component:"a",variant:"default",size:"xs",compact:!0,href:"/cms/settings",children:n("Open settings")},"settings")),e.links&&e.links.forEach((s,m)=>{o.push(t(l,{component:"a",variant:"default",size:"xs",compact:!0,href:s.url,target:s.target,children:s.label},`link-${m}`))}),o.length===0?t("span",{className:"ActionsLogs__links--empty"}):(a.limit&&(o=o.slice(0,a.limit)),t("div",{className:"ActionsLogs__table__buttons",children:o}))}function it(a,e){let o=J(a,`before:${e}`),n=J(a,`after:${e}`);return`/cms/compare?left=${o}&right=${n}`}function J(a,e){return encodeURIComponent(`${a}@${e}`).replaceAll("%2F","/").replaceAll("%40","@").replaceAll("%3A",":")}function ct(a){let{actions:e,loading:o}=W(a.limit||10);return o?t("div",{className:w(a.className,"ActionLogsCompact","ActionLogsCompact--loading"),children:t(x,{color:"gray",size:"xl"})}):t("div",{className:w(a.className,"ActionLogsCompact"),children:t(y,{className:"ActionLogsCompact__table",multiple:!0,children:e.map((n,s)=>t(y.Item,{label:t(rt,{action:n}),children:t(lt,{action:n})},s))})})}function rt(a){let e=a.action,o=mt(e),n=a.action.by||"";return t("div",{className:"ActionLogsCompactItemPreview",children:[t("div",{className:"ActionLogsCompactItemPreview__user",children:t(N,{email:n,size:20})}),t("div",{className:"ActionLogsCompactItemPreview__timestamp",children:t(G,{timestamp:e.timestamp})}),t("div",{className:"ActionLogsCompactItemPreview__action",children:e.action}),t("div",{className:"ActionLogsCompactItemPreview__actionMetaId",children:o}),t("div",{className:"ActionLogsCompactItemPreview__buttons",children:t(I,{action:e,label:"Open",limit:1})})]})}function lt(a){let e=a.action,o={user:e.by,...e.metadata};return t("div",{className:"ActionLogsCompactItemDetails",children:[t(Q,{metadata:o}),t(I,{action:e})]})}function mt(a){for(let e of Object.keys(a.metadata||{}))if(e.toLowerCase().endsWith("id"))return a.metadata[e];return""}function C(a){return a?a instanceof A?a:typeof a=="object"&&typeof a._seconds=="number"?new A(a._seconds,a._nanoseconds||0):typeof a=="object"&&typeof a.seconds=="number"?new A(a.seconds,a.nanoseconds||0):typeof a=="number"?A.fromMillis(a):null:null}function G(a){let e=C(a.timestamp)?.toMillis()||0;if(!e)return t("span",{children:"Invalid date"});let o=a.format==="long"?_t(e):pt(e);return t(f,{transition:"pop",label:gt(e),children:t("span",{className:"ActionsLogs__timestamp",children:o})})}var dt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function R(a){let e=a.getHours(),o=e<12?"AM":"PM",n=String(e%12||12).padStart(2,"0"),s=String(a.getMinutes()).padStart(2,"0");return`${n}:${s} ${o}`}function pt(a){let e=new Date(a),o=String(e.getDate()).padStart(2,"0");return`${dt[e.getMonth()]} ${o}, ${R(e)}`}function _t(a){let e=new Date(a),o=e.toLocaleDateString("en",{month:"long"}),n=String(e.getDate()).padStart(2,"0");return`${o} ${n}, ${e.getFullYear()} ${R(e)}`}function gt(a){return new Date(a).toLocaleString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ut(a){function e(o){return o===null?"null":typeof o>"u"?"undefined":typeof o=="string"?`"${o.replaceAll('"','\\"')}"`:typeof o!="object"?String(o):Array.isArray(o)?`[${o.map(e).join(", ")}]`:`{${Object.entries(o).map(([s,m])=>`${s}: ${e(m)}`).join(", ")}}`}return e(a)}export{Pt as a};
@@ -1 +1 @@
1
- import{d as Q}from"./chunk-WASID5UU.js";import{a as z,c as d,e as i,h as c,j as h}from"./chunk-WRA24P66.js";h();function R(r,t,n={}){let{query:l,route:g}=Q(),{replace:m=!1,serialize:y=e=>String(e),deserialize:f=e=>e}=n,a=i(t),T=i(y),P=i(f);a.current=t,T.current=y,P.current=f;let o=c(()=>{let e=l[r];return e!==void 0?P.current(e):a.current},[l,r]),[S,p]=z(o);d(()=>{p(o())},[o]);let b=c(e=>{p(e);let s=new URL(window.location.href),u=T.current(e);u===String(a.current)||u===""?s.searchParams.delete(r):s.searchParams.set(r,u);let k=s.pathname+s.search;g(k,m)},[r,m,g]);return[S,b]}function O(r,t=""){return R(r,t)}function w(r,t=[]){return R(r,t,{serialize:n=>Array.isArray(n)?n.join(","):"",deserialize:n=>n?n.split(",").filter(Boolean):t})}export{R as a,O as b,w as c};
1
+ import{d as Q}from"./chunk-GJ7ES2LA.js";import{a as z,c as d,e as i,h as c,j as h}from"./chunk-Y7RYSRP7.js";h();function R(r,t,n={}){let{query:l,route:g}=Q(),{replace:m=!1,serialize:y=e=>String(e),deserialize:f=e=>e}=n,a=i(t),T=i(y),P=i(f);a.current=t,T.current=y,P.current=f;let o=c(()=>{let e=l[r];return e!==void 0?P.current(e):a.current},[l,r]),[S,p]=z(o);d(()=>{p(o())},[o]);let b=c(e=>{p(e);let s=new URL(window.location.href),u=T.current(e);u===String(a.current)||u===""?s.searchParams.delete(r):s.searchParams.set(r,u);let k=s.pathname+s.search;g(k,m)},[r,m,g]);return[S,b]}function O(r,t=""){return R(r,t)}function w(r,t=[]){return R(r,t,{serialize:n=>Array.isArray(n)?n.join(","):"",deserialize:n=>n?n.split(",").filter(Boolean):t})}export{R as a,O as b,w as c};