claudecode-dashboard 1.0.0 → 1.0.2

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.
@@ -1,124 +0,0 @@
1
- #!/usr/bin/env node
2
- import {a as a$2,c,d as d$1,e,f as f$1,g as g$1,h,i as i$1,b as b$2}from'./chunk-AHIRPBQB.js';import {j,k as k$1,i,a as a$1,b as b$1}from'./chunk-H6DM526Z.js';import {a}from'./chunk-CUZUQPDA.js';import {b,d}from'./chunk-KBW7PPBV.js';import {readFile,writeFile,stat,mkdir}from'fs/promises';import {existsSync}from'fs';import {homedir}from'os';import {join}from'path';var nl=b((Ah,Xu)=>{Xu.exports={dots:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]},dots2:{interval:80,frames:["\u28FE","\u28FD","\u28FB","\u28BF","\u287F","\u28DF","\u28EF","\u28F7"]},dots3:{interval:80,frames:["\u280B","\u2819","\u281A","\u281E","\u2816","\u2826","\u2834","\u2832","\u2833","\u2813"]},dots4:{interval:80,frames:["\u2804","\u2806","\u2807","\u280B","\u2819","\u2838","\u2830","\u2820","\u2830","\u2838","\u2819","\u280B","\u2807","\u2806"]},dots5:{interval:80,frames:["\u280B","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B"]},dots6:{interval:80,frames:["\u2801","\u2809","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2824","\u2804","\u2804","\u2824","\u2834","\u2832","\u2812","\u2802","\u2802","\u2812","\u281A","\u2819","\u2809","\u2801"]},dots7:{interval:80,frames:["\u2808","\u2809","\u280B","\u2813","\u2812","\u2810","\u2810","\u2812","\u2816","\u2826","\u2824","\u2820","\u2820","\u2824","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B","\u2809","\u2808"]},dots8:{interval:80,frames:["\u2801","\u2801","\u2809","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2824","\u2804","\u2804","\u2824","\u2820","\u2820","\u2824","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B","\u2809","\u2808","\u2808"]},dots9:{interval:80,frames:["\u28B9","\u28BA","\u28BC","\u28F8","\u28C7","\u2867","\u2857","\u284F"]},dots10:{interval:80,frames:["\u2884","\u2882","\u2881","\u2841","\u2848","\u2850","\u2860"]},dots11:{interval:100,frames:["\u2801","\u2802","\u2804","\u2840","\u2880","\u2820","\u2810","\u2808"]},dots12:{interval:80,frames:["\u2880\u2800","\u2840\u2800","\u2804\u2800","\u2882\u2800","\u2842\u2800","\u2805\u2800","\u2883\u2800","\u2843\u2800","\u280D\u2800","\u288B\u2800","\u284B\u2800","\u280D\u2801","\u288B\u2801","\u284B\u2801","\u280D\u2809","\u280B\u2809","\u280B\u2809","\u2809\u2819","\u2809\u2819","\u2809\u2829","\u2808\u2899","\u2808\u2859","\u2888\u2829","\u2840\u2899","\u2804\u2859","\u2882\u2829","\u2842\u2898","\u2805\u2858","\u2883\u2828","\u2843\u2890","\u280D\u2850","\u288B\u2820","\u284B\u2880","\u280D\u2841","\u288B\u2801","\u284B\u2801","\u280D\u2809","\u280B\u2809","\u280B\u2809","\u2809\u2819","\u2809\u2819","\u2809\u2829","\u2808\u2899","\u2808\u2859","\u2808\u2829","\u2800\u2899","\u2800\u2859","\u2800\u2829","\u2800\u2898","\u2800\u2858","\u2800\u2828","\u2800\u2890","\u2800\u2850","\u2800\u2820","\u2800\u2880","\u2800\u2840"]},dots13:{interval:80,frames:["\u28FC","\u28F9","\u28BB","\u283F","\u285F","\u28CF","\u28E7","\u28F6"]},dots8Bit:{interval:80,frames:["\u2800","\u2801","\u2802","\u2803","\u2804","\u2805","\u2806","\u2807","\u2840","\u2841","\u2842","\u2843","\u2844","\u2845","\u2846","\u2847","\u2808","\u2809","\u280A","\u280B","\u280C","\u280D","\u280E","\u280F","\u2848","\u2849","\u284A","\u284B","\u284C","\u284D","\u284E","\u284F","\u2810","\u2811","\u2812","\u2813","\u2814","\u2815","\u2816","\u2817","\u2850","\u2851","\u2852","\u2853","\u2854","\u2855","\u2856","\u2857","\u2818","\u2819","\u281A","\u281B","\u281C","\u281D","\u281E","\u281F","\u2858","\u2859","\u285A","\u285B","\u285C","\u285D","\u285E","\u285F","\u2820","\u2821","\u2822","\u2823","\u2824","\u2825","\u2826","\u2827","\u2860","\u2861","\u2862","\u2863","\u2864","\u2865","\u2866","\u2867","\u2828","\u2829","\u282A","\u282B","\u282C","\u282D","\u282E","\u282F","\u2868","\u2869","\u286A","\u286B","\u286C","\u286D","\u286E","\u286F","\u2830","\u2831","\u2832","\u2833","\u2834","\u2835","\u2836","\u2837","\u2870","\u2871","\u2872","\u2873","\u2874","\u2875","\u2876","\u2877","\u2838","\u2839","\u283A","\u283B","\u283C","\u283D","\u283E","\u283F","\u2878","\u2879","\u287A","\u287B","\u287C","\u287D","\u287E","\u287F","\u2880","\u2881","\u2882","\u2883","\u2884","\u2885","\u2886","\u2887","\u28C0","\u28C1","\u28C2","\u28C3","\u28C4","\u28C5","\u28C6","\u28C7","\u2888","\u2889","\u288A","\u288B","\u288C","\u288D","\u288E","\u288F","\u28C8","\u28C9","\u28CA","\u28CB","\u28CC","\u28CD","\u28CE","\u28CF","\u2890","\u2891","\u2892","\u2893","\u2894","\u2895","\u2896","\u2897","\u28D0","\u28D1","\u28D2","\u28D3","\u28D4","\u28D5","\u28D6","\u28D7","\u2898","\u2899","\u289A","\u289B","\u289C","\u289D","\u289E","\u289F","\u28D8","\u28D9","\u28DA","\u28DB","\u28DC","\u28DD","\u28DE","\u28DF","\u28A0","\u28A1","\u28A2","\u28A3","\u28A4","\u28A5","\u28A6","\u28A7","\u28E0","\u28E1","\u28E2","\u28E3","\u28E4","\u28E5","\u28E6","\u28E7","\u28A8","\u28A9","\u28AA","\u28AB","\u28AC","\u28AD","\u28AE","\u28AF","\u28E8","\u28E9","\u28EA","\u28EB","\u28EC","\u28ED","\u28EE","\u28EF","\u28B0","\u28B1","\u28B2","\u28B3","\u28B4","\u28B5","\u28B6","\u28B7","\u28F0","\u28F1","\u28F2","\u28F3","\u28F4","\u28F5","\u28F6","\u28F7","\u28B8","\u28B9","\u28BA","\u28BB","\u28BC","\u28BD","\u28BE","\u28BF","\u28F8","\u28F9","\u28FA","\u28FB","\u28FC","\u28FD","\u28FE","\u28FF"]},sand:{interval:80,frames:["\u2801","\u2802","\u2804","\u2840","\u2848","\u2850","\u2860","\u28C0","\u28C1","\u28C2","\u28C4","\u28CC","\u28D4","\u28E4","\u28E5","\u28E6","\u28EE","\u28F6","\u28F7","\u28FF","\u287F","\u283F","\u289F","\u281F","\u285B","\u281B","\u282B","\u288B","\u280B","\u280D","\u2849","\u2809","\u2811","\u2821","\u2881"]},line:{interval:130,frames:["-","\\","|","/"]},line2:{interval:100,frames:["\u2802","-","\u2013","\u2014","\u2013","-"]},pipe:{interval:100,frames:["\u2524","\u2518","\u2534","\u2514","\u251C","\u250C","\u252C","\u2510"]},simpleDots:{interval:400,frames:[". ",".. ","..."," "]},simpleDotsScrolling:{interval:200,frames:[". ",".. ","..."," .."," ."," "]},star:{interval:70,frames:["\u2736","\u2738","\u2739","\u273A","\u2739","\u2737"]},star2:{interval:80,frames:["+","x","*"]},flip:{interval:70,frames:["_","_","_","-","`","`","'","\xB4","-","_","_","_"]},hamburger:{interval:100,frames:["\u2631","\u2632","\u2634"]},growVertical:{interval:120,frames:["\u2581","\u2583","\u2584","\u2585","\u2586","\u2587","\u2586","\u2585","\u2584","\u2583"]},growHorizontal:{interval:120,frames:["\u258F","\u258E","\u258D","\u258C","\u258B","\u258A","\u2589","\u258A","\u258B","\u258C","\u258D","\u258E"]},balloon:{interval:140,frames:[" ",".","o","O","@","*"," "]},balloon2:{interval:120,frames:[".","o","O","\xB0","O","o","."]},noise:{interval:100,frames:["\u2593","\u2592","\u2591"]},bounce:{interval:120,frames:["\u2801","\u2802","\u2804","\u2802"]},boxBounce:{interval:120,frames:["\u2596","\u2598","\u259D","\u2597"]},boxBounce2:{interval:100,frames:["\u258C","\u2580","\u2590","\u2584"]},triangle:{interval:50,frames:["\u25E2","\u25E3","\u25E4","\u25E5"]},binary:{interval:80,frames:["010010","001100","100101","111010","111101","010111","101011","111000","110011","110101"]},arc:{interval:100,frames:["\u25DC","\u25E0","\u25DD","\u25DE","\u25E1","\u25DF"]},circle:{interval:120,frames:["\u25E1","\u2299","\u25E0"]},squareCorners:{interval:180,frames:["\u25F0","\u25F3","\u25F2","\u25F1"]},circleQuarters:{interval:120,frames:["\u25F4","\u25F7","\u25F6","\u25F5"]},circleHalves:{interval:50,frames:["\u25D0","\u25D3","\u25D1","\u25D2"]},squish:{interval:100,frames:["\u256B","\u256A"]},toggle:{interval:250,frames:["\u22B6","\u22B7"]},toggle2:{interval:80,frames:["\u25AB","\u25AA"]},toggle3:{interval:120,frames:["\u25A1","\u25A0"]},toggle4:{interval:100,frames:["\u25A0","\u25A1","\u25AA","\u25AB"]},toggle5:{interval:100,frames:["\u25AE","\u25AF"]},toggle6:{interval:300,frames:["\u101D","\u1040"]},toggle7:{interval:80,frames:["\u29BE","\u29BF"]},toggle8:{interval:100,frames:["\u25CD","\u25CC"]},toggle9:{interval:100,frames:["\u25C9","\u25CE"]},toggle10:{interval:100,frames:["\u3282","\u3280","\u3281"]},toggle11:{interval:50,frames:["\u29C7","\u29C6"]},toggle12:{interval:120,frames:["\u2617","\u2616"]},toggle13:{interval:80,frames:["=","*","-"]},arrow:{interval:100,frames:["\u2190","\u2196","\u2191","\u2197","\u2192","\u2198","\u2193","\u2199"]},arrow2:{interval:80,frames:["\u2B06\uFE0F ","\u2197\uFE0F ","\u27A1\uFE0F ","\u2198\uFE0F ","\u2B07\uFE0F ","\u2199\uFE0F ","\u2B05\uFE0F ","\u2196\uFE0F "]},arrow3:{interval:120,frames:["\u25B9\u25B9\u25B9\u25B9\u25B9","\u25B8\u25B9\u25B9\u25B9\u25B9","\u25B9\u25B8\u25B9\u25B9\u25B9","\u25B9\u25B9\u25B8\u25B9\u25B9","\u25B9\u25B9\u25B9\u25B8\u25B9","\u25B9\u25B9\u25B9\u25B9\u25B8"]},bouncingBar:{interval:80,frames:["[ ]","[= ]","[== ]","[=== ]","[====]","[ ===]","[ ==]","[ =]","[ ]","[ =]","[ ==]","[ ===]","[====]","[=== ]","[== ]","[= ]"]},bouncingBall:{interval:80,frames:["( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF)","( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF )","(\u25CF )"]},smiley:{interval:200,frames:["\u{1F604} ","\u{1F61D} "]},monkey:{interval:300,frames:["\u{1F648} ","\u{1F648} ","\u{1F649} ","\u{1F64A} "]},hearts:{interval:100,frames:["\u{1F49B} ","\u{1F499} ","\u{1F49C} ","\u{1F49A} ","\u2764\uFE0F "]},clock:{interval:100,frames:["\u{1F55B} ","\u{1F550} ","\u{1F551} ","\u{1F552} ","\u{1F553} ","\u{1F554} ","\u{1F555} ","\u{1F556} ","\u{1F557} ","\u{1F558} ","\u{1F559} ","\u{1F55A} "]},earth:{interval:180,frames:["\u{1F30D} ","\u{1F30E} ","\u{1F30F} "]},material:{interval:17,frames:["\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581"]},moon:{interval:80,frames:["\u{1F311} ","\u{1F312} ","\u{1F313} ","\u{1F314} ","\u{1F315} ","\u{1F316} ","\u{1F317} ","\u{1F318} "]},runner:{interval:140,frames:["\u{1F6B6} ","\u{1F3C3} "]},pong:{interval:80,frames:["\u2590\u2802 \u258C","\u2590\u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802\u258C","\u2590 \u2820\u258C","\u2590 \u2840\u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590\u2820 \u258C"]},shark:{interval:120,frames:["\u2590|\\____________\u258C","\u2590_|\\___________\u258C","\u2590__|\\__________\u258C","\u2590___|\\_________\u258C","\u2590____|\\________\u258C","\u2590_____|\\_______\u258C","\u2590______|\\______\u258C","\u2590_______|\\_____\u258C","\u2590________|\\____\u258C","\u2590_________|\\___\u258C","\u2590__________|\\__\u258C","\u2590___________|\\_\u258C","\u2590____________|\\\u258C","\u2590____________/|\u258C","\u2590___________/|_\u258C","\u2590__________/|__\u258C","\u2590_________/|___\u258C","\u2590________/|____\u258C","\u2590_______/|_____\u258C","\u2590______/|______\u258C","\u2590_____/|_______\u258C","\u2590____/|________\u258C","\u2590___/|_________\u258C","\u2590__/|__________\u258C","\u2590_/|___________\u258C","\u2590/|____________\u258C"]},dqpb:{interval:100,frames:["d","q","p","b"]},weather:{interval:100,frames:["\u2600\uFE0F ","\u2600\uFE0F ","\u2600\uFE0F ","\u{1F324} ","\u26C5\uFE0F ","\u{1F325} ","\u2601\uFE0F ","\u{1F327} ","\u{1F328} ","\u{1F327} ","\u{1F328} ","\u{1F327} ","\u{1F328} ","\u26C8 ","\u{1F328} ","\u{1F327} ","\u{1F328} ","\u2601\uFE0F ","\u{1F325} ","\u26C5\uFE0F ","\u{1F324} ","\u2600\uFE0F ","\u2600\uFE0F "]},christmas:{interval:400,frames:["\u{1F332}","\u{1F384}"]},grenade:{interval:80,frames:["\u060C ","\u2032 "," \xB4 "," \u203E "," \u2E0C"," \u2E0A"," |"," \u204E"," \u2055"," \u0DF4 "," \u2053"," "," "," "]},point:{interval:125,frames:["\u2219\u2219\u2219","\u25CF\u2219\u2219","\u2219\u25CF\u2219","\u2219\u2219\u25CF","\u2219\u2219\u2219"]},layer:{interval:150,frames:["-","=","\u2261"]},betaWave:{interval:80,frames:["\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2","\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2","\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2","\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2","\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2","\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2","\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1"]},fingerDance:{interval:160,frames:["\u{1F918} ","\u{1F91F} ","\u{1F596} ","\u270B ","\u{1F91A} ","\u{1F446} "]},fistBump:{interval:80,frames:["\u{1F91C}\u3000\u3000\u3000\u3000\u{1F91B} ","\u{1F91C}\u3000\u3000\u3000\u3000\u{1F91B} ","\u{1F91C}\u3000\u3000\u3000\u3000\u{1F91B} ","\u3000\u{1F91C}\u3000\u3000\u{1F91B}\u3000 ","\u3000\u3000\u{1F91C}\u{1F91B}\u3000\u3000 ","\u3000\u{1F91C}\u2728\u{1F91B}\u3000\u3000 ","\u{1F91C}\u3000\u2728\u3000\u{1F91B}\u3000 "]},soccerHeader:{interval:80,frames:[" \u{1F9D1}\u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F\u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} "]},mindblown:{interval:160,frames:["\u{1F610} ","\u{1F610} ","\u{1F62E} ","\u{1F62E} ","\u{1F626} ","\u{1F626} ","\u{1F627} ","\u{1F627} ","\u{1F92F} ","\u{1F4A5} ","\u2728 ","\u3000 ","\u3000 ","\u3000 "]},speaker:{interval:160,frames:["\u{1F508} ","\u{1F509} ","\u{1F50A} ","\u{1F509} "]},orangePulse:{interval:100,frames:["\u{1F538} ","\u{1F536} ","\u{1F7E0} ","\u{1F7E0} ","\u{1F536} "]},bluePulse:{interval:100,frames:["\u{1F539} ","\u{1F537} ","\u{1F535} ","\u{1F535} ","\u{1F537} "]},orangeBluePulse:{interval:100,frames:["\u{1F538} ","\u{1F536} ","\u{1F7E0} ","\u{1F7E0} ","\u{1F536} ","\u{1F539} ","\u{1F537} ","\u{1F535} ","\u{1F535} ","\u{1F537} "]},timeTravel:{interval:100,frames:["\u{1F55B} ","\u{1F55A} ","\u{1F559} ","\u{1F558} ","\u{1F557} ","\u{1F556} ","\u{1F555} ","\u{1F554} ","\u{1F553} ","\u{1F552} ","\u{1F551} ","\u{1F550} "]},aesthetic:{interval:80,frames:["\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0","\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1"]},dwarfFortress:{interval:80,frames:[" \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\xA3\xA3\xA3 "," \u263A \u2588\xA3\xA3\xA3 "," \u263A\u2588\xA3\xA3\xA3 "," \u263A\u2588\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3\xA3 "," \u263A\u2592\xA3\xA3\xA3 "," \u263A\u2592\xA3\xA3\xA3 "," \u263A\u2591\xA3\xA3\xA3 "," \u263A\u2591\xA3\xA3\xA3 "," \u263A \xA3\xA3\xA3 "," \u263A\xA3\xA3\xA3 "," \u263A\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3 "," \u263A\u2593\xA3\xA3 "," \u263A\u2592\xA3\xA3 "," \u263A\u2592\xA3\xA3 "," \u263A\u2591\xA3\xA3 "," \u263A\u2591\xA3\xA3 "," \u263A \xA3\xA3 "," \u263A\xA3\xA3 "," \u263A\xA3\xA3 "," \u263A\u2593\xA3 "," \u263A\u2593\xA3 "," \u263A\u2592\xA3 "," \u263A\u2592\xA3 "," \u263A\u2591\xA3 "," \u263A\u2591\xA3 "," \u263A \xA3 "," \u263A\xA3 "," \u263A\xA3 "," \u263A\u2593 "," \u263A\u2593 "," \u263A\u2592 "," \u263A\u2592 "," \u263A\u2591 "," \u263A\u2591 "," \u263A "," \u263A &"," \u263A \u263C&"," \u263A \u263C &"," \u263A\u263C &"," \u263A\u263C & "," \u203C & "," \u263A & "," \u203C & "," \u263A & "," \u203C & "," \u263A & ","\u203C & "," & "," & "," & \u2591 "," & \u2592 "," & \u2593 "," & \xA3 "," & \u2591\xA3 "," & \u2592\xA3 "," & \u2593\xA3 "," & \xA3\xA3 "," & \u2591\xA3\xA3 "," & \u2592\xA3\xA3 ","& \u2593\xA3\xA3 ","& \xA3\xA3\xA3 "," \u2591\xA3\xA3\xA3 "," \u2592\xA3\xA3\xA3 "," \u2593\xA3\xA3\xA3 "," \u2588\xA3\xA3\xA3 "," \u2591\u2588\xA3\xA3\xA3 "," \u2592\u2588\xA3\xA3\xA3 "," \u2593\u2588\xA3\xA3\xA3 "," \u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "]}};});var al=b((Ph,il)=>{var Bn=Object.assign({},nl()),ol=Object.keys(Bn);Object.defineProperty(Bn,"random",{get(){let s=Math.floor(Math.random()*ol.length),e=ol[s];return Bn[e]}});il.exports=Bn;});var ul=b(jn=>{var Ku=a(),Gu=Symbol.for("react.element"),Yu=Symbol.for("react.fragment"),zu=Object.prototype.hasOwnProperty,Qu=Ku.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Zu={key:true,ref:true,__self:true,__source:true};function cl(s,e,t){var r,n={},o=null,i=null;t!==void 0&&(o=""+t),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(i=e.ref);for(r in e)zu.call(e,r)&&!Zu.hasOwnProperty(r)&&(n[r]=e[r]);if(s&&s.defaultProps)for(r in e=s.defaultProps,e)n[r]===void 0&&(n[r]=e[r]);return {$$typeof:Gu,type:s,key:o,ref:i,props:n,_owner:Qu.current}}jn.Fragment=Yu;jn.jsx=cl;jn.jsxs=cl;});var fl=b(Dn=>{process.env.NODE_ENV!=="production"&&(function(){var s=a(),e=Symbol.for("react.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a$1=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),d=Symbol.for("react.offscreen"),R=Symbol.iterator,A="@@iterator";function B(l){if(l===null||typeof l!="object")return null;var y=R&&l[R]||l[A];return typeof y=="function"?y:null}var T=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(l){{for(var y=arguments.length,v=new Array(y>1?y-1:0),C=1;C<y;C++)v[C-1]=arguments[C];K("error",l,v);}}function K(l,y,v){{var C=T.ReactDebugCurrentFrame,D=C.getStackAddendum();D!==""&&(y+="%s",v=v.concat([D]));var W=v.map(function(j){return String(j)});W.unshift("Warning: "+y),Function.prototype.apply.call(console[l],console,W);}}var U=false,ce=false,ue=false,q=false,te=false,z;z=Symbol.for("react.module.reference");function Y(l){return !!(typeof l=="string"||typeof l=="function"||l===r||l===o||te||l===n||l===u||l===_||q||l===d||U||ce||ue||typeof l=="object"&&l!==null&&(l.$$typeof===x||l.$$typeof===h||l.$$typeof===i||l.$$typeof===a$1||l.$$typeof===c||l.$$typeof===z||l.getModuleId!==void 0))}function Q(l,y,v){var C=l.displayName;if(C)return C;var D=y.displayName||y.name||"";return D!==""?v+"("+D+")":v}function Ns(l){return l.displayName||"Context"}function we(l){if(l==null)return null;if(typeof l.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case r:return "Fragment";case t:return "Portal";case o:return "Profiler";case n:return "StrictMode";case u:return "Suspense";case _:return "SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case a$1:var y=l;return Ns(y)+".Consumer";case i:var v=l;return Ns(v._context)+".Provider";case c:return Q(l,l.render,"ForwardRef");case h:var C=l.displayName||null;return C!==null?C:we(l.type)||"Memo";case x:{var D=l,W=D._payload,j=D._init;try{return we(j(W))}catch{return null}}}return null}var Qe=Object.assign,pt=0,Ia,Ra,Ea,ka,Ta,Ca,Oa;function Ma(){}Ma.__reactDisabledLog=true;function bu(){{if(pt===0){Ia=console.log,Ra=console.info,Ea=console.warn,ka=console.error,Ta=console.group,Ca=console.groupCollapsed,Oa=console.groupEnd;var l={configurable:true,enumerable:true,value:Ma,writable:true};Object.defineProperties(console,{info:l,log:l,warn:l,error:l,group:l,groupCollapsed:l,groupEnd:l});}pt++;}}function wu(){{if(pt--,pt===0){var l={configurable:true,enumerable:true,writable:true};Object.defineProperties(console,{log:Qe({},l,{value:Ia}),info:Qe({},l,{value:Ra}),warn:Qe({},l,{value:Ea}),error:Qe({},l,{value:ka}),group:Qe({},l,{value:Ta}),groupCollapsed:Qe({},l,{value:Ca}),groupEnd:Qe({},l,{value:Oa})});}pt<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.");}}var Go=T.ReactCurrentDispatcher,Yo;function $n(l,y,v){{if(Yo===void 0)try{throw Error()}catch(D){var C=D.stack.trim().match(/\n( *(at )?)/);Yo=C&&C[1]||"";}return `
3
- `+Yo+l}}var zo=false,Fn;{var xu=typeof WeakMap=="function"?WeakMap:Map;Fn=new xu;}function $a(l,y){if(!l||zo)return "";{var v=Fn.get(l);if(v!==void 0)return v}var C;zo=true;var D=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var W;W=Go.current,Go.current=null,bu();try{if(y){var j=function(){throw Error()};if(Object.defineProperty(j.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(j,[]);}catch(xe){C=xe;}Reflect.construct(l,[],j);}else {try{j.call();}catch(xe){C=xe;}l.call(j.prototype);}}else {try{throw Error()}catch(xe){C=xe;}l();}}catch(xe){if(xe&&C&&typeof xe.stack=="string"){for(var L=xe.stack.split(`
4
- `),ye=C.stack.split(`
5
- `),Z=L.length-1,re=ye.length-1;Z>=1&&re>=0&&L[Z]!==ye[re];)re--;for(;Z>=1&&re>=0;Z--,re--)if(L[Z]!==ye[re]){if(Z!==1||re!==1)do if(Z--,re--,re<0||L[Z]!==ye[re]){var Ce=`
6
- `+L[Z].replace(" at new "," at ");return l.displayName&&Ce.includes("<anonymous>")&&(Ce=Ce.replace("<anonymous>",l.displayName)),typeof l=="function"&&Fn.set(l,Ce),Ce}while(Z>=1&&re>=0);break}}}finally{zo=false,Go.current=W,wu(),Error.prepareStackTrace=D;}var Sr=l?l.displayName||l.name:"",Ut=Sr?$n(Sr):"";return typeof l=="function"&&Fn.set(l,Ut),Ut}function Su(l,y,v){return $a(l,false)}function Au(l){var y=l.prototype;return !!(y&&y.isReactComponent)}function Nn(l,y,v){if(l==null)return "";if(typeof l=="function")return $a(l,Au(l));if(typeof l=="string")return $n(l);switch(l){case u:return $n("Suspense");case _:return $n("SuspenseList")}if(typeof l=="object")switch(l.$$typeof){case c:return Su(l.render);case h:return Nn(l.type,y,v);case x:{var C=l,D=C._payload,W=C._init;try{return Nn(W(D),y,v)}catch{}}}return ""}var Ls=Object.prototype.hasOwnProperty,Fa={},Na=T.ReactDebugCurrentFrame;function Ln(l){if(l){var y=l._owner,v=Nn(l.type,l._source,y?y.type:null);Na.setExtraStackFrame(v);}else Na.setExtraStackFrame(null);}function Pu(l,y,v,C,D){{var W=Function.call.bind(Ls);for(var j in l)if(W(l,j)){var L=void 0;try{if(typeof l[j]!="function"){var ye=Error((C||"React class")+": "+v+" type `"+j+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof l[j]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ye.name="Invariant Violation",ye}L=l[j](y,j,C,v,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");}catch(Z){L=Z;}L&&!(L instanceof Error)&&(Ln(D),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",C||"React class",v,j,typeof L),Ln(null)),L instanceof Error&&!(L.message in Fa)&&(Fa[L.message]=true,Ln(D),b("Failed %s type: %s",v,L.message),Ln(null));}}}var vu=Array.isArray;function Qo(l){return vu(l)}function Iu(l){{var y=typeof Symbol=="function"&&Symbol.toStringTag,v=y&&l[Symbol.toStringTag]||l.constructor.name||"Object";return v}}function Ru(l){try{return La(l),!1}catch{return true}}function La(l){return ""+l}function Ba(l){if(Ru(l))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Iu(l)),La(l)}var Bs=T.ReactCurrentOwner,Eu={key:true,ref:true,__self:true,__source:true},ja,Da;function ku(l){if(Ls.call(l,"ref")){var y=Object.getOwnPropertyDescriptor(l,"ref").get;if(y&&y.isReactWarning)return false}return l.ref!==void 0}function Tu(l){if(Ls.call(l,"key")){var y=Object.getOwnPropertyDescriptor(l,"key").get;if(y&&y.isReactWarning)return false}return l.key!==void 0}function Cu(l,y){if(typeof l.ref=="string"&&Bs.current&&y);}function Ou(l,y){{var v=function(){ja||(ja=true,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",y));};v.isReactWarning=true,Object.defineProperty(l,"key",{get:v,configurable:true});}}function Mu(l,y){{var v=function(){Da||(Da=true,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",y));};v.isReactWarning=true,Object.defineProperty(l,"ref",{get:v,configurable:true});}}var $u=function(l,y,v,C,D,W,j){var L={$$typeof:e,type:l,key:y,ref:v,props:j,_owner:W};return L._store={},Object.defineProperty(L._store,"validated",{configurable:false,enumerable:false,writable:true,value:false}),Object.defineProperty(L,"_self",{configurable:false,enumerable:false,writable:false,value:C}),Object.defineProperty(L,"_source",{configurable:false,enumerable:false,writable:false,value:D}),Object.freeze&&(Object.freeze(L.props),Object.freeze(L)),L};function Fu(l,y,v,C,D){{var W,j={},L=null,ye=null;v!==void 0&&(Ba(v),L=""+v),Tu(y)&&(Ba(y.key),L=""+y.key),ku(y)&&(ye=y.ref,Cu(y,D));for(W in y)Ls.call(y,W)&&!Eu.hasOwnProperty(W)&&(j[W]=y[W]);if(l&&l.defaultProps){var Z=l.defaultProps;for(W in Z)j[W]===void 0&&(j[W]=Z[W]);}if(L||ye){var re=typeof l=="function"?l.displayName||l.name||"Unknown":l;L&&Ou(j,re),ye&&Mu(j,re);}return $u(l,L,ye,D,C,Bs.current,j)}}var ei=T.ReactCurrentOwner,Ua=T.ReactDebugCurrentFrame;function xr(l){if(l){var y=l._owner,v=Nn(l.type,l._source,y?y.type:null);Ua.setExtraStackFrame(v);}else Ua.setExtraStackFrame(null);}var ti;ti=false;function ri(l){return typeof l=="object"&&l!==null&&l.$$typeof===e}function qa(){{if(ei.current){var l=we(ei.current.type);if(l)return `
7
-
8
- Check the render method of \``+l+"`."}return ""}}function Nu(l){{return ""}}var Wa={};function Lu(l){{var y=qa();if(!y){var v=typeof l=="string"?l:l.displayName||l.name;v&&(y=`
9
-
10
- Check the top-level render call using <`+v+">.");}return y}}function Ha(l,y){{if(!l._store||l._store.validated||l.key!=null)return;l._store.validated=true;var v=Lu(y);if(Wa[v])return;Wa[v]=true;var C="";l&&l._owner&&l._owner!==ei.current&&(C=" It was passed a child from "+we(l._owner.type)+"."),xr(l),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',v,C),xr(null);}}function Ja(l,y){{if(typeof l!="object")return;if(Qo(l))for(var v=0;v<l.length;v++){var C=l[v];ri(C)&&Ha(C,y);}else if(ri(l))l._store&&(l._store.validated=true);else if(l){var D=B(l);if(typeof D=="function"&&D!==l.entries)for(var W=D.call(l),j;!(j=W.next()).done;)ri(j.value)&&Ha(j.value,y);}}}function Bu(l){{var y=l.type;if(y==null||typeof y=="string")return;var v;if(typeof y=="function")v=y.propTypes;else if(typeof y=="object"&&(y.$$typeof===c||y.$$typeof===h))v=y.propTypes;else return;if(v){var C=we(y);Pu(v,l.props,"prop",C,l);}else if(y.PropTypes!==void 0&&!ti){ti=true;var D=we(y);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",D||"Unknown");}typeof y.getDefaultProps=="function"&&!y.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");}}function ju(l){{for(var y=Object.keys(l.props),v=0;v<y.length;v++){var C=y[v];if(C!=="children"&&C!=="key"){xr(l),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",C),xr(null);break}}l.ref!==null&&(xr(l),b("Invalid attribute `ref` supplied to `React.Fragment`."),xr(null));}}var Xa={};function Va(l,y,v,C,D,W){{var j=Y(l);if(!j){var L="";(l===void 0||typeof l=="object"&&l!==null&&Object.keys(l).length===0)&&(L+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var ye=Nu();ye?L+=ye:L+=qa();var Z;l===null?Z="null":Qo(l)?Z="array":l!==void 0&&l.$$typeof===e?(Z="<"+(we(l.type)||"Unknown")+" />",L=" Did you accidentally export a JSX literal instead of a component?"):Z=typeof l,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Z,L);}var re=Fu(l,y,v,D,W);if(re==null)return re;if(j){var Ce=y.children;if(Ce!==void 0)if(C)if(Qo(Ce)){for(var Sr=0;Sr<Ce.length;Sr++)Ja(Ce[Sr],l);Object.freeze&&Object.freeze(Ce);}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ja(Ce,l);}if(Ls.call(y,"key")){var Ut=we(l),xe=Object.keys(y).filter(function(Ju){return Ju!=="key"}),si=xe.length>0?"{key: someKey, "+xe.join(": ..., ")+": ...}":"{key: someKey}";if(!Xa[Ut+si]){var Hu=xe.length>0?"{"+xe.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
11
- let props = %s;
12
- <%s {...props} />
13
- React keys must be passed directly to JSX without using spread:
14
- let props = %s;
15
- <%s key={someKey} {...props} />`,si,Ut,Hu,Ut),Xa[Ut+si]=true;}}return l===r?ju(re):Bu(re),re}}function Du(l,y,v){return Va(l,y,v,true)}function Uu(l,y,v){return Va(l,y,v,false)}var qu=Uu,Wu=Du;Dn.Fragment=r,Dn.jsx=qu,Dn.jsxs=Wu;})();});var ne=b((kh,ni)=>{process.env.NODE_ENV==="production"?ni.exports=ul():ni.exports=fl();});var Ar=d(a(),1);var ll=d(al(),1);function Vu({type:s="dots"}){let[e,t]=(0, Ar.useState)(0),r=ll.default[s];return (0, Ar.useEffect)(()=>{let n=setInterval(()=>{t(o=>o===r.frames.length-1?0:o+1);},r.interval);return ()=>{clearInterval(n);}},[r]),Ar.default.createElement(b$1,null,r.frames[e])}var Ds=Vu;var Fe=d(ne(),1);function dl({categories:s,selected:e,focused:t}){return (0, Fe.jsxs)(a$1,{flexDirection:"column",children:[(0, Fe.jsx)(b$1,{bold:true,underline:true,children:"CATEGORIES"}),(0, Fe.jsx)(a$1,{marginTop:1,flexDirection:"column",children:s.map((r,n)=>{let o=n===e;return o&&t?(0, Fe.jsxs)(b$1,{bold:true,underline:true,children:["\u25B8 ",r.label," ",(0, Fe.jsx)(b$1,{bold:true,children:r.count})]},r.key):o?(0, Fe.jsxs)(b$1,{bold:true,children:["\u203A ",r.label," ",(0, Fe.jsx)(b$1,{dimColor:true,children:r.count})]},r.key):(0, Fe.jsxs)(b$1,{dimColor:true,children:[" ",r.label," ",(0, Fe.jsx)(b$1,{dimColor:true,children:r.count})]},r.key)})})]})}var Se=d(ne(),1);function hl({items:s,selected:e,focused:t,maxHeight:r=15}){if(s.length===0)return (0, Se.jsxs)(a$1,{flexDirection:"column",children:[(0, Se.jsx)(b$1,{bold:true,underline:true,children:"ITEMS"}),(0, Se.jsx)(a$1,{marginTop:1,children:(0, Se.jsx)(b$1,{dimColor:true,italic:true,children:"No items"})})]});let n=Math.max(5,r-3),o=Math.max(0,Math.min(e-Math.floor(n/2),s.length-n)),i=s.slice(o,o+n);return (0, Se.jsxs)(a$1,{flexDirection:"column",children:[(0, Se.jsxs)(b$1,{bold:true,underline:true,children:["ITEMS (",s.length,")"]}),(0, Se.jsxs)(a$1,{marginTop:1,flexDirection:"column",children:[o>0&&(0, Se.jsxs)(b$1,{dimColor:true,children:["\u2191 ",o," more"]}),i.map((a,c)=>{let u=o+c,_=u===e,h=a.name.length>24?a.name.slice(0,21)+"...":a.name;return _&&t?(0, Se.jsxs)(b$1,{bold:true,underline:true,children:["\u25B8 ",h]},`${a.name}-${u}`):_?(0, Se.jsxs)(b$1,{bold:true,children:["\u203A ",h]},`${a.name}-${u}`):(0, Se.jsxs)(b$1,{dimColor:true,children:[" ",h]},`${a.name}-${u}`)}),o+n<s.length&&(0, Se.jsxs)(b$1,{dimColor:true,children:["\u2193 ",s.length-o-n," more"]})]})]})}var cu=d(a(),1);var De=d(a(),1);function k(s,e,t,r,n){if(typeof e=="function"?s!==e||true:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(s,t),t}function f(s,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!r:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(s):r?r.value:e.get(s)}var oi=function(){let{crypto:s}=globalThis;if(s?.randomUUID)return oi=s.randomUUID.bind(s),s.randomUUID();let e=new Uint8Array(1),t=s?()=>s.getRandomValues(e)[0]:()=>Math.random()*255&255;return "10000000-1000-4000-8000-100000000000".replace(/[018]/g,r=>(+r^t()&15>>+r/4).toString(16))};function Us(s){return typeof s=="object"&&s!==null&&("name"in s&&s.name==="AbortError"||"message"in s&&String(s.message).includes("FetchRequestCanceledException"))}var qs=s=>{if(s instanceof Error)return s;if(typeof s=="object"&&s!==null){try{if(Object.prototype.toString.call(s)==="[object Error]"){let e=new Error(s.message,s.cause?{cause:s.cause}:{});return s.stack&&(e.stack=s.stack),s.cause&&!e.cause&&(e.cause=s.cause),s.name&&(e.name=s.name),e}}catch{}try{return new Error(JSON.stringify(s))}catch{}}return new Error(s)};var I=class extends Error{},oe=class s extends I{constructor(e,t,r,n){super(`${s.makeMessage(e,t,r)}`),this.status=e,this.headers=n,this.requestID=n?.get("x-request-id"),this.error=t;let o=t;this.code=o?.code,this.param=o?.param,this.type=o?.type;}static makeMessage(e,t,r){let n=t?.message?typeof t.message=="string"?t.message:JSON.stringify(t.message):t?JSON.stringify(t):r;return e&&n?`${e} ${n}`:e?`${e} status code (no body)`:n||"(no status code or body)"}static generate(e,t,r,n){if(!e||!n)return new _t({message:r,cause:qs(t)});let o=t?.error;return e===400?new Pr(e,o,r,n):e===401?new vr(e,o,r,n):e===403?new Ir(e,o,r,n):e===404?new Rr(e,o,r,n):e===409?new Er(e,o,r,n):e===422?new kr(e,o,r,n):e===429?new Tr(e,o,r,n):e>=500?new Cr(e,o,r,n):new s(e,o,r,n)}},se=class extends oe{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0);}},_t=class extends oe{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t);}},yt=class extends _t{constructor({message:e}={}){super({message:e??"Request timed out."});}},Pr=class extends oe{},vr=class extends oe{},Ir=class extends oe{},Rr=class extends oe{},Er=class extends oe{},kr=class extends oe{},Tr=class extends oe{},Cr=class extends oe{},Or=class extends I{constructor(){super("Could not parse response content as the length limit was reached");}},Mr=class extends I{constructor(){super("Could not parse response content as the request was rejected by the content filter");}},Ue=class extends Error{constructor(e){super(e);}};var tf=/^[a-z][a-z0-9+.-]*:/i,ml=s=>tf.test(s),ge=s=>(ge=Array.isArray,ge(s)),ii=ge;function ai(s){return typeof s!="object"?{}:s??{}}function pl(s){if(!s)return true;for(let e in s)return false;return true}function gl(s,e){return Object.prototype.hasOwnProperty.call(s,e)}function Ws(s){return s!=null&&typeof s=="object"&&!Array.isArray(s)}var _l=(s,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new I(`${s} must be an integer`);if(e<0)throw new I(`${s} must be a positive integer`);return e};var yl=s=>{try{return JSON.parse(s)}catch{return}};var qe=s=>new Promise(e=>setTimeout(e,s));var bt="6.15.0";var Sl=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function rf(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}var sf=()=>{let s=rf();if(s==="deno")return {"X-Stainless-Lang":"js","X-Stainless-Package-Version":bt,"X-Stainless-OS":wl(Deno.build.os),"X-Stainless-Arch":bl(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return {"X-Stainless-Lang":"js","X-Stainless-Package-Version":bt,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(s==="node")return {"X-Stainless-Lang":"js","X-Stainless-Package-Version":bt,"X-Stainless-OS":wl(globalThis.process.platform??"unknown"),"X-Stainless-Arch":bl(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let e=nf();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":bt,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":bt,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function nf(){if(typeof navigator>"u"||!navigator)return null;let s=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:e,pattern:t}of s){let r=t.exec(navigator.userAgent);if(r){let n=r[1]||0,o=r[2]||0,i=r[3]||0;return {browser:e,version:`${n}.${o}.${i}`}}}return null}var bl=s=>s==="x32"?"x32":s==="x86_64"||s==="x64"?"x64":s==="arm"?"arm":s==="aarch64"||s==="arm64"?"arm64":s?`other:${s}`:"unknown",wl=s=>(s=s.toLowerCase(),s.includes("ios")?"iOS":s==="android"?"Android":s==="darwin"?"MacOS":s==="win32"?"Windows":s==="freebsd"?"FreeBSD":s==="openbsd"?"OpenBSD":s==="linux"?"Linux":s?`Other:${s}`:"Unknown"),xl,Al=()=>xl??(xl=sf());function Pl(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function li(...s){let e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...s)}function Un(s){let e=Symbol.asyncIterator in s?s[Symbol.asyncIterator]():s[Symbol.iterator]();return li({start(){},async pull(t){let{done:r,value:n}=await e.next();r?t.close():t.enqueue(n);},async cancel(){await e.return?.();}})}function ci(s){if(s[Symbol.asyncIterator])return s;let e=s.getReader();return {async next(){try{let t=await e.read();return t?.done&&e.releaseLock(),t}catch(t){throw e.releaseLock(),t}},async return(){let t=e.cancel();return e.releaseLock(),await t,{done:true,value:void 0}},[Symbol.asyncIterator](){return this}}}async function vl(s){if(s===null||typeof s!="object")return;if(s[Symbol.asyncIterator]){await s[Symbol.asyncIterator]().return?.();return}let e=s.getReader(),t=e.cancel();e.releaseLock(),await t;}var Il=({headers:s,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)});var qn="RFC3986",ui=s=>String(s),Wn={RFC1738:s=>String(s).replace(/%20/g,"+"),RFC3986:ui},fi="RFC1738";var Hn=(s,e)=>(Hn=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Hn(s,e)),We=(()=>{let s=[];for(let e=0;e<256;++e)s.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return s})();var di=1024,Rl=(s,e,t,r,n)=>{if(s.length===0)return s;let o=s;if(typeof s=="symbol"?o=Symbol.prototype.toString.call(s):typeof s!="string"&&(o=String(s)),t==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(a){return "%26%23"+parseInt(a.slice(2),16)+"%3B"});let i="";for(let a=0;a<o.length;a+=di){let c=o.length>=di?o.slice(a,a+di):o,u=[];for(let _=0;_<c.length;++_){let h=c.charCodeAt(_);if(h===45||h===46||h===95||h===126||h>=48&&h<=57||h>=65&&h<=90||h>=97&&h<=122||n===fi&&(h===40||h===41)){u[u.length]=c.charAt(_);continue}if(h<128){u[u.length]=We[h];continue}if(h<2048){u[u.length]=We[192|h>>6]+We[128|h&63];continue}if(h<55296||h>=57344){u[u.length]=We[224|h>>12]+We[128|h>>6&63]+We[128|h&63];continue}_+=1,h=65536+((h&1023)<<10|c.charCodeAt(_)&1023),u[u.length]=We[240|h>>18]+We[128|h>>12&63]+We[128|h>>6&63]+We[128|h&63];}i+=u.join("");}return i};function El(s){return !s||typeof s!="object"?false:!!(s.constructor&&s.constructor.isBuffer&&s.constructor.isBuffer(s))}function hi(s,e){if(ge(s)){let t=[];for(let r=0;r<s.length;r+=1)t.push(e(s[r]));return t}return e(s)}var Tl={brackets(s){return String(s)+"[]"},comma:"comma",indices(s,e){return String(s)+"["+e+"]"},repeat(s){return String(s)}},Cl=function(s,e){Array.prototype.push.apply(s,ge(e)?e:[e]);},kl,ie={addQueryPrefix:false,allowDots:false,allowEmptyArrays:false,arrayFormat:"indices",charset:"utf-8",charsetSentinel:false,delimiter:"&",encode:true,encodeDotInKeys:false,encoder:Rl,encodeValuesOnly:false,format:qn,formatter:ui,indices:false,serializeDate(s){return (kl??(kl=Function.prototype.call.bind(Date.prototype.toISOString)))(s)},skipNulls:false,strictNullHandling:false};function lf(s){return typeof s=="string"||typeof s=="number"||typeof s=="boolean"||typeof s=="symbol"||typeof s=="bigint"}var mi={};function Ol(s,e,t,r,n,o,i,a,c,u,_,h,x,d,R,A,B,T){let b=s,K=T,U=0,ce=false;for(;(K=K.get(mi))!==void 0&&!ce;){let Y=K.get(s);if(U+=1,typeof Y<"u"){if(Y===U)throw new RangeError("Cyclic object value");ce=true;}typeof K.get(mi)>"u"&&(U=0);}if(typeof u=="function"?b=u(e,b):b instanceof Date?b=x?.(b):t==="comma"&&ge(b)&&(b=hi(b,function(Y){return Y instanceof Date?x?.(Y):Y})),b===null){if(o)return c&&!A?c(e,ie.encoder,B,"key",d):e;b="";}if(lf(b)||El(b)){if(c){let Y=A?e:c(e,ie.encoder,B,"key",d);return [R?.(Y)+"="+R?.(c(b,ie.encoder,B,"value",d))]}return [R?.(e)+"="+R?.(String(b))]}let ue=[];if(typeof b>"u")return ue;let q;if(t==="comma"&&ge(b))A&&c&&(b=hi(b,c)),q=[{value:b.length>0?b.join(",")||null:void 0}];else if(ge(u))q=u;else {let Y=Object.keys(b);q=_?Y.sort(_):Y;}let te=a?String(e).replace(/\./g,"%2E"):String(e),z=r&&ge(b)&&b.length===1?te+"[]":te;if(n&&ge(b)&&b.length===0)return z+"[]";for(let Y=0;Y<q.length;++Y){let Q=q[Y],Ns=typeof Q=="object"&&typeof Q.value<"u"?Q.value:b[Q];if(i&&Ns===null)continue;let we=h&&a?Q.replace(/\./g,"%2E"):Q,Qe=ge(b)?typeof t=="function"?t(z,we):z:z+(h?"."+we:"["+we+"]");T.set(s,U);let pt=new WeakMap;pt.set(mi,T),Cl(ue,Ol(Ns,Qe,t,r,n,o,i,a,t==="comma"&&A&&ge(b)?null:c,u,_,h,x,d,R,A,B,pt));}return ue}function cf(s=ie){if(typeof s.allowEmptyArrays<"u"&&typeof s.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof s.encodeDotInKeys<"u"&&typeof s.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(s.encoder!==null&&typeof s.encoder<"u"&&typeof s.encoder!="function")throw new TypeError("Encoder has to be a function.");let e=s.charset||ie.charset;if(typeof s.charset<"u"&&s.charset!=="utf-8"&&s.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let t=qn;if(typeof s.format<"u"){if(!Hn(Wn,s.format))throw new TypeError("Unknown format option provided.");t=s.format;}let r=Wn[t],n=ie.filter;(typeof s.filter=="function"||ge(s.filter))&&(n=s.filter);let o;if(s.arrayFormat&&s.arrayFormat in Tl?o=s.arrayFormat:"indices"in s?o=s.indices?"indices":"repeat":o=ie.arrayFormat,"commaRoundTrip"in s&&typeof s.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let i=typeof s.allowDots>"u"?s.encodeDotInKeys?true:ie.allowDots:!!s.allowDots;return {addQueryPrefix:typeof s.addQueryPrefix=="boolean"?s.addQueryPrefix:ie.addQueryPrefix,allowDots:i,allowEmptyArrays:typeof s.allowEmptyArrays=="boolean"?!!s.allowEmptyArrays:ie.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof s.charsetSentinel=="boolean"?s.charsetSentinel:ie.charsetSentinel,commaRoundTrip:!!s.commaRoundTrip,delimiter:typeof s.delimiter>"u"?ie.delimiter:s.delimiter,encode:typeof s.encode=="boolean"?s.encode:ie.encode,encodeDotInKeys:typeof s.encodeDotInKeys=="boolean"?s.encodeDotInKeys:ie.encodeDotInKeys,encoder:typeof s.encoder=="function"?s.encoder:ie.encoder,encodeValuesOnly:typeof s.encodeValuesOnly=="boolean"?s.encodeValuesOnly:ie.encodeValuesOnly,filter:n,format:t,formatter:r,serializeDate:typeof s.serializeDate=="function"?s.serializeDate:ie.serializeDate,skipNulls:typeof s.skipNulls=="boolean"?s.skipNulls:ie.skipNulls,sort:typeof s.sort=="function"?s.sort:null,strictNullHandling:typeof s.strictNullHandling=="boolean"?s.strictNullHandling:ie.strictNullHandling}}function pi(s,e={}){let t=s,r=cf(e),n,o;typeof r.filter=="function"?(o=r.filter,t=o("",t)):ge(r.filter)&&(o=r.filter,n=o);let i=[];if(typeof t!="object"||t===null)return "";let a=Tl[r.arrayFormat],c=a==="comma"&&r.commaRoundTrip;n||(n=Object.keys(t)),r.sort&&n.sort(r.sort);let u=new WeakMap;for(let x=0;x<n.length;++x){let d=n[x];r.skipNulls&&t[d]===null||Cl(i,Ol(t[d],d,a,c,r.allowEmptyArrays,r.strictNullHandling,r.skipNulls,r.encodeDotInKeys,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,u));}let _=i.join(r.delimiter),h=r.addQueryPrefix===true?"?":"";return r.charsetSentinel&&(r.charset==="iso-8859-1"?h+="utf8=%26%2310003%3B&":h+="utf8=%E2%9C%93&"),_.length>0?h+_:""}function Fl(s){let e=0;for(let n of s)e+=n.length;let t=new Uint8Array(e),r=0;for(let n of s)t.set(n,r),r+=n.length;return t}var Ml;function $r(s){let e;return (Ml??(e=new globalThis.TextEncoder,Ml=e.encode.bind(e)))(s)}var $l;function gi(s){let e;return ($l??(e=new globalThis.TextDecoder,$l=e.decode.bind(e)))(s)}var Pe,ve,qt=class{constructor(){Pe.set(this,void 0),ve.set(this,void 0),k(this,Pe,new Uint8Array),k(this,ve,null);}decode(e){if(e==null)return [];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?$r(e):e;k(this,Pe,Fl([f(this,Pe,"f"),t]));let r=[],n;for(;(n=ff(f(this,Pe,"f"),f(this,ve,"f")))!=null;){if(n.carriage&&f(this,ve,"f")==null){k(this,ve,n.index);continue}if(f(this,ve,"f")!=null&&(n.index!==f(this,ve,"f")+1||n.carriage)){r.push(gi(f(this,Pe,"f").subarray(0,f(this,ve,"f")-1))),k(this,Pe,f(this,Pe,"f").subarray(f(this,ve,"f"))),k(this,ve,null);continue}let o=f(this,ve,"f")!==null?n.preceding-1:n.preceding,i=gi(f(this,Pe,"f").subarray(0,o));r.push(i),k(this,Pe,f(this,Pe,"f").subarray(n.index)),k(this,ve,null);}return r}flush(){return f(this,Pe,"f").length?this.decode(`
16
- `):[]}};Pe=new WeakMap,ve=new WeakMap;qt.NEWLINE_CHARS=new Set([`
17
- `,"\r"]);qt.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function ff(s,e){for(let n=e??0;n<s.length;n++){if(s[n]===10)return {preceding:n,index:n+1,carriage:false};if(s[n]===13)return {preceding:n,index:n+1,carriage:true}}return null}function Nl(s){for(let r=0;r<s.length-1;r++){if(s[r]===10&&s[r+1]===10||s[r]===13&&s[r+1]===13)return r+2;if(s[r]===13&&s[r+1]===10&&r+3<s.length&&s[r+2]===13&&s[r+3]===10)return r+4}return -1}var Xn={off:0,error:200,warn:300,info:400,debug:500},_i=(s,e,t)=>{if(s){if(gl(Xn,s))return s;ee(t).warn(`${e} was set to ${JSON.stringify(s)}, expected one of ${JSON.stringify(Object.keys(Xn))}`);}};function Hs(){}function Jn(s,e,t){return !e||Xn[s]>Xn[t]?Hs:e[s].bind(e)}var df={error:Hs,warn:Hs,info:Hs,debug:Hs},Ll=new WeakMap;function ee(s){let e=s.logger,t=s.logLevel??"off";if(!e)return df;let r=Ll.get(e);if(r&&r[0]===t)return r[1];let n={error:Jn("error",e,t),warn:Jn("warn",e,t),info:Jn("info",e,t),debug:Jn("debug",e,t)};return Ll.set(e,[t,n]),n}var et=s=>(s.options&&(s.options={...s.options},delete s.options.headers),s.headers&&(s.headers=Object.fromEntries((s.headers instanceof Headers?[...s.headers]:Object.entries(s.headers)).map(([e,t])=>[e,e.toLowerCase()==="authorization"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":t]))),"retryOfRequestLogID"in s&&(s.retryOfRequestLogID&&(s.retryOf=s.retryOfRequestLogID),delete s.retryOfRequestLogID),s);var Js,He=class s{constructor(e,t,r){this.iterator=e,Js.set(this,void 0),this.controller=t,k(this,Js,r);}static fromSSEResponse(e,t,r){let n=false,o=r?ee(r):console;async function*i(){if(n)throw new I("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");n=true;let a=false;try{for await(let c of hf(e,t))if(!a){if(c.data.startsWith("[DONE]")){a=!0;continue}if(c.event===null||!c.event.startsWith("thread.")){let u;try{u=JSON.parse(c.data);}catch(_){throw o.error("Could not parse message into JSON:",c.data),o.error("From chunk:",c.raw),_}if(u&&u.error)throw new oe(void 0,u.error,void 0,e.headers);yield u;}else {let u;try{u=JSON.parse(c.data);}catch(_){throw console.error("Could not parse message into JSON:",c.data),console.error("From chunk:",c.raw),_}if(c.event=="error")throw new oe(void 0,u.error,u.message,void 0);yield {event:c.event,data:u};}}a=!0;}catch(c){if(Us(c))return;throw c}finally{a||t.abort();}}return new s(i,t,r)}static fromReadableStream(e,t,r){let n=false;async function*o(){let a=new qt,c=ci(e);for await(let u of c)for(let _ of a.decode(u))yield _;for(let u of a.flush())yield u;}async function*i(){if(n)throw new I("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");n=true;let a=false;try{for await(let c of o())a||c&&(yield JSON.parse(c));a=!0;}catch(c){if(Us(c))return;throw c}finally{a||t.abort();}}return new s(i,t,r)}[(Js=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let e=[],t=[],r=this.iterator(),n=o=>({next:()=>{if(o.length===0){let i=r.next();e.push(i),t.push(i);}return o.shift()}});return [new s(()=>n(e),this.controller,f(this,Js,"f")),new s(()=>n(t),this.controller,f(this,Js,"f"))]}toReadableStream(){let e=this,t;return li({async start(){t=e[Symbol.asyncIterator]();},async pull(r){try{let{value:n,done:o}=await t.next();if(o)return r.close();let i=$r(JSON.stringify(n)+`
18
- `);r.enqueue(i);}catch(n){r.error(n);}},async cancel(){await t.return?.();}})}};async function*hf(s,e){if(!s.body)throw e.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new I("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new I("Attempted to iterate over a response with no body");let t=new yi,r=new qt,n=ci(s.body);for await(let o of mf(n))for(let i of r.decode(o)){let a=t.decode(i);a&&(yield a);}for(let o of r.flush()){let i=t.decode(o);i&&(yield i);}}async function*mf(s){let e=new Uint8Array;for await(let t of s){if(t==null)continue;let r=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?$r(t):t,n=new Uint8Array(e.length+r.length);n.set(e),n.set(r,e.length),e=n;let o;for(;(o=Nl(e))!==-1;)yield e.slice(0,o),e=e.slice(o);}e.length>0&&(yield e);}var yi=class{constructor(){this.event=null,this.data=[],this.chunks=[];}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let o={event:this.event,data:this.data.join(`
19
- `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],o}if(this.chunks.push(e),e.startsWith(":"))return null;let[t,r,n]=pf(e,":");return n.startsWith(" ")&&(n=n.substring(1)),t==="event"?this.event=n:t==="data"&&this.data.push(n),null}};function pf(s,e){let t=s.indexOf(e);return t!==-1?[s.substring(0,t),e,s.substring(t+e.length)]:[s,"",""]}async function Vn(s,e){let{response:t,requestLogID:r,retryOfRequestLogID:n,startTime:o}=e,i=await(async()=>{if(e.options.stream)return ee(s).debug("response",t.status,t.url,t.headers,t.body),e.options.__streamClass?e.options.__streamClass.fromSSEResponse(t,e.controller,s):He.fromSSEResponse(t,e.controller,s);if(t.status===204)return null;if(e.options.__binaryResponse)return t;let c=t.headers.get("content-type")?.split(";")[0]?.trim();if(c?.includes("application/json")||c?.endsWith("+json")){let h=await t.json();return bi(h,t)}return await t.text()})();return ee(s).debug(`[${r}] response parsed`,et({retryOfRequestLogID:n,url:t.url,status:t.status,body:i,durationMs:Date.now()-o})),i}function bi(s,e){return !s||typeof s!="object"||Array.isArray(s)?s:Object.defineProperty(s,"_request_id",{value:e.headers.get("x-request-id"),enumerable:false})}var Xs,Wt=class s extends Promise{constructor(e,t,r=Vn){super(n=>{n(null);}),this.responsePromise=t,this.parseResponse=r,Xs.set(this,void 0),k(this,Xs,e);}_thenUnwrap(e){return new s(f(this,Xs,"f"),this.responsePromise,async(t,r)=>bi(e(await this.parseResponse(t,r),r),r.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return {data:e,response:t,request_id:t.headers.get("x-request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(f(this,Xs,"f"),e))),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}};Xs=new WeakMap;var Kn,Vs=class{constructor(e,t,r,n){Kn.set(this,void 0),k(this,Kn,e),this.options=n,this.response=t,this.body=r;}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:false}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new I("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await f(this,Kn,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e;}async*[(Kn=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t;}},Ks=class extends Wt{constructor(e,t,r){super(e,t,async(n,o)=>new r(n,o.response,await Vn(n,o),o.options));}async*[Symbol.asyncIterator](){let e=await this;for await(let t of e)yield t;}},Je=class extends Vs{constructor(e,t,r,n){super(e,t,r,n),this.data=r.data||[],this.object=r.object;}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}},F=class extends Vs{constructor(e,t,r,n){super(e,t,r,n),this.data=r.data||[],this.has_more=r.has_more||false;}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===false?false:super.hasNextPage()}nextPageRequestOptions(){let e=this.getPaginatedItems(),t=e[e.length-1]?.id;return t?{...this.options,query:{...ai(this.options.query),after:t}}:null}},tt=class extends Vs{constructor(e,t,r,n){super(e,t,r,n),this.data=r.data||[],this.has_more=r.has_more||false,this.last_id=r.last_id||"";}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===false?false:super.hasNextPage()}nextPageRequestOptions(){let e=this.last_id;return e?{...this.options,query:{...ai(this.options.query),after:e}}:null}};var Si=()=>{if(typeof File>"u"){let{process:s}=globalThis,e=typeof s?.versions?.node=="string"&&parseInt(s.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(e?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function Fr(s,e,t){return Si(),new File(s,e??"unknown_file",t)}function Gs(s){return (typeof s=="object"&&s!==null&&("name"in s&&s.name&&String(s.name)||"url"in s&&s.url&&String(s.url)||"filename"in s&&s.filename&&String(s.filename)||"path"in s&&s.path&&String(s.path))||"").split(/[\\/]/).pop()||void 0}var Gn=s=>s!=null&&typeof s=="object"&&typeof s[Symbol.asyncIterator]=="function",Ai=async(s,e)=>wi(s.body)?{...s,body:await jl(s.body,e)}:s,Ie=async(s,e)=>({...s,body:await jl(s.body,e)}),Bl=new WeakMap;function _f(s){let e=typeof s=="function"?s:s.fetch,t=Bl.get(e);if(t)return t;let r=(async()=>{try{let n="Response"in e?e.Response:(await e("data:,")).constructor,o=new FormData;return o.toString()!==await new n(o).text()}catch{return true}})();return Bl.set(e,r),r}var jl=async(s,e)=>{if(!await _f(e))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let t=new FormData;return await Promise.all(Object.entries(s||{}).map(([r,n])=>xi(t,r,n))),t},Dl=s=>s instanceof Blob&&"name"in s,yf=s=>typeof s=="object"&&s!==null&&(s instanceof Response||Gn(s)||Dl(s)),wi=s=>{if(yf(s))return true;if(Array.isArray(s))return s.some(wi);if(s&&typeof s=="object"){for(let e in s)if(wi(s[e]))return true}return false},xi=async(s,e,t)=>{if(t!==void 0){if(t==null)throw new TypeError(`Received null for "${e}"; to pass null in FormData, you must use the string 'null'`);if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")s.append(e,String(t));else if(t instanceof Response)s.append(e,Fr([await t.blob()],Gs(t)));else if(Gn(t))s.append(e,Fr([await new Response(Un(t)).blob()],Gs(t)));else if(Dl(t))s.append(e,t,Gs(t));else if(Array.isArray(t))await Promise.all(t.map(r=>xi(s,e+"[]",r)));else if(typeof t=="object")await Promise.all(Object.entries(t).map(([r,n])=>xi(s,`${e}[${r}]`,n)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${t} instead`)}};var Ul=s=>s!=null&&typeof s=="object"&&typeof s.size=="number"&&typeof s.type=="string"&&typeof s.text=="function"&&typeof s.slice=="function"&&typeof s.arrayBuffer=="function",bf=s=>s!=null&&typeof s=="object"&&typeof s.name=="string"&&typeof s.lastModified=="number"&&Ul(s),wf=s=>s!=null&&typeof s=="object"&&typeof s.url=="string"&&typeof s.blob=="function";async function Yn(s,e,t){if(Si(),s=await s,bf(s))return s instanceof File?s:Fr([await s.arrayBuffer()],s.name);if(wf(s)){let n=await s.blob();return e||(e=new URL(s.url).pathname.split(/[\\/]/).pop()),Fr(await Pi(n),e,t)}let r=await Pi(s);if(e||(e=Gs(s)),!t?.type){let n=r.find(o=>typeof o=="object"&&"type"in o&&o.type);typeof n=="string"&&(t={...t,type:n});}return Fr(r,e,t)}async function Pi(s){let e=[];if(typeof s=="string"||ArrayBuffer.isView(s)||s instanceof ArrayBuffer)e.push(s);else if(Ul(s))e.push(s instanceof Blob?s:await s.arrayBuffer());else if(Gn(s))for await(let t of s)e.push(...await Pi(t));else {let t=s?.constructor?.name;throw new Error(`Unexpected data type: ${typeof s}${t?`; constructor: ${t}`:""}${xf(s)}`)}return e}function xf(s){return typeof s!="object"||s===null?"":`; props: [${Object.getOwnPropertyNames(s).map(t=>`"${t}"`).join(", ")}]`}var g=class{constructor(e){this._client=e;}};function Wl(s){return s.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var ql=Object.freeze(Object.create(null)),Af=(s=Wl)=>function(t,...r){if(t.length===1)return t[0];let n=false,o=[],i=t.reduce((_,h,x)=>{/[?#]/.test(h)&&(n=true);let d=r[x],R=(n?encodeURIComponent:s)(""+d);return x!==r.length&&(d==null||typeof d=="object"&&d.toString===Object.getPrototypeOf(Object.getPrototypeOf(d.hasOwnProperty??ql)??ql)?.toString)&&(R=d+"",o.push({start:_.length+h.length,length:R.length,error:`Value of type ${Object.prototype.toString.call(d).slice(8,-1)} is not a valid path parameter`})),_+h+(x===r.length?"":R)},""),a=i.split(/[?#]/,1)[0],c=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,u;for(;(u=c.exec(a))!==null;)o.push({start:u.index,length:u[0].length,error:`Value "${u[0]}" can't be safely passed as a path parameter`});if(o.sort((_,h)=>_.start-h.start),o.length>0){let _=0,h=o.reduce((x,d)=>{let R=" ".repeat(d.start-_),A="^".repeat(d.length);return _=d.start+d.length,x+R+A},"");throw new I(`Path parameters result in path with invalid segments:
20
- ${o.map(x=>x.error).join(`
21
- `)}
22
- ${i}
23
- ${h}`)}return i},p=Af(Wl);var Ht=class extends g{list(e,t={},r){return this._client.getAPIList(p`/chat/completions/${e}/messages`,F,{query:t,...r})}};function Ys(s){return s!==void 0&&"function"in s&&s.function!==void 0}function zs(s){return s?.$brand==="auto-parseable-response-format"}function Jt(s){return s?.$brand==="auto-parseable-tool"}function Hl(s,e){return !e||!vi(e)?{...s,choices:s.choices.map(t=>(Xl(t.message.tool_calls),{...t,message:{...t.message,parsed:null,...t.message.tool_calls?{tool_calls:t.message.tool_calls}:void 0}}))}:Qs(s,e)}function Qs(s,e){let t=s.choices.map(r=>{if(r.finish_reason==="length")throw new Or;if(r.finish_reason==="content_filter")throw new Mr;return Xl(r.message.tool_calls),{...r,message:{...r.message,...r.message.tool_calls?{tool_calls:r.message.tool_calls?.map(n=>Rf(e,n))??void 0}:void 0,parsed:r.message.content&&!r.message.refusal?If(e,r.message.content):null}}});return {...s,choices:t}}function If(s,e){return s.response_format?.type!=="json_schema"?null:s.response_format?.type==="json_schema"?"$parseRaw"in s.response_format?s.response_format.$parseRaw(e):JSON.parse(e):null}function Rf(s,e){let t=s.tools?.find(r=>Ys(r)&&r.function?.name===e.function.name);return {...e,function:{...e.function,parsed_arguments:Jt(t)?t.$parseRaw(e.function.arguments):t?.function.strict?JSON.parse(e.function.arguments):null}}}function Jl(s,e){if(!s||!("tools"in s)||!s.tools)return false;let t=s.tools?.find(r=>Ys(r)&&r.function?.name===e.function.name);return Ys(t)&&(Jt(t)||t?.function.strict||false)}function vi(s){return zs(s.response_format)?true:s.tools?.some(e=>Jt(e)||e.type==="function"&&e.function.strict===true)??false}function Xl(s){for(let e of s||[])if(e.type!=="function")throw new I(`Currently only \`function\` tool calls are supported; Received \`${e.type}\``)}function Vl(s){for(let e of s??[]){if(e.type!=="function")throw new I(`Currently only \`function\` tool types support auto-parsing; Received \`${e.type}\``);if(e.function.strict!==true)throw new I(`The \`${e.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}var Nr=s=>s?.role==="assistant",Ii=s=>s?.role==="tool";var Ri,zn,Qn,Zs,en,Zn,tn,rt,rn,eo,to,Lr,Kl,wt=class{constructor(){Ri.add(this),this.controller=new AbortController,zn.set(this,void 0),Qn.set(this,()=>{}),Zs.set(this,()=>{}),en.set(this,void 0),Zn.set(this,()=>{}),tn.set(this,()=>{}),rt.set(this,{}),rn.set(this,false),eo.set(this,false),to.set(this,false),Lr.set(this,false),k(this,zn,new Promise((e,t)=>{k(this,Qn,e,"f"),k(this,Zs,t,"f");})),k(this,en,new Promise((e,t)=>{k(this,Zn,e,"f"),k(this,tn,t,"f");})),f(this,zn,"f").catch(()=>{}),f(this,en,"f").catch(()=>{});}_run(e){setTimeout(()=>{e().then(()=>{this._emitFinal(),this._emit("end");},f(this,Ri,"m",Kl).bind(this));},0);}_connected(){this.ended||(f(this,Qn,"f").call(this),this._emit("connect"));}get ended(){return f(this,rn,"f")}get errored(){return f(this,eo,"f")}get aborted(){return f(this,to,"f")}abort(){this.controller.abort();}on(e,t){return (f(this,rt,"f")[e]||(f(this,rt,"f")[e]=[])).push({listener:t}),this}off(e,t){let r=f(this,rt,"f")[e];if(!r)return this;let n=r.findIndex(o=>o.listener===t);return n>=0&&r.splice(n,1),this}once(e,t){return (f(this,rt,"f")[e]||(f(this,rt,"f")[e]=[])).push({listener:t,once:true}),this}emitted(e){return new Promise((t,r)=>{k(this,Lr,true),e!=="error"&&this.once("error",r),this.once(e,t);})}async done(){k(this,Lr,true),await f(this,en,"f");}_emit(e,...t){if(f(this,rn,"f"))return;e==="end"&&(k(this,rn,true),f(this,Zn,"f").call(this));let r=f(this,rt,"f")[e];if(r&&(f(this,rt,"f")[e]=r.filter(n=>!n.once),r.forEach(({listener:n})=>n(...t))),e==="abort"){let n=t[0];!f(this,Lr,"f")&&!r?.length&&Promise.reject(n),f(this,Zs,"f").call(this,n),f(this,tn,"f").call(this,n),this._emit("end");return}if(e==="error"){let n=t[0];!f(this,Lr,"f")&&!r?.length&&Promise.reject(n),f(this,Zs,"f").call(this,n),f(this,tn,"f").call(this,n),this._emit("end");}}_emitFinal(){}};zn=new WeakMap,Qn=new WeakMap,Zs=new WeakMap,en=new WeakMap,Zn=new WeakMap,tn=new WeakMap,rt=new WeakMap,rn=new WeakMap,eo=new WeakMap,to=new WeakMap,Lr=new WeakMap,Ri=new WeakSet,Kl=function(e){if(k(this,eo,true),e instanceof Error&&e.name==="AbortError"&&(e=new se),e instanceof se)return k(this,to,true),this._emit("abort",e);if(e instanceof I)return this._emit("error",e);if(e instanceof Error){let t=new I(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new I(String(e)))};function Gl(s){return typeof s.parse=="function"}var be,Ei,ro,ki,Ti,Ci,Yl,zl,Ef=10,Br=class extends wt{constructor(){super(...arguments),be.add(this),this._chatCompletions=[],this.messages=[];}_addChatCompletion(e){this._chatCompletions.push(e),this._emit("chatCompletion",e);let t=e.choices[0]?.message;return t&&this._addMessage(t),e}_addMessage(e,t=true){if("content"in e||(e.content=null),this.messages.push(e),t){if(this._emit("message",e),Ii(e)&&e.content)this._emit("functionToolCallResult",e.content);else if(Nr(e)&&e.tool_calls)for(let r of e.tool_calls)r.type==="function"&&this._emit("functionToolCall",r.function);}}async finalChatCompletion(){await this.done();let e=this._chatCompletions[this._chatCompletions.length-1];if(!e)throw new I("stream ended without producing a ChatCompletion");return e}async finalContent(){return await this.done(),f(this,be,"m",Ei).call(this)}async finalMessage(){return await this.done(),f(this,be,"m",ro).call(this)}async finalFunctionToolCall(){return await this.done(),f(this,be,"m",ki).call(this)}async finalFunctionToolCallResult(){return await this.done(),f(this,be,"m",Ti).call(this)}async totalUsage(){return await this.done(),f(this,be,"m",Ci).call(this)}allChatCompletions(){return [...this._chatCompletions]}_emitFinal(){let e=this._chatCompletions[this._chatCompletions.length-1];e&&this._emit("finalChatCompletion",e);let t=f(this,be,"m",ro).call(this);t&&this._emit("finalMessage",t);let r=f(this,be,"m",Ei).call(this);r&&this._emit("finalContent",r);let n=f(this,be,"m",ki).call(this);n&&this._emit("finalFunctionToolCall",n);let o=f(this,be,"m",Ti).call(this);o!=null&&this._emit("finalFunctionToolCallResult",o),this._chatCompletions.some(i=>i.usage)&&this._emit("totalUsage",f(this,be,"m",Ci).call(this));}async _createChatCompletion(e,t,r){let n=r?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),f(this,be,"m",Yl).call(this,t);let o=await e.chat.completions.create({...t,stream:false},{...r,signal:this.controller.signal});return this._connected(),this._addChatCompletion(Qs(o,t))}async _runChatCompletion(e,t,r){for(let n of t.messages)this._addMessage(n,false);return await this._createChatCompletion(e,t,r)}async _runTools(e,t,r){let n="tool",{tool_choice:o="auto",stream:i,...a}=t,c=typeof o!="string"&&o.type==="function"&&o?.function?.name,{maxChatCompletions:u=Ef}=r||{},_=t.tools.map(d=>{if(Jt(d)){if(!d.$callback)throw new I("Tool given to `.runTools()` that does not have an associated function");return {type:"function",function:{function:d.$callback,name:d.function.name,description:d.function.description||"",parameters:d.function.parameters,parse:d.$parseRaw,strict:true}}}return d}),h={};for(let d of _)d.type==="function"&&(h[d.function.name||d.function.function.name]=d.function);let x="tools"in t?_.map(d=>d.type==="function"?{type:"function",function:{name:d.function.name||d.function.function.name,parameters:d.function.parameters,description:d.function.description,strict:d.function.strict}}:d):void 0;for(let d of t.messages)this._addMessage(d,false);for(let d=0;d<u;++d){let A=(await this._createChatCompletion(e,{...a,tool_choice:o,tools:x,messages:[...this.messages]},r)).choices[0]?.message;if(!A)throw new I("missing message in ChatCompletion response");if(!A.tool_calls?.length)return;for(let B of A.tool_calls){if(B.type!=="function")continue;let T=B.id,{name:b,arguments:K}=B.function,U=h[b];if(U){if(c&&c!==b){let te=`Invalid tool_call: ${JSON.stringify(b)}. ${JSON.stringify(c)} requested. Please try again`;this._addMessage({role:n,tool_call_id:T,content:te});continue}}else {let te=`Invalid tool_call: ${JSON.stringify(b)}. Available options are: ${Object.keys(h).map(z=>JSON.stringify(z)).join(", ")}. Please try again`;this._addMessage({role:n,tool_call_id:T,content:te});continue}let ce;try{ce=Gl(U)?await U.parse(K):K;}catch(te){let z=te instanceof Error?te.message:String(te);this._addMessage({role:n,tool_call_id:T,content:z});continue}let ue=await U.function(ce,this),q=f(this,be,"m",zl).call(this,ue);if(this._addMessage({role:n,tool_call_id:T,content:q}),c)return}}}};be=new WeakSet,Ei=function(){return f(this,be,"m",ro).call(this).content??null},ro=function(){let e=this.messages.length;for(;e-- >0;){let t=this.messages[e];if(Nr(t))return {...t,content:t.content??null,refusal:t.refusal??null}}throw new I("stream ended without producing a ChatCompletionMessage with role=assistant")},ki=function(){for(let e=this.messages.length-1;e>=0;e--){let t=this.messages[e];if(Nr(t)&&t?.tool_calls?.length)return t.tool_calls.filter(r=>r.type==="function").at(-1)?.function}},Ti=function(){for(let e=this.messages.length-1;e>=0;e--){let t=this.messages[e];if(Ii(t)&&t.content!=null&&typeof t.content=="string"&&this.messages.some(r=>r.role==="assistant"&&r.tool_calls?.some(n=>n.type==="function"&&n.id===t.tool_call_id)))return t.content}},Ci=function(){let e={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:t}of this._chatCompletions)t&&(e.completion_tokens+=t.completion_tokens,e.prompt_tokens+=t.prompt_tokens,e.total_tokens+=t.total_tokens);return e},Yl=function(e){if(e.n!=null&&e.n>1)throw new I("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},zl=function(e){return typeof e=="string"?e:e===void 0?"undefined":JSON.stringify(e)};var sn=class s extends Br{static runTools(e,t,r){let n=new s,o={...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"runTools"}};return n._run(()=>n._runTools(e,t,o)),n}_addMessage(e,t=true){super._addMessage(e,t),Nr(e)&&e.content&&this._emit("content",e.content);}};var fe={STR:1,NUM:2,ARR:4,OBJ:8,NULL:16,BOOL:32,NAN:64,INFINITY:128,MINUS_INFINITY:256,INF:384,SPECIAL:496,ATOM:499,COLLECTION:12,ALL:511},Oi=class extends Error{},Mi=class extends Error{};function kf(s,e=fe.ALL){if(typeof s!="string")throw new TypeError(`expecting str, got ${typeof s}`);if(!s.trim())throw new Error(`${s} is empty`);return Tf(s.trim(),e)}var Tf=(s,e)=>{let t=s.length,r=0,n=x=>{throw new Oi(`${x} at position ${r}`)},o=x=>{throw new Mi(`${x} at position ${r}`)},i=()=>(h(),r>=t&&n("Unexpected end of input"),s[r]==='"'?a():s[r]==="{"?c():s[r]==="["?u():s.substring(r,r+4)==="null"||fe.NULL&e&&t-r<4&&"null".startsWith(s.substring(r))?(r+=4,null):s.substring(r,r+4)==="true"||fe.BOOL&e&&t-r<4&&"true".startsWith(s.substring(r))?(r+=4,true):s.substring(r,r+5)==="false"||fe.BOOL&e&&t-r<5&&"false".startsWith(s.substring(r))?(r+=5,false):s.substring(r,r+8)==="Infinity"||fe.INFINITY&e&&t-r<8&&"Infinity".startsWith(s.substring(r))?(r+=8,1/0):s.substring(r,r+9)==="-Infinity"||fe.MINUS_INFINITY&e&&1<t-r&&t-r<9&&"-Infinity".startsWith(s.substring(r))?(r+=9,-1/0):s.substring(r,r+3)==="NaN"||fe.NAN&e&&t-r<3&&"NaN".startsWith(s.substring(r))?(r+=3,NaN):_()),a=()=>{let x=r,d=false;for(r++;r<t&&(s[r]!=='"'||d&&s[r-1]==="\\");)d=s[r]==="\\"?!d:false,r++;if(s.charAt(r)=='"')try{return JSON.parse(s.substring(x,++r-Number(d)))}catch(R){o(String(R));}else if(fe.STR&e)try{return JSON.parse(s.substring(x,r-Number(d))+'"')}catch{return JSON.parse(s.substring(x,s.lastIndexOf("\\"))+'"')}n("Unterminated string literal");},c=()=>{r++,h();let x={};try{for(;s[r]!=="}";){if(h(),r>=t&&fe.OBJ&e)return x;let d=a();h(),r++;try{let R=i();Object.defineProperty(x,d,{value:R,writable:!0,enumerable:!0,configurable:!0});}catch(R){if(fe.OBJ&e)return x;throw R}h(),s[r]===","&&r++;}}catch{if(fe.OBJ&e)return x;n("Expected '}' at end of object");}return r++,x},u=()=>{r++;let x=[];try{for(;s[r]!=="]";)x.push(i()),h(),s[r]===","&&r++;}catch{if(fe.ARR&e)return x;n("Expected ']' at end of array");}return r++,x},_=()=>{if(r===0){s==="-"&&fe.NUM&e&&n("Not sure what '-' is");try{return JSON.parse(s)}catch(d){if(fe.NUM&e)try{return s[s.length-1]==="."?JSON.parse(s.substring(0,s.lastIndexOf("."))):JSON.parse(s.substring(0,s.lastIndexOf("e")))}catch{}o(String(d));}}let x=r;for(s[r]==="-"&&r++;s[r]&&!",]}".includes(s[r]);)r++;r==t&&!(fe.NUM&e)&&n("Unterminated number literal");try{return JSON.parse(s.substring(x,r))}catch{s.substring(x,r)==="-"&&fe.NUM&e&&n("Not sure what '-' is");try{return JSON.parse(s.substring(x,s.lastIndexOf("e")))}catch(R){o(String(R));}}},h=()=>{for(;r<t&&`
24
- \r `.includes(s[r]);)r++;};return i()},$i=s=>kf(s,fe.ALL^fe.NUM);var ae,st,jr,xt,Fi,so,Ni,Li,Bi,no,ji,Ql,Xt=class s extends Br{constructor(e){super(),ae.add(this),st.set(this,void 0),jr.set(this,void 0),xt.set(this,void 0),k(this,st,e),k(this,jr,[]);}get currentChatCompletionSnapshot(){return f(this,xt,"f")}static fromReadableStream(e){let t=new s(null);return t._run(()=>t._fromReadableStream(e)),t}static createChatCompletion(e,t,r){let n=new s(t);return n._run(()=>n._runChatCompletion(e,{...t,stream:true},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),n}async _createChatCompletion(e,t,r){super._createChatCompletion;let n=r?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),f(this,ae,"m",Fi).call(this);let o=await e.chat.completions.create({...t,stream:true},{...r,signal:this.controller.signal});this._connected();for await(let i of o)f(this,ae,"m",Ni).call(this,i);if(o.controller.signal?.aborted)throw new se;return this._addChatCompletion(f(this,ae,"m",no).call(this))}async _fromReadableStream(e,t){let r=t?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),f(this,ae,"m",Fi).call(this),this._connected();let n=He.fromReadableStream(e,this.controller),o;for await(let i of n)o&&o!==i.id&&this._addChatCompletion(f(this,ae,"m",no).call(this)),f(this,ae,"m",Ni).call(this,i),o=i.id;if(n.controller.signal?.aborted)throw new se;return this._addChatCompletion(f(this,ae,"m",no).call(this))}[(st=new WeakMap,jr=new WeakMap,xt=new WeakMap,ae=new WeakSet,Fi=function(){this.ended||k(this,xt,void 0);},so=function(t){let r=f(this,jr,"f")[t.index];return r||(r={content_done:false,refusal_done:false,logprobs_content_done:false,logprobs_refusal_done:false,done_tool_calls:new Set,current_tool_call_index:null},f(this,jr,"f")[t.index]=r,r)},Ni=function(t){if(this.ended)return;let r=f(this,ae,"m",Ql).call(this,t);this._emit("chunk",t,r);for(let n of t.choices){let o=r.choices[n.index];n.delta.content!=null&&o.message?.role==="assistant"&&o.message?.content&&(this._emit("content",n.delta.content,o.message.content),this._emit("content.delta",{delta:n.delta.content,snapshot:o.message.content,parsed:o.message.parsed})),n.delta.refusal!=null&&o.message?.role==="assistant"&&o.message?.refusal&&this._emit("refusal.delta",{delta:n.delta.refusal,snapshot:o.message.refusal}),n.logprobs?.content!=null&&o.message?.role==="assistant"&&this._emit("logprobs.content.delta",{content:n.logprobs?.content,snapshot:o.logprobs?.content??[]}),n.logprobs?.refusal!=null&&o.message?.role==="assistant"&&this._emit("logprobs.refusal.delta",{refusal:n.logprobs?.refusal,snapshot:o.logprobs?.refusal??[]});let i=f(this,ae,"m",so).call(this,o);o.finish_reason&&(f(this,ae,"m",Bi).call(this,o),i.current_tool_call_index!=null&&f(this,ae,"m",Li).call(this,o,i.current_tool_call_index));for(let a of n.delta.tool_calls??[])i.current_tool_call_index!==a.index&&(f(this,ae,"m",Bi).call(this,o),i.current_tool_call_index!=null&&f(this,ae,"m",Li).call(this,o,i.current_tool_call_index)),i.current_tool_call_index=a.index;for(let a of n.delta.tool_calls??[]){let c=o.message.tool_calls?.[a.index];c?.type&&(c?.type==="function"?this._emit("tool_calls.function.arguments.delta",{name:c.function?.name,index:a.index,arguments:c.function.arguments,parsed_arguments:c.function.parsed_arguments,arguments_delta:a.function?.arguments??""}):(c?.type,void 0));}}},Li=function(t,r){if(f(this,ae,"m",so).call(this,t).done_tool_calls.has(r))return;let o=t.message.tool_calls?.[r];if(!o)throw new Error("no tool call snapshot");if(!o.type)throw new Error("tool call snapshot missing `type`");if(o.type==="function"){let i=f(this,st,"f")?.tools?.find(a=>Ys(a)&&a.function.name===o.function.name);this._emit("tool_calls.function.arguments.done",{name:o.function.name,index:r,arguments:o.function.arguments,parsed_arguments:Jt(i)?i.$parseRaw(o.function.arguments):i?.function.strict?JSON.parse(o.function.arguments):null});}else o.type;},Bi=function(t){let r=f(this,ae,"m",so).call(this,t);if(t.message.content&&!r.content_done){r.content_done=true;let n=f(this,ae,"m",ji).call(this);this._emit("content.done",{content:t.message.content,parsed:n?n.$parseRaw(t.message.content):null});}t.message.refusal&&!r.refusal_done&&(r.refusal_done=true,this._emit("refusal.done",{refusal:t.message.refusal})),t.logprobs?.content&&!r.logprobs_content_done&&(r.logprobs_content_done=true,this._emit("logprobs.content.done",{content:t.logprobs.content})),t.logprobs?.refusal&&!r.logprobs_refusal_done&&(r.logprobs_refusal_done=true,this._emit("logprobs.refusal.done",{refusal:t.logprobs.refusal}));},no=function(){if(this.ended)throw new I("stream has ended, this shouldn't happen");let t=f(this,xt,"f");if(!t)throw new I("request ended without sending any chunks");return k(this,xt,void 0),k(this,jr,[]),Cf(t,f(this,st,"f"))},ji=function(){let t=f(this,st,"f")?.response_format;return zs(t)?t:null},Ql=function(t){var r,n,o,i;let a=f(this,xt,"f"),{choices:c,...u}=t;a?Object.assign(a,u):a=k(this,xt,{...u,choices:[]});for(let{delta:_,finish_reason:h,index:x,logprobs:d=null,...R}of t.choices){let A=a.choices[x];if(A||(A=a.choices[x]={finish_reason:h,index:x,message:{},logprobs:d,...R}),d)if(!A.logprobs)A.logprobs=Object.assign({},d);else {let{content:ue,refusal:q,...te}=d;Object.assign(A.logprobs,te),ue&&((r=A.logprobs).content??(r.content=[]),A.logprobs.content.push(...ue)),q&&((n=A.logprobs).refusal??(n.refusal=[]),A.logprobs.refusal.push(...q));}if(h&&(A.finish_reason=h,f(this,st,"f")&&vi(f(this,st,"f")))){if(h==="length")throw new Or;if(h==="content_filter")throw new Mr}if(Object.assign(A,R),!_)continue;let{content:B,refusal:T,function_call:b,role:K,tool_calls:U,...ce}=_;if(Object.assign(A.message,ce),T&&(A.message.refusal=(A.message.refusal||"")+T),K&&(A.message.role=K),b&&(A.message.function_call?(b.name&&(A.message.function_call.name=b.name),b.arguments&&((o=A.message.function_call).arguments??(o.arguments=""),A.message.function_call.arguments+=b.arguments)):A.message.function_call=b),B&&(A.message.content=(A.message.content||"")+B,!A.message.refusal&&f(this,ae,"m",ji).call(this)&&(A.message.parsed=$i(A.message.content))),U){A.message.tool_calls||(A.message.tool_calls=[]);for(let{index:ue,id:q,type:te,function:z,...Y}of U){let Q=(i=A.message.tool_calls)[ue]??(i[ue]={});Object.assign(Q,Y),q&&(Q.id=q),te&&(Q.type=te),z&&(Q.function??(Q.function={name:z.name??"",arguments:""})),z?.name&&(Q.function.name=z.name),z?.arguments&&(Q.function.arguments+=z.arguments,Jl(f(this,st,"f"),Q)&&(Q.function.parsed_arguments=$i(Q.function.arguments)));}}}return a},Symbol.asyncIterator)](){let e=[],t=[],r=false;return this.on("chunk",n=>{let o=t.shift();o?o.resolve(n):e.push(n);}),this.on("end",()=>{r=true;for(let n of t)n.resolve(void 0);t.length=0;}),this.on("abort",n=>{r=true;for(let o of t)o.reject(n);t.length=0;}),this.on("error",n=>{r=true;for(let o of t)o.reject(n);t.length=0;}),{next:async()=>e.length?{value:e.shift(),done:false}:r?{value:void 0,done:true}:new Promise((o,i)=>t.push({resolve:o,reject:i})).then(o=>o?{value:o,done:false}:{value:void 0,done:true}),return:async()=>(this.abort(),{value:void 0,done:true})}}toReadableStream(){return new He(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};function Cf(s,e){let{id:t,choices:r,created:n,model:o,system_fingerprint:i,...a}=s,c={...a,id:t,choices:r.map(({message:u,finish_reason:_,index:h,logprobs:x,...d})=>{if(!_)throw new I(`missing finish_reason for choice ${h}`);let{content:R=null,function_call:A,tool_calls:B,...T}=u,b=u.role;if(!b)throw new I(`missing role for choice ${h}`);if(A){let{arguments:K,name:U}=A;if(K==null)throw new I(`missing function_call.arguments for choice ${h}`);if(!U)throw new I(`missing function_call.name for choice ${h}`);return {...d,message:{content:R,function_call:{arguments:K,name:U},role:b,refusal:u.refusal??null},finish_reason:_,index:h,logprobs:x}}return B?{...d,index:h,finish_reason:_,logprobs:x,message:{...T,role:b,content:R,refusal:u.refusal??null,tool_calls:B.map((K,U)=>{let{function:ce,type:ue,id:q,...te}=K,{arguments:z,name:Y,...Q}=ce||{};if(q==null)throw new I(`missing choices[${h}].tool_calls[${U}].id
25
- ${oo(s)}`);if(ue==null)throw new I(`missing choices[${h}].tool_calls[${U}].type
26
- ${oo(s)}`);if(Y==null)throw new I(`missing choices[${h}].tool_calls[${U}].function.name
27
- ${oo(s)}`);if(z==null)throw new I(`missing choices[${h}].tool_calls[${U}].function.arguments
28
- ${oo(s)}`);return {...te,id:q,type:ue,function:{...Q,name:Y,arguments:z}}})}}:{...d,message:{...T,content:R,role:b,refusal:u.refusal??null},finish_reason:_,index:h,logprobs:x}}),created:n,model:o,object:"chat.completion",...i?{system_fingerprint:i}:{}};return Hl(c,e)}function oo(s){return JSON.stringify(s)}var nn=class s extends Xt{static fromReadableStream(e){let t=new s(null);return t._run(()=>t._fromReadableStream(e)),t}static runTools(e,t,r){let n=new s(t),o={...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"runTools"}};return n._run(()=>n._runTools(e,t,o)),n}};var nt=class extends g{constructor(){super(...arguments),this.messages=new Ht(this._client);}create(e,t){return this._client.post("/chat/completions",{body:e,...t,stream:e.stream??false})}retrieve(e,t){return this._client.get(p`/chat/completions/${e}`,t)}update(e,t,r){return this._client.post(p`/chat/completions/${e}`,{body:t,...r})}list(e={},t){return this._client.getAPIList("/chat/completions",F,{query:e,...t})}delete(e,t){return this._client.delete(p`/chat/completions/${e}`,t)}parse(e,t){return Vl(e.tools),this._client.chat.completions.create(e,{...t,headers:{...t?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap(r=>Qs(r,e))}runTools(e,t){return e.stream?nn.runTools(this._client,e,t):sn.runTools(this._client,e,t)}stream(e,t){return Xt.createChatCompletion(this._client,e,t)}};nt.Messages=Ht;var St=class extends g{constructor(){super(...arguments),this.completions=new nt(this._client);}};St.Completions=nt;var Zl=Symbol("brand.privateNullableHeaders");function*Mf(s){if(!s)return;if(Zl in s){let{values:r,nulls:n}=s;yield*r.entries();for(let o of n)yield [o,null];return}let e=false,t;s instanceof Headers?t=s.entries():ii(s)?t=s:(e=true,t=Object.entries(s??{}));for(let r of t){let n=r[0];if(typeof n!="string")throw new TypeError("expected header name to be a string");let o=ii(r[1])?r[1]:[r[1]],i=false;for(let a of o)a!==void 0&&(e&&!i&&(i=true,yield [n,null]),yield [n,a]);}}var w=s=>{let e=new Headers,t=new Set;for(let r of s){let n=new Set;for(let[o,i]of Mf(r)){let a=o.toLowerCase();n.has(a)||(e.delete(o),n.add(a)),i===null?(e.delete(o),t.add(a)):(e.append(o,i),t.delete(a));}}return {[Zl]:true,values:e,nulls:t}};var Dr=class extends g{create(e,t){return this._client.post("/audio/speech",{body:e,...t,headers:w([{Accept:"application/octet-stream"},t?.headers]),__binaryResponse:true})}};var Ur=class extends g{create(e,t){return this._client.post("/audio/transcriptions",Ie({body:e,...t,stream:e.stream??false,__metadata:{model:e.model}},this._client))}};var qr=class extends g{create(e,t){return this._client.post("/audio/translations",Ie({body:e,...t,__metadata:{model:e.model}},this._client))}};var Xe=class extends g{constructor(){super(...arguments),this.transcriptions=new Ur(this._client),this.translations=new qr(this._client),this.speech=new Dr(this._client);}};Xe.Transcriptions=Ur;Xe.Translations=qr;Xe.Speech=Dr;var Vt=class extends g{create(e,t){return this._client.post("/batches",{body:e,...t})}retrieve(e,t){return this._client.get(p`/batches/${e}`,t)}list(e={},t){return this._client.getAPIList("/batches",F,{query:e,...t})}cancel(e,t){return this._client.post(p`/batches/${e}/cancel`,t)}};var Wr=class extends g{create(e,t){return this._client.post("/assistants",{body:e,...t,headers:w([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(p`/assistants/${e}`,{...t,headers:w([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,r){return this._client.post(p`/assistants/${e}`,{body:t,...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}list(e={},t){return this._client.getAPIList("/assistants",F,{query:e,...t,headers:w([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}delete(e,t){return this._client.delete(p`/assistants/${e}`,{...t,headers:w([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}};var Hr=class extends g{create(e,t){return this._client.post("/realtime/sessions",{body:e,...t,headers:w([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}};var Jr=class extends g{create(e,t){return this._client.post("/realtime/transcription_sessions",{body:e,...t,headers:w([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}};var At=class extends g{constructor(){super(...arguments),this.sessions=new Hr(this._client),this.transcriptionSessions=new Jr(this._client);}};At.Sessions=Hr;At.TranscriptionSessions=Jr;var Xr=class extends g{create(e,t){return this._client.post("/chatkit/sessions",{body:e,...t,headers:w([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}cancel(e,t){return this._client.post(p`/chatkit/sessions/${e}/cancel`,{...t,headers:w([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}};var Vr=class extends g{retrieve(e,t){return this._client.get(p`/chatkit/threads/${e}`,{...t,headers:w([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}list(e={},t){return this._client.getAPIList("/chatkit/threads",tt,{query:e,...t,headers:w([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}delete(e,t){return this._client.delete(p`/chatkit/threads/${e}`,{...t,headers:w([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}listItems(e,t={},r){return this._client.getAPIList(p`/chatkit/threads/${e}/items`,tt,{query:t,...r,headers:w([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers])})}};var Pt=class extends g{constructor(){super(...arguments),this.sessions=new Xr(this._client),this.threads=new Vr(this._client);}};Pt.Sessions=Xr;Pt.Threads=Vr;var Kr=class extends g{create(e,t,r){return this._client.post(p`/threads/${e}/messages`,{body:t,...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}retrieve(e,t,r){let{thread_id:n}=t;return this._client.get(p`/threads/${n}/messages/${e}`,{...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}update(e,t,r){let{thread_id:n,...o}=t;return this._client.post(p`/threads/${n}/messages/${e}`,{body:o,...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}list(e,t={},r){return this._client.getAPIList(p`/threads/${e}/messages`,F,{query:t,...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}delete(e,t,r){let{thread_id:n}=t;return this._client.delete(p`/threads/${n}/messages/${e}`,{...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}};var Gr=class extends g{retrieve(e,t,r){let{thread_id:n,run_id:o,...i}=t;return this._client.get(p`/threads/${n}/runs/${o}/steps/${e}`,{query:i,...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}list(e,t,r){let{thread_id:n,...o}=t;return this._client.getAPIList(p`/threads/${n}/runs/${e}/steps`,F,{query:o,...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}};var ec=s=>{if(typeof Buffer<"u"){let e=Buffer.from(s,"base64");return Array.from(new Float32Array(e.buffer,e.byteOffset,e.length/Float32Array.BYTES_PER_ELEMENT))}else {let e=atob(s),t=e.length,r=new Uint8Array(t);for(let n=0;n<t;n++)r[n]=e.charCodeAt(n);return Array.from(new Float32Array(r.buffer))}};var vt=s=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[s]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(s)?.trim()};var me,Gt,Di,Ve,io,Ne,Yt,Yr,Kt,co,Re,ao,lo,ln,on,an,tc,rc,sc,nc,oc,ic,ac,ot=class extends wt{constructor(){super(...arguments),me.add(this),Di.set(this,[]),Ve.set(this,{}),io.set(this,{}),Ne.set(this,void 0),Yt.set(this,void 0),Yr.set(this,void 0),Kt.set(this,void 0),co.set(this,void 0),Re.set(this,void 0),ao.set(this,void 0),lo.set(this,void 0),ln.set(this,void 0);}[(Di=new WeakMap,Ve=new WeakMap,io=new WeakMap,Ne=new WeakMap,Yt=new WeakMap,Yr=new WeakMap,Kt=new WeakMap,co=new WeakMap,Re=new WeakMap,ao=new WeakMap,lo=new WeakMap,ln=new WeakMap,me=new WeakSet,Symbol.asyncIterator)](){let e=[],t=[],r=false;return this.on("event",n=>{let o=t.shift();o?o.resolve(n):e.push(n);}),this.on("end",()=>{r=true;for(let n of t)n.resolve(void 0);t.length=0;}),this.on("abort",n=>{r=true;for(let o of t)o.reject(n);t.length=0;}),this.on("error",n=>{r=true;for(let o of t)o.reject(n);t.length=0;}),{next:async()=>e.length?{value:e.shift(),done:false}:r?{value:void 0,done:true}:new Promise((o,i)=>t.push({resolve:o,reject:i})).then(o=>o?{value:o,done:false}:{value:void 0,done:true}),return:async()=>(this.abort(),{value:void 0,done:true})}}static fromReadableStream(e){let t=new Gt;return t._run(()=>t._fromReadableStream(e)),t}async _fromReadableStream(e,t){let r=t?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),this._connected();let n=He.fromReadableStream(e,this.controller);for await(let o of n)f(this,me,"m",on).call(this,o);if(n.controller.signal?.aborted)throw new se;return this._addRun(f(this,me,"m",an).call(this))}toReadableStream(){return new He(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,t,r,n){let o=new Gt;return o._run(()=>o._runToolAssistantStream(e,t,r,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),o}async _createToolAssistantStream(e,t,r,n){let o=n?.signal;o&&(o.aborted&&this.controller.abort(),o.addEventListener("abort",()=>this.controller.abort()));let i={...r,stream:true},a=await e.submitToolOutputs(t,i,{...n,signal:this.controller.signal});this._connected();for await(let c of a)f(this,me,"m",on).call(this,c);if(a.controller.signal?.aborted)throw new se;return this._addRun(f(this,me,"m",an).call(this))}static createThreadAssistantStream(e,t,r){let n=new Gt;return n._run(()=>n._threadAssistantStream(e,t,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),n}static createAssistantStream(e,t,r,n){let o=new Gt;return o._run(()=>o._runAssistantStream(e,t,r,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),o}currentEvent(){return f(this,ao,"f")}currentRun(){return f(this,lo,"f")}currentMessageSnapshot(){return f(this,Ne,"f")}currentRunStepSnapshot(){return f(this,ln,"f")}async finalRunSteps(){return await this.done(),Object.values(f(this,Ve,"f"))}async finalMessages(){return await this.done(),Object.values(f(this,io,"f"))}async finalRun(){if(await this.done(),!f(this,Yt,"f"))throw Error("Final run was not received.");return f(this,Yt,"f")}async _createThreadAssistantStream(e,t,r){let n=r?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort()));let o={...t,stream:true},i=await e.createAndRun(o,{...r,signal:this.controller.signal});this._connected();for await(let a of i)f(this,me,"m",on).call(this,a);if(i.controller.signal?.aborted)throw new se;return this._addRun(f(this,me,"m",an).call(this))}async _createAssistantStream(e,t,r,n){let o=n?.signal;o&&(o.aborted&&this.controller.abort(),o.addEventListener("abort",()=>this.controller.abort()));let i={...r,stream:true},a=await e.create(t,i,{...n,signal:this.controller.signal});this._connected();for await(let c of a)f(this,me,"m",on).call(this,c);if(a.controller.signal?.aborted)throw new se;return this._addRun(f(this,me,"m",an).call(this))}static accumulateDelta(e,t){for(let[r,n]of Object.entries(t)){if(!e.hasOwnProperty(r)){e[r]=n;continue}let o=e[r];if(o==null){e[r]=n;continue}if(r==="index"||r==="type"){e[r]=n;continue}if(typeof o=="string"&&typeof n=="string")o+=n;else if(typeof o=="number"&&typeof n=="number")o+=n;else if(Ws(o)&&Ws(n))o=this.accumulateDelta(o,n);else if(Array.isArray(o)&&Array.isArray(n)){if(o.every(i=>typeof i=="string"||typeof i=="number")){o.push(...n);continue}for(let i of n){if(!Ws(i))throw new Error(`Expected array delta entry to be an object but got: ${i}`);let a=i.index;if(a==null)throw console.error(i),new Error("Expected array delta entry to have an `index` property");if(typeof a!="number")throw new Error(`Expected array delta entry \`index\` property to be a number but got ${a}`);let c=o[a];c==null?o.push(i):o[a]=this.accumulateDelta(c,i);}continue}else throw Error(`Unhandled record type: ${r}, deltaValue: ${n}, accValue: ${o}`);e[r]=o;}return e}_addRun(e){return e}async _threadAssistantStream(e,t,r){return await this._createThreadAssistantStream(t,e,r)}async _runAssistantStream(e,t,r,n){return await this._createAssistantStream(t,e,r,n)}async _runToolAssistantStream(e,t,r,n){return await this._createToolAssistantStream(t,e,r,n)}};Gt=ot,on=function(e){if(!this.ended)switch(k(this,ao,e),f(this,me,"m",sc).call(this,e),e.event){case "thread.created":break;case "thread.run.created":case "thread.run.queued":case "thread.run.in_progress":case "thread.run.requires_action":case "thread.run.completed":case "thread.run.incomplete":case "thread.run.failed":case "thread.run.cancelling":case "thread.run.cancelled":case "thread.run.expired":f(this,me,"m",ac).call(this,e);break;case "thread.run.step.created":case "thread.run.step.in_progress":case "thread.run.step.delta":case "thread.run.step.completed":case "thread.run.step.failed":case "thread.run.step.cancelled":case "thread.run.step.expired":f(this,me,"m",rc).call(this,e);break;case "thread.message.created":case "thread.message.in_progress":case "thread.message.delta":case "thread.message.completed":case "thread.message.incomplete":f(this,me,"m",tc).call(this,e);break;case "error":throw new Error("Encountered an error event in event processing - errors should be processed earlier");}},an=function(){if(this.ended)throw new I("stream has ended, this shouldn't happen");if(!f(this,Yt,"f"))throw Error("Final run has not been received");return f(this,Yt,"f")},tc=function(e){let[t,r]=f(this,me,"m",oc).call(this,e,f(this,Ne,"f"));k(this,Ne,t),f(this,io,"f")[t.id]=t;for(let n of r){let o=t.content[n.index];o?.type=="text"&&this._emit("textCreated",o.text);}switch(e.event){case "thread.message.created":this._emit("messageCreated",e.data);break;case "thread.message.in_progress":break;case "thread.message.delta":if(this._emit("messageDelta",e.data.delta,t),e.data.delta.content)for(let n of e.data.delta.content){if(n.type=="text"&&n.text){let o=n.text,i=t.content[n.index];if(i&&i.type=="text")this._emit("textDelta",o,i.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(n.index!=f(this,Yr,"f")){if(f(this,Kt,"f"))switch(f(this,Kt,"f").type){case "text":this._emit("textDone",f(this,Kt,"f").text,f(this,Ne,"f"));break;case "image_file":this._emit("imageFileDone",f(this,Kt,"f").image_file,f(this,Ne,"f"));break}k(this,Yr,n.index);}k(this,Kt,t.content[n.index]);}break;case "thread.message.completed":case "thread.message.incomplete":if(f(this,Yr,"f")!==void 0){let n=e.data.content[f(this,Yr,"f")];if(n)switch(n.type){case "image_file":this._emit("imageFileDone",n.image_file,f(this,Ne,"f"));break;case "text":this._emit("textDone",n.text,f(this,Ne,"f"));break}}f(this,Ne,"f")&&this._emit("messageDone",e.data),k(this,Ne,void 0);}},rc=function(e){let t=f(this,me,"m",nc).call(this,e);switch(k(this,ln,t),e.event){case "thread.run.step.created":this._emit("runStepCreated",e.data);break;case "thread.run.step.delta":let r=e.data.delta;if(r.step_details&&r.step_details.type=="tool_calls"&&r.step_details.tool_calls&&t.step_details.type=="tool_calls")for(let o of r.step_details.tool_calls)o.index==f(this,co,"f")?this._emit("toolCallDelta",o,t.step_details.tool_calls[o.index]):(f(this,Re,"f")&&this._emit("toolCallDone",f(this,Re,"f")),k(this,co,o.index),k(this,Re,t.step_details.tool_calls[o.index]),f(this,Re,"f")&&this._emit("toolCallCreated",f(this,Re,"f")));this._emit("runStepDelta",e.data.delta,t);break;case "thread.run.step.completed":case "thread.run.step.failed":case "thread.run.step.cancelled":case "thread.run.step.expired":k(this,ln,void 0),e.data.step_details.type=="tool_calls"&&f(this,Re,"f")&&(this._emit("toolCallDone",f(this,Re,"f")),k(this,Re,void 0)),this._emit("runStepDone",e.data,t);break;}},sc=function(e){f(this,Di,"f").push(e),this._emit("event",e);},nc=function(e){switch(e.event){case "thread.run.step.created":return f(this,Ve,"f")[e.data.id]=e.data,e.data;case "thread.run.step.delta":let t=f(this,Ve,"f")[e.data.id];if(!t)throw Error("Received a RunStepDelta before creation of a snapshot");let r=e.data;if(r.delta){let n=Gt.accumulateDelta(t,r.delta);f(this,Ve,"f")[e.data.id]=n;}return f(this,Ve,"f")[e.data.id];case "thread.run.step.completed":case "thread.run.step.failed":case "thread.run.step.cancelled":case "thread.run.step.expired":case "thread.run.step.in_progress":f(this,Ve,"f")[e.data.id]=e.data;break}if(f(this,Ve,"f")[e.data.id])return f(this,Ve,"f")[e.data.id];throw new Error("No snapshot available")},oc=function(e,t){let r=[];switch(e.event){case "thread.message.created":return [e.data,r];case "thread.message.delta":if(!t)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let n=e.data;if(n.delta.content)for(let o of n.delta.content)if(o.index in t.content){let i=t.content[o.index];t.content[o.index]=f(this,me,"m",ic).call(this,o,i);}else t.content[o.index]=o,r.push(o);return [t,r];case "thread.message.in_progress":case "thread.message.completed":case "thread.message.incomplete":if(t)return [t,r];throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},ic=function(e,t){return Gt.accumulateDelta(t,e)},ac=function(e){switch(k(this,lo,e.data),e.event){case "thread.run.created":break;case "thread.run.queued":break;case "thread.run.in_progress":break;case "thread.run.requires_action":case "thread.run.cancelled":case "thread.run.failed":case "thread.run.completed":case "thread.run.expired":case "thread.run.incomplete":k(this,Yt,e.data),f(this,Re,"f")&&(this._emit("toolCallDone",f(this,Re,"f")),k(this,Re,void 0));break;}};var zt=class extends g{constructor(){super(...arguments),this.steps=new Gr(this._client);}create(e,t,r){let{include:n,...o}=t;return this._client.post(p`/threads/${e}/runs`,{query:{include:n},body:o,...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers]),stream:t.stream??false})}retrieve(e,t,r){let{thread_id:n}=t;return this._client.get(p`/threads/${n}/runs/${e}`,{...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}update(e,t,r){let{thread_id:n,...o}=t;return this._client.post(p`/threads/${n}/runs/${e}`,{body:o,...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}list(e,t={},r){return this._client.getAPIList(p`/threads/${e}/runs`,F,{query:t,...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}cancel(e,t,r){let{thread_id:n}=t;return this._client.post(p`/threads/${n}/runs/${e}/cancel`,{...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}async createAndPoll(e,t,r){let n=await this.create(e,t,r);return await this.poll(n.id,{thread_id:e},r)}createAndStream(e,t,r){return ot.createAssistantStream(e,this._client.beta.threads.runs,t,r)}async poll(e,t,r){let n=w([r?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":r?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:o,response:i}=await this.retrieve(e,t,{...r,headers:{...r?.headers,...n}}).withResponse();switch(o.status){case "queued":case "in_progress":case "cancelling":let a=5e3;if(r?.pollIntervalMs)a=r.pollIntervalMs;else {let c=i.headers.get("openai-poll-after-ms");if(c){let u=parseInt(c);isNaN(u)||(a=u);}}await qe(a);break;case "requires_action":case "incomplete":case "cancelled":case "completed":case "failed":case "expired":return o}}}stream(e,t,r){return ot.createAssistantStream(e,this._client.beta.threads.runs,t,r)}submitToolOutputs(e,t,r){let{thread_id:n,...o}=t;return this._client.post(p`/threads/${n}/runs/${e}/submit_tool_outputs`,{body:o,...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers]),stream:t.stream??false})}async submitToolOutputsAndPoll(e,t,r){let n=await this.submitToolOutputs(e,t,r);return await this.poll(n.id,t,r)}submitToolOutputsStream(e,t,r){return ot.createToolAssistantStream(e,this._client.beta.threads.runs,t,r)}};zt.Steps=Gr;var It=class extends g{constructor(){super(...arguments),this.runs=new zt(this._client),this.messages=new Kr(this._client);}create(e={},t){return this._client.post("/threads",{body:e,...t,headers:w([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(p`/threads/${e}`,{...t,headers:w([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,r){return this._client.post(p`/threads/${e}`,{body:t,...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}delete(e,t){return this._client.delete(p`/threads/${e}`,{...t,headers:w([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}createAndRun(e,t){return this._client.post("/threads/runs",{body:e,...t,headers:w([{"OpenAI-Beta":"assistants=v2"},t?.headers]),stream:e.stream??false})}async createAndRunPoll(e,t){let r=await this.createAndRun(e,t);return await this.runs.poll(r.id,{thread_id:r.thread_id},t)}createAndRunStream(e,t){return ot.createThreadAssistantStream(e,this._client.beta.threads,t)}};It.Runs=zt;It.Messages=Kr;var Le=class extends g{constructor(){super(...arguments),this.realtime=new At(this._client),this.chatkit=new Pt(this._client),this.assistants=new Wr(this._client),this.threads=new It(this._client);}};Le.Realtime=At;Le.ChatKit=Pt;Le.Assistants=Wr;Le.Threads=It;var Qt=class extends g{create(e,t){return this._client.post("/completions",{body:e,...t,stream:e.stream??false})}};var zr=class extends g{retrieve(e,t,r){let{container_id:n}=t;return this._client.get(p`/containers/${n}/files/${e}/content`,{...r,headers:w([{Accept:"application/binary"},r?.headers]),__binaryResponse:true})}};var Zt=class extends g{constructor(){super(...arguments),this.content=new zr(this._client);}create(e,t,r){return this._client.post(p`/containers/${e}/files`,Ie({body:t,...r},this._client))}retrieve(e,t,r){let{container_id:n}=t;return this._client.get(p`/containers/${n}/files/${e}`,r)}list(e,t={},r){return this._client.getAPIList(p`/containers/${e}/files`,F,{query:t,...r})}delete(e,t,r){let{container_id:n}=t;return this._client.delete(p`/containers/${n}/files/${e}`,{...r,headers:w([{Accept:"*/*"},r?.headers])})}};Zt.Content=zr;var Rt=class extends g{constructor(){super(...arguments),this.files=new Zt(this._client);}create(e,t){return this._client.post("/containers",{body:e,...t})}retrieve(e,t){return this._client.get(p`/containers/${e}`,t)}list(e={},t){return this._client.getAPIList("/containers",F,{query:e,...t})}delete(e,t){return this._client.delete(p`/containers/${e}`,{...t,headers:w([{Accept:"*/*"},t?.headers])})}};Rt.Files=Zt;var Qr=class extends g{create(e,t,r){let{include:n,...o}=t;return this._client.post(p`/conversations/${e}/items`,{query:{include:n},body:o,...r})}retrieve(e,t,r){let{conversation_id:n,...o}=t;return this._client.get(p`/conversations/${n}/items/${e}`,{query:o,...r})}list(e,t={},r){return this._client.getAPIList(p`/conversations/${e}/items`,tt,{query:t,...r})}delete(e,t,r){let{conversation_id:n}=t;return this._client.delete(p`/conversations/${n}/items/${e}`,r)}};var Et=class extends g{constructor(){super(...arguments),this.items=new Qr(this._client);}create(e={},t){return this._client.post("/conversations",{body:e,...t})}retrieve(e,t){return this._client.get(p`/conversations/${e}`,t)}update(e,t,r){return this._client.post(p`/conversations/${e}`,{body:t,...r})}delete(e,t){return this._client.delete(p`/conversations/${e}`,t)}};Et.Items=Qr;var er=class extends g{create(e,t){let r=!!e.encoding_format,n=r?e.encoding_format:"base64";r&&ee(this._client).debug("embeddings/user defined encoding_format:",e.encoding_format);let o=this._client.post("/embeddings",{body:{...e,encoding_format:n},...t});return r?o:(ee(this._client).debug("embeddings/decoding base64 embeddings from base64"),o._thenUnwrap(i=>(i&&i.data&&i.data.forEach(a=>{let c=a.embedding;a.embedding=ec(c);}),i)))}};var Zr=class extends g{retrieve(e,t,r){let{eval_id:n,run_id:o}=t;return this._client.get(p`/evals/${n}/runs/${o}/output_items/${e}`,r)}list(e,t,r){let{eval_id:n,...o}=t;return this._client.getAPIList(p`/evals/${n}/runs/${e}/output_items`,F,{query:o,...r})}};var tr=class extends g{constructor(){super(...arguments),this.outputItems=new Zr(this._client);}create(e,t,r){return this._client.post(p`/evals/${e}/runs`,{body:t,...r})}retrieve(e,t,r){let{eval_id:n}=t;return this._client.get(p`/evals/${n}/runs/${e}`,r)}list(e,t={},r){return this._client.getAPIList(p`/evals/${e}/runs`,F,{query:t,...r})}delete(e,t,r){let{eval_id:n}=t;return this._client.delete(p`/evals/${n}/runs/${e}`,r)}cancel(e,t,r){let{eval_id:n}=t;return this._client.post(p`/evals/${n}/runs/${e}`,r)}};tr.OutputItems=Zr;var kt=class extends g{constructor(){super(...arguments),this.runs=new tr(this._client);}create(e,t){return this._client.post("/evals",{body:e,...t})}retrieve(e,t){return this._client.get(p`/evals/${e}`,t)}update(e,t,r){return this._client.post(p`/evals/${e}`,{body:t,...r})}list(e={},t){return this._client.getAPIList("/evals",F,{query:e,...t})}delete(e,t){return this._client.delete(p`/evals/${e}`,t)}};kt.Runs=tr;var rr=class extends g{create(e,t){return this._client.post("/files",Ie({body:e,...t},this._client))}retrieve(e,t){return this._client.get(p`/files/${e}`,t)}list(e={},t){return this._client.getAPIList("/files",F,{query:e,...t})}delete(e,t){return this._client.delete(p`/files/${e}`,t)}content(e,t){return this._client.get(p`/files/${e}/content`,{...t,headers:w([{Accept:"application/binary"},t?.headers]),__binaryResponse:true})}async waitForProcessing(e,{pollInterval:t=5e3,maxWait:r=1800*1e3}={}){let n=new Set(["processed","error","deleted"]),o=Date.now(),i=await this.retrieve(e);for(;!i.status||!n.has(i.status);)if(await qe(t),i=await this.retrieve(e),Date.now()-o>r)throw new yt({message:`Giving up on waiting for file ${e} to finish processing after ${r} milliseconds.`});return i}};var es=class extends g{};var ts=class extends g{run(e,t){return this._client.post("/fine_tuning/alpha/graders/run",{body:e,...t})}validate(e,t){return this._client.post("/fine_tuning/alpha/graders/validate",{body:e,...t})}};var sr=class extends g{constructor(){super(...arguments),this.graders=new ts(this._client);}};sr.Graders=ts;var rs=class extends g{create(e,t,r){return this._client.getAPIList(p`/fine_tuning/checkpoints/${e}/permissions`,Je,{body:t,method:"post",...r})}retrieve(e,t={},r){return this._client.get(p`/fine_tuning/checkpoints/${e}/permissions`,{query:t,...r})}delete(e,t,r){let{fine_tuned_model_checkpoint:n}=t;return this._client.delete(p`/fine_tuning/checkpoints/${n}/permissions/${e}`,r)}};var nr=class extends g{constructor(){super(...arguments),this.permissions=new rs(this._client);}};nr.Permissions=rs;var ss=class extends g{list(e,t={},r){return this._client.getAPIList(p`/fine_tuning/jobs/${e}/checkpoints`,F,{query:t,...r})}};var or=class extends g{constructor(){super(...arguments),this.checkpoints=new ss(this._client);}create(e,t){return this._client.post("/fine_tuning/jobs",{body:e,...t})}retrieve(e,t){return this._client.get(p`/fine_tuning/jobs/${e}`,t)}list(e={},t){return this._client.getAPIList("/fine_tuning/jobs",F,{query:e,...t})}cancel(e,t){return this._client.post(p`/fine_tuning/jobs/${e}/cancel`,t)}listEvents(e,t={},r){return this._client.getAPIList(p`/fine_tuning/jobs/${e}/events`,F,{query:t,...r})}pause(e,t){return this._client.post(p`/fine_tuning/jobs/${e}/pause`,t)}resume(e,t){return this._client.post(p`/fine_tuning/jobs/${e}/resume`,t)}};or.Checkpoints=ss;var Be=class extends g{constructor(){super(...arguments),this.methods=new es(this._client),this.jobs=new or(this._client),this.checkpoints=new nr(this._client),this.alpha=new sr(this._client);}};Be.Methods=es;Be.Jobs=or;Be.Checkpoints=nr;Be.Alpha=sr;var ns=class extends g{};var Tt=class extends g{constructor(){super(...arguments),this.graderModels=new ns(this._client);}};Tt.GraderModels=ns;var ir=class extends g{createVariation(e,t){return this._client.post("/images/variations",Ie({body:e,...t},this._client))}edit(e,t){return this._client.post("/images/edits",Ie({body:e,...t,stream:e.stream??false},this._client))}generate(e,t){return this._client.post("/images/generations",{body:e,...t,stream:e.stream??false})}};var ar=class extends g{retrieve(e,t){return this._client.get(p`/models/${e}`,t)}list(e){return this._client.getAPIList("/models",Je,e)}delete(e,t){return this._client.delete(p`/models/${e}`,t)}};var lr=class extends g{create(e,t){return this._client.post("/moderations",{body:e,...t})}};var os=class extends g{accept(e,t,r){return this._client.post(p`/realtime/calls/${e}/accept`,{body:t,...r,headers:w([{Accept:"*/*"},r?.headers])})}hangup(e,t){return this._client.post(p`/realtime/calls/${e}/hangup`,{...t,headers:w([{Accept:"*/*"},t?.headers])})}refer(e,t,r){return this._client.post(p`/realtime/calls/${e}/refer`,{body:t,...r,headers:w([{Accept:"*/*"},r?.headers])})}reject(e,t={},r){return this._client.post(p`/realtime/calls/${e}/reject`,{body:t,...r,headers:w([{Accept:"*/*"},r?.headers])})}};var is=class extends g{create(e,t){return this._client.post("/realtime/client_secrets",{body:e,...t})}};var it=class extends g{constructor(){super(...arguments),this.clientSecrets=new is(this._client),this.calls=new os(this._client);}};it.ClientSecrets=is;it.Calls=os;function lc(s,e){return !e||!ud(e)?{...s,output_parsed:null,output:s.output.map(t=>t.type==="function_call"?{...t,parsed_arguments:null}:t.type==="message"?{...t,content:t.content.map(r=>({...r,parsed:null}))}:t)}:Ui(s,e)}function Ui(s,e){let t=s.output.map(n=>{if(n.type==="function_call")return {...n,parsed_arguments:hd(e,n)};if(n.type==="message"){let o=n.content.map(i=>i.type==="output_text"?{...i,parsed:cd(e,i.text)}:i);return {...n,content:o}}return n}),r=Object.assign({},s,{output:t});return Object.getOwnPropertyDescriptor(s,"output_text")||uo(r),Object.defineProperty(r,"output_parsed",{enumerable:true,get(){for(let n of r.output)if(n.type==="message"){for(let o of n.content)if(o.type==="output_text"&&o.parsed!==null)return o.parsed}return null}}),r}function cd(s,e){return s.text?.format?.type!=="json_schema"?null:"$parseRaw"in s.text?.format?(s.text?.format).$parseRaw(e):JSON.parse(e)}function ud(s){return !!zs(s.text?.format)}function fd(s){return s?.$brand==="auto-parseable-tool"}function dd(s,e){return s.find(t=>t.type==="function"&&t.name===e)}function hd(s,e){let t=dd(s.tools??[],e.name);return {...e,...e,parsed_arguments:fd(t)?t.$parseRaw(e.arguments):t?.strict?JSON.parse(e.arguments):null}}function uo(s){let e=[];for(let t of s.output)if(t.type==="message")for(let r of t.content)r.type==="output_text"&&e.push(r.text);s.output_text=e.join("");}var as,fo,Ct,ho,cc,uc,fc,dc,mo=class s extends wt{constructor(e){super(),as.add(this),fo.set(this,void 0),Ct.set(this,void 0),ho.set(this,void 0),k(this,fo,e);}static createResponse(e,t,r){let n=new s(t);return n._run(()=>n._createOrRetrieveResponse(e,t,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),n}async _createOrRetrieveResponse(e,t,r){let n=r?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),f(this,as,"m",cc).call(this);let o,i=null;"response_id"in t?(o=await e.responses.retrieve(t.response_id,{stream:true},{...r,signal:this.controller.signal,stream:true}),i=t.starting_after??null):o=await e.responses.create({...t,stream:true},{...r,signal:this.controller.signal}),this._connected();for await(let a of o)f(this,as,"m",uc).call(this,a,i);if(o.controller.signal?.aborted)throw new se;return f(this,as,"m",fc).call(this)}[(fo=new WeakMap,Ct=new WeakMap,ho=new WeakMap,as=new WeakSet,cc=function(){this.ended||k(this,Ct,void 0);},uc=function(t,r){if(this.ended)return;let n=(i,a)=>{(r==null||a.sequence_number>r)&&this._emit(i,a);},o=f(this,as,"m",dc).call(this,t);switch(n("event",t),t.type){case "response.output_text.delta":{let i=o.output[t.output_index];if(!i)throw new I(`missing output at index ${t.output_index}`);if(i.type==="message"){let a=i.content[t.content_index];if(!a)throw new I(`missing content at index ${t.content_index}`);if(a.type!=="output_text")throw new I(`expected content to be 'output_text', got ${a.type}`);n("response.output_text.delta",{...t,snapshot:a.text});}break}case "response.function_call_arguments.delta":{let i=o.output[t.output_index];if(!i)throw new I(`missing output at index ${t.output_index}`);i.type==="function_call"&&n("response.function_call_arguments.delta",{...t,snapshot:i.arguments});break}default:n(t.type,t);break}},fc=function(){if(this.ended)throw new I("stream has ended, this shouldn't happen");let t=f(this,Ct,"f");if(!t)throw new I("request ended without sending any events");k(this,Ct,void 0);let r=md(t,f(this,fo,"f"));return k(this,ho,r),r},dc=function(t){let r=f(this,Ct,"f");if(!r){if(t.type!=="response.created")throw new I(`When snapshot hasn't been set yet, expected 'response.created' event, got ${t.type}`);return r=k(this,Ct,t.response),r}switch(t.type){case "response.output_item.added":{r.output.push(t.item);break}case "response.content_part.added":{let n=r.output[t.output_index];if(!n)throw new I(`missing output at index ${t.output_index}`);let o=n.type,i=t.part;o==="message"&&i.type!=="reasoning_text"?n.content.push(i):o==="reasoning"&&i.type==="reasoning_text"&&(n.content||(n.content=[]),n.content.push(i));break}case "response.output_text.delta":{let n=r.output[t.output_index];if(!n)throw new I(`missing output at index ${t.output_index}`);if(n.type==="message"){let o=n.content[t.content_index];if(!o)throw new I(`missing content at index ${t.content_index}`);if(o.type!=="output_text")throw new I(`expected content to be 'output_text', got ${o.type}`);o.text+=t.delta;}break}case "response.function_call_arguments.delta":{let n=r.output[t.output_index];if(!n)throw new I(`missing output at index ${t.output_index}`);n.type==="function_call"&&(n.arguments+=t.delta);break}case "response.reasoning_text.delta":{let n=r.output[t.output_index];if(!n)throw new I(`missing output at index ${t.output_index}`);if(n.type==="reasoning"){let o=n.content?.[t.content_index];if(!o)throw new I(`missing content at index ${t.content_index}`);if(o.type!=="reasoning_text")throw new I(`expected content to be 'reasoning_text', got ${o.type}`);o.text+=t.delta;}break}case "response.completed":{k(this,Ct,t.response);break}}return r},Symbol.asyncIterator)](){let e=[],t=[],r=false;return this.on("event",n=>{let o=t.shift();o?o.resolve(n):e.push(n);}),this.on("end",()=>{r=true;for(let n of t)n.resolve(void 0);t.length=0;}),this.on("abort",n=>{r=true;for(let o of t)o.reject(n);t.length=0;}),this.on("error",n=>{r=true;for(let o of t)o.reject(n);t.length=0;}),{next:async()=>e.length?{value:e.shift(),done:false}:r?{value:void 0,done:true}:new Promise((o,i)=>t.push({resolve:o,reject:i})).then(o=>o?{value:o,done:false}:{value:void 0,done:true}),return:async()=>(this.abort(),{value:void 0,done:true})}}async finalResponse(){await this.done();let e=f(this,ho,"f");if(!e)throw new I("stream ended without producing a ChatCompletion");return e}};function md(s,e){return lc(s,e)}var ls=class extends g{list(e,t={},r){return this._client.getAPIList(p`/responses/${e}/input_items`,F,{query:t,...r})}};var cs=class extends g{count(e={},t){return this._client.post("/responses/input_tokens",{body:e,...t})}};var at=class extends g{constructor(){super(...arguments),this.inputItems=new ls(this._client),this.inputTokens=new cs(this._client);}create(e,t){return this._client.post("/responses",{body:e,...t,stream:e.stream??false})._thenUnwrap(r=>("object"in r&&r.object==="response"&&uo(r),r))}retrieve(e,t={},r){return this._client.get(p`/responses/${e}`,{query:t,...r,stream:t?.stream??false})._thenUnwrap(n=>("object"in n&&n.object==="response"&&uo(n),n))}delete(e,t){return this._client.delete(p`/responses/${e}`,{...t,headers:w([{Accept:"*/*"},t?.headers])})}parse(e,t){return this._client.responses.create(e,t)._thenUnwrap(r=>Ui(r,e))}stream(e,t){return mo.createResponse(this._client,e,t)}cancel(e,t){return this._client.post(p`/responses/${e}/cancel`,t)}compact(e,t){return this._client.post("/responses/compact",{body:e,...t})}};at.InputItems=ls;at.InputTokens=cs;var us=class extends g{create(e,t,r){return this._client.post(p`/uploads/${e}/parts`,Ie({body:t,...r},this._client))}};var Ot=class extends g{constructor(){super(...arguments),this.parts=new us(this._client);}create(e,t){return this._client.post("/uploads",{body:e,...t})}cancel(e,t){return this._client.post(p`/uploads/${e}/cancel`,t)}complete(e,t,r){return this._client.post(p`/uploads/${e}/complete`,{body:t,...r})}};Ot.Parts=us;var hc=async s=>{let e=await Promise.allSettled(s),t=e.filter(n=>n.status==="rejected");if(t.length){for(let n of t)console.error(n.reason);throw new Error(`${t.length} promise(s) failed - see the above errors`)}let r=[];for(let n of e)n.status==="fulfilled"&&r.push(n.value);return r};var fs=class extends g{create(e,t,r){return this._client.post(p`/vector_stores/${e}/file_batches`,{body:t,...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}retrieve(e,t,r){let{vector_store_id:n}=t;return this._client.get(p`/vector_stores/${n}/file_batches/${e}`,{...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}cancel(e,t,r){let{vector_store_id:n}=t;return this._client.post(p`/vector_stores/${n}/file_batches/${e}/cancel`,{...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}async createAndPoll(e,t,r){let n=await this.create(e,t);return await this.poll(e,n.id,r)}listFiles(e,t,r){let{vector_store_id:n,...o}=t;return this._client.getAPIList(p`/vector_stores/${n}/file_batches/${e}/files`,F,{query:o,...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}async poll(e,t,r){let n=w([r?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":r?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:o,response:i}=await this.retrieve(t,{vector_store_id:e},{...r,headers:n}).withResponse();switch(o.status){case "in_progress":let a=5e3;if(r?.pollIntervalMs)a=r.pollIntervalMs;else {let c=i.headers.get("openai-poll-after-ms");if(c){let u=parseInt(c);isNaN(u)||(a=u);}}await qe(a);break;case "failed":case "cancelled":case "completed":return o}}}async uploadAndPoll(e,{files:t,fileIds:r=[]},n){if(t==null||t.length==0)throw new Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let o=n?.maxConcurrency??5,i=Math.min(o,t.length),a=this._client,c=t.values(),u=[...r];async function _(x){for(let d of x){let R=await a.files.create({file:d,purpose:"assistants"},n);u.push(R.id);}}let h=Array(i).fill(c).map(_);return await hc(h),await this.createAndPoll(e,{file_ids:u})}};var ds=class extends g{create(e,t,r){return this._client.post(p`/vector_stores/${e}/files`,{body:t,...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}retrieve(e,t,r){let{vector_store_id:n}=t;return this._client.get(p`/vector_stores/${n}/files/${e}`,{...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}update(e,t,r){let{vector_store_id:n,...o}=t;return this._client.post(p`/vector_stores/${n}/files/${e}`,{body:o,...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}list(e,t={},r){return this._client.getAPIList(p`/vector_stores/${e}/files`,F,{query:t,...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}delete(e,t,r){let{vector_store_id:n}=t;return this._client.delete(p`/vector_stores/${n}/files/${e}`,{...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}async createAndPoll(e,t,r){let n=await this.create(e,t,r);return await this.poll(e,n.id,r)}async poll(e,t,r){let n=w([r?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":r?.pollIntervalMs?.toString()??void 0}]);for(;;){let o=await this.retrieve(t,{vector_store_id:e},{...r,headers:n}).withResponse(),i=o.data;switch(i.status){case "in_progress":let a=5e3;if(r?.pollIntervalMs)a=r.pollIntervalMs;else {let c=o.response.headers.get("openai-poll-after-ms");if(c){let u=parseInt(c);isNaN(u)||(a=u);}}await qe(a);break;case "failed":case "completed":return i}}}async upload(e,t,r){let n=await this._client.files.create({file:t,purpose:"assistants"},r);return this.create(e,{file_id:n.id},r)}async uploadAndPoll(e,t,r){let n=await this.upload(e,t,r);return await this.poll(e,n.id,r)}content(e,t,r){let{vector_store_id:n}=t;return this._client.getAPIList(p`/vector_stores/${n}/files/${e}/content`,Je,{...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}};var lt=class extends g{constructor(){super(...arguments),this.files=new ds(this._client),this.fileBatches=new fs(this._client);}create(e,t){return this._client.post("/vector_stores",{body:e,...t,headers:w([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(p`/vector_stores/${e}`,{...t,headers:w([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,r){return this._client.post(p`/vector_stores/${e}`,{body:t,...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}list(e={},t){return this._client.getAPIList("/vector_stores",F,{query:e,...t,headers:w([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}delete(e,t){return this._client.delete(p`/vector_stores/${e}`,{...t,headers:w([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}search(e,t,r){return this._client.getAPIList(p`/vector_stores/${e}/search`,Je,{body:t,method:"post",...r,headers:w([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}};lt.Files=ds;lt.FileBatches=fs;var cr=class extends g{create(e,t){return this._client.post("/videos",Ai({body:e,...t},this._client))}retrieve(e,t){return this._client.get(p`/videos/${e}`,t)}list(e={},t){return this._client.getAPIList("/videos",tt,{query:e,...t})}delete(e,t){return this._client.delete(p`/videos/${e}`,t)}downloadContent(e,t={},r){return this._client.get(p`/videos/${e}/content`,{query:t,...r,headers:w([{Accept:"application/binary"},r?.headers]),__binaryResponse:true})}remix(e,t,r){return this._client.post(p`/videos/${e}/remix`,Ai({body:t,...r},this._client))}};var hs,mc,po,ur=class extends g{constructor(){super(...arguments),hs.add(this);}async unwrap(e,t,r=this._client.webhookSecret,n=300){return await this.verifySignature(e,t,r,n),JSON.parse(e)}async verifySignature(e,t,r=this._client.webhookSecret,n=300){if(typeof crypto>"u"||typeof crypto.subtle.importKey!="function"||typeof crypto.subtle.verify!="function")throw new Error("Webhook signature verification is only supported when the `crypto` global is defined");f(this,hs,"m",mc).call(this,r);let o=w([t]).values,i=f(this,hs,"m",po).call(this,o,"webhook-signature"),a=f(this,hs,"m",po).call(this,o,"webhook-timestamp"),c=f(this,hs,"m",po).call(this,o,"webhook-id"),u=parseInt(a,10);if(isNaN(u))throw new Ue("Invalid webhook timestamp format");let _=Math.floor(Date.now()/1e3);if(_-u>n)throw new Ue("Webhook timestamp is too old");if(u>_+n)throw new Ue("Webhook timestamp is too new");let h=i.split(" ").map(A=>A.startsWith("v1,")?A.substring(3):A),x=r.startsWith("whsec_")?Buffer.from(r.replace("whsec_",""),"base64"):Buffer.from(r,"utf-8"),d=c?`${c}.${a}.${e}`:`${a}.${e}`,R=await crypto.subtle.importKey("raw",x,{name:"HMAC",hash:"SHA-256"},false,["verify"]);for(let A of h)try{let B=Buffer.from(A,"base64");if(await crypto.subtle.verify("HMAC",R,B,new TextEncoder().encode(d)))return}catch{continue}throw new Ue("The given webhook signature does not match the expected signature")}};hs=new WeakSet,mc=function(e){if(typeof e!="string"||e.length===0)throw new Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function")},po=function(e,t){if(!e)throw new Error("Headers are required");let r=e.get(t);if(r==null)throw new Error(`Missing required header: ${t}`);return r};var qi,Wi,go,pc,O=class{constructor({baseURL:e=vt("OPENAI_BASE_URL"),apiKey:t=vt("OPENAI_API_KEY"),organization:r=vt("OPENAI_ORG_ID")??null,project:n=vt("OPENAI_PROJECT_ID")??null,webhookSecret:o=vt("OPENAI_WEBHOOK_SECRET")??null,...i}={}){if(qi.add(this),go.set(this,void 0),this.completions=new Qt(this),this.chat=new St(this),this.embeddings=new er(this),this.files=new rr(this),this.images=new ir(this),this.audio=new Xe(this),this.moderations=new lr(this),this.models=new ar(this),this.fineTuning=new Be(this),this.graders=new Tt(this),this.vectorStores=new lt(this),this.webhooks=new ur(this),this.beta=new Le(this),this.batches=new Vt(this),this.uploads=new Ot(this),this.responses=new at(this),this.realtime=new it(this),this.conversations=new Et(this),this.evals=new kt(this),this.containers=new Rt(this),this.videos=new cr(this),t===void 0)throw new I("Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.");let a={apiKey:t,organization:r,project:n,webhookSecret:o,...i,baseURL:e||"https://api.openai.com/v1"};if(!a.dangerouslyAllowBrowser&&Sl())throw new I(`It looks like you're running in a browser-like environment.
29
-
30
- This is disabled by default, as it risks exposing your secret API credentials to attackers.
31
- If you understand the risks and have appropriate mitigations in place,
32
- you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
33
-
34
- new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
35
-
36
- https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
37
- `);this.baseURL=a.baseURL,this.timeout=a.timeout??Wi.DEFAULT_TIMEOUT,this.logger=a.logger??console;let c="warn";this.logLevel=c,this.logLevel=_i(a.logLevel,"ClientOptions.logLevel",this)??_i(vt("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??c,this.fetchOptions=a.fetchOptions,this.maxRetries=a.maxRetries??2,this.fetch=a.fetch??Pl(),k(this,go,Il),this._options=a,this.apiKey=typeof t=="string"?t:"Missing Key",this.organization=r,this.project=n,this.webhookSecret=o;}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){}async authHeaders(e){return w([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return pi(e,{arrayFormat:"brackets"})}getUserAgent(){return `${this.constructor.name}/JS ${bt}`}defaultIdempotencyKey(){return `stainless-node-retry-${oi()}`}makeStatusError(e,t,r,n){return oe.generate(e,t,r,n)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!="function")return false;let t;try{t=await e();}catch(r){throw r instanceof I?r:new I(`Failed to get token from 'apiKey' function: ${r.message}`,{cause:r})}if(typeof t!="string"||!t)throw new I(`Expected 'apiKey' function argument to return a string but it returned ${t}`);return this.apiKey=t,true}buildURL(e,t,r){let n=!f(this,qi,"m",pc).call(this)&&r||this.baseURL,o=ml(e)?new URL(e):new URL(n+(n.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),i=this.defaultQuery();return pl(i)||(t={...i,...t}),typeof t=="object"&&t&&!Array.isArray(t)&&(o.search=this.stringifyQuery(t)),o.toString()}async prepareOptions(e){await this._callApiKey();}async prepareRequest(e,{url:t,options:r}){}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,r){return this.request(Promise.resolve(r).then(n=>({method:e,path:t,...n})))}request(e,t=null){return new Wt(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,r){let n=await e,o=n.maxRetries??this.maxRetries;t==null&&(t=o),await this.prepareOptions(n);let{req:i,url:a,timeout:c}=await this.buildRequest(n,{retryCount:o-t});await this.prepareRequest(i,{url:a,options:n});let u="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),_=r===void 0?"":`, retryOf: ${r}`,h=Date.now();if(ee(this).debug(`[${u}] sending request`,et({retryOfRequestLogID:r,method:n.method,url:a,options:n,headers:i.headers})),n.signal?.aborted)throw new se;let x=new AbortController,d=await this.fetchWithTimeout(a,i,c,x).catch(qs),R=Date.now();if(d instanceof globalThis.Error){let T=`retrying, ${t} attempts remaining`;if(n.signal?.aborted)throw new se;let b=Us(d)||/timed? ?out/i.test(String(d)+("cause"in d?String(d.cause):""));if(t)return ee(this).info(`[${u}] connection ${b?"timed out":"failed"} - ${T}`),ee(this).debug(`[${u}] connection ${b?"timed out":"failed"} (${T})`,et({retryOfRequestLogID:r,url:a,durationMs:R-h,message:d.message})),this.retryRequest(n,t,r??u);throw ee(this).info(`[${u}] connection ${b?"timed out":"failed"} - error; no more retries left`),ee(this).debug(`[${u}] connection ${b?"timed out":"failed"} (error; no more retries left)`,et({retryOfRequestLogID:r,url:a,durationMs:R-h,message:d.message})),b?new yt:new _t({cause:d})}let A=[...d.headers.entries()].filter(([T])=>T==="x-request-id").map(([T,b])=>", "+T+": "+JSON.stringify(b)).join(""),B=`[${u}${_}${A}] ${i.method} ${a} ${d.ok?"succeeded":"failed"} with status ${d.status} in ${R-h}ms`;if(!d.ok){let T=await this.shouldRetry(d);if(t&&T){let q=`retrying, ${t} attempts remaining`;return await vl(d.body),ee(this).info(`${B} - ${q}`),ee(this).debug(`[${u}] response error (${q})`,et({retryOfRequestLogID:r,url:d.url,status:d.status,headers:d.headers,durationMs:R-h})),this.retryRequest(n,t,r??u,d.headers)}let b=T?"error; no more retries left":"error; not retryable";ee(this).info(`${B} - ${b}`);let K=await d.text().catch(q=>qs(q).message),U=yl(K),ce=U?void 0:K;throw ee(this).debug(`[${u}] response error (${b})`,et({retryOfRequestLogID:r,url:d.url,status:d.status,headers:d.headers,message:ce,durationMs:Date.now()-h})),this.makeStatusError(d.status,U,ce,d.headers)}return ee(this).info(B),ee(this).debug(`[${u}] response start`,et({retryOfRequestLogID:r,url:d.url,status:d.status,headers:d.headers,durationMs:R-h})),{response:d,options:n,controller:x,requestLogID:u,retryOfRequestLogID:r,startTime:h}}getAPIList(e,t,r){return this.requestAPIList(t,{method:"get",path:e,...r})}requestAPIList(e,t){let r=this.makeRequest(t,null,void 0);return new Ks(this,r,e)}async fetchWithTimeout(e,t,r,n){let{signal:o,method:i,...a}=t||{};o&&o.addEventListener("abort",()=>n.abort());let c=setTimeout(()=>n.abort(),r),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,_={signal:n.signal,...u?{duplex:"half"}:{},method:"GET",...a};i&&(_.method=i.toUpperCase());try{return await this.fetch.call(void 0,e,_)}finally{clearTimeout(c);}}async shouldRetry(e){let t=e.headers.get("x-should-retry");return t==="true"?true:t==="false"?false:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,r,n){let o,i=n?.get("retry-after-ms");if(i){let c=parseFloat(i);Number.isNaN(c)||(o=c);}let a=n?.get("retry-after");if(a&&!o){let c=parseFloat(a);Number.isNaN(c)?o=Date.parse(a)-Date.now():o=c*1e3;}if(!(o&&0<=o&&o<60*1e3)){let c=e.maxRetries??this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(t,c);}return await qe(o),this.makeRequest(e,t-1,r)}calculateDefaultRetryTimeoutMillis(e,t){let o=t-e,i=Math.min(.5*Math.pow(2,o),8),a=1-Math.random()*.25;return i*a*1e3}async buildRequest(e,{retryCount:t=0}={}){let r={...e},{method:n,path:o,query:i,defaultBaseURL:a}=r,c=this.buildURL(o,i,a);"timeout"in r&&_l("timeout",r.timeout),r.timeout=r.timeout??this.timeout;let{bodyHeaders:u,body:_}=this.buildBody({options:r}),h=await this.buildHeaders({options:e,method:n,bodyHeaders:u,retryCount:t});return {req:{method:n,headers:h,...r.signal&&{signal:r.signal},...globalThis.ReadableStream&&_ instanceof globalThis.ReadableStream&&{duplex:"half"},..._&&{body:_},...this.fetchOptions??{},...r.fetchOptions??{}},url:c,timeout:r.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:r,retryCount:n}){let o={};this.idempotencyHeader&&t!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),o[this.idempotencyHeader]=e.idempotencyKey);let i=w([o,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(n),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...Al(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,r,e.headers]);return this.validateHeaders(i),i.values}buildBody({options:{body:e,headers:t}}){if(!e)return {bodyHeaders:void 0,body:void 0};let r=w([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&r.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:Un(e)}:f(this,go,"f").call(this,{body:e,headers:r})}};Wi=O,go=new WeakMap,qi=new WeakSet,pc=function(){return this.baseURL!=="https://api.openai.com/v1"};O.OpenAI=Wi;O.DEFAULT_TIMEOUT=6e5;O.OpenAIError=I;O.APIError=oe;O.APIConnectionError=_t;O.APIConnectionTimeoutError=yt;O.APIUserAbortError=se;O.NotFoundError=Rr;O.ConflictError=Er;O.RateLimitError=Tr;O.BadRequestError=Pr;O.AuthenticationError=vr;O.InternalServerError=Cr;O.PermissionDeniedError=Ir;O.UnprocessableEntityError=kr;O.InvalidWebhookSignatureError=Ue;O.toFile=Yn;O.Completions=Qt;O.Chat=St;O.Embeddings=er;O.Files=rr;O.Images=ir;O.Audio=Xe;O.Moderations=lr;O.Models=ar;O.FineTuning=Be;O.Graders=Tt;O.VectorStores=lt;O.Webhooks=ur;O.Beta=Le;O.Batches=Vt;O.Uploads=Ot;O.Responses=at;O.Realtime=it;O.Conversations=Et;O.Evals=kt;O.Containers=Rt;O.Videos=cr;function P(s,e,t,r,n){if(typeof e=="function"?s!==e||true:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(s,t),t}function m(s,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!r:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(s):r?r.value:e.get(s)}var Hi=function(){let{crypto:s}=globalThis;if(s?.randomUUID)return Hi=s.randomUUID.bind(s),s.randomUUID();let e=new Uint8Array(1),t=s?()=>s.getRandomValues(e)[0]:()=>Math.random()*255&255;return "10000000-1000-4000-8000-100000000000".replace(/[018]/g,r=>(+r^t()&15>>+r/4).toString(16))};function ct(s){return typeof s=="object"&&s!==null&&("name"in s&&s.name==="AbortError"||"message"in s&&String(s.message).includes("FetchRequestCanceledException"))}var cn=s=>{if(s instanceof Error)return s;if(typeof s=="object"&&s!==null){try{if(Object.prototype.toString.call(s)==="[object Error]"){let e=new Error(s.message,s.cause?{cause:s.cause}:{});return s.stack&&(e.stack=s.stack),s.cause&&!e.cause&&(e.cause=s.cause),s.name&&(e.name=s.name),e}}catch{}try{return new Error(JSON.stringify(s))}catch{}}return new Error(s)};var E=class extends Error{},de=class s extends E{constructor(e,t,r,n){super(`${s.makeMessage(e,t,r)}`),this.status=e,this.headers=n,this.requestID=n?.get("request-id"),this.error=t;}static makeMessage(e,t,r){let n=t?.message?typeof t.message=="string"?t.message:JSON.stringify(t.message):t?JSON.stringify(t):r;return e&&n?`${e} ${n}`:e?`${e} status code (no body)`:n||"(no status code or body)"}static generate(e,t,r,n){if(!e||!n)return new Mt({message:r,cause:cn(t)});let o=t;return e===400?new ps(e,o,r,n):e===401?new gs(e,o,r,n):e===403?new _s(e,o,r,n):e===404?new ys(e,o,r,n):e===409?new bs(e,o,r,n):e===422?new ws(e,o,r,n):e===429?new xs(e,o,r,n):e>=500?new Ss(e,o,r,n):new s(e,o,r,n)}},pe=class extends de{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0);}},Mt=class extends de{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t);}},ms=class extends Mt{constructor({message:e}={}){super({message:e??"Request timed out."});}},ps=class extends de{},gs=class extends de{},_s=class extends de{},ys=class extends de{},bs=class extends de{},ws=class extends de{},xs=class extends de{},Ss=class extends de{};var Sd=/^[a-z][a-z0-9+.-]*:/i,gc=s=>Sd.test(s),Ji=s=>(Ji=Array.isArray,Ji(s)),Xi=Ji;function _o(s){return typeof s!="object"?{}:s??{}}function _c(s){if(!s)return true;for(let e in s)return false;return true}function yc(s,e){return Object.prototype.hasOwnProperty.call(s,e)}var bc=(s,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new E(`${s} must be an integer`);if(e<0)throw new E(`${s} must be a positive integer`);return e};var yo=s=>{try{return JSON.parse(s)}catch{return}};var wc=s=>new Promise(e=>setTimeout(e,s));var $t="0.71.2";var Pc=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function Ad(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}var Pd=()=>{let s=Ad();if(s==="deno")return {"X-Stainless-Lang":"js","X-Stainless-Package-Version":$t,"X-Stainless-OS":Sc(Deno.build.os),"X-Stainless-Arch":xc(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return {"X-Stainless-Lang":"js","X-Stainless-Package-Version":$t,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(s==="node")return {"X-Stainless-Lang":"js","X-Stainless-Package-Version":$t,"X-Stainless-OS":Sc(globalThis.process.platform??"unknown"),"X-Stainless-Arch":xc(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let e=vd();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":$t,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":$t,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function vd(){if(typeof navigator>"u"||!navigator)return null;let s=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:e,pattern:t}of s){let r=t.exec(navigator.userAgent);if(r){let n=r[1]||0,o=r[2]||0,i=r[3]||0;return {browser:e,version:`${n}.${o}.${i}`}}}return null}var xc=s=>s==="x32"?"x32":s==="x86_64"||s==="x64"?"x64":s==="arm"?"arm":s==="aarch64"||s==="arm64"?"arm64":s?`other:${s}`:"unknown",Sc=s=>(s=s.toLowerCase(),s.includes("ios")?"iOS":s==="android"?"Android":s==="darwin"?"MacOS":s==="win32"?"Windows":s==="freebsd"?"FreeBSD":s==="openbsd"?"OpenBSD":s==="linux"?"Linux":s?`Other:${s}`:"Unknown"),Ac,vc=()=>Ac??(Ac=Pd());function Ic(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function Vi(...s){let e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...s)}function bo(s){let e=Symbol.asyncIterator in s?s[Symbol.asyncIterator]():s[Symbol.iterator]();return Vi({start(){},async pull(t){let{done:r,value:n}=await e.next();r?t.close():t.enqueue(n);},async cancel(){await e.return?.();}})}function un(s){if(s[Symbol.asyncIterator])return s;let e=s.getReader();return {async next(){try{let t=await e.read();return t?.done&&e.releaseLock(),t}catch(t){throw e.releaseLock(),t}},async return(){let t=e.cancel();return e.releaseLock(),await t,{done:true,value:void 0}},[Symbol.asyncIterator](){return this}}}async function Rc(s){if(s===null||typeof s!="object")return;if(s[Symbol.asyncIterator]){await s[Symbol.asyncIterator]().return?.();return}let e=s.getReader(),t=e.cancel();e.releaseLock(),await t;}var Ec=({headers:s,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)});function Cc(s){let e=0;for(let n of s)e+=n.length;let t=new Uint8Array(e),r=0;for(let n of s)t.set(n,r),r+=n.length;return t}var kc;function fn(s){let e;return (kc??(e=new globalThis.TextEncoder,kc=e.encode.bind(e)))(s)}var Tc;function Ki(s){let e;return (Tc??(e=new globalThis.TextDecoder,Tc=e.decode.bind(e)))(s)}var Ee,ke,ut=class{constructor(){Ee.set(this,void 0),ke.set(this,void 0),P(this,Ee,new Uint8Array),P(this,ke,null);}decode(e){if(e==null)return [];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?fn(e):e;P(this,Ee,Cc([m(this,Ee,"f"),t]));let r=[],n;for(;(n=Ed(m(this,Ee,"f"),m(this,ke,"f")))!=null;){if(n.carriage&&m(this,ke,"f")==null){P(this,ke,n.index);continue}if(m(this,ke,"f")!=null&&(n.index!==m(this,ke,"f")+1||n.carriage)){r.push(Ki(m(this,Ee,"f").subarray(0,m(this,ke,"f")-1))),P(this,Ee,m(this,Ee,"f").subarray(m(this,ke,"f"))),P(this,ke,null);continue}let o=m(this,ke,"f")!==null?n.preceding-1:n.preceding,i=Ki(m(this,Ee,"f").subarray(0,o));r.push(i),P(this,Ee,m(this,Ee,"f").subarray(n.index)),P(this,ke,null);}return r}flush(){return m(this,Ee,"f").length?this.decode(`
38
- `):[]}};Ee=new WeakMap,ke=new WeakMap;ut.NEWLINE_CHARS=new Set([`
39
- `,"\r"]);ut.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Ed(s,e){for(let n=e??0;n<s.length;n++){if(s[n]===10)return {preceding:n,index:n+1,carriage:false};if(s[n]===13)return {preceding:n,index:n+1,carriage:true}}return null}function Oc(s){for(let r=0;r<s.length-1;r++){if(s[r]===10&&s[r+1]===10||s[r]===13&&s[r+1]===13)return r+2;if(s[r]===13&&s[r+1]===10&&r+3<s.length&&s[r+2]===13&&s[r+3]===10)return r+4}return -1}var xo={off:0,error:200,warn:300,info:400,debug:500},Gi=(s,e,t)=>{if(s){if(yc(xo,s))return s;he(t).warn(`${e} was set to ${JSON.stringify(s)}, expected one of ${JSON.stringify(Object.keys(xo))}`);}};function dn(){}function wo(s,e,t){return !e||xo[s]>xo[t]?dn:e[s].bind(e)}var kd={error:dn,warn:dn,info:dn,debug:dn},Mc=new WeakMap;function he(s){let e=s.logger,t=s.logLevel??"off";if(!e)return kd;let r=Mc.get(e);if(r&&r[0]===t)return r[1];let n={error:wo("error",e,t),warn:wo("warn",e,t),info:wo("info",e,t),debug:wo("debug",e,t)};return Mc.set(e,[t,n]),n}var ft=s=>(s.options&&(s.options={...s.options},delete s.options.headers),s.headers&&(s.headers=Object.fromEntries((s.headers instanceof Headers?[...s.headers]:Object.entries(s.headers)).map(([e,t])=>[e,e.toLowerCase()==="x-api-key"||e.toLowerCase()==="authorization"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":t]))),"retryOfRequestLogID"in s&&(s.retryOfRequestLogID&&(s.retryOf=s.retryOfRequestLogID),delete s.retryOfRequestLogID),s);var hn,Ke=class s{constructor(e,t,r){this.iterator=e,hn.set(this,void 0),this.controller=t,P(this,hn,r);}static fromSSEResponse(e,t,r){let n=false,o=r?he(r):console;async function*i(){if(n)throw new E("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");n=true;let a=false;try{for await(let c of Td(e,t)){if(c.event==="completion")try{yield JSON.parse(c.data);}catch(u){throw o.error("Could not parse message into JSON:",c.data),o.error("From chunk:",c.raw),u}if(c.event==="message_start"||c.event==="message_delta"||c.event==="message_stop"||c.event==="content_block_start"||c.event==="content_block_delta"||c.event==="content_block_stop")try{yield JSON.parse(c.data);}catch(u){throw o.error("Could not parse message into JSON:",c.data),o.error("From chunk:",c.raw),u}if(c.event!=="ping"&&c.event==="error")throw new de(void 0,yo(c.data)??c.data,void 0,e.headers)}a=!0;}catch(c){if(ct(c))return;throw c}finally{a||t.abort();}}return new s(i,t,r)}static fromReadableStream(e,t,r){let n=false;async function*o(){let a=new ut,c=un(e);for await(let u of c)for(let _ of a.decode(u))yield _;for(let u of a.flush())yield u;}async function*i(){if(n)throw new E("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");n=true;let a=false;try{for await(let c of o())a||c&&(yield JSON.parse(c));a=!0;}catch(c){if(ct(c))return;throw c}finally{a||t.abort();}}return new s(i,t,r)}[(hn=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let e=[],t=[],r=this.iterator(),n=o=>({next:()=>{if(o.length===0){let i=r.next();e.push(i),t.push(i);}return o.shift()}});return [new s(()=>n(e),this.controller,m(this,hn,"f")),new s(()=>n(t),this.controller,m(this,hn,"f"))]}toReadableStream(){let e=this,t;return Vi({async start(){t=e[Symbol.asyncIterator]();},async pull(r){try{let{value:n,done:o}=await t.next();if(o)return r.close();let i=fn(JSON.stringify(n)+`
40
- `);r.enqueue(i);}catch(n){r.error(n);}},async cancel(){await t.return?.();}})}};async function*Td(s,e){if(!s.body)throw e.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new E("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new E("Attempted to iterate over a response with no body");let t=new Yi,r=new ut,n=un(s.body);for await(let o of Cd(n))for(let i of r.decode(o)){let a=t.decode(i);a&&(yield a);}for(let o of r.flush()){let i=t.decode(o);i&&(yield i);}}async function*Cd(s){let e=new Uint8Array;for await(let t of s){if(t==null)continue;let r=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?fn(t):t,n=new Uint8Array(e.length+r.length);n.set(e),n.set(r,e.length),e=n;let o;for(;(o=Oc(e))!==-1;)yield e.slice(0,o),e=e.slice(o);}e.length>0&&(yield e);}var Yi=class{constructor(){this.event=null,this.data=[],this.chunks=[];}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let o={event:this.event,data:this.data.join(`
41
- `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],o}if(this.chunks.push(e),e.startsWith(":"))return null;let[t,r,n]=Od(e,":");return n.startsWith(" ")&&(n=n.substring(1)),t==="event"?this.event=n:t==="data"&&this.data.push(n),null}};function Od(s,e){let t=s.indexOf(e);return t!==-1?[s.substring(0,t),e,s.substring(t+e.length)]:[s,"",""]}async function So(s,e){let{response:t,requestLogID:r,retryOfRequestLogID:n,startTime:o}=e,i=await(async()=>{if(e.options.stream)return he(s).debug("response",t.status,t.url,t.headers,t.body),e.options.__streamClass?e.options.__streamClass.fromSSEResponse(t,e.controller):Ke.fromSSEResponse(t,e.controller);if(t.status===204)return null;if(e.options.__binaryResponse)return t;let c=t.headers.get("content-type")?.split(";")[0]?.trim();if(c?.includes("application/json")||c?.endsWith("+json")){let h=await t.json();return zi(h,t)}return await t.text()})();return he(s).debug(`[${r}] response parsed`,ft({retryOfRequestLogID:n,url:t.url,status:t.status,body:i,durationMs:Date.now()-o})),i}function zi(s,e){return !s||typeof s!="object"||Array.isArray(s)?s:Object.defineProperty(s,"_request_id",{value:e.headers.get("request-id"),enumerable:false})}var mn,fr=class s extends Promise{constructor(e,t,r=So){super(n=>{n(null);}),this.responsePromise=t,this.parseResponse=r,mn.set(this,void 0),P(this,mn,e);}_thenUnwrap(e){return new s(m(this,mn,"f"),this.responsePromise,async(t,r)=>zi(e(await this.parseResponse(t,r),r),r.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return {data:e,response:t,request_id:t.headers.get("request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(m(this,mn,"f"),e))),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}};mn=new WeakMap;var Ao,Po=class{constructor(e,t,r,n){Ao.set(this,void 0),P(this,Ao,e),this.options=n,this.response=t,this.body=r;}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:false}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new E("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await m(this,Ao,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e;}async*[(Ao=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t;}},pn=class extends fr{constructor(e,t,r){super(e,t,async(n,o)=>new r(n,o.response,await So(n,o),o.options));}async*[Symbol.asyncIterator](){let e=await this;for await(let t of e)yield t;}},Oe=class extends Po{constructor(e,t,r,n){super(e,t,r,n),this.data=r.data||[],this.has_more=r.has_more||false,this.first_id=r.first_id||null,this.last_id=r.last_id||null;}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===false?false:super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.before_id){let t=this.first_id;return t?{...this.options,query:{..._o(this.options.query),before_id:t}}:null}let e=this.last_id;return e?{...this.options,query:{..._o(this.options.query),after_id:e}}:null}};var As=class extends Po{constructor(e,t,r,n){super(e,t,r,n),this.data=r.data||[],this.has_more=r.has_more||false,this.next_page=r.next_page||null;}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===false?false:super.hasNextPage()}nextPageRequestOptions(){let e=this.next_page;return e?{...this.options,query:{..._o(this.options.query),page:e}}:null}};var Zi=()=>{if(typeof File>"u"){let{process:s}=globalThis,e=typeof s?.versions?.node=="string"&&parseInt(s.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(e?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function dr(s,e,t){return Zi(),new File(s,e??"unknown_file",t)}function gn(s){return (typeof s=="object"&&s!==null&&("name"in s&&s.name&&String(s.name)||"url"in s&&s.url&&String(s.url)||"filename"in s&&s.filename&&String(s.filename)||"path"in s&&s.path&&String(s.path))||"").split(/[\\/]/).pop()||void 0}var ea=s=>s!=null&&typeof s=="object"&&typeof s[Symbol.asyncIterator]=="function";var Ps=async(s,e)=>({...s,body:await Fd(s.body,e)}),$c=new WeakMap;function $d(s){let e=typeof s=="function"?s:s.fetch,t=$c.get(e);if(t)return t;let r=(async()=>{try{let n="Response"in e?e.Response:(await e("data:,")).constructor,o=new FormData;return o.toString()!==await new n(o).text()}catch{return true}})();return $c.set(e,r),r}var Fd=async(s,e)=>{if(!await $d(e))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let t=new FormData;return await Promise.all(Object.entries(s||{}).map(([r,n])=>Qi(t,r,n))),t},Nd=s=>s instanceof Blob&&"name"in s;var Qi=async(s,e,t)=>{if(t!==void 0){if(t==null)throw new TypeError(`Received null for "${e}"; to pass null in FormData, you must use the string 'null'`);if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")s.append(e,String(t));else if(t instanceof Response){let r={},n=t.headers.get("Content-Type");n&&(r={type:n}),s.append(e,dr([await t.blob()],gn(t),r));}else if(ea(t))s.append(e,dr([await new Response(bo(t)).blob()],gn(t)));else if(Nd(t))s.append(e,dr([t],gn(t),{type:t.type}));else if(Array.isArray(t))await Promise.all(t.map(r=>Qi(s,e+"[]",r)));else if(typeof t=="object")await Promise.all(Object.entries(t).map(([r,n])=>Qi(s,`${e}[${r}]`,n)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${t} instead`)}};var Fc=s=>s!=null&&typeof s=="object"&&typeof s.size=="number"&&typeof s.type=="string"&&typeof s.text=="function"&&typeof s.slice=="function"&&typeof s.arrayBuffer=="function",Ld=s=>s!=null&&typeof s=="object"&&typeof s.name=="string"&&typeof s.lastModified=="number"&&Fc(s),Bd=s=>s!=null&&typeof s=="object"&&typeof s.url=="string"&&typeof s.blob=="function";async function vo(s,e,t){if(Zi(),s=await s,e||(e=gn(s)),Ld(s))return s instanceof File&&e==null&&t==null?s:dr([await s.arrayBuffer()],e??s.name,{type:s.type,lastModified:s.lastModified,...t});if(Bd(s)){let n=await s.blob();return e||(e=new URL(s.url).pathname.split(/[\\/]/).pop()),dr(await ta(n),e,t)}let r=await ta(s);if(!t?.type){let n=r.find(o=>typeof o=="object"&&"type"in o&&o.type);typeof n=="string"&&(t={...t,type:n});}return dr(r,e,t)}async function ta(s){let e=[];if(typeof s=="string"||ArrayBuffer.isView(s)||s instanceof ArrayBuffer)e.push(s);else if(Fc(s))e.push(s instanceof Blob?s:await s.arrayBuffer());else if(ea(s))for await(let t of s)e.push(...await ta(t));else {let t=s?.constructor?.name;throw new Error(`Unexpected data type: ${typeof s}${t?`; constructor: ${t}`:""}${jd(s)}`)}return e}function jd(s){return typeof s!="object"||s===null?"":`; props: [${Object.getOwnPropertyNames(s).map(t=>`"${t}"`).join(", ")}]`}var X=class{constructor(e){this._client=e;}};var Nc=Symbol.for("brand.privateNullableHeaders");function*Ud(s){if(!s)return;if(Nc in s){let{values:r,nulls:n}=s;yield*r.entries();for(let o of n)yield [o,null];return}let e=false,t;s instanceof Headers?t=s.entries():Xi(s)?t=s:(e=true,t=Object.entries(s??{}));for(let r of t){let n=r[0];if(typeof n!="string")throw new TypeError("expected header name to be a string");let o=Xi(r[1])?r[1]:[r[1]],i=false;for(let a of o)a!==void 0&&(e&&!i&&(i=true,yield [n,null]),yield [n,a]);}}var $=s=>{let e=new Headers,t=new Set;for(let r of s){let n=new Set;for(let[o,i]of Ud(r)){let a=o.toLowerCase();n.has(a)||(e.delete(o),n.add(a)),i===null?(e.delete(o),t.add(a)):(e.append(o,i),t.delete(a));}}return {[Nc]:true,values:e,nulls:t}};function Bc(s){return s.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var Lc=Object.freeze(Object.create(null)),qd=(s=Bc)=>function(t,...r){if(t.length===1)return t[0];let n=false,o=[],i=t.reduce((_,h,x)=>{/[?#]/.test(h)&&(n=true);let d=r[x],R=(n?encodeURIComponent:s)(""+d);return x!==r.length&&(d==null||typeof d=="object"&&d.toString===Object.getPrototypeOf(Object.getPrototypeOf(d.hasOwnProperty??Lc)??Lc)?.toString)&&(R=d+"",o.push({start:_.length+h.length,length:R.length,error:`Value of type ${Object.prototype.toString.call(d).slice(8,-1)} is not a valid path parameter`})),_+h+(x===r.length?"":R)},""),a=i.split(/[?#]/,1)[0],c=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,u;for(;(u=c.exec(a))!==null;)o.push({start:u.index,length:u[0].length,error:`Value "${u[0]}" can't be safely passed as a path parameter`});if(o.sort((_,h)=>_.start-h.start),o.length>0){let _=0,h=o.reduce((x,d)=>{let R=" ".repeat(d.start-_),A="^".repeat(d.length);return _=d.start+d.length,x+R+A},"");throw new E(`Path parameters result in path with invalid segments:
42
- ${o.map(x=>x.error).join(`
43
- `)}
44
- ${i}
45
- ${h}`)}return i},V=qd(Bc);var vs=class extends X{list(e={},t){let{betas:r,...n}=e??{};return this._client.getAPIList("/v1/files",Oe,{query:n,...t,headers:$([{"anthropic-beta":[...r??[],"files-api-2025-04-14"].toString()},t?.headers])})}delete(e,t={},r){let{betas:n}=t??{};return this._client.delete(V`/v1/files/${e}`,{...r,headers:$([{"anthropic-beta":[...n??[],"files-api-2025-04-14"].toString()},r?.headers])})}download(e,t={},r){let{betas:n}=t??{};return this._client.get(V`/v1/files/${e}/content`,{...r,headers:$([{"anthropic-beta":[...n??[],"files-api-2025-04-14"].toString(),Accept:"application/binary"},r?.headers]),__binaryResponse:true})}retrieveMetadata(e,t={},r){let{betas:n}=t??{};return this._client.get(V`/v1/files/${e}`,{...r,headers:$([{"anthropic-beta":[...n??[],"files-api-2025-04-14"].toString()},r?.headers])})}upload(e,t){let{betas:r,...n}=e;return this._client.post("/v1/files",Ps({body:n,...t,headers:$([{"anthropic-beta":[...r??[],"files-api-2025-04-14"].toString()},t?.headers])},this._client))}};var Is=class extends X{retrieve(e,t={},r){let{betas:n}=t??{};return this._client.get(V`/v1/models/${e}?beta=true`,{...r,headers:$([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},r?.headers])})}list(e={},t){let{betas:r,...n}=e??{};return this._client.getAPIList("/v1/models?beta=true",Oe,{query:n,...t,headers:$([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},t?.headers])})}};var Io={"claude-opus-4-20250514":8192,"claude-opus-4-0":8192,"claude-4-opus-20250514":8192,"anthropic.claude-opus-4-20250514-v1:0":8192,"claude-opus-4@20250514":8192,"claude-opus-4-1-20250805":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192};function ra(s,e,t){return !e||!("parse"in(e.output_format??{}))?{...s,content:s.content.map(r=>{if(r.type==="text"){let n=Object.defineProperty({...r},"parsed_output",{value:null,enumerable:false});return Object.defineProperty(n,"parsed",{get(){return t.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null},enumerable:false})}return r}),parsed_output:null}:sa(s,e,t)}function sa(s,e,t){let r=null,n=s.content.map(o=>{if(o.type==="text"){let i=Jd(e,o.text);r===null&&(r=i);let a=Object.defineProperty({...o},"parsed_output",{value:i,enumerable:false});return Object.defineProperty(a,"parsed",{get(){return t.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),i},enumerable:false})}return o});return {...s,content:n,parsed_output:r}}function Jd(s,e){if(s.output_format?.type!=="json_schema")return null;try{return "parse"in s.output_format?s.output_format.parse(e):JSON.parse(e)}catch(t){throw new E(`Failed to parse structured output: ${t}`)}}var Xd=s=>{let e=0,t=[];for(;e<s.length;){let r=s[e];if(r==="\\"){e++;continue}if(r==="{"){t.push({type:"brace",value:"{"}),e++;continue}if(r==="}"){t.push({type:"brace",value:"}"}),e++;continue}if(r==="["){t.push({type:"paren",value:"["}),e++;continue}if(r==="]"){t.push({type:"paren",value:"]"}),e++;continue}if(r===":"){t.push({type:"separator",value:":"}),e++;continue}if(r===","){t.push({type:"delimiter",value:","}),e++;continue}if(r==='"'){let a="",c=false;for(r=s[++e];r!=='"';){if(e===s.length){c=true;break}if(r==="\\"){if(e++,e===s.length){c=true;break}a+=r+s[e],r=s[++e];}else a+=r,r=s[++e];}r=s[++e],c||t.push({type:"string",value:a});continue}if(r&&/\s/.test(r)){e++;continue}let o=/[0-9]/;if(r&&o.test(r)||r==="-"||r==="."){let a="";for(r==="-"&&(a+=r,r=s[++e]);r&&o.test(r)||r===".";)a+=r,r=s[++e];t.push({type:"number",value:a});continue}let i=/[a-z]/i;if(r&&i.test(r)){let a="";for(;r&&i.test(r)&&e!==s.length;)a+=r,r=s[++e];if(a=="true"||a=="false"||a==="null")t.push({type:"name",value:a});else {e++;continue}continue}e++;}return t},Rs=s=>{if(s.length===0)return s;let e=s[s.length-1];switch(e.type){case "separator":return s=s.slice(0,s.length-1),Rs(s);case "number":let t=e.value[e.value.length-1];if(t==="."||t==="-")return s=s.slice(0,s.length-1),Rs(s);case "string":let r=s[s.length-2];if(r?.type==="delimiter")return s=s.slice(0,s.length-1),Rs(s);if(r?.type==="brace"&&r.value==="{")return s=s.slice(0,s.length-1),Rs(s);break;case "delimiter":return s=s.slice(0,s.length-1),Rs(s);}return s},Vd=s=>{let e=[];return s.map(t=>{t.type==="brace"&&(t.value==="{"?e.push("}"):e.splice(e.lastIndexOf("}"),1)),t.type==="paren"&&(t.value==="["?e.push("]"):e.splice(e.lastIndexOf("]"),1));}),e.length>0&&e.reverse().map(t=>{t==="}"?s.push({type:"brace",value:"}"}):t==="]"&&s.push({type:"paren",value:"]"});}),s},Kd=s=>{let e="";return s.map(t=>{t.type==="string"?e+='"'+t.value+'"':e+=t.value;}),e},Ro=s=>JSON.parse(Kd(Vd(Rs(Xd(s)))));var Me,Ft,Es,_n,Eo,yn,bn,ko,wn,dt,xn,To,Co,hr,Oo,Mo,Sn,na,jc,$o,oa,ia,aa,Dc,Uc="__json_buf";function qc(s){return s.type==="tool_use"||s.type==="server_tool_use"||s.type==="mcp_tool_use"}var Fo=class s{constructor(e,t){Me.add(this),this.messages=[],this.receivedMessages=[],Ft.set(this,void 0),Es.set(this,null),this.controller=new AbortController,_n.set(this,void 0),Eo.set(this,()=>{}),yn.set(this,()=>{}),bn.set(this,void 0),ko.set(this,()=>{}),wn.set(this,()=>{}),dt.set(this,{}),xn.set(this,false),To.set(this,false),Co.set(this,false),hr.set(this,false),Oo.set(this,void 0),Mo.set(this,void 0),Sn.set(this,void 0),$o.set(this,r=>{if(P(this,To,true),ct(r)&&(r=new pe),r instanceof pe)return P(this,Co,true),this._emit("abort",r);if(r instanceof E)return this._emit("error",r);if(r instanceof Error){let n=new E(r.message);return n.cause=r,this._emit("error",n)}return this._emit("error",new E(String(r)))}),P(this,_n,new Promise((r,n)=>{P(this,Eo,r,"f"),P(this,yn,n,"f");})),P(this,bn,new Promise((r,n)=>{P(this,ko,r,"f"),P(this,wn,n,"f");})),m(this,_n,"f").catch(()=>{}),m(this,bn,"f").catch(()=>{}),P(this,Es,e),P(this,Sn,t?.logger??console);}get response(){return m(this,Oo,"f")}get request_id(){return m(this,Mo,"f")}async withResponse(){P(this,hr,true);let e=await m(this,_n,"f");if(!e)throw new Error("Could not resolve a `Response` object");return {data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){let t=new s(null);return t._run(()=>t._fromReadableStream(e)),t}static createMessage(e,t,r,{logger:n}={}){let o=new s(t,{logger:n});for(let i of t.messages)o._addMessageParam(i);return P(o,Es,{...t,stream:true}),o._run(()=>o._createMessage(e,{...t,stream:true},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),o}_run(e){e().then(()=>{this._emitFinal(),this._emit("end");},m(this,$o,"f"));}_addMessageParam(e){this.messages.push(e);}_addMessage(e,t=true){this.receivedMessages.push(e),t&&this._emit("message",e);}async _createMessage(e,t,r){let n=r?.signal,o;n&&(n.aborted&&this.controller.abort(),o=this.controller.abort.bind(this.controller),n.addEventListener("abort",o));try{m(this,Me,"m",oa).call(this);let{response:i,data:a}=await e.create({...t,stream:!0},{...r,signal:this.controller.signal}).withResponse();this._connected(i);for await(let c of a)m(this,Me,"m",ia).call(this,c);if(a.controller.signal?.aborted)throw new pe;m(this,Me,"m",aa).call(this);}finally{n&&o&&n.removeEventListener("abort",o);}}_connected(e){this.ended||(P(this,Oo,e),P(this,Mo,e?.headers.get("request-id")),m(this,Eo,"f").call(this,e),this._emit("connect"));}get ended(){return m(this,xn,"f")}get errored(){return m(this,To,"f")}get aborted(){return m(this,Co,"f")}abort(){this.controller.abort();}on(e,t){return (m(this,dt,"f")[e]||(m(this,dt,"f")[e]=[])).push({listener:t}),this}off(e,t){let r=m(this,dt,"f")[e];if(!r)return this;let n=r.findIndex(o=>o.listener===t);return n>=0&&r.splice(n,1),this}once(e,t){return (m(this,dt,"f")[e]||(m(this,dt,"f")[e]=[])).push({listener:t,once:true}),this}emitted(e){return new Promise((t,r)=>{P(this,hr,true),e!=="error"&&this.once("error",r),this.once(e,t);})}async done(){P(this,hr,true),await m(this,bn,"f");}get currentMessage(){return m(this,Ft,"f")}async finalMessage(){return await this.done(),m(this,Me,"m",na).call(this)}async finalText(){return await this.done(),m(this,Me,"m",jc).call(this)}_emit(e,...t){if(m(this,xn,"f"))return;e==="end"&&(P(this,xn,true),m(this,ko,"f").call(this));let r=m(this,dt,"f")[e];if(r&&(m(this,dt,"f")[e]=r.filter(n=>!n.once),r.forEach(({listener:n})=>n(...t))),e==="abort"){let n=t[0];!m(this,hr,"f")&&!r?.length&&Promise.reject(n),m(this,yn,"f").call(this,n),m(this,wn,"f").call(this,n),this._emit("end");return}if(e==="error"){let n=t[0];!m(this,hr,"f")&&!r?.length&&Promise.reject(n),m(this,yn,"f").call(this,n),m(this,wn,"f").call(this,n),this._emit("end");}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",m(this,Me,"m",na).call(this));}async _fromReadableStream(e,t){let r=t?.signal,n;r&&(r.aborted&&this.controller.abort(),n=this.controller.abort.bind(this.controller),r.addEventListener("abort",n));try{m(this,Me,"m",oa).call(this),this._connected(null);let o=Ke.fromReadableStream(e,this.controller);for await(let i of o)m(this,Me,"m",ia).call(this,i);if(o.controller.signal?.aborted)throw new pe;m(this,Me,"m",aa).call(this);}finally{r&&n&&r.removeEventListener("abort",n);}}[(Ft=new WeakMap,Es=new WeakMap,_n=new WeakMap,Eo=new WeakMap,yn=new WeakMap,bn=new WeakMap,ko=new WeakMap,wn=new WeakMap,dt=new WeakMap,xn=new WeakMap,To=new WeakMap,Co=new WeakMap,hr=new WeakMap,Oo=new WeakMap,Mo=new WeakMap,Sn=new WeakMap,$o=new WeakMap,Me=new WeakSet,na=function(){if(this.receivedMessages.length===0)throw new E("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},jc=function(){if(this.receivedMessages.length===0)throw new E("stream ended without producing a Message with role=assistant");let t=this.receivedMessages.at(-1).content.filter(r=>r.type==="text").map(r=>r.text);if(t.length===0)throw new E("stream ended without producing a content block with type=text");return t.join(" ")},oa=function(){this.ended||P(this,Ft,void 0);},ia=function(t){if(this.ended)return;let r=m(this,Me,"m",Dc).call(this,t);switch(this._emit("streamEvent",t,r),t.type){case "content_block_delta":{let n=r.content.at(-1);switch(t.delta.type){case "text_delta":{n.type==="text"&&this._emit("text",t.delta.text,n.text||"");break}case "citations_delta":{n.type==="text"&&this._emit("citation",t.delta.citation,n.citations??[]);break}case "input_json_delta":{qc(n)&&n.input&&this._emit("inputJson",t.delta.partial_json,n.input);break}case "thinking_delta":{n.type==="thinking"&&this._emit("thinking",t.delta.thinking,n.thinking);break}case "signature_delta":{n.type==="thinking"&&this._emit("signature",n.signature);break}default:t.delta;}break}case "message_stop":{this._addMessageParam(r),this._addMessage(ra(r,m(this,Es,"f"),{logger:m(this,Sn,"f")}),true);break}case "content_block_stop":{this._emit("contentBlock",r.content.at(-1));break}case "message_start":{P(this,Ft,r);break}}},aa=function(){if(this.ended)throw new E("stream has ended, this shouldn't happen");let t=m(this,Ft,"f");if(!t)throw new E("request ended without sending any chunks");return P(this,Ft,void 0),ra(t,m(this,Es,"f"),{logger:m(this,Sn,"f")})},Dc=function(t){let r=m(this,Ft,"f");if(t.type==="message_start"){if(r)throw new E(`Unexpected event order, got ${t.type} before receiving "message_stop"`);return t.message}if(!r)throw new E(`Unexpected event order, got ${t.type} before "message_start"`);switch(t.type){case "message_stop":return r;case "message_delta":return r.container=t.delta.container,r.stop_reason=t.delta.stop_reason,r.stop_sequence=t.delta.stop_sequence,r.usage.output_tokens=t.usage.output_tokens,r.context_management=t.context_management,t.usage.input_tokens!=null&&(r.usage.input_tokens=t.usage.input_tokens),t.usage.cache_creation_input_tokens!=null&&(r.usage.cache_creation_input_tokens=t.usage.cache_creation_input_tokens),t.usage.cache_read_input_tokens!=null&&(r.usage.cache_read_input_tokens=t.usage.cache_read_input_tokens),t.usage.server_tool_use!=null&&(r.usage.server_tool_use=t.usage.server_tool_use),r;case "content_block_start":return r.content.push(t.content_block),r;case "content_block_delta":{let n=r.content.at(t.index);switch(t.delta.type){case "text_delta":{n?.type==="text"&&(r.content[t.index]={...n,text:(n.text||"")+t.delta.text});break}case "citations_delta":{n?.type==="text"&&(r.content[t.index]={...n,citations:[...n.citations??[],t.delta.citation]});break}case "input_json_delta":{if(n&&qc(n)){let o=n[Uc]||"";o+=t.delta.partial_json;let i={...n};if(Object.defineProperty(i,Uc,{value:o,enumerable:false,writable:true}),o)try{i.input=Ro(o);}catch(a){let c=new E(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${a}. JSON: ${o}`);m(this,$o,"f").call(this,c);}r.content[t.index]=i;}break}case "thinking_delta":{n?.type==="thinking"&&(r.content[t.index]={...n,thinking:n.thinking+t.delta.thinking});break}case "signature_delta":{n?.type==="thinking"&&(r.content[t.index]={...n,signature:t.delta.signature});break}default:t.delta;}return r}case "content_block_stop":return r}},Symbol.asyncIterator)](){let e=[],t=[],r=false;return this.on("streamEvent",n=>{let o=t.shift();o?o.resolve(n):e.push(n);}),this.on("end",()=>{r=true;for(let n of t)n.resolve(void 0);t.length=0;}),this.on("abort",n=>{r=true;for(let o of t)o.reject(n);t.length=0;}),this.on("error",n=>{r=true;for(let o of t)o.reject(n);t.length=0;}),{next:async()=>e.length?{value:e.shift(),done:false}:r?{value:void 0,done:true}:new Promise((o,i)=>t.push({resolve:o,reject:i})).then(o=>o?{value:o,done:false}:{value:void 0,done:true}),return:async()=>(this.abort(),{value:void 0,done:true})}}toReadableStream(){return new Ke(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};var Wc=`You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:
46
- 1. Task Overview
47
- The user's core request and success criteria
48
- Any clarifications or constraints they specified
49
- 2. Current State
50
- What has been completed so far
51
- Files created, modified, or analyzed (with paths if relevant)
52
- Key outputs or artifacts produced
53
- 3. Important Discoveries
54
- Technical constraints or requirements uncovered
55
- Decisions made and their rationale
56
- Errors encountered and how they were resolved
57
- What approaches were tried that didn't work (and why)
58
- 4. Next Steps
59
- Specific actions needed to complete the task
60
- Any blockers or open questions to resolve
61
- Priority order if multiple steps remain
62
- 5. Context to Preserve
63
- User preferences or style requirements
64
- Domain-specific details that aren't obvious
65
- Any promises made to the user
66
- Be concise but complete\u2014err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.
67
- Wrap your summary in <summary></summary> tags.`;var An,ks,mr,le,Pn,Te,ht,Nt,vn,Hc,la;function Jc(){let s,e;return {promise:new Promise((r,n)=>{s=r,e=n;}),resolve:s,reject:e}}var Ts=class{constructor(e,t,r){An.add(this),this.client=e,ks.set(this,false),mr.set(this,false),le.set(this,void 0),Pn.set(this,void 0),Te.set(this,void 0),ht.set(this,void 0),Nt.set(this,void 0),vn.set(this,0),P(this,le,{params:{...t,messages:structuredClone(t.messages)}}),P(this,Pn,{...r,headers:$([{"x-stainless-helper":"BetaToolRunner"},r?.headers])}),P(this,Nt,Jc());}async*[(ks=new WeakMap,mr=new WeakMap,le=new WeakMap,Pn=new WeakMap,Te=new WeakMap,ht=new WeakMap,Nt=new WeakMap,vn=new WeakMap,An=new WeakSet,Hc=async function(){let t=m(this,le,"f").params.compactionControl;if(!t||!t.enabled)return false;let r=0;if(m(this,Te,"f")!==void 0)try{let u=await m(this,Te,"f");r=u.usage.input_tokens+(u.usage.cache_creation_input_tokens??0)+(u.usage.cache_read_input_tokens??0)+u.usage.output_tokens;}catch{return false}let n=t.contextTokenThreshold??1e5;if(r<n)return false;let o=t.model??m(this,le,"f").params.model,i=t.summaryPrompt??Wc,a=m(this,le,"f").params.messages;if(a[a.length-1].role==="assistant"){let u=a[a.length-1];if(Array.isArray(u.content)){let _=u.content.filter(h=>h.type!=="tool_use");_.length===0?a.pop():u.content=_;}}let c=await this.client.beta.messages.create({model:o,messages:[...a,{role:"user",content:[{type:"text",text:i}]}],max_tokens:m(this,le,"f").params.max_tokens},{headers:{"x-stainless-helper":"compaction"}});if(c.content[0]?.type!=="text")throw new E("Expected text response for compaction");return m(this,le,"f").params.messages=[{role:"user",content:c.content}],true},Symbol.asyncIterator)](){var e;if(m(this,ks,"f"))throw new E("Cannot iterate over a consumed stream");P(this,ks,true),P(this,mr,true),P(this,ht,void 0);try{for(;;){let t;try{if(m(this,le,"f").params.max_iterations&&m(this,vn,"f")>=m(this,le,"f").params.max_iterations)break;P(this,mr,!1,"f"),P(this,ht,void 0,"f"),P(this,vn,(e=m(this,vn,"f"),e++,e),"f"),P(this,Te,void 0,"f");let{max_iterations:r,compactionControl:n,...o}=m(this,le,"f").params;if(o.stream?(t=this.client.beta.messages.stream({...o},m(this,Pn,"f")),P(this,Te,t.finalMessage(),"f"),m(this,Te,"f").catch(()=>{}),yield t):(P(this,Te,this.client.beta.messages.create({...o,stream:!1},m(this,Pn,"f")),"f"),yield m(this,Te,"f")),!await m(this,An,"m",Hc).call(this)){if(!m(this,mr,"f")){let{role:c,content:u}=await m(this,Te,"f");m(this,le,"f").params.messages.push({role:c,content:u});}let a=await m(this,An,"m",la).call(this,m(this,le,"f").params.messages.at(-1));if(a)m(this,le,"f").params.messages.push(a);else if(!m(this,mr,"f"))break}}finally{t&&t.abort();}}if(!m(this,Te,"f"))throw new E("ToolRunner concluded without a message from the server");m(this,Nt,"f").resolve(await m(this,Te,"f"));}catch(t){throw P(this,ks,false),m(this,Nt,"f").promise.catch(()=>{}),m(this,Nt,"f").reject(t),P(this,Nt,Jc()),t}}setMessagesParams(e){typeof e=="function"?m(this,le,"f").params=e(m(this,le,"f").params):m(this,le,"f").params=e,P(this,mr,true),P(this,ht,void 0);}async generateToolResponse(){let e=await m(this,Te,"f")??this.params.messages.at(-1);return e?m(this,An,"m",la).call(this,e):null}done(){return m(this,Nt,"f").promise}async runUntilDone(){if(!m(this,ks,"f"))for await(let e of this);return this.done()}get params(){return m(this,le,"f").params}pushMessages(...e){this.setMessagesParams(t=>({...t,messages:[...t.messages,...e]}));}then(e,t){return this.runUntilDone().then(e,t)}};la=async function(e){return m(this,ht,"f")!==void 0?m(this,ht,"f"):(P(this,ht,Yd(m(this,le,"f").params,e)),m(this,ht,"f"))};async function Yd(s,e=s.messages.at(-1)){if(!e||e.role!=="assistant"||!e.content||typeof e.content=="string")return null;let t=e.content.filter(n=>n.type==="tool_use");return t.length===0?null:{role:"user",content:await Promise.all(t.map(async n=>{let o=s.tools.find(i=>("name"in i?i.name:i.mcp_server_name)===n.name);if(!o||!("run"in o))return {type:"tool_result",tool_use_id:n.id,content:`Error: Tool '${n.name}' not found`,is_error:true};try{let i=n.input;"parse"in o&&o.parse&&(i=o.parse(i));let a=await o.run(i);return {type:"tool_result",tool_use_id:n.id,content:a}}catch(i){return {type:"tool_result",tool_use_id:n.id,content:`Error: ${i instanceof Error?i.message:String(i)}`,is_error:true}}}))}}var Cs=class s{constructor(e,t){this.iterator=e,this.controller=t;}async*decoder(){let e=new ut;for await(let t of this.iterator)for(let r of e.decode(t))yield JSON.parse(r);for(let t of e.flush())yield JSON.parse(t);}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(e,t){if(!e.body)throw t.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new E("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new E("Attempted to iterate over a response with no body");return new s(un(e.body),t)}};var Os=class extends X{create(e,t){let{betas:r,...n}=e;return this._client.post("/v1/messages/batches?beta=true",{body:n,...t,headers:$([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString()},t?.headers])})}retrieve(e,t={},r){let{betas:n}=t??{};return this._client.get(V`/v1/messages/batches/${e}?beta=true`,{...r,headers:$([{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString()},r?.headers])})}list(e={},t){let{betas:r,...n}=e??{};return this._client.getAPIList("/v1/messages/batches?beta=true",Oe,{query:n,...t,headers:$([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString()},t?.headers])})}delete(e,t={},r){let{betas:n}=t??{};return this._client.delete(V`/v1/messages/batches/${e}?beta=true`,{...r,headers:$([{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString()},r?.headers])})}cancel(e,t={},r){let{betas:n}=t??{};return this._client.post(V`/v1/messages/batches/${e}/cancel?beta=true`,{...r,headers:$([{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString()},r?.headers])})}async results(e,t={},r){let n=await this.retrieve(e);if(!n.results_url)throw new E(`No batch \`results_url\`; Has it finished processing? ${n.processing_status} - ${n.id}`);let{betas:o}=t??{};return this._client.get(n.results_url,{...r,headers:$([{"anthropic-beta":[...o??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary"},r?.headers]),stream:true,__binaryResponse:true})._thenUnwrap((i,a)=>Cs.fromResponse(a.response,a.controller))}};var Xc={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026"},Lt=class extends X{constructor(){super(...arguments),this.batches=new Os(this._client);}create(e,t){let{betas:r,...n}=e;n.model in Xc&&console.warn(`The model '${n.model}' is deprecated and will reach end-of-life on ${Xc[n.model]}
68
- Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);let o=this._client._options.timeout;if(!n.stream&&o==null){let i=Io[n.model]??void 0;o=this._client.calculateNonstreamingTimeout(n.max_tokens,i);}return this._client.post("/v1/messages?beta=true",{body:n,timeout:o??6e5,...t,headers:$([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},t?.headers]),stream:e.stream??false})}parse(e,t){return t={...t,headers:$([{"anthropic-beta":[...e.betas??[],"structured-outputs-2025-11-13"].toString()},t?.headers])},this.create(e,t).then(r=>sa(r,e,{logger:this._client.logger??console}))}stream(e,t){return Fo.createMessage(this,e,t)}countTokens(e,t){let{betas:r,...n}=e;return this._client.post("/v1/messages/count_tokens?beta=true",{body:n,...t,headers:$([{"anthropic-beta":[...r??[],"token-counting-2024-11-01"].toString()},t?.headers])})}toolRunner(e,t){return new Ts(this._client,e,t)}};Lt.Batches=Os;Lt.BetaToolRunner=Ts;var Ms=class extends X{create(e,t={},r){let{betas:n,...o}=t??{};return this._client.post(V`/v1/skills/${e}/versions?beta=true`,Ps({body:o,...r,headers:$([{"anthropic-beta":[...n??[],"skills-2025-10-02"].toString()},r?.headers])},this._client))}retrieve(e,t,r){let{skill_id:n,betas:o}=t;return this._client.get(V`/v1/skills/${n}/versions/${e}?beta=true`,{...r,headers:$([{"anthropic-beta":[...o??[],"skills-2025-10-02"].toString()},r?.headers])})}list(e,t={},r){let{betas:n,...o}=t??{};return this._client.getAPIList(V`/v1/skills/${e}/versions?beta=true`,As,{query:o,...r,headers:$([{"anthropic-beta":[...n??[],"skills-2025-10-02"].toString()},r?.headers])})}delete(e,t,r){let{skill_id:n,betas:o}=t;return this._client.delete(V`/v1/skills/${n}/versions/${e}?beta=true`,{...r,headers:$([{"anthropic-beta":[...o??[],"skills-2025-10-02"].toString()},r?.headers])})}};var pr=class extends X{constructor(){super(...arguments),this.versions=new Ms(this._client);}create(e={},t){let{betas:r,...n}=e??{};return this._client.post("/v1/skills?beta=true",Ps({body:n,...t,headers:$([{"anthropic-beta":[...r??[],"skills-2025-10-02"].toString()},t?.headers])},this._client))}retrieve(e,t={},r){let{betas:n}=t??{};return this._client.get(V`/v1/skills/${e}?beta=true`,{...r,headers:$([{"anthropic-beta":[...n??[],"skills-2025-10-02"].toString()},r?.headers])})}list(e={},t){let{betas:r,...n}=e??{};return this._client.getAPIList("/v1/skills?beta=true",As,{query:n,...t,headers:$([{"anthropic-beta":[...r??[],"skills-2025-10-02"].toString()},t?.headers])})}delete(e,t={},r){let{betas:n}=t??{};return this._client.delete(V`/v1/skills/${e}?beta=true`,{...r,headers:$([{"anthropic-beta":[...n??[],"skills-2025-10-02"].toString()},r?.headers])})}};pr.Versions=Ms;var je=class extends X{constructor(){super(...arguments),this.models=new Is(this._client),this.messages=new Lt(this._client),this.files=new vs(this._client),this.skills=new pr(this._client);}};je.Models=Is;je.Messages=Lt;je.Files=vs;je.Skills=pr;var gr=class extends X{create(e,t){let{betas:r,...n}=e;return this._client.post("/v1/complete",{body:n,timeout:this._client._options.timeout??6e5,...t,headers:$([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},t?.headers]),stream:e.stream??false})}};var $e,Bt,In,No,Rn,En,Lo,kn,mt,Tn,Bo,jo,_r,Do,Uo,ca,Vc,ua,fa,da,ha,Kc,Gc="__json_buf";function Yc(s){return s.type==="tool_use"||s.type==="server_tool_use"}var qo=class s{constructor(){$e.add(this),this.messages=[],this.receivedMessages=[],Bt.set(this,void 0),this.controller=new AbortController,In.set(this,void 0),No.set(this,()=>{}),Rn.set(this,()=>{}),En.set(this,void 0),Lo.set(this,()=>{}),kn.set(this,()=>{}),mt.set(this,{}),Tn.set(this,false),Bo.set(this,false),jo.set(this,false),_r.set(this,false),Do.set(this,void 0),Uo.set(this,void 0),ua.set(this,e=>{if(P(this,Bo,true),ct(e)&&(e=new pe),e instanceof pe)return P(this,jo,true),this._emit("abort",e);if(e instanceof E)return this._emit("error",e);if(e instanceof Error){let t=new E(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new E(String(e)))}),P(this,In,new Promise((e,t)=>{P(this,No,e,"f"),P(this,Rn,t,"f");})),P(this,En,new Promise((e,t)=>{P(this,Lo,e,"f"),P(this,kn,t,"f");})),m(this,In,"f").catch(()=>{}),m(this,En,"f").catch(()=>{});}get response(){return m(this,Do,"f")}get request_id(){return m(this,Uo,"f")}async withResponse(){P(this,_r,true);let e=await m(this,In,"f");if(!e)throw new Error("Could not resolve a `Response` object");return {data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){let t=new s;return t._run(()=>t._fromReadableStream(e)),t}static createMessage(e,t,r){let n=new s;for(let o of t.messages)n._addMessageParam(o);return n._run(()=>n._createMessage(e,{...t,stream:true},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),n}_run(e){e().then(()=>{this._emitFinal(),this._emit("end");},m(this,ua,"f"));}_addMessageParam(e){this.messages.push(e);}_addMessage(e,t=true){this.receivedMessages.push(e),t&&this._emit("message",e);}async _createMessage(e,t,r){let n=r?.signal,o;n&&(n.aborted&&this.controller.abort(),o=this.controller.abort.bind(this.controller),n.addEventListener("abort",o));try{m(this,$e,"m",fa).call(this);let{response:i,data:a}=await e.create({...t,stream:!0},{...r,signal:this.controller.signal}).withResponse();this._connected(i);for await(let c of a)m(this,$e,"m",da).call(this,c);if(a.controller.signal?.aborted)throw new pe;m(this,$e,"m",ha).call(this);}finally{n&&o&&n.removeEventListener("abort",o);}}_connected(e){this.ended||(P(this,Do,e),P(this,Uo,e?.headers.get("request-id")),m(this,No,"f").call(this,e),this._emit("connect"));}get ended(){return m(this,Tn,"f")}get errored(){return m(this,Bo,"f")}get aborted(){return m(this,jo,"f")}abort(){this.controller.abort();}on(e,t){return (m(this,mt,"f")[e]||(m(this,mt,"f")[e]=[])).push({listener:t}),this}off(e,t){let r=m(this,mt,"f")[e];if(!r)return this;let n=r.findIndex(o=>o.listener===t);return n>=0&&r.splice(n,1),this}once(e,t){return (m(this,mt,"f")[e]||(m(this,mt,"f")[e]=[])).push({listener:t,once:true}),this}emitted(e){return new Promise((t,r)=>{P(this,_r,true),e!=="error"&&this.once("error",r),this.once(e,t);})}async done(){P(this,_r,true),await m(this,En,"f");}get currentMessage(){return m(this,Bt,"f")}async finalMessage(){return await this.done(),m(this,$e,"m",ca).call(this)}async finalText(){return await this.done(),m(this,$e,"m",Vc).call(this)}_emit(e,...t){if(m(this,Tn,"f"))return;e==="end"&&(P(this,Tn,true),m(this,Lo,"f").call(this));let r=m(this,mt,"f")[e];if(r&&(m(this,mt,"f")[e]=r.filter(n=>!n.once),r.forEach(({listener:n})=>n(...t))),e==="abort"){let n=t[0];!m(this,_r,"f")&&!r?.length&&Promise.reject(n),m(this,Rn,"f").call(this,n),m(this,kn,"f").call(this,n),this._emit("end");return}if(e==="error"){let n=t[0];!m(this,_r,"f")&&!r?.length&&Promise.reject(n),m(this,Rn,"f").call(this,n),m(this,kn,"f").call(this,n),this._emit("end");}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",m(this,$e,"m",ca).call(this));}async _fromReadableStream(e,t){let r=t?.signal,n;r&&(r.aborted&&this.controller.abort(),n=this.controller.abort.bind(this.controller),r.addEventListener("abort",n));try{m(this,$e,"m",fa).call(this),this._connected(null);let o=Ke.fromReadableStream(e,this.controller);for await(let i of o)m(this,$e,"m",da).call(this,i);if(o.controller.signal?.aborted)throw new pe;m(this,$e,"m",ha).call(this);}finally{r&&n&&r.removeEventListener("abort",n);}}[(Bt=new WeakMap,In=new WeakMap,No=new WeakMap,Rn=new WeakMap,En=new WeakMap,Lo=new WeakMap,kn=new WeakMap,mt=new WeakMap,Tn=new WeakMap,Bo=new WeakMap,jo=new WeakMap,_r=new WeakMap,Do=new WeakMap,Uo=new WeakMap,ua=new WeakMap,$e=new WeakSet,ca=function(){if(this.receivedMessages.length===0)throw new E("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},Vc=function(){if(this.receivedMessages.length===0)throw new E("stream ended without producing a Message with role=assistant");let t=this.receivedMessages.at(-1).content.filter(r=>r.type==="text").map(r=>r.text);if(t.length===0)throw new E("stream ended without producing a content block with type=text");return t.join(" ")},fa=function(){this.ended||P(this,Bt,void 0);},da=function(t){if(this.ended)return;let r=m(this,$e,"m",Kc).call(this,t);switch(this._emit("streamEvent",t,r),t.type){case "content_block_delta":{let n=r.content.at(-1);switch(t.delta.type){case "text_delta":{n.type==="text"&&this._emit("text",t.delta.text,n.text||"");break}case "citations_delta":{n.type==="text"&&this._emit("citation",t.delta.citation,n.citations??[]);break}case "input_json_delta":{Yc(n)&&n.input&&this._emit("inputJson",t.delta.partial_json,n.input);break}case "thinking_delta":{n.type==="thinking"&&this._emit("thinking",t.delta.thinking,n.thinking);break}case "signature_delta":{n.type==="thinking"&&this._emit("signature",n.signature);break}default:t.delta;}break}case "message_stop":{this._addMessageParam(r),this._addMessage(r,true);break}case "content_block_stop":{this._emit("contentBlock",r.content.at(-1));break}case "message_start":{P(this,Bt,r);break}}},ha=function(){if(this.ended)throw new E("stream has ended, this shouldn't happen");let t=m(this,Bt,"f");if(!t)throw new E("request ended without sending any chunks");return P(this,Bt,void 0),t},Kc=function(t){let r=m(this,Bt,"f");if(t.type==="message_start"){if(r)throw new E(`Unexpected event order, got ${t.type} before receiving "message_stop"`);return t.message}if(!r)throw new E(`Unexpected event order, got ${t.type} before "message_start"`);switch(t.type){case "message_stop":return r;case "message_delta":return r.stop_reason=t.delta.stop_reason,r.stop_sequence=t.delta.stop_sequence,r.usage.output_tokens=t.usage.output_tokens,t.usage.input_tokens!=null&&(r.usage.input_tokens=t.usage.input_tokens),t.usage.cache_creation_input_tokens!=null&&(r.usage.cache_creation_input_tokens=t.usage.cache_creation_input_tokens),t.usage.cache_read_input_tokens!=null&&(r.usage.cache_read_input_tokens=t.usage.cache_read_input_tokens),t.usage.server_tool_use!=null&&(r.usage.server_tool_use=t.usage.server_tool_use),r;case "content_block_start":return r.content.push({...t.content_block}),r;case "content_block_delta":{let n=r.content.at(t.index);switch(t.delta.type){case "text_delta":{n?.type==="text"&&(r.content[t.index]={...n,text:(n.text||"")+t.delta.text});break}case "citations_delta":{n?.type==="text"&&(r.content[t.index]={...n,citations:[...n.citations??[],t.delta.citation]});break}case "input_json_delta":{if(n&&Yc(n)){let o=n[Gc]||"";o+=t.delta.partial_json;let i={...n};Object.defineProperty(i,Gc,{value:o,enumerable:false,writable:true}),o&&(i.input=Ro(o)),r.content[t.index]=i;}break}case "thinking_delta":{n?.type==="thinking"&&(r.content[t.index]={...n,thinking:n.thinking+t.delta.thinking});break}case "signature_delta":{n?.type==="thinking"&&(r.content[t.index]={...n,signature:t.delta.signature});break}default:t.delta;}return r}case "content_block_stop":return r}},Symbol.asyncIterator)](){let e=[],t=[],r=false;return this.on("streamEvent",n=>{let o=t.shift();o?o.resolve(n):e.push(n);}),this.on("end",()=>{r=true;for(let n of t)n.resolve(void 0);t.length=0;}),this.on("abort",n=>{r=true;for(let o of t)o.reject(n);t.length=0;}),this.on("error",n=>{r=true;for(let o of t)o.reject(n);t.length=0;}),{next:async()=>e.length?{value:e.shift(),done:false}:r?{value:void 0,done:true}:new Promise((o,i)=>t.push({resolve:o,reject:i})).then(o=>o?{value:o,done:false}:{value:void 0,done:true}),return:async()=>(this.abort(),{value:void 0,done:true})}}toReadableStream(){return new Ke(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};var $s=class extends X{create(e,t){return this._client.post("/v1/messages/batches",{body:e,...t})}retrieve(e,t){return this._client.get(V`/v1/messages/batches/${e}`,t)}list(e={},t){return this._client.getAPIList("/v1/messages/batches",Oe,{query:e,...t})}delete(e,t){return this._client.delete(V`/v1/messages/batches/${e}`,t)}cancel(e,t){return this._client.post(V`/v1/messages/batches/${e}/cancel`,t)}async results(e,t){let r=await this.retrieve(e);if(!r.results_url)throw new E(`No batch \`results_url\`; Has it finished processing? ${r.processing_status} - ${r.id}`);return this._client.get(r.results_url,{...t,headers:$([{Accept:"application/binary"},t?.headers]),stream:true,__binaryResponse:true})._thenUnwrap((n,o)=>Cs.fromResponse(o.response,o.controller))}};var jt=class extends X{constructor(){super(...arguments),this.batches=new $s(this._client);}create(e,t){e.model in zc&&console.warn(`The model '${e.model}' is deprecated and will reach end-of-life on ${zc[e.model]}
69
- Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);let r=this._client._options.timeout;if(!e.stream&&r==null){let n=Io[e.model]??void 0;r=this._client.calculateNonstreamingTimeout(e.max_tokens,n);}return this._client.post("/v1/messages",{body:e,timeout:r??6e5,...t,stream:e.stream??false})}stream(e,t){return qo.createMessage(this,e,t)}countTokens(e,t){return this._client.post("/v1/messages/count_tokens",{body:e,...t})}},zc={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026"};jt.Batches=$s;var yr=class extends X{retrieve(e,t={},r){let{betas:n}=t??{};return this._client.get(V`/v1/models/${e}`,{...r,headers:$([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},r?.headers])})}list(e={},t){let{betas:r,...n}=e??{};return this._client.getAPIList("/v1/models",Oe,{query:n,...t,headers:$([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},t?.headers])})}};var Cn=s=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[s]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(s)?.trim()};var ma,pa,Wo,Qc,Zc="\\n\\nHuman:",eu="\\n\\nAssistant:",G=class{constructor({baseURL:e=Cn("ANTHROPIC_BASE_URL"),apiKey:t=Cn("ANTHROPIC_API_KEY")??null,authToken:r=Cn("ANTHROPIC_AUTH_TOKEN")??null,...n}={}){ma.add(this),Wo.set(this,void 0);let o={apiKey:t,authToken:r,...n,baseURL:e||"https://api.anthropic.com"};if(!o.dangerouslyAllowBrowser&&Pc())throw new E(`It looks like you're running in a browser-like environment.
70
-
71
- This is disabled by default, as it risks exposing your secret API credentials to attackers.
72
- If you understand the risks and have appropriate mitigations in place,
73
- you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
74
-
75
- new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
76
- `);this.baseURL=o.baseURL,this.timeout=o.timeout??pa.DEFAULT_TIMEOUT,this.logger=o.logger??console;let i="warn";this.logLevel=i,this.logLevel=Gi(o.logLevel,"ClientOptions.logLevel",this)??Gi(Cn("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",this)??i,this.fetchOptions=o.fetchOptions,this.maxRetries=o.maxRetries??2,this.fetch=o.fetch??Ic(),P(this,Wo,Ec),this._options=o,this.apiKey=typeof t=="string"?t:null,this.authToken=r;}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,authToken:this.authToken,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(!(e.get("x-api-key")||e.get("authorization"))&&!(this.apiKey&&e.get("x-api-key"))&&!t.has("x-api-key")&&!(this.authToken&&e.get("authorization"))&&!t.has("authorization"))throw new Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}async authHeaders(e){return $([await this.apiKeyAuth(e),await this.bearerAuth(e)])}async apiKeyAuth(e){if(this.apiKey!=null)return $([{"X-Api-Key":this.apiKey}])}async bearerAuth(e){if(this.authToken!=null)return $([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return Object.entries(e).filter(([t,r])=>typeof r<"u").map(([t,r])=>{if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")return `${encodeURIComponent(t)}=${encodeURIComponent(r)}`;if(r===null)return `${encodeURIComponent(t)}=`;throw new E(`Cannot stringify type ${typeof r}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}getUserAgent(){return `${this.constructor.name}/JS ${$t}`}defaultIdempotencyKey(){return `stainless-node-retry-${Hi()}`}makeStatusError(e,t,r,n){return de.generate(e,t,r,n)}buildURL(e,t,r){let n=!m(this,ma,"m",Qc).call(this)&&r||this.baseURL,o=gc(e)?new URL(e):new URL(n+(n.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),i=this.defaultQuery();return _c(i)||(t={...i,...t}),typeof t=="object"&&t&&!Array.isArray(t)&&(o.search=this.stringifyQuery(t)),o.toString()}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new E("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details");return 600*1e3}async prepareOptions(e){}async prepareRequest(e,{url:t,options:r}){}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,r){return this.request(Promise.resolve(r).then(n=>({method:e,path:t,...n})))}request(e,t=null){return new fr(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,r){let n=await e,o=n.maxRetries??this.maxRetries;t==null&&(t=o),await this.prepareOptions(n);let{req:i,url:a,timeout:c}=await this.buildRequest(n,{retryCount:o-t});await this.prepareRequest(i,{url:a,options:n});let u="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),_=r===void 0?"":`, retryOf: ${r}`,h=Date.now();if(he(this).debug(`[${u}] sending request`,ft({retryOfRequestLogID:r,method:n.method,url:a,options:n,headers:i.headers})),n.signal?.aborted)throw new pe;let x=new AbortController,d=await this.fetchWithTimeout(a,i,c,x).catch(cn),R=Date.now();if(d instanceof globalThis.Error){let T=`retrying, ${t} attempts remaining`;if(n.signal?.aborted)throw new pe;let b=ct(d)||/timed? ?out/i.test(String(d)+("cause"in d?String(d.cause):""));if(t)return he(this).info(`[${u}] connection ${b?"timed out":"failed"} - ${T}`),he(this).debug(`[${u}] connection ${b?"timed out":"failed"} (${T})`,ft({retryOfRequestLogID:r,url:a,durationMs:R-h,message:d.message})),this.retryRequest(n,t,r??u);throw he(this).info(`[${u}] connection ${b?"timed out":"failed"} - error; no more retries left`),he(this).debug(`[${u}] connection ${b?"timed out":"failed"} (error; no more retries left)`,ft({retryOfRequestLogID:r,url:a,durationMs:R-h,message:d.message})),b?new ms:new Mt({cause:d})}let A=[...d.headers.entries()].filter(([T])=>T==="request-id").map(([T,b])=>", "+T+": "+JSON.stringify(b)).join(""),B=`[${u}${_}${A}] ${i.method} ${a} ${d.ok?"succeeded":"failed"} with status ${d.status} in ${R-h}ms`;if(!d.ok){let T=await this.shouldRetry(d);if(t&&T){let q=`retrying, ${t} attempts remaining`;return await Rc(d.body),he(this).info(`${B} - ${q}`),he(this).debug(`[${u}] response error (${q})`,ft({retryOfRequestLogID:r,url:d.url,status:d.status,headers:d.headers,durationMs:R-h})),this.retryRequest(n,t,r??u,d.headers)}let b=T?"error; no more retries left":"error; not retryable";he(this).info(`${B} - ${b}`);let K=await d.text().catch(q=>cn(q).message),U=yo(K),ce=U?void 0:K;throw he(this).debug(`[${u}] response error (${b})`,ft({retryOfRequestLogID:r,url:d.url,status:d.status,headers:d.headers,message:ce,durationMs:Date.now()-h})),this.makeStatusError(d.status,U,ce,d.headers)}return he(this).info(B),he(this).debug(`[${u}] response start`,ft({retryOfRequestLogID:r,url:d.url,status:d.status,headers:d.headers,durationMs:R-h})),{response:d,options:n,controller:x,requestLogID:u,retryOfRequestLogID:r,startTime:h}}getAPIList(e,t,r){return this.requestAPIList(t,{method:"get",path:e,...r})}requestAPIList(e,t){let r=this.makeRequest(t,null,void 0);return new pn(this,r,e)}async fetchWithTimeout(e,t,r,n){let{signal:o,method:i,...a}=t||{};o&&o.addEventListener("abort",()=>n.abort());let c=setTimeout(()=>n.abort(),r),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,_={signal:n.signal,...u?{duplex:"half"}:{},method:"GET",...a};i&&(_.method=i.toUpperCase());try{return await this.fetch.call(void 0,e,_)}finally{clearTimeout(c);}}async shouldRetry(e){let t=e.headers.get("x-should-retry");return t==="true"?true:t==="false"?false:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,r,n){let o,i=n?.get("retry-after-ms");if(i){let c=parseFloat(i);Number.isNaN(c)||(o=c);}let a=n?.get("retry-after");if(a&&!o){let c=parseFloat(a);Number.isNaN(c)?o=Date.parse(a)-Date.now():o=c*1e3;}if(!(o&&0<=o&&o<60*1e3)){let c=e.maxRetries??this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(t,c);}return await wc(o),this.makeRequest(e,t-1,r)}calculateDefaultRetryTimeoutMillis(e,t){let o=t-e,i=Math.min(.5*Math.pow(2,o),8),a=1-Math.random()*.25;return i*a*1e3}calculateNonstreamingTimeout(e,t){if(36e5*e/128e3>6e5||t!=null&&e>t)throw new E("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details");return 6e5}async buildRequest(e,{retryCount:t=0}={}){let r={...e},{method:n,path:o,query:i,defaultBaseURL:a}=r,c=this.buildURL(o,i,a);"timeout"in r&&bc("timeout",r.timeout),r.timeout=r.timeout??this.timeout;let{bodyHeaders:u,body:_}=this.buildBody({options:r}),h=await this.buildHeaders({options:e,method:n,bodyHeaders:u,retryCount:t});return {req:{method:n,headers:h,...r.signal&&{signal:r.signal},...globalThis.ReadableStream&&_ instanceof globalThis.ReadableStream&&{duplex:"half"},..._&&{body:_},...this.fetchOptions??{},...r.fetchOptions??{}},url:c,timeout:r.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:r,retryCount:n}){let o={};this.idempotencyHeader&&t!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),o[this.idempotencyHeader]=e.idempotencyKey);let i=$([o,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(n),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...vc(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01"},await this.authHeaders(e),this._options.defaultHeaders,r,e.headers]);return this.validateHeaders(i),i.values}buildBody({options:{body:e,headers:t}}){if(!e)return {bodyHeaders:void 0,body:void 0};let r=$([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&r.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:bo(e)}:m(this,Wo,"f").call(this,{body:e,headers:r})}};pa=G,Wo=new WeakMap,ma=new WeakSet,Qc=function(){return this.baseURL!=="https://api.anthropic.com"};G.Anthropic=pa;G.HUMAN_PROMPT=Zc;G.AI_PROMPT=eu;G.DEFAULT_TIMEOUT=6e5;G.AnthropicError=E;G.APIError=de;G.APIConnectionError=Mt;G.APIConnectionTimeoutError=ms;G.APIUserAbortError=pe;G.NotFoundError=ys;G.ConflictError=bs;G.RateLimitError=xs;G.BadRequestError=ps;G.AuthenticationError=gs;G.InternalServerError=Ss;G.PermissionDeniedError=_s;G.UnprocessableEntityError=ws;G.toFile=vo;var Ge=class extends G{constructor(){super(...arguments),this.completions=new gr(this),this.messages=new jt(this),this.models=new yr(this),this.beta=new je(this);}};Ge.Completions=gr;Ge.Messages=jt;Ge.Models=yr;Ge.Beta=je;var ga=join(homedir(),".claude","claudecode-dashboard"),_a=join(ga,"cache.json"),Ye=null;async function su(){existsSync(ga)||await mkdir(ga,{recursive:true});}async function ya(){if(Ye)return Ye;if(await su(),!existsSync(_a))return Ye={version:1,entries:{}},Ye;try{let s=await readFile(_a,"utf-8");return Ye=JSON.parse(s),Ye}catch(s){let e=s instanceof Error?s.message:"Unknown error";return a$2.warn("cache",`Failed to load cache, starting fresh: ${e}`),Ye={version:1,entries:{}},Ye}}async function ba(){if(Ye)try{await su(),await writeFile(_a,JSON.stringify(Ye,null,2));}catch(s){let e=s instanceof Error?s.message:"Unknown error";a$2.error("cache",`Failed to save cache: ${e}`);}}async function nu(s){try{return (await stat(s)).mtimeMs}catch(e){let t=e instanceof Error?e.message:"Unknown error";return a$2.warn("cache",`Failed to get mtime for ${s}: ${t}`),0}}async function wa(s){let e=await ya(),t=e.entries[s];return t?await nu(s)!==t.mtime?(delete e.entries[s],await ba(),null):t.summary:null}async function xa(s,e){let t=await ya(),r=await nu(s);t.entries[s]={summary:e,mtime:r,generatedAt:Date.now()},await ba();}async function Sa(s){let e=await ya();return e.entries[s]?(delete e.entries[s],await ba(),a$2.info("cache",`Cache cleared for: ${s}`),true):false}var Aa="gpt-4o-mini",Pa="claude-haiku-4-5-latest",Ho=null,Jo=null;function Xo(){return process.env.ANTHROPIC_API_KEY?"anthropic":process.env.OPENAI_API_KEY?"openai":"none"}function On(){let s=Xo();switch(s){case "anthropic":return {provider:s,description:`Claude AI (${Pa})`};case "openai":return {provider:s,description:`OpenAI (${Aa})`};case "none":return {provider:s,description:"Set ANTHROPIC_API_KEY or OPENAI_API_KEY for AI summaries"}}}function uh(){if(Ho)return Ho;let s=process.env.OPENAI_API_KEY;return s?(Ho=new O({apiKey:s}),Ho):null}function fh(){if(Jo)return Jo;let s=process.env.ANTHROPIC_API_KEY;return s?(Jo=new Ge({apiKey:s}),Jo):null}var ou=30;function dh(s){return s.replace(/\|/g,"\u2502").replace(/─{3,}/g,"\u2500\u2500\u2500")}function hh(s,e=ou){let t=s.split(`
77
- `),r=t.slice(0,e);if(r[0]==="---"){let i=r.findIndex((a,c)=>c>0&&a==="---");i>0&&r.splice(0,i+1);}let n=t.length<=e,o=r.join(`
78
- `).trim();return o=dh(o),n?o+=`
79
- \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
80
- <EOF>`:o+=`
81
- \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
82
- ... (${t.length-e} more lines)`,{text:o,isEOF:n}}async function mh(s,e){let t=Xo(),r=`You are a senior engineer reviewing this Claude Code ${e}.
83
-
84
- Provide a structured analysis (keep it concise, ~500 words max):
85
-
86
- **What it does:** 2-3 sentences explaining the core functionality and behavior.
87
-
88
- **Key details:**
89
- - Implementation: How it works technically (tools, patterns, integrations)
90
- - Trigger: When/how it activates (events, commands, conditions)
91
- - Scope: What it affects (files, sessions, permissions)
92
-
93
- **Engineering notes:** 1-2 practical tips or gotchas.
94
-
95
- Be specific and technical. Include actual values from the config. Ensure your response is COMPLETE - do not cut off mid-sentence.`,n=s.slice(0,4e3);if(t==="anthropic"){let o=fh();if(!o)throw a$2.error("ai","Anthropic client initialization failed"),new Error("Anthropic client init failed");try{let a=(await o.messages.create({model:Pa,max_tokens:1e3,messages:[{role:"user",content:`${r}
96
-
97
- ${n}`}]})).content.find(c=>c.type==="text");if(a?.type==="text")return a$2.info("ai",`Generated summary using ${Pa}`),a.text.trim();throw a$2.error("ai","No text in Anthropic response"),new Error("No text in Anthropic response")}catch(i){let a=i instanceof Error?i.message:"Unknown error";throw a$2.error("ai",`Anthropic API error: ${a}`),i}}if(t==="openai"){let o=uh();if(!o)throw a$2.error("ai","OpenAI client initialization failed"),new Error("OpenAI client init failed");try{let a=(await o.chat.completions.create({model:Aa,messages:[{role:"system",content:r},{role:"user",content:n}],max_tokens:1e3,temperature:.3})).choices[0]?.message?.content?.trim();if(a)return a$2.info("ai",`Generated summary using ${Aa}`),a;throw a$2.error("ai","No text in OpenAI response"),new Error("No text in OpenAI response")}catch(i){let a=i instanceof Error?i.message:"Unknown error";throw a$2.error("ai",`OpenAI API error: ${a}`),i}}throw a$2.warn("ai","No AI provider configured"),new Error("No AI provider configured")}async function va(s,e){if(!existsSync(s))return a$2.warn("summary",`File not found: ${s}`),{aiSummary:null,preview:"[File not found]"};let t;try{t=await readFile(s,"utf-8");}catch(i){let a=i instanceof Error?i.message:"Unknown error";return a$2.error("summary",`Failed to read file ${s}: ${a}`),{aiSummary:null,preview:"[Failed to read file]"}}let r=hh(t),n=await wa(s);if(n)return a$2.info("summary",`Using cached summary for ${s}`),{aiSummary:n,preview:r.text};if(Xo()!=="none")try{let i=await mh(t,e);return await xa(s,i),{aiSummary:i,preview:r.text}}catch(i){let a=i instanceof Error?i.message:"Unknown error";return {aiSummary:null,preview:r.text,aiError:a}}return {aiSummary:null,preview:r.text}}function iu(s,e){let[t,r]=(0, De.useState)(null),[n,o]=(0, De.useState)(null),[i,a]=(0, De.useState)(null),[c,u]=(0, De.useState)(false),[_,h]=(0, De.useState)(null),x=On(),d=(0, De.useCallback)(async()=>{if(!s){r(null),o(null),a(null);return}u(true),h(null),o(null);try{let A=await va(s,e);r(A.aiSummary),o(A.aiError||null),a(A.preview);}catch(A){let B=A instanceof Error?A.message:"Failed to load";a$2.error("summary-hook",`Failed to load summary: ${B}`),h(B);}finally{u(false);}},[s,e]),R=(0, De.useCallback)(async()=>{s&&(a$2.info("summary-hook",`Regenerating summary for: ${s}`),await Sa(s),await d());},[s,d]);return (0, De.useEffect)(()=>{d();},[d]),{aiSummary:t,aiError:n,preview:i,loading:c,error:_,provider:x.provider,providerDescription:x.description,refresh:d,regenerate:R}}var Fs=d(ne(),1);function au({tabs:s,activeTab:e,onTabChange:t,disabled:r}){return i((n,o)=>{if(r)return;let i=s.findIndex(a=>a.key===e);if(i!==-1){if(o.tab&&!o.shift){let a=(i+1)%s.length;t(s[a].key);}else if(o.tab&&o.shift){let a=(i-1+s.length)%s.length;t(s[a].key);}}}),(0, Fs.jsxs)(a$1,{children:[s.map(n=>{let o=n.key===e;return (0, Fs.jsx)(a$1,{marginRight:1,children:(0, Fs.jsxs)(b$1,{bold:o,color:o?"cyan":void 0,dimColor:!o,children:["[",o?"\u25CF":" ","] ",n.label]})},n.key)}),(0, Fs.jsx)(b$1,{dimColor:true,children:" (Tab \u2194)"})]})}var Vo=d(a(),1);var br=d(ne(),1);function lu({content:s,maxLines:e=8,width:t,disabled:r}){let[n,o]=(0, Vo.useState)(false),{truncated:i$1,needsTruncation:a,totalVisualLines:c}=(0, Vo.useMemo)(()=>{let _=Math.max(20,t-2),h=ph(s,_);return h.length<=e?{truncated:s,needsTruncation:false,totalVisualLines:h.length}:{truncated:h.slice(0,e).join(`
98
- `),needsTruncation:true,totalVisualLines:h.length}},[s,e,t]);i((_,h)=>{r||h.return&&a&&o(x=>!x);});let u=c-e;return a?(0, br.jsxs)(a$1,{flexDirection:"column",children:[(0, br.jsx)(b$1,{wrap:"wrap",children:n?s:i$1}),(0, br.jsx)(a$1,{marginTop:1,children:(0, br.jsx)(b$1,{color:"cyan",children:n?"[Enter: See less \u2191]":`[Enter: See more... +${u} lines]`})})]}):(0, br.jsx)(b$1,{wrap:"wrap",children:s})}function ph(s,e){let t=s.split(`
99
- `),r=[];for(let n of t){if(n.length===0){r.push("");continue}if(n.length<=e){r.push(n);continue}let o=n.split(" "),i="";for(let a of o){let c=i?`${i} ${a}`:a;if(c.length<=e)i=c;else if(i&&r.push(i),a.length>e){let u=a;for(;u.length>e;)r.push(u.slice(0,e)),u=u.slice(e);i=u;}else i=a;}i&&r.push(i);}return r}var M=d(ne(),1),gh=[{key:"preview",label:"Preview"},{key:"summary",label:"AI Summary"}];function uu({item:s,width:e,maxHeight:t=30,category:r}){let[n,o]=(0, cu.useState)("preview"),i$1=s?.path,a=r||"configuration",{aiSummary:c,aiError:u,preview:_,loading:h,provider:x,regenerate:d}=iu(i$1,a);if(i(b=>{(b==="r"||b==="R")&&n==="summary"&&!h&&d();}),!s)return (0, M.jsxs)(a$1,{flexDirection:"column",paddingX:1,children:[(0, M.jsx)(b$1,{bold:true,underline:true,children:"DETAILS"}),(0, M.jsx)(b$1,{dimColor:true,italic:true,children:"Select an item to view details"})]});let R="\u2500".repeat(Math.max(10,e-4)),A=fu(s),T=Math.max(5,t-A-6);return (0, M.jsxs)(a$1,{flexDirection:"column",paddingX:1,children:[(0, M.jsx)(b$1,{bold:true,underline:true,children:"DETAILS"}),(0, M.jsxs)(a$1,{marginTop:1,flexDirection:"column",children:[(0, M.jsx)(b$1,{color:"green",bold:true,children:"Properties:"}),du(s,1,e-4)]}),i$1&&(0, M.jsxs)(a$1,{marginTop:1,flexDirection:"column",children:[(0, M.jsx)(b$1,{dimColor:true,children:R}),(0, M.jsx)(a$1,{marginTop:1,children:(0, M.jsx)(au,{tabs:gh,activeTab:n,onTabChange:b=>o(b)})}),(0, M.jsx)(a$1,{marginTop:1,flexDirection:"column",minHeight:T,children:n==="preview"?(0, M.jsx)(_h,{preview:_,loading:h,maxLines:T,width:e-6}):(0, M.jsx)(yh,{summary:c,error:u,loading:h,provider:x,maxLines:T-2,width:e-6})})]})]})}function _h({preview:s,loading:e,maxLines:t,width:r}){if(e)return (0, M.jsxs)(b$1,{color:"cyan",children:[(0, M.jsx)(Ds,{type:"dots"})," Loading preview..."]});if(!s)return (0, M.jsx)(b$1,{dimColor:true,italic:true,children:"No content available"});let n=bh(s,t,r);return (0, M.jsx)(b$1,{children:n})}function yh({summary:s,error:e,loading:t,provider:r,maxLines:n,width:o}){return r==="none"?(0, M.jsxs)(a$1,{flexDirection:"column",children:[(0, M.jsx)(b$1,{dimColor:true,italic:true,children:"AI Summary not configured"}),(0, M.jsx)(b$1,{dimColor:true,children:"Export ANTHROPIC_API_KEY or OPENAI_API_KEY to enable"})]}):t?(0, M.jsxs)(b$1,{color:"cyan",children:[(0, M.jsx)(Ds,{type:"dots"})," Generating summary..."]}):e?(0, M.jsxs)(b$1,{color:"red",children:["Error: ",e]}):s?(0, M.jsxs)(a$1,{flexDirection:"column",children:[(0, M.jsx)(lu,{content:s,maxLines:n-1,width:o}),(0, M.jsx)(b$1,{dimColor:true,children:" (R: regenerate)"})]}):(0, M.jsx)(b$1,{dimColor:true,italic:true,children:"No summary available"})}function fu(s){let e=0;for(let[,t]of Object.entries(s))t!=null&&(e++,typeof t=="object"&&!Array.isArray(t)?e+=fu(t):Array.isArray(t)&&t.length>0&&typeof t[0]=="object"&&(e+=Math.min(t.length,3),t.length>3&&e++));return e}function bh(s,e,t){let r=s.split(`
100
- `),n=r[r.length-1]||"",o=n.includes("<EOF>"),i=n.includes("... (")&&n.includes("more lines)"),a=r.length>=2&&r[r.length-2]?.startsWith("\u2500\u2500\u2500"),c=o||i?a?2:1:0,u=e-c,_=[],h=c>0?r.slice(0,-c):r;for(let d of h){if(_.length>=u)break;if(d.length<=t)_.push(d);else {let R=d.split(" "),A="";for(let B of R){if(_.length>=u)break;(A+" "+B).trim().length<=t?A=(A+" "+B).trim():(A&&_.push(A),A=B);}A&&_.length<u&&_.push(A);}}return _.length<h.length&&_.length>0&&(_[_.length-1]=_[_.length-1].slice(0,t-15)+"... [truncated]"),c>0&&(a&&c===2&&_.push(r[r.length-2]),_.push(n)),_.join(`
101
- `)}function du(s,e,t){let r=[],n=" ".repeat(e);for(let[o,i]of Object.entries(s))if(i!=null)if(typeof i=="object"&&!Array.isArray(i))r.push((0, M.jsxs)(b$1,{children:[n,(0, M.jsxs)(b$1,{color:"yellow",children:[o,":"]})]},o)),r.push(...du(i,e+1,t));else if(Array.isArray(i))if(i.length===0)r.push((0, M.jsxs)(b$1,{children:[n,(0, M.jsxs)(b$1,{color:"yellow",children:[o,":"]})," ",(0, M.jsx)(b$1,{dimColor:true,children:"[]"})]},o));else if(typeof i[0]=="object"&&i[0]!==null)r.push((0, M.jsxs)(b$1,{children:[n,(0, M.jsxs)(b$1,{color:"yellow",children:[o,":"]})," ",(0, M.jsxs)(b$1,{dimColor:true,children:["[",i.length," items]"]})]},o)),i.slice(0,3).forEach((a,c)=>{let u=a.name||a.event||a.command||`[${c}]`;r.push((0, M.jsxs)(b$1,{children:[n," ",(0, M.jsxs)(b$1,{dimColor:true,children:["\u2022 ",String(u).slice(0,t-e*2-6)]})]},`${o}-${c}`));}),i.length>3&&r.push((0, M.jsxs)(b$1,{children:[n," ",(0, M.jsxs)(b$1,{dimColor:true,children:["... +",i.length-3," more"]})]},`${o}-more`));else {let a=i.length>5?`[${i.slice(0,5).join(", ")}... +${i.length-5}]`:`[${i.join(", ")}]`;r.push((0, M.jsxs)(b$1,{children:[n,(0, M.jsxs)(b$1,{color:"yellow",children:[o,":"]})," ",a]},o));}else {let a=String(i),c=t-n.length-o.length-3,u=a.length>c?a.slice(0,c-3)+"...":a;r.push((0, M.jsxs)(b$1,{children:[n,(0, M.jsxs)(b$1,{color:"yellow",children:[o,":"]})," ",u]},o));}return r}var Mn=d(ne(),1);function hu(){let{provider:s,description:e}=On(),t=s!=="none";return (0, Mn.jsxs)(a$1,{borderStyle:"single",paddingX:1,justifyContent:"space-between",children:[(0, Mn.jsx)(b$1,{dimColor:true,children:"\u2191\u2193 Navigate \u2190\u2192 Switch r Refresh q Quit"}),(0, Mn.jsx)(b$1,{color:t?"green":"yellow",children:t?`\u25CF ${e}`:`\u25CB ${e}`})]})}var Ko=d(a(),1);function mu(s=10){let e=b$2(),[t,r]=(0, Ko.useState)(()=>e.getRecent(s));return (0, Ko.useEffect)(()=>e.subscribe(o=>{r(o.slice(-s));}),[s,e]),t}var ze=d(ne(),1);function wh(s){switch(s){case "error":return "red";case "warn":return "yellow";case "info":return "cyan";case "debug":return "gray"}}function xh(s){switch(s){case "error":return "\u2717";case "warn":return "\u26A0";case "info":return "\u2022";case "debug":return "\u25CB"}}function Sh(s){return s.toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function pu({height:s=5}){let e=mu(s-1);return (0, ze.jsxs)(a$1,{flexDirection:"column",height:s,borderStyle:"single",borderColor:"gray",paddingX:1,children:[(0, ze.jsx)(b$1,{bold:true,dimColor:true,children:"LOG"}),e.length===0?(0, ze.jsx)(b$1,{dimColor:true,italic:true,children:"No logs yet"}):e.map((t,r)=>(0, ze.jsxs)(b$1,{wrap:"truncate",children:[(0, ze.jsx)(b$1,{dimColor:true,children:Sh(t.timestamp)})," ",(0, ze.jsx)(b$1,{color:wh(t.level),children:xh(t.level)})," ",(0, ze.jsxs)(b$1,{dimColor:true,children:["[",t.source,"]"]})," ",(0, ze.jsx)(b$1,{color:t.level==="error"?"red":void 0,children:t.message})]},r))]})}var _e=d(ne(),1);function gu({config:s,nav:e,width:t,height:r}){let i=t-22-30-6,a=6,c=Math.max(10,r-6-a);return (0, _e.jsxs)(a$1,{flexDirection:"column",width:t,children:[(0, _e.jsxs)(a$1,{borderStyle:"single",paddingX:1,children:[(0, _e.jsx)(b$1,{bold:true,color:"cyan",children:"ClaudeCode Dashboard"}),(0, _e.jsx)(a$1,{flexGrow:1}),(0, _e.jsx)(b$1,{dimColor:true,children:"Claude Code Config Viewer"})]}),(0, _e.jsxs)(a$1,{height:c,children:[(0, _e.jsx)(a$1,{flexDirection:"column",width:22,borderStyle:"single",paddingX:1,children:(0, _e.jsx)(dl,{categories:e.categories,selected:e.categoryIndex,focused:e.panel==="category"})}),(0, _e.jsx)(a$1,{flexDirection:"column",width:30,borderStyle:"single",paddingX:1,children:(0, _e.jsx)(hl,{items:e.currentItems,selected:e.itemIndex,focused:e.panel==="item",maxHeight:c-4})}),(0, _e.jsx)(a$1,{flexDirection:"column",width:i,borderStyle:"single",children:(0, _e.jsx)(uu,{item:e.selectedItem,width:i,maxHeight:c-2,category:e.categories[e.categoryIndex]?.key})})]}),(0, _e.jsx)(pu,{height:a}),(0, _e.jsx)(hu,{})]})}var Dt=d(a(),1);function _u(){let[s,e$1]=(0, Dt.useState)({settings:null,skills:[],agents:[],commands:[],plugins:[],hooks:[],mcpServers:[],outputStyles:[]}),[t,r]=(0, Dt.useState)(true),[n,o]=(0, Dt.useState)(null),i=(0, Dt.useCallback)(async()=>{r(true),a$2.info("config","Loading configurations...");try{let[a,c$1,u,_,h$1,x,d]=await Promise.all([c(),d$1(),e(),f$1(),g$1(),h(),i$1()]);e$1({settings:a,skills:c$1,agents:u,commands:_,plugins:d,hooks:h$1,mcpServers:x,outputStyles:[]}),o(null),a$2.info("config",`Loaded: ${c$1.length} skills, ${u.length} agents, ${_.length} commands`);}catch(a){let c=a instanceof Error?a.message:"Failed to load config";a$2.error("config",`Load failed: ${c}`),o(c);}finally{r(false);}},[]);return (0, Dt.useEffect)(()=>{i();},[i]),{data:s,loading:t,error:n,refresh:i}}var wr=d(a(),1);function yu(s,e){let[t,r]=(0, wr.useState)("category"),[n,o]=(0, wr.useState)(()=>{if(!e)return 0;let h=["skills","agents","commands","hooks","mcp","plugins","settings"].indexOf(e);return h>=0?h:0}),[i,a]=(0, wr.useState)(0),c=(0, wr.useMemo)(()=>[{key:"skills",label:"Skills",count:s.data.skills.length},{key:"agents",label:"Agents",count:s.data.agents.length},{key:"commands",label:"Commands",count:s.data.commands.length},{key:"hooks",label:"Hooks",count:s.data.hooks.length},{key:"mcp",label:"MCP Servers",count:s.data.mcpServers.length},{key:"plugins",label:"Plugins",count:s.data.plugins.length},{key:"settings",label:"Settings",count:s.data.settings?1:0}],[s.data]),u=(0, wr.useMemo)(()=>{let h=c[n];if(!h)return [];switch(h.key){case "skills":return s.data.skills;case "agents":return s.data.agents;case "commands":return s.data.commands;case "hooks":return s.data.hooks.map(x=>({...x,name:`${x.event}${x.matcher?`:${x.matcher}`:""}`}));case "mcp":return s.data.mcpServers;case "plugins":return s.data.plugins;case "settings":return s.data.settings?[{name:"Settings",...s.data.settings}]:[]}},[s.data,n,c]),_=u[i]??null;return {panel:t,categoryIndex:n,itemIndex:i,categories:c,currentItems:u,selectedItem:_,up:()=>{t==="category"?(o(h=>Math.max(0,h-1)),a(0)):a(h=>Math.max(0,h-1));},down:()=>{t==="category"?(o(h=>Math.min(c.length-1,h+1)),a(0)):a(h=>Math.min(u.length-1,h+1));},left:()=>r("category"),right:()=>r("item"),select:()=>{t==="category"&&r("item");},pageUp:()=>{t==="item"&&a(h=>Math.max(0,h-10));},pageDown:()=>{t==="item"&&a(h=>Math.min(u.length-1,h+10));}}}var Ae=d(ne(),1);function IP({initialCategory:s}){let{exit:e}=j(),{stdout:t}=k$1(),r=_u(),n=yu(r,s);i((a,c)=>{a==="q"&&e(),a==="r"&&r.refresh(),(c.upArrow||a==="k")&&n.up(),(c.downArrow||a==="j")&&n.down(),(c.leftArrow||a==="h")&&n.left(),(c.rightArrow||a==="l")&&n.right(),c.return&&n.select(),(c.pageUp||a==="u")&&n.pageUp(),(c.pageDown||a==="d")&&n.pageDown();});let o=t?.columns??120,i$1=t?.rows??30;return o<80?(0, Ae.jsxs)(a$1,{flexDirection:"column",padding:1,children:[(0, Ae.jsxs)(b$1,{color:"yellow",children:["Terminal too narrow (",o," cols)"]}),(0, Ae.jsx)(b$1,{children:"Minimum 80 columns required."}),(0, Ae.jsx)(b$1,{dimColor:true,children:"Press q to quit."})]}):r.loading?(0, Ae.jsxs)(a$1,{padding:1,children:[(0, Ae.jsx)(b$1,{color:"cyan",children:(0, Ae.jsx)(Ds,{type:"dots"})}),(0, Ae.jsx)(b$1,{children:" Loading configurations..."})]}):r.error?(0, Ae.jsxs)(a$1,{flexDirection:"column",padding:1,children:[(0, Ae.jsxs)(b$1,{color:"red",children:["Error: ",r.error]}),(0, Ae.jsx)(b$1,{dimColor:true,children:"Press r to retry, q to quit."})]}):(0, Ae.jsx)(gu,{config:r.data,nav:n,width:Math.min(o,160),height:i$1})}/*! Bundled license information:
102
-
103
- react/cjs/react-jsx-runtime.production.min.js:
104
- (**
105
- * @license React
106
- * react-jsx-runtime.production.min.js
107
- *
108
- * Copyright (c) Facebook, Inc. and its affiliates.
109
- *
110
- * This source code is licensed under the MIT license found in the
111
- * LICENSE file in the root directory of this source tree.
112
- *)
113
-
114
- react/cjs/react-jsx-runtime.development.js:
115
- (**
116
- * @license React
117
- * react-jsx-runtime.development.js
118
- *
119
- * Copyright (c) Facebook, Inc. and its affiliates.
120
- *
121
- * This source code is licensed under the MIT license found in the
122
- * LICENSE file in the root directory of this source tree.
123
- *)
124
- */export{IP as App};