1import{r as o,j as f}from"./vendor-react.l8Rnuy9A.bundle.js";import{e as $}from"./mrcFormat.Bil4OPw6.bundle.js";import{bD as F,bE as N}from"./index.entry.BuJoZZ4t.bundle.js";import{a as T}from"./escapeHtml.CEV7QrD-.bundle.js";import{C as q,f as z,n as C,h as B}from"./mw-viewer.BW465abQ.bundle.js";import"./vendor-antd.Yb1N6ZFd.bundle.js";import"./vendor-sentry.CM8pNoEG.bundle.js";import"./tslib.es6.BKEKvuId.bundle.js";import"./Checkbox.BLDeMFY5.bundle.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"[email protected]+71849ab"};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="be1095bf-3fd9-4d00-92cf-ab33ba3a840e",e._sentryDebugIdIdentifier="sentry-dbid-be1095bf-3fd9-4d00-92cf-ab33ba3a840e")}catch{}})();const I=o.createContext(null),W=({children:e,value:t})=>f.jsx(I.Provider,{value:t,children:e}),Y=e=>{const t=e.split(/[_\s]+/).filter(Boolean),s=(t[0]??"").toUpperCase();if(t.length>=3){const i=parseInt(t[2],10);return{chemId:s,asymId:t[1],seqId:Number.isFinite(i)?i:void 0}}if(t.length===2){const i=t[1].match(/^([A-Za-z]+)(\d+)$/);return i?{chemId:s,asymId:i[1],seqId:parseInt(i[2],10)}:/^\d+$/.test(t[1])?{chemId:s}:{chemId:s,asymId:t[1]}}return{chemId:s}},V=e=>e?{focusing:!0,residue:Y(e)}:{focusing:!1,residue:null},x={container:{display:"flex",height:"var(--viewer-height)",width:"100%",margin:0,padding:0,overflow:"hidden",borderRadius:"var(--viewer-radius)"},molstarSection:{flex:1,height:"var(--viewer-height)",display:"flex",flexDirection:"column",position:"relative",overflow:"hidden"},molstarContainer:{flex:1,width:"100%",position:"relative"}};function k(e,t){const s=o.useRef([]),i=t?.map(a=>`${a.type}:${a.url}`).join("|")??"",r=o.useMemo(()=>t,[i]);o.useEffect(()=>{if(e){for(const a of s.current)e.removeOverlay(a).catch(()=>{});if(s.current=[],!!r?.length)return(async()=>{for(const a of r)try{const{root_ref:l}=await e.loadOverlay(a);l&&s.current.push(l)}catch(l){console.warn("Failed to load overlay:",l)}})(),()=>{for(const a of s.current)e.removeOverlay(a).catch(()=>{});s.current=[]}}},[r,e])}const Z=({overlays:e})=>(k(o.useContext(I),e),null),_=({cacheableResource:e,overlays:t,assetType:s="EMMAP",onError:i,volumeOptions:r,isoValue:a,focusLigandKey:l})=>{const n=o.useContext(I),y=o.useRef(null);return o.useEffect(()=>{let d=!1;const m={value:e.url,cacheKey:e.cacheKey,label:r?.label,type:s};return(async()=>{try{if(s==="MODEL"){const{focusing:h,residue:g}=V(l),{root_ref:p}=await n.upload_mmcif_structure(m,{skipCameraReset:h});if(d)return;if(g&&n){try{await n.addInteractionsToStructure(p)}catch{}if(d)return;try{n.focusResidue(g.chemId,g.asymId,g.seqId)}catch{}}}else{const h=r?{color:r.color,alpha:r.alpha,isoValue:r.isoValue,isMask:r.isMask,skipCameraReset:r.skipCameraReset,contours:r.contours,dataOnly:r.dataOnly}:a!==void 0?{isoValue:a}:void 0,{root_ref:g,repr_ref:p}=await n.load_emdb(m,h);if(d)return;r?.onVolumeLoaded?.(g,p),r&&(y.current=g),(r?.isMask||r?.isOverlayVolume)&&n&&(z(n.plugin,{rootRef:g,reprRef:p,label:r.label,control:r.isMask?"opacity":"iso"}),C(n.plugin))}}catch(h){if(d)return;i?.(h)}})(),()=>{d=!0,(r?.isMask||r?.isOverlayVolume)&&n&&y.current&&(B(n.plugin,y.current),C(n.plugin)),r&&n&&y.current&&(n.remove_structure(y.current).catch(()=>{}),y.current=null)}},[]),k(n,t),null},S=e=>{const[t,s]=o.useState(e?.url?null:""),[i,r]=o.useState(null),a=o.useRef(null);return o.useEffect(()=>{if(!e?.url){s("");return}s(null),r(null);const l=new AbortController,{url:n,cacheKey:y}=e;return(async()=>{if(y&&F())try{if(await N(y)&&!l.signal.aborted){s(n);return}}catch{}try{const d=await $(n,l.signal,r);if(l.signal.aborted)return;const m=URL.createObjectURL(d);a.current=m,s(m)}catch(d){if(d.name==="AbortError")return;s(n)}})(),()=>{l.abort(),a.current&&(URL.revokeObjectURL(a.current),a.current=null)}},[e?.url,e?.cacheKey]),{resolvedUrl:t,downloadProgress:i}},G=({vol:e,progressKey:t,onProgress:s,skipCameraReset:i})=>{const{resolvedUrl:r,downloadProgress:a}=S(e.cacheableResource),l=t,n=r===null;return o.useEffect(()=>(s(l,n?a:void 0),()=>s(l,void 0)),[l,n,a,s]),r?f.jsx(_,{cacheableResource:{...e.cacheableResource,url:r},assetType:e.assetType,volumeOptions:{color:e.color,alpha:e.alpha,isoValue:e.isoValue,isMask:e.isMask,label:e.label,contours:e.contours,onVolumeLoaded:e.onVolumeLoaded,skipCameraReset:i,isOverlayVolume:e.isOverlayVolume,dataOnly:e.dataOnly}}):null},ae=({cacheableResource:e,overlays:t,assetType:s,onError:i,additionalVolumes:r,volumeIsoValue:a,focusLigandKey:l,wireframe:n,onPluginReady:y})=>{const d=o.useRef(null),m=o.useRef(null),[h,g]=o.useState(null),p=o.useRef(null),{resolvedUrl:v,downloadProgress:D}=S(e),L=o.useMemo(()=>{const u=new Map;return(r??[]).map(c=>{const b=c.cacheableResource.cacheKey||c.cacheableResource.url,w=u.get(b)??0;return u.set(b,w+1),{vol:c,key:w===0?b:`${b}#${w}`}})},[r]),[M,U]=o.useState({}),K=o.useCallback((u,c)=>{U(b=>{if(c===void 0){if(!(u in b))return b;const w={...b};return delete w[u],w}return{...b,[u]:c}})},[]);o.useEffect(()=>((async()=>
1{if(m.current){const c=new q;await c.init(m.current,{wireframe:n,manualReset:V(l).focusing}),p.current=c,g(c),y?.(c)}})(),()=>{p.current?.dispose()}),[]),o.useEffect(()=>{const u=d.current;if(!u)return;const c=new ResizeObserver(()=>{window.dispatchEvent(new Event("resize"))});return c.observe(u),()=>c.disconnect()},[]);const R=v&&e?{...e,url:v}:e,E=!!e?.url&&v===null,P=Object.keys(M),A=E||P.length>0,j=P.map(u=>M[u]).filter(u=>u!==null),O=E?D:j.length>0?Math.min(...j):null;return f.jsx(W,{value:h,children:f.jsxs("div",{ref:d,style:x.container,children:[R?.url&&h&&v&&f.jsx(_,{cacheableResource:R,overlays:t,assetType:s,onError:i,isoValue:a,focusLigandKey:l},R.cacheKey||R.url),h&&!R?.url&&f.jsx(Z,{overlays:t}),h&&L.map(({vol:u,key:c})=>f.jsx(G,{vol:u,progressKey:c,onProgress:K,skipCameraReset:!!l},c)),f.jsxs("div",{style:x.molstarSection,children:[A&&f.jsx(T,{percent:O}),f.jsx("div",{style:x.molstarContainer,children:f.jsx(H,{ref:m})})]})]})})},H=o.forwardRef((e,t)=>f.jsx("div",{ref:t,style:{width:"100%",height:"100%",position:"relative",margin:0,padding:0}}));export{ae as default};
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.