import{b as _,a8 as qn,v as s,j as e,w as F,a9 as ve,r as g,aa as je,$ as H,ab as Bn,y as he,z as ke,D as G,F as W,B as Mn,R as Fe,o as Za,ac as Ye,ad as se,ae as en,af as Pi,E as Sa,ag as Nn,a6 as ne,a1 as $n,a2 as Y,ah as Ya,ai as de,aj as sn,ak as Mi,al as ra,am as sa,an as oa,ao as Dn,ap as be,n as el,a as Ni,aq as $i,ar as Vi,as as zi,at as Ai,au as Qi,c as Oi,d as ji,av as qi}from"./vendor-CUDAPm8e.js";import{R as Ke,u as Te,a as we,T as va,P as nl,b as al,M as $a,c as Va,d as Vn,D as Bi,e as Hi,f as A,g as ll,h as me,i as Un,j as hn,k as tl,l as kn,m as bn,n as il,o as Pe,p as ln,C as te,q as Jn,r as qe,s as xa,t as zn,E as Gi,v as Wi,w as Ui,L as pe,x as Ji,y as Xi,F as Zi,z as Yi,A as Rn,B as Se,S as er,G as nr,H as rl,I as ar,J as lr,K as za,N as tr,O as ir,Q as rr,U as sr,V as or,W as dr,X as sl,Y as Sn,Z as cr,_ as ur,$ as mr,a0 as gr,a1 as pr,a2 as nn,a3 as Fa,a4 as ol,a5 as gn,a6 as ka,a7 as un,a8 as Ce,a9 as J,aa as tn,ab as yr,ac as Me,ad as Ka,ae as Le,af as fr,ag as hr,ah as Ta,ai as Re,aj as kr,ak as br,al as Sr,am as ye,an as _e,ao as An,ap as vr,aq as Xn,ar as dl,as as xr,at as Qn,au as vn,av as $e,aw as cl,ax as xn,ay as Fn,az as Fr,aA as Aa,aB as ul,aC as Kr,aD as Tr,aE as Dr,aF as Hn,aG as Cr,aH as Ir,aI as Lr,aJ as Er,aK as Rr,aL as _r,aM as wr,aN as Ue,aO as Pr,aP as Da,aQ as Je,aR as En,aS as Mr,aT as Nr,aU as Zn,aV as $r,aW as Ca,aX as Vr}from"./components-C8sm_r1F.js";import{B as ml,C as fe,D as q,G as pn,H as ue,J as zr,l as Ia,K as Yn,P as Kn,I as N,e as M,M as rn,a as gl,c as oe,p as ea,q as na,t as le,h as K,n as pl,N as Ve,j as D,i as k,L as yn,O as yl,f as O,Q as X,s as ee,S as ae,U as fl,V as hl,W as Ar,X as Qr,Y as La,_ as ze,b as Xe,T as ge,Z as kl,r as _n,d as Ne,$ as Q,E as Ea,z as aa,a0 as Ra,a1 as Or,a2 as la,u as jr,x as _a,a3 as qr}from"./vendor-arizeai-Do2HOmcL.js";import{R as Be,C as On,X as He,Y as xe,a as Ge,T as We,B as fn,A as wn,b as bl,c as wa,L as Sl,d as Br,P as Hr,e as Gr,f as Wr}from"./vendor-recharts-PKRvByVe.js";import{p as Pa,R as ta,n as ia,j as Ur,E as Jr,k as Xr,b as Zr}from"./vendor-codemirror-CrdxOlMs.js";const vl=function(){var n=[{alias:null,args:null,concreteType:"Functionality",kind:"LinkedField",name:"functionality",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"modelInferences",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"ProjectConnection",kind:"LinkedField",name:"projects",plural:!1,selections:[{alias:null,args:null,concreteType:"ProjectEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"project",args:null,concreteType:"Project",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"endTime",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:[],kind:"Fragment",metadata:null,name:"homeLoaderQuery",selections:n,type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[],kind:"Operation",name:"homeLoaderQuery",selections:n},params:{cacheID:"6926e4e720b443f7b7252b60271944e6",id:null,metadata:{},name:"homeLoaderQuery",operationKind:"query",text:`query homeLoaderQuery {
  functionality {
    modelInferences
  }
  projects {
    edges {
      project: node {
        id
        endTime
      }
    }
  }
}
`}}}();vl.hash="a4bbc4917b3217b8254d68ec7c76dbdd";async function _c(n){var l;const a=await _.fetchQuery(Ke,vl,{}).toPromise();if(a!=null&&a.functionality.modelInferences)return qn("/model");if((l=a==null?void 0:a.projects.edges)!=null&&l.length){let t=0,i=null;for(const{project:o}of a.projects.edges)o.endTime!=null&&(t++,i=o.id);if(t>1)return qn("/projects");if(t===1&&i!=null)return qn(`/projects/${i}`);const r=a==null?void 0:a.projects.edges[0].project.id;return qn(`/projects/${r}`)}else throw new Error("No functionality available")}const xl=function(){var n={defaultValue:null,kind:"LocalArgument",name:"endTime"},a={defaultValue:null,kind:"LocalArgument",name:"startTime"},l=[{kind:"Variable",name:"endTime",variableName:"endTime"},{kind:"Variable",name:"startTime",variableName:"startTime"}],t=[{kind:"Literal",name:"first",value:50}],i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},r={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},o={fields:[{kind:"Variable",name:"end",variableName:"endTime"},{kind:"Variable",name:"start",variableName:"startTime"}],kind:"ObjectValue",name:"timeRange"},c={alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},d=[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],u={alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null};return{fragment:{argumentDefinitions:[n,a],kind:"Fragment",metadata:null,name:"ModelPageQuery",selections:[{args:l,kind:"FragmentSpread",name:"ModelSchemaTable_dimensions"},{args:l,kind:"FragmentSpread",name:"ModelEmbeddingsTable_embeddingDimensions"}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[a,n],kind:"Operation",name:"ModelPageQuery",selections:[{alias:null,args:null,concreteType:"Model",kind:"LinkedField",name:"model",plural:!1,selections:[{alias:null,args:t,concreteType:"DimensionConnection",kind:"LinkedField",name:"dimensions",plural:!1,selections:[{alias:null,args:null,concreteType:"DimensionEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"dimension",args:null,concreteType:"Dimension",kind:"LinkedField",name:"node",plural:!1,selections:[i,r,{alias:null,args:null,kind:"ScalarField",name:"type",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"dataType",storageKey:null},{alias:"cardinality",args:[{kind:"Literal",name:"metric",value:"cardinality"},o],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"percentEmpty",args:[{kind:"Literal",name:"metric",value:"percentEmpty"},o],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"min",args:[{kind:"Literal",name:"metric",value:"min"},o],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"mean",args:[{kind:"Literal",name:"metric",value:"mean"},o],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"max",args:[{kind:"Literal",name:"metric",value:"max"},o],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"psi",args:[{kind:"Literal",name:"metric",value:"psi"},o],kind:"ScalarField",name:"driftMetric",storageKey:null}],storageKey:null},c,{alias:null,args:null,concreteType:"Dimension",kind:"LinkedField",name:"node",plural:!1,selections:d,storageKey:null}],storageKey:null},u],storageKey:"dimensions(first:50)"},{alias:null,args:t,filters:null,handle:"connection",key:"ModelSchemaTable_dimensions",kind:"LinkedHandle",name:"dimensions"},{alias:null,args:t,concreteType:"EmbeddingDimensionConnection",kind:"LinkedField",name:"embeddingDimensions",plural:!1,selections:[{alias:null,args:null,concreteType:"EmbeddingDimensionEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"embedding",args:null,concreteType:"EmbeddingDimension",kind:"LinkedField",name:"node",plural:!1,selections:[i,r,{alias:"euclideanDistance",args:[{kind:"Literal",name:"metric",value:"euclideanDistance"},o],kind:"ScalarField",name:"driftMetric",storageKey:null}],storageKey:null},c,{alias:null,args:null,concreteType:"EmbeddingDimension",kind:"LinkedField",name:"node",plural:!1,selections:d,storageKey:null}],storageKey:null},u],storageKey:"embeddingDimensions(first:50)"},{alias:null,args:t,filters:null,handle:"connection",key:"ModelEmbeddingsTable_embeddingDimensions",kind:"LinkedHandle",name:"embeddingDimensions"}],storageKey:null}]},params:{cacheID:"18059ac8df6b3c15d5e4bc04ca2c9877",id:null,metadata:{},name:"ModelPageQuery",operationKind:"query",text:`query ModelPageQuery(
  $startTime: DateTime!
  $endTime: DateTime!
) {
  ...ModelSchemaTable_dimensions_3uKjWt
  ...ModelEmbeddingsTable_embeddingDimensions_3uKjWt
}

fragment ModelEmbeddingsTable_embeddingDimensions_3uKjWt on Query {
  model {
    embeddingDimensions(first: 50) {
      edges {
        embedding: node {
          id
          name
          euclideanDistance: driftMetric(metric: euclideanDistance, timeRange: {start: $startTime, end: $endTime})
        }
        cursor
        node {
          __typename
        }
      }
      pageInfo {
        endCursor
        hasNextPage
      }
    }
  }
}

fragment ModelSchemaTable_dimensions_3uKjWt on Query {
  model {
    dimensions(first: 50) {
      edges {
        dimension: node {
          id
          name
          type
          dataType
          cardinality: dataQualityMetric(metric: cardinality, timeRange: {start: $startTime, end: $endTime})
          percentEmpty: dataQualityMetric(metric: percentEmpty, timeRange: {start: $startTime, end: $endTime})
          min: dataQualityMetric(metric: min, timeRange: {start: $startTime, end: $endTime})
          mean: dataQualityMetric(metric: mean, timeRange: {start: $startTime, end: $endTime})
          max: dataQualityMetric(metric: max, timeRange: {start: $startTime, end: $endTime})
          psi: driftMetric(metric: psi, timeRange: {start: $startTime, end: $endTime})
        }
        cursor
        node {
          __typename
        }
      }
      pageInfo {
        endCursor
        hasNextPage
      }
    }
  }
}
`}}}();xl.hash="b612239336c7638df42037315b00f635";function wc(n){const{referenceInferences:a}=Te(),{timeRange:l}=we(),t=_.useLazyLoadQuery(xl,{startTime:l.start.toISOString(),endTime:l.end.toISOString()});return s("main",{children:[s(va,{children:[e(nl,{}),a?e(al,{inferencesRole:"reference",timeRange:{start:new Date(a.startTime),end:new Date(a.endTime)}}):null]}),e("section",{css:F`
          margin: var(--px-spacing-lg);
        `,children:e(ml,{title:"Model Schema",variant:"compact",bodyStyle:{padding:0},children:s(fe,{children:[e(q,{name:"All",children:s(pn,{children:[e(ue,{title:"Embeddings",id:"embeddings",children:e($a,{model:t})}),e(ue,{title:"Dimensions",id:"dimensions",children:e(Va,{model:t})})]})},"all"),e(q,{name:"Embeddings",children:e($a,{model:t})},"embeddings"),e(q,{name:"Dimensions",children:e(Va,{model:t})},"dimensions")]})})}),e(ve,{})]})}const Fl={fragment:{argumentDefinitions:[],kind:"Fragment",metadata:null,name:"EmbeddingPageModelQuery",selections:[{alias:null,args:null,concreteType:"Model",kind:"LinkedField",name:"model",plural:!1,selections:[{args:null,kind:"FragmentSpread",name:"MetricSelector_dimensions"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[],kind:"Operation",name:"EmbeddingPageModelQuery",selections:[{alias:null,args:null,concreteType:"Model",kind:"LinkedField",name:"model",plural:!1,selections:[{alias:"numericDimensions",args:[{kind:"Literal",name:"include",value:{dataTypes:["numeric"]}}],concreteType:"DimensionConnection",kind:"LinkedField",name:"dimensions",plural:!1,selections:[{alias:null,args:null,concreteType:"DimensionEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:null,args:null,concreteType:"Dimension",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"type",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:'dimensions(include:{"dataTypes":["numeric"]})'}],storageKey:null}]},params:{cacheID:"4ccf476dd862525b059197daccd0d4d9",id:null,metadata:{},name:"EmbeddingPageModelQuery",operationKind:"query",text:`query EmbeddingPageModelQuery {
  model {
    ...MetricSelector_dimensions
  }
}

fragment MetricSelector_dimensions on Model {
  numericDimensions: dimensions(include: {dataTypes: [numeric]}) {
    edges {
      node {
        id
        name
        type
      }
    }
  }
}
`}};Fl.hash="374499f7f8ce6919e4a0a4ecbe380c52";const Kl=function(){var n={defaultValue:null,kind:"LocalArgument",name:"clusterMinSamples"},a={defaultValue:null,kind:"LocalArgument",name:"clusterSelectionEpsilon"},l={defaultValue:null,kind:"LocalArgument",name:"dataQualityMetricColumnName"},t={defaultValue:null,kind:"LocalArgument",name:"fetchDataQualityMetric"},i={defaultValue:null,kind:"LocalArgument",name:"fetchPerformanceMetric"},r={defaultValue:null,kind:"LocalArgument",name:"id"},o={defaultValue:null,kind:"LocalArgument",name:"minClusterSize"},c={defaultValue:null,kind:"LocalArgument",name:"minDist"},d={defaultValue:null,kind:"LocalArgument",name:"nNeighbors"},u={defaultValue:null,kind:"LocalArgument",name:"nSamples"},f={defaultValue:null,kind:"LocalArgument",name:"performanceMetric"},m={defaultValue:null,kind:"LocalArgument",name:"timeRange"},p=[{kind:"Variable",name:"id",variableName:"id"}],y={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},b={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},S={alias:null,args:null,kind:"ScalarField",name:"x",storageKey:null},h={alias:null,args:null,kind:"ScalarField",name:"y",storageKey:null},x=[y,{alias:null,args:null,kind:"ScalarField",name:"eventId",storageKey:null},{alias:null,args:null,concreteType:null,kind:"LinkedField",name:"coordinates",plural:!1,selections:[b,{kind:"InlineFragment",selections:[S,h,{alias:null,args:null,kind:"ScalarField",name:"z",storageKey:null}],type:"Point3D",abstractKey:null},{kind:"InlineFragment",selections:[S,h],type:"Point2D",abstractKey:null}],storageKey:null},{alias:null,args:null,concreteType:"EmbeddingMetadata",kind:"LinkedField",name:"embeddingMetadata",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"linkToData",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"rawData",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"EventMetadata",kind:"LinkedField",name:"eventMetadata",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"predictionId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"predictionLabel",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"actualLabel",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"predictionScore",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"actualScore",storageKey:null}],storageKey:null}],L=[{alias:null,args:null,kind:"ScalarField",name:"primaryValue",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"referenceValue",storageKey:null}],I={kind:"InlineFragment",selections:[{alias:null,args:[{kind:"Variable",name:"clusterMinSamples",variableName:"clusterMinSamples"},{kind:"Variable",name:"clusterSelectionEpsilon",variableName:"clusterSelectionEpsilon"},{kind:"Variable",name:"minClusterSize",variableName:"minClusterSize"},{kind:"Variable",name:"minDist",variableName:"minDist"},{kind:"Variable",name:"nNeighbors",variableName:"nNeighbors"},{kind:"Variable",name:"nSamples",variableName:"nSamples"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],concreteType:"UMAPPoints",kind:"LinkedField",name:"UMAPPoints",plural:!1,selections:[{alias:null,args:null,concreteType:"UMAPPoint",kind:"LinkedField",name:"data",plural:!0,selections:x,storageKey:null},{alias:null,args:null,concreteType:"UMAPPoint",kind:"LinkedField",name:"referenceData",plural:!0,selections:x,storageKey:null},{alias:null,args:null,concreteType:"UMAPPoint",kind:"LinkedField",name:"corpusData",plural:!0,selections:x,storageKey:null},{alias:null,args:null,concreteType:"Cluster",kind:"LinkedField",name:"clusters",plural:!0,selections:[y,{alias:null,args:null,kind:"ScalarField",name:"eventIds",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"driftRatio",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"primaryToCorpusRatio",storageKey:null},{condition:"fetchDataQualityMetric",kind:"Condition",passingValue:!0,selections:[{alias:null,args:[{fields:[{kind:"Variable",name:"columnName",variableName:"dataQualityMetricColumnName"},{kind:"Literal",name:"metric",value:"mean"}],kind:"ObjectValue",name:"metric"}],concreteType:"DatasetValues",kind:"LinkedField",name:"dataQualityMetric",plural:!1,selections:L,storageKey:null}]},{condition:"fetchPerformanceMetric",kind:"Condition",passingValue:!0,selections:[{alias:null,args:[{fields:[{kind:"Variable",name:"metric",variableName:"performanceMetric"}],kind:"ObjectValue",name:"metric"}],concreteType:"DatasetValues",kind:"LinkedField",name:"performanceMetric",plural:!1,selections:L,storageKey:null}]}],storageKey:null},{alias:null,args:null,concreteType:"Retrieval",kind:"LinkedField",name:"contextRetrievals",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"queryId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"documentId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"relevance",storageKey:null}],storageKey:null}],storageKey:null}],type:"EmbeddingDimension",abstractKey:null};return{fragment:{argumentDefinitions:[n,a,l,t,i,r,o,c,d,u,f,m],kind:"Fragment",metadata:null,name:"EmbeddingPageUMAPQuery",selections:[{alias:"embedding",args:p,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[I],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[r,m,c,d,u,o,n,a,t,l,i,f],kind:"Operation",name:"EmbeddingPageUMAPQuery",selections:[{alias:"embedding",args:p,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[b,I,{kind:"TypeDiscriminator",abstractKey:"__isNode"},y],storageKey:null}]},params:{cacheID:"d30210c52f86b9d9a7ac958f866aa93e",id:null,metadata:{},name:"EmbeddingPageUMAPQuery",operationKind:"query",text:`query EmbeddingPageUMAPQuery(
  $id: GlobalID!
  $timeRange: TimeRange!
  $minDist: Float!
  $nNeighbors: Int!
  $nSamples: Int!
  $minClusterSize: Int!
  $clusterMinSamples: Int!
  $clusterSelectionEpsilon: Float!
  $fetchDataQualityMetric: Boolean!
  $dataQualityMetricColumnName: String
  $fetchPerformanceMetric: Boolean!
  $performanceMetric: PerformanceMetric!
) {
  embedding: node(id: $id) {
    __typename
    ... on EmbeddingDimension {
      UMAPPoints(timeRange: $timeRange, minDist: $minDist, nNeighbors: $nNeighbors, nSamples: $nSamples, minClusterSize: $minClusterSize, clusterMinSamples: $clusterMinSamples, clusterSelectionEpsilon: $clusterSelectionEpsilon) {
        data {
          id
          eventId
          coordinates {
            __typename
            ... on Point3D {
              x
              y
              z
            }
            ... on Point2D {
              x
              y
            }
          }
          embeddingMetadata {
            linkToData
            rawData
          }
          eventMetadata {
            predictionId
            predictionLabel
            actualLabel
            predictionScore
            actualScore
          }
        }
        referenceData {
          id
          eventId
          coordinates {
            __typename
            ... on Point3D {
              x
              y
              z
            }
            ... on Point2D {
              x
              y
            }
          }
          embeddingMetadata {
            linkToData
            rawData
          }
          eventMetadata {
            predictionId
            predictionLabel
            actualLabel
            predictionScore
            actualScore
          }
        }
        corpusData {
          id
          eventId
          coordinates {
            __typename
            ... on Point3D {
              x
              y
              z
            }
            ... on Point2D {
              x
              y
            }
          }
          embeddingMetadata {
            linkToData
            rawData
          }
          eventMetadata {
            predictionId
            predictionLabel
            actualLabel
            predictionScore
            actualScore
          }
        }
        clusters {
          id
          eventIds
          driftRatio
          primaryToCorpusRatio
          dataQualityMetric(metric: {columnName: $dataQualityMetricColumnName, metric: mean}) @include(if: $fetchDataQualityMetric) {
            primaryValue
            referenceValue
          }
          performanceMetric(metric: {metric: $performanceMetric}) @include(if: $fetchPerformanceMetric) {
            primaryValue
            referenceValue
          }
        }
        contextRetrievals {
          queryId
          documentId
          relevance
        }
      }
    }
    __isNode: __typename
    id
  }
}
`}}}();Kl.hash="f1ee7ce02317f1c3fe96b77af405095f";function Yr(){const{theme:n}=Vn();return g.useMemo(()=>n==="light"?Bi:Hi,[n])}function es(){const{embeddingDimensionId:n}=je();if(!n)throw new Error("Missing embeddingDimensionId in URL params");return n}const Tl={euclideanDistance:{name:"Euclidean Distance",shortName:"Euc. Distance",definition:"Euclidean distance over time captures how much your primary inferences's embeddings are drifting from the reference data. Euclidean distance of the embeddings is calculated by taking the centroid of the embedding vectors for each inferences and calculating the distance between the two centroids."},queryDistance:{name:"Query Distance",shortName:"Query Distance",definition:"The query distance is the euclidean distance of the centroid of queries from the centroid of the corpus."},accuracyScore:{name:"Accuracy Score",shortName:"Accuracy",definition:"Accuracy classification score. In multi-label classification, this function computes subset accuracy: the set of labels predicted for a sample must exactly match the corresponding set of labels in the ground truth."}};function Ze(n){const a=Tl[n];return a!=null?a.shortName:n}function da(n){const a=Tl[n];return a&&a.definition!=null&&a.definition||null}function on(n){return`${n.column}:${n.dir}`}function ns(){const{referenceInferences:n}=Te(),a=!!n,l=A(d=>d.clusterSort),t=A(d=>d.setClusterSort),[i,r]=g.useState(!1),o=g.useMemo(()=>{const d=[];return a&&d.push({label:"Most drift",value:on({column:"driftRatio",dir:"desc"})}),[...d,{label:"Largest clusters",value:on({column:"size",dir:"desc"})},{label:"Smallest clusters",value:on({column:"size",dir:"asc"})},{label:"Highest metric value",value:on({column:"primaryMetricValue",dir:"desc"})},{label:"Lowest metric value",value:on({column:"primaryMetricValue",dir:"asc"})}]},[a]),c=on(l);return e("div",{css:d=>F`
        .ac-action-button {
          background: none;
          border: none;
          color: ${"var(--ac-global-text-color-700)"};
          font-size: ${d.typography.sizes.small.fontSize}px;
          line-height: ${d.typography.sizes.small.lineHeight}px;
          cursor: pointer;
          outline: none;
          &:hover {
            color: var(--ac-global-text-color-900);
          }
        }
      `,children:s(Kn,{placement:"bottom right","aria-label":"Sort clusters by",isOpen:i,onOpenChange:d=>r(d),children:[s(zr,{children:["Sort",e("span",{"aria-hidden":!0,"data-testid":"dropdown-caret",css:F`
              margin-left: var(--px-spacing-sm);
              border-bottom-color: #0000;
              border-left-color: #0000;
              border-right-color: #0000;
              border-style: solid;
              border-width: 3px 3px 0;
              content: "";
              display: inline-block;
              height: 0;
              vertical-align: middle;
              width: 0;
            `})]}),e(Ia,{children:e(Yn,{style:{width:200},selectedKeys:[c],selectionMode:"single",items:o,onSelectionChange:d=>{if(d instanceof Set&&d.size>0){const[u]=d.values(),[f,m]=u.split(":");t({column:f,dir:m})}r(!1)},children:d=>e(H,{children:d.label},d.value)})})]})})}const Dl=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"clusters"}],a=[{alias:null,args:[{kind:"Variable",name:"clusters",variableName:"clusters"}],concreteType:"ExportedFile",kind:"LinkedField",name:"exportClusters",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"fileName",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"EmbeddingActionMenuExportClustersMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"EmbeddingActionMenuExportClustersMutation",selections:a},params:{cacheID:"1bef6586fcb3d6eb7034204fbe49633c",id:null,metadata:{},name:"EmbeddingActionMenuExportClustersMutation",operationKind:"mutation",text:`mutation EmbeddingActionMenuExportClustersMutation(
  $clusters: [ClusterInput!]!
) {
  exportClusters(clusters: $clusters) {
    fileName
  }
}
`}}}();Dl.hash="b5ff2517dbb0d19a1b24dea1796a3576";function as(){const n=A(r=>r.clusters),{notifyError:a,notifySuccess:l}=ll(),[t,i]=_.useMutation(Dl);return e(rn,{align:"end",buttonSize:"compact",icon:i?e(N,{svg:e(M.LoadingOutline,{})}):null,onAction:r=>{switch(r){case"export_cluster":t({variables:{clusters:n.map(o=>({eventIds:o.eventIds,id:o.id}))},onCompleted:o=>{const{fileName:c}=o.exportClusters;l({title:"Clusters Exported",message:"dataframe is available via px.active_session().exports or can be downloaded by clicking below",action:{text:"Download",onClick:()=>{window.open(`/exports?filename=${c}`,"_self")}}})},onError:o=>{a({title:"Failed to export clusters",message:`Failed to export clusters: ${o.message}`})}});break}},children:s(H,{children:[e(N,{svg:e(M.Download,{})}),"Export clusters"]},"export_cluster")})}const Cl={argumentDefinitions:[],kind:"Fragment",metadata:null,name:"MetricSelector_dimensions",selections:[{alias:"numericDimensions",args:[{kind:"Literal",name:"include",value:{dataTypes:["numeric"]}}],concreteType:"DimensionConnection",kind:"LinkedField",name:"dimensions",plural:!1,selections:[{alias:null,args:null,concreteType:"DimensionEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:null,args:null,concreteType:"Dimension",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"type",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:'dimensions(include:{"dataTypes":["numeric"]})'}],type:"Model",abstractKey:null};Cl.hash="55d03de16503d7af254c17cef7d18ee0";const mn=":";function ls(n){return["drift","performance","dataQuality","retrieval"].includes(n)}function Cn(n){const{type:a,metric:l}=n;switch(a){case"drift":return`${a}${mn}${l}`;case"retrieval":return`${a}${mn}${l}`;case"performance":return`${a}${mn}${l}`;case"dataQuality":{const{name:t}=n.dimension;return`${a}${mn}${l}${mn}${t}`}default:me()}}function ts({metricKey:n,dimensions:a}){const[l,t,i]=n.split(mn);if(!ls(l))throw new Error(`Invalid metric type: ${l}`);switch(l){case"drift":return{type:l,metric:t};case"retrieval":return{type:l,metric:t};case"performance":return{type:l,metric:t};case"dataQuality":{const r=a.find(o=>o.name===i);if(!r)throw new Error(`Invalid dimension name: ${i}`);return{type:l,metric:t,dimension:r}}default:me()}}const is=s(na,{variant:"info",children:[e(oe,{level:4,children:"Analysis Metric"}),s(ea,{children:[e("p",{children:"Select a metric to drive the analysis of your embeddings."}),e("p",{children:"To analyze the the drift between your two inferencess, select a drift metric and the UI will highlight areas of high drift."}),e("p",{children:"To analyze the quality of your embeddings, select a dimension data quality metric by which to analyze the point cloud. The UI will highlight areas where the data quality is degrading."})]})]});function rs({model:n}){const[,a]=g.useTransition(),l=_.useFragment(Cl,n),{referenceInferences:t,corpusInferences:i}=Te(),r=!!t,o=!!i,c=A(y=>y.metric),d=A(y=>y.loading),u=A(y=>y.setMetric),f=l.numericDimensions.edges.map(y=>y.node),m=f.length>0,p=g.useCallback(y=>{const b=ts({metricKey:y,dimensions:f});a(()=>{u(b)})},[u,f,a]);return s(gl,{label:"metric",labelExtra:is,selectedKey:c?Cn(c):void 0,onSelectionChange:p,placeholder:"Select a metric...",isDisabled:d,children:[r?e(Bn,{title:"Drift",children:e(H,{children:"Euclidean Distance"},Cn({type:"drift",metric:"euclideanDistance"}))}):null,o?e(Bn,{title:"Retrieval",children:e(H,{children:"Query Distance"},Cn({type:"retrieval",metric:"queryDistance"}))}):null,e(Bn,{title:"Performance",children:e(H,{children:"Accuracy Score"},Cn({type:"performance",metric:"accuracyScore"}))}),m?e(Bn,{title:"Data Quality",children:f.map(y=>e(H,{children:`${y.name} avg`},Cn({type:"dataQuality",metric:"average",dimension:y})))}):null]})}const Il=function(){var n={defaultValue:null,kind:"LocalArgument",name:"countGranularity"},a={defaultValue:null,kind:"LocalArgument",name:"dimensionId"},l={defaultValue:null,kind:"LocalArgument",name:"embeddingDimensionId"},t={defaultValue:null,kind:"LocalArgument",name:"fetchDataQuality"},i={defaultValue:null,kind:"LocalArgument",name:"fetchDrift"},r={defaultValue:null,kind:"LocalArgument",name:"fetchPerformance"},o={defaultValue:null,kind:"LocalArgument",name:"fetchQueryDistance"},c={defaultValue:null,kind:"LocalArgument",name:"metricGranularity"},d={defaultValue:null,kind:"LocalArgument",name:"performanceMetric"},u={defaultValue:null,kind:"LocalArgument",name:"timeRange"},f=[{kind:"Variable",name:"id",variableName:"embeddingDimensionId"}],m={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},p={kind:"Variable",name:"granularity",variableName:"metricGranularity"},y={kind:"Variable",name:"timeRange",variableName:"timeRange"},b=[p,{kind:"Literal",name:"metric",value:"euclideanDistance"},y],S=[{alias:null,args:null,concreteType:"TimeSeriesDataPoint",kind:"LinkedField",name:"data",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"timestamp",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}],storageKey:null}],h={kind:"InlineFragment",selections:[{condition:"fetchDrift",kind:"Condition",passingValue:!0,selections:[{alias:"euclideanDistanceTimeSeries",args:b,concreteType:"DriftTimeSeries",kind:"LinkedField",name:"driftTimeSeries",plural:!1,selections:S,storageKey:null}]},{condition:"fetchQueryDistance",kind:"Condition",passingValue:!0,selections:[{alias:null,args:b,concreteType:"DriftTimeSeries",kind:"LinkedField",name:"retrievalMetricTimeSeries",plural:!1,selections:S,storageKey:null}]},{alias:"trafficTimeSeries",args:[{kind:"Variable",name:"granularity",variableName:"countGranularity"},{kind:"Literal",name:"metric",value:"count"},y],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:S,storageKey:null}],type:"EmbeddingDimension",abstractKey:null},x=[{kind:"Variable",name:"id",variableName:"dimensionId"}],L={kind:"InlineFragment",selections:[{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:[p,{kind:"Literal",name:"metric",value:"mean"},y],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:S,storageKey:null}],type:"Dimension",abstractKey:null},I={alias:null,args:null,concreteType:"Model",kind:"LinkedField",name:"model",plural:!1,selections:[{condition:"fetchPerformance",kind:"Condition",passingValue:!0,selections:[{alias:null,args:[p,{fields:[{kind:"Variable",name:"metric",variableName:"performanceMetric"}],kind:"ObjectValue",name:"metric"},y],concreteType:"PerformanceTimeSeries",kind:"LinkedField",name:"performanceTimeSeries",plural:!1,selections:S,storageKey:null}]}],storageKey:null},C={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null};return{fragment:{argumentDefinitions:[n,a,l,t,i,r,o,c,d,u],kind:"Fragment",metadata:null,name:"MetricTimeSeriesQuery",selections:[{alias:"embedding",args:f,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[m,h],storageKey:null},{condition:"fetchDataQuality",kind:"Condition",passingValue:!0,selections:[{alias:"dimension",args:x,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[L],storageKey:null}]},I],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[l,u,c,n,i,o,t,a,r,d],kind:"Operation",name:"MetricTimeSeriesQuery",selections:[{alias:"embedding",args:f,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[C,m,h],storageKey:null},{condition:"fetchDataQuality",kind:"Condition",passingValue:!0,selections:[{alias:"dimension",args:x,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[C,L,{kind:"TypeDiscriminator",abstractKey:"__isNode"},m],storageKey:null}]},I]},params:{cacheID:"a68a8204bf7fdd13e6915b338d4b5497",id:null,metadata:{},name:"MetricTimeSeriesQuery",operationKind:"query",text:`query MetricTimeSeriesQuery(
  $embeddingDimensionId: GlobalID!
  $timeRange: TimeRange!
  $metricGranularity: Granularity!
  $countGranularity: Granularity!
  $fetchDrift: Boolean!
  $fetchQueryDistance: Boolean!
  $fetchDataQuality: Boolean!
  $dimensionId: GlobalID!
  $fetchPerformance: Boolean!
  $performanceMetric: PerformanceMetric!
) {
  embedding: node(id: $embeddingDimensionId) {
    __typename
    id
    ... on EmbeddingDimension {
      euclideanDistanceTimeSeries: driftTimeSeries(metric: euclideanDistance, timeRange: $timeRange, granularity: $metricGranularity) @include(if: $fetchDrift) {
        data {
          timestamp
          value
        }
      }
      retrievalMetricTimeSeries(metric: euclideanDistance, timeRange: $timeRange, granularity: $metricGranularity) @include(if: $fetchQueryDistance) {
        data {
          timestamp
          value
        }
      }
      trafficTimeSeries: dataQualityTimeSeries(metric: count, timeRange: $timeRange, granularity: $countGranularity) {
        data {
          timestamp
          value
        }
      }
    }
  }
  dimension: node(id: $dimensionId) @include(if: $fetchDataQuality) {
    __typename
    ... on Dimension {
      name
      dataQualityTimeSeries(metric: mean, timeRange: $timeRange, granularity: $metricGranularity) {
        data {
          timestamp
          value
        }
      }
    }
    __isNode: __typename
    id
  }
  model {
    performanceTimeSeries(metric: {metric: $performanceMetric}, timeRange: $timeRange, granularity: $metricGranularity) @include(if: $fetchPerformance) {
      data {
        timestamp
        value
      }
    }
  }
}
`}}}();Il.hash="f31abad2141a5a1c461ef2a598ffa4f3";const Qa=new Intl.NumberFormat([],{maximumFractionDigits:2}),Ll=()=>{const n=Pe(),a=n.blue400,l=n.gray500;return{color:a,barColor:l}};function ss({active:n,payload:a,label:l}){var r,o,c;const{color:t,barColor:i}=Ll();if(n&&a&&a.length){const d=((r=a[1])==null?void 0:r.value)??null,u=((o=a[0])==null?void 0:o.value)??null,f=typeof d=="number"?Qa.format(d):"--",m=typeof u=="number"?Qa.format(u):"--";return s(qe,{children:[e(K,{weight:"heavy",textSize:"medium",children:`${ln(new Date(l))}`}),e(te,{color:t,name:((c=a[1])==null?void 0:c.payload.metricName)??"Metric",value:f}),e(te,{color:i,shape:"square",name:"Count",value:m}),e(Jn,{}),s("div",{css:F`
            display: flex;
            flex-direction: row;
            align-items: center;
            color: var(--ac-global-color-primary);
            gap: var(--px-spacing-sm);

            margin-top: var(--px-spacing-sm);
          `,children:[e(N,{svg:e(pl,{})}),e("span",{children:"Click to view the point cloud at this time"})]})]})}return null}function os(n){switch(n.type){case"drift":return"Embedding Drift";case"performance":return"Model Performance";case"dataQuality":return"Data Quality";case"retrieval":return"Query Distance";default:me()}}function ds(n){if(n)switch(n.type){case"drift":return Ze(n.metric);case"performance":return Ze(n.metric);case"dataQuality":return`${n.dimension.name} avg`;case"retrieval":return Ze(n.metric);default:me()}else return"Count"}function cs(n){switch(n.type){case"drift":return da(n.metric);case"performance":return da(n.metric);case"dataQuality":return null;case"retrieval":return da(n.metric);default:me()}}function us({embeddingDimensionId:n}){const a=A(v=>v.metric),l=a.type==="drift",t=a.type==="retrieval",i=a.type==="dataQuality",r=a.type==="performance",{timeRange:o}=we(),{selectedTimestamp:c,setSelectedTimestamp:d}=Un(),u=hn(o),f=_.useLazyLoadQuery(Il,{embeddingDimensionId:n,timeRange:{start:o.start.toISOString(),end:o.end.toISOString()},metricGranularity:tl(o),countGranularity:u,fetchDrift:l,fetchQueryDistance:t,fetchDataQuality:i,fetchPerformance:r,dimensionId:a.type==="dataQuality"?a.dimension.id:n,performanceMetric:a.type==="performance"?a.metric:"accuracyScore"}),m=kn({samplingIntervalMinutes:u.samplingIntervalMinutes}),p=g.useCallback(v=>{const{activePayload:T}=v;if(T!=null&&T.length>0){const P=T[0].payload;d(new Date(P.timestamp))}},[d]),y=ms({data:f,metric:a}),S=gs(f).reduce((v,T)=>(v[T.timestamp]=T.value,v),{})??{},h=y.map(v=>{const T=S[v.timestamp];return{...v,traffic:T,timestamp:new Date(v.timestamp).getTime()}}),x=ds(a),L=cs(a),{color:I,barColor:C}=Ll();return s("section",{css:F`
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        h3 {
          padding: var(--px-spacing-sm) var(--px-spacing-lg) 0
            var(--px-spacing-lg);
          flex: none;
          display: flex;
          flex-direction: row;
          align-items: center;
          gap: var(--px-spacing-sm);
        }
        & > div {
          flex: 1 1 auto;
          width: 100%;
          overflow: hidden;
        }
      `,children:[s(oe,{level:3,children:[os(a),L!=null?s(na,{children:[e(oe,{level:4,children:x}),e(ea,{children:L})]}):null]}),e("div",{children:e(Be,{width:"100%",height:"100%",children:s(On,{data:h,margin:{top:25,right:18,left:18,bottom:10},onClick:p,children:[s("defs",{children:[s("linearGradient",{id:"colorUv",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:I,stopOpacity:.8}),e("stop",{offset:"95%",stopColor:I,stopOpacity:0})]}),s("linearGradient",{id:"barColor",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:C,stopOpacity:.3}),e("stop",{offset:"95%",stopColor:C,stopOpacity:0})]})]}),e(He,{...bn,tickFormatter:v=>m(new Date(v)),style:{fill:"var(--ac-global-text-color-700)"}}),e(xe,{stroke:le.colors.gray200,label:{value:x,angle:-90,position:"insideLeft",style:{textAnchor:"middle",fill:"var(--ac-global-text-color-900)"}},style:{fill:"var(--ac-global-text-color-700)"}}),e(xe,{yAxisId:"right",orientation:"right",label:{value:"Count",angle:90,position:"insideRight",style:{textAnchor:"middle",fill:"var(--ac-global-text-color-900)"}},style:{fill:"var(--ac-global-text-color-700)"}}),e(Ge,{strokeDasharray:"4 4",stroke:le.colors.gray200,strokeOpacity:.5}),e(We,{content:e(ss,{})}),e(fn,{yAxisId:"right",dataKey:"traffic",fill:"url(#barColor)",spacing:5}),e(wn,{type:"monotone",dataKey:"value",stroke:I,fillOpacity:1,fill:"url(#colorUv)"}),c!=null?e(bl,{...il,x:c.getTime()}):null]})})})]})}function ms({data:n,metric:a}){var l,t,i,r,o,c;if(((l=n.embedding.euclideanDistanceTimeSeries)==null?void 0:l.data)!=null&&n.embedding.euclideanDistanceTimeSeries.data.length>0)return n.embedding.euclideanDistanceTimeSeries.data.map(d=>({metricName:Ze(a.metric),...d}));if(((t=n.embedding.retrievalMetricTimeSeries)==null?void 0:t.data)!=null&&n.embedding.retrievalMetricTimeSeries.data.length>0)return n.embedding.retrievalMetricTimeSeries.data.map(d=>({metricName:Ze(a.metric),...d}));if(n.dimension&&((r=(i=n.dimension)==null?void 0:i.dataQualityTimeSeries)==null?void 0:r.data)!=null&&n.dimension.dataQualityTimeSeries.data.length>0){const d=n.dimension.name||"unknown";return n.dimension.dataQualityTimeSeries.data.map(u=>({metricName:`${d} avg`,...u}))}else{if(n.model&&((o=n.model.performanceTimeSeries)==null?void 0:o.data)!=null&&n.model.performanceTimeSeries.data.length>0)return n.model.performanceTimeSeries.data.map(d=>({metricName:Ze(a.metric),...d}));if(((c=n.embedding.trafficTimeSeries)==null?void 0:c.data)!=null)return n.embedding.trafficTimeSeries.data.map(d=>({metricName:"Count",...d}))}return[]}function gs(n){var a;return((a=n.embedding.trafficTimeSeries)==null?void 0:a.data)!=null?[...n.embedding.trafficTimeSeries.data]:[]}const El=function(){var n={defaultValue:null,kind:"LocalArgument",name:"corpusEventIds"},a={defaultValue:null,kind:"LocalArgument",name:"primaryEventIds"},l={defaultValue:null,kind:"LocalArgument",name:"referenceEventIds"},t=[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,concreteType:"DimensionWithValue",kind:"LinkedField",name:"dimensions",plural:!0,selections:[{alias:null,args:null,concreteType:"Dimension",kind:"LinkedField",name:"dimension",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"type",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"EventMetadata",kind:"LinkedField",name:"eventMetadata",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"predictionId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"predictionLabel",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"predictionScore",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"actualLabel",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"actualScore",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PromptResponse",kind:"LinkedField",name:"promptAndResponse",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"prompt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"response",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"documentText",storageKey:null}],i=[{alias:null,args:null,concreteType:"Model",kind:"LinkedField",name:"model",plural:!1,selections:[{alias:null,args:null,concreteType:"Inferences",kind:"LinkedField",name:"primaryInferences",plural:!1,selections:[{alias:null,args:[{kind:"Variable",name:"eventIds",variableName:"primaryEventIds"}],concreteType:"Event",kind:"LinkedField",name:"events",plural:!0,selections:t,storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"Inferences",kind:"LinkedField",name:"referenceInferences",plural:!1,selections:[{alias:null,args:[{kind:"Variable",name:"eventIds",variableName:"referenceEventIds"}],concreteType:"Event",kind:"LinkedField",name:"events",plural:!0,selections:t,storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"Inferences",kind:"LinkedField",name:"corpusInferences",plural:!1,selections:[{alias:null,args:[{kind:"Variable",name:"eventIds",variableName:"corpusEventIds"}],concreteType:"Event",kind:"LinkedField",name:"events",plural:!0,selections:t,storageKey:null}],storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:[n,a,l],kind:"Fragment",metadata:null,name:"PointSelectionPanelContentQuery",selections:i,type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[a,l,n],kind:"Operation",name:"PointSelectionPanelContentQuery",selections:i},params:{cacheID:"8b48064eba35d0d6c8dc834c2f7795c0",id:null,metadata:{},name:"PointSelectionPanelContentQuery",operationKind:"query",text:`query PointSelectionPanelContentQuery(
  $primaryEventIds: [ID!]!
  $referenceEventIds: [ID!]!
  $corpusEventIds: [ID!]!
) {
  model {
    primaryInferences {
      events(eventIds: $primaryEventIds) {
        id
        dimensions {
          dimension {
            name
            type
          }
          value
        }
        eventMetadata {
          predictionId
          predictionLabel
          predictionScore
          actualLabel
          actualScore
        }
        promptAndResponse {
          prompt
          response
        }
        documentText
      }
    }
    referenceInferences {
      events(eventIds: $referenceEventIds) {
        id
        dimensions {
          dimension {
            name
            type
          }
          value
        }
        eventMetadata {
          predictionId
          predictionLabel
          predictionScore
          actualLabel
          actualScore
        }
        promptAndResponse {
          prompt
          response
        }
        documentText
      }
    }
    corpusInferences {
      events(eventIds: $corpusEventIds) {
        id
        dimensions {
          dimension {
            name
            type
          }
          value
        }
        eventMetadata {
          predictionId
          predictionLabel
          predictionScore
          actualLabel
          actualScore
        }
        promptAndResponse {
          prompt
          response
        }
        documentText
      }
    }
  }
}
`}}}();El.hash="4bd627481610322f2acbcf73dfbfaadc";const Oa=F`
  margin: var(--px-spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--px-spacing-med);
  & > div {
    display: flex;
    flex-direction: row;
    dt {
      font-weight: bold;
      flex: none;
      width: 130px;
    }
    dd {
      flex: 1 1 auto;
      margin-inline-start: 0;
    }
  }
`;function In(n){return e("div",{css:F`
        max-height: 200px;
        overflow-y: auto;
      `,children:e("pre",{css:F`
          padding: var(--px-spacing-lg);
          color: var(--ac-global-text-color-900);
          white-space: normal;
          margin: 0;
        `,children:n.children})})}function ps({event:n}){const a=n.retrievedDocuments&&n.retrievedDocuments.length>0,l=!n.id.includes("CORPUS");return s("section",{css:F`
        height: 100%;
        overflow-y: auto;
      `,children:[e(ks,{event:n}),s(pn,{children:[l?e(ue,{id:"prediction",title:"Prediction Details",children:s("dl",{css:Oa,children:[n.predictionId!=null&&s("div",{children:[e("dt",{children:"Prediction ID"}),e("dd",{css:F`
                      display: flex;
                      align-items: center;
                    `,children:n.predictionId})]}),n.predictionLabel!=null&&s("div",{children:[e("dt",{children:"Prediction Label"}),e("dd",{children:n.predictionLabel})]}),n.predictionScore!=null&&s("div",{children:[e("dt",{children:"Prediction Score"}),e("dd",{children:n.predictionScore})]}),n.actualLabel!=null&&s("div",{children:[e("dt",{children:"Actual Label"}),e("dd",{children:n.actualLabel})]}),n.actualScore!=null&&s("div",{children:[e("dt",{children:"Actual Score"}),e("dd",{children:n.actualScore})]})]})}):e(ue,{id:"document",title:"Document Details",children:e("dl",{css:Oa,children:n.predictionId!=null&&s("div",{children:[e("dt",{children:"Document ID"}),e("dd",{css:F`
                      display: flex;
                      align-items: center;
                    `,children:n.predictionId})]})})}),e(ue,{id:"dimensions",title:"Dimensions",children:e(fs,{dimensions:n.dimensions})}),a&&e(ue,{id:"retrievals",title:"Retrieved Documents",titleExtra:e(Ve,{variant:"light",children:n.retrievedDocuments.length}),children:e("ul",{css:F`
                padding: var(--px-spacing-med);
                li + li {
                  margin-top: var(--px-spacing-med);
                }
              `,children:n.retrievedDocuments.map(t=>e("li",{children:e(ys,{document:t})},t.id))})})]})]})}function ys({document:n}){return e(D,{borderRadius:"medium",backgroundColor:"light",children:s(k,{direction:"column",children:[e(D,{width:"100%",borderBottomWidth:"thin",borderBottomColor:"dark",children:s(k,{direction:"row",justifyContent:"space-between",margin:"size-100",alignItems:"center",children:[s(k,{direction:"row",gap:"size-50",alignItems:"center",children:[e(N,{svg:e(M.FileOutline,{})}),s(oe,{level:4,children:["document ",n.id]})]}),typeof n.relevance=="number"&&e(yn,{color:"blue",children:`relevance ${xa(n.relevance)}`})]})}),e("pre",{css:F`
            padding: var(--px-spacing-lg);
            white-space: normal;
            margin: 0;
          `,children:n.text})]})})}function fs({dimensions:n}){const a=g.useMemo(()=>n.map(i=>({name:i.dimension.name,type:i.dimension.type,value:i.value??"--"})),[n]),l=g.useMemo(()=>[{header:()=>"Name",accessorKey:"name"},{header:()=>"Type",accessorKey:"type"},{header:()=>"Value",accessorKey:"value"}],[]),t=he({columns:l,data:a,getCoreRowModel:ke()});return s("table",{css:zn,children:[e("thead",{children:t.getHeaderGroups().map(i=>e("tr",{children:i.headers.map(r=>e("th",{colSpan:r.colSpan,children:r.isPlaceholder?null:e("div",{children:G(r.column.columnDef.header,r.getContext())})},r.id))},i.id))}),t.getCoreRowModel().rows.length?e("tbody",{children:t.getRowModel().rows.map(i=>e("tr",{children:i.getVisibleCells().map(r=>e("td",{children:G(r.column.columnDef.cell,r.getContext())},r.id))},i.id))}):e(bs,{})]})}function hs({dataUrl:n}){const a=Wi(n),l=Ui(n);return a?e("video",{src:n,controls:!0,css:F`
          width: 100%;
          height: 500px;
          background-color: black;
        `}):l?e("audio",{src:n,controls:!0,autoPlay:!0}):e("img",{src:n,alt:"event image",width:"100%",height:"200px",css:F`
        object-fit: contain;
        background-color: black;
      `})}function ks({event:n}){const a=n.linkToData||void 0,l=n.rawData,t=n.prompt||n.response?{prompt:n.prompt,response:n.response}:null,i=n.documentText;let r=null;return a?r=s(k,{direction:"column",children:[e(hs,{dataUrl:a}),l&&e(pn,{children:e(ue,{id:"raw",title:"Raw Data",children:e(In,{children:l})})})]}):i?r=e(pn,{children:e(ue,{id:"document",title:"Document",children:e(In,{children:i})})}):t?r=s(pn,{children:[e(ue,{id:"prompt",title:"Prompt",children:e(In,{children:t.prompt})}),e(ue,{id:"response",title:"Response",children:e(In,{children:t.response})})]}):n.rawData&&n.rawData&&n.rawData,r}function bs(){return e("tbody",{className:"is-empty",children:e("tr",{children:e("td",{colSpan:100,css:n=>F`
            text-align: center;
            padding: ${n.spacing.margin24}px ${n.spacing.margin24}px !important;
          `,children:e(Gi,{graphicKey:"documents",message:"This embedding has no associated dimensions"})})})})}const Rl=function(){var n=[{alias:null,args:null,concreteType:"Model",kind:"LinkedField",name:"model",plural:!1,selections:[{alias:null,args:null,concreteType:"ExportedFile",kind:"LinkedField",name:"exportedFiles",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"fileName",storageKey:null}],storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:[],kind:"Fragment",metadata:null,name:"ExportSelectionButtonExportsQuery",selections:n,type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[],kind:"Operation",name:"ExportSelectionButtonExportsQuery",selections:n},params:{cacheID:"2f7e3554305121746dc799b6a8d120da",id:null,metadata:{},name:"ExportSelectionButtonExportsQuery",operationKind:"query",text:`query ExportSelectionButtonExportsQuery {
  model {
    exportedFiles {
      fileName
    }
  }
}
`}}}();Rl.hash="7e6db431afe21f137e54505645c787f4";const _l=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"eventIds"}],a=[{alias:null,args:[{kind:"Variable",name:"eventIds",variableName:"eventIds"}],concreteType:"ExportedFile",kind:"LinkedField",name:"exportEvents",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"fileName",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ExportSelectionButtonMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ExportSelectionButtonMutation",selections:a},params:{cacheID:"d370df04ca30a5059288c7aa298239a8",id:null,metadata:{},name:"ExportSelectionButtonMutation",operationKind:"mutation",text:`mutation ExportSelectionButtonMutation(
  $eventIds: [ID!]!
) {
  exportEvents(eventIds: $eventIds) {
    fileName
  }
}
`}}}();_l.hash="8b0d6962e2034d4c148d1b9919111d2f";const Ss=`import phoenix as px

exports = px.active_session().exports
dataframe = exports[-1]
dataframe`,vs=F`
  .cm-content {
    padding: var(--ac-global-dimension-static-size-100);
  }
`;function xs({value:n}){const{theme:a}=Vn(),l=a==="light"?void 0:ia;return e(ta,{value:n,basicSetup:!1,extensions:[Pa()],editable:!1,theme:l,css:vs})}function Fs(){const n=A(o=>o.selectedEventIds),[a,l]=_.useMutation(_l),[t,i]=g.useState(null),r=g.useCallback(()=>{a({variables:{eventIds:[...n]},onCompleted:o=>{i(o.exportEvents)}})},[a,n]);return s(W,{children:[e(O,{variant:"default",size:"compact",icon:e(N,{svg:e(yl,{})}),"aria-label":"Export selection / cluster",loading:l,onClick:r,children:l?"Exporting":"Export"}),e(ae,{type:"slideOver",isDismissable:!0,onDismiss:()=>i(null),children:t!=null&&s(X,{title:"Cluster Exports",size:"M",children:[e(ee,{variant:"success",banner:!0,title:"Export succeeded",extra:e(O,{variant:"success",size:"compact",onClick:()=>{window.open(`/exports?filename=${t.fileName}`,"_self")},children:"Download"})}),s("div",{css:F`
                display: flex;
                flex-direction: column;
                justify-content: space-between;
                align-items: flex-start;
                padding: 16px;
                gap: 16px;
              `,children:[e("p",{css:F`
                  margin: 0;
                  flex: 1 1 auto;
                `,children:"You can retrieve your export in your notebook via"}),e(D,{borderColor:"light",borderWidth:"thin",borderRadius:"medium",children:e(xs,{value:Ss})})]}),e(pn,{children:e(ue,{id:"all-exports",title:"Latest Exports",children:e(g.Suspense,{fallback:e(pe,{}),children:e(Ks,{})})})})]})})]})}function Ks(){const n=_.useLazyLoadQuery(Rl,{},{fetchPolicy:"network-only"});return e(hl,{children:n.model.exportedFiles.map((a,l)=>e(fl,{children:s("div",{css:F`
              display: flex;
              flex-direction: row;
              justify-content: space-between;
              align-items: center;
            `,children:[a.fileName,e(O,{size:"compact","aria-label":"Download",variant:"default",icon:e(N,{svg:e(yl,{})}),onClick:()=>{window.open(`/exports?filename=${a.fileName}`,"_self")}})]})},l))})}function Ts(n){const{getInferencesNameByRole:a}=Te(),{events:l,onItemSelected:t}=n,i=A(u=>u.eventIdToDataMap),r=A(u=>u.eventIdToGroup),o=A(u=>u.pointGroupColors),c=A(u=>u.selectionGridSize),d=A(u=>u.setHoveredEventId);return e("div",{css:F`
        flex: 1 1 auto;
        overflow-y: auto;
      `,"data-testid":"grid-view-scroll-container",children:e("ul",{"data-grid-size":c,css:F`
          &[data-grid-size="small"] {
            --grid-item-min-width: 100px;
            --grid-item-height: 100px;
          }
          &[data-grid-size="medium"] {
            --grid-item-min-width: 200px;
            --grid-item-height: 200px;
          }
          &[data-grid-size="large"] {
            --grid-item-min-width: 300px;
            --grid-item-height: 200px;
          }
          padding: var(--px-spacing-lg);
          transition: all 0.2s ease-in-out;
          display: grid;
          grid-template-columns: repeat(
            auto-fill,
            minmax(var(--grid-item-min-width), 1fr)
          );
          flex-wrap: wrap;
          gap: var(--px-spacing-lg);
          & > li {
            min-width: var(--grid-item-min-width);
            height: var(--grid-item-height);
          }
        `,children:l.map((u,f)=>{const m=i.get(u.id),{rawData:p=null,linkToData:y=null}=(m==null?void 0:m.embeddingMetadata)??{},{predictionLabel:b=null,actualLabel:S=null}=(m==null?void 0:m.eventMetadata)??{},h=Ji(u.id),x=a(h),L=r[u.id],I=o[L];return e("li",{children:e(Xi,{rawData:p,linkToData:y,inferencesName:x,group:L,onClick:()=>{t(u.id)},onMouseOver:()=>{d(u.id)},onMouseOut:()=>{d(null)},color:I,size:c,predictionLabel:b,actualLabel:S,promptAndResponse:u.promptAndResponse,documentText:u.documentText,autoPlay:!1})},f)})})})}function Ds({data:n,onPointSelected:a}){const{primaryInferences:l,referenceInferences:t}=Te(),i=A(f=>f.metric),[r,o]=g.useState([]),{columns:c,tableData:d}=g.useMemo(()=>{const f=n.filter(I=>I.id.includes("CORPUS")===!1);let m=!1,p=!1,y=!1,b=!1,S=!1;n.forEach(I=>{I.linkToData&&(m=!0),I.rawData&&(p=!0),(I.prompt||I.response)&&(y=!0),I.predictionLabel&&(b=!0),I.actualLabel&&(S=!0)});const h=[];t&&h.push({header:"Inference Set",accessorKey:"id",size:50,cell:({getValue:I})=>e(Cs,{id:I(),primaryInferencesName:l.name,referenceInferencesName:(t==null?void 0:t.name)??"reference"})}),m&&h.push({header:"Link",accessorKey:"linkToData",cell:({getValue:I})=>{const C=I();if(typeof C=="string"){const v=C.split("/").pop();return e(Rn,{href:C,children:v})}return null}}),y?(h.push({header:"Prompt",accessorKey:"prompt",cell:Se,size:200}),h.push({header:"Response",accessorKey:"response",cell:Se,size:200})):p&&h.push({header:"Raw Data",accessorKey:"rawData"}),b&&h.push({header:"Prediction Label",accessorKey:"predictionLabel",size:50}),S&&h.push({header:"Actual Label",accessorKey:"actualLabel",size:50});const x=[];if(i&&i.type==="dataQuality"){const I=i.dimension.name;x.push({header:i.dimension.name,accessorKey:"metric",cell:Zi,sortingFn:"basic"}),f.forEach(C=>{var T;const v=(T=C.dimensions.find(P=>P.dimension.name===I))==null?void 0:T.value;C.metric=v!=null?Number(v):null})}return{columns:[...h,...x,{header:"",id:"view-details",size:50,cell:({row:I})=>e(Yi,{"aria-label":"view point details",onClick:()=>{a(I.original.id)},children:"view details"})}],tableData:f}},[n,a,l,t,i]),u=he({columns:c,data:d,state:{sorting:r},getCoreRowModel:ke(),onSortingChange:o,getSortedRowModel:Mn()});return s("table",{css:zn,children:[e("thead",{children:u.getHeaderGroups().map(f=>e("tr",{children:f.headers.map(m=>s("th",{children:[m.isPlaceholder?null:s("div",{className:m.column.getCanSort()?"cursor-pointer":"",onClick:m.column.getToggleSortingHandler(),children:[G(m.column.columnDef.header,m.getContext()),m.column.getIsSorted()?e(N,{className:"sort-icon",svg:m.column.getIsSorted()==="asc"?e(M.ArrowDownFilled,{}):e(M.ArrowUpFilled,{})}):null]}),e("div",{onMouseDown:m.getResizeHandler(),onTouchStart:m.getResizeHandler(),className:`resizer ${m.column.getIsResizing()?"isResizing":""}`,style:{transform:m.column.getIsResizing()?`translateX(${u.getState().columnSizingInfo.deltaOffset}px)`:""}})]},m.id))},f.id))}),e("tbody",{children:u.getRowModel().rows.map(f=>e("tr",{children:f.getVisibleCells().map(m=>e("td",{style:{width:m.column.getSize()},children:G(m.column.columnDef.cell,m.getContext())},m.id))},f.id))})]})}function Cs({id:n,primaryInferencesName:a,referenceInferencesName:l}){const t=n.includes("PRIMARY"),i=Yr();return s(k,{direction:"row",gap:"size-100",alignItems:"center",children:[e(nr,{shape:er.circle,color:i[t?0:1]}),t?a:l]})}const Is=F`
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  /* Give spacing for the close icon */
  & > .ac-tabs {
    padding-top: 17px;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    [role="tablist"] {
      flex: none;
    }
    .ac-tabs__pane-container {
      display: flex;
      flex-direction: column;
      flex: 1 1 auto;
      overflow: hidden;
      [role="tabpanel"] {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        overflow: hidden;
      }
    }
  }
`;function Ls({event:n,relevance:a}){return{id:n.eventMetadata.predictionId||"unknown id",text:n.documentText??"empty document",relevance:a}}function Es(){const n=A(v=>v.selectedEventIds),a=A(v=>v.setSelectedEventIds),l=A(v=>v.setSelectedClusterId),t=A(v=>v.selectionDisplay),[i,r]=Fe.useState(null),{primaryEventIds:o,referenceEventIds:c,corpusEventIds:d}=g.useMemo(()=>{const v=[],T=[],P=[];return n.forEach(R=>{R.includes("PRIMARY")?v.push(R):R.includes("CORPUS")?P.push(R):T.push(R)}),{primaryEventIds:v,referenceEventIds:T,corpusEventIds:P}},[n]),u=_.useLazyLoadQuery(El,{primaryEventIds:[...o],referenceEventIds:[...c],corpusEventIds:[...d]}),f=g.useMemo(()=>{var R,z,j,U,ie,re;const v=((z=(R=u.model)==null?void 0:R.primaryInferences)==null?void 0:z.events)??[],T=((U=(j=u.model)==null?void 0:j.referenceInferences)==null?void 0:U.events)??[],P=((re=(ie=u.model)==null?void 0:ie.corpusInferences)==null?void 0:re.events)??[];return[...v,...T,...P]},[u]),m=()=>{a(new Set),l(null)},p=A(v=>v.eventIdToDataMap),y=A(v=>v.pointData),b=A(v=>v.selectionSearchText),S=g.useMemo(()=>f.map(v=>{var R,z,j,U,ie,re,w;const T=p.get(v.id),P=[];return y!=null&&(T==null?void 0:T.retrievals)!=null&&T.retrievals.forEach(({documentId:$,relevance:E})=>{const V=y[$];V!=null&&P.push(Ls({event:V,relevance:E}))}),{id:v.id,predictionId:((R=v.eventMetadata)==null?void 0:R.predictionId)??null,actualLabel:((z=v.eventMetadata)==null?void 0:z.actualLabel)??null,actualScore:((j=v.eventMetadata)==null?void 0:j.actualScore)??null,predictionLabel:((U=v.eventMetadata)==null?void 0:U.predictionLabel)??null,predictionScore:((ie=v.eventMetadata)==null?void 0:ie.predictionScore)??null,rawData:(T==null?void 0:T.embeddingMetadata.rawData)??null,linkToData:(T==null?void 0:T.embeddingMetadata.linkToData)??null,dimensions:v.dimensions,prompt:((re=v.promptAndResponse)==null?void 0:re.prompt)??null,response:((w=v.promptAndResponse)==null?void 0:w.response)??null,retrievedDocuments:P,documentText:v.documentText??null}}),[f,p,y]),h=g.useMemo(()=>{if(b){const v=b.toLowerCase();return S.filter(T=>{var P,R,z,j;return T.id.includes(v)||((P=T.documentText)==null?void 0:P.toLowerCase().includes(v))||((R=T.predictionId)==null?void 0:R.includes(v))||((z=T.prompt)==null?void 0:z.toLowerCase().includes(v))||((j=T.response)==null?void 0:j.toLowerCase().includes(v))})}return S},[S,b]),x=g.useMemo(()=>{if(b){const v=b.toLowerCase();return f.filter(T=>{var P,R,z,j,U,ie,re;return T.id.includes(v)||((P=T.documentText)==null?void 0:P.toLowerCase().includes(v))||((z=(R=T.eventMetadata)==null?void 0:R.predictionId)==null?void 0:z.includes(v))||((U=(j=T.promptAndResponse)==null?void 0:j.prompt)==null?void 0:U.toLowerCase().includes(v))||((re=(ie=T.promptAndResponse)==null?void 0:ie.response)==null?void 0:re.toLowerCase().includes(v))})}return f},[f,b]),L=g.useMemo(()=>i?S.find(T=>T.id===i)??null:null,[S,i]),I=f.length,C=x.length;return s("section",{css:Is,children:[s("div",{role:"toolbar",css:F`
          position: absolute;
          top: var(--px-spacing-med);
          right: var(--px-spacing-lg);
          display: flex;
          flex-direction: row-reverse;
          gap: var(--px-spacing-med);
        `,children:[e(O,{variant:"default",size:"compact",icon:e(N,{svg:e(Ar,{})}),"aria-label":"Clear selection",onClick:m}),e(Fs,{})]}),e(fe,{children:s(q,{name:"Selection",children:[e(Rs,{numSelectedEvents:I,numMatchingEvents:C,searchText:b}),t===rl.list?e("div",{css:F`
                flex: 1 1 auto;
                overflow-y: auto;
              `,children:e(Ds,{data:h,onPointSelected:r})}):e(Ts,{events:x,onItemSelected:r})]})}),e(ae,{type:"slideOver",isDismissable:!0,onDismiss:()=>r(null),children:L&&e(X,{title:"Embedding Details",size:"L",children:e(ps,{event:L})})})]})}function Rs({numSelectedEvents:n,numMatchingEvents:a,searchText:l}){const t=A(u=>u.selectionDisplay),i=A(u=>u.setSelectionDisplay),r=A(u=>u.selectionGridSize),o=A(u=>u.setSelectionGridSize),c=A(u=>u.setSelectionSearchText),d=g.useMemo(()=>l?`${a}/${n} match "${l}"`:`${n} selected`,[n,a,l]);return e(va,{extra:s("div",{css:F`
            display: flex;
            flex-direction: row;
            gap: var(--px-spacing-med);
          `,children:[e(Qr,{placeholder:"Search by text or ID",onChange:u=>{c(u)}}),t===rl.gallery&&e(ar,{size:r,onChange:o}),e(lr,{mode:t,onChange:u=>{i(u)}})]}),children:e(K,{children:d})})}const wl=Kl;function Pc(){const{referenceInferences:n,corpusInferences:a}=Te(),{timeRange:l}=we(),t=g.useMemo(()=>{let i={};return a!=null?i=rr():n!=null?i=sr():i=or(),i={...i,umapParameters:{...window.Config.UMAP}},i},[a,n]);return e(sl,{initialTimestamp:l.end,children:e(dr,{...t,children:e(_s,{})})})}function _s(){const n=es(),{primaryInferences:a,referenceInferences:l}=Te(),t=A(x=>x.umapParameters),i=A(x=>x.getHDSCANParameters),r=A(x=>x.getMetric),o=A(x=>x.reset),c=A(x=>x.setLoading),[d,u]=g.useState(!0),[f,m,p]=_.useQueryLoader(wl),{selectedTimestamp:y}=Un(),b=g.useMemo(()=>y??new Date(a.endTime),[y,a.endTime]),S=g.useMemo(()=>({start:Za(b,2).toISOString(),end:b.toISOString()}),[b]),h=_.useLazyLoadQuery(Fl,{});return g.useEffect(()=>{o(),c(!0);const x=r();return m({id:n,timeRange:S,...t,...i(),fetchDataQualityMetric:x.type==="dataQuality",fetchPerformanceMetric:x.type==="performance",dataQualityMetricColumnName:x.type==="dataQuality"?x.dimension.name:null,performanceMetric:x.type==="performance"?x.metric:"accuracyScore"},{fetchPolicy:"network-only"}),()=>{p()}},[c,o,n,m,p,t,i,r,S]),s("main",{css:F`
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        overflow: hidden;
      `,children:[e(As,{}),s(va,{extra:s(k,{direction:"row",justifyContent:"center",alignItems:"center",gap:"size-100",children:[e(La,{onChange:x=>{u(x)},defaultSelected:!0,labelPlacement:"start",children:"Show Timeseries"}),e(as,{})]}),children:[e(nl,{}),l?e(al,{inferencesRole:"reference",timeRange:{start:new Date(l.startTime),end:new Date(l.endTime)}}):null,e(rs,{model:h.model})]}),s(Ye,{direction:"vertical",children:[d?s(W,{children:[e(se,{defaultSize:20,collapsible:!0,order:1,children:e(g.Suspense,{fallback:e(pe,{}),children:e(us,{embeddingDimensionId:n})})}),e(en,{css:Sn})]}):null,e(se,{order:2,children:e("div",{css:F`
              width: 100%;
              height: 100%;
              position: relative;
            `,children:e(g.Suspense,{fallback:e(cr,{}),children:f?e(Ps,{queryReference:f}):null})})})]})]})}function ws(n){if(n.__typename!=="Point3D")throw new Error(`Expected Point3D but got ${n.__typename} for coordinates`);return[n.x,n.y,n.z]}function Ps({queryReference:n}){const a=_.usePreloadedQuery(wl,n),l=g.useMemo(()=>{var u,f;return((f=(u=a.embedding)==null?void 0:u.UMAPPoints)==null?void 0:f.data)??[]},[a]),t=g.useMemo(()=>{var u,f;return((f=(u=a.embedding)==null?void 0:u.UMAPPoints)==null?void 0:f.referenceData)??[]},[a]),i=g.useMemo(()=>{var u,f;return((f=(u=a.embedding)==null?void 0:u.UMAPPoints)==null?void 0:f.corpusData)??[]},[a]),r=g.useMemo(()=>{var u,f;return((f=(u=a.embedding)==null?void 0:u.UMAPPoints)==null?void 0:f.contextRetrievals)??[]},[a]),o=g.useMemo(()=>[...l,...t,...i].map(f=>({...f,position:ws(f.coordinates),metaData:{id:f.eventId}})),[t,l,i]),c=A(u=>u.setInitialData),d=A(u=>u.setClusters);return Pi(()=>{var f,m;const u=((m=(f=a.embedding)==null?void 0:f.UMAPPoints)==null?void 0:m.clusters)||[];c({points:o,clusters:u,retrievals:r})},[o,n,r,c,d]),e("div",{css:F`
        flex: 1 1 auto;
        display: flex;
        flex-direction: row;
        align-items: stretch;
        width: 100%;
        height: 100%;
      `,"data-testid":"point-cloud-display",children:s(Ye,{direction:"horizontal",children:[e(se,{id:"embedding-left",defaultSize:15,maxSize:30,minSize:10,collapsible:!0,children:s(Ye,{autoSaveId:"embedding-controls-vertical",direction:"vertical",children:[e(se,{css:F`
                display: flex;
                flex-direction: column;
                .ac-tabs {
                  height: 100%;
                  overflow: hidden;
                  display: flex;
                  flex-direction: column;
                  [role="tablist"] {
                    flex: none;
                  }
                  .ac-tabs__pane-container {
                    flex: 1 1 auto;
                    overflow: hidden;
                    display: flex;
                    flex-direction: column;
                    & > div {
                      height: 100%;
                    }
                  }
                }
              `,children:e(Vs,{})}),e(en,{css:Sn}),e(se,{css:F`
                .ac-tabs {
                  height: 100%;
                  overflow: hidden;
                  .ac-tabs__pane-container {
                    height: 100%;
                    overflow-y: auto;
                  }
                }
              `,children:s(fe,{children:[e(q,{name:"Display",children:e(ur,{})}),e(q,{name:"Hyperparameters",children:e(mr,{})})]})})]})}),e(en,{css:gr}),e(se,{children:s("div",{css:F`
              position: relative;
              width: 100%;
              height: 100%;
            `,children:[e(Ms,{}),e(pr,{})]})})]})})}function Ms(){return A(a=>a.selectedEventIds).size===0?null:e("div",{css:F`
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
      `,"data-testid":"selection-panel",children:s(Ye,{direction:"vertical",children:[e(se,{}),e(en,{css:Sn,style:{zIndex:1}}),e(se,{id:"embedding-point-selection",defaultSize:40,minSize:20,order:2,style:{zIndex:1},children:e(Ns,{children:e(g.Suspense,{fallback:e(pe,{}),children:e(Es,{})})})})]})})}function Ns(n){return e("div",{css:F`
        background-color: var(--ac-global-color-grey-75);
        width: 100%;
        height: 100%;
      `,children:n.children})}const $s=1,Vs=Fe.memo(function(){const{referenceInferences:a}=Te(),l=A(m=>m.clusters),t=A(m=>m.selectedClusterId),i=A(m=>m.metric),r=A(m=>m.setSelectedClusterId),o=A(m=>m.setSelectedEventIds),c=A(m=>m.setHighlightedClusterId),d=A(m=>m.setClusterColorMode),u=a==null||i.type==="drift",f=g.useCallback(m=>{d(m===$s?za.highlight:za.default)},[d]);return s(fe,{onChange:f,children:[e(q,{name:"Clusters",extra:e(Ve,{children:l.length}),children:s(k,{direction:"column",height:"100%",children:[e(D,{borderBottomColor:"dark",borderBottomWidth:"thin",backgroundColor:"dark",flex:"none",padding:"size-50",children:e(k,{direction:"row",justifyContent:"end",children:e(ns,{})})}),e(D,{flex:"1 1 auto",overflow:"auto",children:e("ul",{css:m=>F`
                flex: 1 1 auto;
                display: flex;
                flex-direction: column;
                gap: ${m.spacing.margin8}px;
                margin: ${m.spacing.margin8}px;
              `,children:l.map(m=>e("li",{children:e(tr,{clusterId:m.id,numPoints:m.eventIds.length,isSelected:t===m.id,driftRatio:m.driftRatio,primaryToCorpusRatio:m.primaryToCorpusRatio,primaryMetricValue:m.primaryMetricValue,referenceMetricValue:m.referenceMetricValue,metricName:zs(i),hideReference:u,onClick:()=>{t!==m.id?(r(m.id),o(new Set(m.eventIds))):(r(null),o(new Set))},onMouseEnter:()=>{c(m.id)},onMouseLeave:()=>{c(null)}})},m.id))})})]})}),e(q,{name:"Configuration",children:e(D,{overflow:"auto",height:"100%",children:e(ir,{})})})]})});function zs(n){const{type:a,metric:l}=n;switch(a){case"dataQuality":return`${n.dimension.name} avg`;case"drift":{switch(l){case"euclideanDistance":return"Cluster Drift";default:me()}break}case"performance":return Ze(l);case"retrieval":{switch(l){case"queryDistance":return"% Query";default:me()}break}default:me()}}function As(){const{notifyError:n}=ll(),a=A(t=>t.errorMessage),l=A(t=>t.setErrorMessage);return g.useEffect(()=>{a!==null&&n({title:"An error occurred",message:a,action:{text:"Dismiss",onClick:()=>{l(null)}}})},[a,n,l]),null}const Pl=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"embeddingLoaderQuery",selections:[{alias:"embedding",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{kind:"InlineFragment",selections:[l,t],type:"EmbeddingDimension",abstractKey:null}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"embeddingLoaderQuery",selections:[{alias:"embedding",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},l,{kind:"InlineFragment",selections:[t],type:"EmbeddingDimension",abstractKey:null}],storageKey:null}]},params:{cacheID:"cff0ac130f1ef79784f7bef4161ac60d",id:null,metadata:{},name:"embeddingLoaderQuery",operationKind:"query",text:`query embeddingLoaderQuery(
  $id: GlobalID!
) {
  embedding: node(id: $id) {
    __typename
    ... on EmbeddingDimension {
      id
      name
    }
    __isNode: __typename
    id
  }
}
`}}}();Pl.hash="c049e57d92943f64b5e751e0daa89dc8";async function Mc(n){const{embeddingDimensionId:a}=n.params;return _.fetchQuery(Ke,Pl,{id:a}).toPromise()}const Ml=function(){var n={defaultValue:null,kind:"LocalArgument",name:"dimensionId"},a={defaultValue:null,kind:"LocalArgument",name:"hasReference"},l={defaultValue:null,kind:"LocalArgument",name:"timeRange"},t=[{kind:"Variable",name:"id",variableName:"dimensionId"}],i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},r={kind:"Variable",name:"timeRange",variableName:"timeRange"},o=[r],c=[{kind:"Variable",name:"hasReference",variableName:"hasReference"},r],d={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},u=[{alias:null,args:null,kind:"ScalarField",name:"primaryValue",storageKey:null}],f={kind:"Literal",name:"metric",value:"cardinality"},m={kind:"Literal",name:"metric",value:"percentEmpty"},p={kind:"Literal",name:"inferencesRole",value:"reference"};return{fragment:{argumentDefinitions:[n,a,l],kind:"Fragment",metadata:null,name:"DimensionPageQuery",selections:[{alias:"dimension",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{kind:"InlineFragment",selections:[i,{args:o,kind:"FragmentSpread",name:"DimensionSegmentsBarChart_dimension"},{args:o,kind:"FragmentSpread",name:"DimensionCountStats_dimension"},{args:o,kind:"FragmentSpread",name:"DimensionDriftStats_dimension"},{args:c,kind:"FragmentSpread",name:"DimensionCardinalityStats_dimension"},{args:c,kind:"FragmentSpread",name:"DimensionPercentEmptyStats_dimension"},{args:o,kind:"FragmentSpread",name:"DimensionQuantilesStats_dimension"}],type:"Dimension",abstractKey:null}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[n,l,a],kind:"Operation",name:"DimensionPageQuery",selections:[{alias:"dimension",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[d,{kind:"TypeDiscriminator",abstractKey:"__isNode"},i,{kind:"InlineFragment",selections:[{alias:null,args:[{kind:"Variable",name:"primaryTimeRange",variableName:"timeRange"}],concreteType:"Segments",kind:"LinkedField",name:"segmentsComparison",plural:!1,selections:[{alias:null,args:null,concreteType:"Segment",kind:"LinkedField",name:"segments",plural:!0,selections:[{alias:null,args:null,concreteType:null,kind:"LinkedField",name:"bin",plural:!1,selections:[d,{kind:"InlineFragment",selections:[{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null}],type:"NominalBin",abstractKey:null},{kind:"InlineFragment",selections:[{alias:null,args:null,concreteType:"NumericRange",kind:"LinkedField",name:"range",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"start",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"end",storageKey:null}],storageKey:null}],type:"IntervalBin",abstractKey:null}],storageKey:null},{alias:null,args:null,concreteType:"DatasetValues",kind:"LinkedField",name:"counts",plural:!1,selections:u,storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"DatasetValues",kind:"LinkedField",name:"totalCounts",plural:!1,selections:u,storageKey:null}],storageKey:null},{alias:"count",args:[{kind:"Literal",name:"metric",value:"count"},r],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"psi",args:[{kind:"Literal",name:"metric",value:"psi"},r],kind:"ScalarField",name:"driftMetric",storageKey:null},{alias:"cardinality",args:[f,r],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"percentEmpty",args:[m,r],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"p99",args:[{kind:"Literal",name:"metric",value:"p99"},r],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"p75",args:[{kind:"Literal",name:"metric",value:"p75"},r],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"p50",args:[{kind:"Literal",name:"metric",value:"p50"},r],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"p25",args:[{kind:"Literal",name:"metric",value:"p25"},r],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"p1",args:[{kind:"Literal",name:"metric",value:"p01"},r],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{condition:"hasReference",kind:"Condition",passingValue:!0,selections:[{alias:"referenceCardinality",args:[p,f],kind:"ScalarField",name:"dataQualityMetric",storageKey:'dataQualityMetric(inferencesRole:"reference",metric:"cardinality")'},{alias:"referencePercentEmpty",args:[p,m],kind:"ScalarField",name:"dataQualityMetric",storageKey:'dataQualityMetric(inferencesRole:"reference",metric:"percentEmpty")'}]}],type:"Dimension",abstractKey:null}],storageKey:null}]},params:{cacheID:"2ad937e56d4647309b9d78ac11f57265",id:null,metadata:{},name:"DimensionPageQuery",operationKind:"query",text:`query DimensionPageQuery(
  $dimensionId: GlobalID!
  $timeRange: TimeRange!
  $hasReference: Boolean!
) {
  dimension: node(id: $dimensionId) {
    __typename
    ... on Dimension {
      id
      ...DimensionSegmentsBarChart_dimension_3E0ZE6
      ...DimensionCountStats_dimension_3E0ZE6
      ...DimensionDriftStats_dimension_3E0ZE6
      ...DimensionCardinalityStats_dimension_1JBzL3
      ...DimensionPercentEmptyStats_dimension_1JBzL3
      ...DimensionQuantilesStats_dimension_3E0ZE6
    }
    __isNode: __typename
    id
  }
}

fragment DimensionCardinalityStats_dimension_1JBzL3 on Dimension {
  id
  cardinality: dataQualityMetric(metric: cardinality, timeRange: $timeRange)
  referenceCardinality: dataQualityMetric(metric: cardinality, inferencesRole: reference) @include(if: $hasReference)
}

fragment DimensionCountStats_dimension_3E0ZE6 on Dimension {
  id
  count: dataQualityMetric(metric: count, timeRange: $timeRange)
}

fragment DimensionDriftStats_dimension_3E0ZE6 on Dimension {
  id
  psi: driftMetric(metric: psi, timeRange: $timeRange)
}

fragment DimensionPercentEmptyStats_dimension_1JBzL3 on Dimension {
  id
  percentEmpty: dataQualityMetric(metric: percentEmpty, timeRange: $timeRange)
  referencePercentEmpty: dataQualityMetric(metric: percentEmpty, inferencesRole: reference) @include(if: $hasReference)
}

fragment DimensionQuantilesStats_dimension_3E0ZE6 on Dimension {
  p99: dataQualityMetric(metric: p99, timeRange: $timeRange)
  p75: dataQualityMetric(metric: p75, timeRange: $timeRange)
  p50: dataQualityMetric(metric: p50, timeRange: $timeRange)
  p25: dataQualityMetric(metric: p25, timeRange: $timeRange)
  p1: dataQualityMetric(metric: p01, timeRange: $timeRange)
}

fragment DimensionSegmentsBarChart_dimension_3E0ZE6 on Dimension {
  id
  segmentsComparison(primaryTimeRange: $timeRange) {
    segments {
      bin {
        __typename
        ... on NominalBin {
          __typename
          name
        }
        ... on IntervalBin {
          __typename
          range {
            start
            end
          }
        }
        ... on MissingValueBin {
          __typename
        }
      }
      counts {
        primaryValue
      }
    }
    totalCounts {
      primaryValue
    }
  }
}
`}}}();Ml.hash="d194bfd656408e8ba7cb427ddc80fc85";const Nl=function(){var n={kind:"Literal",name:"metric",value:"cardinality"};return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"hasReference"},{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],kind:"Fragment",metadata:null,name:"DimensionCardinalityStats_dimension",selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:"cardinality",args:[n,{kind:"Variable",name:"timeRange",variableName:"timeRange"}],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{condition:"hasReference",kind:"Condition",passingValue:!0,selections:[{alias:"referenceCardinality",args:[{kind:"Literal",name:"inferencesRole",value:"reference"},n],kind:"ScalarField",name:"dataQualityMetric",storageKey:'dataQualityMetric(inferencesRole:"reference",metric:"cardinality")'}]}],type:"Dimension",abstractKey:null}}();Nl.hash="8b4edef350e4df49e799afa70ca34918";function Qs(n){const a=_.useFragment(Nl,n.dimension);return s(W,{children:[e(K,{elementType:"h3",textSize:"small",color:"text-700",children:"Cardinality"}),e(K,{textSize:"xlarge",children:nn(a.cardinality)}),a.referenceCardinality!=null&&e(K,{textSize:"medium",color:"designationPurple",children:nn(a.referenceCardinality)})]})}const $l=function(){var n={defaultValue:null,kind:"LocalArgument",name:"dimensionId"},a={defaultValue:null,kind:"LocalArgument",name:"granularity"},l={defaultValue:null,kind:"LocalArgument",name:"timeRange"},t=[{kind:"Variable",name:"id",variableName:"dimensionId"}],i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},r={kind:"InlineFragment",selections:[{alias:"cardinalityTimeSeries",args:[{kind:"Variable",name:"granularity",variableName:"granularity"},{kind:"Literal",name:"metric",value:"cardinality"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:[{alias:null,args:null,concreteType:"TimeSeriesDataPoint",kind:"LinkedField",name:"data",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"timestamp",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}],storageKey:null}],storageKey:null}],type:"Dimension",abstractKey:null};return{fragment:{argumentDefinitions:[n,a,l],kind:"Fragment",metadata:null,name:"DimensionCardinalityTimeSeriesQuery",selections:[{alias:"dimension",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[i,r],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[n,l,a],kind:"Operation",name:"DimensionCardinalityTimeSeriesQuery",selections:[{alias:"dimension",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i,r],storageKey:null}]},params:{cacheID:"f53e5ac5e0bfd6a0a6c50b761223a617",id:null,metadata:{},name:"DimensionCardinalityTimeSeriesQuery",operationKind:"query",text:`query DimensionCardinalityTimeSeriesQuery(
  $dimensionId: GlobalID!
  $timeRange: TimeRange!
  $granularity: Granularity!
) {
  dimension: node(id: $dimensionId) {
    __typename
    id
    ... on Dimension {
      cardinalityTimeSeries: dataQualityTimeSeries(metric: cardinality, timeRange: $timeRange, granularity: $granularity) {
        data {
          timestamp
          value
        }
      }
    }
  }
}
`}}}();$l.hash="88ce04bb2022d5e2bc75c663abd7e5de";const jn={top:25,right:18,left:18,bottom:5},Os=new Intl.NumberFormat([],{maximumFractionDigits:2}),Vl=()=>{const{gray300:n}=Pe();return{color:n}};function js({active:n,payload:a,label:l}){var i;const{color:t}=Vl();if(n&&a&&a.length){const r=((i=a[0])==null?void 0:i.value)??null,o=typeof r=="number"?Os.format(r):"--";return s(qe,{children:[e(K,{weight:"heavy",textSize:"medium",children:`${ln(new Date(l))}`}),e(te,{color:t,name:"Cardinality",value:o}),e(Jn,{})]})}return null}function qs({dimensionId:n}){var c;const{timeRange:a}=we(),l=hn(a),t=_.useLazyLoadQuery($l,{dimensionId:n,timeRange:{start:a.start.toISOString(),end:a.end.toISOString()},granularity:l}),{color:i}=Vl(),r=((c=t.dimension.cardinalityTimeSeries)==null?void 0:c.data.map(d=>({timestamp:new Date(d.timestamp).valueOf(),value:d.value})))||[],o=kn({samplingIntervalMinutes:l.samplingIntervalMinutes});return e(Be,{width:"100%",height:"100%",children:s(On,{data:r,margin:jn,syncId:"dimensionDetails",children:[e("defs",{children:s("linearGradient",{id:"cardinalityColorUv",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:i,stopOpacity:.8}),e("stop",{offset:"95%",stopColor:i,stopOpacity:0})]})}),e(He,{...bn,tickFormatter:d=>o(new Date(d))}),e(xe,{stroke:le.colors.gray200,label:{value:"Cardinality",angle:-90,position:"insideLeft",style:{textAnchor:"middle",fill:"var(--ac-global-text-color-900)"}},style:{fill:"var(--ac-global-text-color-700)"}}),e(Ge,{strokeDasharray:"4 4",stroke:le.colors.gray200,strokeOpacity:.5}),e(We,{content:e(js,{})}),e(wn,{type:"monotone",dataKey:"value",stroke:i,fillOpacity:1,fill:"url(#cardinalityColorUv)"})]})})}const zl={argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],kind:"Fragment",metadata:null,name:"DimensionCountStats_dimension",selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:"count",args:[{kind:"Literal",name:"metric",value:"count"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],kind:"ScalarField",name:"dataQualityMetric",storageKey:null}],type:"Dimension",abstractKey:null};zl.hash="6dccac51f3fb0853276677c692af5a43";function Bs(n){const l=_.useFragment(zl,n.dimension).count??0;return s(W,{children:[e(K,{elementType:"h3",textSize:"small",color:"text-700",children:"Total Count"}),e(K,{textSize:"xlarge",children:nn(l)})]})}const Al=function(){var n={defaultValue:null,kind:"LocalArgument",name:"countGranularity"},a={defaultValue:null,kind:"LocalArgument",name:"dimensionId"},l={defaultValue:null,kind:"LocalArgument",name:"timeRange"},t=[{kind:"Variable",name:"id",variableName:"dimensionId"}],i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},r={kind:"InlineFragment",selections:[{alias:"trafficTimeSeries",args:[{kind:"Variable",name:"granularity",variableName:"countGranularity"},{kind:"Literal",name:"metric",value:"count"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:[{alias:null,args:null,concreteType:"TimeSeriesDataPoint",kind:"LinkedField",name:"data",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"timestamp",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}],storageKey:null}],storageKey:null}],type:"Dimension",abstractKey:null};return{fragment:{argumentDefinitions:[n,a,l],kind:"Fragment",metadata:null,name:"DimensionCountTimeSeriesQuery",selections:[{alias:"embedding",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[i,r],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[a,l,n],kind:"Operation",name:"DimensionCountTimeSeriesQuery",selections:[{alias:"embedding",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i,r],storageKey:null}]},params:{cacheID:"1f9eff6d8d453148844edae32b844df7",id:null,metadata:{},name:"DimensionCountTimeSeriesQuery",operationKind:"query",text:`query DimensionCountTimeSeriesQuery(
  $dimensionId: GlobalID!
  $timeRange: TimeRange!
  $countGranularity: Granularity!
) {
  embedding: node(id: $dimensionId) {
    __typename
    id
    ... on Dimension {
      trafficTimeSeries: dataQualityTimeSeries(metric: count, timeRange: $timeRange, granularity: $countGranularity) {
        data {
          timestamp
          value
        }
      }
    }
  }
}
`}}}();Al.hash="9677ef7c6b298554824fe3fd3904c7aa";const Hs=new Intl.NumberFormat([],{maximumFractionDigits:2}),Ql=()=>{const{gray300:n}=Pe();return{barColor:n}};function Gs({active:n,payload:a,label:l}){var i;const{barColor:t}=Ql();if(n&&a&&a.length){const r=((i=a[0])==null?void 0:i.value)??null,o=typeof r=="number"?Hs.format(r):"--";return s(qe,{children:[e(K,{weight:"heavy",textSize:"medium",children:`${ln(new Date(l))}`}),e(te,{color:t,shape:"square",name:"Count",value:o})]})}return null}function Ws({dimensionId:n}){var d;const{timeRange:a}=we(),l=hn(a),r=(((d=_.useLazyLoadQuery(Al,{dimensionId:n,timeRange:{start:a.start.toISOString(),end:a.end.toISOString()},countGranularity:l}).embedding.trafficTimeSeries)==null?void 0:d.data)||[]).map(u=>({...u,timestamp:new Date(u.timestamp).valueOf()})),o=kn({samplingIntervalMinutes:l.samplingIntervalMinutes}),{barColor:c}=Ql();return e(Be,{width:"100%",height:"100%",children:s(wa,{data:r,margin:jn,syncId:"dimensionDetails",children:[e("defs",{children:s("linearGradient",{id:"countBarColor",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:c,stopOpacity:1}),e("stop",{offset:"95%",stopColor:c,stopOpacity:.5})]})}),e(He,{...bn,tickFormatter:u=>o(new Date(u))}),e(xe,{stroke:le.colors.gray200,label:{value:"Count",angle:-90,position:"insideLeft",style:{textAnchor:"middle",fill:"var(--ac-global-text-color-900)"}},style:{fill:"var(--ac-global-text-color-700)"}}),e(Ge,{strokeDasharray:"4 4",stroke:le.colors.gray200,strokeOpacity:.5}),e(We,{...Fa,content:e(Gs,{})}),e(fn,{dataKey:"value",fill:"url(#countBarColor)",spacing:5})]})})}const Ol=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"dimensionId"},{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],a=[{kind:"Variable",name:"id",variableName:"dimensionId"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t=[{kind:"Variable",name:"primaryTimeRange",variableName:"timeRange"}],i={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},r={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},o={alias:null,args:null,concreteType:"NumericRange",kind:"LinkedField",name:"range",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"start",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"end",storageKey:null}],storageKey:null},c=[{alias:null,args:null,kind:"ScalarField",name:"primaryValue",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"referenceValue",storageKey:null}],d={alias:null,args:null,concreteType:"DatasetValues",kind:"LinkedField",name:"counts",plural:!1,selections:c,storageKey:null},u={alias:null,args:null,concreteType:"DatasetValues",kind:"LinkedField",name:"totalCounts",plural:!1,selections:c,storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"DimensionDriftBreakdownSegmentBarChartQuery",selections:[{alias:"dimension",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,{kind:"InlineFragment",selections:[{kind:"RequiredField",field:{alias:null,args:t,concreteType:"Segments",kind:"LinkedField",name:"segmentsComparison",plural:!1,selections:[{alias:null,args:null,concreteType:"Segment",kind:"LinkedField",name:"segments",plural:!0,selections:[{alias:null,args:null,concreteType:null,kind:"LinkedField",name:"bin",plural:!1,selections:[{kind:"InlineFragment",selections:[i,r],type:"NominalBin",abstractKey:null},{kind:"InlineFragment",selections:[i,o],type:"IntervalBin",abstractKey:null},{kind:"InlineFragment",selections:[i],type:"MissingValueBin",abstractKey:null}],storageKey:null},d],storageKey:null},u],storageKey:null},action:"THROW",path:"dimension.segmentsComparison"}],type:"Dimension",abstractKey:null}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"DimensionDriftBreakdownSegmentBarChartQuery",selections:[{alias:"dimension",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[i,l,{kind:"InlineFragment",selections:[{alias:null,args:t,concreteType:"Segments",kind:"LinkedField",name:"segmentsComparison",plural:!1,selections:[{alias:null,args:null,concreteType:"Segment",kind:"LinkedField",name:"segments",plural:!0,selections:[{alias:null,args:null,concreteType:null,kind:"LinkedField",name:"bin",plural:!1,selections:[i,{kind:"InlineFragment",selections:[r],type:"NominalBin",abstractKey:null},{kind:"InlineFragment",selections:[o],type:"IntervalBin",abstractKey:null}],storageKey:null},d],storageKey:null},u],storageKey:null}],type:"Dimension",abstractKey:null}],storageKey:null}]},params:{cacheID:"7d11d88f419003f5ee8cd9d11312e427",id:null,metadata:{},name:"DimensionDriftBreakdownSegmentBarChartQuery",operationKind:"query",text:`query DimensionDriftBreakdownSegmentBarChartQuery(
  $dimensionId: GlobalID!
  $timeRange: TimeRange!
) {
  dimension: node(id: $dimensionId) {
    __typename
    id
    ... on Dimension {
      segmentsComparison(primaryTimeRange: $timeRange) {
        segments {
          bin {
            __typename
            ... on NominalBin {
              __typename
              name
            }
            ... on IntervalBin {
              __typename
              range {
                start
                end
              }
            }
            ... on MissingValueBin {
              __typename
            }
          }
          counts {
            primaryValue
            referenceValue
          }
        }
        totalCounts {
          primaryValue
          referenceValue
        }
      }
    }
  }
}
`}}}();Ol.hash="6bb76e3cce4ee28c333e485b3aa2dffd";const ja=Sa(".2f"),jl=()=>{const{primary:n,reference:a}=Pe();return{primaryBarColor:n,referenceBarColor:a}};function Us({active:n,payload:a,label:l}){var r,o,c,d,u,f;const{primaryBarColor:t,referenceBarColor:i}=jl();if(n&&a&&a.length){const m=(o=(r=a[0])==null?void 0:r.payload)==null?void 0:o.primaryName,p=(c=a[0])==null?void 0:c.value,y=(u=(d=a[0])==null?void 0:d.payload)==null?void 0:u.referenceName,b=(f=a[1])==null?void 0:f.value;return s(qe,{children:[e(K,{elementType:"h3",textSize:"medium",weight:"heavy",children:l}),e(te,{color:t,shape:"square",name:m,value:p!=null?`${ja(p)}%`:"--"}),e(te,{color:i,shape:"square",name:y,value:b!=null?`${ja(b)}%`:"--"})]})}return null}function Js(n){var p,y,b,S,h;const{primaryInferences:a,referenceInferences:l}=Te(),t=a.name,i=(l==null?void 0:l.name)||"reference",{selectedTimestamp:r}=Un(),o=g.useMemo(()=>r??new Date(a.endTime),[r,a.endTime]),c=g.useMemo(()=>({start:Za(o,2).toISOString(),end:o.toISOString()}),[o]),d=_.useLazyLoadQuery(Ol,{dimensionId:n.dimensionId,timeRange:c}),u=g.useMemo(()=>{var C,v,T,P,R;const x=((C=d.dimension.segmentsComparison)==null?void 0:C.segments)??[],L=((T=(v=d.dimension.segmentsComparison)==null?void 0:v.totalCounts)==null?void 0:T.primaryValue)??0,I=((R=(P=d.dimension.segmentsComparison)==null?void 0:P.totalCounts)==null?void 0:R.referenceValue)??0;return x.map(z=>{var $,E;const j=(($=z.counts)==null?void 0:$.primaryValue)??0,U=((E=z.counts)==null?void 0:E.referenceValue)??0,ie=ol(z.bin),re=j/L*100,w=U/I*100;return{name:ie,primaryName:t,referenceName:i,primaryPercent:re,referencePercent:w}})},[(p=d.dimension.segmentsComparison)==null?void 0:p.segments,(b=(y=d.dimension.segmentsComparison)==null?void 0:y.totalCounts)==null?void 0:b.primaryValue,(h=(S=d.dimension.segmentsComparison)==null?void 0:S.totalCounts)==null?void 0:h.referenceValue,t,i]),{primaryBarColor:f,referenceBarColor:m}=jl();return s(k,{direction:"column",height:"100%",children:[e(D,{flex:"none",paddingTop:"size-100",paddingStart:"size-200",children:e(K,{elementType:"h3",textSize:"medium",color:"text-700",children:`Distribution comparison at ${ln(new Date(c.end))}`})}),e(D,{flex:!0,children:e(Be,{children:s(wa,{data:u,margin:{top:15,right:18,left:18,bottom:5},children:[s("defs",{children:[s("linearGradient",{id:"dimensionPrimarySegmentsBarColor",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:f,stopOpacity:1}),e("stop",{offset:"95%",stopColor:f,stopOpacity:.5})]}),s("linearGradient",{id:"dimensionReferenceSegmentsBarColor",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:m,stopOpacity:1}),e("stop",{offset:"95%",stopColor:m,stopOpacity:.5})]})]}),e(He,{dataKey:"name",style:{fill:"var(--ac-global-text-color-700)"}}),e(xe,{stroke:le.colors.gray200,label:{value:"Percent",angle:-90,position:"insideLeft",style:{textAnchor:"middle",fill:"var(--ac-global-text-color-900)"}},style:{fill:"var(--ac-global-text-color-700)"}}),e(Ge,{strokeDasharray:"4 4",stroke:le.colors.gray200,strokeOpacity:.5}),e(We,{...Fa,content:e(Us,{})}),e(fn,{dataKey:"primaryPercent",fill:"url(#dimensionPrimarySegmentsBarColor)"}),e(fn,{dataKey:"referencePercent",fill:"url(#dimensionReferenceSegmentsBarColor)"})]})})})]})}const ql={argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],kind:"Fragment",metadata:null,name:"DimensionDriftStats_dimension",selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:"psi",args:[{kind:"Literal",name:"metric",value:"psi"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],kind:"ScalarField",name:"driftMetric",storageKey:null}],type:"Dimension",abstractKey:null};ql.hash="f8a9fb08a14f63906e38bc247d50b189";const Xs=s(na,{variant:"info",placement:"top end",children:[e(oe,{weight:"heavy",level:4,children:"Population Stability Index"}),e(ea,{children:e(K,{children:"PSI is a symmetric metric that measures the relative entropy, or difference in information represented by two distributions. It can be thought of as measuring the distance between two data distributions showing how different the two distributions are from each other."})}),e("footer",{children:e(Rn,{href:"https://arize.com/blog-course/population-stability-index-psi/#:~:text=Population%20Stability%20Index%20(PSI)%20Overview,distributions%20are%20from%20each%20other.",children:"Learn more"})})]});function Zs(n){const a=_.useFragment(ql,n.dimension);return s(W,{children:[s(k,{direction:"row",alignItems:"center",gap:"size-25",children:[e(K,{elementType:"h3",textSize:"small",color:"text-700",children:"PSI"}),Xs]}),e(K,{textSize:"xlarge",children:gn(a.psi)})]})}const Bl=function(){var n={defaultValue:null,kind:"LocalArgument",name:"countGranularity"},a={defaultValue:null,kind:"LocalArgument",name:"dimensionId"},l={defaultValue:null,kind:"LocalArgument",name:"driftGranularity"},t={defaultValue:null,kind:"LocalArgument",name:"timeRange"},i=[{kind:"Variable",name:"id",variableName:"dimensionId"}],r={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},o={kind:"Variable",name:"timeRange",variableName:"timeRange"},c=[{alias:null,args:null,concreteType:"TimeSeriesDataPoint",kind:"LinkedField",name:"data",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"timestamp",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}],storageKey:null}],d={kind:"InlineFragment",selections:[{alias:null,args:[{kind:"Variable",name:"granularity",variableName:"driftGranularity"},{kind:"Literal",name:"metric",value:"psi"},o],concreteType:"DriftTimeSeries",kind:"LinkedField",name:"driftTimeSeries",plural:!1,selections:c,storageKey:null},{alias:"trafficTimeSeries",args:[{kind:"Variable",name:"granularity",variableName:"countGranularity"},{kind:"Literal",name:"metric",value:"count"},o],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:c,storageKey:null}],type:"Dimension",abstractKey:null};return{fragment:{argumentDefinitions:[n,a,l,t],kind:"Fragment",metadata:null,name:"DimensionDriftTimeSeriesQuery",selections:[{alias:"embedding",args:i,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[r,d],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[a,t,l,n],kind:"Operation",name:"DimensionDriftTimeSeriesQuery",selections:[{alias:"embedding",args:i,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},r,d],storageKey:null}]},params:{cacheID:"af2d25e28675891b3c8a6bc75027f731",id:null,metadata:{},name:"DimensionDriftTimeSeriesQuery",operationKind:"query",text:`query DimensionDriftTimeSeriesQuery(
  $dimensionId: GlobalID!
  $timeRange: TimeRange!
  $driftGranularity: Granularity!
  $countGranularity: Granularity!
) {
  embedding: node(id: $dimensionId) {
    __typename
    id
    ... on Dimension {
      driftTimeSeries(metric: psi, timeRange: $timeRange, granularity: $driftGranularity) {
        data {
          timestamp
          value
        }
      }
      trafficTimeSeries: dataQualityTimeSeries(metric: count, timeRange: $timeRange, granularity: $countGranularity) {
        data {
          timestamp
          value
        }
      }
    }
  }
}
`}}}();Bl.hash="6312b58dbb252b17efdf08d44dd58630";const Hl=()=>{const{orange300:n,gray300:a}=Pe();return{color:n,barColor:a}};function Ys({active:n,payload:a,label:l}){var i;const{color:t}=Hl();if(n&&a&&a.length){const r=((i=a[1])==null?void 0:i.value)??null;return s(qe,{children:[e(K,{weight:"heavy",textSize:"medium",children:`${ln(new Date(l))}`}),e(te,{color:t,name:"PSI",value:gn(r)}),e(Jn,{}),s("div",{css:F`
            display: flex;
            flex-direction: row;
            align-items: center;
            color: var(--ac-global-color-primary);
            gap: var(--px-spacing-sm);

            margin-top: var(--px-spacing-sm);
          `,children:[e(N,{svg:e(pl,{})}),e("span",{children:"Click to view details"})]})]})}return null}function eo({dimensionId:n}){var y,b;const{timeRange:a}=we(),{selectedTimestamp:l,setSelectedTimestamp:t}=Un(),i=hn(a),r=_.useLazyLoadQuery(Bl,{dimensionId:n,timeRange:{start:a.start.toISOString(),end:a.end.toISOString()},driftGranularity:tl(a),countGranularity:i}),o=((y=r.embedding.driftTimeSeries)==null?void 0:y.data)||[],c=((b=r.embedding.trafficTimeSeries)==null?void 0:b.data.reduce((S,h)=>(S[h.timestamp]=h.value,S),{}))??{},d=o.map(S=>{const h=c[S.timestamp];return{...S,traffic:h,timestamp:new Date(S.timestamp).valueOf()}}),u=kn({samplingIntervalMinutes:i.samplingIntervalMinutes}),f=g.useCallback(S=>{const{activePayload:h}=S;if(h!=null&&h.length>0){const x=h[0].payload;t(new Date(x.timestamp))}},[t]),{color:m,barColor:p}=Hl();return e(Be,{width:"100%",height:"100%",children:s(On,{data:d,margin:jn,onClick:f,syncId:"dimensionDetails",children:[s("defs",{children:[s("linearGradient",{id:"dimensionDriftColorUv",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:m,stopOpacity:.8}),e("stop",{offset:"95%",stopColor:m,stopOpacity:0})]}),s("linearGradient",{id:"barColor",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:p,stopOpacity:.8}),e("stop",{offset:"95%",stopColor:p,stopOpacity:0})]})]}),e(He,{...bn,tickFormatter:S=>u(new Date(S))}),e(xe,{stroke:le.colors.gray200,label:{value:"PSI",angle:-90,position:"insideLeft",style:{textAnchor:"middle",fill:"var(--ac-global-text-color-900)"}},style:{fill:"var(--ac-global-text-color-700)"}}),e(xe,{yAxisId:"right",orientation:"right",tick:!1,tickLine:!1,width:0}),e(Ge,{strokeDasharray:"4 4",stroke:le.colors.gray200,strokeOpacity:.5}),e(We,{content:e(Ys,{})}),e(fn,{yAxisId:"right",dataKey:"traffic",fill:"url(#barColor)",spacing:5}),e(wn,{type:"monotone",dataKey:"value",stroke:m,fillOpacity:1,fill:"url(#dimensionDriftColorUv)"}),l!=null?e(bl,{...il,x:l.getTime()}):null]})})}const Gl=function(){var n={kind:"Literal",name:"metric",value:"percentEmpty"};return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"hasReference"},{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],kind:"Fragment",metadata:null,name:"DimensionPercentEmptyStats_dimension",selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:"percentEmpty",args:[n,{kind:"Variable",name:"timeRange",variableName:"timeRange"}],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{condition:"hasReference",kind:"Condition",passingValue:!0,selections:[{alias:"referencePercentEmpty",args:[{kind:"Literal",name:"inferencesRole",value:"reference"},n],kind:"ScalarField",name:"dataQualityMetric",storageKey:'dataQualityMetric(inferencesRole:"reference",metric:"percentEmpty")'}]}],type:"Dimension",abstractKey:null}}();Gl.hash="1e10d0449d6607d9292f355548c41c78";function no(n){const a=_.useFragment(Gl,n.dimension);return s(W,{children:[e(K,{elementType:"h3",textSize:"small",color:"text-700",children:"% Empty"}),e(K,{textSize:"xlarge",children:ka(a.percentEmpty)}),a.referencePercentEmpty!=null&&e(K,{textSize:"medium",color:"designationPurple",children:ka(a.referencePercentEmpty)})]})}const Wl=function(){var n={defaultValue:null,kind:"LocalArgument",name:"dimensionId"},a={defaultValue:null,kind:"LocalArgument",name:"granularity"},l={defaultValue:null,kind:"LocalArgument",name:"timeRange"},t=[{kind:"Variable",name:"id",variableName:"dimensionId"}],i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},r={kind:"InlineFragment",selections:[{alias:"percentEmptyTimeSeries",args:[{kind:"Variable",name:"granularity",variableName:"granularity"},{kind:"Literal",name:"metric",value:"percentEmpty"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:[{alias:null,args:null,concreteType:"TimeSeriesDataPoint",kind:"LinkedField",name:"data",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"timestamp",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}],storageKey:null}],storageKey:null}],type:"Dimension",abstractKey:null};return{fragment:{argumentDefinitions:[n,a,l],kind:"Fragment",metadata:null,name:"DimensionPercentEmptyTimeSeriesQuery",selections:[{alias:"embedding",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[i,r],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[n,l,a],kind:"Operation",name:"DimensionPercentEmptyTimeSeriesQuery",selections:[{alias:"embedding",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i,r],storageKey:null}]},params:{cacheID:"9be05c72f19755036f4829777a96f97d",id:null,metadata:{},name:"DimensionPercentEmptyTimeSeriesQuery",operationKind:"query",text:`query DimensionPercentEmptyTimeSeriesQuery(
  $dimensionId: GlobalID!
  $timeRange: TimeRange!
  $granularity: Granularity!
) {
  embedding: node(id: $dimensionId) {
    __typename
    id
    ... on Dimension {
      percentEmptyTimeSeries: dataQualityTimeSeries(metric: percentEmpty, timeRange: $timeRange, granularity: $granularity) {
        data {
          timestamp
          value
        }
      }
    }
  }
}
`}}}();Wl.hash="1e843d6c8dbe05b389b24188c6bdb394";const ao=new Intl.NumberFormat([],{maximumFractionDigits:2}),Ul=()=>{const{gray100:n}=Pe();return{color:n}};function lo({active:n,payload:a,label:l}){var i;const{color:t}=Ul();if(n&&a&&a.length){const r=((i=a[0])==null?void 0:i.value)??null,o=typeof r=="number"?ao.format(r):"--";return s(qe,{children:[e(K,{weight:"heavy",textSize:"medium",children:`${ln(new Date(l))}`}),e(te,{color:t,name:"% Empty",value:o})]})}return null}function to({dimensionId:n}){var c;const{timeRange:a}=we(),l=hn(a),i=((c=_.useLazyLoadQuery(Wl,{dimensionId:n,timeRange:{start:a.start.toISOString(),end:a.end.toISOString()},granularity:l}).embedding.percentEmptyTimeSeries)==null?void 0:c.data.map(d=>({timestamp:new Date(d.timestamp).valueOf(),value:d.value})))||[],r=kn({samplingIntervalMinutes:l.samplingIntervalMinutes}),{color:o}=Ul();return e(Be,{width:"100%",height:"100%",children:s(On,{data:i,margin:jn,syncId:"dimensionDetails",children:[e("defs",{children:s("linearGradient",{id:"percentEmptyColorUv",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:o,stopOpacity:.8}),e("stop",{offset:"95%",stopColor:o,stopOpacity:0})]})}),e(He,{...bn,tickFormatter:d=>r(new Date(d))}),e(xe,{stroke:le.colors.gray200,label:{value:"% Empty",angle:-90,position:"insideLeft",style:{textAnchor:"middle",fill:"var(--ac-global-text-color-900)"}},style:{fill:"var(--ac-global-text-color-700)"}}),e(Ge,{strokeDasharray:"4 4",stroke:le.colors.gray200,strokeOpacity:.5}),e(We,{content:e(lo,{})}),e(Sl,{type:"monotone",dataKey:"value",stroke:o,fillOpacity:1,fill:"url(#percentEmptyColorUv)"})]})})}const Jl=function(){var n={kind:"Variable",name:"timeRange",variableName:"timeRange"};return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],kind:"Fragment",metadata:null,name:"DimensionQuantilesStats_dimension",selections:[{alias:"p99",args:[{kind:"Literal",name:"metric",value:"p99"},n],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"p75",args:[{kind:"Literal",name:"metric",value:"p75"},n],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"p50",args:[{kind:"Literal",name:"metric",value:"p50"},n],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"p25",args:[{kind:"Literal",name:"metric",value:"p25"},n],kind:"ScalarField",name:"dataQualityMetric",storageKey:null},{alias:"p1",args:[{kind:"Literal",name:"metric",value:"p01"},n],kind:"ScalarField",name:"dataQualityMetric",storageKey:null}],type:"Dimension",abstractKey:null}}();Jl.hash="c306c8eafb1d34be464d3a658d5f94a7";function io(n){const a=_.useFragment(Jl,n.dimension);return e("ul",{css:F`
        display: flex;
        flex-direction: column;
        gap: var(--px-spacing-sm);
      `,children:Object.keys(a).map(l=>{const t=a[l];return s("li",{css:F`
              display: flex;
              flex-direction: column;
              align-items: flex-end;
            `,children:[e(K,{elementType:"h3",textSize:"xsmall",color:"text-700",children:l}),e(K,{textSize:"medium","data-raw":t,children:xa(t)})]},l)})})}const Xl=function(){var n={defaultValue:null,kind:"LocalArgument",name:"dimensionId"},a={defaultValue:null,kind:"LocalArgument",name:"granularity"},l={defaultValue:null,kind:"LocalArgument",name:"timeRange"},t=[{kind:"Variable",name:"id",variableName:"dimensionId"}],i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},r={kind:"Variable",name:"granularity",variableName:"granularity"},o={kind:"Variable",name:"timeRange",variableName:"timeRange"},c=[{alias:null,args:null,concreteType:"TimeSeriesDataPoint",kind:"LinkedField",name:"data",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"timestamp",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}],storageKey:null}],d={kind:"InlineFragment",selections:[{alias:"p99TimeSeries",args:[r,{kind:"Literal",name:"metric",value:"p99"},o],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:c,storageKey:null},{alias:"p75TimeSeries",args:[r,{kind:"Literal",name:"metric",value:"p75"},o],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:c,storageKey:null},{alias:"p50TimeSeries",args:[r,{kind:"Literal",name:"metric",value:"p50"},o],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:c,storageKey:null},{alias:"p25TimeSeries",args:[r,{kind:"Literal",name:"metric",value:"p25"},o],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:c,storageKey:null},{alias:"p01TimeSeries",args:[r,{kind:"Literal",name:"metric",value:"p01"},o],concreteType:"DataQualityTimeSeries",kind:"LinkedField",name:"dataQualityTimeSeries",plural:!1,selections:c,storageKey:null}],type:"Dimension",abstractKey:null};return{fragment:{argumentDefinitions:[n,a,l],kind:"Fragment",metadata:null,name:"DimensionQuantilesTimeSeriesQuery",selections:[{alias:"dimension",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[i,d],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[n,l,a],kind:"Operation",name:"DimensionQuantilesTimeSeriesQuery",selections:[{alias:"dimension",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i,d],storageKey:null}]},params:{cacheID:"0bb3d9faf9d7f0c2e27995120ae24e1c",id:null,metadata:{},name:"DimensionQuantilesTimeSeriesQuery",operationKind:"query",text:`query DimensionQuantilesTimeSeriesQuery(
  $dimensionId: GlobalID!
  $timeRange: TimeRange!
  $granularity: Granularity!
) {
  dimension: node(id: $dimensionId) {
    __typename
    id
    ... on Dimension {
      p99TimeSeries: dataQualityTimeSeries(metric: p99, timeRange: $timeRange, granularity: $granularity) {
        data {
          timestamp
          value
        }
      }
      p75TimeSeries: dataQualityTimeSeries(metric: p75, timeRange: $timeRange, granularity: $granularity) {
        data {
          timestamp
          value
        }
      }
      p50TimeSeries: dataQualityTimeSeries(metric: p50, timeRange: $timeRange, granularity: $granularity) {
        data {
          timestamp
          value
        }
      }
      p25TimeSeries: dataQualityTimeSeries(metric: p25, timeRange: $timeRange, granularity: $granularity) {
        data {
          timestamp
          value
        }
      }
      p01TimeSeries: dataQualityTimeSeries(metric: p01, timeRange: $timeRange, granularity: $granularity) {
        data {
          timestamp
          value
        }
      }
    }
  }
}
`}}}();Xl.hash="134f0dad0e0ecc7863dfbb0f437d829b";const ro=Sa("~s");var Zl=(n=>(n.p99_p01="p99_p01",n.p75_p25="p75_p25",n.p50="p50",n))(Zl||{});const so=new Intl.NumberFormat([],{maximumFractionDigits:2});function Ln(n){return typeof n=="number"?so.format(n):"--"}const Yl=()=>{const n=Pe();return{outerColor:n.gray500,innerColor:n.gray300,lineColor:n.default}};function oo({active:n,payload:a,label:l}){const{outerColor:t,innerColor:i,lineColor:r}=Yl();if(n&&a&&a.length){const o=a[0].payload;return s(qe,{children:[e(K,{weight:"heavy",textSize:"medium",children:`${ln(new Date(l))}`}),e(te,{color:t,name:"p99",value:Ln(o.p99_p01[0])}),e(te,{color:i,name:"p75",value:Ln(o.p75_p25[0])}),e(te,{color:r,name:"p50",value:Ln(o.p50)}),e(te,{color:i,name:"p25",value:Ln(o.p75_p25[1])}),e(te,{color:t,name:"p01",value:Ln(o.p99_p01[1])})]})}return null}function co({dimensionId:n}){var I,C,v,T,P;const{timeRange:a}=we(),l=hn(a),t=_.useLazyLoadQuery(Xl,{dimensionId:n,timeRange:{start:a.start.toISOString(),end:a.end.toISOString()},granularity:l}),i=((I=t.dimension.p99TimeSeries)==null?void 0:I.data.map(R=>R))||[],r=((C=t.dimension.p01TimeSeries)==null?void 0:C.data.map(R=>R))||[],o=((v=t.dimension.p75TimeSeries)==null?void 0:v.data.map(R=>R))||[],c=((T=t.dimension.p25TimeSeries)==null?void 0:T.data.map(R=>R))||[],d=((P=t.dimension.p50TimeSeries)==null?void 0:P.data.map(R=>R))||[],u=i.map((R,z)=>({timestamp:new Date(R.timestamp).valueOf(),p99_p01:[R.value,r[z].value],p75_p25:[o[z].value,c[z].value],p50:d[z].value})),f=kn({samplingIntervalMinutes:l.samplingIntervalMinutes}),[m,p]=g.useState(Object.keys(Zl).reduce((R,z)=>(R[z]=!1,R),{})),y=R=>{m[R.dataKey]||p({...m})},b=()=>{p({...m})},S=R=>{p({...m,[String(R.dataKey)]:!m[R.dataKey]})},{outerColor:h,innerColor:x,lineColor:L}=Yl();return e(Be,{width:"100%",height:"100%",children:s(On,{data:u,margin:jn,syncId:"dimensionDetails",children:[s("defs",{children:[s("linearGradient",{id:"p99_p01ColorUV",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"10%",stopColor:h,stopOpacity:.7}),e("stop",{offset:"50%",stopColor:h,stopOpacity:.3}),e("stop",{offset:"90%",stopColor:h,stopOpacity:.7})]}),s("linearGradient",{id:"p75_p25ColorUV",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"10%",stopColor:x,stopOpacity:.7}),e("stop",{offset:"50%",stopColor:x,stopOpacity:.3}),e("stop",{offset:"90%",stopColor:x,stopOpacity:.7})]})]}),e(He,{...bn,tickFormatter:R=>f(new Date(R))}),e(xe,{stroke:le.colors.gray200,label:{value:"Value",angle:-90,position:"insideLeft",style:{textAnchor:"middle",fill:"var(--ac-global-text-color-900)"}},tickFormatter:R=>ro(R),style:{fill:"var(--ac-global-text-color-700)"}}),e(Ge,{strokeDasharray:"4 4",stroke:le.colors.gray200,strokeOpacity:.5}),e(We,{content:e(oo,{})}),e(Br,{onClick:S,onMouseOver:y,onMouseOut:b}),e(wn,{type:"monotone",dataKey:"p99_p01",name:"p99 - p01",fillOpacity:1,fill:"url(#p99_p01ColorUV)",stroke:h,hide:m.p99_p01===!0}),e(wn,{type:"monotone",dataKey:"p75_p25",name:"p75 - p25",fillOpacity:1,stroke:x,fill:"url(#p75_p25ColorUV)",hide:m.p75_p25===!0}),e(Sl,{type:"monotone",dataKey:"p50",stroke:L,hide:m.p50===!0})]})})}const et=function(){var n={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},a=[{alias:null,args:null,kind:"ScalarField",name:"primaryValue",storageKey:null}];return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],kind:"Fragment",metadata:null,name:"DimensionSegmentsBarChart_dimension",selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:[{kind:"Variable",name:"primaryTimeRange",variableName:"timeRange"}],concreteType:"Segments",kind:"LinkedField",name:"segmentsComparison",plural:!1,selections:[{alias:null,args:null,concreteType:"Segment",kind:"LinkedField",name:"segments",plural:!0,selections:[{alias:null,args:null,concreteType:null,kind:"LinkedField",name:"bin",plural:!1,selections:[{kind:"InlineFragment",selections:[n,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null}],type:"NominalBin",abstractKey:null},{kind:"InlineFragment",selections:[n,{alias:null,args:null,concreteType:"NumericRange",kind:"LinkedField",name:"range",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"start",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"end",storageKey:null}],storageKey:null}],type:"IntervalBin",abstractKey:null},{kind:"InlineFragment",selections:[n],type:"MissingValueBin",abstractKey:null}],storageKey:null},{alias:null,args:null,concreteType:"DatasetValues",kind:"LinkedField",name:"counts",plural:!1,selections:a,storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"DatasetValues",kind:"LinkedField",name:"totalCounts",plural:!1,selections:a,storageKey:null}],storageKey:null}],type:"Dimension",abstractKey:null}}();et.hash="8cef9841e9a5bd7d0d50acb5db9028b0";const uo=Sa(".2f"),nt=()=>{const{primary:n}=Pe();return{color:n}};function mo({active:n,payload:a,label:l}){var i;const{color:t}=nt();if(n&&a&&a.length){const r=(i=a[0])==null?void 0:i.value;return e(qe,{children:e(te,{color:t,shape:"square",name:l,value:r!=null?`${uo(r)}%`:"--"})})}return null}function go(n){const a=_.useFragment(et,n.dimension),l=g.useMemo(()=>{var o,c,d;const i=((o=a.segmentsComparison)==null?void 0:o.segments)??[],r=((d=(c=a.segmentsComparison)==null?void 0:c.totalCounts)==null?void 0:d.primaryValue)??0;return i.map(u=>{var y;const f=((y=u.counts)==null?void 0:y.primaryValue)??0,m=ol(u.bin),p=f/r*100;return{name:m,percent:p}})},[a]),{color:t}=nt();return e(Be,{children:s(wa,{data:l,margin:{top:25,right:18,left:18,bottom:5},children:[e("defs",{children:s("linearGradient",{id:"dimensionSegmentsBarColor",x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"5%",stopColor:t,stopOpacity:1}),e("stop",{offset:"95%",stopColor:t,stopOpacity:.5})]})}),e(He,{dataKey:"name",style:{fill:"var(--ac-global-text-color-700)"}}),e(xe,{stroke:le.colors.gray200,label:{value:"% Volume",angle:-90,position:"insideLeft",style:{textAnchor:"middle",fill:"var(--ac-global-text-color-900)"}},style:{fill:"var(--ac-global-text-color-700)"}}),e(Ge,{strokeDasharray:"4 4",stroke:le.colors.gray200,strokeOpacity:.5}),e(We,{...Fa,content:e(mo,{})}),e(fn,{dataKey:"percent",fill:"url(#dimensionSegmentsBarColor)",spacing:15})]})})}function Nc(){const{dimensionId:n}=je(),{timeRange:a}=we(),l=Nn(),{referenceInferences:t}=Te(),i=t!==null,r=i,o=l.dimension.shape!=="continuous",c=l.dimension.dataType==="numeric",d=ne(),u=_.useLazyLoadQuery(Ml,{dimensionId:n,timeRange:{start:a.start.toISOString(),end:a.end.toISOString()},hasReference:i});if(!n)throw new Error("Dimension ID is required to display a dimension");return e(sl,{initialTimestamp:new Date(a.end),children:e(ae,{type:"slideOver",isDismissable:!0,onDismiss:()=>d(-1),children:e(X,{size:"L",title:l.dimension.name,children:e("main",{css:F`
              padding: var(--px-spacing-med);
              display: flex;
              flex-direction: column;
              min-height: 400px;
              overflow-y: auto;
              height: 100%;
            `,children:e(g.Suspense,{fallback:e(pe,{}),children:s(k,{direction:"column",gap:"size-100",children:[e(D,{borderColor:"dark",borderRadius:"medium",borderWidth:"thin",height:"size-1600",children:e(go,{dimension:u.dimension})}),e(D,{borderColor:"dark",borderRadius:"medium",borderWidth:"thin",height:"size-1600","data-testid":"dimension-count-time-series-view",children:s(k,{direction:"row",alignItems:"stretch",height:"100%",children:[e(Ws,{dimensionId:n}),e(un,{children:e(Bs,{dimension:u.dimension})})]})}),r?e(D,{borderColor:"dark",borderRadius:"medium",borderWidth:"thin",children:s(k,{direction:"column",alignItems:"stretch",children:[e(D,{width:"100%",height:"size-1600",children:s(k,{direction:"row",alignItems:"stretch",height:"100%",children:[e(D,{flex:!0,children:e(eo,{dimensionId:n})}),e(un,{children:e(Zs,{dimension:u.dimension})})]})}),e(D,{height:"size-1600",width:"100%",borderTopColor:"dark",borderTopWidth:"thin",children:e(g.Suspense,{fallback:e(pe,{}),children:e(Js,{dimensionId:n})})})]})}):null,c?e(D,{borderColor:"dark",borderRadius:"medium",borderWidth:"thin",height:"size-3000",children:s(k,{direction:"row",alignItems:"stretch",height:"100%",children:[e(D,{flex:!0,children:e(co,{dimensionId:n})}),e(un,{children:e(io,{dimension:u.dimension})})]})}):null,o?e(D,{borderColor:"dark",borderRadius:"medium",borderWidth:"thin",height:"size-1600",children:s(k,{direction:"row",alignItems:"stretch",height:"100%",children:[e(D,{flex:!0,children:e(qs,{dimensionId:n})}),e(un,{children:e(Qs,{dimension:u.dimension})})]})}):null,e(D,{borderColor:"dark",borderRadius:"medium",borderWidth:"thin",height:"size-1600",children:s(k,{direction:"row",alignItems:"stretch",height:"100%",children:[e(to,{dimensionId:n}),e(un,{children:e(no,{dimension:u.dimension})})]})})]})})})})})})}const at=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},i={alias:null,args:null,kind:"ScalarField",name:"dataType",storageKey:null},r={alias:null,args:null,kind:"ScalarField",name:"shape",storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"dimensionLoaderQuery",selections:[{alias:"dimension",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{kind:"InlineFragment",selections:[l,t,i,r],type:"Dimension",abstractKey:null}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"dimensionLoaderQuery",selections:[{alias:"dimension",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},l,{kind:"InlineFragment",selections:[t,i,r],type:"Dimension",abstractKey:null}],storageKey:null}]},params:{cacheID:"03a9aafe3f08a9d093b029ff4a9e3253",id:null,metadata:{},name:"dimensionLoaderQuery",operationKind:"query",text:`query dimensionLoaderQuery(
  $id: GlobalID!
) {
  dimension: node(id: $id) {
    __typename
    ... on Dimension {
      id
      name
      dataType
      shape
    }
    __isNode: __typename
    id
  }
}
`}}}();at.hash="5a662d77e69d2e9bb4eb2af4cad6b722";async function $c(n){const{dimensionId:a}=n.params;return _.fetchQuery(Ke,at,{id:a}).toPromise()}const lt=function(){var n={defaultValue:null,kind:"LocalArgument",name:"id"},a={defaultValue:null,kind:"LocalArgument",name:"traceId"},l=[{kind:"Variable",name:"id",variableName:"id"}],t=[{kind:"Variable",name:"traceId",variableName:"traceId"}],i=[{kind:"Literal",name:"first",value:1e3}],r={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},o={alias:null,args:null,concreteType:"SpanContext",kind:"LinkedField",name:"context",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"spanId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null}],storageKey:null},c={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},d={alias:null,args:null,kind:"ScalarField",name:"spanKind",storageKey:null},u={alias:"statusCode",args:null,kind:"ScalarField",name:"propagatedStatusCode",storageKey:null},f={alias:null,args:null,kind:"ScalarField",name:"statusMessage",storageKey:null},m={alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},p={alias:null,args:null,kind:"ScalarField",name:"parentId",storageKey:null},y={alias:null,args:null,kind:"ScalarField",name:"latencyMs",storageKey:null},b={alias:null,args:null,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},S={alias:null,args:null,kind:"ScalarField",name:"tokenCountPrompt",storageKey:null},h={alias:null,args:null,kind:"ScalarField",name:"tokenCountCompletion",storageKey:null},x=[{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"mimeType",storageKey:null}],L={alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"input",plural:!1,selections:x,storageKey:null},I={alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"output",plural:!1,selections:x,storageKey:null},C={alias:null,args:null,kind:"ScalarField",name:"attributes",storageKey:null},v={alias:null,args:null,concreteType:"SpanEvent",kind:"LinkedField",name:"events",plural:!0,selections:[c,{alias:null,args:null,kind:"ScalarField",name:"message",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"timestamp",storageKey:null}],storageKey:null},T={alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},P={alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null},R={alias:null,args:null,concreteType:"DocumentRetrievalMetrics",kind:"LinkedField",name:"documentRetrievalMetrics",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"evaluationName",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"ndcg",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"precision",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hit",storageKey:null}],storageKey:null},z={alias:null,args:null,kind:"ScalarField",name:"explanation",storageKey:null},j={alias:null,args:null,concreteType:"DocumentEvaluation",kind:"LinkedField",name:"documentEvaluations",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"documentPosition",storageKey:null},c,T,P,z],storageKey:null};return{fragment:{argumentDefinitions:[n,a],kind:"Fragment",metadata:null,name:"TraceDetailsQuery",selections:[{alias:"project",args:l,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{kind:"InlineFragment",selections:[{alias:null,args:t,concreteType:"Trace",kind:"LinkedField",name:"trace",plural:!1,selections:[{alias:null,args:i,concreteType:"SpanConnection",kind:"LinkedField",name:"spans",plural:!1,selections:[{alias:null,args:null,concreteType:"SpanEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"span",args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[r,o,c,d,u,f,m,p,y,b,S,h,L,I,C,v,{alias:null,args:null,concreteType:"SpanEvaluation",kind:"LinkedField",name:"spanEvaluations",plural:!0,selections:[c,T,P],storageKey:null},R,j,{args:null,kind:"FragmentSpread",name:"SpanEvaluationsTable_evals"}],storageKey:null}],storageKey:null}],storageKey:"spans(first:1000)"}],storageKey:null}],type:"Project",abstractKey:null}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[a,n],kind:"Operation",name:"TraceDetailsQuery",selections:[{alias:"project",args:l,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"InlineFragment",selections:[{alias:null,args:t,concreteType:"Trace",kind:"LinkedField",name:"trace",plural:!1,selections:[{alias:null,args:i,concreteType:"SpanConnection",kind:"LinkedField",name:"spans",plural:!1,selections:[{alias:null,args:null,concreteType:"SpanEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"span",args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[r,o,c,d,u,f,m,p,y,b,S,h,L,I,C,v,{alias:null,args:null,concreteType:"SpanEvaluation",kind:"LinkedField",name:"spanEvaluations",plural:!0,selections:[c,T,P,z],storageKey:null},R,j],storageKey:null}],storageKey:null}],storageKey:"spans(first:1000)"}],storageKey:null}],type:"Project",abstractKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},r],storageKey:null}]},params:{cacheID:"a7eb8bfce36ca7633be29b3bde1952b8",id:null,metadata:{},name:"TraceDetailsQuery",operationKind:"query",text:`query TraceDetailsQuery(
  $traceId: ID!
  $id: GlobalID!
) {
  project: node(id: $id) {
    __typename
    ... on Project {
      trace(traceId: $traceId) {
        spans(first: 1000) {
          edges {
            span: node {
              id
              context {
                spanId
                traceId
              }
              name
              spanKind
              statusCode: propagatedStatusCode
              statusMessage
              startTime
              parentId
              latencyMs
              tokenCountTotal
              tokenCountPrompt
              tokenCountCompletion
              input {
                value
                mimeType
              }
              output {
                value
                mimeType
              }
              attributes
              events {
                name
                message
                timestamp
              }
              spanEvaluations {
                name
                label
                score
              }
              documentRetrievalMetrics {
                evaluationName
                ndcg
                precision
                hit
              }
              documentEvaluations {
                documentPosition
                name
                label
                score
                explanation
              }
              ...SpanEvaluationsTable_evals
            }
          }
        }
      }
    }
    __isNode: __typename
    id
  }
}

fragment SpanEvaluationsTable_evals on Span {
  spanEvaluations {
    name
    label
    score
    explanation
  }
}
`}}}();lt.hash="77c479ec3740896d2dadf3010f72760a";function tt(n){return s(ge,{children:[e(ze,{children:e(ca,{children:n.tokenCountTotal})}),e(Xe,{children:s(k,{direction:"column",gap:"size-50",children:[s(k,{direction:"row",gap:"size-100",justifyContent:"space-between",children:["prompt tokens",e(ca,{children:n.tokenCountPrompt})]}),s(k,{direction:"row",gap:"size-100",justifyContent:"space-between",children:["completion tokens",e(ca,{children:n.tokenCountCompletion})]})]})})]})}function ca({children:n}){return s(k,{direction:"row",gap:"size-25",alignItems:"center",children:[e(N,{svg:e(M.TokensOutline,{}),css:F`
          color: var(--ac-global-text-color-900);
        `}),e(K,{children:n})]})}const qa=F`
  display: flex;
  align-items: center;
  .ac-text {
    display: inline-block;
    max-width: 9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
`;function Ma({evaluation:n}){const a=n.label||typeof n.score=="number"&&Ce(n.score)||"n/a";return s(ge,{delay:500,offset:3,children:[e(ze,{children:e(yn,{color:"cyan-1000",shape:"badge",children:s(k,{direction:"row",gap:"size-50",children:[e("div",{css:qa,children:e(K,{weight:"heavy",textSize:"small",color:"inherit",children:n.name})}),e("div",{css:qa,children:e(K,{textSize:"small",children:a})})]})})}),e(Xe,{children:s(k,{direction:"row",gap:"size-100",children:[e(K,{weight:"heavy",textSize:"small",color:"inherit",children:n.name}),e(K,{textSize:"small",color:"inherit",children:a})]})})]})}const ua=F`
  display: flex;
  align-items: center;
  .ac-text {
    display: inline-block;
    max-width: 9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
`;function ce(n){const{name:a,metric:l,k:t,score:i}=n,r=typeof t=="number"?`${l}@${t}`:l,o=g.useMemo(()=>l==="hit"?i?"true":"false":typeof i=="number"&&Ce(i)||"--",[i,l]);return s(ge,{delay:500,offset:3,children:[e(ze,{children:e(yn,{color:"seafoam-1000",shape:"badge",children:s(k,{direction:"row",gap:"size-50",children:[a?e("div",{css:ua,children:e(K,{weight:"heavy",textSize:"small",color:"inherit",children:a})}):null,e("div",{css:ua,children:e(K,{textSize:"small",color:"inherit",children:r})}),e("div",{css:ua,children:e(K,{textSize:"small",children:o})})]})})}),e(Xe,{children:s(k,{direction:"row",gap:"size-100",children:[s(K,{weight:"heavy",textSize:"small",color:"inherit",children:[a," ",r]}),e(K,{textSize:"small",color:"inherit",children:o})]})})]})}function po(n){const{spanId:a,traceId:l}=n;return e("div",{css:F`
        button.ac-dropdown-button {
          min-width: 50px;
          .ac-dropdown-button__text {
            padding-right: 10px;
          }
        }
      `,children:s(Kn,{placement:"bottom right",children:[e(kl,{addonBefore:e(N,{svg:e(M.Code,{})}),children:"Code"}),e(Ia,{children:e(D,{padding:"size-200",children:s(_n,{children:[s(k,{direction:"row",gap:"size-100",alignItems:"end",children:[e(Ne,{label:"Span ID",isReadOnly:!0,value:a}),e(J,{text:a,size:"normal"})]}),s(k,{direction:"row",gap:"size-100",alignItems:"end",children:[e(Ne,{label:"Trace ID",isReadOnly:!0,value:l}),e(J,{text:l,size:"normal"})]})]})})})]})})}const it={argumentDefinitions:[],kind:"Fragment",metadata:null,name:"SpanEvaluationsTable_evals",selections:[{alias:null,args:null,concreteType:"SpanEvaluation",kind:"LinkedField",name:"spanEvaluations",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"explanation",storageKey:null}],storageKey:null}],type:"Span",abstractKey:null};it.hash="0604d02236eeb7e73817a68e2e6f12e2";const yo=[{header:"name",accessorKey:"name",size:100},{header:"label",accessorKey:"label",size:100},{header:"score",accessorKey:"score",size:100},{header:"explanation",accessorKey:"explanation",cell:yr,size:400}];function fo(n){const a=_.useFragment(it,n.span),l=g.useMemo(()=>[...a.spanEvaluations],[a.spanEvaluations]),t=he({columns:yo,data:l,getCoreRowModel:ke()}),r=t.getRowModel().rows.length===0;return s("table",{css:zn,children:[e("thead",{children:t.getHeaderGroups().map(o=>e("tr",{children:o.headers.map(c=>e("th",{colSpan:c.colSpan,children:c.isPlaceholder?null:e(W,{children:G(c.column.columnDef.header,c.getContext())})},c.id))},o.id))}),r?e(tn,{}):e("tbody",{children:t.getRowModel().rows.map(o=>e("tr",{children:o.getVisibleCells().map(c=>e("td",{style:{width:c.column.getSize()},children:G(c.column.columnDef.cell,c.getContext())},c.id))},o.id))})]})}const rt=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"input"}],a=[{alias:null,args:[{kind:"Variable",name:"input",variableName:"input"}],concreteType:"DatasetMutationPayload",kind:"LinkedField",name:"addExamplesToDataset",plural:!1,selections:[{alias:null,args:null,concreteType:"Dataset",kind:"LinkedField",name:"dataset",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null}],storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"SpanToDatasetExampleDialogAddExampleToDatasetMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"SpanToDatasetExampleDialogAddExampleToDatasetMutation",selections:a},params:{cacheID:"d93c9d47668fc266ba09ecb14c2b72ae",id:null,metadata:{},name:"SpanToDatasetExampleDialogAddExampleToDatasetMutation",operationKind:"mutation",text:`mutation SpanToDatasetExampleDialogAddExampleToDatasetMutation(
  $input: AddExamplesToDatasetInput!
) {
  addExamplesToDataset(input: $input) {
    dataset {
      id
    }
  }
}
`}}}();rt.hash="75120065d239f28304e9dd91fc34bec9";const st=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"spanId"}],a=[{kind:"Variable",name:"id",variableName:"spanId"}],l={kind:"InlineFragment",selections:[{alias:"revision",args:null,concreteType:"SpanAsExampleRevision",kind:"LinkedField",name:"asExampleRevision",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"input",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"output",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null}],storageKey:null}],type:"Span",abstractKey:null},t={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"SpanToDatasetExampleDialogQuery",selections:[{alias:"span",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l],storageKey:null},{args:null,kind:"FragmentSpread",name:"DatasetPicker__datasets"}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"SpanToDatasetExampleDialogQuery",selections:[{alias:"span",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},l,{kind:"TypeDiscriminator",abstractKey:"__isNode"},t],storageKey:null},{alias:null,args:null,concreteType:"DatasetConnection",kind:"LinkedField",name:"datasets",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"dataset",args:null,concreteType:"Dataset",kind:"LinkedField",name:"node",plural:!1,selections:[t,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}]},params:{cacheID:"340325aadd2b2d81cb509e6b6bee7f0b",id:null,metadata:{},name:"SpanToDatasetExampleDialogQuery",operationKind:"query",text:`query SpanToDatasetExampleDialogQuery(
  $spanId: GlobalID!
) {
  span: node(id: $spanId) {
    __typename
    ... on Span {
      revision: asExampleRevision {
        input
        output
        metadata
      }
    }
    __isNode: __typename
    id
  }
  ...DatasetPicker__datasets
}

fragment DatasetPicker__datasets on Query {
  datasets {
    edges {
      dataset: node {
        id
        name
      }
    }
  }
}
`}}}();st.hash="5afd1a4eede339492f5473ed17b770b3";function ho({str:n,excludePrimitives:a=!1,excludeArray:l=!1}){try{const t=JSON.parse(n);if(a&&typeof t!="object"||l&&Array.isArray(t))return!1}catch{return!1}return!0}function Ee(n){return ho({str:n,excludeArray:!0,excludePrimitives:!0})}const ot={fragment:{argumentDefinitions:[],kind:"Fragment",metadata:null,name:"DatasetPickerRefetchQuery",selections:[{args:null,kind:"FragmentSpread",name:"DatasetPicker__datasets"}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[],kind:"Operation",name:"DatasetPickerRefetchQuery",selections:[{alias:null,args:null,concreteType:"DatasetConnection",kind:"LinkedField",name:"datasets",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"dataset",args:null,concreteType:"Dataset",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}]},params:{cacheID:"38a431d0ba6fa8c12622a1cbb3d1e446",id:null,metadata:{},name:"DatasetPickerRefetchQuery",operationKind:"query",text:`query DatasetPickerRefetchQuery {
  ...DatasetPicker__datasets
}

fragment DatasetPicker__datasets on Query {
  datasets {
    edges {
      dataset: node {
        id
        name
      }
    }
  }
}
`}};ot.hash="03d88d1706089bb63edcd44d04563cbc";const dt={argumentDefinitions:[],kind:"Fragment",metadata:{refetch:{connection:null,fragmentPathInResult:[],operation:ot}},name:"DatasetPicker__datasets",selections:[{alias:null,args:null,concreteType:"DatasetConnection",kind:"LinkedField",name:"datasets",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"dataset",args:null,concreteType:"Dataset",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}],type:"Query",abstractKey:null};dt.hash="03d88d1706089bb63edcd44d04563cbc";function ko(n){const[a,l]=_.useRefetchableFragment(dt,n.query);return s(k,{direction:"row",gap:"size-100",alignItems:"end",children:[e(gl,{label:"dataset","data-testid":"dataset-picker",className:"dataset-picker",width:"100%","aria-label":"The dataset to add the example to",onSelectionChange:n.onSelectionChange,placeholder:"Select a dataset",onBlur:n.onBlur,isRequired:!0,validationState:n.validationState,errorMessage:n.errorMessage,children:a.datasets.edges.map(({dataset:t})=>e(H,{children:t.name},t.id))}),e(bo,{onDatasetCreated:()=>{g.startTransition(()=>{l({},{fetchPolicy:"store-and-network"})})}})]})}function bo({onDatasetCreated:n}){const[a,l]=g.useState(null),[t,i]=g.useState(!1),r=Me();return s(Kn,{placement:"bottom right",isOpen:t,onOpenChange:o=>{l(null),i(o)},children:[e(O,{variant:"default",icon:e(N,{svg:e(M.PlusCircleOutline,{})}),"aria-label":"Create a new dataset"}),e(Q,{title:"Create New Dataset",bodyStyle:{padding:0},variant:"compact",borderColor:"light",backgroundColor:"light",children:s(D,{width:"500px",children:[a?e(ee,{variant:"danger",children:a}):null,e(Ka,{onDatasetCreateError:o=>l(o.message),onDatasetCreated:({id:o,name:c})=>{l(null),i(!1),r({title:"Dataset Created",message:`Dataset "${c}" created successfully`}),n(o)}})]})})]})}const ma={backgroundColor:"light",borderColor:"light",collapsible:!0,bodyStyle:{padding:0}};function So({spanId:n,onCompleted:a}){const[l,t]=g.useState(null),i=_.useLazyLoadQuery(st,{spanId:n},{fetchPolicy:"store-and-network"}),{span:{revision:r}}=i,[o,c]=_.useMutation(rt),{control:d,setError:u,handleSubmit:f,formState:{isValid:m}}=$n({defaultValues:{input:JSON.stringify(r==null?void 0:r.input,null,2),output:JSON.stringify(r==null?void 0:r.output,null,2),metadata:JSON.stringify(r==null?void 0:r.metadata,null,2),datasetId:""}}),p=g.useCallback(y=>{if(t(null),!Ee(y==null?void 0:y.input))return u("input",{message:"Input must be a valid JSON object"});if(!Ee(y==null?void 0:y.output))return u("output",{message:"Output must be a valid JSON object"});if(!Ee(y==null?void 0:y.metadata))return u("metadata",{message:"Metadata must be a valid JSON object"});if(!(y!=null&&y.datasetId))return u("datasetId",{message:"Dataset is required"});o({variables:{input:{datasetId:y.datasetId,examples:[{input:JSON.parse(y.input),output:JSON.parse(y.output),metadata:JSON.parse(y.metadata),spanId:n}]}},onCompleted:()=>{a(y.datasetId)},onError:b=>{t(b.message)}})},[o,u,n,a]);return e(X,{size:"fullscreen",title:"Add Example to Dataset",extra:e(O,{variant:"primary",size:"compact",disabled:!m||c,loading:c,onClick:f(p),icon:e(N,{svg:e(M.PlusCircleOutline,{})}),children:"Add Example"}),children:e("div",{css:F`
          overflow-y: auto;
          padding: var(--ac-global-dimension-size-400);
          /* Make widths configurable */
          .dataset-picker {
            width: 100%;
            .ac-dropdown--picker,
            .ac-dropdown-button {
              width: 100%;
            }
          }
        `,children:e(k,{direction:"row",justifyContent:"center",children:e(D,{width:"900px",paddingStart:"auto",paddingEnd:"auto",children:s(k,{direction:"column",gap:"size-200",children:[l?e(ee,{variant:"danger",children:l}):null,e(Y,{control:d,name:"datasetId",render:({field:{onChange:y,onBlur:b},fieldState:{invalid:S,error:h}})=>e(ko,{onSelectionChange:y,onBlur:b,validationState:S?"invalid":"valid",errorMessage:h==null?void 0:h.message,query:i})}),e(Y,{control:d,name:"input",render:({field:{onChange:y,onBlur:b,value:S},fieldState:{invalid:h,error:x}})=>s(Q,{title:"Input",subTitle:"The input to the LLM, retriever, program, etc.",...ma,children:[h?e(ee,{variant:"danger",banner:!0,children:x==null?void 0:x.message}):null,e(Le,{value:S,onChange:y,onBlur:b})]})}),e(Y,{control:d,name:"output",render:({field:{onChange:y,onBlur:b,value:S},fieldState:{invalid:h,error:x}})=>s(Q,{title:"Output",subTitle:"The output of the LLM or program to be used as an expected output",...ma,backgroundColor:"green-100",borderColor:"green-700",children:[h?e(ee,{variant:"danger",banner:!0,children:x==null?void 0:x.message}):null,e(Le,{value:S,onChange:y,onBlur:b})]})}),e(Y,{control:d,name:"metadata",render:({field:{onChange:y,onBlur:b,value:S},fieldState:{invalid:h,error:x}})=>s(Q,{title:"Metadata",subTitle:"All data from the span to use during experimentation or evaluation",...ma,children:[h?e(ee,{variant:"danger",banner:!0,children:x==null?void 0:x.message}):null,e(Le,{value:S,onChange:y,onBlur:b})]})})]})})})})})}const vo=n=>g.useMemo(()=>{try{return{json:JSON.parse(n)}}catch(a){return{json:null,parseError:a}}},[n]),xo=n=>n.events.some(a=>a.name==="exception"),Z={backgroundColor:"light",borderColor:"light",variant:"compact",collapsible:!0};function Fo(n){const a=n.find(i=>i.parentId==null);if(a)return a;const l=new Set(n.map(i=>i.context.spanId)),t=n.filter(i=>i.parentId!=null&&!l.has(i.parentId));return t.length===1?t[0]:null}function ct(n){const{traceId:a,projectId:l}=n,[t,i]=Ya(),r=_.useLazyLoadQuery(lt,{traceId:a,id:l},{fetchPolicy:"store-and-network"}),o=g.useMemo(()=>{var p;return(((p=r.project.trace)==null?void 0:p.spans.edges)||[]).map(y=>y.span)},[r]),d=t.get("selectedSpanId")??o[0].context.spanId,u=o.find(m=>m.context.spanId===d),f=g.useMemo(()=>Fo(o),[o]);return g.useEffect(()=>()=>{i(m=>(m.delete("selectedSpanId"),m),{replace:!0})},[]),s("main",{css:F`
        flex: 1 1 auto;
        overflow: hidden;
        display: flex;
        flex-direction: column;
      `,children:[e(Ko,{rootSpan:f}),s(Ye,{direction:"horizontal",autoSaveId:"trace-panel-group",css:F`
          flex: 1 1 auto;
          overflow: hidden;
        `,children:[e(se,{defaultSize:30,minSize:10,maxSize:40,children:e(Do,{children:e(fr,{spans:o,selectedSpanId:d,onSpanClick:m=>{i(p=>(p.set("selectedSpanId",m),p),{replace:!0})}})})}),e(en,{css:Sn}),e(se,{children:e(To,{children:u?e(Co,{selectedSpan:u}):null})})]})]})}function Ko({rootSpan:n}){const{latencyMs:a,statusCode:l,spanEvaluations:t}=n??{latencyMs:null,statusCode:"UNSET",spanEvaluations:[]},i=hr(l),r=t.length;return e(D,{padding:"size-200",borderBottomWidth:"thin",borderBottomColor:"dark",children:s(k,{direction:"row",gap:"size-400",children:[s(k,{direction:"column",children:[e(K,{elementType:"h3",textSize:"medium",color:"text-700",children:"Trace Status"}),e(K,{textSize:"xlarge",children:s(k,{direction:"row",gap:"size-50",alignItems:"center",children:[e(Ta,{statusCode:l}),e(K,{textSize:"xlarge",color:i,children:l})]})})]}),s(k,{direction:"column",children:[e(K,{elementType:"h3",textSize:"medium",color:"text-700",children:"Latency"}),e(K,{textSize:"xlarge",children:typeof a=="number"?e(Re,{latencyMs:a,textSize:"xlarge"}):"--"})]}),r?s(k,{direction:"column",gap:"size-50",children:[e(K,{elementType:"h3",textSize:"medium",color:"text-700",children:"Evaluations"}),e(k,{direction:"row",gap:"size-50",children:t.map(o=>e(Ma,{evaluation:o},o.name))})]}):null]})})}function To({children:n}){return e("div",{"data-testid":"scrolling-tabs-wrapper",css:F`
        height: 100%;
        overflow: hidden;
        .ac-tabs {
          height: 100%;
          overflow: hidden;
          .ac-tabs__pane-container {
            height: 100%;
            overflow-y: auto;
          }
        }
      `,children:n})}function Do({children:n}){return e("div",{"data-testid":"scrolling-panel-content",css:F`
        height: 100%;
        overflow-y: auto;
      `,children:n})}const ut=e(k,{alignItems:"center",justifyContent:"center",children:e(D,{marginStart:"size-100",children:s(na,{children:[e(oe,{weight:"heavy",level:4,children:"Span Attributes"}),e(ea,{children:e(K,{children:"Attributes are key-value pairs that represent metadata associated with a span. For detailed descriptions of specific attributes, consult the semantic conventions section of the OpenInference tracing specification."})}),e("footer",{children:e(Rn,{href:"https://github.com/Arize-ai/openinference/blob/main/spec/semantic_conventions.md",children:"Semantic Conventions"})})]})})});function Co({selectedSpan:n}){const a=g.useMemo(()=>xo(n),[n]);return s(k,{direction:"column",flex:"1 1 auto",height:"100%",children:[e(D,{paddingTop:"size-100",paddingBottom:"size-100",paddingStart:"size-150",paddingEnd:"size-200",flex:"none",children:s(k,{direction:"row",gap:"size-200",justifyContent:"space-between",alignItems:"center",children:[e(kr,{...n}),s(k,{flex:"none",direction:"row",alignItems:"center",gap:"size-100",children:[e(po,{traceId:n.context.traceId,spanId:n.context.spanId}),e(Io,{span:n})]})]})}),s(fe,{children:[e(q,{name:"Info",children:e(Lo,{span:n})}),e(q,{name:"Evaluations",extra:e(Ve,{variant:"light",children:n.spanEvaluations.length}),children:l=>l?e(Bo,{span:n}):null}),e(q,{name:"Attributes",title:"Attributes",children:e(D,{padding:"size-200",children:e(Q,{title:"All Attributes",...Z,titleExtra:ut,extra:e(J,{text:n.attributes}),bodyStyle:{padding:0},children:e(Ae,{children:n.attributes})})})}),e(q,{name:"Events",extra:e(Ve,{variant:a?"danger":"light",children:n.events.length}),children:e(qo,{events:n.events})})]})]})}function Io({span:n}){const[a,l]=g.useState(null),t=Me(),i=ne(),r=g.useCallback(()=>{l(e(So,{spanId:n.id,onCompleted:o=>{l(null),t({title:"Span Added to Dataset",message:"Successfully added span to dataset",action:{text:"View Dataset",onClick:()=>{i(`/datasets/${o}/examples`)}}})}}))},[n.id,t,i]);return s(W,{children:[e(O,{variant:"default",icon:e(N,{svg:e(M.DatabaseOutline,{})}),onClick:r,children:"Add to Dataset"}),e(g.Suspense,{children:e(ae,{type:"slideOver",isDismissable:!0,onDismiss:()=>l(null),children:a})})]})}function Lo({span:n}){const{spanKind:a,attributes:l}=n,{json:t,parseError:i}=vo(l),r=g.useMemo(()=>n.statusMessage?e(ee,{variant:"danger",title:"Status Description",children:n.statusMessage}):null,[n]);if(i||!t)return e(D,{padding:"size-200",children:s(k,{direction:"column",gap:"size-200",children:[r,e(ee,{variant:"warning",title:"Un-parsable attributes",children:`Failed to parse span attributes. ${i instanceof Error?i.message:""}`}),e(Q,{...Z,title:"Attributes",children:e(D,{padding:"size-100",children:l})})]})});let o;switch(a){case"llm":{o=e(Eo,{span:n,spanAttributes:t});break}case"retriever":{o=e(Ro,{span:n,spanAttributes:t});break}case"reranker":{o=e(_o,{span:n,spanAttributes:t});break}case"embedding":{o=e(wo,{span:n,spanAttributes:t});break}case"tool":{o=e(Po,{span:n,spanAttributes:t});break}default:o=e(Qo,{span:n})}return e(D,{padding:"size-200",children:s(k,{direction:"column",gap:"size-200",children:[r,o,t!=null&&t.metadata?e(Q,{...Z,title:"Metadata",children:e(Ae,{children:JSON.stringify(t.metadata)})}):null]})})}function Eo(n){const{spanAttributes:a,span:l}=n,{input:t,output:i}=l,r=g.useMemo(()=>a[de.llm]||null,[a]),o=g.useMemo(()=>{if(r==null)return null;const C=r[sn.model_name];return typeof C=="string"?C:null},[r]),c=g.useMemo(()=>{var C;return r==null?[]:((C=r[sn.input_messages])==null?void 0:C.map(v=>v[de.message]).filter(Boolean))||[]},[r]),d=g.useMemo(()=>{var C;return r==null?[]:((C=r[sn.output_messages])==null?void 0:C.map(v=>v[de.message]).filter(Boolean))||[]},[r]),u=g.useMemo(()=>{if(r==null)return[];const C=r[sn.prompts];return br(C)?C:[]},[r]),f=g.useMemo(()=>{if(r==null)return null;const C=r[sn.prompt_template];return C??null},[r]),m=g.useMemo(()=>r==null?"{}":r[sn.invocation_parameters]||"{}",[r]),p=g.useMemo(()=>o==null?null:s(k,{direction:"row",gap:"size-100",alignItems:"center",children:[e(Sr,{spanKind:"llm"}),e(K,{textSize:"large",weight:"heavy",children:o})]}),[o]),y=t!=null&&t.value!=null,b=c.length>0,S=i!=null&&i.value!=null,h=d.length>0,x=u.length>0,L=Object.keys(JSON.parse(m)).length>0,I=f!=null;return s(k,{direction:"column",gap:"size-200",children:[e(Q,{collapsible:!0,backgroundColor:"light",borderColor:"light",bodyStyle:{padding:0},titleSeparator:!1,variant:"compact",title:p,children:s(fe,{children:[b?e(q,{name:"Input Messages",hidden:!b,children:e(Ba,{messages:c})}):null,y?e(q,{name:"Input",hidden:!y,children:e(D,{padding:"size-200",children:e(ye,{children:e(Q,{...Z,title:"LLM Input",extra:s(k,{direction:"row",gap:"size-100",children:[e(_e,{}),e(J,{text:t.value})]}),children:e(Qe,{...t})})})})}):null,I?e(q,{name:"Prompt Template",hidden:!I,children:e(D,{padding:"size-200",children:s(k,{direction:"column",gap:"size-100",children:[e(D,{borderRadius:"medium",borderColor:"light",backgroundColor:"light",borderWidth:"thin",padding:"size-200",children:s(Gn,{text:f.template,children:[e(K,{color:"text-700",fontStyle:"italic",children:"prompt template"}),e(mt,{children:f.template})]})}),e(D,{borderRadius:"medium",borderColor:"light",backgroundColor:"light",borderWidth:"thin",padding:"size-200",children:s(Gn,{text:JSON.stringify(f.variables),children:[e(K,{color:"text-700",fontStyle:"italic",children:"template variables"}),e(Ae,{children:JSON.stringify(f.variables)})]})})]})})}):null,e(q,{name:"Prompts",hidden:!x,children:e($o,{prompts:u})}),e(q,{name:"Invocation Params",hidden:!L,children:e(Gn,{text:m,padding:"size-100",children:e(Ae,{children:m})})})]})}),S||h?e(ml,{...Z,children:s(fe,{children:[h?e(q,{name:"Output Messages",hidden:!h,children:e(Ba,{messages:d})}):null,S?e(q,{name:"Output",hidden:!S,children:e(D,{padding:"size-200",children:e(ye,{children:e(Q,{...Z,title:"LLM Output",extra:s(k,{direction:"row",gap:"size-100",children:[e(_e,{}),e(J,{text:i.value})]}),children:e(Qe,{...i})})})})}):null]})}):null]})}function Ro(n){const{spanAttributes:a,span:l}=n,{input:t}=l,i=g.useMemo(()=>a[de.retrieval]||null,[a]),r=g.useMemo(()=>{var f;return i==null?[]:((f=i[Mi.documents])==null?void 0:f.map(m=>m[de.document]).filter(Boolean))||[]},[i]),o=g.useMemo(()=>l.documentEvaluations.reduce((m,p)=>{const y=p.documentPosition,b=m[y]||[];return{...m,[y]:[...b,p]}},{}),[l.documentEvaluations]),c=t!=null&&t.value!=null,d=r.length>0,u=l.documentRetrievalMetrics.length>0;return s(k,{direction:"column",gap:"size-200",children:[c?e(ye,{children:e(Q,{title:"Input",...Z,extra:s(k,{direction:"row",gap:"size-100",children:[e(_e,{}),e(J,{text:t.value})]}),children:e(Qe,{...t})})}):null,d?e(ye,{children:e(Q,{title:"Documents",...Z,titleExtra:u&&e(k,{direction:"row",alignItems:"center",gap:"size-100",children:l.documentRetrievalMetrics.map(f=>s(W,{children:[e(ce,{name:f.evaluationName,metric:"ndcg",score:f.ndcg},"ndcg"),e(ce,{name:f.evaluationName,metric:"precision",score:f.precision},"precision"),e(ce,{name:f.evaluationName,metric:"hit",score:f.hit},"hit")]}))}),extra:e(_e,{}),children:e("ul",{css:F`
                display: flex;
                flex-direction: column;
                gap: var(--ac-global-dimension-static-size-200);
              `,children:r.map((f,m)=>e("li",{children:e(ba,{document:f,documentEvaluations:o[m],borderColor:"seafoam-700",backgroundColor:"seafoam-100",labelColor:"seafoam-1000"})},m))})})}):null]})}function _o(n){const{spanAttributes:a}=n,l=g.useMemo(()=>a[de.reranker]||null,[a]),t=g.useMemo(()=>l==null?"":l[ra.query]||"",[l]),i=g.useMemo(()=>{var d;return l==null?[]:((d=l[ra.input_documents])==null?void 0:d.map(u=>u[de.document]).filter(Boolean))||[]},[l]),r=g.useMemo(()=>{var d;return l==null?[]:((d=l[ra.output_documents])==null?void 0:d.map(u=>u[de.document]).filter(Boolean))||[]},[l]),o=i.length,c=r.length;return s(k,{direction:"column",gap:"size-200",children:[e(ye,{children:e(Q,{title:"Query",...Z,children:e(An,{children:t})})}),e(Q,{title:"Input Documents",titleExtra:e(Ve,{variant:"light",children:o}),...Z,defaultOpen:!1,children:e("ul",{css:F`
              padding: var(--ac-global-dimension-static-size-200);
              display: flex;
              flex-direction: column;
              gap: var(--ac-global-dimension-static-size-200);
            `,children:i.map((d,u)=>e("li",{children:e(ba,{document:d,borderColor:"seafoam-700",backgroundColor:"seafoam-100",labelColor:"seafoam-1000"})},u))})}),e(Q,{title:"Output Documents",titleExtra:e(Ve,{variant:"light",children:c}),...Z,children:e("ul",{css:F`
              padding: var(--ac-global-dimension-static-size-200);
              display: flex;
              flex-direction: column;
              gap: var(--ac-global-dimension-static-size-200);
            `,children:r.map((d,u)=>e("li",{children:e(ba,{document:d,borderColor:"celery-700",backgroundColor:"celery-100",labelColor:"celery-1000"})},u))})})]})}function wo(n){const{spanAttributes:a}=n,l=g.useMemo(()=>a[de.embedding]||null,[a]),t=g.useMemo(()=>{var o;return l==null?[]:((o=l[sa.embeddings])==null?void 0:o.map(c=>c[de.embedding]).filter(Boolean))||[]},[l]),i=t.length>0,r=l==null?void 0:l[sa.model_name];return e(k,{direction:"column",gap:"size-200",children:i?e(Q,{title:"Embeddings"+(typeof r=="string"?`: ${r}`:""),...Z,children:e("ul",{css:F`
                display: flex;
                flex-direction: column;
                gap: var(--ac-global-dimension-static-size-200);
              `,children:t.map((o,c)=>e("li",{children:e(ye,{children:e(Q,{...Z,backgroundColor:"purple-100",borderColor:"purple-700",title:"Embedded Text",children:e(An,{children:o[sa.text]||""})})})},c))})}):null})}function Po(n){const{span:a,spanAttributes:l}=n,{input:t,output:i}=a,r=typeof(t==null?void 0:t.value)=="string",o=typeof(i==null?void 0:i.value)=="string",c=(t==null?void 0:t.mimeType)==="text",d=(i==null?void 0:i.mimeType)==="text",u=g.useMemo(()=>l[de.tool]||{},[l]),f=Object.keys(u).length>0,m=u[oa.name],p=u[oa.description],y=u[oa.parameters];return!r&&!o&&!f?null:s(k,{direction:"column",gap:"size-200",children:[r?e(ye,{children:e(Q,{title:"Input",...Z,extra:s(k,{direction:"row",gap:"size-100",children:[c?e(_e,{}):null,e(J,{text:t.value})]}),children:e(Qe,{...t})})}):null,o?e(ye,{children:e(Q,{title:"Output",...Z,backgroundColor:"green-100",borderColor:"green-700",extra:s(k,{direction:"row",gap:"size-100",children:[d?e(_e,{}):null,e(J,{text:i.value})]}),children:e(Qe,{...i})})}):null,f?e(Q,{title:"Tool"+(typeof m=="string"?`: ${m}`:""),...Z,children:s(k,{direction:"column",children:[p!=null?e(D,{paddingStart:"size-200",paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderBottomColor:"dark",borderBottomWidth:"thin",backgroundColor:"light",children:s(k,{direction:"column",alignItems:"start",gap:"size-50",children:[e(K,{color:"text-700",fontStyle:"italic",children:"Description"}),e(K,{children:p})]})}):null,y!=null?e(D,{paddingStart:"size-200",paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderBottomColor:"dark",borderBottomWidth:"thin",children:s(k,{direction:"column",alignItems:"start",width:"100%",children:[e(K,{color:"text-700",fontStyle:"italic",children:"Parameters"}),e(Ae,{children:JSON.stringify(y)})]})}):null]})}):null]})}const Mo=["irrelevant","unrelated"];function ba({document:n,documentEvaluations:a,backgroundColor:l,borderColor:t,labelColor:i}){const r=n[Dn.metadata],o=a&&a.length,c=n[Dn.content];return e(Q,{...Z,backgroundColor:l,borderColor:t,bodyStyle:{padding:0},title:s(k,{direction:"row",gap:"size-50",alignItems:"center",children:[e(N,{svg:e(M.FileOutline,{})}),s(oe,{level:4,children:["document ",n[Dn.id]]})]}),extra:typeof n[Dn.score]=="number"&&e(yn,{color:i,children:`score ${xa(n[Dn.score])}`}),children:s(k,{direction:"column",children:[c&&e(D,{padding:"size-200",children:e(An,{children:c})}),r&&e(W,{children:e(D,{borderColor:t,borderTopWidth:"thin",children:e(Ae,{children:JSON.stringify(r)})})}),o&&e(D,{borderColor:t,borderTopWidth:"thin",padding:"size-200",children:s(k,{direction:"column",gap:"size-100",children:[e(oe,{level:3,weight:"heavy",children:"Evaluations"}),e("ul",{children:a.map((d,u)=>{const f=d.label&&Mo.includes(d.label)?"danger":i;return e("li",{children:e(D,{padding:"size-200",borderWidth:"thin",borderColor:t,borderRadius:"medium",children:s(k,{direction:"column",gap:"size-50",children:[s(k,{direction:"row",gap:"size-100",children:[e(K,{weight:"heavy",elementType:"h5",children:d.name}),d.label&&e(yn,{color:f,shape:"badge",children:d.label}),typeof d.score=="number"&&e(yn,{color:f,shape:"badge",children:s(k,{direction:"row",gap:"size-50",children:[e(K,{textSize:"xsmall",weight:"heavy",color:"inherit",children:"score"}),e(K,{textSize:"xsmall",children:Ce(d.score)})]})})]}),typeof d.explanation&&e("p",{css:F`
                                margin-top: var(
                                  --ac-global-dimension-static-size-100
                                );
                                margin-bottom: 0;
                              `,children:d.explanation})]})})},u)})})]})})]})})}function No({message:n}){var c;const a=n[be.content],l=n[be.contents],t=((c=n[be.tool_calls])==null?void 0:c.map(d=>d[de.tool_call]).filter(Boolean))||[],i=n[be.function_call_arguments_json]&&n[be.function_call_name],r=n[be.role]||"unknown",o=g.useMemo(()=>r==="user"?{backgroundColor:"grey-100",borderColor:"grey-500"}:r==="assistant"?{backgroundColor:"blue-100",borderColor:"blue-700"}:r==="system"?{backgroundColor:"indigo-100",borderColor:"indigo-700"}:["function","tool"].includes(r)?{backgroundColor:"yellow-100",borderColor:"yellow-700"}:{backgroundColor:"grey-100",borderColor:"grey-700"},[r]);return e(ye,{children:s(Q,{...Z,...o,title:r+(n[be.name]?`: ${n[be.name]}`:""),extra:s(k,{direction:"row",gap:"size-100",children:[e(_e,{}),e(J,{text:a||JSON.stringify(n)})]}),children:[e(vr,{children:l?e(Vo,{messageContents:l}):null}),s(k,{direction:"column",alignItems:"start",children:[a?e(An,{children:a}):null,t.length>0?t.map((d,u)=>{var f,m;return s("pre",{css:F`
                      text-wrap: wrap;
                      margin: var(--ac-global-dimension-static-size-100) 0;
                    `,children:[(f=d==null?void 0:d.function)==null?void 0:f.name,"(",JSON.stringify(JSON.parse((m=d==null?void 0:d.function)==null?void 0:m.arguments),null,2),")"]},u)}):null,i?s("pre",{css:F`
                text-wrap: wrap;
                margin: var(--ac-global-dimension-static-size-100) 0;
              `,children:[n[be.function_call_name],"(",JSON.stringify(JSON.parse(n[be.function_call_arguments_json]),null,2),")"]}):null]})]})})}function Ba({messages:n}){return e("ul",{css:F`
        display: flex;
        flex-direction: column;
        gap: var(--ac-global-dimension-static-size-100);
        padding: var(--ac-global-dimension-static-size-200);
      `,children:n.map((a,l)=>e("li",{children:e(No,{message:a})},l))})}function $o({prompts:n}){return e("ul",{"data-testid":"llm-prompts-list",css:F`
        padding: var(--ac-global-dimension-size-200);
        display: flex;
        flex-direction: column;
        gap: var(--ac-global-dimension-size-100);
      `,children:n.map((a,l)=>e("li",{children:e(D,{backgroundColor:"gray-600",borderColor:"gray-400",borderWidth:"thin",borderRadius:"medium",padding:"size-100",children:e(Gn,{text:a,children:e(Qe,{value:a,mimeType:"text"})})})},l))})}function Vo({messageContents:n}){return e("ul",{css:F`
        display: flex;
        flex-direction: column;
        gap: var(--ac-global-dimension-size-100);
      `,children:n.map((a,l)=>e("li",{children:e(Ao,{messageContentAttribute:a})},l))})}const zo=F`
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
`;function Ao({messageContentAttribute:n}){var r;const{message_content:a}=n,l=a==null?void 0:a.text,t=a==null?void 0:a.image,i=(r=t==null?void 0:t.image)==null?void 0:r.url;return s(k,{direction:"column",children:[l?e("pre",{css:F`
            white-space: pre-wrap;
            padding: 0;
            margin: 0;
          `,children:l}):null,i?e("img",{src:i,css:zo}):null]})}function Qo({span:n}){const{input:a,output:l}=n,t=a==null&&l==null,i=(a==null?void 0:a.mimeType)==="text",r=(l==null?void 0:l.mimeType)==="text";return s(k,{direction:"column",gap:"size-200",children:[a&&a.value!=null?e(ye,{children:e(Q,{title:"Input",...Z,extra:s(k,{direction:"row",gap:"size-100",children:[i?e(_e,{}):null,e(J,{text:a.value})]}),children:e(Qe,{...a})})}):null,l&&l.value!=null?e(ye,{children:e(Q,{title:"Output",...Z,backgroundColor:"green-100",borderColor:"green-700",extra:s(k,{direction:"row",gap:"size-100",children:[r?e(_e,{}):null,e(J,{text:l.value})]}),children:e(Qe,{...l})})}):null,t?e(Q,{title:"All Attributes",titleExtra:ut,...Z,bodyStyle:{padding:0},extra:e(J,{text:n.attributes}),children:e(Ae,{children:n.attributes})}):null]})}const Oo=F`
  .cm-content {
    padding: var(--ac-global-dimension-static-size-200) 0;
  }
  .cm-editor,
  .cm-gutters {
    background-color: transparent;
  }
`;function Gn({text:n,children:a,padding:l}){const t=l?`var(--ac-global-dimension-${l})`:"0";return s("div",{css:F`
        position: relative;
        .copy-to-clipboard-button {
          transition: opacity 0.2s ease-in-out;
          opacity: 0;
          position: absolute;
          right: ${t};
          top: ${t};
          z-index: 1;
        }
        &:hover .copy-to-clipboard-button {
          opacity: 1;
        }
      `,children:[e(J,{text:n}),a]})}function Ae({children:n}){const{theme:a}=Vn(),l=a==="light"?void 0:ia,{value:t,mimeType:i}=g.useMemo(()=>{try{return{value:JSON.stringify(JSON.parse(n),null,2),mimeType:"json"}}catch{return{value:n,mimeType:"text"}}},[n]);return i==="json"?e(ta,{value:t,basicSetup:{lineNumbers:!0,foldGutter:!0,bracketMatching:!0,syntaxHighlighting:!0,highlightActiveLine:!1,highlightActiveLineGutter:!1},extensions:[Ur(),Jr.lineWrapping],editable:!1,theme:l,css:Oo}):e(mt,{children:t})}function mt({children:n}){return e("pre",{css:F`
        white-space: pre-wrap;
        padding: 0;
      `,children:n})}function Qe({value:n,mimeType:a}){let l;switch(a){case"json":l=e(Ae,{children:n});break;case"text":l=e(An,{children:n});break;default:me()}return l}function jo({text:n}){return s(k,{direction:"column",alignItems:"center",flex:"1 1 auto",height:"size-2400",justifyContent:"center",gap:"size-100",children:[e(Ea,{graphicKey:"documents"}),e(K,{children:n})]})}function qo({events:n}){return n.length===0?e(jo,{text:"No events"}):e(hl,{children:n.map((a,l)=>{const t=a.name==="exception";return e(fl,{children:s(k,{direction:"row",alignItems:"center",gap:"size-100",children:[e(D,{flex:"none",children:e("div",{"data-event-type":t?"exception":"info",css:i=>F`
                    &[data-event-type="exception"] {
                      --px-event-icon-color: ${i.colors.statusDanger};
                    }
                    &[data-event-type="info"] {
                      --px-event-icon-color: ${i.colors.statusInfo};
                    }
                    .ac-icon-wrap {
                      color: var(--px-event-icon-color);
                    }
                  `,children:e(N,{svg:t?e(M.AlertTriangleOutline,{}):e(M.InfoOutline,{})})})}),s(k,{direction:"column",gap:"size-25",flex:"1 1 auto",children:[e(K,{weight:"heavy",children:a.name}),e(K,{color:"text-700",children:a.message})]}),e(D,{children:e(K,{color:"text-700",children:new Date(a.timestamp).toLocaleString()})})]})},l)})})}function Bo(n){return e(fo,{span:n.span})}function Vc(){const{traceId:n,projectId:a}=je(),l=ne();return e(ae,{type:"slideOver",isDismissable:!0,onDismiss:()=>l(`/projects/${a}`),children:e(X,{size:"fullscreen",title:"Trace Details",children:e(ct,{traceId:n,projectId:a})})})}const gt=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"id"},{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},i={kind:"Literal",name:"first",value:100},r={kind:"Literal",name:"sort",value:{col:"startTime",dir:"desc"}},o={kind:"Variable",name:"timeRange",variableName:"timeRange"},c=[i,r,o],d={alias:null,args:null,kind:"ScalarField",name:"spanKind",storageKey:null},u={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},f={alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null},m={alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},p={alias:null,args:null,kind:"ScalarField",name:"latencyMs",storageKey:null},y={alias:null,args:null,concreteType:"SpanContext",kind:"LinkedField",name:"context",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"spanId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null}],storageKey:null},b=[{alias:"value",args:null,kind:"ScalarField",name:"truncatedValue",storageKey:null}],S={alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"input",plural:!1,selections:b,storageKey:null},h={alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"output",plural:!1,selections:b,storageKey:null},x={alias:null,args:null,concreteType:"SpanEvaluation",kind:"LinkedField",name:"spanEvaluations",plural:!0,selections:[u,{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null}],storageKey:null},L={alias:null,args:null,concreteType:"DocumentRetrievalMetrics",kind:"LinkedField",name:"documentRetrievalMetrics",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"evaluationName",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"ndcg",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"precision",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hit",storageKey:null}],storageKey:null},I={alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},C={alias:null,args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[l],storageKey:null},v={alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null},T=[i,{kind:"Literal",name:"rootSpansOnly",value:!0},r,o],P={alias:"statusCode",args:null,kind:"ScalarField",name:"propagatedStatusCode",storageKey:null},R={alias:null,args:null,kind:"ScalarField",name:"parentId",storageKey:null},z=[{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}],j=[o];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ProjectPageQuery",selections:[{alias:"project",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:null,kind:"FragmentSpread",name:"SpansTable_spans"},{args:null,kind:"FragmentSpread",name:"TracesTable_spans"},{args:null,kind:"FragmentSpread",name:"ProjectPageHeader_stats"},{args:null,kind:"FragmentSpread",name:"StreamToggle_data"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ProjectPageQuery",selections:[{alias:"project",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,{kind:"TypeDiscriminator",abstractKey:"__isNode"},t,{kind:"InlineFragment",selections:[{alias:null,args:null,kind:"ScalarField",name:"spanEvaluationNames",storageKey:null},{alias:null,args:c,concreteType:"SpanConnection",kind:"LinkedField",name:"spans",plural:!1,selections:[{alias:null,args:null,concreteType:"SpanEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"span",args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[t,d,u,f,{alias:null,args:null,kind:"ScalarField",name:"statusCode",storageKey:null},m,p,{alias:null,args:null,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"tokenCountPrompt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"tokenCountCompletion",storageKey:null},y,S,h,x,L],storageKey:null},I,C],storageKey:null},v],storageKey:null},{alias:null,args:c,filters:["sort","filterCondition","timeRange"],handle:"connection",key:"SpansTable_spans",kind:"LinkedHandle",name:"spans"},{alias:"rootSpans",args:T,concreteType:"SpanConnection",kind:"LinkedField",name:"spans",plural:!1,selections:[{alias:null,args:null,concreteType:"SpanEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"rootSpan",args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[t,d,u,f,P,m,p,{alias:null,args:null,kind:"ScalarField",name:"cumulativeTokenCountTotal",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cumulativeTokenCountPrompt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cumulativeTokenCountCompletion",storageKey:null},R,S,h,y,x,L,{alias:null,args:null,concreteType:"Span",kind:"LinkedField",name:"descendants",plural:!0,selections:[t,d,u,P,m,p,R,{alias:"cumulativeTokenCountTotal",args:null,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},{alias:"cumulativeTokenCountPrompt",args:null,kind:"ScalarField",name:"tokenCountPrompt",storageKey:null},{alias:"cumulativeTokenCountCompletion",args:null,kind:"ScalarField",name:"tokenCountCompletion",storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"input",plural:!1,selections:z,storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"output",plural:!1,selections:z,storageKey:null},y,x,L],storageKey:null}],storageKey:null},I,C],storageKey:null},v],storageKey:null},{alias:"rootSpans",args:T,filters:["sort","rootSpansOnly","filterCondition","timeRange"],handle:"connection",key:"TracesTable_rootSpans",kind:"LinkedHandle",name:"spans"},{alias:null,args:j,kind:"ScalarField",name:"traceCount",storageKey:null},{alias:null,args:j,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},{alias:"latencyMsP50",args:[{kind:"Literal",name:"probability",value:.5},o],kind:"ScalarField",name:"latencyMsQuantile",storageKey:null},{alias:"latencyMsP99",args:[{kind:"Literal",name:"probability",value:.99},o],kind:"ScalarField",name:"latencyMsQuantile",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"documentEvaluationNames",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"streamingLastUpdatedAt",storageKey:null}],type:"Project",abstractKey:null}],storageKey:null}]},params:{cacheID:"f91a1a2f14ed08ee58a7f39925bac3c8",id:null,metadata:{},name:"ProjectPageQuery",operationKind:"query",text:`query ProjectPageQuery(
  $id: GlobalID!
  $timeRange: TimeRange!
) {
  project: node(id: $id) {
    __typename
    ...SpansTable_spans
    ...TracesTable_spans
    ...ProjectPageHeader_stats
    ...StreamToggle_data
    __isNode: __typename
    id
  }
}

fragment ProjectPageHeader_stats on Project {
  traceCount(timeRange: $timeRange)
  tokenCountTotal(timeRange: $timeRange)
  latencyMsP50: latencyMsQuantile(probability: 0.5, timeRange: $timeRange)
  latencyMsP99: latencyMsQuantile(probability: 0.99, timeRange: $timeRange)
  spanEvaluationNames
  documentEvaluationNames
  id
}

fragment SpanColumnSelector_evaluations on Project {
  spanEvaluationNames
}

fragment SpansTable_spans on Project {
  ...SpanColumnSelector_evaluations
  spans(first: 100, sort: {col: startTime, dir: desc}, timeRange: $timeRange) {
    edges {
      span: node {
        id
        spanKind
        name
        metadata
        statusCode
        startTime
        latencyMs
        tokenCountTotal
        tokenCountPrompt
        tokenCountCompletion
        context {
          spanId
          traceId
        }
        input {
          value: truncatedValue
        }
        output {
          value: truncatedValue
        }
        spanEvaluations {
          name
          label
          score
        }
        documentRetrievalMetrics {
          evaluationName
          ndcg
          precision
          hit
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}

fragment StreamToggle_data on Project {
  streamingLastUpdatedAt
  id
}

fragment TracesTable_spans on Project {
  ...SpanColumnSelector_evaluations
  rootSpans: spans(first: 100, sort: {col: startTime, dir: desc}, rootSpansOnly: true, timeRange: $timeRange) {
    edges {
      rootSpan: node {
        id
        spanKind
        name
        metadata
        statusCode: propagatedStatusCode
        startTime
        latencyMs
        cumulativeTokenCountTotal
        cumulativeTokenCountPrompt
        cumulativeTokenCountCompletion
        parentId
        input {
          value: truncatedValue
        }
        output {
          value: truncatedValue
        }
        context {
          spanId
          traceId
        }
        spanEvaluations {
          name
          label
          score
        }
        documentRetrievalMetrics {
          evaluationName
          ndcg
          precision
          hit
        }
        descendants {
          id
          spanKind
          name
          statusCode: propagatedStatusCode
          startTime
          latencyMs
          parentId
          cumulativeTokenCountTotal: tokenCountTotal
          cumulativeTokenCountPrompt: tokenCountPrompt
          cumulativeTokenCountCompletion: tokenCountCompletion
          input {
            value
          }
          output {
            value
          }
          context {
            spanId
            traceId
          }
          spanEvaluations {
            name
            label
            score
          }
          documentRetrievalMetrics {
            evaluationName
            ndcg
            precision
            hit
          }
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();gt.hash="c1b22588515ba56f88b7ea8ed8bb12fa";const pt=function(){var n={defaultValue:null,kind:"LocalArgument",name:"id"},a={defaultValue:null,kind:"LocalArgument",name:"timeRange"},l=[{kind:"Variable",name:"id",variableName:"id"}],t={kind:"Variable",name:"timeRange",variableName:"timeRange"},i=[t];return{fragment:{argumentDefinitions:[n,a],kind:"Fragment",metadata:null,name:"ProjectPageHeaderQuery",selections:[{alias:null,args:l,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:null,kind:"FragmentSpread",name:"ProjectPageHeader_stats"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[a,n],kind:"Operation",name:"ProjectPageHeaderQuery",selections:[{alias:null,args:l,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{kind:"InlineFragment",selections:[{alias:null,args:i,kind:"ScalarField",name:"traceCount",storageKey:null},{alias:null,args:i,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},{alias:"latencyMsP50",args:[{kind:"Literal",name:"probability",value:.5},t],kind:"ScalarField",name:"latencyMsQuantile",storageKey:null},{alias:"latencyMsP99",args:[{kind:"Literal",name:"probability",value:.99},t],kind:"ScalarField",name:"latencyMsQuantile",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"spanEvaluationNames",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"documentEvaluationNames",storageKey:null}],type:"Project",abstractKey:null}],storageKey:null}]},params:{cacheID:"b55d98cce8db8be868e94c1b1dd649af",id:null,metadata:{},name:"ProjectPageHeaderQuery",operationKind:"query",text:`query ProjectPageHeaderQuery(
  $timeRange: TimeRange
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...ProjectPageHeader_stats
    __isNode: __typename
    id
  }
}

fragment ProjectPageHeader_stats on Project {
  traceCount(timeRange: $timeRange)
  tokenCountTotal(timeRange: $timeRange)
  latencyMsP50: latencyMsQuantile(probability: 0.5, timeRange: $timeRange)
  latencyMsP99: latencyMsQuantile(probability: 0.99, timeRange: $timeRange)
  spanEvaluationNames
  documentEvaluationNames
  id
}
`}}}();pt.hash="22a98df993a4375f85851e92f6844c09";const yt=function(){var n={kind:"Variable",name:"timeRange",variableName:"timeRange"},a=[n];return{argumentDefinitions:[{kind:"RootArgument",name:"timeRange"}],kind:"Fragment",metadata:{refetch:{connection:null,fragmentPathInResult:["node"],operation:pt,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"ProjectPageHeader_stats",selections:[{alias:null,args:a,kind:"ScalarField",name:"traceCount",storageKey:null},{alias:null,args:a,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},{alias:"latencyMsP50",args:[{kind:"Literal",name:"probability",value:.5},n],kind:"ScalarField",name:"latencyMsQuantile",storageKey:null},{alias:"latencyMsP99",args:[{kind:"Literal",name:"probability",value:.99},n],kind:"ScalarField",name:"latencyMsQuantile",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"spanEvaluationNames",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"documentEvaluationNames",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null}],type:"Project",abstractKey:null}}();yt.hash="22a98df993a4375f85851e92f6844c09";const ft=g.createContext(null);function Tn(){const n=Fe.useContext(ft);if(n===null)throw new Error("useStreamState must be used within a StreamStateProvider");return n}function Ho({initialFetchKey:n="initial",children:a}){const[l,t]=g.useState(!0),[i,r]=g.useState(n),o=g.useCallback(c=>{g.startTransition(()=>{r(c)})},[r]);return e(ft.Provider,{value:{isStreaming:l,setIsStreaming:t,fetchKey:i,setFetchKey:o},children:a})}const ht=function(){var n={defaultValue:null,kind:"LocalArgument",name:"evaluationName"},a={defaultValue:null,kind:"LocalArgument",name:"id"},l={defaultValue:null,kind:"LocalArgument",name:"timeRange"},t=[{kind:"Variable",name:"id",variableName:"id"}],i=[{kind:"Variable",name:"evaluationName",variableName:"evaluationName"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}];return{fragment:{argumentDefinitions:[n,a,l],kind:"Fragment",metadata:null,name:"DocumentEvaluationSummaryValueQuery",selections:[{alias:null,args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:i,kind:"FragmentSpread",name:"DocumentEvaluationSummaryValueFragment"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[n,l,a],kind:"Operation",name:"DocumentEvaluationSummaryValueQuery",selections:[{alias:null,args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{kind:"InlineFragment",selections:[{alias:null,args:i,concreteType:"DocumentEvaluationSummary",kind:"LinkedField",name:"documentEvaluationSummary",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"averageNdcg",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"averagePrecision",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"meanReciprocalRank",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hitRate",storageKey:null}],storageKey:null}],type:"Project",abstractKey:null}],storageKey:null}]},params:{cacheID:"60d7798d88e1408e6b6b0bebdc1716f5",id:null,metadata:{},name:"DocumentEvaluationSummaryValueQuery",operationKind:"query",text:`query DocumentEvaluationSummaryValueQuery(
  $evaluationName: String!
  $timeRange: TimeRange!
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...DocumentEvaluationSummaryValueFragment_1dJL9N
    __isNode: __typename
    id
  }
}

fragment DocumentEvaluationSummaryValueFragment_1dJL9N on Project {
  documentEvaluationSummary(evaluationName: $evaluationName, timeRange: $timeRange) {
    averageNdcg
    averagePrecision
    meanReciprocalRank
    hitRate
  }
  id
}
`}}}();ht.hash="15d0652aa260c80f62acec943f615d93";const kt={argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"evaluationName"},{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],kind:"Fragment",metadata:{refetch:{connection:null,fragmentPathInResult:["node"],operation:ht,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"DocumentEvaluationSummaryValueFragment",selections:[{alias:null,args:[{kind:"Variable",name:"evaluationName",variableName:"evaluationName"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],concreteType:"DocumentEvaluationSummary",kind:"LinkedField",name:"documentEvaluationSummary",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"averageNdcg",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"averagePrecision",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"meanReciprocalRank",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hitRate",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null}],type:"Project",abstractKey:null};kt.hash="15d0652aa260c80f62acec943f615d93";const bt=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"evaluationName"},{defaultValue:null,kind:"LocalArgument",name:"id"},{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l=[{kind:"Variable",name:"evaluationName",variableName:"evaluationName"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"DocumentEvaluationSummaryQuery",selections:[{alias:"project",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:l,kind:"FragmentSpread",name:"DocumentEvaluationSummaryValueFragment"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"DocumentEvaluationSummaryQuery",selections:[{alias:"project",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{kind:"InlineFragment",selections:[{alias:null,args:l,concreteType:"DocumentEvaluationSummary",kind:"LinkedField",name:"documentEvaluationSummary",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"averageNdcg",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"averagePrecision",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"meanReciprocalRank",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hitRate",storageKey:null}],storageKey:null}],type:"Project",abstractKey:null}],storageKey:null}]},params:{cacheID:"3ebd1cf66ef8f31c995ec6aae6505e94",id:null,metadata:{},name:"DocumentEvaluationSummaryQuery",operationKind:"query",text:`query DocumentEvaluationSummaryQuery(
  $evaluationName: String!
  $id: GlobalID!
  $timeRange: TimeRange!
) {
  project: node(id: $id) {
    __typename
    ...DocumentEvaluationSummaryValueFragment_1dJL9N
    __isNode: __typename
    id
  }
}

fragment DocumentEvaluationSummaryValueFragment_1dJL9N on Project {
  documentEvaluationSummary(evaluationName: $evaluationName, timeRange: $timeRange) {
    averageNdcg
    averagePrecision
    meanReciprocalRank
    hitRate
  }
  id
}
`}}}();bt.hash="4d50474ffa9b9e4a68d07f6e0777c144";function Go({evaluationName:n}){const{projectId:a}=je(),{timeRange:l}=Xn(),t=_.useLazyLoadQuery(bt,{id:a,evaluationName:n,timeRange:{start:l.start.toISOString(),end:l.end.toISOString()}});return s(k,{direction:"column",flex:"none",children:[e(K,{elementType:"h3",textSize:"medium",color:"text-700",children:n}),e(g.Suspense,{fallback:e(K,{textSize:"xlarge",children:"--"}),children:e(Wo,{evaluationName:n,project:t==null?void 0:t.project})})]})}function Wo(n){var u,f,m,p;const{project:a}=n,{fetchKey:l}=Tn(),[t,i]=_.useRefetchableFragment(kt,a);g.useEffect(()=>{g.startTransition(()=>{i({},{fetchPolicy:"store-and-network"})})},[l,i]);const r=(u=t==null?void 0:t.documentEvaluationSummary)==null?void 0:u.averageNdcg,o=(f=t==null?void 0:t.documentEvaluationSummary)==null?void 0:f.averagePrecision,c=(m=t==null?void 0:t.documentEvaluationSummary)==null?void 0:m.hitRate,d=(p=t==null?void 0:t.documentEvaluationSummary)==null?void 0:p.meanReciprocalRank;return s(ge,{delay:0,placement:"bottom",children:[e(ze,{children:e(k,{direction:"row",alignItems:"center",gap:"size-50",height:"28px",children:s(W,{children:[e(ce,{metric:"ndcg",score:r},"ndcg"),e(ce,{metric:"precision",score:o},"precision"),e(ce,{metric:"hit rate",score:c},"hit")]})})}),e(aa,{children:e(D,{width:"size-2400",children:s(k,{direction:"column",children:[s(k,{justifyContent:"space-between",children:[e(K,{children:"average ndcg"}),e(K,{children:typeof r=="number"?Ce(r):"--"})]}),s(k,{justifyContent:"space-between",children:[e(K,{children:"average precision"}),e(K,{children:typeof o=="number"?Ce(o):"--"})]}),s(k,{justifyContent:"space-between",children:[e(K,{children:"mean reciprocal rank"}),e(K,{children:typeof d=="number"?Ce(d):"--"})]}),s(k,{justifyContent:"space-between",children:[e(K,{children:"hit rate"}),e(K,{children:typeof c=="number"?Ce(c):"--"})]})]})})})]})}const St=function(){var n={defaultValue:null,kind:"LocalArgument",name:"evaluationName"},a={defaultValue:null,kind:"LocalArgument",name:"id"},l={defaultValue:null,kind:"LocalArgument",name:"timeRange"},t=[{kind:"Variable",name:"id",variableName:"id"}],i=[{kind:"Variable",name:"evaluationName",variableName:"evaluationName"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}];return{fragment:{argumentDefinitions:[n,a,l],kind:"Fragment",metadata:null,name:"EvaluationSummaryValueQuery",selections:[{alias:null,args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:i,kind:"FragmentSpread",name:"EvaluationSummaryValueFragment"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[n,l,a],kind:"Operation",name:"EvaluationSummaryValueQuery",selections:[{alias:null,args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{kind:"InlineFragment",selections:[{alias:null,args:i,concreteType:"EvaluationSummary",kind:"LinkedField",name:"spanEvaluationSummary",plural:!1,selections:[{alias:null,args:null,concreteType:"LabelFraction",kind:"LinkedField",name:"labelFractions",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"fraction",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"meanScore",storageKey:null}],storageKey:null}],type:"Project",abstractKey:null}],storageKey:null}]},params:{cacheID:"99465624550be40aec8146116c3a223b",id:null,metadata:{},name:"EvaluationSummaryValueQuery",operationKind:"query",text:`query EvaluationSummaryValueQuery(
  $evaluationName: String!
  $timeRange: TimeRange!
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...EvaluationSummaryValueFragment_1dJL9N
    __isNode: __typename
    id
  }
}

fragment EvaluationSummaryValueFragment_1dJL9N on Project {
  spanEvaluationSummary(evaluationName: $evaluationName, timeRange: $timeRange) {
    labelFractions {
      label
      fraction
    }
    meanScore
  }
  id
}
`}}}();St.hash="ba0ee13567d5484ec0697c50e1a77bfa";const vt={argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"evaluationName"},{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],kind:"Fragment",metadata:{refetch:{connection:null,fragmentPathInResult:["node"],operation:St,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"EvaluationSummaryValueFragment",selections:[{alias:null,args:[{kind:"Variable",name:"evaluationName",variableName:"evaluationName"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],concreteType:"EvaluationSummary",kind:"LinkedField",name:"spanEvaluationSummary",plural:!1,selections:[{alias:null,args:null,concreteType:"LabelFraction",kind:"LinkedField",name:"labelFractions",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"fraction",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"meanScore",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null}],type:"Project",abstractKey:null};vt.hash="ba0ee13567d5484ec0697c50e1a77bfa";const xt=function(){var n={defaultValue:null,kind:"LocalArgument",name:"evaluationName"},a={defaultValue:null,kind:"LocalArgument",name:"id"},l={defaultValue:null,kind:"LocalArgument",name:"timeRange"},t=[{kind:"Variable",name:"id",variableName:"id"}],i=[{kind:"Variable",name:"evaluationName",variableName:"evaluationName"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}];return{fragment:{argumentDefinitions:[n,a,l],kind:"Fragment",metadata:null,name:"EvaluationSummaryQuery",selections:[{alias:"project",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:i,kind:"FragmentSpread",name:"EvaluationSummaryValueFragment"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[a,n,l],kind:"Operation",name:"EvaluationSummaryQuery",selections:[{alias:"project",args:t,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{kind:"InlineFragment",selections:[{alias:null,args:i,concreteType:"EvaluationSummary",kind:"LinkedField",name:"spanEvaluationSummary",plural:!1,selections:[{alias:null,args:null,concreteType:"LabelFraction",kind:"LinkedField",name:"labelFractions",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"fraction",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"meanScore",storageKey:null}],storageKey:null}],type:"Project",abstractKey:null}],storageKey:null}]},params:{cacheID:"df512af7fecec8c6f2731f53f703b0f4",id:null,metadata:{},name:"EvaluationSummaryQuery",operationKind:"query",text:`query EvaluationSummaryQuery(
  $id: GlobalID!
  $evaluationName: String!
  $timeRange: TimeRange!
) {
  project: node(id: $id) {
    __typename
    ...EvaluationSummaryValueFragment_1dJL9N
    __isNode: __typename
    id
  }
}

fragment EvaluationSummaryValueFragment_1dJL9N on Project {
  spanEvaluationSummary(evaluationName: $evaluationName, timeRange: $timeRange) {
    labelFractions {
      label
      fraction
    }
    meanScore
  }
  id
}
`}}}();xt.hash="6947c95234456d6fef0b4f148b6ae42c";function Uo({evaluationName:n}){const{projectId:a}=je(),{timeRange:l}=Xn(),t=_.useLazyLoadQuery(xt,{evaluationName:n,id:a,timeRange:{start:l.start.toISOString(),end:l.end.toISOString()}});return s(k,{direction:"column",flex:"none",children:[e(K,{elementType:"h3",textSize:"medium",color:"text-700",children:n}),e(g.Suspense,{fallback:e(K,{textSize:"xlarge",children:"--"}),children:e(Jo,{evaluationName:n,project:t.project})})]})}function Jo(n){var m,p;const{project:a}=n,{fetchKey:l}=Tn(),[t,i]=_.useRefetchableFragment(vt,a);g.useEffect(()=>{g.startTransition(()=>{i({},{fetchPolicy:"store-and-network"})})},[l,i]);const r=Pe(),o=[r.default,r.gray600,r.gray400,r.gray200],c=(m=t==null?void 0:t.spanEvaluationSummary)==null?void 0:m.meanScore,d=(p=t==null?void 0:t.spanEvaluationSummary)==null?void 0:p.labelFractions,u=typeof c=="number",f=Array.isArray(d)&&d.length>0;return s(ge,{delay:0,placement:"bottom",children:[e(ze,{children:s(k,{direction:"row",alignItems:"center",gap:"size-50",children:[f?e(Hr,{width:24,height:24,children:e(Gr,{data:d,dataKey:"fraction",nameKey:"label",cx:"50%",cy:"50%",innerRadius:8,outerRadius:11,strokeWidth:0,stroke:"transparent",children:d.map((y,b)=>e(Wr,{fill:o[b%o.length]},`cell-${b}`))})}):null,e(K,{textSize:"xlarge",children:u?Ce(c):"--"})]})}),e(aa,{children:e(D,{width:"size-2400",children:s(k,{direction:"column",gap:"size-50",children:[f&&e("ul",{children:d.map((y,b)=>e("li",{children:e(te,{color:o[b%o.length],name:y.label,shape:"square",value:dl(y.fraction*100)})},y.label))}),f&&u?e(Jn,{}):null,u?s(k,{direction:"row",justifyContent:"space-between",children:[e(K,{children:"mean"}),e(K,{children:Ce(c)})]}):null]})})})]})}function Xo(n){const{extra:a}=n,{fetchKey:l}=Tn(),[t,i]=_.useRefetchableFragment(yt,n.project);g.useEffect(()=>{g.startTransition(()=>{i({},{fetchPolicy:"store-and-network"})})},[l,i]);const r=t==null?void 0:t.latencyMsP50,o=t==null?void 0:t.latencyMsP99,c=t==null?void 0:t.tokenCountTotal,d=t==null?void 0:t.spanEvaluationNames,u=t==null?void 0:t.documentEvaluationNames;return e(D,{paddingStart:"size-200",paddingEnd:"size-200",paddingTop:"size-200",paddingBottom:"size-50",flex:"none",children:s(k,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e("div",{css:F`
            overflow-x: auto;
            overflow-y: hidden;
            flex: 1 1 auto;
            background-image: linear-gradient(
                to right,
                var(--ac-global-color-grey-75),
                var(--ac-global-color-grey-75)
              ),
              linear-gradient(
                to right,
                var(--ac-global-color-grey-75),
                var(--ac-global-color-grey-75)
              ),
              linear-gradient(
                to right,
                rgba(var(--ac-global-color-grey-300-rgb), 0.9),
                rgba(var(--ac-global-color-grey-300-rgb), 0)
              ),
              linear-gradient(
                to left,
                rgba(var(--ac-global-color-grey-300-rgb), 0.9),
                rgba(var(--ac-global-color-grey-300-rgb), 0)
              );
            background-repeat: no-repeat;
            background-size:
              32px 100%,
              32px 100%,
              32px 100%,
              32px 100%;
            background-position:
              left center,
              right center,
              left center,
              right center;
            background-attachment: local, local, scroll, scroll;
          `,children:s(k,{direction:"row",gap:"size-400",alignItems:"center",children:[s(k,{direction:"column",flex:"none",children:[e(K,{elementType:"h3",textSize:"medium",color:"text-700",children:"Total Traces"}),e(K,{textSize:"xlarge",children:nn(t==null?void 0:t.traceCount)})]}),s(k,{direction:"column",flex:"none",children:[e(K,{elementType:"h3",textSize:"medium",color:"text-700",children:"Total Tokens"}),e(K,{textSize:"xlarge",children:nn(c)})]}),s(k,{direction:"column",flex:"none",children:[e(K,{elementType:"h3",textSize:"medium",color:"text-700",children:"Latency P50"}),r!=null?e(Re,{latencyMs:r,textSize:"xlarge"}):e(K,{textSize:"xlarge",children:"--"})]}),s(k,{direction:"column",flex:"none",children:[e(K,{elementType:"h3",textSize:"medium",color:"text-700",children:"Latency P99"}),o!=null?e(Re,{latencyMs:o,textSize:"xlarge"}):e(K,{textSize:"xlarge",children:"--"})]}),d.map(f=>e(Uo,{evaluationName:f},f)),u.map(f=>e(Go,{evaluationName:f},`document-${f}`))]})}),e(D,{flex:"none",paddingStart:"size-100",children:a})]})})}const Ft=function(){var n={defaultValue:null,kind:"LocalArgument",name:"after"},a={defaultValue:null,kind:"LocalArgument",name:"filterCondition"},l={defaultValue:100,kind:"LocalArgument",name:"first"},t={defaultValue:null,kind:"LocalArgument",name:"id"},i={defaultValue:{col:"startTime",dir:"desc"},kind:"LocalArgument",name:"sort"},r={defaultValue:null,kind:"LocalArgument",name:"timeRange"},o=[{kind:"Variable",name:"id",variableName:"id"}],c={kind:"Variable",name:"after",variableName:"after"},d={kind:"Variable",name:"filterCondition",variableName:"filterCondition"},u={kind:"Variable",name:"first",variableName:"first"},f={kind:"Variable",name:"sort",variableName:"sort"},m={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},p={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},y=[c,d,u,f,{kind:"Variable",name:"timeRange",variableName:"timeRange"}],b={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},S=[{alias:"value",args:null,kind:"ScalarField",name:"truncatedValue",storageKey:null}];return{fragment:{argumentDefinitions:[n,a,l,t,i,r],kind:"Fragment",metadata:null,name:"SpansTableSpansQuery",selections:[{alias:null,args:o,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:[c,d,u,f],kind:"FragmentSpread",name:"SpansTable_spans"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[n,a,l,i,r,t],kind:"Operation",name:"SpansTableSpansQuery",selections:[{alias:null,args:o,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[m,{kind:"TypeDiscriminator",abstractKey:"__isNode"},p,{kind:"InlineFragment",selections:[{alias:null,args:null,kind:"ScalarField",name:"spanEvaluationNames",storageKey:null},{alias:null,args:y,concreteType:"SpanConnection",kind:"LinkedField",name:"spans",plural:!1,selections:[{alias:null,args:null,concreteType:"SpanEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"span",args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[p,{alias:null,args:null,kind:"ScalarField",name:"spanKind",storageKey:null},b,{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"statusCode",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"latencyMs",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"tokenCountPrompt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"tokenCountCompletion",storageKey:null},{alias:null,args:null,concreteType:"SpanContext",kind:"LinkedField",name:"context",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"spanId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"input",plural:!1,selections:S,storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"output",plural:!1,selections:S,storageKey:null},{alias:null,args:null,concreteType:"SpanEvaluation",kind:"LinkedField",name:"spanEvaluations",plural:!0,selections:[b,{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"DocumentRetrievalMetrics",kind:"LinkedField",name:"documentRetrievalMetrics",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"evaluationName",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"ndcg",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"precision",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hit",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[m],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:y,filters:["sort","filterCondition","timeRange"],handle:"connection",key:"SpansTable_spans",kind:"LinkedHandle",name:"spans"}],type:"Project",abstractKey:null}],storageKey:null}]},params:{cacheID:"2413f18f0d411113ca2ad6117d901511",id:null,metadata:{},name:"SpansTableSpansQuery",operationKind:"query",text:`query SpansTableSpansQuery(
  $after: String = null
  $filterCondition: String = null
  $first: Int = 100
  $sort: SpanSort = {col: startTime, dir: desc}
  $timeRange: TimeRange
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...SpansTable_spans_1XEuU
    __isNode: __typename
    id
  }
}

fragment SpanColumnSelector_evaluations on Project {
  spanEvaluationNames
}

fragment SpansTable_spans_1XEuU on Project {
  ...SpanColumnSelector_evaluations
  spans(first: $first, after: $after, sort: $sort, filterCondition: $filterCondition, timeRange: $timeRange) {
    edges {
      span: node {
        id
        spanKind
        name
        metadata
        statusCode
        startTime
        latencyMs
        tokenCountTotal
        tokenCountPrompt
        tokenCountCompletion
        context {
          spanId
          traceId
        }
        input {
          value: truncatedValue
        }
        output {
          value: truncatedValue
        }
        spanEvaluations {
          name
          label
          score
        }
        documentRetrievalMetrics {
          evaluationName
          ndcg
          precision
          hit
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();Ft.hash="78738e3d457d0b4140c9bb4f4dc1180a";const Kt=function(){var n=["spans"],a={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},l={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},t=[{alias:"value",args:null,kind:"ScalarField",name:"truncatedValue",storageKey:null}];return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:null,kind:"LocalArgument",name:"filterCondition"},{defaultValue:100,kind:"LocalArgument",name:"first"},{defaultValue:{col:"startTime",dir:"desc"},kind:"LocalArgument",name:"sort"},{kind:"RootArgument",name:"timeRange"}],kind:"Fragment",metadata:{connection:[{count:"first",cursor:"after",direction:"forward",path:n}],refetch:{connection:{forward:{count:"first",cursor:"after"},backward:null,path:n},fragmentPathInResult:["node"],operation:Ft,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"SpansTable_spans",selections:[{args:null,kind:"FragmentSpread",name:"SpanColumnSelector_evaluations"},{alias:"spans",args:[{kind:"Variable",name:"filterCondition",variableName:"filterCondition"},{kind:"Variable",name:"sort",variableName:"sort"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],concreteType:"SpanConnection",kind:"LinkedField",name:"__SpansTable_spans_connection",plural:!1,selections:[{alias:null,args:null,concreteType:"SpanEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"span",args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[a,{alias:null,args:null,kind:"ScalarField",name:"spanKind",storageKey:null},l,{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"statusCode",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"latencyMs",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"tokenCountPrompt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"tokenCountCompletion",storageKey:null},{alias:null,args:null,concreteType:"SpanContext",kind:"LinkedField",name:"context",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"spanId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"input",plural:!1,selections:t,storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"output",plural:!1,selections:t,storageKey:null},{alias:null,args:null,concreteType:"SpanEvaluation",kind:"LinkedField",name:"spanEvaluations",plural:!0,selections:[l,{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"DocumentRetrievalMetrics",kind:"LinkedField",name:"documentRetrievalMetrics",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"evaluationName",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"ndcg",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"precision",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hit",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},a],type:"Project",abstractKey:null}}();Kt.hash="78738e3d457d0b4140c9bb4f4dc1180a";const Tt=g.createContext(null);function Zo({children:n,...a}){const l=g.useRef();return l.current||(l.current=xr(a)),e(Tt.Provider,{value:l.current,children:n})}function Oe(n,a){const l=Fe.useContext(Tt);if(!l)throw new Error("Missing TracingContext.Provider in the tree");return el(l,n,a)}const Dt={argumentDefinitions:[],kind:"Fragment",metadata:null,name:"SpanColumnSelector_evaluations",selections:[{alias:null,args:null,kind:"ScalarField",name:"spanEvaluationNames",storageKey:null}],type:"Project",abstractKey:null};Dt.hash="b15c9caa847912fdb7b07a0c01a69ed9";const Yo=["spanKind","name"];function Ct(n){return e(Ra,{menu:e(ed,{...n}),triggerProps:{placement:"bottom end"},children:s(k,{direction:"row",alignItems:"center",gap:"size-100",children:[e(N,{svg:e(M.Column,{})}),"Columns"]})})}const Wn=F`
  padding: var(--ac-global-dimension-static-size-50)
    var(--ac-global-dimension-static-size-100);
  label {
    display: flex;
    align-items: center;
    gap: var(--ac-global-dimension-static-size-100);
  }
`;function ed(n){const{columns:a}=n,l=Oe(d=>d.columnVisibility),t=Oe(d=>d.setColumnVisibility),i=g.useMemo(()=>a.filter(d=>!Yo.includes(d.id)),[a]),r=g.useMemo(()=>i.every(d=>{const u=l[d.id];return u??!0}),[i,l]),o=g.useCallback(d=>{const{name:u,checked:f}=d.target;t({...l,[u]:f})},[l,t]),c=g.useCallback(d=>{const{checked:u}=d.target,f=i.reduce((m,p)=>({...m,[p.id]:u}),{});t(f)},[i,t]);return e("div",{css:F`
        overflow-y: auto;
        max-height: calc(100vh - 200px);
      `,children:s(D,{paddingTop:"size-50",paddingBottom:"size-50",children:[e(D,{borderBottomColor:"dark",borderBottomWidth:"thin",paddingBottom:"size-50",children:e("div",{css:Wn,children:s("label",{children:[e("input",{type:"checkbox",name:"toggle-all",checked:r,onChange:c}),"span columns"]})})}),e("ul",{children:i.map(d=>{const u=l[d.id],f=u??!0,m=typeof d.columnDef.header=="string"?d.columnDef.header:d.id;return e("li",{css:Wn,children:s("label",{children:[e("input",{type:"checkbox",name:d.id,checked:f,onChange:o}),m]})},d.id)})}),e(nd,{...n})]})})}function nd({query:n}){const a=_.useFragment(Dt,n),l=Oe(o=>o.evaluationVisibility),t=Oe(o=>o.setEvaluationVisibility),i=g.useMemo(()=>a.spanEvaluationNames.every(o=>l[o]||!1),[l,a.spanEvaluationNames]),r=g.useCallback(()=>{const o=a.spanEvaluationNames.reduce((c,d)=>({...c,[d]:!i}),{});t(o)},[t,i,a.spanEvaluationNames]);return s("section",{children:[e(D,{paddingTop:"size-50",paddingBottom:"size-50",borderColor:"dark",borderTopWidth:"thin",borderBottomWidth:"thin",children:e("div",{css:Wn,children:s("label",{children:[e("input",{type:"checkbox",name:"toggle-evaluations-all",checked:i,onChange:r}),"evaluations"]})})}),e("ul",{children:a.spanEvaluationNames.map(o=>{const c=l[o];return e("li",{css:Wn,children:s("label",{children:[e("input",{type:"checkbox",name:o,checked:c,onChange:()=>{t({...l,[o]:!c})}}),o]})},o)})})]})}const It=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"condition"},{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l={kind:"InlineFragment",selections:[{alias:null,args:[{kind:"Variable",name:"condition",variableName:"condition"}],concreteType:"ValidationResult",kind:"LinkedField",name:"validateSpanFilterCondition",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"isValid",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"errorMessage",storageKey:null}],storageKey:null}],type:"Project",abstractKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"SpanFilterConditionFieldValidationQuery",selections:[{alias:"project",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"SpanFilterConditionFieldValidationQuery",selections:[{alias:"project",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},l,{kind:"TypeDiscriminator",abstractKey:"__isNode"},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null}],storageKey:null}]},params:{cacheID:"29583e7ec666cef832dc7effb9e75678",id:null,metadata:{},name:"SpanFilterConditionFieldValidationQuery",operationKind:"query",text:`query SpanFilterConditionFieldValidationQuery(
  $condition: String!
  $id: GlobalID!
) {
  project: node(id: $id) {
    __typename
    ... on Project {
      validateSpanFilterCondition(condition: $condition) {
        isValid
        errorMessage
      }
    }
    __isNode: __typename
    id
  }
}
`}}}();It.hash="22836f192038b0c40201d3b25aad65b4";const Lt=F`
  flex: 1 1 auto;
  .cm-content {
    padding: var(--ac-global-dimension-static-size-100) 0;
  }
  .cm-editor {
    background-color: transparent;
  }
  .cm-focused {
    outline: none;
  }
  .cm-selectionLayer .cm-selectionBackground {
    background: var(--ac-global-color-cyan-400) !important;
  }
`,Et=F`
  border-width: var(--ac-global-border-size-thin);
  border-style: solid;
  border-color: var(--ac-global-input-field-border-color);
  border-radius: var(--ac-global-rounding-small);
  background-color: var(--ac-global-input-field-background-color);
  transition: all 0.2s ease-in-out;
  overflow-x: hidden;
  &:hover,
  &[data-is-focused="true"] {
    border-color: var(--ac-global-input-field-border-color-active);
    background-color: var(--ac-global-input-field-background-color-active);
  }
  &[data-is-invalid="true"] {
    border-color: var(--ac-global-color-danger);
  }
  box-sizing: border-box;
`;function ad(n){const a=n.matchBefore(/\w*/);return!a||a.from==a.to&&!n.explicit?null:{from:a.from,options:[{label:"span_kind",type:"variable",info:"The span variant: CHAIN, LLM, RETRIEVER, TOOL, etc."},{label:"status_code",type:"variable",info:"The span status: OK, UNSET, or ERROR"},{label:"input.value",type:"variable",info:"The input value of a span, typically a query"},{label:"output.value",type:"variable",info:"The output value of a span, typically a response"},{label:"name",type:"variable",info:"The name given to a span - e.x. OpenAI"},{label:"latency_ms",type:"variable",info:"Latency (i.e. duration) in milliseconds"},{label:"cumulative_token_count.prompt",type:"variable",info:"Sum of token count for prompt from self and all child spans"},{label:"cumulative_token_count.completion",type:"variable",info:"Sum of token count for completion from self and all child spans"},{label:"cumulative_token_count.total",type:"variable",info:"Sum of token count total (prompt + completion) from self and all child spans"},{label:"llm spans",type:"text",apply:"span_kind == 'LLM'",detail:"macro"},{label:"retriever spans",type:"text",apply:"span_kind == 'RETRIEVER'",detail:"macro"},{label:"search input",type:"text",apply:"'' in input.value",detail:"macro"},{label:"search output",type:"text",apply:"'' in output.value",detail:"macro"},{label:"status_code error",type:"text",apply:"status_code == 'ERROR'",detail:"macro"},{label:"Latency >= 10s",type:"text",apply:"latency_ms >= 10_000",detail:"macro"},{label:"Tokens >= 1,000",type:"text",apply:"llm.token_count.total >= 1_000",detail:"macro"},{label:"Hallucinations",type:"text",apply:"evals['Hallucination'].label == 'hallucinated'",detail:"macro"},{label:"Metadata",type:"text",apply:"metadata['topic'] == 'agent'",detail:"macro"},{label:"Substring",type:"text",apply:"'agent' in input.value",detail:"macro"}]}}async function ld(n,a){if(!n)return{isValid:!0,errorMessage:null};const l=await Ni.fetchQuery(Ke,It,{condition:n,id:a}).toPromise();if(!l)throw new Error("Filter condition validation is null");return l.project.validateSpanFilterCondition}const td=[Xr.of([{key:"Enter",run:n=>!0}]),Pa(),Zr({override:[ad]})];function Rt(n){const{onValidCondition:a,placeholder:l="filter condition (e.x. span_kind == 'LLM')"}=n,[t,i]=g.useState(!1),[r,o]=g.useState(""),[c,d]=g.useState(""),u=g.useDeferredValue(c),{theme:f}=Vn(),m=f==="dark"?ia:void 0,p=g.useCallback(h=>{c.length>0?d(`${c} and ${h}`):d(h)},[c,d]),{projectId:y}=je();g.useEffect(()=>{ld(u,y).then(h=>{!(h!=null&&h.isValid)&&(h!=null&&h.errorMessage)?o(h.errorMessage):(o(""),g.startTransition(()=>{a(u)}))})},[a,u,y]);const b=r!=="",S=c!=="";return s("div",{"data-is-focused":t,"data-is-invalid":b,className:"span-filter-condition-field",css:Et,children:[s(k,{direction:"row",children:[e(Or,{children:e(N,{svg:e(M.Search,{})})}),e(ta,{css:Lt,basicSetup:{lineNumbers:!1,foldGutter:!1,bracketMatching:!0,syntaxHighlighting:!0,highlightActiveLine:!1,highlightActiveLineGutter:!1,defaultKeymap:!1},onFocus:()=>i(!0),onBlur:()=>i(!1),value:c,onChange:d,height:"36px",width:"100%",theme:m,placeholder:l,extensions:td}),e("button",{css:F`
            margin-right: var(--ac-global-dimension-static-size-100);
            color: var(--ac-global-text-color-700);
            visibility: ${S?"visible":"hidden"};
          `,onClick:()=>d(""),className:"button--reset",children:e(N,{svg:e(M.CloseCircleOutline,{})})}),s(Kn,{placement:"bottom right",children:[e(ze,{children:e("button",{css:F`
                color: var(--ac-global-text-color-700);
                background-color: var(--ac-global-color-grey-400);
                padding-left: var(--ac-global-dimension-static-size-100);
                padding-right: var(--ac-global-dimension-static-size-100);
                height: 100%;
              `,className:"button--reset",children:e(N,{svg:e(M.PlusCircleOutline,{})})})}),e(id,{onAddFilterConditionSnippet:p})]})]}),s(ge,{isOpen:b&&t,placement:"bottom",children:[e(ze,{children:e("div",{})}),e(aa,{children:r!=""?e(K,{color:"danger",children:r}):e(K,{color:"success",children:"Valid Expression"})})]})]})}function id(n){const{onAddFilterConditionSnippet:a}=n;return e(D,{width:"500px",paddingTop:"size-200",paddingStart:"size-200",paddingEnd:"size-200",borderRadius:"medium",borderWidth:"thin",borderColor:"light",backgroundColor:"light",children:s(_n,{children:[e(dn,{label:"filter by kind",initialSnippet:"span_kind == 'LLM'",onAddFilterConditionSnippet:a},"kind"),e(dn,{label:"filter by token count",initialSnippet:"cumulative_token_count.total > 1000",onAddFilterConditionSnippet:a},"token_count"),e(dn,{label:"filter by evaluation label",initialSnippet:"evals['Hallucination'].label == 'hallucinated'",onAddFilterConditionSnippet:a},"eval_label"),e(dn,{label:"filter by evaluation score",initialSnippet:"evals['Hallucination'].score < 1",onAddFilterConditionSnippet:a},"eval_score"),e(dn,{label:"filter by metadata",initialSnippet:"metadata['topic'] == 'agent'",onAddFilterConditionSnippet:a},"metadata"),e(dn,{label:"filter by substring",initialSnippet:"'agent' in input.value",onAddFilterConditionSnippet:a},"substring")]})})}function dn(n){const{initialSnippet:a,onAddFilterConditionSnippet:l}=n,[t,i]=g.useState(a),{theme:r}=Vn(),o=r==="light"?void 0:ia;return e(la,{label:n.label,children:s(k,{direction:"row",width:"100%",gap:"size-100",children:[e("div",{css:F(Et,F`
              flex: 1 1 auto;
            `),children:e(ta,{value:t,basicSetup:{lineNumbers:!1,foldGutter:!1,bracketMatching:!0,syntaxHighlighting:!0,highlightActiveLine:!1,highlightActiveLineGutter:!1},extensions:[Pa()],editable:!0,onChange:i,theme:o,css:Lt})}),e(O,{title:"Add to filter condition",variant:"default",onClick:()=>l(t),icon:e(N,{svg:e(M.PlusCircleOutline,{})})})]})})}const _t=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"input"}],a=[{alias:null,args:[{kind:"Variable",name:"input",variableName:"input"}],concreteType:"DatasetMutationPayload",kind:"LinkedField",name:"addSpansToDataset",plural:!1,selections:[{alias:null,args:null,concreteType:"Dataset",kind:"LinkedField",name:"dataset",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null}],storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"SpanSelectionToolbarAddSpansToDatasetMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"SpanSelectionToolbarAddSpansToDatasetMutation",selections:a},params:{cacheID:"1c694540190478b8fba8ef3c0cacf30c",id:null,metadata:{},name:"SpanSelectionToolbarAddSpansToDatasetMutation",operationKind:"mutation",text:`mutation SpanSelectionToolbarAddSpansToDatasetMutation(
  $input: AddSpansToDatasetInput!
) {
  addSpansToDataset(input: $input) {
    dataset {
      id
    }
  }
}
`}}}();_t.hash="5e3aef907285081a06c0e0360045e865";const wt={fragment:{argumentDefinitions:[],kind:"Fragment",metadata:null,name:"DatasetSelectorPopoverContentDatasetsQuery",selections:[{args:null,kind:"FragmentSpread",name:"DatasetSelectorPopoverContent_datasets"}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[],kind:"Operation",name:"DatasetSelectorPopoverContentDatasetsQuery",selections:[{alias:null,args:null,concreteType:"DatasetConnection",kind:"LinkedField",name:"datasets",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"dataset",args:null,concreteType:"Dataset",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}]},params:{cacheID:"6d459b61a36b99979f025742892941f9",id:null,metadata:{},name:"DatasetSelectorPopoverContentDatasetsQuery",operationKind:"query",text:`query DatasetSelectorPopoverContentDatasetsQuery {
  ...DatasetSelectorPopoverContent_datasets
}

fragment DatasetSelectorPopoverContent_datasets on Query {
  datasets {
    edges {
      dataset: node {
        id
        name
      }
    }
  }
}
`}};wt.hash="40d5267ad0ec2335a73ff2a4d05bbed1";const Pt={argumentDefinitions:[],kind:"Fragment",metadata:{refetch:{connection:null,fragmentPathInResult:[],operation:wt}},name:"DatasetSelectorPopoverContent_datasets",selections:[{alias:null,args:null,concreteType:"DatasetConnection",kind:"LinkedField",name:"datasets",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"dataset",args:null,concreteType:"Dataset",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}],type:"Query",abstractKey:null};Pt.hash="40d5267ad0ec2335a73ff2a4d05bbed1";const Mt={fragment:{argumentDefinitions:[],kind:"Fragment",metadata:null,name:"DatasetSelectorPopoverContentQuery",selections:[{args:null,kind:"FragmentSpread",name:"DatasetSelectorPopoverContent_datasets"}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[],kind:"Operation",name:"DatasetSelectorPopoverContentQuery",selections:[{alias:null,args:null,concreteType:"DatasetConnection",kind:"LinkedField",name:"datasets",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"dataset",args:null,concreteType:"Dataset",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}]},params:{cacheID:"5fb28a402f330dd235295da21efea58b",id:null,metadata:{},name:"DatasetSelectorPopoverContentQuery",operationKind:"query",text:`query DatasetSelectorPopoverContentQuery {
  ...DatasetSelectorPopoverContent_datasets
}

fragment DatasetSelectorPopoverContent_datasets on Query {
  datasets {
    edges {
      dataset: node {
        id
        name
      }
    }
  }
}
`}};Mt.hash="7cd8a13144d97d2b5294f2a09c9e1351";function rd(n){const{onCreateNewDataset:a,onDatasetSelected:l}=n,[t,i]=g.useState(""),r=_.useLazyLoadQuery(Mt,{},{fetchPolicy:"network-only"});return s(Q,{title:"Add to Dataset",variant:"compact",backgroundColor:"light",borderColor:"light",bodyStyle:{padding:0},extra:e(O,{variant:"default",size:"compact",onClick:a,children:"New Dataset"}),children:[e(D,{padding:"size-100",children:e(Ne,{type:"search",placeholder:"Search datasets",addonBefore:e(N,{svg:e(M.Search,{})}),onChange:o=>{i(o)}})}),e(D,{borderTopWidth:"thin",borderColor:"light",children:e("div",{css:F`
            height: 400px;
            overflow-y: auto;
          `,children:e(sd,{query:r,search:t,onDatasetSelected:l})})})]})}function sd(n){const{search:a,onDatasetSelected:l}=n,[t]=_.useRefetchableFragment(Pt,n.query),i=g.useMemo(()=>{let o=t.datasets.edges.map(c=>c.dataset);return a&&(o=o.filter(c=>c.name.toLowerCase().includes(a.toLowerCase()))),o},[a,t]);return i.length===0?e(k,{direction:"column",justifyContent:"center",alignItems:"center",flex:"1 1 auto",children:e(K,{children:"No datasets found"})}):e(Yn,{selectionMode:"single",onSelectionChange:o=>{if(typeof o=="object"){const c=Array.from(o);l(c[0])}},children:i.map(o=>e(H,{children:o.name},o.id))})}function Nt(n){const a=ne(),[l,t]=g.useState(null),i=Me(),r=Qn(),[o,c]=g.useState(!1),{selectedSpans:d,onClearSelection:u}=n,[f,m]=_.useMutation(_t),p=d.length!==1,y=g.useCallback(b=>{f({variables:{input:{datasetId:b,spanIds:d.map(S=>S.id)}},onCompleted:()=>{i({title:"Examples added to dataset",message:`${d.length} example${p?"s":""} have been added to the dataset.`,action:{text:"View dataset",onClick:()=>{a(`/datasets/${b}/examples`)}}}),u()},onError:S=>{r({title:"An error occurred",message:`Failed to add spans to dataset: ${S.message}`})}})},[f,d,i,p,u,a,r]);return s("div",{css:F`
        position: absolute;
        bottom: var(--ac-global-dimension-size-400);
        left: 50%;
        transform: translateX(-50%);
      `,children:[e(D,{backgroundColor:"light",padding:"size-200",borderColor:"light",borderWidth:"thin",borderRadius:"medium",minWidth:"size-6000",children:s(k,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e(K,{children:`${d.length} span${p?"s":""} selected`}),s(k,{direction:"row",gap:"size-100",children:[e(O,{variant:"default",size:"compact",onClick:u,children:"Cancel"}),s(Kn,{placement:"top end",crossOffset:300,isOpen:o,onOpenChange:b=>{c(b)},children:[e(O,{variant:"primary",size:"compact",icon:e(N,{svg:e(M.DatabaseOutline,{})}),loading:m,disabled:m,children:m?"Adding to dataset":"Add to dataset"}),e(g.Suspense,{children:e(rd,{onDatasetSelected:b=>{y(b),c(!1)},onCreateNewDataset:()=>{c(!1),t(e(X,{title:"New Dataset",isDismissable:!0,onDismiss:()=>t(null),children:e(Ka,{onDatasetCreateError:()=>{r({title:"Dataset creation failed",message:"Failed to create dataset."})},onDatasetCreated:b=>{t(null),i({title:"Dataset created",message:`${b.name} has been successfully created.`}),c(!0)}})}))}})})]})]})]})}),e(ae,{onDismiss:()=>{t(null)},children:l})]})}const $t=F`
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  overflow: hidden;
  .span-filter-condition-field {
    flex: 1 1 auto;
  }

  // Style the column selector
  .ac-dropdown-button {
    min-width: var(--ac-global-dimension-static-size-300);
  }
`,Pn="evals",Ie=":",Vt={col:"startTime",dir:"desc"};function zt(n){let a=null,l=null;if(n.id&&n.id.startsWith(Pn)){const[,t,i]=n.id.split(Ie);l={attr:t,name:i}}else a=n.id;return{col:a,evalResultKey:l,dir:n.desc?"desc":"asc"}}const Ha=100;function od(n){const{fetchKey:a}=Tn(),l=g.useRef(null),[t,i]=g.useState({}),[r,o]=g.useState([]),[c,d]=g.useState(""),u=Oe(w=>w.columnVisibility),f=ne(),{data:m,loadNext:p,hasNext:y,isLoadingNext:b,refetch:S}=_.usePaginationFragment(Kt,n.project),h=Oe(w=>w.evaluationVisibility),x=g.useMemo(()=>Object.keys(h).filter(w=>h[w]),[h]),L=g.useMemo(()=>m.spans.edges.map(({span:$})=>$),[m]),I=x.map(w=>({header:w,columns:[{header:"label",accessorKey:`${Pn}${Ie}label${Ie}${w}`,cell:({row:$})=>{const E=$.original.spanEvaluations.find(V=>V.name===w);return E?E.label:null}},{header:"score",accessorKey:`${Pn}${Ie}score${Ie}${w}`,cell:({row:$})=>{const E=$.original.spanEvaluations.find(V=>V.name===w);return E?E.score:null}}]})),C=[{header:"evaluations",accessorKey:"spanEvaluations",enableSorting:!1,cell:({row:w})=>s(k,{direction:"row",gap:"size-50",wrap:"wrap",children:[w.original.spanEvaluations.map($=>e(Ma,{evaluation:$},$.name)),w.original.documentRetrievalMetrics.map($=>s(W,{children:[e(ce,{name:$.evaluationName,metric:"ndcg",score:$.ndcg},"ndcg"),e(ce,{name:$.evaluationName,metric:"precision",score:$.precision},"precision"),e(ce,{name:$.evaluationName,metric:"hit",score:$.hit},"hit")]}))]})},...I],v=[{id:"select",maxSize:10,header:({table:w})=>e($e,{checked:w.getIsAllRowsSelected(),indeterminate:w.getIsSomeRowsSelected(),onChange:w.getToggleAllRowsSelectedHandler()}),cell:({row:w})=>e($e,{checked:w.getIsSelected(),disabled:!w.getCanSelect(),indeterminate:w.getIsSomeSelected(),onChange:w.getToggleSelectedHandler()})},{header:"kind",accessorKey:"spanKind",maxSize:100,enableSorting:!1,cell:({getValue:w})=>e(cl,{spanKind:w()})},{header:"name",accessorKey:"name",enableSorting:!1,cell:({getValue:w,row:$})=>{const{spanId:E,traceId:V}=$.original.context;return e(xn,{to:`traces/${V}?selectedSpanId=${E}`,children:w()})}},{header:"input",accessorKey:"input.value",cell:Se,enableSorting:!1},{header:"output",accessorKey:"output.value",cell:Se,enableSorting:!1},{header:"metadata",accessorKey:"metadata",cell:Se,enableSorting:!1},...C,{header:"start time",accessorKey:"startTime",cell:Fn},{header:"latency",accessorKey:"latencyMs",cell:({getValue:w})=>{const $=w();return $===null||typeof $!="number"?null:e(Re,{latencyMs:$})}},{header:"total tokens",accessorKey:"tokenCountTotal",cell:({row:w,getValue:$})=>{const E=$();return E===null?"--":e(tt,{tokenCountTotal:E,tokenCountPrompt:w.original.tokenCountPrompt||0,tokenCountCompletion:w.original.tokenCountCompletion||0})}},{header:"status",accessorKey:"statusCode",enableSorting:!1,cell:({getValue:w})=>e(Ta,{statusCode:w()})}];g.useEffect(()=>{const w=r[0];g.startTransition(()=>{S({sort:w?zt(w):Vt,after:null,first:Ha,filterCondition:c},{fetchPolicy:"store-and-network"})})},[r,S,c,a]);const T=g.useCallback(w=>{if(w){const{scrollHeight:$,scrollTop:E,clientHeight:V}=w;$-E-V<300&&!b&&y&&p(Ha)}},[y,b,p]),P=he({columns:v,data:L,state:{sorting:r,columnVisibility:u,rowSelection:t},manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:i,onSortingChange:o,getCoreRowModel:ke(),getSortedRowModel:Mn()}),R=P.getRowModel().rows,z=P.getSelectedRowModel().rows,j=z.map(w=>w.original),U=g.useCallback(()=>{i({})},[i]),ie=R.length===0,re=P.getAllColumns().filter(w=>w.columns.length===0);return s("div",{css:$t,children:[e(D,{paddingTop:"size-100",paddingBottom:"size-100",paddingStart:"size-200",paddingEnd:"size-200",borderBottomColor:"grey-300",borderBottomWidth:"thin",flex:"none",children:s(k,{direction:"row",gap:"size-100",width:"100%",alignItems:"center",children:[e(Rt,{onValidCondition:d}),e(Ct,{columns:re,query:m})]})}),e("div",{css:F`
          flex: 1 1 auto;
          overflow: auto;
        `,onScroll:w=>T(w.target),ref:l,children:s("table",{css:vn,children:[e("thead",{children:P.getHeaderGroups().map(w=>e("tr",{children:w.headers.map($=>e("th",{colSpan:$.colSpan,children:$.isPlaceholder?null:s("div",{className:$.column.getCanSort()?"cursor-pointer":"",onClick:$.column.getToggleSortingHandler(),style:{left:$.getStart(),width:$.getSize()},children:[G($.column.columnDef.header,$.getContext()),$.column.getIsSorted()?e(N,{className:"sort-icon",svg:$.column.getIsSorted()==="asc"?e(M.ArrowUpFilled,{}):e(M.ArrowDownFilled,{})}):null]})},$.id))},w.id))}),ie?e(tn,{}):e("tbody",{children:R.map(w=>e("tr",{onClick:()=>f(`traces/${w.original.context.traceId}?selectedSpanId=${w.original.context.spanId}`),children:w.getVisibleCells().map($=>e("td",{children:G($.column.columnDef.cell,$.getContext())},$.id))},w.id))})]})}),z.length?e(Nt,{selectedSpans:j,onClearSelection:U}):null]})}const At=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"StreamToggleRefetchQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:null,kind:"FragmentSpread",name:"StreamToggle_data"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"StreamToggleRefetchQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},{kind:"TypeDiscriminator",abstractKey:"__isNode"},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{kind:"InlineFragment",selections:[{alias:null,args:null,kind:"ScalarField",name:"streamingLastUpdatedAt",storageKey:null}],type:"Project",abstractKey:null}],storageKey:null}]},params:{cacheID:"4e136f41c0942f253822336dc0c5b291",id:null,metadata:{},name:"StreamToggleRefetchQuery",operationKind:"query",text:`query StreamToggleRefetchQuery(
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...StreamToggle_data
    __isNode: __typename
    id
  }
}

fragment StreamToggle_data on Project {
  streamingLastUpdatedAt
  id
}
`}}}();At.hash="30a8f0bcf1aa6021b2c9a47866f5dc49";const Qt={argumentDefinitions:[],kind:"Fragment",metadata:{refetch:{connection:null,fragmentPathInResult:["node"],operation:At,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"StreamToggle_data",selections:[{alias:null,args:null,kind:"ScalarField",name:"streamingLastUpdatedAt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null}],type:"Project",abstractKey:null};Qt.hash="30a8f0bcf1aa6021b2c9a47866f5dc49";function Ot(n,a){const l=g.useRef(null);g.useEffect(()=>{l.current=n},[n]),g.useEffect(()=>{function t(){l.current&&l.current()}if(a!==null){const i=setInterval(t,a);return()=>clearInterval(i)}},[a])}const dd=2e3;function cd(n){const{isStreaming:a,setIsStreaming:l,setFetchKey:t}=Tn(),[i,r]=_.useRefetchableFragment(Qt,n.project),o=g.useRef(i.streamingLastUpdatedAt),c=g.useCallback(()=>{a&&g.startTransition(()=>{r({},{fetchPolicy:"store-and-network"})})},[a,r]),d=i.streamingLastUpdatedAt;return g.useEffect(()=>{d!=null&&(o.current==null||o.current<d)&&(o.current=d,t(`fetch-traces-${d}`))},[t,d]),Ot(c,dd),e(La,{labelPlacement:"start",defaultSelected:!0,onChange:()=>{l(!a)},children:"Stream"})}const jt=function(){var n={defaultValue:null,kind:"LocalArgument",name:"after"},a={defaultValue:null,kind:"LocalArgument",name:"filterCondition"},l={defaultValue:100,kind:"LocalArgument",name:"first"},t={defaultValue:null,kind:"LocalArgument",name:"id"},i={defaultValue:{col:"startTime",dir:"desc"},kind:"LocalArgument",name:"sort"},r={defaultValue:null,kind:"LocalArgument",name:"timeRange"},o=[{kind:"Variable",name:"id",variableName:"id"}],c={kind:"Variable",name:"after",variableName:"after"},d={kind:"Variable",name:"filterCondition",variableName:"filterCondition"},u={kind:"Variable",name:"first",variableName:"first"},f={kind:"Variable",name:"sort",variableName:"sort"},m={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},p={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},y=[c,d,u,{kind:"Literal",name:"rootSpansOnly",value:!0},f,{kind:"Variable",name:"timeRange",variableName:"timeRange"}],b={alias:null,args:null,kind:"ScalarField",name:"spanKind",storageKey:null},S={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},h={alias:"statusCode",args:null,kind:"ScalarField",name:"propagatedStatusCode",storageKey:null},x={alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},L={alias:null,args:null,kind:"ScalarField",name:"latencyMs",storageKey:null},I={alias:null,args:null,kind:"ScalarField",name:"parentId",storageKey:null},C=[{alias:"value",args:null,kind:"ScalarField",name:"truncatedValue",storageKey:null}],v={alias:null,args:null,concreteType:"SpanContext",kind:"LinkedField",name:"context",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"spanId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null}],storageKey:null},T={alias:null,args:null,concreteType:"SpanEvaluation",kind:"LinkedField",name:"spanEvaluations",plural:!0,selections:[S,{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null}],storageKey:null},P={alias:null,args:null,concreteType:"DocumentRetrievalMetrics",kind:"LinkedField",name:"documentRetrievalMetrics",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"evaluationName",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"ndcg",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"precision",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hit",storageKey:null}],storageKey:null},R=[{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}];return{fragment:{argumentDefinitions:[n,a,l,t,i,r],kind:"Fragment",metadata:null,name:"TracesTableQuery",selections:[{alias:null,args:o,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:[c,d,u,f],kind:"FragmentSpread",name:"TracesTable_spans"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[n,a,l,i,r,t],kind:"Operation",name:"TracesTableQuery",selections:[{alias:null,args:o,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[m,{kind:"TypeDiscriminator",abstractKey:"__isNode"},p,{kind:"InlineFragment",selections:[{alias:null,args:null,kind:"ScalarField",name:"spanEvaluationNames",storageKey:null},{alias:"rootSpans",args:y,concreteType:"SpanConnection",kind:"LinkedField",name:"spans",plural:!1,selections:[{alias:null,args:null,concreteType:"SpanEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"rootSpan",args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[p,b,S,{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null},h,x,L,{alias:null,args:null,kind:"ScalarField",name:"cumulativeTokenCountTotal",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cumulativeTokenCountPrompt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cumulativeTokenCountCompletion",storageKey:null},I,{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"input",plural:!1,selections:C,storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"output",plural:!1,selections:C,storageKey:null},v,T,P,{alias:null,args:null,concreteType:"Span",kind:"LinkedField",name:"descendants",plural:!0,selections:[p,b,S,h,x,L,I,{alias:"cumulativeTokenCountTotal",args:null,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},{alias:"cumulativeTokenCountPrompt",args:null,kind:"ScalarField",name:"tokenCountPrompt",storageKey:null},{alias:"cumulativeTokenCountCompletion",args:null,kind:"ScalarField",name:"tokenCountCompletion",storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"input",plural:!1,selections:R,storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"output",plural:!1,selections:R,storageKey:null},v,T,P],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[m],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},{alias:"rootSpans",args:y,filters:["sort","rootSpansOnly","filterCondition","timeRange"],handle:"connection",key:"TracesTable_rootSpans",kind:"LinkedHandle",name:"spans"}],type:"Project",abstractKey:null}],storageKey:null}]},params:{cacheID:"82574e0f30ec618a7a89afd7c4664347",id:null,metadata:{},name:"TracesTableQuery",operationKind:"query",text:`query TracesTableQuery(
  $after: String = null
  $filterCondition: String = null
  $first: Int = 100
  $sort: SpanSort = {col: startTime, dir: desc}
  $timeRange: TimeRange
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...TracesTable_spans_1XEuU
    __isNode: __typename
    id
  }
}

fragment SpanColumnSelector_evaluations on Project {
  spanEvaluationNames
}

fragment TracesTable_spans_1XEuU on Project {
  ...SpanColumnSelector_evaluations
  rootSpans: spans(first: $first, after: $after, sort: $sort, rootSpansOnly: true, filterCondition: $filterCondition, timeRange: $timeRange) {
    edges {
      rootSpan: node {
        id
        spanKind
        name
        metadata
        statusCode: propagatedStatusCode
        startTime
        latencyMs
        cumulativeTokenCountTotal
        cumulativeTokenCountPrompt
        cumulativeTokenCountCompletion
        parentId
        input {
          value: truncatedValue
        }
        output {
          value: truncatedValue
        }
        context {
          spanId
          traceId
        }
        spanEvaluations {
          name
          label
          score
        }
        documentRetrievalMetrics {
          evaluationName
          ndcg
          precision
          hit
        }
        descendants {
          id
          spanKind
          name
          statusCode: propagatedStatusCode
          startTime
          latencyMs
          parentId
          cumulativeTokenCountTotal: tokenCountTotal
          cumulativeTokenCountPrompt: tokenCountPrompt
          cumulativeTokenCountCompletion: tokenCountCompletion
          input {
            value
          }
          output {
            value
          }
          context {
            spanId
            traceId
          }
          spanEvaluations {
            name
            label
            score
          }
          documentRetrievalMetrics {
            evaluationName
            ndcg
            precision
            hit
          }
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();jt.hash="b8e7c42b9731568c7e348cf191017d06";const qt=function(){var n=["rootSpans"],a={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},l={alias:null,args:null,kind:"ScalarField",name:"spanKind",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},i={alias:"statusCode",args:null,kind:"ScalarField",name:"propagatedStatusCode",storageKey:null},r={alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},o={alias:null,args:null,kind:"ScalarField",name:"latencyMs",storageKey:null},c={alias:null,args:null,kind:"ScalarField",name:"parentId",storageKey:null},d=[{alias:"value",args:null,kind:"ScalarField",name:"truncatedValue",storageKey:null}],u={alias:null,args:null,concreteType:"SpanContext",kind:"LinkedField",name:"context",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"spanId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null}],storageKey:null},f={alias:null,args:null,concreteType:"SpanEvaluation",kind:"LinkedField",name:"spanEvaluations",plural:!0,selections:[t,{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null}],storageKey:null},m={alias:null,args:null,concreteType:"DocumentRetrievalMetrics",kind:"LinkedField",name:"documentRetrievalMetrics",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"evaluationName",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"ndcg",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"precision",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hit",storageKey:null}],storageKey:null},p=[{alias:null,args:null,kind:"ScalarField",name:"value",storageKey:null}];return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:null,kind:"LocalArgument",name:"filterCondition"},{defaultValue:100,kind:"LocalArgument",name:"first"},{defaultValue:{col:"startTime",dir:"desc"},kind:"LocalArgument",name:"sort"},{kind:"RootArgument",name:"timeRange"}],kind:"Fragment",metadata:{connection:[{count:"first",cursor:"after",direction:"forward",path:n}],refetch:{connection:{forward:{count:"first",cursor:"after"},backward:null,path:n},fragmentPathInResult:["node"],operation:jt,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"TracesTable_spans",selections:[{args:null,kind:"FragmentSpread",name:"SpanColumnSelector_evaluations"},{alias:"rootSpans",args:[{kind:"Variable",name:"filterCondition",variableName:"filterCondition"},{kind:"Literal",name:"rootSpansOnly",value:!0},{kind:"Variable",name:"sort",variableName:"sort"},{kind:"Variable",name:"timeRange",variableName:"timeRange"}],concreteType:"SpanConnection",kind:"LinkedField",name:"__TracesTable_rootSpans_connection",plural:!1,selections:[{alias:null,args:null,concreteType:"SpanEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"rootSpan",args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[a,l,t,{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null},i,r,o,{alias:null,args:null,kind:"ScalarField",name:"cumulativeTokenCountTotal",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cumulativeTokenCountPrompt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cumulativeTokenCountCompletion",storageKey:null},c,{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"input",plural:!1,selections:d,storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"output",plural:!1,selections:d,storageKey:null},u,f,m,{alias:null,args:null,concreteType:"Span",kind:"LinkedField",name:"descendants",plural:!0,selections:[a,l,t,i,r,o,c,{alias:"cumulativeTokenCountTotal",args:null,kind:"ScalarField",name:"tokenCountTotal",storageKey:null},{alias:"cumulativeTokenCountPrompt",args:null,kind:"ScalarField",name:"tokenCountPrompt",storageKey:null},{alias:"cumulativeTokenCountCompletion",args:null,kind:"ScalarField",name:"tokenCountCompletion",storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"input",plural:!1,selections:p,storageKey:null},{alias:null,args:null,concreteType:"SpanIOValue",kind:"LinkedField",name:"output",plural:!1,selections:p,storageKey:null},u,f,m],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Span",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},a],type:"Project",abstractKey:null}}();qt.hash="b8e7c42b9731568c7e348cf191017d06";const Ga=100;function Bt(n){const a=[];for(const l of n){const t={...l.span,children:Bt(l.children)};a.push(t)}return a}function ud(n){const a=g.useRef(null),[l,t]=g.useState({}),[i,r]=g.useState([]),[o,c]=g.useState(""),d=ne(),{fetchKey:u}=Tn(),{data:f,loadNext:m,hasNext:p,isLoadingNext:y,refetch:b}=_.usePaginationFragment(qt,n.project),S=Oe(E=>E.evaluationVisibility),h=g.useMemo(()=>Object.keys(S).filter(E=>S[E]),[S]),x=g.useMemo(()=>f.rootSpans.edges.map(({rootSpan:V})=>{const B=Fr([V,...V.descendants]),[De]=Bt(B);return De}),[f]),L=h.map(E=>({header:E,columns:[{header:"label",accessorKey:`${Pn}${Ie}label${Ie}${E}`,cell:({row:V})=>{const B=V.original.spanEvaluations.find(De=>De.name===E);return B?B.label:null}},{header:"score",accessorKey:`${Pn}${Ie}score${Ie}${E}`,cell:({row:V})=>{const B=V.original.spanEvaluations.find(De=>De.name===E);return B?B.score:null}}]})),I=[{header:"evaluations",accessorKey:"spanEvaluations",enableSorting:!1,cell:({row:E})=>{const V=E.original.spanEvaluations.length===0&&E.original.documentRetrievalMetrics.length===0;return s(k,{direction:"row",gap:"size-50",wrap:"wrap",children:[E.original.spanEvaluations.map(B=>e(Ma,{evaluation:B},B.name)),E.original.documentRetrievalMetrics.map(B=>s(g.Fragment,{children:[e(ce,{name:B.evaluationName,metric:"ndcg",score:B.ndcg},"ndcg"),e(ce,{name:B.evaluationName,metric:"precision",score:B.precision},"precision"),e(ce,{name:B.evaluationName,metric:"hit",score:B.hit},"hit")]},"doc-evals")),V?"--":null]})}},...L],C=[{id:"select",maxSize:10,header:({table:E})=>e($e,{checked:E.getIsAllRowsSelected(),indeterminate:E.getIsSomeRowsSelected(),onChange:E.getToggleAllRowsSelectedHandler()}),cell:({row:E})=>e($e,{checked:E.getIsSelected(),disabled:!E.getCanSelect(),indeterminate:E.getIsSomeSelected(),onChange:E.getToggleSelectedHandler()})},{header:()=>s(k,{gap:"size-50",direction:"row",alignItems:"center",children:[e(Aa,{isExpanded:z.getIsAllRowsExpanded(),onClick:z.getToggleAllRowsExpandedHandler(),"aria-label":"Expand all rows"}),"kind"]}),enableSorting:!1,accessorKey:"spanKind",maxSize:100,cell:E=>e("div",{css:F`
              // Since rows are flattened by default,
              // we can use the row.depth property
              // and paddingLeft to visually indicate the depth
              // of the row
              padding-left: ${E.row.depth*2}rem;
            `,children:s(k,{gap:"size-50",children:[E.row.getCanExpand()?e(Aa,{isExpanded:E.row.getIsExpanded(),onClick:E.row.getToggleExpandedHandler(),"aria-label":"Expand row"}):null,e(cl,{spanKind:E.getValue()})]})})},{header:"name",accessorKey:"name",enableSorting:!1,cell:({getValue:E,row:V})=>{const{spanId:B,traceId:De}=V.original.context;return e(xn,{to:`traces/${De}?selectedSpanId=${B}`,children:E()})}},{header:"input",accessorKey:"input.value",enableSorting:!1,cell:Se},{header:"output",accessorKey:"output.value",enableSorting:!1,cell:Se},{header:"metadata",accessorKey:"metadata",enableSorting:!1,cell:Se},...I,{header:"start time",accessorKey:"startTime",cell:Fn},{header:"latency",accessorKey:"latencyMs",cell:({getValue:E})=>{const V=E();return V===null||typeof V!="number"?null:e(Re,{latencyMs:V})}},{header:"total tokens",minSize:80,accessorKey:"cumulativeTokenCountTotal",cell:({row:E,getValue:V})=>{const B=V();return B===null?"--":e(tt,{tokenCountTotal:B,tokenCountPrompt:E.original.cumulativeTokenCountPrompt||0,tokenCountCompletion:E.original.cumulativeTokenCountCompletion||0})}},{header:"status",accessorKey:"statusCode",enableSorting:!1,cell:({getValue:E})=>e(Ta,{statusCode:E()})}];g.useEffect(()=>{const E=i[0];g.startTransition(()=>{b({sort:E?zt(E):Vt,after:null,first:Ga,filterCondition:o},{fetchPolicy:"store-and-network"})})},[i,b,o,u]);const v=Fe.useCallback(E=>{if(E){const{scrollHeight:V,scrollTop:B,clientHeight:De}=E;V-B-De<300&&!y&&p&&m(Ga)}},[p,y,m]),[T,P]=g.useState({}),R=Oe(E=>E.columnVisibility),z=he({columns:C,data:x,onExpandedChange:P,manualSorting:!0,getSubRows:E=>E.children,state:{sorting:i,expanded:T,columnVisibility:R,rowSelection:l},onRowSelectionChange:t,enableSubRowSelection:!1,onSortingChange:r,getCoreRowModel:ke(),getSortedRowModel:Mn(),getExpandedRowModel:$i(),getRowId:E=>E.id}),j=z.getRowModel().rows,U=z.getSelectedRowModel().flatRows,ie=U.map(E=>E.original),re=g.useCallback(()=>{t({})},[t]),w=j.length===0,$=z.getAllColumns().filter(E=>E.columns.length===0);return s("div",{css:$t,children:[e(D,{paddingTop:"size-100",paddingBottom:"size-100",paddingStart:"size-200",paddingEnd:"size-200",borderBottomColor:"grey-300",borderBottomWidth:"thin",flex:"none",children:s(k,{direction:"row",gap:"size-100",width:"100%",alignItems:"center",children:[e(Rt,{onValidCondition:c}),e(Ct,{columns:$,query:f})]})}),e("div",{css:F`
          flex: 1 1 auto;
          overflow: auto;
        `,onScroll:E=>v(E.target),ref:a,children:s("table",{css:vn,children:[e("thead",{children:z.getHeaderGroups().map(E=>e("tr",{children:E.headers.map(V=>e("th",{colSpan:V.colSpan,children:V.isPlaceholder?null:s("div",{"data-sortable":V.column.getCanSort(),className:V.column.getCanSort()?"cursor-pointer":"",onClick:V.column.getToggleSortingHandler(),style:{left:V.getStart(),width:V.getSize()},children:[G(V.column.columnDef.header,V.getContext()),V.column.getIsSorted()?e(N,{className:"sort-icon",svg:V.column.getIsSorted()==="asc"?e(M.ArrowUpFilled,{}):e(M.ArrowDownFilled,{})}):null]})},V.id))},E.id))}),w?e(tn,{}):e("tbody",{children:j.map(E=>e("tr",{onClick:()=>d(`traces/${E.original.context.traceId}`),children:E.getVisibleCells().map(V=>e("td",{children:G(V.column.columnDef.cell,V.getContext())},V.id))},E.id))})]})}),U.length?e(Nt,{selectedSpans:ie,onClearSelection:re}):null]})}const md=F`
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  .ac-tabs {
    flex: 1 1 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    div[role="tablist"] {
      flex: none;
    }
    .ac-tabs__pane-container {
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      div[role="tabpanel"]:not([hidden]) {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        overflow: hidden;
      }
    }
  }
`;function zc(){const{projectId:n}=je(),{timeRange:a}=Xn();return e(g.Suspense,{fallback:e(pe,{}),children:e(gd,{projectId:n,timeRange:a})})}function gd({projectId:n,timeRange:a}){const l=g.useMemo(()=>({start:a.start.toISOString(),end:a.end.toISOString()}),[a]),t=_.useLazyLoadQuery(gt,{id:n,timeRange:l},{fetchPolicy:"store-and-network"});return s("main",{css:md,children:[e(Xo,{project:t.project,extra:s(k,{direction:"row",alignItems:"center",gap:"size-100",children:[e(cd,{project:t.project}),e(ul,{})]})}),s(fe,{children:[e(q,{name:"Traces",children:({isSelected:i})=>i&&e(g.Suspense,{children:e(ud,{project:t.project})})}),e(q,{name:"Spans",title:"Spans",children:({isSelected:i})=>i&&e(g.Suspense,{children:e(od,{project:t.project})})})]}),e(g.Suspense,{children:e(ve,{})})]})}const Ht=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={kind:"InlineFragment",selections:[{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null}],type:"Project",abstractKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"projectLoaderQuery",selections:[{alias:"project",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,t],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"projectLoaderQuery",selections:[{alias:"project",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},l,t],storageKey:null}]},params:{cacheID:"04c84b5bc2a01477851d347af75dcc11",id:null,metadata:{},name:"projectLoaderQuery",operationKind:"query",text:`query projectLoaderQuery(
  $id: GlobalID!
) {
  project: node(id: $id) {
    __typename
    id
    ... on Project {
      name
    }
  }
}
`}}}();Ht.hash="3d31e323c06df38ec2eaa6f3adb55e79";async function Ac(n){const{projectId:a}=n.params;return await _.fetchQuery(Ke,Ht,{id:a}).toPromise()}const pd=F`
  display: flex;
  direction: row;
  height: 100vh;
  overflow: hidden;
`,yd=F`
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  height: 100%;
  overflow: hidden;
  padding-left: var(--px-nav-collapsed-width);
`,fd=F`
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
`,hd=F`
  display: flex;
  flex-direction: column;
  margin: 0;
  list-style: none;
  gap: var(--ac-global-dimension-size-50);
  padding-inline-start: 0;
`,kd=F`
  display: flex;
  flex-direction: column;
  gap: var(--ac-global-dimension-size-50);
`;function Qc(){return s("div",{css:pd,"data-testid":"layout",children:[e(bd,{}),s("div",{css:yd,children:[e(Tr,{children:e(Kr,{})}),e("div",{"data-testid":"content",css:fd,children:e(g.Suspense,{fallback:e(pe,{}),children:e(ve,{})})})]})]})}function bd(){const n=g.useMemo(()=>window.Config.hasInferences,[]);return s(Er,{children:[e(Dr,{}),s(k,{direction:"column",justifyContent:"space-between",flex:"1 1 auto",children:[s("ul",{css:kd,children:[n&&e("li",{children:e(Hn,{to:"/model",text:"Model",icon:e(N,{svg:e(M.CubeOutline,{})})})}),e("li",{children:e(Hn,{to:"/projects",text:"Projects",icon:e(N,{svg:e(M.GridOutline,{})})})}),e("li",{children:e(Hn,{to:"/datasets",text:"Datasets",icon:e(N,{svg:e(M.DatabaseOutline,{})})})}),e("li",{children:e(Hn,{to:"/apis",text:"APIs",icon:e(N,{svg:e(M.Code,{})})})})]}),s("ul",{css:hd,children:[e("li",{children:e(Cr,{})}),e("li",{children:e(Ir,{})}),e("li",{children:e(Lr,{})})]})]})]})}function Oc(){const n=Vi(),a=g.useMemo(()=>n instanceof Error&&n.message==="Failed to fetch"?e(Sd,{}):e(vd,{error:n}),[n]);return e("main",{css:F`
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
      `,children:e("section",{css:F`
          width: 500px;
          /* Add spacing on the bottom so it gets pushed down */
          margin-top: 200px;
          display: flex;
          flex-direction: column;
        `,children:a})})}function Sd(){return s(W,{children:[s(k,{direction:"column",width:"100%",alignItems:"center",children:[e(Ea,{graphicKey:"not found"}),e("h1",{children:"Server disconnected"})]}),e("p",{children:"We are unable to reach the Phoenix server. Please ensure that Phoenix is running and try again."})]})}function vd({error:n}){return s(W,{children:[s(k,{direction:"column",width:"100%",alignItems:"center",children:[e(Ea,{graphicKey:"error"}),e("h1",{children:"Something went wrong"})]}),e("p",{children:"We strive to do our very best but 🐛 bugs happen. It would mean a lot to us if you could file a an issue. If you feel comfortable, please include the error details below in your issue. We will get back to you as soon as we can."}),e("p",{css:F`
          display: flex;
          flex-direction: row;
          justify-content: flex-end;
          gap: var(--px-spacing-med);
        `,children:s("span",{css:F`
            display: inline-flex;
            flex-direction: row;
            align-items: baseline;
            gap: 0.2em;
          `,children:["💙 the",e(Rn,{href:"mailto:phoenix-devs@arize.com",children:"phoenix team"})]})}),s("div",{css:F`
          display: flex;
          flex-direction: row;
          justify-content: flex-end;
          align-items: center;
          gap: var(--px-spacing-med);
        `,children:[e(Rn,{href:"https://github.com/Arize-ai/phoenix/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D",children:"file an issue with us"}),e(O,{variant:"primary",size:"compact",onClick:()=>{window.location.href="/"},children:"Return Home"})]}),s("details",{open:!0,children:[e("summary",{children:"error details"}),e("pre",{css:F`
            white-space: pre-wrap;
            overflow-wrap: break-word;
            overflow: hidden;
            overflow-y: auto;
            max-height: 500px;
          `,children:n instanceof Error?n.message:null})]})]})}const Gt=function(){var n=[{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"endTime",storageKey:null}],a=[{alias:null,args:null,concreteType:"Model",kind:"LinkedField",name:"model",plural:!1,selections:[{alias:null,args:null,concreteType:"Inferences",kind:"LinkedField",name:"primaryInferences",plural:!1,selections:n,storageKey:null},{alias:null,args:null,concreteType:"Inferences",kind:"LinkedField",name:"referenceInferences",plural:!1,selections:n,storageKey:null},{alias:null,args:null,concreteType:"Inferences",kind:"LinkedField",name:"corpusInferences",plural:!1,selections:n,storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:[],kind:"Fragment",metadata:null,name:"ModelRootQuery",selections:a,type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[],kind:"Operation",name:"ModelRootQuery",selections:a},params:{cacheID:"c3baccc5527002697b40a06eef432a4d",id:null,metadata:{},name:"ModelRootQuery",operationKind:"query",text:`query ModelRootQuery {
  model {
    primaryInferences {
      name
      startTime
      endTime
    }
    referenceInferences {
      name
      startTime
      endTime
    }
    corpusInferences {
      name
      startTime
      endTime
    }
  }
}
`}}}();Gt.hash="b73d8f3f532a0c6f88863f3c6dd5734f";const xd=Gt;function jc(){const n=_.useLazyLoadQuery(xd,{}),{model:{primaryInferences:a,referenceInferences:l,corpusInferences:t}}=n;return e(_r,{primaryInferences:a,referenceInferences:l??null,corpusInferences:t??null,children:e(Rr,{timeRangeBounds:{start:new Date(a.startTime),end:new Date(a.endTime)},children:e(ve,{})})})}function qc(){return e(Zo,{children:e(Ho,{children:e(ve,{})})})}function Bc(){return e(wr,{children:e(ve,{})})}const Wt=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"},{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],a=[{kind:"Variable",name:"after",variableName:"after"},{kind:"Variable",name:"first",variableName:"first"}],l={kind:"Variable",name:"timeRange",variableName:"timeRange"},t=[l];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ProjectsPageProjectsQuery",selections:[{args:a,kind:"FragmentSpread",name:"ProjectsPageProjectsFragment"}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ProjectsPageProjectsQuery",selections:[{alias:null,args:a,concreteType:"ProjectConnection",kind:"LinkedField",name:"projects",plural:!1,selections:[{alias:null,args:null,concreteType:"ProjectEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"project",args:null,concreteType:"Project",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"gradientStartColor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"gradientEndColor",storageKey:null},{alias:null,args:t,kind:"ScalarField",name:"traceCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"endTime",storageKey:null},{alias:"latencyMsP50",args:[{kind:"Literal",name:"probability",value:.5},l],kind:"ScalarField",name:"latencyMsQuantile",storageKey:null},{alias:null,args:t,kind:"ScalarField",name:"tokenCountTotal",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Project",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:a,filters:null,handle:"connection",key:"ProjectsPage_projects",kind:"LinkedHandle",name:"projects"}]},params:{cacheID:"dd65be0e4921fda8c7330e4b91d0d016",id:null,metadata:{},name:"ProjectsPageProjectsQuery",operationKind:"query",text:`query ProjectsPageProjectsQuery(
  $after: String = null
  $first: Int = 100
  $timeRange: TimeRange
) {
  ...ProjectsPageProjectsFragment_2HEEH6
}

fragment ProjectsPageProjectsFragment_2HEEH6 on Query {
  projects(first: $first, after: $after) {
    edges {
      project: node {
        id
        name
        gradientStartColor
        gradientEndColor
        traceCount(timeRange: $timeRange)
        endTime
        latencyMsP50: latencyMsQuantile(probability: 0.5, timeRange: $timeRange)
        tokenCountTotal(timeRange: $timeRange)
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
}
`}}}();Wt.hash="720b12837ec779f66a493b8c4f993cba";const Ut=function(){var n=["projects"],a={kind:"Variable",name:"timeRange",variableName:"timeRange"},l=[a];return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"},{kind:"RootArgument",name:"timeRange"}],kind:"Fragment",metadata:{connection:[{count:"first",cursor:"after",direction:"forward",path:n}],refetch:{connection:{forward:{count:"first",cursor:"after"},backward:null,path:n},fragmentPathInResult:[],operation:Wt}},name:"ProjectsPageProjectsFragment",selections:[{alias:"projects",args:null,concreteType:"ProjectConnection",kind:"LinkedField",name:"__ProjectsPage_projects_connection",plural:!1,selections:[{alias:null,args:null,concreteType:"ProjectEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"project",args:null,concreteType:"Project",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"gradientStartColor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"gradientEndColor",storageKey:null},{alias:null,args:l,kind:"ScalarField",name:"traceCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"endTime",storageKey:null},{alias:"latencyMsP50",args:[{kind:"Literal",name:"probability",value:.5},a],kind:"ScalarField",name:"latencyMsQuantile",storageKey:null},{alias:null,args:l,kind:"ScalarField",name:"tokenCountTotal",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Project",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null}],type:"Query",abstractKey:null}}();Ut.hash="720b12837ec779f66a493b8c4f993cba";const Jt=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"timeRange"}],a=[{kind:"Literal",name:"first",value:100}],l={kind:"Variable",name:"timeRange",variableName:"timeRange"},t=[l];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ProjectsPageQuery",selections:[{args:null,kind:"FragmentSpread",name:"ProjectsPageProjectsFragment"}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ProjectsPageQuery",selections:[{alias:null,args:a,concreteType:"ProjectConnection",kind:"LinkedField",name:"projects",plural:!1,selections:[{alias:null,args:null,concreteType:"ProjectEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"project",args:null,concreteType:"Project",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"gradientStartColor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"gradientEndColor",storageKey:null},{alias:null,args:t,kind:"ScalarField",name:"traceCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"endTime",storageKey:null},{alias:"latencyMsP50",args:[{kind:"Literal",name:"probability",value:.5},l],kind:"ScalarField",name:"latencyMsQuantile",storageKey:null},{alias:null,args:t,kind:"ScalarField",name:"tokenCountTotal",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Project",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:"projects(first:100)"},{alias:null,args:a,filters:null,handle:"connection",key:"ProjectsPage_projects",kind:"LinkedHandle",name:"projects"}]},params:{cacheID:"e510243be5e7bcef0561820e0515c779",id:null,metadata:{},name:"ProjectsPageQuery",operationKind:"query",text:`query ProjectsPageQuery(
  $timeRange: TimeRange!
) {
  ...ProjectsPageProjectsFragment
}

fragment ProjectsPageProjectsFragment on Query {
  projects(first: 100) {
    edges {
      project: node {
        id
        name
        gradientStartColor
        gradientEndColor
        traceCount(timeRange: $timeRange)
        endTime
        latencyMsP50: latencyMsQuantile(probability: 0.5, timeRange: $timeRange)
        tokenCountTotal(timeRange: $timeRange)
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
}
`}}}();Jt.hash="c28f5ced0b3ec4b3b8277d0aac29de2d";const Xt=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"input"}],a=[{alias:null,args:[{kind:"Variable",name:"input",variableName:"input"}],concreteType:"Query",kind:"LinkedField",name:"clearProject",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ProjectActionMenuClearMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ProjectActionMenuClearMutation",selections:a},params:{cacheID:"63319b4e42b499db2447817f1dc821fb",id:null,metadata:{},name:"ProjectActionMenuClearMutation",operationKind:"mutation",text:`mutation ProjectActionMenuClearMutation(
  $input: ClearProjectInput!
) {
  clearProject(input: $input) {
    __typename
  }
}
`}}}();Xt.hash="c43eec4d6b882468c611dd9ebf3b095e";const Zt=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"projectId"}],a=[{alias:null,args:[{kind:"Variable",name:"id",variableName:"projectId"}],concreteType:"Query",kind:"LinkedField",name:"deleteProject",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ProjectActionMenuDeleteMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ProjectActionMenuDeleteMutation",selections:a},params:{cacheID:"8b00ab3aaef4c5fb3de24f7295d38499",id:null,metadata:{},name:"ProjectActionMenuDeleteMutation",operationKind:"mutation",text:`mutation ProjectActionMenuDeleteMutation(
  $projectId: GlobalID!
) {
  deleteProject(id: $projectId) {
    __typename
  }
}
`}}}();Zt.hash="3bf82e90b3f2d3485b4efb954e30b2cf";const Yt=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"input"}],a=[{alias:null,args:[{kind:"Variable",name:"input",variableName:"input"}],concreteType:"Query",kind:"LinkedField",name:"clearProject",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"RemoveProjectDataFormMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"RemoveProjectDataFormMutation",selections:a},params:{cacheID:"1b27a3f7535c3f3943b0f2248d1505a6",id:null,metadata:{},name:"RemoveProjectDataFormMutation",operationKind:"mutation",text:`mutation RemoveProjectDataFormMutation(
  $input: ClearProjectInput!
) {
  clearProject(input: $input) {
    __typename
  }
}
`}}}();Yt.hash="212501fe2d6367ec1503bd7a00c1730f";const Fd=24*60*60*1e3,Kd=30*Fd;function Td(n){const{projectId:a}=n,l=g.useRef(null),[t,i]=_.useMutation(Yt),{control:r,handleSubmit:o,setError:c,formState:{isValid:d}}=$n({defaultValues:{endDate:new Date(Date.now()-Kd).toISOString().slice(0,16)}}),u=g.useCallback(f=>{const m=zi(f.endDate);if(!Ai(m))return c("endDate",{message:"Date is not in a valid format"});t({variables:{input:{id:a,endTime:new Date(m).toISOString()}},onCompleted:()=>{n.onComplete()},onError:p=>{alert("Failed to clear project traces: "+p)}})},[t,a,n,c]);return s("form",{onSubmit:o(u),ref:l,children:[s(D,{padding:"size-200",children:[e(K,{color:"danger",children:"You are about to remove all data before the following date. This cannot be undone."}),e(Y,{name:"endDate",control:r,rules:{required:"field is required"},render:({field:{name:f,onChange:m,onBlur:p,value:y},fieldState:{invalid:b,error:S}})=>e(Ne,{label:"End Date",type:"datetime-local",name:f,description:"The date up to which you want to remove data",errorMessage:S==null?void 0:S.message,validationState:b?"invalid":"valid",onChange:m,onBlur:p,defaultValue:y})})]}),e(D,{paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderTopColor:"light",borderTopWidth:"thin",children:e(k,{direction:"row",justifyContent:"end",children:e(O,{type:"submit",variant:"danger",isDisabled:!d,size:"compact",loading:i,onClick:()=>{var f;(f=l.current)==null||f.requestSubmit()},children:i?"Removing...":"Remove Data"})})})]})}function Dd({projectId:n,projectName:a,onProjectDelete:l,onProjectClear:t,onProjectRemoveData:i}){const[r,o]=g.useState(null),c=a!=="default",[d]=_.useMutation(Zt),[u]=_.useMutation(Xt),f=g.useCallback(()=>{g.startTransition(()=>{d({variables:{projectId:n}}),l()})},[d,n,l]),m=g.useCallback(()=>{g.startTransition(()=>{u({variables:{input:{id:n}},onCompleted:()=>{t()},onError:S=>{alert("Failed to clear project: "+S)}})})},[u,n,t]),p=g.useCallback(()=>{o(s(X,{size:"S",title:"Delete Project",children:[e(D,{padding:"size-200",children:e(K,{color:"danger",children:`Are you sure you want to delete project ${a}? This cannot be undone.`})}),e(D,{paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderTopColor:"light",borderTopWidth:"thin",children:e(k,{direction:"row",justifyContent:"end",children:e(O,{variant:"danger",onClick:()=>{f(),o(null)},children:"Delete Project"})})})]}))},[f,a]),y=g.useCallback(()=>{o(s(X,{size:"S",title:"Clear Project",children:[e(D,{padding:"size-200",children:e(K,{color:"danger",children:`Are you sure you want to clear project ${a}? All traces and evaluations for this project will be deleted. This cannot be undone.`})}),e(D,{paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderTopColor:"light",borderTopWidth:"thin",children:e(k,{direction:"row",justifyContent:"end",children:e(O,{variant:"danger",onClick:()=>{m(),o(null)},children:"Clear"})})})]}))},[m,a]),b=g.useCallback(()=>{o(e(X,{size:"M",title:"Remove Data",children:e(Td,{projectId:n,onComplete:()=>{i(),o(null)}})}))},[i,n]);return s("div",{onClick:S=>{S.preventDefault(),S.stopPropagation()},children:[s(rn,{buttonVariant:"quiet",align:"end",onAction:S=>{switch(S){case"deleteProject":return p();case"clearProject":return y();case"removeProjectData":return b()}},disabledKeys:c?[]:["deleteProject"],children:[e(H,{textValue:"Clear Traces",children:s(k,{direction:"row",gap:"size-75",justifyContent:"start",alignItems:"center",children:[e(N,{svg:e(M.Refresh,{})}),e(K,{children:"Clear Data"})]})},"clearProject"),e(H,{textValue:"Remove Data",children:s(k,{direction:"row",gap:"size-75",justifyContent:"start",alignItems:"center",children:[e(N,{svg:e(M.CloseCircleOutline,{})}),e(K,{children:"Remove Data"})]})},"removeProjectData"),c?e(H,{children:s(k,{direction:"row",gap:"size-75",justifyContent:"start",alignItems:"center",children:[e(N,{svg:e(M.TrashOutline,{})}),e(K,{children:"Delete"})]})},"deleteProject"):null]}),e(ae,{type:"modal",isDismissable:!0,onDismiss:()=>o(null),children:r})]})}const Cd=1e4,Id=100;function Hc(){const{timeRange:n}=Xn();return e(g.Suspense,{fallback:e(pe,{}),children:e(Ld,{timeRange:n})})}function Ld({timeRange:n}){const[a,l]=jr(),t=g.useMemo(()=>({start:n.start.toISOString(),end:n.end.toISOString()}),[n]),i=_.useLazyLoadQuery(Jt,{timeRange:t}),{data:r,loadNext:o,hasNext:c,isLoadingNext:d,refetch:u}=_.usePaginationFragment(Ut,i),f=r.projects.edges.map(h=>h.project),m=g.useRef(null),p=g.useCallback(h=>{if(h){const{scrollHeight:x,scrollTop:L,clientHeight:I}=h;x-L-I<300&&!d&&c&&o(Id)}},[c,d,o]);Ot(()=>{g.startTransition(()=>{u({},{fetchPolicy:"store-and-network"})})},Cd);const y=g.useCallback(h=>{g.startTransition(()=>{u({},{fetchPolicy:"store-and-network"}),a({variant:"success",title:"Project Deleted",message:`Project ${h} has been deleted.`})})},[a,u]),b=g.useCallback(h=>{g.startTransition(()=>{u({},{fetchPolicy:"store-and-network"}),a({variant:"success",title:"Project Cleared",message:`Project ${h} has been cleared of traces.`})})},[a,u]),S=g.useCallback(h=>{g.startTransition(()=>{u({},{fetchPolicy:"store-and-network"}),a({variant:"success",title:"Project Data Removed",message:`Old data from project ${h} have been removed.`})})},[a,u]);return s("div",{css:F`
        flex: 1 1 auto;
        overflow-y: auto;
        overflow-x: hidden;
        padding-bottom: var(--ac-global-dimension-size-750);
      `,onScroll:h=>p(h.target),ref:m,children:[e(D,{paddingStart:"size-200",paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",width:"100%",borderBottomColor:"grey-200",borderBottomWidth:"thin",children:e(k,{direction:"row",justifyContent:"end",children:e(ul,{})})}),e(D,{padding:"size-200",width:"100%",children:e("ul",{css:F`
            display: flex;
            flex-direction: row;
            gap: var(--ac-global-dimension-size-200);
            flex-wrap: wrap;
          `,children:f.map(h=>e("li",{children:e(xn,{to:`/projects/${h.id}`,css:F`
                  text-decoration: none;
                `,children:e(Rd,{project:h,onProjectDelete:()=>y(h.name),onProjectClear:()=>b(h.name),onProjectRemoveData:()=>S(h.name)})})},h.id))})}),l]})}function Ed({gradientStartColor:n,gradientEndColor:a}){return e("div",{css:F`
        border-radius: 50%;
        width: 32px;
        height: 32px;
        background: linear-gradient(
          136.27deg,
          ${n} 14.03%,
          ${a} 84.38%
        );
        flex-shrink: 0;
      `})}function Rd({project:n,onProjectDelete:a,onProjectClear:l,onProjectRemoveData:t}){const{endTime:i,traceCount:r,tokenCountTotal:o,latencyMsP50:c,gradientStartColor:d,gradientEndColor:u}=n,f=g.useMemo(()=>i?`Last updated  ${Qi(new Date(i),new Date,{addSuffix:!0})}`:"No traces uploaded yet.",[i]);return s("div",{css:F`
        padding: var(--ac-global-dimension-size-200);
        border: 1px solid var(--ac-global-color-grey-400);
        background-color: var(--ac-global-color-grey-100);
        border-radius: var(--ac-global-rounding-medium);
        height: var(--ac-global-dimension-size-1250);
        width: var(--ac-global-dimension-size-3600);
        transition: border-color 0.2s;
        &:hover {
          border-color: var(--ac-global-color-primary);
        }
        display: flex;
        flex-direction: column;
        justify-content: space-between;
      `,children:[s(k,{direction:"row",justifyContent:"space-between",alignItems:"start",children:[s(k,{direction:"row",gap:"size-100",alignItems:"center",minWidth:0,children:[e(Ed,{gradientStartColor:d,gradientEndColor:u}),s(k,{direction:"column",minWidth:0,children:[e(oe,{level:2,css:F`
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              `,children:n.name}),e(K,{color:"text-700",textSize:"small",fontStyle:"italic",children:f})]})]}),e(Dd,{projectId:n.id,projectName:n.name,onProjectDelete:a,onProjectClear:l,onProjectRemoveData:t})]}),s(k,{direction:"row",justifyContent:"space-between",children:[s(k,{direction:"column",flex:"none",children:[e(K,{elementType:"h3",textSize:"medium",color:"text-700",children:"Total Traces"}),e(K,{textSize:"xlarge",children:nn(r)})]}),s(k,{direction:"column",flex:"none",children:[e(K,{elementType:"h3",textSize:"medium",color:"text-700",children:"Total Tokens"}),e(K,{textSize:"xlarge",children:nn(o)})]}),s(k,{direction:"column",flex:"none",children:[e(K,{elementType:"h3",textSize:"medium",color:"text-700",children:"Latency P50"}),c!=null?e(Re,{latencyMs:c,textSize:"xlarge"}):e(K,{textSize:"xlarge",children:"--"})]})]})]})}const ei=function(){var n=[{kind:"Literal",name:"first",value:100},{kind:"Literal",name:"sort",value:{col:"createdAt",dir:"desc"}}];return{fragment:{argumentDefinitions:[],kind:"Fragment",metadata:null,name:"DatasetsPageQuery",selections:[{args:null,kind:"FragmentSpread",name:"DatasetsTable_datasets"}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[],kind:"Operation",name:"DatasetsPageQuery",selections:[{alias:null,args:n,concreteType:"DatasetConnection",kind:"LinkedField",name:"datasets",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:null,args:null,concreteType:"Dataset",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"exampleCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"experimentCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:'datasets(first:100,sort:{"col":"createdAt","dir":"desc"})'},{alias:null,args:n,filters:["sort"],handle:"connection",key:"DatasetsTable_datasets",kind:"LinkedHandle",name:"datasets"}]},params:{cacheID:"d601b31a6b08ca286a660c02a5d47ed6",id:null,metadata:{},name:"DatasetsPageQuery",operationKind:"query",text:`query DatasetsPageQuery {
  ...DatasetsTable_datasets
}

fragment DatasetsTable_datasets on Query {
  datasets(first: 100, sort: {col: createdAt, dir: desc}) {
    edges {
      node {
        id
        name
        description
        createdAt
        exampleCount
        experimentCount
        __typename
      }
      cursor
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
}
`}}}();ei.hash="985853a7939f44c0cefdd1a91472c67e";function _d(n){const a=n.split(`
`);return a.length>0?a[0].split(",").map(l=>l.trim()):[]}function wd(n){const{onDatasetCreated:a,onDatasetCreateError:l}=n,[t,i]=g.useState([]),{control:r,handleSubmit:o,resetField:c,formState:{isDirty:d,isValid:u}}=$n({defaultValues:{name:"Dataset "+new Date().toISOString(),input_keys:[],output_keys:[],metadata_keys:[],description:"",metadata:{}}}),f=g.useCallback(m=>{const p=new FormData;return p.append("file",m.file[0]),p.append("name",m.name),p.append("description",m.description),p.append("metadata",JSON.stringify(m.metadata)),m.input_keys.forEach(y=>{p.append("input_keys[]",y)}),m.output_keys.forEach(y=>{p.append("output_keys[]",y)}),m.metadata_keys.forEach(y=>{p.append("metadata_keys[]",y)}),fetch("/v1/datasets/upload?sync=true",{method:"POST",body:p}).then(y=>{if(!y.ok)throw l(new Error(y.statusText||"Failed to create dataset"));return y.json()}).then(y=>{a({name:m.name,id:y.data.dataset_id})})},[l,a]);return s(_n,{onSubmit:o(f),children:[s("div",{css:F`
          padding: var(--ac-global-dimension-size-200);
          .ac-dropdown-button {
            width: 100%;
          }
        `,children:[e(Y,{name:"name",control:r,rules:{required:"field is required"},render:({field:{onChange:m,onBlur:p,value:y},fieldState:{invalid:b,error:S}})=>e(Ne,{label:"Dataset Name",description:"The name of the dataset",errorMessage:S==null?void 0:S.message,validationState:b?"invalid":"valid",onChange:m,onBlur:p,value:y.toString()})}),e(Y,{name:"description",control:r,render:({field:{onChange:m,onBlur:p,value:y},fieldState:{invalid:b,error:S}})=>e(_a,{label:"description",placeholder:"Description of the dataset",isRequired:!1,height:100,errorMessage:S==null?void 0:S.message,validationState:b?"invalid":"valid",onChange:m,onBlur:p,value:y.toString()})}),e(Y,{control:r,name:"file",rules:{required:"CSV file is required"},render:({field:{value:m,onChange:p,...y},fieldState:{invalid:b,error:S}})=>e(la,{label:"CSV file",validationState:b?"invalid":"valid",errorMessage:S==null?void 0:S.message,children:e("input",{...y,onChange:h=>{var L;p(h.target.files),c("input_keys"),c("output_keys"),c("metadata_keys");const x=(L=h.target.files)==null?void 0:L[0];if(x){const I=new FileReader;I.onload=function(C){if(!C.target)return;const v=C.target.result,T=_d(v);i(T)},I.readAsText(x)}},type:"file",id:"file",accept:".csv"})})}),e(Y,{name:"input_keys",control:r,rules:{required:"field is required"},render:({field:{value:m,onChange:p},fieldState:{invalid:y,error:b}})=>e(ga,{label:"input keys",validationState:y?"invalid":"valid",description:"the columns to use as input",columns:t,selectedColumns:m,onChange:p,errorMessage:b==null?void 0:b.message})}),e(Y,{name:"output_keys",control:r,render:({field:{value:m,onChange:p},fieldState:{invalid:y,error:b}})=>e(ga,{label:"output keys",validationState:y?"invalid":"valid",description:"the columns to use as output",columns:t,selectedColumns:m,onChange:p,errorMessage:b==null?void 0:b.message})}),e(Y,{name:"metadata_keys",control:r,render:({field:{value:m,onChange:p},fieldState:{invalid:y,error:b}})=>e(ga,{label:"metadata keys",validationState:y?"invalid":"valid",description:"the columns to use as metadata",columns:t,selectedColumns:m,onChange:p,errorMessage:b==null?void 0:b.message})})]}),e(D,{paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderTopColor:"light",borderTopWidth:"thin",children:e(k,{direction:"row",justifyContent:"end",children:e(O,{type:"submit",isDisabled:!u,variant:d?"primary":"default",size:"compact",loading:!1,children:"Create Dataset"})})})]})}function ga(n){const{columns:a,selectedColumns:l,onChange:t,label:i,validationState:r,description:o,errorMessage:c,...d}=n,u=a.length===0,f=g.useMemo(()=>u?"No columns to select":l.length>0?`${l.join(", ")}`:"No columns selected",[l,u]);return e(la,{label:i,isDisabled:u,validationState:r,description:o,errorMessage:c,children:e(Ra,{isDisabled:u,...d,menu:e(Yn,{selectionMode:"multiple",onSelectionChange:m=>{t(Array.from(m))},selectedKeys:new Set(l),children:a.map(m=>e(H,{children:m},m))}),triggerProps:{placement:"bottom end"},children:f})})}const ni=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"},{defaultValue:{col:"createdAt",dir:"desc"},kind:"LocalArgument",name:"sort"}],a=[{kind:"Variable",name:"after",variableName:"after"},{kind:"Variable",name:"first",variableName:"first"},{kind:"Variable",name:"sort",variableName:"sort"}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"DatasetsTableDatasetsQuery",selections:[{args:a,kind:"FragmentSpread",name:"DatasetsTable_datasets"}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"DatasetsTableDatasetsQuery",selections:[{alias:null,args:a,concreteType:"DatasetConnection",kind:"LinkedField",name:"datasets",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:null,args:null,concreteType:"Dataset",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"exampleCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"experimentCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:a,filters:["sort"],handle:"connection",key:"DatasetsTable_datasets",kind:"LinkedHandle",name:"datasets"}]},params:{cacheID:"563b248ababc0a0549a1e4dd039d9fc5",id:null,metadata:{},name:"DatasetsTableDatasetsQuery",operationKind:"query",text:`query DatasetsTableDatasetsQuery(
  $after: String = null
  $first: Int = 100
  $sort: DatasetSort = {col: createdAt, dir: desc}
) {
  ...DatasetsTable_datasets_dWkdd
}

fragment DatasetsTable_datasets_dWkdd on Query {
  datasets(first: $first, after: $after, sort: $sort) {
    edges {
      node {
        id
        name
        description
        createdAt
        exampleCount
        experimentCount
        __typename
      }
      cursor
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
}
`}}}();ni.hash="ead09294d86188dc9d76825bdef37fbf";const ai=function(){var n=["datasets"];return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"},{defaultValue:{col:"createdAt",dir:"desc"},kind:"LocalArgument",name:"sort"}],kind:"Fragment",metadata:{connection:[{count:"first",cursor:"after",direction:"forward",path:n}],refetch:{connection:{forward:{count:"first",cursor:"after"},backward:null,path:n},fragmentPathInResult:[],operation:ni}},name:"DatasetsTable_datasets",selections:[{alias:"datasets",args:[{kind:"Variable",name:"sort",variableName:"sort"}],concreteType:"DatasetConnection",kind:"LinkedField",name:"__DatasetsTable_datasets_connection",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:null,args:null,concreteType:"Dataset",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"exampleCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"experimentCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null}],type:"Query",abstractKey:null}}();ai.hash="ead09294d86188dc9d76825bdef37fbf";const li=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"datasetId"}],a=[{alias:null,args:[{fields:[{kind:"Variable",name:"datasetId",variableName:"datasetId"}],kind:"ObjectValue",name:"input"}],concreteType:"DatasetMutationPayload",kind:"LinkedField",name:"deleteDataset",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"DatasetActionMenuDeleteMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"DatasetActionMenuDeleteMutation",selections:a},params:{cacheID:"4749f861cca561a1178904c53c396e39",id:null,metadata:{},name:"DatasetActionMenuDeleteMutation",operationKind:"mutation",text:`mutation DatasetActionMenuDeleteMutation(
  $datasetId: GlobalID!
) {
  deleteDataset(input: {datasetId: $datasetId}) {
    __typename
  }
}
`}}}();li.hash="d98c682a2c908030c2f772209a4a25b8";function Pd(n){const{datasetId:a,datasetName:l,onDatasetDelete:t,onDatasetDeleteError:i}=n,[r,o]=g.useState(null),[c,d]=_.useMutation(li),u=g.useCallback(()=>{g.startTransition(()=>{c({variables:{datasetId:a},onCompleted:()=>{t()},onError:m=>{i(m)}})})},[c,a,t,i]),f=g.useCallback(()=>{o(s(X,{size:"S",title:"Delete Dataset",children:[e(D,{padding:"size-200",children:e(K,{color:"danger",children:`Are you sure you want to delete dataset ${l}? This will also delete all associated experiments and traces, and it cannot be undone.`})}),e(D,{paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderTopColor:"light",borderTopWidth:"thin",children:e(k,{direction:"row",justifyContent:"end",children:e(O,{variant:"danger",onClick:()=>{u(),o(null)},children:"Delete Dataset"})})})]}))},[u,l]);return s("div",{onClick:m=>{m.preventDefault(),m.stopPropagation()},children:[e(rn,{align:"end",buttonSize:"compact",isDisabled:d,onAction:m=>{switch(m){case"deleteDataset":f();break}},children:e(H,{children:s(k,{direction:"row",gap:"size-75",justifyContent:"start",alignItems:"center",children:[e(N,{svg:e(M.TrashOutline,{})}),e(K,{children:"Delete"})]})},"deleteDataset")}),e(ae,{type:"modal",isDismissable:!0,onDismiss:()=>o(null),children:r})]})}const Wa=100;function Md(n){const a=n.id;if(a!=="createdAt"&&a!=="name")throw new Error("Invalid sort column");return{col:a,dir:n.desc?"desc":"asc"}}function Nd(n){const[a,l]=g.useState([]),t=g.useRef(null),i=ne(),r=Me(),o=Qn(),{data:c,loadNext:d,hasNext:u,isLoadingNext:f,refetch:m}=_.usePaginationFragment(ai,n.query),p=g.useMemo(()=>c.datasets.edges.map(x=>x.node),[c]),y=Fe.useCallback(x=>{if(x){const{scrollHeight:L,scrollTop:I,clientHeight:C}=x;L-I-C<300&&!f&&u&&d(Wa)}},[u,f,d]),b=he({columns:[{header:"name",accessorKey:"name",cell:({row:x})=>{const I=x.original.experimentCount>0?`${x.original.id}/experiments`:`${x.original.id}/examples`;return e(xn,{to:I,children:x.original.name})}},{header:"description",accessorKey:"description",enableSorting:!1},{header:"created at",accessorKey:"createdAt",cell:Fn},{header:"example count",accessorKey:"exampleCount",enableSorting:!1,meta:{textAlign:"right"}},{header:"experiment count",accessorKey:"experimentCount",enableSorting:!1,meta:{textAlign:"right"}},{header:"",id:"actions",enableSorting:!1,size:10,cell:({row:x})=>e(Pd,{datasetId:x.original.id,datasetName:x.original.name,onDatasetDelete:()=>{r({title:"Dataset deleted",message:`${x.original.name} has been successfully deleted.`}),m({},{fetchPolicy:"store-and-network"})},onDatasetDeleteError:L=>{o({title:"Dataset deletion failed",message:L.message})}})}],data:p,state:{sorting:a},getCoreRowModel:ke(),getSortedRowModel:Mn(),onSortingChange:l,manualSorting:!0});g.useEffect(()=>{const x=a[0];g.startTransition(()=>{m({sort:x?Md(x):{col:"createdAt",dir:"desc"},after:null,first:Wa},{fetchPolicy:"store-and-network"})})},[a,m]);const S=b.getRowModel().rows,h=S.length===0;return e("div",{css:F`
        flex: 1 1 auto;
        overflow: auto;
      `,onScroll:x=>y(x.target),ref:t,children:s("table",{css:vn,children:[e("thead",{children:b.getHeaderGroups().map(x=>e("tr",{children:x.headers.map(L=>{var I;return e("th",{colSpan:L.colSpan,children:L.isPlaceholder?null:s("div",{className:L.column.getCanSort()?"cursor-pointer":"",onClick:L.column.getToggleSortingHandler(),style:{textAlign:(I=L.column.columnDef.meta)==null?void 0:I.textAlign},children:[G(L.column.columnDef.header,L.getContext()),L.column.getIsSorted()?e(N,{className:"sort-icon",svg:L.column.getIsSorted()==="asc"?e(M.ArrowUpFilled,{}):e(M.ArrowDownFilled,{})}):null]})},L.id)})},x.id))}),h?e(tn,{}):e("tbody",{children:S.map(x=>e("tr",{onClick:()=>{const I=x.original.experimentCount>0?`${x.original.id}/experiments`:`${x.original.id}/examples`;i(I)},children:x.getVisibleCells().map(L=>{var I;return e("td",{align:(I=L.column.columnDef.meta)==null?void 0:I.textAlign,children:G(L.column.columnDef.cell,L.getContext())},L.id)})},x.id))})]})})}function Gc(){return e(g.Suspense,{fallback:e(pe,{}),children:e($d,{})})}function $d(){const[n,a]=g.useState(0),l=_.useLazyLoadQuery(ei,{},{fetchKey:n}),t=g.useCallback(()=>{a(i=>i+1)},[a]);return s(k,{direction:"column",height:"100%",children:[e(D,{padding:"size-200",borderBottomWidth:"thin",borderBottomColor:"dark",flex:"none",children:s(k,{direction:"row",justifyContent:"space-between",children:[e(oe,{level:1,children:"Datasets"}),e(Vd,{onDatasetCreated:t})]})}),e(Nd,{query:l})]})}function Vd({onDatasetCreated:n}){const a=ne(),l=Me(),t=Qn(),[i,r]=g.useState(null),o=()=>{r(e(X,{size:"S",title:"New Dataset",children:e(Ka,{onDatasetCreated:d=>{l({title:"Dataset created",message:`${d.name} has been successfully created.`,action:{text:"Go to Dataset",onClick:()=>{a(`/datasets/${d.id}`)}}}),r(null),n()},onDatasetCreateError:d=>{t({title:"Dataset creation failed",message:d.message})}})}))},c=()=>{r(e(X,{size:"M",title:"New Dataset from CSV",children:e(wd,{onDatasetCreated:d=>{l({title:"Dataset created",message:`${d.name} has been successfully created.`,action:{text:"Go to Dataset",onClick:()=>{a(`/datasets/${d.id}`)}}}),r(null),n()},onDatasetCreateError:d=>{t({title:"Dataset creation failed",message:d.message})}})}))};return s(W,{children:[s(rn,{buttonText:"Create Dataset",align:"end",icon:e(N,{svg:e(M.DatabaseOutline,{})}),onAction:d=>{switch(d){case"newDataset":o();break;case"datasetFromCSV":c();break}},children:[e(H,{children:"New Dataset"},"newDataset"),e(H,{children:"Dataset from CSV"},"datasetFromCSV")]}),e(ae,{type:"modal",isDismissable:!0,onDismiss:()=>r(null),children:i})]})}const ti=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"datasetId"}],a=[{kind:"Variable",name:"id",variableName:"datasetId"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={kind:"InlineFragment",selections:[{alias:"latestVersions",args:[{kind:"Literal",name:"first",value:1},{kind:"Literal",name:"sort",value:{col:"createdAt",dir:"desc"}}],concreteType:"DatasetVersionConnection",kind:"LinkedField",name:"versions",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetVersionEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"version",args:null,concreteType:"DatasetVersion",kind:"LinkedField",name:"node",plural:!1,selections:[l,{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:'versions(first:1,sort:{"col":"createdAt","dir":"desc"})'}],type:"Dataset",abstractKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"datasetStore_latestVersionQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,t],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"datasetStore_latestVersionQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},l,t],storageKey:null}]},params:{cacheID:"d7075240e4dae8871997e57616c05302",id:null,metadata:{},name:"datasetStore_latestVersionQuery",operationKind:"query",text:`query datasetStore_latestVersionQuery(
  $datasetId: GlobalID!
) {
  dataset: node(id: $datasetId) {
    __typename
    id
    ... on Dataset {
      latestVersions: versions(first: 1, sort: {col: createdAt, dir: desc}) {
        edges {
          version: node {
            id
            description
            createdAt
          }
        }
      }
    }
  }
}
`}}}();ti.hash="a1349b92d8b0c745f5e8039c55b048c7";const zd=n=>{const a=(l,t)=>({...n,isRefreshingLatestVersion:!1,refreshLatestVersion:async()=>{const i=t();l({isRefreshingLatestVersion:!0});const r=await Ad({datasetId:i.datasetId});l({latestVersion:r,isRefreshingLatestVersion:!1})}});return Oi()(ji(a))};async function Ad({datasetId:n}){var i;const a=await _.fetchQuery(Ke,ti,{datasetId:n}).toPromise(),l=(i=a==null?void 0:a.dataset.latestVersions)==null?void 0:i.edges;return l&&l.length&&l[0].version||null}const ii=g.createContext(null);function Qd({children:n,...a}){const l=g.useRef();return l.current||(l.current=zd(a)),e(ii.Provider,{value:l.current,children:n})}function an(n,a){const l=g.useContext(ii);if(!l)throw new Error("Missing DatasetContext.Provider in the tree");return el(l,n,a)}const ri=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"input"}],a=[{alias:null,args:[{kind:"Variable",name:"input",variableName:"input"}],concreteType:"DatasetMutationPayload",kind:"LinkedField",name:"addExamplesToDataset",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"AddDatasetExampleDialogMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"AddDatasetExampleDialogMutation",selections:a},params:{cacheID:"718cf02ccb39b279132822bf503e51e6",id:null,metadata:{},name:"AddDatasetExampleDialogMutation",operationKind:"mutation",text:`mutation AddDatasetExampleDialogMutation(
  $input: AddExamplesToDatasetInput!
) {
  addExamplesToDataset(input: $input) {
    __typename
  }
}
`}}}();ri.hash="8d99470f590cd5d28701fa6e3c0330e6";const pa={backgroundColor:"light",borderColor:"light",collapsible:!0,bodyStyle:{padding:0}};function Od(n){const{datasetId:a,onCompleted:l}=n,[t,i]=g.useState(null),[r,o]=_.useMutation(ri),{control:c,setError:d,handleSubmit:u,formState:{isValid:f}}=$n({defaultValues:{input:"{}",output:"{}",metadata:"{}"}}),m=g.useCallback(p=>{if(i(null),!Ee(p==null?void 0:p.input))return d("input",{message:"Input must be a valid JSON object"});if(!Ee(p==null?void 0:p.output))return d("output",{message:"Output must be a valid JSON object"});if(!Ee(p==null?void 0:p.metadata))return d("metadata",{message:"Metadata must be a valid JSON object"});r({variables:{input:{datasetId:a,examples:[{input:JSON.parse(p.input),output:JSON.parse(p.output),metadata:JSON.parse(p.metadata)}],datasetVersionDescription:p.description}},onCompleted:()=>{l()},onError:y=>{i(y.message)}})},[r,a,d,l]);return s(X,{size:"L",title:"Add Example",children:[e("div",{css:F`
          overflow-y: auto;
          padding: var(--ac-global-dimension-size-400);
        `,children:e(k,{direction:"row",justifyContent:"center",children:e(D,{width:"900px",paddingStart:"auto",paddingEnd:"auto",children:s(k,{direction:"column",gap:"size-200",children:[t?e(ee,{variant:"danger",children:t}):null,e(Y,{control:c,name:"input",render:({field:{onChange:p,onBlur:y,value:b},fieldState:{invalid:S,error:h}})=>s(Q,{title:"Input",subTitle:"The input to the LLM, retriever, program, etc.",...pa,children:[S?e(ee,{variant:"danger",banner:!0,children:h==null?void 0:h.message}):null,e(Le,{value:b,onChange:p,onBlur:y})]})}),e(Y,{control:c,name:"output",render:({field:{onChange:p,onBlur:y,value:b},fieldState:{invalid:S,error:h}})=>s(Q,{title:"Output",subTitle:"The output of the LLM or program to be used as an expected output",...pa,backgroundColor:"green-100",borderColor:"green-700",children:[S?e(ee,{variant:"danger",banner:!0,children:h==null?void 0:h.message}):null,e(Le,{value:b,onChange:p,onBlur:y})]})}),e(Y,{control:c,name:"metadata",render:({field:{onChange:p,onBlur:y,value:b},fieldState:{invalid:S,error:h}})=>s(Q,{title:"Metadata",subTitle:"All data from the span to use during experimentation or evaluation",...pa,children:[S?e(ee,{variant:"danger",banner:!0,children:h==null?void 0:h.message}):null,e(Le,{value:b,onChange:p,onBlur:y})]})}),e(Y,{control:c,name:"description",render:({field:{onChange:p,onBlur:y,value:b},fieldState:{invalid:S,error:h}})=>e(_a,{label:"Version Description",value:b,onChange:p,onBlur:y,errorMessage:h==null?void 0:h.message,validationState:S?"invalid":"valid",placeholder:"A description of the changes made. Will be displayed in the version history.",height:100})})]})})})}),e(D,{padding:"size-200",borderTopColor:"light",borderTopWidth:"thin",children:e(k,{direction:"row",justifyContent:"end",gap:"size-100",children:e(O,{variant:"primary",size:"compact",disabled:!f||o,loading:o,onClick:u(m),children:"Add Example"})})})]})}function jd(n){const{datasetId:a,onAddExampleCompleted:l}=n,[t,i]=g.useState(null),r=g.useCallback(()=>{i(e(Od,{datasetId:a,onCompleted:()=>{l(),i(null)}}))},[a,l]);return s(W,{children:[e(O,{icon:e(N,{svg:e(M.PlusCircleOutline,{})}),size:"compact",variant:"default",onClick:r,children:"Add Example"}),e(ae,{isDismissable:!0,onDismiss:()=>{i(null)},children:t})]})}function qd(){const n=an(i=>i.datasetId),a=an(i=>i.latestVersion);let l=`${Pr}/v1/datasets/${n}/examples`;a&&(l+=`?version-id=${a.id}`);const t=g.useMemo(()=>`import phoenix as px
client = px.Client()
# Get the current dataset version
dataset = client.get_dataset(id="${n}"${a?`, version_id="${a.id}"`:""})`,[n,a]);return e("div",{css:F`
        button.ac-dropdown-button {
          min-width: 80px;
          .ac-dropdown-button__text {
            padding-right: 10px;
          }
        }
      `,children:s(Kn,{placement:"bottom right",children:[e(kl,{addonBefore:e(N,{svg:e(M.Code,{})}),children:"Code"}),e(Ia,{children:s("section",{css:F`
              width: 500px;
              .ac-field {
                flex: 1 1 auto;
              }
            `,children:[e(D,{padding:"size-200",children:s(_n,{children:[s(k,{direction:"row",gap:"size-100",alignItems:"end",children:[e(Ne,{label:"Dataset ID",isReadOnly:!0,value:n}),e(J,{text:n,size:"normal"})]}),s(k,{direction:"row",gap:"size-100",alignItems:"end",children:[e(Ne,{label:"Version ID",isReadOnly:!0,value:(a==null?void 0:a.id)||"No Versions",validationState:a?"valid":"invalid"}),e(J,{text:(a==null?void 0:a.id)||"No Versions",disabled:!a,size:"normal"})]})]})}),s(fe,{children:[e(q,{name:"Python",children:e(D,{margin:"size-200",borderColor:"light",borderWidth:"thin",borderRadius:"small",children:e(Ue,{value:t})})}),e(q,{name:"REST",children:e(D,{padding:"size-200",children:e(_n,{children:s(k,{direction:"row",gap:"size-100",alignItems:"end",children:[e(Ne,{label:"URL",isReadOnly:!0,value:l}),e(J,{text:l,size:"normal"})]})})})})]})]})})]})})}const si=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"datasetId"}],a=[{kind:"Variable",name:"id",variableName:"datasetId"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i=[{kind:"Literal",name:"first",value:100}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"DatasetHistoryDialogQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{kind:"InlineFragment",selections:[l,{args:null,kind:"FragmentSpread",name:"DatasetHistoryTable_versions"}],type:"Dataset",abstractKey:null}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"DatasetHistoryDialogQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[t,{kind:"TypeDiscriminator",abstractKey:"__isNode"},l,{kind:"InlineFragment",selections:[{alias:null,args:i,concreteType:"DatasetVersionConnection",kind:"LinkedField",name:"versions",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetVersionEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:null,args:null,concreteType:"DatasetVersion",kind:"LinkedField",name:"node",plural:!1,selections:[l,{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null},t],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:"versions(first:100)"},{alias:null,args:i,filters:null,handle:"connection",key:"DatasetHistoryTable_versions",kind:"LinkedHandle",name:"versions"}],type:"Dataset",abstractKey:null}],storageKey:null}]},params:{cacheID:"df94b4e72c0187fd0fd1c8416af19354",id:null,metadata:{},name:"DatasetHistoryDialogQuery",operationKind:"query",text:`query DatasetHistoryDialogQuery(
  $datasetId: GlobalID!
) {
  dataset: node(id: $datasetId) {
    __typename
    ... on Dataset {
      id
      ...DatasetHistoryTable_versions
    }
    __isNode: __typename
    id
  }
}

fragment DatasetHistoryTable_versions on Dataset {
  versions(first: 100) {
    edges {
      node {
        id
        description
        createdAt
        __typename
      }
      cursor
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();si.hash="7215c18bda690418c5ecbcb3131a288e";const oi=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"},{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l=[{kind:"Variable",name:"after",variableName:"after"},{kind:"Variable",name:"first",variableName:"first"}],t={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"DatasetHistoryTableVersionsQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:l,kind:"FragmentSpread",name:"DatasetHistoryTable_versions"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"DatasetHistoryTableVersionsQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[t,{kind:"TypeDiscriminator",abstractKey:"__isNode"},i,{kind:"InlineFragment",selections:[{alias:null,args:l,concreteType:"DatasetVersionConnection",kind:"LinkedField",name:"versions",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetVersionEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:null,args:null,concreteType:"DatasetVersion",kind:"LinkedField",name:"node",plural:!1,selections:[i,{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null},t],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:l,filters:null,handle:"connection",key:"DatasetHistoryTable_versions",kind:"LinkedHandle",name:"versions"}],type:"Dataset",abstractKey:null}],storageKey:null}]},params:{cacheID:"e8e3a05b4e86c8eaeea98172405fdc7e",id:null,metadata:{},name:"DatasetHistoryTableVersionsQuery",operationKind:"query",text:`query DatasetHistoryTableVersionsQuery(
  $after: String = null
  $first: Int = 100
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...DatasetHistoryTable_versions_2HEEH6
    __isNode: __typename
    id
  }
}

fragment DatasetHistoryTable_versions_2HEEH6 on Dataset {
  versions(first: $first, after: $after) {
    edges {
      node {
        id
        description
        createdAt
        __typename
      }
      cursor
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();oi.hash="37e453bc58759a1e89bc5862c460de6b";const di=function(){var n=["versions"],a={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null};return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"}],kind:"Fragment",metadata:{connection:[{count:"first",cursor:"after",direction:"forward",path:n}],refetch:{connection:{forward:{count:"first",cursor:"after"},backward:null,path:n},fragmentPathInResult:["node"],operation:oi,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"DatasetHistoryTable_versions",selections:[{alias:"versions",args:null,concreteType:"DatasetVersionConnection",kind:"LinkedField",name:"__DatasetHistoryTable_versions_connection",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetVersionEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:null,args:null,concreteType:"DatasetVersion",kind:"LinkedField",name:"node",plural:!1,selections:[a,{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},a],type:"Dataset",abstractKey:null}}();di.hash="37e453bc58759a1e89bc5862c460de6b";const Bd=100;function Hd(n){const a=g.useRef(null),{data:l,loadNext:t,hasNext:i,isLoadingNext:r}=_.usePaginationFragment(di,n.dataset),o=g.useMemo(()=>l.versions.edges.map(m=>m.node),[l]),c=Fe.useCallback(m=>{if(m){const{scrollHeight:p,scrollTop:y,clientHeight:b}=m;p-y-b<300&&!r&&i&&t(Bd)}},[i,r,t]),d=he({columns:[{header:"version ID",accessorKey:"id"},{header:"description",accessorKey:"description"},{header:"created at",accessorKey:"createdAt",cell:Fn}],data:o,getCoreRowModel:ke(),getSortedRowModel:Mn()}),u=d.getRowModel().rows,f=u.length===0;return e("div",{css:F`
        flex: 1 1 auto;
        overflow: auto;
      `,onScroll:m=>c(m.target),ref:a,children:s("table",{css:zn,children:[e("thead",{children:d.getHeaderGroups().map(m=>e("tr",{children:m.headers.map(p=>e("th",{colSpan:p.colSpan,children:p.isPlaceholder?null:s("div",{className:p.column.getCanSort()?"cursor-pointer":"",onClick:p.column.getToggleSortingHandler(),style:{left:p.getStart(),width:p.getSize()},children:[G(p.column.columnDef.header,p.getContext()),p.column.getIsSorted()?e(N,{className:"sort-icon",svg:p.column.getIsSorted()==="asc"?e(M.ArrowUpFilled,{}):e(M.ArrowDownFilled,{})}):null]})},p.id))},m.id))}),f?e(tn,{}):e("tbody",{children:u.map(m=>e("tr",{children:m.getVisibleCells().map(p=>e("td",{children:G(p.column.columnDef.cell,p.getContext())},p.id))},m.id))})]})})}function Gd(n){const{datasetId:a}=n,l=_.useLazyLoadQuery(si,{datasetId:a});return e(X,{size:"L",title:"Dataset History",children:e("div",{css:F`
          height: 500px;
        `,children:e(Hd,{dataset:l.dataset})})})}function Wd(n){const{datasetId:a}=n,[l,t]=g.useState(null);return s(W,{children:[s(ge,{children:[e(O,{variant:"default",icon:e(N,{svg:e(M.ClockOutline,{})}),"aria-label":"Version History",onClick:()=>{t(e(Gd,{datasetId:a}))}}),e(Xe,{children:"Dataset Version History"})]}),e(g.Suspense,{fallback:null,children:e(ae,{type:"modal",isDismissable:!0,onDismiss:()=>{t(null)},children:l})})]})}const Ud=`pip install arize-phoenix>=${window.Config.platformVersion}`,Jd=`import os
# Set the phoenix collector endpoint. Commonly http://localhost:6060 
os.environ["PHOENIX_COLLECTOR_ENDPOINT"] = "<your-phoenix-url>"`,Xd=`from phoenix.experiments import Example
# Define your task
# Typically should be an LLM call or a call to your application
def my_task(example: Example) -> str:
    # This is just an example of how to return a JSON serializable value
    return f"Hello {example.input["person"]}"`,Zd=`# Define an evaluator. This just an example.
def exact_match(input, output) -> float:
    return 1.0 if output is f"Hello {input}" else 0.0

# Store the evaluators for later use
evaluators = [exact_match]`,Yd=`# Run an experiment
from phoenix.experiments import run_experiment

experiment = run_experiment(dataset, my_task, evaluators=evaluators)`;function ci(){const[n,a]=g.useState(null),l=g.useCallback(()=>{a(e(X,{title:"Run Experiment",size:"XL",children:e(ec,{})}))},[]);return s(W,{children:[e(O,{size:"compact",variant:"default",icon:e(N,{svg:e(M.ExperimentOutline,{})}),onClick:l,children:"Run Experiment"}),e(ae,{isDismissable:!0,type:"slideOver",onDismiss:()=>{a(null)},children:n})]})}function ec(){const n=an(t=>t.datasetName),a=an(t=>t.latestVersion),l=g.useMemo(()=>`import phoenix as px
# Initialize a phoenix client
client = px.Client()
# Get the current dataset version. You can omit the version for the latest.
dataset = client.get_dataset(name="${n}"${a?`, version_id="${a.id}"`:""})`,[n,a]);return s(D,{padding:"size-400",overflow:"auto",children:[e(D,{paddingBottom:"size-100",children:e(K,{children:"Install Phoenix"})}),e(cn,{children:e(Ue,{value:Ud})}),e(D,{paddingTop:"size-100",paddingBottom:"size-100",children:e(K,{children:"Point to a running instance of Phoenix"})}),e(cn,{children:e(Ue,{value:Jd})}),e(D,{paddingTop:"size-100",paddingBottom:"size-100",children:e(K,{children:"Pull down this dataset"})}),e(cn,{children:e(Ue,{value:l})}),e(D,{paddingTop:"size-100",paddingBottom:"size-100",children:e(K,{children:"Define your task"})}),e(cn,{children:e(Ue,{value:Xd})}),e(D,{paddingTop:"size-100",paddingBottom:"size-100",children:e(K,{children:"Define evaluators"})}),e(cn,{children:e(Ue,{value:Zd})}),e(D,{paddingTop:"size-100",paddingBottom:"size-100",children:e(K,{children:"Run an experiment"})}),e(cn,{children:e(Ue,{value:Yd})})]})}function cn({children:n}){return e(D,{borderColor:"light",borderWidth:"thin",borderRadius:"small",children:n})}function Wc(){const n=Nn(),a=g.useMemo(()=>{const l=n.dataset.latestVersions;return l!=null&&l.edges&&l.edges.length?l.edges[0].version:null},[n]);return e(Qd,{datasetId:n.dataset.id,datasetName:n.dataset.name,latestVersion:a,children:e(g.Suspense,{fallback:e(pe,{}),children:e(ac,{dataset:n.dataset})})})}const nc=F`
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  .ac-tabs {
    flex: 1 1 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    div[role="tablist"] {
      flex: none;
    }
    .ac-tabs__pane-container {
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      div[role="tabpanel"]:not([hidden]) {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        overflow: hidden;
      }
    }
  }
`;function ac({dataset:n}){const a=n.id,l=an(d=>d.refreshLatestVersion),t=Me(),i=ne(),r=g.useCallback(d=>{d===0?i(`/datasets/${a}/experiments`):d===1&&i(`/datasets/${a}/examples`)},[i,a]),c=qi().pathname.includes("examples")?1:0;return s("main",{css:nc,children:[e(D,{paddingStart:"size-200",paddingEnd:"size-200",paddingTop:"size-200",paddingBottom:"size-50",flex:"none",children:s(k,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e(k,{direction:"column",justifyContent:"space-between",children:e(k,{direction:"row",gap:"size-200",alignItems:"center",children:s(k,{direction:"column",children:[e(K,{elementType:"h1",textSize:"xlarge",weight:"heavy",children:n.name}),e(K,{color:"text-700",children:n.description||"--"})]})})}),s(k,{direction:"row",gap:"size-100",children:[s(rn,{align:"end",icon:e(N,{svg:e(M.DownloadOutline,{})}),onAction:d=>{switch(d){case"csv":window.open(`/v1/datasets/${n.id}/csv`,"_blank");break;case"openai-ft":window.open(`/v1/datasets/${n.id}/jsonl/openai_ft`,"_blank");break;case"openai-evals":window.open(`/v1/datasets/${n.id}/jsonl/openai_evals`,"_blank");break}},children:[e(H,{children:"Download CSV"},"csv"),e(H,{children:"Download OpenAI Fine-Tuning JSONL"},"openai-ft"),e(H,{children:"Download OpenAI Evals JSONL"},"openai-evals")]}),e(Wd,{datasetId:n.id}),e(qd,{}),e(ci,{}),e(jd,{datasetId:n.id,onAddExampleCompleted:()=>{t({title:"Example added",message:"The example has been added successfully and the version has been updated."}),l()}})]})]})}),s(fe,{onChange:r,defaultIndex:c,children:[e(q,{name:"Experiments",extra:e(Ve,{children:n.experimentCount}),children:e(g.Suspense,{children:e(ve,{})})}),e(q,{name:"Examples",extra:e(Ve,{children:n.exampleCount}),children:e(g.Suspense,{children:e(ve,{})})})]})]})}const ui=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},i={kind:"InlineFragment",selections:[{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},t,{alias:null,args:null,kind:"ScalarField",name:"exampleCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"experimentCount",storageKey:null},{alias:"latestVersions",args:[{kind:"Literal",name:"first",value:1},{kind:"Literal",name:"sort",value:{col:"createdAt",dir:"desc"}}],concreteType:"DatasetVersionConnection",kind:"LinkedField",name:"versions",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetVersionEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"version",args:null,concreteType:"DatasetVersion",kind:"LinkedField",name:"node",plural:!1,selections:[l,t,{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:'versions(first:1,sort:{"col":"createdAt","dir":"desc"})'}],type:"Dataset",abstractKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"datasetLoaderQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,i],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"datasetLoaderQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},l,i],storageKey:null}]},params:{cacheID:"5b221627cf7e63f41fbec41027cc0951",id:null,metadata:{},name:"datasetLoaderQuery",operationKind:"query",text:`query datasetLoaderQuery(
  $id: GlobalID!
) {
  dataset: node(id: $id) {
    __typename
    id
    ... on Dataset {
      id
      name
      description
      exampleCount
      experimentCount
      latestVersions: versions(first: 1, sort: {col: createdAt, dir: desc}) {
        edges {
          version: node {
            id
            description
            createdAt
          }
        }
      }
    }
  }
}
`}}}();ui.hash="469da2debdebd608c88a6ef83c2540aa";async function Uc(n){const{datasetId:a}=n.params;return await _.fetchQuery(Ke,ui,{id:a}).toPromise()}const mi=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"exampleId"}],a=[{kind:"Variable",name:"id",variableName:"exampleId"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"output",storageKey:null},i={alias:"latestRevision",args:null,concreteType:"DatasetExampleRevision",kind:"LinkedField",name:"revision",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"input",storageKey:null},t,{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null}],storageKey:null},r={alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null},o={alias:null,args:null,concreteType:"Span",kind:"LinkedField",name:"span",plural:!1,selections:[{alias:null,args:null,concreteType:"SpanContext",kind:"LinkedField",name:"context",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"spanId",storageKey:null},r],storageKey:null},{alias:null,args:null,concreteType:"Project",kind:"LinkedField",name:"project",plural:!1,selections:[l],storageKey:null}],storageKey:null},c={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},d=[{kind:"Literal",name:"first",value:100}],u={alias:null,args:null,concreteType:"Trace",kind:"LinkedField",name:"trace",plural:!1,selections:[r,{alias:null,args:null,kind:"ScalarField",name:"projectId",storageKey:null}],storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ExampleDetailsDialogQuery",selections:[{alias:"example",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{kind:"InlineFragment",selections:[l,i,o],type:"DatasetExample",abstractKey:null},{args:null,kind:"FragmentSpread",name:"ExampleExperimentRunsTableFragment"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ExampleDetailsDialogQuery",selections:[{alias:"example",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[c,{kind:"TypeDiscriminator",abstractKey:"__isNode"},l,{kind:"InlineFragment",selections:[i,o,{alias:null,args:d,concreteType:"ExperimentRunConnection",kind:"LinkedField",name:"experimentRuns",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentRunEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"run",args:null,concreteType:"ExperimentRun",kind:"LinkedField",name:"node",plural:!1,selections:[l,{alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"endTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"error",storageKey:null},t,u,{alias:null,args:null,concreteType:"ExperimentRunAnnotationConnection",kind:"LinkedField",name:"annotations",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentRunAnnotationEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"annotation",args:null,concreteType:"ExperimentRunAnnotation",kind:"LinkedField",name:"node",plural:!1,selections:[l,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"explanation",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"annotatorKind",storageKey:null},u],storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"ExperimentRun",kind:"LinkedField",name:"node",plural:!1,selections:[c],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:"experimentRuns(first:100)"},{alias:null,args:d,filters:null,handle:"connection",key:"ExampleExperimentRunsTable_experimentRuns",kind:"LinkedHandle",name:"experimentRuns"}],type:"DatasetExample",abstractKey:null}],storageKey:null}]},params:{cacheID:"3a826f05abb4b9ae214c0d16ba70d8a1",id:null,metadata:{},name:"ExampleDetailsDialogQuery",operationKind:"query",text:`query ExampleDetailsDialogQuery(
  $exampleId: GlobalID!
) {
  example: node(id: $exampleId) {
    __typename
    ... on DatasetExample {
      id
      latestRevision: revision {
        input
        output
        metadata
      }
      span {
        context {
          spanId
          traceId
        }
        project {
          id
        }
      }
    }
    ...ExampleExperimentRunsTableFragment
    __isNode: __typename
    id
  }
}

fragment ExampleExperimentRunsTableFragment on DatasetExample {
  experimentRuns(first: 100) {
    edges {
      run: node {
        id
        startTime
        endTime
        error
        output
        trace {
          traceId
          projectId
        }
        annotations {
          edges {
            annotation: node {
              id
              name
              label
              score
              explanation
              annotatorKind
              trace {
                traceId
                projectId
              }
            }
          }
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();mi.hash="e0deec4a6716862bd003e56ea5c7c3ad";const gi=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"input"}],a=[{alias:null,args:[{kind:"Variable",name:"input",variableName:"input"}],concreteType:"DatasetMutationPayload",kind:"LinkedField",name:"patchDatasetExamples",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"EditExampleDialogMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"EditExampleDialogMutation",selections:a},params:{cacheID:"7217082d3d3796ecb60481d17133c351",id:null,metadata:{},name:"EditExampleDialogMutation",operationKind:"mutation",text:`mutation EditExampleDialogMutation(
  $input: PatchDatasetExamplesInput!
) {
  patchDatasetExamples(input: $input) {
    __typename
  }
}
`}}}();gi.hash="a5e0e601ed24ffaa37a99ba358f960d3";const ya={backgroundColor:"light",borderColor:"light",collapsible:!0,bodyStyle:{padding:0}};function lc(n){const{exampleId:a,onCompleted:l}=n,[t,i]=g.useState(null),[r,o]=_.useMutation(gi),{control:c,setError:d,handleSubmit:u,formState:{isValid:f}}=$n({defaultValues:n.currentRevision}),m=g.useCallback(p=>{if(i(null),!Ee(p==null?void 0:p.input))return d("input",{message:"Input must be a valid JSON object"});if(!Ee(p==null?void 0:p.output))return d("output",{message:"Output must be a valid JSON object"});if(!Ee(p==null?void 0:p.metadata))return d("metadata",{message:"Metadata must be a valid JSON object"});r({variables:{input:{patches:[{exampleId:a,input:JSON.parse(p.input),output:JSON.parse(p.output),metadata:JSON.parse(p.metadata)}],versionDescription:p.description}},onCompleted:()=>{l()},onError:y=>{i(y.message)}})},[r,a,d,l]);return e(X,{size:"fullscreen",title:`Edit Example: ${a}`,extra:e(O,{variant:"primary",size:"compact",disabled:!f||o,loading:o,onClick:u(m),children:"Save Changes"}),children:e("div",{css:F`
          overflow-y: auto;
          padding: var(--ac-global-dimension-size-400);
          /* Make widths configurable */
          .dataset-picker {
            width: 100%;
            .ac-dropdown--picker,
            .ac-dropdown-button {
              width: 100%;
            }
          }
        `,children:e(k,{direction:"row",justifyContent:"center",children:e(D,{width:"900px",paddingStart:"auto",paddingEnd:"auto",children:s(k,{direction:"column",gap:"size-200",children:[t?e(ee,{variant:"danger",children:t}):null,e(Y,{control:c,name:"input",render:({field:{onChange:p,onBlur:y,value:b},fieldState:{invalid:S,error:h}})=>s(Q,{title:"Input",subTitle:"The input to the LLM, retriever, program, etc.",...ya,children:[S?e(ee,{variant:"danger",banner:!0,children:h==null?void 0:h.message}):null,e(Le,{value:b,onChange:p,onBlur:y})]})}),e(Y,{control:c,name:"output",render:({field:{onChange:p,onBlur:y,value:b},fieldState:{invalid:S,error:h}})=>s(Q,{title:"Output",subTitle:"The output of the LLM or program to be used as an expected output",...ya,backgroundColor:"green-100",borderColor:"green-700",children:[S?e(ee,{variant:"danger",banner:!0,children:h==null?void 0:h.message}):null,e(Le,{value:b,onChange:p,onBlur:y})]})}),e(Y,{control:c,name:"metadata",render:({field:{onChange:p,onBlur:y,value:b},fieldState:{invalid:S,error:h}})=>s(Q,{title:"Metadata",subTitle:"All data from the span to use during experimentation or evaluation",...ya,children:[S?e(ee,{variant:"danger",banner:!0,children:h==null?void 0:h.message}):null,e(Le,{value:b,onChange:p,onBlur:y})]})}),e(Y,{control:c,name:"description",render:({field:{onChange:p,onBlur:y,value:b},fieldState:{invalid:S,error:h}})=>e(_a,{label:"Revision Description",value:b,onChange:p,onBlur:y,errorMessage:h==null?void 0:h.message,validationState:S?"invalid":"valid",placeholder:"A description of the changes made in this revision. Will be displayed in the version history.",height:100})})]})})})})})}function tc(n){const{onCompleted:a,...l}=n,[t,i]=g.useState(null);return s(W,{children:[e(O,{variant:"default",size:"compact",icon:e(N,{svg:e(M.EditOutline,{})}),onClick:()=>i(e(lc,{...l,onCompleted:()=>{i(null),a()}})),children:"Edit Example"}),e(ae,{type:"slideOver",isDismissable:!0,onDismiss:()=>i(null),children:t})]})}const pi=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"},{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l=[{kind:"Variable",name:"after",variableName:"after"},{kind:"Variable",name:"first",variableName:"first"}],t={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},r={alias:null,args:null,concreteType:"Trace",kind:"LinkedField",name:"trace",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"projectId",storageKey:null}],storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ExampleExperimentRunsTableQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:l,kind:"FragmentSpread",name:"ExampleExperimentRunsTableFragment"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ExampleExperimentRunsTableQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[t,{kind:"TypeDiscriminator",abstractKey:"__isNode"},i,{kind:"InlineFragment",selections:[{alias:null,args:l,concreteType:"ExperimentRunConnection",kind:"LinkedField",name:"experimentRuns",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentRunEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"run",args:null,concreteType:"ExperimentRun",kind:"LinkedField",name:"node",plural:!1,selections:[i,{alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"endTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"error",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"output",storageKey:null},r,{alias:null,args:null,concreteType:"ExperimentRunAnnotationConnection",kind:"LinkedField",name:"annotations",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentRunAnnotationEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"annotation",args:null,concreteType:"ExperimentRunAnnotation",kind:"LinkedField",name:"node",plural:!1,selections:[i,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"explanation",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"annotatorKind",storageKey:null},r],storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"ExperimentRun",kind:"LinkedField",name:"node",plural:!1,selections:[t],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:l,filters:null,handle:"connection",key:"ExampleExperimentRunsTable_experimentRuns",kind:"LinkedHandle",name:"experimentRuns"}],type:"DatasetExample",abstractKey:null}],storageKey:null}]},params:{cacheID:"2ec7ead16e6df0877bc47db0ed7c7553",id:null,metadata:{},name:"ExampleExperimentRunsTableQuery",operationKind:"query",text:`query ExampleExperimentRunsTableQuery(
  $after: String = null
  $first: Int = 100
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...ExampleExperimentRunsTableFragment_2HEEH6
    __isNode: __typename
    id
  }
}

fragment ExampleExperimentRunsTableFragment_2HEEH6 on DatasetExample {
  experimentRuns(first: $first, after: $after) {
    edges {
      run: node {
        id
        startTime
        endTime
        error
        output
        trace {
          traceId
          projectId
        }
        annotations {
          edges {
            annotation: node {
              id
              name
              label
              score
              explanation
              annotatorKind
              trace {
                traceId
                projectId
              }
            }
          }
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();pi.hash="6ca0f938b309407e8c184a1c13d1c52d";const yi=function(){var n=["experimentRuns"],a={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},l={alias:null,args:null,concreteType:"Trace",kind:"LinkedField",name:"trace",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"projectId",storageKey:null}],storageKey:null};return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"}],kind:"Fragment",metadata:{connection:[{count:"first",cursor:"after",direction:"forward",path:n}],refetch:{connection:{forward:{count:"first",cursor:"after"},backward:null,path:n},fragmentPathInResult:["node"],operation:pi,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"ExampleExperimentRunsTableFragment",selections:[{alias:"experimentRuns",args:null,concreteType:"ExperimentRunConnection",kind:"LinkedField",name:"__ExampleExperimentRunsTable_experimentRuns_connection",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentRunEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"run",args:null,concreteType:"ExperimentRun",kind:"LinkedField",name:"node",plural:!1,selections:[a,{alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"endTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"error",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"output",storageKey:null},l,{alias:null,args:null,concreteType:"ExperimentRunAnnotationConnection",kind:"LinkedField",name:"annotations",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentRunAnnotationEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"annotation",args:null,concreteType:"ExperimentRunAnnotation",kind:"LinkedField",name:"node",plural:!1,selections:[a,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"explanation",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"annotatorKind",storageKey:null},l],storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"ExperimentRun",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},a],type:"DatasetExample",abstractKey:null}}();yi.hash="6ca0f938b309407e8c184a1c13d1c52d";const ic=100;function rc(){return e("tbody",{className:"is-empty",children:e("tr",{children:e("td",{colSpan:100,css:n=>F`
            text-align: center;
            padding: ${n.spacing.margin24}px ${n.spacing.margin24}px !important;
          `,children:"No experiments have been run for this example."})})})}function sc({example:n}){const a=g.useRef(null),l=ne(),{data:t,loadNext:i,hasNext:r,isLoadingNext:o}=_.usePaginationFragment(yi,n),c=g.useMemo(()=>t.experimentRuns.edges.map(y=>{let b=null;return y.run.startTime&&y.run.endTime&&(b=new Date(y.run.endTime).getTime()-new Date(y.run.startTime).getTime()),{...y.run,output:JSON.stringify(y.run.output),latencyMs:b}}),[t]),u=he({columns:[{header:"start time",accessorKey:"startTime",cell:Fn},{header:"output",accessorKey:"output",cell:y=>{var S;const b=(S=y.row.original)==null?void 0:S.error;return b!==null?e(K,{color:"danger",children:b}):e(Se,{...y})}},{header:"latency",accessorKey:"latencyMs",cell:({getValue:y})=>{const b=y();return b===null||typeof b!="number"?"--":e(Re,{latencyMs:b})}},{header:"evaluations",accessorKey:"annotations",cell:({row:y})=>e(k,{direction:"row",gap:"size-50",wrap:"wrap",children:y.original.annotations.edges.map((b,S)=>{const h=b.annotation;return e(Da,{annotation:h,onClick:()=>{h.trace&&l(`/projects/${h.trace.projectId}/traces/${h.trace.traceId}`)}},S)})})},{id:"actions",cell:({row:y})=>{const b=y.original.trace;if(b)return e(O,{variant:"default",size:"compact",icon:e(N,{svg:e(M.Trace,{})}),onClick:()=>{l(`/projects/${b.projectId}/traces/${b.traceId}`)},"aria-label":"view trace"})}}],data:c,getCoreRowModel:ke()}),f=u.getRowModel().rows,m=f.length===0,p=g.useCallback(y=>{if(y){const{scrollHeight:b,scrollTop:S,clientHeight:h}=y;b-S-h<300&&!o&&r&&i(ic)}},[r,o,i]);return e("div",{css:F`
        flex: 1 1 auto;
        overflow: auto;
      `,ref:a,onScroll:y=>p(y.target),children:s("table",{css:vn,children:[e("thead",{children:u.getHeaderGroups().map(y=>e("tr",{children:y.headers.map(b=>e("th",{children:e("div",{children:G(b.column.columnDef.header,b.getContext())})},b.id))},y.id))}),m?e(rc,{}):e("tbody",{children:f.map(y=>e("tr",{children:y.getVisibleCells().map(b=>e("td",{children:G(b.column.columnDef.cell,b.getContext())},b.id))},y.id))})]})})}function fi({exampleId:n,onDismiss:a}){const[l,t]=g.useState(0),i=_.useLazyLoadQuery(mi,{exampleId:n},{fetchKey:l,fetchPolicy:"store-and-network"}),r=g.useMemo(()=>{const p=i.example.latestRevision;return{input:JSON.stringify(p==null?void 0:p.input,null,2),output:JSON.stringify(p==null?void 0:p.output,null,2),metadata:JSON.stringify(p==null?void 0:p.metadata,null,2)}},[i]),o=g.useMemo(()=>{const p=i.example.span;return p?{spanId:p.context.spanId,traceId:p.context.traceId,projectId:p.project.id}:null},[i]),{input:c,output:d,metadata:u}=r,f=ne(),m=Me();return e(ae,{type:"slideOver",isDismissable:!0,onDismiss:a,children:e(X,{size:"XL",title:`Example: ${n}`,extra:s(k,{direction:"row",gap:"size-100",children:[o?e(O,{variant:"default",size:"compact",onClick:()=>{f(`/projects/${o.projectId}/traces/${o.traceId}?selectedSpanId=${o.spanId}`)},children:"View Source Span"}):null,e(tc,{exampleId:n,currentRevision:r,onCompleted:()=>{m({title:"Example updated",message:`Example ${n} has been updated.`}),t(p=>p+1)}})]}),children:s(Ye,{direction:"vertical",autoSaveId:"example-panel-group",children:[e(se,{defaultSize:200,children:e("div",{css:F`
                overflow-y: auto;
                height: 100%;
              `,children:e(k,{direction:"row",justifyContent:"center",children:e(D,{width:"900px",paddingStart:"auto",paddingEnd:"auto",paddingTop:"size-200",paddingBottom:"size-200",children:s(k,{direction:"column",gap:"size-200",children:[e(Q,{title:"Input",...fa,extra:e(J,{text:c}),children:e(Je,{value:c})}),e(Q,{title:"Output",...fa,extra:e(J,{text:d}),children:e(Je,{value:d})}),e(Q,{title:"Metadata",...fa,extra:e(J,{text:u}),children:e(Je,{value:u})})]})})})})}),e(en,{css:Sn}),e(se,{defaultSize:100,children:s(k,{direction:"column",height:"100%",children:[e(D,{paddingStart:"size-200",paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderBottomColor:"dark",borderBottomWidth:"thin",flex:"none",children:e(oe,{level:3,children:"Experiment Runs"})}),e(sc,{example:i.example})]})})]})})})}const fa={backgroundColor:"light",borderColor:"light",variant:"compact",collapsible:!0,bodyStyle:{padding:0}};function Jc(){const{exampleId:n,datasetId:a}=je(),l=ne();return e(fi,{exampleId:n,onDismiss:()=>{l(`/datasets/${a}/examples`)}})}const hi=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i=[{kind:"Literal",name:"first",value:100}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"examplesLoaderQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,{args:null,kind:"FragmentSpread",name:"ExamplesTableFragment"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"examplesLoaderQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[t,l,{kind:"InlineFragment",selections:[{alias:null,args:i,concreteType:"DatasetExampleConnection",kind:"LinkedField",name:"examples",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetExampleEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"example",args:null,concreteType:"DatasetExample",kind:"LinkedField",name:"node",plural:!1,selections:[l,{alias:null,args:null,concreteType:"DatasetExampleRevision",kind:"LinkedField",name:"revision",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"input",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"output",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"DatasetExample",kind:"LinkedField",name:"node",plural:!1,selections:[t],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:"examples(first:100)"},{alias:null,args:i,filters:["datasetVersionId"],handle:"connection",key:"ExamplesTable_examples",kind:"LinkedHandle",name:"examples"}],type:"Dataset",abstractKey:null}],storageKey:null}]},params:{cacheID:"7e303fa9a3c09ccd6a3dc1f3dbb2afb3",id:null,metadata:{},name:"examplesLoaderQuery",operationKind:"query",text:`query examplesLoaderQuery(
  $id: GlobalID!
) {
  dataset: node(id: $id) {
    __typename
    id
    ...ExamplesTableFragment
  }
}

fragment ExamplesTableFragment on Dataset {
  examples(first: 100) {
    edges {
      example: node {
        id
        revision {
          input
          output
          metadata
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();hi.hash="6406bbf43a2e850b384ba9573d8e69de";async function Xc(n){const{datasetId:a}=n.params;return await _.fetchQuery(Ke,hi,{id:a}).toPromise()}const ki=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:null,kind:"LocalArgument",name:"datasetVersionId"},{defaultValue:100,kind:"LocalArgument",name:"first"},{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l=[{kind:"Variable",name:"after",variableName:"after"},{kind:"Variable",name:"datasetVersionId",variableName:"datasetVersionId"},{kind:"Variable",name:"first",variableName:"first"}],t={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ExamplesTableQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:l,kind:"FragmentSpread",name:"ExamplesTableFragment"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ExamplesTableQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[t,{kind:"TypeDiscriminator",abstractKey:"__isNode"},i,{kind:"InlineFragment",selections:[{alias:null,args:l,concreteType:"DatasetExampleConnection",kind:"LinkedField",name:"examples",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetExampleEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"example",args:null,concreteType:"DatasetExample",kind:"LinkedField",name:"node",plural:!1,selections:[i,{alias:null,args:null,concreteType:"DatasetExampleRevision",kind:"LinkedField",name:"revision",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"input",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"output",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"DatasetExample",kind:"LinkedField",name:"node",plural:!1,selections:[t],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:l,filters:["datasetVersionId"],handle:"connection",key:"ExamplesTable_examples",kind:"LinkedHandle",name:"examples"}],type:"Dataset",abstractKey:null}],storageKey:null}]},params:{cacheID:"ca59c018695d41ca01b5f9d453386886",id:null,metadata:{},name:"ExamplesTableQuery",operationKind:"query",text:`query ExamplesTableQuery(
  $after: String = null
  $datasetVersionId: GlobalID
  $first: Int = 100
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...ExamplesTableFragment_4a6F8Z
    __isNode: __typename
    id
  }
}

fragment ExamplesTableFragment_4a6F8Z on Dataset {
  examples(datasetVersionId: $datasetVersionId, first: $first, after: $after) {
    edges {
      example: node {
        id
        revision {
          input
          output
          metadata
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();ki.hash="e04e697cdb44ab2dd115f4562211f6a4";const bi=function(){var n=["examples"],a={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null};return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:null,kind:"LocalArgument",name:"datasetVersionId"},{defaultValue:100,kind:"LocalArgument",name:"first"}],kind:"Fragment",metadata:{connection:[{count:"first",cursor:"after",direction:"forward",path:n}],refetch:{connection:{forward:{count:"first",cursor:"after"},backward:null,path:n},fragmentPathInResult:["node"],operation:ki,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"ExamplesTableFragment",selections:[{alias:"examples",args:[{kind:"Variable",name:"datasetVersionId",variableName:"datasetVersionId"}],concreteType:"DatasetExampleConnection",kind:"LinkedField",name:"__ExamplesTable_examples_connection",plural:!1,selections:[{alias:null,args:null,concreteType:"DatasetExampleEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"example",args:null,concreteType:"DatasetExample",kind:"LinkedField",name:"node",plural:!1,selections:[a,{alias:null,args:null,concreteType:"DatasetExampleRevision",kind:"LinkedField",name:"revision",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"input",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"output",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"DatasetExample",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},a],type:"Dataset",abstractKey:null}}();bi.hash="e04e697cdb44ab2dd115f4562211f6a4";const Si=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"input"}],a=[{alias:null,args:[{kind:"Variable",name:"input",variableName:"input"}],concreteType:"DatasetMutationPayload",kind:"LinkedField",name:"deleteDatasetExamples",plural:!1,selections:[{alias:null,args:null,concreteType:"Dataset",kind:"LinkedField",name:"dataset",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null}],storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ExampleSelectionToolbarDeleteExamplesMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ExampleSelectionToolbarDeleteExamplesMutation",selections:a},params:{cacheID:"b63159f3c325b9af3dc469692f9329e5",id:null,metadata:{},name:"ExampleSelectionToolbarDeleteExamplesMutation",operationKind:"mutation",text:`mutation ExampleSelectionToolbarDeleteExamplesMutation(
  $input: DeleteDatasetExamplesInput!
) {
  deleteDatasetExamples(input: $input) {
    dataset {
      id
    }
  }
}
`}}}();Si.hash="455bf9e5dc4b9cc655095dc829ef7e12";function oc(n){const a=an(y=>y.refreshLatestVersion),{selectedExamples:l,onExamplesDeleted:t,onClearSelection:i}=n,[r,o]=g.useState(null),c=Me(),d=Qn(),[u,f]=_.useMutation(Si),m=l.length!==1,p=g.useCallback(()=>{u({variables:{input:{exampleIds:l.map(y=>y.id)}},onCompleted:()=>{c({title:"Examples Deleted",message:`${l.length} example${m?"s":""} have been deleted.`}),t(),i(),a()},onError:y=>{d({title:"An error occurred",message:`Failed to delete examples: ${y.message}`})}})},[u,l,c,m,t,i,a,d]);return s("div",{css:F`
        position: absolute;
        bottom: var(--ac-global-dimension-size-400);
        left: 50%;
        transform: translateX(-50%);
      `,children:[e(D,{backgroundColor:"light",padding:"size-200",borderColor:"light",borderWidth:"thin",borderRadius:"medium",minWidth:"size-6000",children:s(k,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e(K,{children:`${l.length} example${m?"s":""} selected`}),s(k,{direction:"row",gap:"size-100",children:[e(O,{variant:"default",size:"compact",onClick:i,children:"Cancel"}),e(O,{variant:"danger",size:"compact",icon:e(N,{svg:e(M.TrashOutline,{})}),loading:f,disabled:f,onClick:p,children:f?"Deleting...":"Delete Example"+(m?"s":"")})]})]})}),e(ae,{onDismiss:()=>{o(null)},children:r})]})}const dc=100;function cc({dataset:n}){const a=an(C=>C.latestVersion),l=g.useRef(null),[t,i]=Fe.useState({}),{data:r,loadNext:o,hasNext:c,isLoadingNext:d,refetch:u}=_.usePaginationFragment(bi,n);g.useEffect(()=>{g.startTransition(()=>{u({datasetVersionId:(a==null?void 0:a.id)||null},{fetchPolicy:"store-and-network"})})},[a,u]);const f=g.useMemo(()=>r.examples.edges.map(C=>{const v=C.example,T=v.revision;return{id:v.id,input:T.input,output:T.output,metadata:T.metadata}}),[r]),p=he({columns:[{id:"select",header:({table:C})=>e($e,{checked:C.getIsAllRowsSelected(),indeterminate:C.getIsSomeRowsSelected(),onChange:C.getToggleAllRowsSelectedHandler()}),cell:({row:C})=>e($e,{checked:C.getIsSelected(),disabled:!C.getCanSelect(),indeterminate:C.getIsSomeSelected(),onChange:C.getToggleSelectedHandler()})},{header:"example id",accessorKey:"id",cell:({getValue:C,row:v})=>{const T=v.original.id;return e(xn,{to:`${T}`,children:C()})}},{header:"input",accessorKey:"input",cell:En},{header:"output",accessorKey:"output",cell:En},{header:"metadata",accessorKey:"metadata",cell:En}],data:f,state:{rowSelection:t},onRowSelectionChange:i,getCoreRowModel:ke()}),y=p.getRowModel().rows,b=y.length===0,S=p.getSelectedRowModel().rows,h=S.map(C=>C.original),x=g.useCallback(()=>{i({})},[i]),L=g.useCallback(C=>{if(C){const{scrollHeight:v,scrollTop:T,clientHeight:P}=C;v-T-P<300&&!d&&c&&o(dc)}},[c,d,o]),I=ne();return s("div",{css:F`
        flex: 1 1 auto;
        overflow: auto;
      `,ref:l,onScroll:C=>L(C.target),children:[s("table",{css:vn,children:[e("thead",{children:p.getHeaderGroups().map(C=>e("tr",{children:C.headers.map(v=>e("th",{children:e("div",{children:G(v.column.columnDef.header,v.getContext())})},v.id))},C.id))}),b?e(tn,{}):e("tbody",{children:y.map(C=>e("tr",{onClick:()=>{I(`${C.original.id}`)},children:C.getVisibleCells().map(v=>e("td",{children:G(v.column.columnDef.cell,v.getContext())},v.id))},C.id))})]}),S.length?e(oc,{selectedExamples:h,onClearSelection:x,onExamplesDeleted:()=>{u({},{fetchPolicy:"store-and-network"})}}):null]})}function Zc(){const n=Nn();return s(W,{children:[e(cc,{dataset:n.dataset})," ",e(g.Suspense,{children:e(ve,{})})]})}const vi=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i={alias:null,args:null,kind:"ScalarField",name:"annotationName",storageKey:null},r=[{kind:"Literal",name:"first",value:100}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"experimentsLoaderQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,{kind:"InlineFragment",selections:[{args:null,kind:"FragmentSpread",name:"ExperimentsTableFragment"}],type:"Dataset",abstractKey:null}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"experimentsLoaderQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[t,l,{kind:"InlineFragment",selections:[{alias:null,args:null,concreteType:"ExperimentAnnotationSummary",kind:"LinkedField",name:"experimentAnnotationSummaries",plural:!0,selections:[i,{alias:null,args:null,kind:"ScalarField",name:"minScore",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"maxScore",storageKey:null}],storageKey:null},{alias:null,args:r,concreteType:"ExperimentConnection",kind:"LinkedField",name:"experiments",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"experiment",args:null,concreteType:"Experiment",kind:"LinkedField",name:"node",plural:!1,selections:[l,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"sequenceNumber",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"errorRate",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"runCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"averageRunLatencyMs",storageKey:null},{alias:null,args:null,concreteType:"Project",kind:"LinkedField",name:"project",plural:!1,selections:[l],storageKey:null},{alias:null,args:null,concreteType:"ExperimentAnnotationSummary",kind:"LinkedField",name:"annotationSummaries",plural:!0,selections:[i,{alias:null,args:null,kind:"ScalarField",name:"meanScore",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Experiment",kind:"LinkedField",name:"node",plural:!1,selections:[t],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:"experiments(first:100)"},{alias:null,args:r,filters:null,handle:"connection",key:"ExperimentsTable_experiments",kind:"LinkedHandle",name:"experiments"}],type:"Dataset",abstractKey:null}],storageKey:null}]},params:{cacheID:"91f92395f5df4858554b124deed3f47a",id:null,metadata:{},name:"experimentsLoaderQuery",operationKind:"query",text:`query experimentsLoaderQuery(
  $id: GlobalID!
) {
  dataset: node(id: $id) {
    __typename
    id
    ... on Dataset {
      ...ExperimentsTableFragment
    }
  }
}

fragment ExperimentsTableFragment on Dataset {
  experimentAnnotationSummaries {
    annotationName
    minScore
    maxScore
  }
  experiments(first: 100) {
    edges {
      experiment: node {
        id
        name
        sequenceNumber
        description
        createdAt
        metadata
        errorRate
        runCount
        averageRunLatencyMs
        project {
          id
        }
        annotationSummaries {
          annotationName
          meanScore
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();vi.hash="1461484d9e1232cbb99e1251edabbec3";async function Yc(n){const{datasetId:a}=n.params;return await _.fetchQuery(Ke,vi,{id:a}).toPromise()}const xi=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"},{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l=[{kind:"Variable",name:"after",variableName:"after"},{kind:"Variable",name:"first",variableName:"first"}],t={alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},i={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},r={alias:null,args:null,kind:"ScalarField",name:"annotationName",storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ExperimentsTableQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{args:l,kind:"FragmentSpread",name:"ExperimentsTableFragment"}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ExperimentsTableQuery",selections:[{alias:null,args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[t,{kind:"TypeDiscriminator",abstractKey:"__isNode"},i,{kind:"InlineFragment",selections:[{alias:null,args:null,concreteType:"ExperimentAnnotationSummary",kind:"LinkedField",name:"experimentAnnotationSummaries",plural:!0,selections:[r,{alias:null,args:null,kind:"ScalarField",name:"minScore",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"maxScore",storageKey:null}],storageKey:null},{alias:null,args:l,concreteType:"ExperimentConnection",kind:"LinkedField",name:"experiments",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"experiment",args:null,concreteType:"Experiment",kind:"LinkedField",name:"node",plural:!1,selections:[i,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"sequenceNumber",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"errorRate",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"runCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"averageRunLatencyMs",storageKey:null},{alias:null,args:null,concreteType:"Project",kind:"LinkedField",name:"project",plural:!1,selections:[i],storageKey:null},{alias:null,args:null,concreteType:"ExperimentAnnotationSummary",kind:"LinkedField",name:"annotationSummaries",plural:!0,selections:[r,{alias:null,args:null,kind:"ScalarField",name:"meanScore",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Experiment",kind:"LinkedField",name:"node",plural:!1,selections:[t],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:l,filters:null,handle:"connection",key:"ExperimentsTable_experiments",kind:"LinkedHandle",name:"experiments"}],type:"Dataset",abstractKey:null}],storageKey:null}]},params:{cacheID:"1db5ce5523fa9a472c91d093b0e6160e",id:null,metadata:{},name:"ExperimentsTableQuery",operationKind:"query",text:`query ExperimentsTableQuery(
  $after: String = null
  $first: Int = 100
  $id: GlobalID!
) {
  node(id: $id) {
    __typename
    ...ExperimentsTableFragment_2HEEH6
    __isNode: __typename
    id
  }
}

fragment ExperimentsTableFragment_2HEEH6 on Dataset {
  experimentAnnotationSummaries {
    annotationName
    minScore
    maxScore
  }
  experiments(first: $first, after: $after) {
    edges {
      experiment: node {
        id
        name
        sequenceNumber
        description
        createdAt
        metadata
        errorRate
        runCount
        averageRunLatencyMs
        project {
          id
        }
        annotationSummaries {
          annotationName
          meanScore
        }
      }
      cursor
      node {
        __typename
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
  id
}
`}}}();xi.hash="c7c7580fe40888ceb86a1701fe4eedf4";const Fi=function(){var n=["experiments"],a={alias:null,args:null,kind:"ScalarField",name:"annotationName",storageKey:null},l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null};return{argumentDefinitions:[{defaultValue:null,kind:"LocalArgument",name:"after"},{defaultValue:100,kind:"LocalArgument",name:"first"}],kind:"Fragment",metadata:{connection:[{count:"first",cursor:"after",direction:"forward",path:n}],refetch:{connection:{forward:{count:"first",cursor:"after"},backward:null,path:n},fragmentPathInResult:["node"],operation:xi,identifierInfo:{identifierField:"id",identifierQueryVariableName:"id"}}},name:"ExperimentsTableFragment",selections:[{alias:null,args:null,concreteType:"ExperimentAnnotationSummary",kind:"LinkedField",name:"experimentAnnotationSummaries",plural:!0,selections:[a,{alias:null,args:null,kind:"ScalarField",name:"minScore",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"maxScore",storageKey:null}],storageKey:null},{alias:"experiments",args:null,concreteType:"ExperimentConnection",kind:"LinkedField",name:"__ExperimentsTable_experiments_connection",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"experiment",args:null,concreteType:"Experiment",kind:"LinkedField",name:"node",plural:!1,selections:[l,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"sequenceNumber",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"description",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"metadata",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"errorRate",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"runCount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"averageRunLatencyMs",storageKey:null},{alias:null,args:null,concreteType:"Project",kind:"LinkedField",name:"project",plural:!1,selections:[l],storageKey:null},{alias:null,args:null,concreteType:"ExperimentAnnotationSummary",kind:"LinkedField",name:"annotationSummaries",plural:!0,selections:[a,{alias:null,args:null,kind:"ScalarField",name:"meanScore",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"cursor",storageKey:null},{alias:null,args:null,concreteType:"Experiment",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"PageInfo",kind:"LinkedField",name:"pageInfo",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"endCursor",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"hasNextPage",storageKey:null}],storageKey:null}],storageKey:null},l],type:"Dataset",abstractKey:null}}();Fi.hash="c7c7580fe40888ceb86a1701fe4eedf4";function uc({getValue:n}){const l=n()*100,t=g.useMemo(()=>l>=80?"red-1100":l>0?"orange-1100":"green-1100",[l]);return e(K,{color:t,children:ka(l)})}const Ki=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"input"}],a=[{alias:null,args:[{kind:"Variable",name:"input",variableName:"input"}],concreteType:"ExperimentMutationPayload",kind:"LinkedField",name:"deleteExperiments",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"ExperimentSelectionToolbarDeleteExperimentsMutation",selections:a,type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"ExperimentSelectionToolbarDeleteExperimentsMutation",selections:a},params:{cacheID:"3af24cbaf3208c0d5ad1cd9313dd3823",id:null,metadata:{},name:"ExperimentSelectionToolbarDeleteExperimentsMutation",operationKind:"mutation",text:`mutation ExperimentSelectionToolbarDeleteExperimentsMutation(
  $input: DeleteExperimentsInput!
) {
  deleteExperiments(input: $input) {
    __typename
  }
}
`}}}();Ki.hash="4ab310746eb51c6a3fcb799d2c972762";function mc(n){const a=ne(),[l,t]=g.useState(null),[i,r]=_.useMutation(Ki),{datasetId:o,selectedExperiments:c,onClearSelection:d,onExperimentsDeleted:u}=n,f=c.length!==1,m=Me(),p=Qn(),y=g.useCallback(()=>{i({variables:{input:{experimentIds:c.map(S=>S.id)}},onCompleted:()=>{m({title:"Examples Deleted",message:`${c.length} experiment${f?"s":""} have been deleted.`}),u(),d()},onError:S=>{p({title:"An error occurred",message:`Failed to delete examples: ${S.message}`})}})},[i,f,p,m,d,u,c]),b=g.useCallback(()=>{t(s(X,{size:"S",title:"Delete Experiments",children:[e(D,{padding:"size-200",children:e(K,{color:"danger",children:"Are you sure you want to delete these experiments? This will also delete all associated annotations and traces, and it cannot be undone."})}),e(D,{paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderTopColor:"light",borderTopWidth:"thin",children:e(k,{direction:"row",justifyContent:"end",children:e(O,{variant:"danger",onClick:()=>{y(),t(null)},children:"Delete Experiments"})})})]}))},[y]);return s("div",{css:F`
        position: absolute;
        bottom: var(--ac-global-dimension-size-400);
        left: 50%;
        transform: translateX(-50%);
      `,children:[e(D,{backgroundColor:"light",padding:"size-200",borderColor:"light",borderWidth:"thin",borderRadius:"medium",minWidth:"size-6000",children:s(k,{direction:"row",justifyContent:"space-between",alignItems:"center",gap:"size-100",children:[e(K,{children:`${c.length} experiment${f?"s":""} selected`}),s(k,{direction:"row",gap:"size-100",children:[e(O,{variant:"default",size:"compact",onClick:d,children:"Cancel"}),e(O,{variant:"danger",size:"compact",icon:e(N,{svg:e(M.TrashOutline,{})}),loading:r,disabled:r,onClick:b,children:r?"Deleting...":"Delete"}),e(O,{variant:"primary",size:"compact",onClick:()=>{a(`/datasets/${o}/compare?${c.map(S=>`experimentId=${S.id}`).join("&")}`)},icon:e(N,{svg:e(M.ArrowCompareOutline,{})}),children:"Compare Experiments"})]})]})}),e(ae,{onDismiss:()=>{t(null)},children:l})]})}const gc=100;function pc(){return e("tbody",{className:"is-empty",children:e("tr",{children:s("td",{colSpan:100,css:F`
            text-align: center;
            padding: var(--ac-global-dimension-size-400) !important;
            .ac-button {
              margin-top: var(--ac-global-dimension-size-200);
              margin-left: auto;
              margin-right: auto;
            }
          `,children:["No experiments for this dataset. To see how to run experiments on a dataset, check out the documentation.",e(ci,{})]})})})}function yc({dataset:n}){const a=g.useRef(null),[l,t]=g.useState({}),{data:i,loadNext:r,hasNext:o,isLoadingNext:c,refetch:d}=_.usePaginationFragment(Fi,n),u=g.useMemo(()=>i.experiments.edges.map(v=>{const T=v.experiment.annotationSummaries.reduce((P,R)=>(P[R.annotationName]=R,P),{});return{...v.experiment,annotationSummaryMap:T}}),[i]),f=[{id:"select",header:({table:v})=>e($e,{checked:v.getIsAllRowsSelected(),indeterminate:v.getIsSomeRowsSelected(),onChange:v.getToggleAllRowsSelectedHandler()}),cell:({row:v})=>e($e,{checked:v.getIsSelected(),disabled:!v.getCanSelect(),indeterminate:v.getIsSomeSelected(),onChange:v.getToggleSelectedHandler()})},{header:"name",accessorKey:"name",minSize:200,cell:({getValue:v,row:T})=>{const P=T.original.id,R=T.original.sequenceNumber;return s(k,{direction:"row",gap:"size-100",children:[e(Zn,{sequenceNumber:R}),e(xn,{to:`/datasets/${n.id}/compare?experimentId=${P}`,children:v()})]})}},{header:"description",accessorKey:"description",minSize:300,cell:Se},{header:"created at",accessorKey:"createdAt",cell:Fn}],m=i.experimentAnnotationSummaries.map(v=>{const{annotationName:T,minScore:P,maxScore:R}=v;return{header:()=>s(k,{direction:"row",gap:"size-100",wrap:!0,alignItems:"center",justifyContent:"end",children:[e(K,{children:T}),e(Mr,{annotationName:T})]}),id:`annotation-${T}`,meta:{textAlign:"right"},cell:({row:z})=>{const j=z.original.annotationSummaryMap[T];return!j||j.meanScore==null?e("span",{css:F`
                  float: right;
                `,children:"--"}):e(fc,{annotationName:T,value:j.meanScore,min:P,max:R})}}}),p=[{header:"run count",accessorKey:"runCount",meta:{textAlign:"right"},cell:$r},{header:"avg latency",accessorKey:"averageRunLatencyMs",meta:{textAlign:"right"},cell:({getValue:v})=>{const T=v();return T===null||typeof T!="number"?"--":e(Re,{latencyMs:T})}},{header:"error rate",accessorKey:"errorRate",meta:{textAlign:"right"},cell:uc},{header:"metadata",accessorKey:"metadata",minSize:200,cell:En},{id:"actions",cell:({row:v})=>{const T=v.original.project,P=v.original.metadata;return e(hc,{projectId:(T==null?void 0:T.id)||null,metadata:P})}}],y=he({columns:[...f,...m,...p],data:u,getCoreRowModel:ke(),state:{rowSelection:l},onRowSelectionChange:t}),b=y.getRowModel().rows,S=y.getSelectedRowModel().rows,h=S.map(v=>v.original),x=g.useCallback(()=>{t({})},[t]),L=b.length===0,I=g.useCallback(v=>{if(v){const{scrollHeight:T,scrollTop:P,clientHeight:R}=v;T-P-R<300&&!c&&o&&r(gc)}},[o,c,r]),C=ne();return s("div",{css:F`
        flex: 1 1 auto;
        overflow: auto;
        width: table.getTotalSize();
      `,ref:a,onScroll:v=>I(v.target),children:[s("table",{css:vn,children:[e("thead",{children:y.getHeaderGroups().map(v=>e("tr",{children:v.headers.map(T=>{var P,R;return e("th",{align:(R=(P=T.column.columnDef)==null?void 0:P.meta)==null?void 0:R.textAlign,children:e("div",{children:G(T.column.columnDef.header,T.getContext())})},T.id)})},v.id))}),L?e(pc,{}):e("tbody",{children:b.map(v=>e("tr",{onClick:()=>{C(`/datasets/${n.id}/compare?experimentId=${v.original.id}`)},children:v.getVisibleCells().map(T=>e("td",{children:G(T.column.columnDef.cell,T.getContext())},T.id))},v.id))})]}),S.length?e(mc,{datasetId:n.id,selectedExperiments:h,onClearSelection:x,onExperimentsDeleted:()=>{d({},{fetchPolicy:"store-and-network"})}}):null]})}function fc({annotationName:n,value:a,min:l,max:t}){const i=Nr(n),r=g.useMemo(()=>{const o=typeof l=="number"?l:0,c=typeof t=="number"?t:1;if(o===c&&c===a)return 100;const d=c-o||1;return(a-o)/d*100},[a,l,t]);return s(ge,{children:[e(ze,{children:s("div",{css:F`
            float: right;
            --mod-barloader-fill-color: ${i};
            display: flex;
            flex-direction: row;
            align-items: center;
            gap: var(--ac-global-dimension-size-100);
          `,children:[gn(a),e(qr,{width:"40px",value:r,"aria-label":"where the mean score lands between overall min max"})]})}),e(aa,{children:s(D,{width:"size-2400",children:[e(oe,{level:3,weight:"heavy",children:n}),s(k,{direction:"column",children:[s(k,{justifyContent:"space-between",children:[e(K,{weight:"heavy",textSize:"small",children:"Mean Score"}),e(K,{textSize:"small",children:gn(a)})]}),s(k,{justifyContent:"space-between",children:[e(K,{weight:"heavy",textSize:"small",children:"All Experiments Min"}),e(K,{textSize:"small",children:gn(l)})]}),s(k,{justifyContent:"space-between",children:[e(K,{weight:"heavy",textSize:"small",children:"All Experiments Max"}),e(K,{textSize:"small",children:gn(t)})]}),s(k,{justifyContent:"space-between",children:[e(K,{weight:"heavy",textSize:"small",children:"Mean Score Percentile"}),e(K,{textSize:"small",children:dl(r)})]})]})]})})]})}function hc(n){const{projectId:a}=n,l=ne(),[t,i]=g.useState(null);return s("div",{onClick:r=>{r.preventDefault(),r.stopPropagation()},children:[s(rn,{buttonSize:"compact",align:"end",disabledKeys:a?[]:["GO_TO_EXPERIMENT_RUN_TRACES"],onAction:r=>{switch(r){case"GO_TO_EXPERIMENT_RUN_TRACES":return l(`/projects/${a}`);case"VIEW_METADATA":{i(e(X,{title:"Metadata",onDismiss:()=>i(null),children:e(Je,{value:JSON.stringify(n.metadata,null,2)})}));break}default:me()}},children:[e(H,{children:s(k,{direction:"row",gap:"size-75",justifyContent:"start",alignItems:"center",children:[e(N,{svg:e(M.Trace,{})}),e(K,{children:"View run traces"})]})},"GO_TO_EXPERIMENT_RUN_TRACES"),e(H,{children:s(k,{direction:"row",gap:"size-75",justifyContent:"start",alignItems:"center",children:[e(N,{svg:e(M.InfoOutline,{})}),e(K,{children:"View Metadata"})]})},"VIEW_METADATA")]}),e(ae,{type:"modal",isDismissable:!0,onDismiss:()=>{i(null)},children:t})]})}function eu(){const n=Nn();return s(W,{children:[e(yc,{dataset:n.dataset}),e(g.Suspense,{children:e(ve,{})})]})}const Ti=function(){var n={defaultValue:null,kind:"LocalArgument",name:"datasetId"},a={defaultValue:null,kind:"LocalArgument",name:"experimentIds"},l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={alias:null,args:null,concreteType:"Trace",kind:"LinkedField",name:"trace",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"traceId",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"projectId",storageKey:null}],storageKey:null},i={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},r={alias:"comparisons",args:[{kind:"Variable",name:"experimentIds",variableName:"experimentIds"}],concreteType:"ExperimentComparison",kind:"LinkedField",name:"compareExperiments",plural:!0,selections:[{alias:null,args:null,concreteType:"DatasetExample",kind:"LinkedField",name:"example",plural:!1,selections:[l,{alias:null,args:null,concreteType:"DatasetExampleRevision",kind:"LinkedField",name:"revision",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"input",storageKey:null},{alias:"referenceOutput",args:null,kind:"ScalarField",name:"output",storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,concreteType:"RunComparisonItem",kind:"LinkedField",name:"runComparisonItems",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"experimentId",storageKey:null},{alias:null,args:null,concreteType:"ExperimentRun",kind:"LinkedField",name:"runs",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"output",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"error",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"startTime",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"endTime",storageKey:null},t,{alias:null,args:null,concreteType:"ExperimentRunAnnotationConnection",kind:"LinkedField",name:"annotations",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentRunAnnotationEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"annotation",args:null,concreteType:"ExperimentRunAnnotation",kind:"LinkedField",name:"node",plural:!1,selections:[l,i,{alias:null,args:null,kind:"ScalarField",name:"score",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"label",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"annotatorKind",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"explanation",storageKey:null},t],storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null},o=[{kind:"Variable",name:"id",variableName:"datasetId"}],c={kind:"InlineFragment",selections:[{alias:null,args:null,concreteType:"ExperimentConnection",kind:"LinkedField",name:"experiments",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"experiment",args:null,concreteType:"Experiment",kind:"LinkedField",name:"node",plural:!1,selections:[l,i,{alias:null,args:null,kind:"ScalarField",name:"sequenceNumber",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}],type:"Dataset",abstractKey:null};return{fragment:{argumentDefinitions:[n,a],kind:"Fragment",metadata:null,name:"ExperimentCompareTableQuery",selections:[r,{alias:"dataset",args:o,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,c],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[a,n],kind:"Operation",name:"ExperimentCompareTableQuery",selections:[r,{alias:"dataset",args:o,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},l,c],storageKey:null}]},params:{cacheID:"97e80c617426f75b81affa68e276b3d8",id:null,metadata:{},name:"ExperimentCompareTableQuery",operationKind:"query",text:`query ExperimentCompareTableQuery(
  $experimentIds: [GlobalID!]!
  $datasetId: GlobalID!
) {
  comparisons: compareExperiments(experimentIds: $experimentIds) {
    example {
      id
      revision {
        input
        referenceOutput: output
      }
    }
    runComparisonItems {
      experimentId
      runs {
        output
        error
        startTime
        endTime
        trace {
          traceId
          projectId
        }
        annotations {
          edges {
            annotation: node {
              id
              name
              score
              label
              annotatorKind
              explanation
              trace {
                traceId
                projectId
              }
            }
          }
        }
      }
    }
  }
  dataset: node(id: $datasetId) {
    __typename
    id
    ... on Dataset {
      experiments {
        edges {
          experiment: node {
            id
            name
            sequenceNumber
          }
        }
      }
    }
  }
}
`}}}();Ti.hash="e6132b301f6d80be7f5c5b0653e25178";const ha={backgroundColor:"light",borderColor:"light",variant:"compact",collapsible:!0,bodyStyle:{padding:0}},kc=F`
  flex: 1 1 auto;
  overflow: auto;
  // Make sure the table fills up the remaining space
  table {
    min-width: 100%;
    td {
      vertical-align: top;
    }
  }
`,Di=F`
  position: relative;
  min-height: 75px;
  .controls {
    transition: opacity 0.2s ease-in-out;
    opacity: 0;
    display: none;
    z-index: 1;
  }
  &:hover .controls {
    opacity: 1;
    display: flex;
    // make them stand out
    .ac-button {
      border-color: var(--ac-global-color-primary);
    }
  }
`,Ci=F`
  position: absolute;
  top: -23px;
  right: 0px;
  display: flex;
  flex-direction: row;
  gap: var(--ac-global-dimension-static-size-100);
`;function bc(n){const{datasetId:a,experimentIds:l,displayFullText:t}=n,i=_.useLazyLoadQuery(Ti,{experimentIds:l,datasetId:a}),r=g.useMemo(()=>{var h,x;return((x=(h=i.dataset)==null?void 0:h.experiments)==null?void 0:x.edges.reduce((L,I)=>(L[I.experiment.id]={...I.experiment},L),{}))||{}},[i]),o=g.useMemo(()=>i.comparisons.map(h=>{const x=h.runComparisonItems.reduce((L,I)=>(L[I.experimentId]=I,L),{});return{...h,id:h.example.id,input:h.example.revision.input,referenceOutput:h.example.revision.referenceOutput,runComparisonMap:x}}),[i]),[c,d]=g.useState(null),u=g.useMemo(()=>[{header:"input",accessorKey:"input",minWidth:500,cell:({row:h})=>s("div",{css:Di,children:[e(Na,{children:e(Ca,{json:h.original.input,disableTitle:!0,space:t?2:0})}),e("div",{className:"controls",css:Ci,children:s(ge,{children:[e(O,{variant:"default",size:"compact","aria-label":"View example details",icon:e(N,{svg:e(M.ExpandOutline,{})}),onClick:()=>{g.startTransition(()=>{d(e(g.Suspense,{children:e(fi,{exampleId:h.original.example.id,onDismiss:()=>{d(null)}})}))})}}),e(Xe,{children:"View Example"})]})})]})},{header:"reference output",accessorKey:"referenceOutput",minWidth:500,cell:t?Kc:En}],[t]),f=g.useMemo(()=>l.map(h=>({header:()=>{var I,C;const x=(I=r[h])==null?void 0:I.name,L=((C=r[h])==null?void 0:C.sequenceNumber)||0;return s(k,{direction:"row",gap:"size-100",wrap:!0,children:[e(Zn,{sequenceNumber:L}),e(K,{children:x})]})},accessorKey:h,minSize:500,cell:({row:x})=>{var z,j;const L=x.original.runComparisonMap[h],I=(L==null?void 0:L.runs.length)||0;if(I===0)return e(Ua,{});if(I>1)return e(K,{color:"warning",children:`${I} runs`});const C=L==null?void 0:L.runs[0];let v=null;const T=(z=C==null?void 0:C.trace)==null?void 0:z.traceId,P=(j=C==null?void 0:C.trace)==null?void 0:j.projectId;T&&P&&(v=s(ge,{children:[e(O,{variant:"default",className:"trace-button",size:"compact","aria-label":"View run trace",icon:e(N,{svg:e(M.Trace,{})}),onClick:U=>{U.preventDefault(),U.stopPropagation(),g.startTransition(()=>{d(e(Ri,{traceId:T,projectId:P,title:"Experiment Run Trace"}))})}}),e(Xe,{children:"View Trace"})]}));const R=s(W,{children:[s(ge,{children:[e(O,{variant:"default",className:"expand-button",size:"compact","aria-label":"View example run details",icon:e(N,{svg:e(M.ExpandOutline,{})}),onClick:U=>{U.preventDefault(),U.stopPropagation(),g.startTransition(()=>{d(e(Tc,{selectedExample:x.original,datasetId:a,experimentInfoById:r}))})}}),e(Xe,{children:"View run details"})]}),v]});return C?e(Fc,{controls:R,children:e(xc,{...C,displayFullText:t,setDialog:d})}):e(Ua,{})}})),[l,r,a,t]),m=g.useMemo(()=>[...u,...f,{id:"tail",minSize:500}],[u,f]),p=he({columns:m,data:o,getCoreRowModel:ke(),columnResizeMode:"onChange"}),y=Fe.useMemo(()=>{const h=p.getFlatHeaders(),x={};for(let L=0;L<h.length;L++){const I=h[L];x[`--header-${I.id}-size`]=I.getSize(),x[`--col-${I.column.id}-size`]=I.column.getSize()}return x},[p.getState().columnSizingInfo,p.getState().columnSizing]),S=p.getRowModel().rows.length===0;return s("div",{css:kc,children:[s("table",{css:h=>F(zn(h),Vr),style:{...y,width:p.getTotalSize(),minWidth:"100%"},children:[e("thead",{children:p.getHeaderGroups().map(h=>e("tr",{children:h.headers.map(x=>s("th",{style:{width:`calc(var(--header-${x==null?void 0:x.id}-size) * 1px)`},children:[e("div",{children:G(x.column.columnDef.header,x.getContext())}),e("div",{onMouseDown:x.getResizeHandler(),onTouchStart:x.getResizeHandler(),className:`resizer ${x.column.getIsResizing()?"isResizing":""}`})]},x.id))},h.id))}),S?e(tn,{}):p.getState().columnSizingInfo.isResizingColumn?e(Sc,{table:p}):e(Ii,{table:p})]}),e(ae,{isDismissable:!0,type:"slideOver",onDismiss:()=>{d(null)},children:c})]})}function Ii({table:n}){return e("tbody",{children:n.getRowModel().rows.map(a=>e("tr",{children:a.getVisibleCells().map(l=>e("td",{style:{width:`calc(var(--col-${l.column.id}-size) * 1px)`},children:G(l.column.columnDef.cell,l.getContext())},l.id))},a.id))})}const Sc=Fe.memo(Ii,(n,a)=>n.table.options.data===a.table.options.data);function vc(n){const{datasetId:a,exampleId:l}=n,t=ne();return e("div",{onClick:i=>{i.preventDefault(),i.stopPropagation()},children:e(rn,{buttonSize:"compact",align:"end",onAction:i=>{switch(i){case"gotoExample":return t(`/datasets/${a}/examples/${l}`);default:me()}},children:e(H,{children:s(k,{direction:"row",gap:"size-75",justifyContent:"start",alignItems:"center",children:[e(N,{svg:e(M.ExternalLinkOutline,{})}),e(K,{children:"Go to example"})]})},"gotoExample")})})}function xc(n){const{output:a,error:l,startTime:t,endTime:i,annotations:r,displayFullText:o,setDialog:c}=n;if(l)return e(Li,{error:l});const d=r!=null&&r.edges.length?r.edges.map(u=>u.annotation):[];return s(k,{direction:"column",gap:"size-100",height:"100%",justifyContent:"space-between",children:[e(Na,{children:e(Ca,{json:a,disableTitle:!0,space:o?2:0})}),s("ul",{css:F`
          display: flex;
          flex-direction: row;
          gap: var(--ac-global-dimension-static-size-100);
          align-items: center;
          flex-wrap: wrap;
        `,children:[e("li",{children:e(Ei,{startTime:t,endTime:i})},"run-latency"),d.map(u=>e("li",{children:e(Da,{annotation:u,onClick:()=>{const f=u.trace;f&&g.startTransition(()=>{c(e(Ri,{traceId:f.traceId,projectId:f.projectId,title:`Evaluator Trace: ${u.name}`}))})}})},u.id))]})]})}function Fc(n){return s("div",{css:Di,children:[n.children,e("div",{css:Ci,className:"controls",children:n.controls})]})}function Li({error:n}){return s(k,{direction:"row",gap:"size-50",alignItems:"center",children:[e(N,{svg:e(M.AlertCircleOutline,{}),color:"danger"}),e(K,{color:"danger",children:n})]})}function Ei({startTime:n,endTime:a}){const l=g.useMemo(()=>{let t=null;return n&&a&&(t=new Date(a).getTime()-new Date(n).getTime()),t},[n,a]);return l===null?null:e(Re,{latencyMs:l})}function Ua(){return s(k,{direction:"row",gap:"size-50",children:[e(N,{svg:e(M.MinusCircleOutline,{}),color:"grey-800"}),e(K,{color:"text-700",children:"not run"})]})}function Kc({getValue:n}){const a=n();return e(Na,{children:e(Ca,{json:a,space:2})})}function Na({children:n}){return e("div",{css:F`
        max-height: 300px;
        overflow-y: auto;
      `,children:n})}function Tc({selectedExample:n,datasetId:a,experimentInfoById:l}){return e(X,{title:`Comparing Experiments for Example: ${n.id}`,size:"fullscreen",extra:e(vc,{datasetId:a,exampleId:n.id}),children:s(Ye,{direction:"vertical",autoSaveId:"example-compare-panel-group",children:[e(se,{defaultSize:100,children:e("div",{css:F`
              overflow-y: auto;
              height: 100%;
            `,children:e(D,{overflow:"hidden",padding:"size-200",children:s(k,{direction:"row",gap:"size-200",flex:"1 1 auto",children:[e(D,{width:"50%",children:e(Q,{title:"Input",...ha,bodyStyle:{padding:0,maxHeight:"300px",overflowY:"auto"},extra:e(J,{text:JSON.stringify(n.input)}),children:e(Je,{value:JSON.stringify(n.input,null,2)})})}),e(D,{width:"50%",children:e(Q,{title:"Reference Output",...ha,extra:e(J,{text:JSON.stringify(n.input)}),bodyStyle:{padding:0,maxHeight:"300px",overflowY:"auto"},children:e(Je,{value:JSON.stringify(n.referenceOutput,null,2)})})})]})})})}),e(en,{css:Sn}),e(se,{defaultSize:200,children:s(k,{direction:"column",height:"100%",children:[e(D,{paddingStart:"size-200",paddingEnd:"size-200",paddingTop:"size-100",paddingBottom:"size-100",borderBottomColor:"dark",borderBottomWidth:"thin",flex:"none",children:e(oe,{level:2,children:"Experiments"})}),e("div",{css:F`
                overflow-y: auto;
                height: 100%;
                padding: var(--ac-global-dimension-static-size-200);
              `,children:e("ul",{css:F`
                  display: flex;
                  flex-direction: column;
                  gap: var(--ac-global-dimension-static-size-200);
                `,children:n.runComparisonItems.map(t=>{const i=l[t.experimentId];return e("li",{children:e(Q,{...ha,title:i==null?void 0:i.name,titleExtra:e(Zn,{sequenceNumber:(i==null?void 0:i.sequenceNumber)||0}),children:e("ul",{children:t.runs.map((r,o)=>{var c;return e("li",{children:s(k,{direction:"row",children:[e(D,{flex:!0,children:r.error?e(D,{padding:"size-200",children:e(Li,{error:r.error})}):e(Je,{value:JSON.stringify(r.output,null,2)})}),s(un,{width:"size-3000",children:[e(Ei,{startTime:r.startTime,endTime:r.endTime}),e("ul",{css:F`
                                      margin-top: var(
                                        --ac-global-dimension-static-size-100
                                      );
                                      display: flex;
                                      flex-direction: column;
                                      justify-content: flex-start;
                                      align-items: flex-end;
                                      gap: var(
                                        --ac-global-dimension-static-size-100
                                      );
                                    `,children:(c=r.annotations)==null?void 0:c.edges.map(d=>e("li",{children:e(Da,{annotation:d.annotation})},d.annotation.id))})]})]})},o)})})})},t.experimentId)})})})]})})]})})}function Ri({traceId:n,projectId:a,title:l}){const t=ne();return e(X,{title:l,size:"fullscreen",extra:e(O,{variant:"default",onClick:()=>t(`/projects/${a}/traces/${n}`),children:"View Trace in Project"}),children:e(ct,{traceId:n,projectId:a})})}const _i={argumentDefinitions:[],kind:"Fragment",metadata:null,name:"ExperimentMultiSelector__experiments",selections:[{alias:null,args:null,concreteType:"ExperimentConnection",kind:"LinkedField",name:"experiments",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"experiment",args:null,concreteType:"Experiment",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"sequenceNumber",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}],type:"Dataset",abstractKey:null};_i.hash="1aa376b1e9425f49268ac231dc2c0412";function Dc(n){const{dataset:a,selectedExperimentIds:l,onChange:t,label:i,validationState:r,description:o,errorMessage:c,...d}=n,u=_.useFragment(_i,a),f=g.useMemo(()=>u.experiments.edges.map(y=>y.experiment),[u]),m=f.length===0,p=g.useMemo(()=>{if(m)return"No experiments";const y=l.length;return y>0?`${y} experiment${y>1?"s":""}`:"No experiments selected"},[l,m]);return e(la,{label:i,isDisabled:m,validationState:r,description:o,errorMessage:c,children:e(Ra,{isDisabled:m,...d,menu:e(Yn,{selectionMode:"multiple",onSelectionChange:y=>{t(Array.from(y))},selectedKeys:new Set(l),children:f.map(y=>e(H,{textValue:y.name,children:s(k,{direction:"column",gap:"size-50",children:[s(k,{direction:"row",gap:"size-100",children:[e(Zn,{sequenceNumber:y.sequenceNumber}),e(K,{children:y.name})]}),e(K,{textSize:"small",color:"text-700",children:new Date(y.createdAt).toLocaleString()})]})},y.id))}),triggerProps:{placement:"bottom start"},children:p})})}function nu(){const n=Nn(),[a,l]=g.useState(!1),[t,i]=Ya(),r=t.getAll("experimentId"),o=r.length>0;return s("main",{css:F`
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
      `,children:[e(D,{padding:"size-200",borderBottomColor:"dark",borderBottomWidth:"thin",flex:"none",children:s(k,{direction:"column",gap:"size-100",children:[e(oe,{level:1,children:"Compare Experiments"}),s(k,{direction:"row",justifyContent:"space-between",alignItems:"end",children:[e(Dc,{dataset:n.dataset,selectedExperimentIds:r,label:"experiments",onChange:c=>{g.startTransition(()=>{t.delete("experimentId"),c.forEach(d=>{t.append("experimentId",d)}),i(t)})}}),e(La,{onChange:c=>{l(c)},defaultSelected:!1,labelPlacement:"start",children:"Full Text"})]})]})}),o?e(g.Suspense,{fallback:e(pe,{}),children:e(bc,{datasetId:n.dataset.id,experimentIds:r,displayFullText:a})}):e(D,{padding:"size-200",children:e(ee,{variant:"info",title:"No Experiment Selected",children:"Please select one or more experiments."})})]})}const wi=function(){var n=[{defaultValue:null,kind:"LocalArgument",name:"id"}],a=[{kind:"Variable",name:"id",variableName:"id"}],l={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},t={alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null};return{fragment:{argumentDefinitions:n,kind:"Fragment",metadata:null,name:"experimentCompareLoaderQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[l,{kind:"InlineFragment",selections:[t,{args:null,kind:"FragmentSpread",name:"ExperimentMultiSelector__experiments"}],type:"Dataset",abstractKey:null}],storageKey:null}],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:n,kind:"Operation",name:"experimentCompareLoaderQuery",selections:[{alias:"dataset",args:a,concreteType:null,kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},l,{kind:"InlineFragment",selections:[t,{alias:null,args:null,concreteType:"ExperimentConnection",kind:"LinkedField",name:"experiments",plural:!1,selections:[{alias:null,args:null,concreteType:"ExperimentEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:"experiment",args:null,concreteType:"Experiment",kind:"LinkedField",name:"node",plural:!1,selections:[l,t,{alias:null,args:null,kind:"ScalarField",name:"sequenceNumber",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"createdAt",storageKey:null}],storageKey:null}],storageKey:null}],storageKey:null}],type:"Dataset",abstractKey:null}],storageKey:null}]},params:{cacheID:"7e89f99f940098a21985137aae870de7",id:null,metadata:{},name:"experimentCompareLoaderQuery",operationKind:"query",text:`query experimentCompareLoaderQuery(
  $id: GlobalID!
) {
  dataset: node(id: $id) {
    __typename
    id
    ... on Dataset {
      id
      name
      ...ExperimentMultiSelector__experiments
    }
  }
}

fragment ExperimentMultiSelector__experiments on Dataset {
  experiments {
    edges {
      experiment: node {
        id
        name
        sequenceNumber
        createdAt
      }
    }
  }
}
`}}}();wi.hash="fa02088830fd16688f0f2fba9a0009eb";async function au(n){const{datasetId:a}=n.params;return await _.fetchQuery(Ke,wi,{id:a}).toPromise()}const Ja=window.Config.basename,Xa={width:"100%",height:"100%",border:"none",backgroundColor:"white"};function lu(){return s("div",{css:F`
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        height: 100%;
        .ac-tabs {
          flex: 1 1 auto;
        }
        .ac-tabs__pane-container,
        .ac-tabs__pane-container > div {
          flex: 1 1 auto;
          height: 100%;
        }
      `,children:[e(ee,{variant:"info",banner:!0,icon:e(N,{svg:e(M.InfoFilled,{})}),children:"These APIs are under active development and are subject to change."}),s(fe,{children:[e(q,{name:"REST",children:({isSelected:n})=>n&&e("iframe",{src:`${Ja}/docs`,style:Xa})}),e(q,{name:"GraphQL",children:({isSelected:n})=>n&&e("iframe",{src:`${Ja}/graphql`,style:Xa})})]})]})}export{lu as A,Nc as D,Oc as E,Qc as L,jc as M,Bc as P,tt as T,wc as a,Pc as b,Hc as c,$c as d,Mc as e,qc as f,zc as g,_c as h,Vc as i,Gc as j,Uc as k,Wc as l,eu as m,Yc as n,Zc as o,Ac as p,Xc as q,Jc as r,au as s,nu as t,Yr as u};
