1import{b as M,j as e,B as m,H as A,T as t,a4 as w,F as P,g as F,a3 as se,I as ne,f as d,A as g,c as b,ae as j,bb as ue,bc as he,_ as te,C as pe,K as oe,J as xe,S as ge,Z as ae}from"./index-DN2b6gf5.js";import{r as i,L as O}from"./react-vendor-DRshJiK8.js";import{E as be}from"./ElnAccessGate-bTOJqp1j.js";import{d as le,r as je,e as fe,f as Se,h as ye,i as Ce}from"./elnRegistryClient-BiyHVXUN.js";import{a as G}from"./elnWorkspaceClient-CkS9XCxA.js";import{C as Q}from"./code-_Z-zDLl0.js";import{l as ke}from"./elnProjectsClient-DoOoaXdY.js";import{L as ze,a as we}from"./link-box-DmdZxI_T.js";import"./auth-Boit7xya.js";import"./PsnElnCrossLink-BAYXfIN_.js";import"./classroomPricingApi-yl3Ui8D1.js";import"./list-DmJqstiu.js";import"./CheckCircle-C0BmS915.js";const ve=["name","smiles","inchikey","cid"];function Pe({initialQuery:f="",initialKind:T="name",onAccept:D,helpText:K}){var N;const[u,J]=i.useState(T),[L,U]=i.useState(f),[S,$]=i.useState(!1),[h,y]=i.useState(null),[l,v]=i.useState(null),[C,R]=i.useState(""),[r,k]=i.useState(!0),[q,_]=i.useState(!0),H=M("gray.50","gray.700"),z=M("gray.600","gray.300"),o=i.useMemo(()=>(l==null?void 0:l.find(n=>n.cid===C))??null,[l,C]),c=(o==null?void 0:o.isomericSmiles)??(o==null?void 0:o.canonicalSmiles)??null,p=(o==null?void 0:o.iupacName)??((N=o==null?void 0:o.synonyms)==null?void 0:N[0])??null,I=async()=>{const n=L.trim();if(!n){y("Enter something to look up.");return}$(!0),y(null),v(null),R("");try{const a=await je(u,n);v(a.matches),a.matches.length===1&&R(a.matches[0].cid)}catch(a){y(a instanceof G?a.message:"PubChem could not be reached. Enter the values manually, or try again later.")}finally{$(!1)}},E=()=>{if(!o)return;const n=[],a={cid:o.cid,acceptedFields:n};r&&c&&(a.smiles=c,n.push("canonicalSmiles")),q&&p&&(a.preferredName=p,n.push("preferredName")),D(a)};return e.jsxs(m,{as:"section","aria-labelledby":"eln-pubchem-lookup-heading",bg:H,borderRadius:"md",p:4,children:[e.jsx(A,{as:"h3",size:"sm",id:"eln-pubchem-lookup-heading",mb:1,children:"Look up in PubChem"}),e.jsxs(t,{fontSize:"sm",color:z,mb:3,children:[K??"PubChem is the only outside source this notebook consults, and only when you press the button."," ","What you type below is sent to PubChem. Nothing else about this experiment leaves ChemIllusion."]}),e.jsxs(w,{as:"form",gap:3,wrap:"wrap",align:"flex-end",onSubmit:n=>{n.preventDefault(),I()},children:[e.jsxs(P,{maxW:"40",isRequired:!0,children:[e.jsx(F,{fontSize:"sm",htmlFor:"eln-pubchem-kind",children:"Look up by"}),e.jsx(se,{id:"eln-pubchem-kind",size:"sm",value:u,onChange:n=>J(n.target.value),children:ve.map(n=>e.jsx("option",{value:n,children:le[n]},n))})]}),e.jsxs(P,{flex:"1",minW:"52",isRequired:!0,children:[e.jsxs(F,{fontSize:"sm",htmlFor:"eln-pubchem-query",children:[le[u]," to send"]}),e.jsx(ne,{id:"eln-pubchem-query",size:"sm",value:L,onChange:n=>U(n.target.value),placeholder:u==="name"?"e.g. acetophenone":""})]}),e.jsx(d,{type:"submit",size:"sm",colorScheme:"blue",isLoading:S,children:"Look up"})]}),e.jsxs(m,{"aria-live":"polite",mt:3,children:[S&&e.jsx(t,{fontSize:"sm",color:z,children:"Asking PubChemâ¦"}),h&&e.jsxs(g,{status:"warning",borderRadius:"md",fontSize:"sm",children:[e.jsx(b,{}),h]}),(l==null?void 0:l.length)===0&&e.jsxs(g,{status:"info",borderRadius:"md",fontSize:"sm",children:[e.jsx(b,{}),"PubChem has no match for that. You can still register the compound â a PubChem entry is not required."]}),l&&l.length>0&&e.jsxs(j,{spacing:3,mt:1,children:[e.jsx(ue,{value:C,onChange:R,children:e.jsx(j,{as:"fieldset",spacing:2,role:"radiogroup","aria-label":"PubChem candidates",children:l.map(n=>e.jsxs(m,{borderWidth:"1px",borderRadius:"md",p:2,children:[e.jsxs(he,{value:n.cid,size:"sm",children:[e.jsxs(t,{as:"span",fontWeight:"semibold",children:["CID ",n.cid]}),n.iupacName?` â ${n.iupacName}`:""]}),e.jsxs(j,{spacing:0,pl:6,mt:1,fontSize:"xs",color:z,children:[n.molecularFormula&&e.jsxs(t,{children:["Formula (PubChem): ",n.molecularFormula]}),(n.isomericSmiles??n.canonicalSmiles)&&e.jsxs(t,{noOfLines:2,children:["SMILES:"," ",e.jsx(Q,{fontSize:"xs",children:n.isomericSmiles??n.canonicalSmiles})]}),n.synonyms.length>0&&e.jsxs(t,{noOfLines:1,children:["Also called: ",n.synonyms.slice(0,3).join(", ")
1]})]})]},n.cid))})}),o&&e.jsxs(m,{borderWidth:"1px",borderRadius:"md",p:3,children:[e.jsxs(t,{fontSize:"sm",fontWeight:"semibold",mb:1,children:["Take from CID ",o.cid]}),e.jsx(t,{fontSize:"xs",color:z,mb:2,children:"Only what you tick is stored with a PubChem citation. Formula and exact mass are always computed here from the structure, so they are never cited to PubChem."}),e.jsxs(j,{spacing:1,children:[e.jsxs(te,{size:"sm",isChecked:r&&!!c,isDisabled:!c,onChange:n=>k(n.target.checked),children:["Structure (SMILES)",c?"":" â not provided by PubChem"]}),e.jsxs(te,{size:"sm",isChecked:q&&!!p,isDisabled:!p,onChange:n=>_(n.target.checked),children:["Preferred name",p?` (${p})`:" â not provided by PubChem"]})]}),e.jsx(d,{mt:3,size:"sm",colorScheme:"blue",onClick:E,children:"Use these values"})]})]})]})]})}function Fe(f){return Object.keys(f.propertyProvenance??{}).length>0}function Le(){const[f,T]=i.useState(null),[D,K]=i.useState([]),[u,J]=i.useState("all"),[L,U]=i.useState(null),[S,$]=i.useState(!1),[h,y]=i.useState(""),[l,v]=i.useState(""),[C,R]=i.useState(""),[r,k]=i.useState(null),[q,_]=i.useState(!1),[H,z]=i.useState(!1),[o,c]=i.useState(null),[p,I]=i.useState(null),[E,N]=i.useState(!1),[n,a]=i.useState(null),[V,Y]=i.useState([]),[W,Z]=i.useState(null),ie=M("white","gray.800"),X=M("gray.200","gray.700"),B=M("gray.600","gray.300"),ee=i.useCallback(async()=>{U(null);try{const s=u==="all"?null:Number(u);T(await fe(s))}catch(s){T([]),U(s instanceof G?s.message:"Could not load the compound registry.")}},[u]);i.useEffect(()=>{ee()},[ee]),i.useEffect(()=>{ke().then(K).catch(()=>K([]))},[]),i.useEffect(()=>{Se().then(Z).catch(()=>Z(null))},[]);const ce=s=>{y(s),k(null),a(null),Y([]),I(null)},de=s=>{s.smiles&&y(s.smiles),s.preferredName&&v(s.preferredName),a(s.cid),Y(s.acceptedFields),k(null),N(!1),I(`Filled from PubChem CID ${s.cid}. Check the identity before registering.`)},me=async()=>{if(!h.trim()){c("Enter a structure first.");return}_(!0),c(null);try{k(await ye(h.trim()))}catch(s){k(null),c(s instanceof G?s.message:"That structure could not be read.")}finally{_(!1)}},re=async s=>{z(!0),c(null);try{const x=await Ce({smiles:h.trim(),preferredName:l.trim()||null,researchProjectId:C?Number(C):null,pubchemCid:n,pubchemAcceptedFields:n?V:[],reuseExisting:s});I(s?`Using the compound you already had: ${x.preferredName??x.canonicalSmiles}.`:`Registered ${x.preferredName??x.canonicalSmiles}.`),x.libraryScale&&Z(x.libraryScale),y(""),v(""),k(null),a(null),Y([]),await ee()}catch(x){c(x instanceof G?x.message:"The compound could not be registered.")}finally{z(!1)}};return e.jsxs(pe,{maxW:"4xl",py:8,children:[e.jsx(d,{as:O,to:"/eln",variant:"link",size:"sm",colorScheme:"blue",mb:3,children:"â ELN Notebook"}),e.jsxs(w,{justify:"space-between",align:"baseline",gap:3,wrap:"wrap",mb:2,children:[e.jsx(A,{as:"h1",size:"lg",children:"Compounds"}),e.jsx(d,{as:O,to:"/eln/samples",size:"sm",variant:"outline",colorScheme:"blue",children:"Samples"})]}),e.jsx(t,{mb:6,color:B,children:"A compound is a chemical identity â one substance, however many times you make it. Physical material lives under it as samples. Registering a compound writes nothing to any experiment's record."}),L&&e.jsxs(g,{status:"warning",mb:4,borderRadius:"md",children:[e.jsx(b,{}),L]}),(W==null?void 0:W.userMessage)&&e.jsxs(g,{status:W.phase==="approaching"?"info":"warning",mb:4,borderRadius:"md",children:[e.jsx(b,{}),W.userMessage]}),e.jsxs(m,{as:"section","aria-labelledby":"eln-register-heading",mb:8,children:[e.jsx(d,{size:"sm",colorScheme:"blue",onClick:()=>$(s=>!s),"aria-expanded":S,"aria-controls":"eln-register-form",mb:S?3:0,children:S?"Close":"Register a compound"}),e.jsx(oe,{in:S,animateOpacity:!0,children:e.jsxs(m,{id:"eln-register-form",bg:ie,borderWidth:"1px",borderColor:X,borderRadius:"md",p:4,children:[e.jsx(A,{as:"h2",size:"sm",id:"eln-register-heading",mb:3,children:"Register a compound"}),e.jsxs(j,{spacing:3,children:[e.jsxs(P,{isRequired:!0,children:[e.jsx(F,{fontSize:"sm",htmlFor:"eln-compound-smiles",children:"Structure (SMILES)"}),e.jsx(ne,{id:"eln-compound-smiles",size:"sm",value:h,onChange:s=>ce(s.target.value),placeholder:"e.g. CC(=O)c1ccccc1"})]}),e.jsxs(P,{children:[e.jsx(F,{fontSize:"sm",htmlFor:"eln-compound-name",children:"Preferred name"}
1),e.jsx(ne,{id:"eln-compound-name",size:"sm",value:l,onChange:s=>v(s.target.value),placeholder:"What you call it in the lab"})]}),e.jsxs(P,{children:[e.jsx(F,{fontSize:"sm",htmlFor:"eln-compound-project",children:"Research project"}),e.jsxs(se,{id:"eln-compound-project",size:"sm",value:C,onChange:s=>R(s.target.value),children:[e.jsx("option",{value:"",children:"Unassigned"}),D.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]})]}),e.jsxs(m,{children:[e.jsx(d,{size:"xs",variant:"outline",colorScheme:"blue",onClick:()=>N(s=>!s),"aria-expanded":E,"aria-controls":"eln-compound-lookup",children:E?"Hide PubChem lookup":"Look up in PubChem"}),e.jsx(oe,{in:E,animateOpacity:!0,children:e.jsx(m,{id:"eln-compound-lookup",mt:3,children:e.jsx(Pe,{initialQuery:h.trim(),initialKind:h.trim()?"smiles":"name",onAccept:de,helpText:"Fill the structure and name from a PubChem record, with the CID stored as the citation."})})})]}),n&&e.jsxs(t,{fontSize:"xs",color:B,children:["Will be stored citing PubChem CID ",n," for:"," ",V.length>0?V.join(", "):"nothing","."]}),p&&e.jsxs(g,{status:"info",borderRadius:"md",fontSize:"sm",children:[e.jsx(b,{}),p]}),o&&e.jsxs(g,{status:"error",borderRadius:"md",fontSize:"sm",children:[e.jsx(b,{}),o]}),e.jsx(w,{gap:2,wrap:"wrap",children:e.jsx(d,{size:"sm",colorScheme:"blue",variant:"outline",isLoading:q,onClick:()=>void me(),children:"Check identity"})}),r&&e.jsxs(m,{borderWidth:"1px",borderColor:X,borderRadius:"md",p:3,children:[e.jsx(A,{as:"h3",size:"xs",mb:2,children:"Identity, computed here from the structure"}),e.jsxs(j,{spacing:0,fontSize:"sm",children:[e.jsxs(t,{children:["Canonical SMILES: ",e.jsx(Q,{fontSize:"xs",children:r.canonicalSmiles})]}),r.molecularFormula&&e.jsxs(t,{children:["Formula: ",r.molecularFormula]}),r.molecularWeight!=null&&e.jsxs(t,{children:["Molecular weight: ",r.molecularWeight.toFixed(3)," g/mol"]}),r.inchikey&&e.jsxs(t,{children:["InChIKey: ",e.jsx(Q,{fontSize:"xs",children:r.inchikey})]})]}),r.hasUnspecifiedStereo&&e.jsxs(g,{status:"info",mt:2,borderRadius:"md",fontSize:"sm",children:[e.jsx(b,{}),"This structure leaves stereochemistry unspecified. That is allowed â but two runs drawn this way cannot be told apart later."]}),e.jsx(xe,{my:3}),r.matchKind==="none"&&e.jsxs(e.Fragment,{children:[e.jsx(t,{fontSize:"sm",mb:2,children:"Nothing in your registry matches this. It will be a new compound."}),e.jsx(d,{size:"sm",colorScheme:"blue",isLoading:H,onClick:()=>void re(!1),children:"Register compound"})]}),r.matchKind==="exact"&&e.jsxs(e.Fragment,{children:[e.jsxs(g,{status:"info",borderRadius:"md",fontSize:"sm",mb:2,children:[e.jsx(b,{}),r.matchReason]}),e.jsxs(w,{gap:2,wrap:"wrap",children:[e.jsx(d,{size:"sm",colorScheme:"blue",isLoading:H,onClick:()=>void re(!0),children:"Use the existing compound"}),r.matchCompoundId!=null&&e.jsx(d,{as:O,to:`/eln/compound/${r.matchCompoundId}`,size:"sm",variant:"outline",colorScheme:"blue",children:"Open it"})]})]}),r.matchKind==="ambiguous"&&e.jsxs(e.Fragment,{children:[e.jsxs(g,{status:"warning",borderRadius:"md",fontSize:"sm",mb:2,children:[e.jsx(b,{}),r.matchReason]}),e.jsx(t,{fontSize:"sm",color:B,children:"Specify the stereochemistry in the structure and check again, or open the existing compound if it is the same substance. Registering past an ambiguous match would merge two substances on a guess."}),r.matchCompoundId!=null&&e.jsx(d,{as:O,to:`/eln/compound/${r.matchCompoundId}`,size:"sm",mt:2,variant:"outline",colorScheme:"blue",children:"Open the existing compound"})]})]})]})]})})]}),e.jsxs(w,{justify:"space-between",align:"baseline",gap:3,wrap:"wrap",mb:3,children:[e.jsx(A,{as:"h2",size:"md",children:"Registered compounds"}),e.jsxs(P,{maxW:"60",display:"flex",alignItems:"center",gap:2,children:[e.jsx(F,{fontSize:"sm",htmlFor:"eln-compound-filter",mb:0,whiteSpace:"nowrap",children:"Project"}),e.jsxs(se,{id:"eln-compound-filter",size:"sm",value:u,onChange:s=>J(s.target.value),children:[e.jsx("option",{value:"all",children:"All projects"}),D.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]})]})]}),f===null?e.jsxs(w,{align:"center",gap:2,children:[e.jsx(ge,{size:"sm"}),e.jsx(t,{fontSize:"sm",children:"Loading compoundsâ¦"})]}):f.length===0?e.jsx(t,{color:B,children:"No compounds registered yet. Register one above, or register an experiment's product from its page."}):e.jsx(j,{spacing:3,as:"ul",listStyleType:"none",m:0,p:0,children:f.map(s=>e.jsx(ze,{as:"li",bg:ie,borderWidth:"1px",borderColor:X,borderRadius:"md",p:3,children:e.jsxs(w,{justify:"space-between",gap:3,wrap:"wrap",align:"baseline",children:[e.jsxs(m,{minW:"0",children:[e.jsx(we,{as:O,to:`/eln/compound/${s.id}`,children:e.jsx(t,{fontWeight:"semibold",children:s.preferredName??"Unnamed compound"})}),e.jsx(Q,{fontSize:"xs",wordBreak:"break-all",children:s.canonicalSmiles}),e.jsxs(t,{fontSize:"xs",color:B,mt:1,children:[s.molecularFormula??"formula unavailable",s.molecularWeight!=null?` · ${s.molecularWeight.toFixed(2)} g/mol`:""]})]}),e.jsxs(j,{spacing:1,align:"flex-end",children:[e.jsxs(ae,{colorScheme:"blue",children:[s.sampleCount," sample",s.sampleCount===1?"":"s"]}),s.pubchemCid&&Fe(s)&&e.jsxs(ae,{colorScheme:"yellow",children:["PubChem CID ",s.pubchemCid]})]})]})},s.id))})]})}function $e(){return e.jsx(be,{children:e.jsx(Le,{})})}
1export{$e as default,Fe as hasPubChemProvenance};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.