braintrust 0.0.26 → 0.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- A Node.js library for logging data to BrainTrust.
1
+ An isomorphic JS library for logging data to BrainTrust.
2
2
 
3
3
  ### Quickstart
4
4
 
@@ -12,10 +12,10 @@ Then, run a simple experiment with the following code (replace `YOUR_API_KEY` wi
12
12
  your BrainTrust API key):
13
13
 
14
14
  ```javascript
15
- const braintrust = require("braintrust");
15
+ import * as braintrust from "braintrust";
16
16
 
17
17
  const experiment = await braintrust.init("NodeTest", {
18
- api_key: "YOUR_API_KEY",
18
+ apiKey: "YOUR_API_KEY",
19
19
  });
20
20
  experiment.log({
21
21
  inputs: { test: 1 },
@@ -0,0 +1 @@
1
+ export * from "./logger";
@@ -0,0 +1,3 @@
1
+ function z(e,t){return function(){return e.apply(t,arguments)}}var{toString:Ut}=Object.prototype,{getPrototypeOf:we}=Object,Z=(e=>t=>{let r=Ut.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),R=e=>(e=e.toLowerCase(),t=>Z(t)===e),ee=e=>t=>typeof t===e,{isArray:k}=Array,H=ee("undefined");function jt(e){return e!==null&&!H(e)&&e.constructor!==null&&!H(e.constructor)&&_(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var Ve=R("ArrayBuffer");function kt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ve(e.buffer),t}var Dt=ee("string"),_=ee("function"),Ke=ee("number"),te=e=>e!==null&&typeof e=="object",Lt=e=>e===!0||e===!1,Y=e=>{if(Z(e)!=="object")return!1;let t=we(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Ft=R("Date"),Bt=R("File"),It=R("Blob"),vt=R("FileList"),zt=e=>te(e)&&_(e.pipe),Ht=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||_(e.append)&&((t=Z(e))==="formdata"||t==="object"&&_(e.toString)&&e.toString()==="[object FormData]"))},qt=R("URLSearchParams"),Mt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function q(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),k(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{let i=r?Object.getOwnPropertyNames(e):Object.keys(e),s=i.length,u;for(n=0;n<s;n++)u=i[n],t.call(null,e[u],u,e)}}function We(e,t){t=t.toLowerCase();let r=Object.keys(e),n=r.length,o;for(;n-- >0;)if(o=r[n],t===o.toLowerCase())return o;return null}var Ge=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),Xe=e=>!H(e)&&e!==Ge;function ye(){let{caseless:e}=Xe(this)&&this||{},t={},r=(n,o)=>{let i=e&&We(t,o)||o;Y(t[i])&&Y(n)?t[i]=ye(t[i],n):Y(n)?t[i]=ye({},n):k(n)?t[i]=n.slice():t[i]=n};for(let n=0,o=arguments.length;n<o;n++)arguments[n]&&q(arguments[n],r);return t}var Jt=(e,t,r,{allOwnKeys:n}={})=>(q(t,(o,i)=>{r&&_(o)?e[i]=z(o,r):e[i]=o},{allOwnKeys:n}),e),$t=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Vt=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},Kt=(e,t,r,n)=>{let o,i,s,u={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],(!n||n(s,e,t))&&!u[s]&&(t[s]=e[s],u[s]=!0);e=r!==!1&&we(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},Wt=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},Gt=e=>{if(!e)return null;if(k(e))return e;let t=e.length;if(!Ke(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},Xt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&we(Uint8Array)),Qt=(e,t)=>{let n=(e&&e[Symbol.iterator]).call(e),o;for(;(o=n.next())&&!o.done;){let i=o.value;t.call(e,i[0],i[1])}},Yt=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},Zt=R("HTMLFormElement"),er=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),Je=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),tr=R("RegExp"),Qe=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};q(r,(o,i)=>{t(o,i,e)!==!1&&(n[i]=o)}),Object.defineProperties(e,n)},rr=e=>{Qe(e,(t,r)=>{if(_(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(_(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},nr=(e,t)=>{let r={},n=o=>{o.forEach(i=>{r[i]=!0})};return k(e)?n(e):n(String(e).split(t)),r},or=()=>{},ir=(e,t)=>(e=+e,Number.isFinite(e)?e:t),ge="abcdefghijklmnopqrstuvwxyz",$e="0123456789",Ye={DIGIT:$e,ALPHA:ge,ALPHA_DIGIT:ge+ge.toUpperCase()+$e},sr=(e=16,t=Ye.ALPHA_DIGIT)=>{let r="",{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function ar(e){return!!(e&&_(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var ur=e=>{let t=new Array(10),r=(n,o)=>{if(te(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[o]=n;let i=k(n)?[]:{};return q(n,(s,u)=>{let f=r(s,o+1);!H(f)&&(i[u]=f)}),t[o]=void 0,i}}return n};return r(e,0)},cr=R("AsyncFunction"),lr=e=>e&&(te(e)||_(e))&&_(e.then)&&_(e.catch),a={isArray:k,isArrayBuffer:Ve,isBuffer:jt,isFormData:Ht,isArrayBufferView:kt,isString:Dt,isNumber:Ke,isBoolean:Lt,isObject:te,isPlainObject:Y,isUndefined:H,isDate:Ft,isFile:Bt,isBlob:It,isRegExp:tr,isFunction:_,isStream:zt,isURLSearchParams:qt,isTypedArray:Xt,isFileList:vt,forEach:q,merge:ye,extend:Jt,trim:Mt,stripBOM:$t,inherits:Vt,toFlatObject:Kt,kindOf:Z,kindOfTest:R,endsWith:Wt,toArray:Gt,forEachEntry:Qt,matchAll:Yt,isHTMLForm:Zt,hasOwnProperty:Je,hasOwnProp:Je,reduceDescriptors:Qe,freezeMethods:rr,toObjectSet:nr,toCamelCase:er,noop:or,toFiniteNumber:ir,findKey:We,global:Ge,isContextDefined:Xe,ALPHABET:Ye,generateString:sr,isSpecCompliantForm:ar,toJSONObject:ur,isAsyncFn:cr,isThenable:lr};function D(e,t,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}a.inherits(D,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var Ze=D.prototype,et={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{et[e]={value:e}});Object.defineProperties(D,et);Object.defineProperty(Ze,"isAxiosError",{value:!0});D.from=(e,t,r,n,o,i)=>{let s=Object.create(Ze);return a.toFlatObject(e,s,function(f){return f!==Error.prototype},u=>u!=="isAxiosError"),D.call(s,e.message,t,r,n,o),s.cause=e,s.name=e.name,i&&Object.assign(s,i),s};var m=D;var re=null;function be(e){return a.isPlainObject(e)||a.isArray(e)}function rt(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function tt(e,t,r){return e?e.concat(t).map(function(o,i){return o=rt(o),!r&&i?"["+o+"]":o}).join(r?".":""):t}function fr(e){return a.isArray(e)&&!e.some(be)}var dr=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function pr(e,t,r){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new(re||FormData),r=a.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,O){return!a.isUndefined(O[h])});let n=r.metaTokens,o=r.visitor||l,i=r.dots,s=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(o))throw new TypeError("visitor must be a function");function c(d){if(d===null)return"";if(a.isDate(d))return d.toISOString();if(!f&&a.isBlob(d))throw new m("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(d)||a.isTypedArray(d)?f&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function l(d,h,O){let S=d;if(d&&!O&&typeof d=="object"){if(a.endsWith(h,"{}"))h=n?h:h.slice(0,-2),d=JSON.stringify(d);else if(a.isArray(d)&&fr(d)||(a.isFileList(d)||a.endsWith(h,"[]"))&&(S=a.toArray(d)))return h=rt(h),S.forEach(function(Q,Ct){!(a.isUndefined(Q)||Q===null)&&t.append(s===!0?tt([h],Ct,i):s===null?h:h+"[]",c(Q))}),!1}return be(d)?!0:(t.append(tt(O,h,i),c(d)),!1)}let p=[],y=Object.assign(dr,{defaultVisitor:l,convertValue:c,isVisitable:be});function g(d,h){if(!a.isUndefined(d)){if(p.indexOf(d)!==-1)throw Error("Circular reference detected in "+h.join("."));p.push(d),a.forEach(d,function(S,j){(!(a.isUndefined(S)||S===null)&&o.call(t,S,a.isString(j)?j.trim():j,h,y))===!0&&g(S,h?h.concat(j):[j])}),p.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return g(e),t}var P=pr;function nt(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function ot(e,t){this._pairs=[],e&&P(e,this,t)}var it=ot.prototype;it.append=function(t,r){this._pairs.push([t,r])};it.toString=function(t){let r=t?function(n){return t.call(this,n,nt)}:nt;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};var ne=ot;function mr(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function M(e,t,r){if(!t)return e;let n=r&&r.encode||mr,o=r&&r.serialize,i;if(o?i=o(t,r):i=a.isURLSearchParams(t)?t.toString():new ne(t,r).toString(n),i){let s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}var xe=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(n){n!==null&&t(n)})}},Ee=xe;var oe={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var st=typeof URLSearchParams<"u"?URLSearchParams:ne;var at=typeof FormData<"u"?FormData:null;var ut=typeof Blob<"u"?Blob:null;var hr=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),gr=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),x={isBrowser:!0,classes:{URLSearchParams:st,FormData:at,Blob:ut},isStandardBrowserEnv:hr,isStandardBrowserWebWorkerEnv:gr,protocols:["http","https","file","blob","url","data"]};function _e(e,t){return P(e,new x.classes.URLSearchParams,Object.assign({visitor:function(r,n,o,i){return x.isNode&&a.isBuffer(r)?(this.append(n,r.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}function yr(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function wr(e){let t={},r=Object.keys(e),n,o=r.length,i;for(n=0;n<o;n++)i=r[n],t[i]=e[i];return t}function br(e){function t(r,n,o,i){let s=r[i++],u=Number.isFinite(+s),f=i>=r.length;return s=!s&&a.isArray(o)?o.length:s,f?(a.hasOwnProp(o,s)?o[s]=[o[s],n]:o[s]=n,!u):((!o[s]||!a.isObject(o[s]))&&(o[s]=[]),t(r,n,o[s],i)&&a.isArray(o[s])&&(o[s]=wr(o[s])),!u)}if(a.isFormData(e)&&a.isFunction(e.entries)){let r={};return a.forEachEntry(e,(n,o)=>{t(yr(n),o,r,0)}),r}return null}var ie=br;var xr={"Content-Type":void 0};function Er(e,t,r){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var se={transitional:oe,adapter:["xhr","http"],transformRequest:[function(t,r){let n=r.getContentType()||"",o=n.indexOf("application/json")>-1,i=a.isObject(t);if(i&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return o&&o?JSON.stringify(ie(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let u;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return _e(t,this.formSerializer).toString();if((u=a.isFileList(t))||n.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return P(u?{"files[]":t}:t,f&&new f,this.formSerializer)}}return i||o?(r.setContentType("application/json",!1),Er(t)):t}],transformResponse:[function(t){let r=this.transitional||se.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(t&&a.isString(t)&&(n&&!this.responseType||o)){let s=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(t)}catch(u){if(s)throw u.name==="SyntaxError"?m.from(u,m.ERR_BAD_RESPONSE,this,null,this.response):u}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:x.classes.FormData,Blob:x.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};a.forEach(["delete","get","head"],function(t){se.headers[t]={}});a.forEach(["post","put","patch"],function(t){se.headers[t]=a.merge(xr)});var L=se;var _r=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),ct=e=>{let t={},r,n,o;return e&&e.split(`
2
+ `).forEach(function(s){o=s.indexOf(":"),r=s.substring(0,o).trim().toLowerCase(),n=s.substring(o+1).trim(),!(!r||t[r]&&_r[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var lt=Symbol("internals");function J(e){return e&&String(e).trim().toLowerCase()}function ae(e){return e===!1||e==null?e:a.isArray(e)?e.map(ae):String(e)}function Sr(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}var Rr=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Se(e,t,r,n,o){if(a.isFunction(n))return n.call(this,t,r);if(o&&(t=r),!!a.isString(t)){if(a.isString(n))return t.indexOf(n)!==-1;if(a.isRegExp(n))return n.test(t)}}function Ar(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function Or(e,t){let r=a.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(o,i,s){return this[n].call(this,t,o,i,s)},configurable:!0})})}var F=class{constructor(t){t&&this.set(t)}set(t,r,n){let o=this;function i(u,f,c){let l=J(f);if(!l)throw new Error("header name must be a non-empty string");let p=a.findKey(o,l);(!p||o[p]===void 0||c===!0||c===void 0&&o[p]!==!1)&&(o[p||f]=ae(u))}let s=(u,f)=>a.forEach(u,(c,l)=>i(c,l,f));return a.isPlainObject(t)||t instanceof this.constructor?s(t,r):a.isString(t)&&(t=t.trim())&&!Rr(t)?s(ct(t),r):t!=null&&i(r,t,n),this}get(t,r){if(t=J(t),t){let n=a.findKey(this,t);if(n){let o=this[n];if(!r)return o;if(r===!0)return Sr(o);if(a.isFunction(r))return r.call(this,o,n);if(a.isRegExp(r))return r.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=J(t),t){let n=a.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||Se(this,this[n],n,r)))}return!1}delete(t,r){let n=this,o=!1;function i(s){if(s=J(s),s){let u=a.findKey(n,s);u&&(!r||Se(n,n[u],u,r))&&(delete n[u],o=!0)}}return a.isArray(t)?t.forEach(i):i(t),o}clear(t){let r=Object.keys(this),n=r.length,o=!1;for(;n--;){let i=r[n];(!t||Se(this,this[i],i,t,!0))&&(delete this[i],o=!0)}return o}normalize(t){let r=this,n={};return a.forEach(this,(o,i)=>{let s=a.findKey(n,i);if(s){r[s]=ae(o),delete r[i];return}let u=t?Ar(i):String(i).trim();u!==i&&delete r[i],r[u]=ae(o),n[u]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return a.forEach(this,(n,o)=>{n!=null&&n!==!1&&(r[o]=t&&a.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
3
+ `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(o=>n.set(o)),n}static accessor(t){let n=(this[lt]=this[lt]={accessors:{}}).accessors,o=this.prototype;function i(s){let u=J(s);n[u]||(Or(o,s),n[u]=!0)}return a.isArray(t)?t.forEach(i):i(t),this}};F.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.freezeMethods(F.prototype);a.freezeMethods(F);var E=F;function $(e,t){let r=this||L,n=t||r,o=E.from(n.headers),i=n.data;return a.forEach(e,function(u){i=u.call(r,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function V(e){return!!(e&&e.__CANCEL__)}function ft(e,t,r){m.call(this,e??"canceled",m.ERR_CANCELED,t,r),this.name="CanceledError"}a.inherits(ft,m,{__CANCEL__:!0});var T=ft;function Re(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new m("Request failed with status code "+r.status,[m.ERR_BAD_REQUEST,m.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}var dt=x.isStandardBrowserEnv?function(){return{write:function(r,n,o,i,s,u){let f=[];f.push(r+"="+encodeURIComponent(n)),a.isNumber(o)&&f.push("expires="+new Date(o).toGMTString()),a.isString(i)&&f.push("path="+i),a.isString(s)&&f.push("domain="+s),u===!0&&f.push("secure"),document.cookie=f.join("; ")},read:function(r){let n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Ae(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Oe(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function K(e,t){return e&&!Ae(t)?Oe(e,t):t}var pt=x.isStandardBrowserEnv?function(){let t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function o(i){let s=i;return t&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=o(window.location.href),function(s){let u=a.isString(s)?o(s):s;return u.protocol===n.protocol&&u.host===n.host}}():function(){return function(){return!0}}();function Ne(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Nr(e,t){e=e||10;let r=new Array(e),n=new Array(e),o=0,i=0,s;return t=t!==void 0?t:1e3,function(f){let c=Date.now(),l=n[i];s||(s=c),r[o]=f,n[o]=c;let p=i,y=0;for(;p!==o;)y+=r[p++],p=p%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),c-s<t)return;let g=l&&c-l;return g?Math.round(y*1e3/g):void 0}}var mt=Nr;function ht(e,t){let r=0,n=mt(50,250);return o=>{let i=o.loaded,s=o.lengthComputable?o.total:void 0,u=i-r,f=n(u),c=i<=s;r=i;let l={loaded:i,total:s,progress:s?i/s:void 0,bytes:u,rate:f||void 0,estimated:f&&s&&c?(s-i)/f:void 0,event:o};l[t?"download":"upload"]=!0,e(l)}}var Pr=typeof XMLHttpRequest<"u",gt=Pr&&function(e){return new Promise(function(r,n){let o=e.data,i=E.from(e.headers).normalize(),s=e.responseType,u;function f(){e.cancelToken&&e.cancelToken.unsubscribe(u),e.signal&&e.signal.removeEventListener("abort",u)}a.isFormData(o)&&(x.isStandardBrowserEnv||x.isStandardBrowserWebWorkerEnv?i.setContentType(!1):i.setContentType("multipart/form-data;",!1));let c=new XMLHttpRequest;if(e.auth){let g=e.auth.username||"",d=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(g+":"+d))}let l=K(e.baseURL,e.url);c.open(e.method.toUpperCase(),M(l,e.params,e.paramsSerializer),!0),c.timeout=e.timeout;function p(){if(!c)return;let g=E.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders()),h={data:!s||s==="text"||s==="json"?c.responseText:c.response,status:c.status,statusText:c.statusText,headers:g,config:e,request:c};Re(function(S){r(S),f()},function(S){n(S),f()},h),c=null}if("onloadend"in c?c.onloadend=p:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(p)},c.onabort=function(){c&&(n(new m("Request aborted",m.ECONNABORTED,e,c)),c=null)},c.onerror=function(){n(new m("Network Error",m.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let d=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",h=e.transitional||oe;e.timeoutErrorMessage&&(d=e.timeoutErrorMessage),n(new m(d,h.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,e,c)),c=null},x.isStandardBrowserEnv){let g=(e.withCredentials||pt(l))&&e.xsrfCookieName&&dt.read(e.xsrfCookieName);g&&i.set(e.xsrfHeaderName,g)}o===void 0&&i.setContentType(null),"setRequestHeader"in c&&a.forEach(i.toJSON(),function(d,h){c.setRequestHeader(h,d)}),a.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),s&&s!=="json"&&(c.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&c.addEventListener("progress",ht(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",ht(e.onUploadProgress)),(e.cancelToken||e.signal)&&(u=g=>{c&&(n(!g||g.type?new T(null,e,c):g),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(u),e.signal&&(e.signal.aborted?u():e.signal.addEventListener("abort",u)));let y=Ne(l);if(y&&x.protocols.indexOf(y)===-1){n(new m("Unsupported protocol "+y+":",m.ERR_BAD_REQUEST,e));return}c.send(o||null)})};var ue={http:re,xhr:gt};a.forEach(ue,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var yt={getAdapter:e=>{e=a.isArray(e)?e:[e];let{length:t}=e,r,n;for(let o=0;o<t&&(r=e[o],!(n=a.isString(r)?ue[r.toLowerCase()]:r));o++);if(!n)throw n===!1?new m(`Adapter ${r} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(a.hasOwnProp(ue,r)?`Adapter '${r}' is not available in the build`:`Unknown adapter '${r}'`);if(!a.isFunction(n))throw new TypeError("adapter is not a function");return n},adapters:ue};function Pe(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new T(null,e)}function ce(e){return Pe(e),e.headers=E.from(e.headers),e.data=$.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),yt.getAdapter(e.adapter||L.adapter)(e).then(function(n){return Pe(e),n.data=$.call(e,e.transformResponse,n),n.headers=E.from(n.headers),n},function(n){return V(n)||(Pe(e),n&&n.response&&(n.response.data=$.call(e,e.transformResponse,n.response),n.response.headers=E.from(n.response.headers))),Promise.reject(n)})}var wt=e=>e instanceof E?e.toJSON():e;function N(e,t){t=t||{};let r={};function n(c,l,p){return a.isPlainObject(c)&&a.isPlainObject(l)?a.merge.call({caseless:p},c,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function o(c,l,p){if(a.isUndefined(l)){if(!a.isUndefined(c))return n(void 0,c,p)}else return n(c,l,p)}function i(c,l){if(!a.isUndefined(l))return n(void 0,l)}function s(c,l){if(a.isUndefined(l)){if(!a.isUndefined(c))return n(void 0,c)}else return n(void 0,l)}function u(c,l,p){if(p in t)return n(c,l);if(p in e)return n(void 0,c)}let f={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:u,headers:(c,l)=>o(wt(c),wt(l),!0)};return a.forEach(Object.keys(Object.assign({},e,t)),function(l){let p=f[l]||o,y=p(e[l],t[l],l);a.isUndefined(y)&&p!==u||(r[l]=y)}),r}var le="1.4.0";var Te={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Te[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});var bt={};Te.transitional=function(t,r,n){function o(i,s){return"[Axios v"+le+"] Transitional option '"+i+"'"+s+(n?". "+n:"")}return(i,s,u)=>{if(t===!1)throw new m(o(s," has been removed"+(r?" in "+r:"")),m.ERR_DEPRECATED);return r&&!bt[s]&&(bt[s]=!0,console.warn(o(s," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(i,s,u):!0}};function Tr(e,t,r){if(typeof e!="object")throw new m("options must be an object",m.ERR_BAD_OPTION_VALUE);let n=Object.keys(e),o=n.length;for(;o-- >0;){let i=n[o],s=t[i];if(s){let u=e[i],f=u===void 0||s(u,i,e);if(f!==!0)throw new m("option "+i+" must be "+f,m.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new m("Unknown option "+i,m.ERR_BAD_OPTION)}}var fe={assertOptions:Tr,validators:Te};var C=fe.validators,B=class{constructor(t){this.defaults=t,this.interceptors={request:new Ee,response:new Ee}}request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=N(this.defaults,r);let{transitional:n,paramsSerializer:o,headers:i}=r;n!==void 0&&fe.assertOptions(n,{silentJSONParsing:C.transitional(C.boolean),forcedJSONParsing:C.transitional(C.boolean),clarifyTimeoutError:C.transitional(C.boolean)},!1),o!=null&&(a.isFunction(o)?r.paramsSerializer={serialize:o}:fe.assertOptions(o,{encode:C.function,serialize:C.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s;s=i&&a.merge(i.common,i[r.method]),s&&a.forEach(["delete","get","head","post","put","patch","common"],d=>{delete i[d]}),r.headers=E.concat(s,i);let u=[],f=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(r)===!1||(f=f&&h.synchronous,u.unshift(h.fulfilled,h.rejected))});let c=[];this.interceptors.response.forEach(function(h){c.push(h.fulfilled,h.rejected)});let l,p=0,y;if(!f){let d=[ce.bind(this),void 0];for(d.unshift.apply(d,u),d.push.apply(d,c),y=d.length,l=Promise.resolve(r);p<y;)l=l.then(d[p++],d[p++]);return l}y=u.length;let g=r;for(p=0;p<y;){let d=u[p++],h=u[p++];try{g=d(g)}catch(O){h.call(this,O);break}}try{l=ce.call(this,g)}catch(d){return Promise.reject(d)}for(p=0,y=c.length;p<y;)l=l.then(c[p++],c[p++]);return l}getUri(t){t=N(this.defaults,t);let r=K(t.baseURL,t.url);return M(r,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){B.prototype[t]=function(r,n){return this.request(N(n||{},{method:t,url:r,data:(n||{}).data}))}});a.forEach(["post","put","patch"],function(t){function r(n){return function(i,s,u){return this.request(N(u||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}B.prototype[t]=r(),B.prototype[t+"Form"]=r(!0)});var W=B;var Ce=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});let n=this;this.promise.then(o=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](o);n._listeners=null}),this.promise.then=o=>{let i,s=new Promise(u=>{n.subscribe(u),i=u}).then(o);return s.cancel=function(){n.unsubscribe(i)},s},t(function(i,s,u){n.reason||(n.reason=new T(i,s,u),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}static source(){let t;return{token:new e(function(o){t=o}),cancel:t}}},xt=Ce;function Ue(e){return function(r){return e.apply(null,r)}}function je(e){return a.isObject(e)&&e.isAxiosError===!0}var ke={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ke).forEach(([e,t])=>{ke[t]=e});var Et=ke;function _t(e){let t=new W(e),r=z(W.prototype.request,t);return a.extend(r,W.prototype,t,{allOwnKeys:!0}),a.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return _t(N(e,o))},r}var w=_t(L);w.Axios=W;w.CanceledError=T;w.CancelToken=xt;w.isCancel=V;w.VERSION=le;w.toFormData=P;w.AxiosError=m;w.Cancel=w.CanceledError;w.all=function(t){return Promise.all(t)};w.spread=Ue;w.isAxiosError=je;w.mergeConfig=N;w.AxiosHeaders=E;w.formToJSON=e=>ie(a.isHTMLForm(e)?new FormData(e):e);w.HttpStatusCode=Et;w.default=w;var I=w;var{Axios:mi,AxiosError:hi,CanceledError:gi,isCancel:yi,CancelToken:wi,VERSION:bi,all:xi,Cancel:Ei,isAxiosError:_i,spread:Si,toFormData:Ri,AxiosHeaders:Ai,HttpStatusCode:Oi,formToJSON:Ni,mergeConfig:Pi}=I;var de,Cr=new Uint8Array(16);function De(){if(!de&&(de=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!de))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return de(Cr)}var b=[];for(let e=0;e<256;++e)b.push((e+256).toString(16).slice(1));function St(e,t=0){return(b[e[t+0]]+b[e[t+1]]+b[e[t+2]]+b[e[t+3]]+"-"+b[e[t+4]]+b[e[t+5]]+"-"+b[e[t+6]]+b[e[t+7]]+"-"+b[e[t+8]]+b[e[t+9]]+"-"+b[e[t+10]]+b[e[t+11]]+b[e[t+12]]+b[e[t+13]]+b[e[t+14]]+b[e[t+15]]).toLowerCase()}var Ur=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Le={randomUUID:Ur};function jr(e,t,r){if(Le.randomUUID&&!t&&!e)return Le.randomUUID();e=e||{};let n=e.random||(e.rng||De)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let o=0;o<16;++o)t[r+o]=n[o];return t}return St(n)}var pe=jr;var kr={makeAxios:e=>I.create({...e}),getRepoStatus:async()=>{},getPastNAncestors:async()=>[],getEnv:e=>{}},v=kr;var U={current_project:null,current_experiment:null},X=null,ve=null,Me=null,Ot=null,Rt=!1,me=class{constructor(t){this.base_url=t,this.token=null,this.session=null,this._reset()}async ping(){try{let t=await this.get("ping");return G===null&&(G=t.data),t.status===200}catch{return!1}}make_long_lived(){this._reset()}set_token(t){t=t.trim(),this.token=t,this._reset()}_reset(){let t={};this.token&&(t.Authorization=`Bearer ${this.token}`),this.session=v.makeAxios({headers:t})}async get(t,r=void 0){return await this.session.get(ze(this.base_url,t),{params:r})}async post(t,r=void 0){return await this.session.post(ze(this.base_url,t),r)}async get_json(t,r=void 0,n=0){let o=n+1;for(let i=0;i<o;i++)try{return(await this.get(`${t}`,r)).data}catch(s){if(i<o-1){console.log(`Retrying API request ${t} ${r} ${s.status} ${s.text}`);continue}throw s}}async post_json(t,r=void 0){return(await this.post(`${t}`,r)).data}},Fe=null;function Nt(){return Fe||(Fe=new me(X)),Fe}var Be=null;function A(){return Be||(Be=new me(Ot)),Be}var G=null;async function Pt(){return G===null&&(G=await A().get_json("ping")),G}var At=class{constructor(t,r,n){this.name=t,this.id=r,this.org_id=n}},Ie="projects";async function Dr(e){let t={name:e,org_id:ve},r=[];if(t&&(r=await A().get_json(Ie,t)),r.length===0&&(r=await A().post_json(Ie,t)),r)return r[0];throw new Error(`Unable to find record in ${Ie}`)}var he=class{constructor(){this.items=[];this.active_flush=Promise.resolve([]);this.active_flush_resolved=!0}log(t){this.items.push(...t),this.active_flush_resolved&&(this.active_flush_resolved=!1,this.active_flush=this.flush_once())}async flush_once(){this.active_flush_resolved=!1;let t=this.items;this.items=[];let r=[];return t.length>0&&(r=(await A().post_json("logs",t)).data),this.items.length>0?this.active_flush=this.flush_once():this.active_flush_resolved=!0,r}async flush(){for(;await this.active_flush,!this.active_flush_resolved;);}};async function Ki(e,t={}){let{experiment:r,description:n,baseExperiment:o,update:i,apiUrl:s,apiKey:u,orgName:f,disableCache:c}=t||{};return await Tt({orgName:f,disableCache:c,apiKey:u,apiUrl:s}),U.current_project=await Dr(e),U.current_experiment=await Fr(U.current_project,{name:r,description:n,update:i,baseExperiment:o}),U.current_experiment}async function Wi(e,t={}){let{dataset:r,description:n,apiUrl:o,apiKey:i,orgName:s,disableCache:u}=t||{};return await Tt({orgName:s,disableCache:u,apiKey:i,apiUrl:o}),await Br(e,{name:r,description:n})}async function Tt(e={}){let{apiUrl:t=v.getEnv("BRAINTRUST_API_URL")||"https://www.braintrustdata.com",apiKey:r=v.getEnv("BRAINTRUST_API_KEY"),orgName:n=void 0,disableCache:o=!1,forceLogin:i=!1}=e||{};if(Rt&&!i)return;X=t;let s=null,u=!1,f=null;if(r!==void 0){let l=(await I.post(ze(X,"/api/apikey/login"),{token:r})).data;Lr(l.org_info,n),f=A(),f.set_token(r),u=await f.ping()}else throw new Error("Please specify an api key. Token based login is not yet implemented in the JS client.");if(!f)throw new Error("Conn should be set at this point (a bug)");u||await f.get("ping"),f.make_long_lived(),Nt().set_token(r),Rt=!0}function Gi(e){if(!U.current_experiment)throw new Error("Not initialized. Please call init() first");return U.current_experiment.log(e)}async function Xi(e={}){if(!U.current_experiment)throw new Error("Not initialized. Please call init() first");return await U.current_experiment.summarize(e)}function Lr(e,t){if(e.length===0)throw new Error("This user is not part of any organizations.");for(let r of e)if(t===void 0||r.name===t){ve=r.id,Me=r.name,Ot=r.api_url;break}if(ve===void 0)throw new Error(`Organization ${t} not found. Must be one of ${e.map(r=>r.name).join(", ")}`)}function ze(...e){return e.map(t=>t.replace(/^\//,"")).join("/")}async function Fr(e,{name:t,description:r,update:n,baseExperiment:o}={name:void 0,description:void 0,baseExperiment:void 0}){let i={project_id:e.id};t&&(i.name=t),r&&(i.description=r),n&&(i.update=n);let s=await v.getRepoStatus();s&&(i.repo_info=s);let u=A(),f;if(o!==void 0){let y=(await u.get("experiments",{project_id:e.id,name:o})).data;if(y.length>0)f=y[0].id;else throw new Error(`Base experiment ${o} not found`)}f===void 0&&(f=(await u.post("experiments-by-commits",{project_id:e.id,commits:await v.getPastNAncestors()})).data.experiment_id),f!==void 0&&(i.base_exp_id=f);let c=(await A().post_json("register-experiment",i))[0],l=(await Pt()).id;return new He(e,c.id,c.name,l)}var He=class{constructor(t,r,n,o){this.project=t,this.id=r,this.name=n,this.user_id=o,this.logger=new he}log({input:t,output:r,expected:n,scores:o,metadata:i,id:s,allowLarge:u=!1,inputs:f}){if(t===void 0&&f===void 0)throw new Error("Either input or inputs (deprecated) must be specified. Prefer input.");if(t!==void 0&&f!==void 0)throw new Error("Only one of input or inputs (deprecated) can be specified. Prefer input.");for(let[l,p]of Object.entries(o)){if(typeof l!="string")throw new Error("score names must be strings");if(typeof p!="number")throw new Error("score values must be numbers");if(p<0||p>1)throw new Error("score values must be between 0 and 1")}if(i!==void 0){for(let l of Object.keys(i))if(typeof l!="string")throw new Error("metadata keys must be strings")}let c={id:s||pe(),inputs:t??f,output:r,expected:n,scores:o,project_id:this.project.id,experiment_id:this.id,user_id:this.user_id,created:new Date().toISOString(),metadata:i};if(!u)for(let[l,p]of Object.entries(c)){let y=JSON.stringify(p);if(y&&y.length>65535)throw new Error(`Events must be less than 64KB in size. Please reduce the size of your ${l}.`)}return this.logger.log([c]),c.id}async summarize(t={}){let{summarizeScores:r=!0,comparisonExperimentId:n=void 0}=t||{};await this.logger.flush();let o=`${X}/app/${encodeURIComponent(Me)}/p/${encodeURIComponent(this.project.name)}`,i=`${o}/${encodeURIComponent(this.name)}`,s,u;if(r){if(n===void 0){let l=(await A().get("/crud/base_experiments",{id:this.id})).data;l.length>0&&(n=l[0].base_exp_id,u=l[0].base_exp_name)}n!==void 0&&(s=await A().get_json("/experiment-comparison",{experiment_id:this.id,base_experiment_id:n},3))}return{projectName:this.project.name,experimentName:this.name,projectUrl:o,experimentUrl:i,comparisonExperimentName:u,scores:s}}};async function Br(e,{name:t,description:r}={name:void 0,description:void 0}){let n={project_name:e,dataset_name:t,description:r},o=await Nt().post_json("api/dataset/register",n),i=o.project,s=o.dataset,u=(await Pt()).id;return new qe(i,s.id,s.name,u)}var qe=class{constructor(t,r,n,o){this.project=t,this.id=r,this.name=n,this.user_id=o,this.logger=new he}log({input:t,output:r,metadata:n,id:o,allowLarge:i=!1}){if(n!==void 0){for(let u of Object.keys(n))if(typeof u!="string")throw new Error("metadata keys must be strings")}let s={id:o||pe(),inputs:t,output:r,project_id:this.project.id,dataset_id:this.id,user_id:this.user_id,created:new Date().toISOString(),metadata:n};if(!i)for(let[u,f]of Object.entries(s)){let c=JSON.stringify(f);if(c&&c.length>65535)throw new Error(`Records must be less than 64KB in size. Please reduce the size of your ${u}.`)}return this.logger.log([s]),s.id}delete(t){let r=this.user_id,n={id:t,project_id:this.project.id,dataset_id:this.id,user_id:r,created:new Date().toISOString(),_object_delete:!0};return this.logger.log([n]),n.id}async summarize(t={}){let{summarizeData:r=!0}=t||{};await this.logger.flush();let n=`${X}/app/${encodeURIComponent(Me)}/p/${encodeURIComponent(this.project.name)}`,o=`${n}/d/${encodeURIComponent(this.name)}`,i;return r&&(i=await A().get_json("dataset-summary",{dataset_id:this.id},3)),{projectName:this.project.name,datasetName:this.name,projectUrl:n,datasetUrl:o,dataSummary:i}}};export{qe as Dataset,He as Experiment,At as Project,Ki as init,Wi as initDataset,Gi as log,Tt as login,Xi as summarize};